Files
karl/src/generators/reflector_generator.cpp
T
csendlinger 0a843f0a4c Electric field only used at the position at the beginning of the timestep,
the magnetic field is not changed since its value does not depend on the
particles;
Added a reflector for both ends of the cylinder
2026-01-27 14:19:44 +01:00

37 lines
1.4 KiB
C++
Executable File

#include "generators/reflector_generator.h"
#include "simulation/errors.h"
namespace generator {
std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
const json_path& path_to_reflector) {
if (parameter.jsonObjectFromBase(
json_path_append(path_to_reflector, {"ReflectorDPS"}))) {
#ifdef debug_level2
DEBUG_LEVEL_2("Create reflector: ReflectorDPS");
#endif
double position_z = json_read_length(
parameter.jsonObjectFromBase(json_path_append(
path_to_reflector, {"ReflectorDPS", "position_z"})),
"m");
return std::shared_ptr<Reflector>(new ReflectorDPS(position_z));
} else if (parameter.jsonObjectFromBase(
json_path_append(path_to_reflector, {"LongitudinalReflector"}))) {
double height = json_read_length(
parameter.jsonObjectFromBase(
json_path_append(path_to_reflector, {"LongitudinalReflector", "height"})), "m");
return std::shared_ptr<Reflector>(new LongitudinalReflector(height));
} else if (parameter.jsonObjectFromBase(
json_path_append(path_to_reflector, {"NoReflector"}))) {
#ifdef debug_level2
DEBUG_LEVEL_2("Create reflector: NoReflector");
#endif
return std::shared_ptr<Reflector>(new NoReflector());
} else {
ERROR("This reflector is not implemented.");
return nullptr;
}
}
}; // namespace generator