#include "generators/energy_distribution_function_generator.h" #include #include "simulation/errors.h" namespace generator { std::shared_ptr 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(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( 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( new Constant(constant_eV)); } ERROR("This Energy Distribution is not implemented."); return nullptr; } }; // namespace generator