Files
karl/include/simulation/energy_distribution.h
2024-12-04 17:15:04 +01:00

52 lines
1.7 KiB
C++
Executable File

#ifndef ENERGY_DISTRIBUTION_H
#define ENERGY_DISTRIBUTION_H
#include <functional>
#include <random>
// class defining the minimum requirements of an EnergyDistributionFunction child class
class EnergyDistributionFunction {
public:
// draw an energy value using the provided engine in eV
virtual double rollEnergy(std::mt19937* engine) = 0;
};
// class for drawing an energy value from the Fermi spectrum of the Tritium beta decay
// using the rejection method
class TritiumBetaDecay : public EnergyDistributionFunction {
public:
// Constructor: initializes the random distributions
TritiumBetaDecay();
// draw an energy (eV) from the Fermi spectrum of the Tritium beta decay
double rollEnergy(std::mt19937* engine);
private:
const std::function<double(double)> tritium_spectrum_;
std::uniform_real_distribution<double> x_distribution_;
std::uniform_real_distribution<double> y_distribution_;
};
// class for drawing an energy value from the Maxwell Boltzmann energy distribution
class MaxwellBoltzmann : public EnergyDistributionFunction {
public:
// initialize the distribution with the temperature (in K)
MaxwellBoltzmann(double temperature_K);
// draw an energy (in eV) from the Maxwell Boltzmann energy distribtion
double rollEnergy(std::mt19937* engine);
private:
std::gamma_distribution<double> distribution_;
};
// class for returnig a constant energy value
class Constant : public EnergyDistributionFunction {
public:
// Constructor: takes the energy value (in eV) that will be returned later
Constant(double constant_eV);
// return the energy (in eV) set at construction of the object
double rollEnergy(std::mt19937* engine);
private:
const double constant_eV_;
};
#endif /* ENERGY_DISTRIBUTION_H */