36 lines
1.5 KiB
C++
Executable File
36 lines
1.5 KiB
C++
Executable File
#include "generators/energy_distribution_function_generator.h"
|
|
|
|
#include <string>
|
|
#include "simulation/errors.h"
|
|
|
|
namespace generator {
|
|
|
|
std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
|
Parameter& parameter,
|
|
const json_path& path_to_function) {
|
|
json_t* object = parameter.jsonObjectFromBase(path_to_function);
|
|
|
|
if (json_object_by_path(object, {"TritiumBetaDecay"})) {
|
|
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
|
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
|
|
|
} else if (json_object_by_path(object, {"MaxwellBoltzmann"})) {
|
|
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
|
double temperature_K = json_double(json_object_by_path(
|
|
object, {"MaxwellBoltzmann", "Temperature", "value"}));
|
|
DEBUG_LEVEL_3("with temperature: " + std::to_string(temperature_K) + " K");
|
|
return std::shared_ptr<EnergyDistributionFunction>(
|
|
new MaxwellBoltzmann(temperature_K));
|
|
} else if (json_object_by_path(object, {"Constant"})) {
|
|
DEBUG_LEVEL_2("Creating energy distribution function: Constant.");
|
|
double constant_eV = json_double(
|
|
json_object_by_path(object, {"Constant", "constant", "value"}));
|
|
DEBUG_LEVEL_3("with constant: " + std::to_string(constant_eV) + " eV");
|
|
return std::shared_ptr<EnergyDistributionFunction>(
|
|
new Constant(constant_eV));
|
|
}
|
|
ERROR("This Energy Distribution is not implemented.");
|
|
return nullptr;
|
|
}
|
|
|
|
}; // namespace generator
|