Many, many more comments

This commit is contained in:
2024-12-04 17:15:04 +01:00
parent 8696517336
commit 03854339ca
100 changed files with 1702 additions and 49 deletions
+51
View File
@@ -9,12 +9,63 @@
#include "simulation/position_binning.h"
namespace generator {
// return a CylinderBinning object as described in the json-object object
// object has to contain a json-object "CylinderBinning"
// "CylinderBinning" has to consist of:
// - json-object "Radial" consisting of a json-double (later cast to an integer) "NumberOfBins"
// and a json-object "MaxRadius", which has to follow the form described in "json_read_length"
// ("simulation/jansson_additionals.h")
// - json-object "Longitudinal" consisting of a json-double (later cast to an integer) "NumberOfBins"
// and a json-object "MaxLength", which has to follow the form described in "json_read_length"
// ("simulation/jansson_additionals.h")
// - json-object "Azimuthal" consisting of a json-double (later cast to an integer) "NumberOfBins"
// example:
// "object" : {
// "CylinderBinning": {
// "Radial": {"NumberOfBins": 1, "MaxRadius" : {...}},
// "Azimuthal": {"NumberOfBins": 1},
// "Longitudinal": {"NumberOfBins": 1, "MaxLength" : {...}}
// }
// }
CylinderBinning buildPositionBinning(json_t* object);
// return a CylinderBinning object described by the json-object in parameter at the
// path "path_to_binning"
// if a json-array called "CreateSameAs" exists: has to consist of the path to the PositionBinning
// json-object that should be used (e.g. ["Object1", "Object2", ..., "PositionBinning"],
// "Object1" has to be located in the root object)
// otherwise same specifications as "buildPositionBinning"
CylinderBinning buildPositionBinningIncludingRedirection(
Parameter& parameter,
json_path& path_to_binning);
// return a EnergyBinning object as defined in the json-object object
// object has to contain:
// - a json-string "Type", defining the type of the EnergyBinning (right now only "Logarithmic" is valid)
// - a json-double "NumberOfBins", defining the number of bins for the binning (will be cast to an int)
// - a json-object "MinEnergy" and a json-object "MaxEnergy", defining the lower and upper
// value for the binning. Both objects have to follow the structure described in
// "json_read_energy" ("simulation/jansson_additionals.h")
//
// example:
// "object": {
// "Type": "Logarithmic",
// "NumberOfBins": 3,
// "MinEnergy": {
// "value": 1,
// "unit": eV
// },
// "MaxEnergy": {
// "value": 1000,
// "unit": eV
// }
// }
EnergyBinning buildEnergyBinning(json_t* object);
// return a EnergyBinning object described by the json-object in parameter at the
// path "path_to_binning"
// if a json-array called "CreateSameAs" exists: has to consist of the path to the EnergyBinning
// json-object that should be used (e.g. ["Object1", "Object2", ..., "EnergyBinning"],
// "Object1" has to be located in the root object)
// otherwise same specifications as "buildEnergy"
EnergyBinning buildEnergyBinningIncludingRedirection(
Parameter& parameter,
json_path& path_to_binning);
@@ -9,6 +9,11 @@
#include "simulation/timer.h"
namespace generator {
// return a shared_ptr to a CurrentCollector object, defined by the json-object
// at "path_to_collector" in the Parameter file using the provied Timer object
// the json-object has to contain a json-object called "PositionBinning",
// wich has to follow the structure described in "buildPositionBinning"
// (in "generators/binning_generator.h")
std::shared_ptr<CurrentCollector> buildCurrentCollector(
Parameter& parameter,
const json_path& path_to_collector,
@@ -8,8 +8,16 @@
namespace generator {
// return a shared_ptr to a ConstantDensityField object described by the give json-object
// object has to contain a json-object "ScalarField", that has to follow the form
// described in "buildScalarField" (defined in "generators/scalar_field_generator.h")
std::shared_ptr<ConstantDensityField> buildConstantDensityField(json_t* object);
// return a shared_ptr to a DynamicDensityField object described by the json-object
// at the give path in the Parameter object which uses the given Timer object
// the json-object at path_to_field has to contain two json-objects called
// "PositionBinning" and "EnergyBinning", which are described in "buildPositionBinning"
// and "buildEnergyBinning" respectivley (both defined in "generators/binning_generator.h")
std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
Parameter& parameter,
const json_path& path_to_field,
@@ -7,10 +7,21 @@
namespace generator {
// create a shared_ptr to a DriftVelocity object described by the json-object in parameter at the
// path "path_to_drift_velocity"
// has to consist of a json-object "VectorField" or "null"
// if "VectorField" is specified: has to follow the form described by "buildVectorField" (in "generators/vector_field_generator.h")
// if "null" is specified: nothing more has to be specified, simply returns a nullptr
// (examples in "simulation_config/drift_velocity_examples.json")
std::shared_ptr<DriftVelocity> buildDriftVelocity(
Parameter& parameter,
const json_path& path_to_drift_velocity);
// create a shared_ptr to a DriftVelocity object described by the json-object in parameter at the
// path "path_to_drift_velocity"
// if a json-array called "CreateSameAs" exists: has to consist of the path to the DriftVelocity
// json-object that should be used (e.g. ["Object1", "Object2", ..., "DriftVelocity"], has to start at the root)
// otherwise same specifications as "buildDriftVelocity"
std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
Parameter& parameter, const json_path& path_to_drift_velocity);
};
@@ -6,8 +6,15 @@
namespace generator {
// create an ElectricField object from a json_t pointer to an json object
// defining the electric field
// has to consist of two json-objects "Background" and "Dynamic" defining the vector fields
// as described in "generators/vector_field_generator.h" (function: "buildVectorField")
std::shared_ptr<ElectricField> electricField(json_t* object);
// create an ElectricField object from the given Parameter object
// json file has to have a json object called "ElectricField" directly in the json root object
// of the parameter file
std::shared_ptr<ElectricField> electricField(Parameter& parameter);
}; // namespace generator
@@ -9,6 +9,22 @@
namespace generator {
// return a shared_ptr to an EnergyDistributionFunction object at the json-object
// with path "path_to_function" (from root) in the Parameter object
// has to consist of a json-object called either "TritiumBetaDecay", "MaxwellBoltzmann" or "Constant"
// if "TritiumBetaDecay" is specified:
// - does not have to contain anything (returns a TritiumBetaDecay object)
//
// if "MaxwellBoltzmann" is specified:
// - has to contain a json-object "Temperature", which has to contain a json-double "value"
// that specified the temperature (in K) for the Maxwell-Boltzmann distribution (returns a MaxwellBoltzmann object)
//
// if "Constant" is specified:
// - has to contain a json-object "constant", which has to contain a json-double "value", which
// specifies the constant energy in eV (returns a Constant object)
//
// (examples in "simulation_config_energy_distribution_function_examples.json"; definition of the
// objects in "simulatoin/energy_distribution.h")
std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
Parameter& parameter,
const json_path& path_to_function);
+30 -1
View File
@@ -6,8 +6,37 @@
#include "jansson.h"
namespace generator {
// return a function1D specified by the json object "object"
// consists of a json-object called either "Constant", "PiecewiseLinear", "PiecewiseLinearFromFile" or an json-array called "Product"
// if "Constant" is specified:
// - has to contain a json-double called "constant" specifying the value of the constant the function should return
//
// if "PiecewiseLinear" is specified:
// - has to contain two json_arrays "xValues" and "yValues" specifying the point between which should be linearly interpolated
// - has to contain a json-double "prefactor", with which "yValues" will be scaled
//
// if "PiecewiseLinearFromFile" is specified:
// - has to contain a json-object "PathToH5" as described in "generators/vector_field_generator.h"
// - two json-strings "xValuesKey" and "yValuesKey" specifying the path of the x- and y-values in the hdf5 file
// - a json-double "prefactor" which scales the read y-values
//
// if "Product" is specified:
// - has to consist of an arbitrary number of json-objects following the format described for this function
//
// (examples can be found in "simulation_config/function_examples.json")
std::function<double(double)> function1D(json_t* object);
// return a function3D specified by the json object "object"
// has to consist of a json-object called either "Constant3D" or "Product"
//
// if "Constant3D" is specified:
// - has to contain a json-double "constant", defining the constant value that should be returned
//
// if "Product" is specified:
// - has to contain three json-objects called "fi", "fk" and "fj" defining the
// functional form in x,y and z direction; objects have to follow the description
// of "function1D"
//
// (examples can be found in "simulation_config/function_examples.json")
std::function<double(double, double, double)> function3D(json_t* object);
}; // namespace generator
+4
View File
@@ -9,6 +9,10 @@
namespace generator {
// return a shared_ptr to a Geometry object described by the json-object at the given path in the Parameter object
// the json-object at the path has to contain a json-object "Cylinder". This json-object has to contain:
// two json-objects "Radius" and "Height", which have to follow the form described in "json_read_length"
// ("simulation/jansson_additionals.h")
std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
const json_path& path_to_geometry);
+23
View File
@@ -10,6 +10,29 @@
namespace generator {
// return a shared_ptr to an Injector object described in the Parameter object
// the tracked_species should contain all TrackedSpecie objects that are considered in the simulation
// (background_species is not used)
// Parameter has to have a json-object "Injector" in the root object
// - in "Injector" a json-object "CreatedSpecies" has to exist, which
// consists of one more arbitrarily named json-objects
// these json-objects have to contain:
// - a json-string "TrackedSpecieName", which has to correspond to one
// of the strings used to describe the TrackedSpecies in the "Tracked" json-object of the same Paramter file
// - a json-object "CreationVelocityDistribution" following the description in "generators/velocity_distribution_generator.h"
// - a json-object "EventPositionDistribution" has to exit
// - therein a json-object "ScalarField" has to exist, which describes the distribution from which positions will be drawn (following the
// description in "generators/scalar_field_generator.h")
// - a json-object "DensityLimit", which has to contain
// - a json-double "min", which described the minimal density value of the used density distribution
// - a json-double "max", which described the maximal density value of the used density distribution
// - a json-object "PositionLimits" consisting of three json-object "rPosition", "phiPosition" and "zPosition", which
// all have the same sturcture:
// - a json-double "min", describing the minimum value that a drawn position should have
// - a json-double "max", describing the maximum value that a drawn position should have
// - a json-object "MotherDriftVelocity", which has a form as described in "generators/drift_velocity_generator.h"
//
// (example in "simulation_config/parameter_katrin_example.json")
std::shared_ptr<Injector> buildInjector(
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
tracked_species,
+103
View File
@@ -12,6 +12,61 @@
namespace generator {
// create the interactions specified at the "path_to_insteractions" in the Parameter
// and add them to the given TrackedSpecie specie
// the json-object at "path_to_interactions" has to consist of an arbitrary number
// of arbitrarily named json-objects describing the interaction. These objects have to contain:
// - a json-string "Type" with a value of either: "ElasticScattering", "FreeMovement", "ElectronIonization", "Excitation"
// "Clustering", "ChargeExchange" or "Recombination"
//
// if the Type "ElasticScattering" is specified (for elastic scattering interactions) the additional elements have to be present:
// - a json-object "CrossSection" (as described in "buildTotalCrossSection" function)
// - a json-object "ScatteringAngleDistribution" (as described in "buildScatteringAngleDistribution")
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of either a TrackedSpecie or a BackgroundSpecie)
//
// if the Type "FreeMovement" is specified (for a dummy interaction that does nothing) no additional elements have to be present
//
// if the Type is "ElectronIonization" the additional elements have to be provided:
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of either a TrackedSpecie or a BackgroundSpecie)
// - a json-string "OutgoingElectron", containing the name (given in the json parameter file) of
// a TrackedSpecie
// - a json-string "OutgoingIon", containing the name (given in the json parameter file) of
// a TrackedSpecie
// - a json-string "IonizationModel" with a value of either "JanevNonDiss", "JanevDissToGround" or "JanevDissToFirstExcited"
// - if the value is "IonizationModel": the "eT2_ionization_janev_non_diss" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
// and "OutgoingIon" has to be a T2plus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
// - if the value is "JanevDissToGround": the "eT2_ionization_janev_diss_ground" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
// and "OutgoingIon" has to be a Tplus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
// - if the value is "JanevDissToFirstExcited": the "eT2_ionization_janev_diss_first" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
// and "OutgoingIon" has to be a Tplus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
//
// if the Type is "Excitation" the additiona elements have to be provided:
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of either a TrackedSpecie or a BackgroundSpecie)
// - a json-string "ExcitationState" being one of the names defined in "buildExcitationCrossSection"
//
// if the Type is "Clustering":
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of either a TrackedSpecie or a BackgroundSpecie)
// - a json-string "Product" (being a name of a tracked specie as defined in the json parameter file)
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
//
// if the Type is "ChargeExchange" (right now only if the species for which it's defined is the target with a charge of +1):
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of either a TrackedSpecie or a BackgroundSpecie)
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
//
// if the Type is "Recombination" the additional elements have to be present as well:
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
// of a TrackedSpecie)
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
//
// examples for the usage in a json-file can be found in simulation_config/interactions_examples.json
void addInteractions(
std::shared_ptr<species::TrackedSpecie> specie,
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
@@ -21,17 +76,62 @@ void addInteractions(
Parameter& parameter,
json_path& path_to_interactions);
// returns the cross section function defined in the given json-object
// the json-object has to either contain a json-string "PredefinedFunction", a json-object "1dFunction" or a json-object "ExcitationFunction"
// if the json-string "PredefinedFunction" is defined it has to have a value of one of the following strings:
// - "eT2_elastic_scattering_constant", "eT2_elastic_scattering", "TpT2_elastic_scattering_tabata", "T3pT2_elastic_scattering_tabata",
// "eT2_ionization_janev_diss_ground", "eT2_ionization_janev_diss_first", "TpT2_clustering_radiative_ascendion_pasil",
// "TpT2_clustering_tertiary_ascendion_pasil", "T2pT2_clustering_janev", "T2pT2_charge_exchange_janev", "eT2p_recombination_janev", "eT3p_recombination_janev"
// (further explanations can be found in "interactions/cross_sections.h"; the functions have the same name as the corresponding string listed above)
//
// if the json-object "1dFunction" exists, it has to follow the structure described in "generators/function_generator.h" for function1D
//
// if the json-object "ExcitationFunction" has to exist, this object has to contain a json-string called "ExcitationState",
// which has to be one of the strings defined in "buildExcitationCrossSection"
std::function<double(double)> buildTotalCrossSection(json_t* object);
// return a cross section function depending on two variables (e.g. in-going and out-going particle energies in an ionization)
// has to contain a json-string "PredefinedFunction" with a value of "eT2_ionization_bed"
// (right now the function is only defined but never used)
std::function<double(double, double)> build2DCrossSection(json_t* object);
// return a shared_ptr to a ScatteringAngleDistribution object that is defined by the given json-object
// has to contain a json-object called:
// "Isotropic". This object does not need any elements.
//
// "AngleDistributionFromFile". Has to contain a json-object "PathToH5" following the format as described in "readAbsoluteFilename"
// (defined in "generators/vector_field_generator.h")
//
// "CompositeAngleDistribution". Has to contain a
// - json-object "DeciderEnergy" following the description of "json_read_energy" (defined in "simulation/jansson_additionals.h")
// - two json-objects "LowerDistribution" and "HigherDisribuiton" as defined for this function
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
json_t* object);
// return the value of the excitation energy for the given string defining the final excitation state of the target particle
// possible values for the excitation_state are (the numerical values can be found in the interaction_generatior.cpp file):
// - janev_singlet_B1, janev_singlet_B1prime, janev_singlet_B1primeprime, janev_singlet_C1, janev_singlet_D1,
// janev_singlet_D1prime, janev_singlet_symmetry_forbidden_EF1, janev_singlet_symmetry_forbidden_HHb,
// janev_singlet_symmetry_forbidden_GK1, janev_singlet_symmetry_forbidden_I1, janev_triplet_A3, janev_triplet_B3,
// janev_triplet_C3, janev_triplet_D3, janev_triplet_E3, janev_vibrational_first, janev_vibrational_second,
// england_rotational_j0_to_j2, england_rotational_j1_to_j3
double buildExcitationEnergy(std::string excitation_state);
// return the function for a predefined excitation cross section (see simulation/cross_sections.h)
// defined by the string "excitation_state"
// possible values for the excitation_state are:
// - janev_singlet_B1, janev_singlet_B1prime, janev_singlet_B1primeprime, janev_singlet_C1, janev_singlet_D1,
// janev_singlet_D1prime, janev_singlet_symmetry_forbidden_EF1, janev_singlet_symmetry_forbidden_HHb,
// janev_singlet_symmetry_forbidden_GK1, janev_singlet_symmetry_forbidden_I1, janev_triplet_A3, janev_triplet_B3,
// janev_triplet_C3, janev_triplet_D3, janev_triplet_E3, janev_vibrational_first, janev_vibrational_second,
// england_rotational_j0_to_j2, england_rotational_j1_to_j3
std::function<double(double)> buildExcitationCrossSection(
std::string excitation_state);
// if the string target_name is used as a key in either the map for the TrackedSpecies or
// the map for the BackgroundSpecies returns the corresponding Species
// (the keys in the map are defined by the name given in the json parameter file)
std::shared_ptr<species::Specie> findTarget(
std::string& target_name,
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
@@ -39,6 +139,9 @@ std::shared_ptr<species::Specie> findTarget(
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
background_species);
// if the string target_name is used as a key in either the map for the TrackedSpecies
// returns the corresponding TrackedSpecie
// (the keys in the map are defined by the name given in the json parameter file)
std::shared_ptr<species::TrackedSpecie> findTracked(
std::string& target_name,
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
+9
View File
@@ -7,7 +7,16 @@
namespace generator {
// return a shared_ptr to a DeletionLogger object described by the given json-object
// can contain a json-array or a json-string "Type"
// - if it's a json-array: list the DeletionTypes that should be counted
// during the simulation (json-strings: "wall", "recombination", "max_interactions", "max_time_alive" and "cluster_formation")
// - if it's a json-string: has to have the value "all" and then all DeletionTypes are tracked (see list above)
// - if not present: no DeletionTypes are tracked
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object);
// return a shared_ptr to a DeletionLogger object described at the given path
// in the Parameter object, this object has to contain a json-object "Deletion"
// following the structure in the overload of this function
std::shared_ptr<DeletionLogger> buildDeletionLogger(
Parameter& parameter,
const json_path& path_to_logger);
@@ -6,8 +6,15 @@
namespace generator {
// create an MagneticField object from a json_t pointer to an json object
// defining the magnetic field
// has to consist of a json-objects called "VectorField"
// as described in "generators/vector_field_generator.h" (function: "buildVectorField")
std::shared_ptr<MagneticField> magneticField(json_t* object);
// create an MagneticField object from the given Parameter object
// json file has to have a json object called "MagneticField" directly in the root object
// of the parameter file
std::shared_ptr<MagneticField> magneticField(Parameter& parameter);
}; // namespace generator
+7
View File
@@ -4,20 +4,27 @@
#include <map>
#include "jansson.h"
// defined in "simulation/species.h"
namespace species {
enum class ImplementedSpecies;
};
namespace generator {
// class containing a map of the masses (in kg) to the respective ImplementedSpecies
class SpeciesMasses {
public:
// return the mass of the ImplementedSpecies
static double mass(const species::ImplementedSpecies& species);
private:
static std::map<species::ImplementedSpecies, double> mass_;
};
// return the mass of the specie at the json-object
// has to contain either a json-string "FromParticleType" or a json-double "value"
// if "FromParticleType" is specified, it has to be one of the strings defined in the SpecieAlias class in "generators/species_generator.h"
// if "value" is specified, it has to be the value in (kg)
double buildMass(json_t* object);
}; // namespace generator
+16
View File
@@ -7,6 +7,22 @@
namespace generator {
// return a shared_ptr to a Mover object described at the given path in the Parameter file
// the json-object at path_to_mover has to consist of a json-object called either "Boris", "Drift" or "Euler"
// if "Boris" exists:
// - has to contain a json-object "MaximalTimestepLength", which has to contain
// a json-double called "value" giving the maximum allowed timestep for the BorisMover
// in seconds
//
// if "Drift" is specified:
// - has to contain a json-object "MaximalMovedDistance" which has to follow the form
// described in json_read_length ("simulation/jansson_additionals.h")
// specifies the maximal distance a particle is allowed to move in one timestep
//
// if "Euler" is specified:
// - has to contain a json-object "MaximalMovedDistance" which has to follow the form
// described in json_read_length ("simulation/jansson_additionals.h")
// specifies the maximal distance a particle is allowed to move in one timestep
std::shared_ptr<Mover> buildMover(Parameter& parameter,
const json_path& path_to_mover);
@@ -7,6 +7,10 @@
namespace generator {
// return a shared_ptr to a RandomNumbers object
// parameter has to have a json-object "RandomNumbers" in its root object
// "RandomNumbers" has to contain a json-double "Seed" which specifies the seed
// on mpi-process 0 (a different seed is calculated for all other mpi-processes)
std::shared_ptr<RandomNumbers> buildRandomNumbers(Parameter& parameter);
};
+6
View File
@@ -9,6 +9,12 @@
namespace generator {
// return a shared_ptr to a Reflector object described at the given path in the Parameter object
// the object at the path has to consist of a json-object called either "ReflectorDPS"
// or "NoReflector"
// if "ReflectorDPS" exists, a json-object "position_z" has to exist following the structure
// described in json_read_length ("simulation/jansson_additionals.h")
// if "NoReflector" is specified, it can be an empty object
std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
const json_path& path_to_reflector);
@@ -7,6 +7,10 @@
#include "simulation/scalar_field.h"
namespace generator {
// return a shared_ptr to a ScalarField object described in the json-object "object"
// has to contain a json-object "ScalarFieldFunctionInZ"
// - has to contain a json-object "zFunction" defined as in "function3D" (in "generators/function_generator.h")
// (example in "simulation_config/scalar_fields_examples.json")
std::shared_ptr<ScalarField> buildScalarField(json_t* object);
}
@@ -6,13 +6,33 @@
#include <string>
#include "jansson.h"
// defined in "IO/simulation_output.h"
class SimulationOutput;
// defined in "simulation/species.h"
namespace species {
class TrackedSpecie;
};
namespace generator {
// return a shared_ptr to a SimulationOutput object defined in the given json-object
// the json-object has to consist of:
// - a json-string "folder" containing the path to where the ouput file is supposed to be written
// (relative to where the program was started from)
// - a json-string "filename": with the name of the file (a ".h5" is always appended)
// - a json-object "DensityFields", which has to contain:
// - a json-double (interpreted as an int) or a json-string called "Intervall":
// - if it's a json_double it has to > 0
// - if it's a json_string it has to have the value "EachSync", which means that after each cpu-synchronization step
// the ouput is written
// - a json-string "OverwriteLast" with value either "true" or "false" (defaults to false)
// if "true" old data is overwritten each step
// - a json-array or a json-string "Species":
// - if its a json-string it has to have the value "all" (density information is written for each tracked specie)
// - if its a json-array has to be an array of the names used in the "Tracked" object for which
// density output should be written
// - two more json-objects "CurrentBorders" and "DeletionLogger", which follow the same structure
// as the "DensityFields" object
std::shared_ptr<SimulationOutput> buildSimulationOutput(
json_t* object,
const std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
+117
View File
@@ -11,10 +11,13 @@
#include "simulation/parameter.h"
#include "simulation/species.h"
// defined in "simulation/timer.h"
class Timer;
namespace generator {
// structure to store various variables neccessary for the creation
// of TrackedSpecies objects
struct TrackedSpeciesBuilderInfo {
public:
std::shared_ptr<Mover> mover;
@@ -32,6 +35,8 @@ struct TrackedSpeciesBuilderInfo {
json_path path_in_json;
};
// structure to store various variables neccessary for the creation
// of BackgroundSpecies objects
struct BackgroundSpeciesBuilderInfo {
public:
BackgroundSpeciesBuilderInfo()
@@ -49,33 +54,57 @@ struct BackgroundSpeciesBuilderInfo {
json_path path_in_json;
};
// class for mapping between certain strings and ImplementedSpecies enums
class SpeciesAlias {
public:
// return the ImplementedSpecies enum for the given string. If the
// name is not defined as an alias an error is thrown
static species::ImplementedSpecies alias(const std::string& name);
// return the string defined as an alias for the given ImplemetedSpecies enum
// if no alias has been defined returns an empty string
// (if it were to be defined multiple times return the first found instance)
static std::string name(species::ImplementedSpecies specie);
// check if the string name is defined as an alias
static bool isAlias(const std::string& name);
private:
// mapping between the string and enum
static std::map<std::string, species::ImplementedSpecies> specie_aliases;
};
// class mapping between ImplementedSpecies enum and the charge corresponding to
// the physical particle
class SpeciesCharges {
public:
// return the charge of the ImplementedSpecies enum
static double charge(species::ImplementedSpecies species);
private:
static std::map<species::ImplementedSpecies, double> charge_;
};
// class for creation of the TrackedSpecies map and the BackgroudSpecies map
class SpeciesBuilder {
public:
// Constructor: takes the Parameter object created by the input json file
SpeciesBuilder(Parameter& parameter);
// function to create a map of TrackedSpecies and an arbitrary string used to
// identify the TrackedSpecies within the map
// description for the json-object structure can be found in the private functions of
// this class (examples e.g. in "simulation_config/parameter_katrin_example")
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
trackedSpecies();
// function to create a map of BackgroundSpecies and an arbitrary string used to
// identify the BackgroundSpecies within the map
// description for the json-object structure can be found in the private functions of
// this class (examples e.g. in "simulation_config/parameter_katrin_example")
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
backgroundSpecies();
// function to create a shared_ptr to a Timer object
std::shared_ptr<Timer> timer();
// function to create a shared_ptr to a Timer object (to be used as a copy of the
// main timer object during cpu synchronization)
std::shared_ptr<Timer> lastSyncTimer();
private:
@@ -89,27 +118,115 @@ class SpeciesBuilder {
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
background_species;
// checks all json-objects (with an aribtrary name used as the name of the corresponding
// BackgroundSpecie) in the json-object "Background", which is located in the json-object
// "Species" (which is in the root) and creates new entries in the background_species_info
// map (and sets the name and path_in_json members)
//
// example:
// {
// "Species":{
// "Background": {
// "background1": {...},
// ...
// }
// ...
// }
// }
// in this example the name is set to "background1" and path_in_json to ["Species", "Background", "background1"]
void initBackgroundSpecies(Parameter& parameter);
// checks all json-objects (with an aribtrary name used as the name of the corresponding
// BackgroundSpecie) in the json-object "Tracked", which is located in the json-object
// "Species" (which is in the root) and creates new entries in the background_species_info
// map (and sets the name and path_in_json members)
//
// example:
// {
// "Species":{
// "Tracked": {
// "tracked1": {...},
// ...
// }
// ...
// }
// }
// in this example the name is set to "tracked1" and path_in_json to ["Species", "Tracked", "tracked1"]
void initTrackedSpecies(Parameter& parameter);
// for each element of the background_species_info element and for each tracked_species_info element
// fill the velocity_distribution member with a VelocityDistribution object
// described in a json-object called "VelocityDistribution", that has to follow the
// format described in "buildVelocityDistribution" (generators/velocity_distribution_generator.h)
void fillVelocityDistribution(Parameter& parameter);
// for each element of the background_species_info element and for each tracked_species_info element
// fill the drift_velocity member with a DirftVelocity object
// described in a json-object called "DriftVelocity", that has to follow the
// format described in "buildDriftVelocity" (generators/drift_velocity_generator.h)
void fillDriftVelocity(Parameter& parameter);
// for each element of the background_species_info element and for each tracked_species_info element
// fill the mass_kg member with the value defined in the SpeciesMasses class (defined in
// "generators/mass_generator.h")
void fillMass();
// for each element of the background_species_info element and for each tracked_species_info element
// fill the charge_C member with the value defined in the SpeciesCharges class (defined here in
// "generators/species_generator.h")
void fillCharge();
// for all elements in the tracked_species map add the defined interactions
// in the path stored in the corresponding tracked_species_info element (i.e. ["Species", "Tracked", name of the tracked specie])
// a json-object "Interactions" has to exist, this object has to follow the
// format described for the "addInteractions" function (defined in "generators/interaction_generator.h")
void fillInteractions(Parameter& parameter);
// read the json-string "ParticleType" in the json-object at the path stored in
// path_in_json in the BackgroundSpeciesBuilderInfo map for all elements
// "ParticleType" has to be one of the strings defined as an alias in
// the SpeciesAlias class ("generators/species_generator.h")
void fillBackgroundSpecieType(Parameter& parameter);
// for all elements in the BackgroundSpeciesBuilderInfo map create the
// density member with the density field described in the json-object "ConstantDensityField"
// (in the json-object at path_in_json)
// "ConstantDensityField" has to follow the structure described in "buildConstantDensityField"
// (defined in "generators/density_field_generator.h")
void fillBackgroundDensity(Parameter& parameter);
// read the json-string "ParticleType" in the json-object at the path stored in
// path_in_json in the TrackedSpeciesBuilderInfo map for all elements
// "ParticleType" has to be one of the strings defined as an alias in
// the SpeciesAlias class ("generators/species_generator.h")
void fillTrackedSpecieType(Parameter& parameter);
// fill current_collector and last_sync_current_collector members of the
// TrackedSpecies map, created according to the json-object
// "CurrentCollector" (located in at the path_in_json member)
// has to follow the form described in "buildCurrentCollector" ("generators/current_collector_generator.h")
void fillCurrentCollector(Parameter& parameter);
// fill deletion_logger and last_sync_deletion_logger members of the
// TrackedSpecies map, created according to the json-object
// "Loggers" (located in at the path_in_json member)
// has to follow the form described in "buildDeletionLogger" ("generators/logger_generator.h")
void fillLoggers(Parameter& parameter);
// fill mover member of the TrackedSpeciesBuilderInfo map,
// created according to the json-object "Mover" (located in at the path_in_json member)
// has to follow the form described in "buildMover" ("generators/mover_generator.h")
void fillMover(Parameter& parameter);
// fill terminator member of the TrackedSpeciesBuilderInfo map,
// created according to the json-object "Terminator" (located in at the path_in_json member)
// has to follow the form described in "buildTerminator" ("generators/mover_generator.h")
void fillTerminator(Parameter& parameter);
// fill reflector member of the TrackedSpeciesBuilderInfo map,
// created according to the json-object "Reflector" (located in at the path_in_json member)
// has to follow the form described in "buildReflector" ("generators/mover_generator.h")
void fillReflector(Parameter& parameter);
// fill density_field and last_sync_density_field members of the
// TrackedSpeciesBuilderInfo map, created according to the json-object
// "DynamicDensityField" (located in at the path_in_json member)
// has to follow the form described in "buildDyamicDensityField"
void fillTrackedDensity(Parameter& parameter);
// fill timer_ and last_sync_timer_ objects (no json-specifications needed)
void initTimer();
// create the TrackedSpecies and BackgroundSpecies maps from the data contained in
// the corresponding entries of the TrackedSpeciesBuilderInfo and BackgroundSpeciesBuilderInfo
// maps
void buildSpecies();
};
@@ -7,6 +7,13 @@
namespace generator {
// return a shared_ptr to a Terminator object described by the given json-object in the Parameter object
// the object at the path has to contain:
// - a json-double (later cast to an integer) "MaximumInteractions"
// - a json-object "MaxTimeAlive", which has to contain a json-double "value", giving the
// maximum time a particle is allowed to live in seconds
// - a json-object "BoundaryGeometry", which has to follow the structure given in buildGeometry
// ("generators/geometry_generator.h")
std::shared_ptr<Terminator> buildTerminator(
Parameter& parameter,
const json_path& path_to_terminator);
@@ -8,9 +8,57 @@
#include "simulation/vector_field.h"
namespace generator {
// create an VectorField object from a json_t pointer to an json object
// defining the vector field:
// has to contain a json-object with key either: "VectorFieldConstant", "VectorFieldFunctionInZ" or "VectorFieldFromArray"
// if neither of those is specified an error is thrown
// if "VectorFieldConstant" is specified:
// - has to contain a json-object called "constant" containing a json-array of size 3 (r,phi and z component in this ordering)
// with an arbitrary key
// if "VectorFieldFunctionInZ" is specifid:
// - has to contain a json-object with key "zFunction", that defines a function3D (see "generators/function_generator.h")
// if "VectorFieldFromArray" is specified:
// - has to contain a json-object called "ReadArrayFromFile" (see readComponentFromFile)
// - a json-double "Radius" specifying the radial extent for which the read in vector field is defined
// - a json-double "Length" specifying the longitudinal extent for which the read in vector field is defined
// examples for the look in a json file can be found in "simulation_config/vector_field_examples.json"
std::shared_ptr<VectorField> buildVectorField(json_t* object);
// read a path to a file from a json-object consisting of three json-string objects:
// - "Type": acceptable value either "AbsolutePath" or "RelativeToHomebase", if neither is specified throw an error
// - if "Type" is "AbsolutePath", the json-string with key "AbsoluteFolderPath" has to be defined, containing
// the absolute path to the directory the file that should be read is located in
// - if "Type" is "RelativeToHomebase", the json-string with key "RelativePath" has to be defined, containing
// the path relative (wrt the shell variable "HOMEBASE") to the directory the file that should be read is located in
// - the json-string with key "Filename", containing the name of the file to be read
//
// "key_of_object": {
// "Type": "RelativeToHomebase" or "AbsolutePath",
// "RelativePath" or "AbsoluteFolderPath": path to directory
// "Filename": name of file in the path to the directory
// }
std::string readAbsoluteFilename(json_t* object);
// read a single component (radial, azimuthal or longitudinal) into a blitz::Array
// has to consist of:
// - a json_object called "PathToH5" in the format described for the function "readAbsoluteFilename"
// - a json_array "Keys" consisting of the keys of the absolute path to groups that should be read from the given hdf5 file
//
// "key_to_object": {
// "PathToH5" : { ... },
// "Keys": [path to component of vector field in r-dir, path to component of vector field in phi-dir, path to component of vector field in z-dir]
// }
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component);
// read a single 3d array into a blitz::Array
// has to consist of:
// - a json_object called "PathToH5" in the format described for the function "readAbsoluteFilename"
// - a json_string "Key" specifying the path to the array within the hdf5 file
//
// "key_to_object": {
// "PathToH5" : { ... },
// "Key": path within hdf5 file
// }
blitz::Array<double, 3> readFromFile(json_t* object);
} // namespace generator
@@ -8,6 +8,21 @@
namespace generator {
// return a shared_ptr to a VelocityDistributionFunction object described by the json-object
// at the given json_path in the Parameter object
// has to contain a json-object called either "IsotropicDistribution" or "DirectedDistribution"
// if "IsotropicDistribution" is specified:
// - has to include a json-object "EnergyDistributionFunction" as defined in "generators/energy_distribtion_function_generator.h"
// - has to include a json-object "Mass" as defined in "generators/mass_generator.h"
// - returns a IsotropicDistribution object (see simulation/energy_distribtion.h)
//
// if "DirectedDistribution" is specified:
// - has to include a json-object "EnergyDistributionFunction" as defined in "generators/energy_distribtion_function_generator.h"
// - has to include a json-object "Mass" as defined in "generators/mass_generator.h"
// - has to include a json-array of size 3, defining the direction in cartesian coordinates (x,y,z)
// - returns a DirectedDistribution object (see simulation/energy_distribtion.h)
//
// (example in "simulation_config/velocity_distribution_function_examples.json")
std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
Parameter& parameter,
const json_path& path_to_distribution);
@@ -8,6 +8,25 @@
namespace generator {
// return a shared_ptr to a VelocityDistribution object described by the json-object
// at the path "path_to_distribution" (from root object) in the Parameter object
// consisting of a json-object either called "VelocityDistributionFromFunction" or "null"
// if "VelocityDistributionFromFunction" is specified:
// - has to consist of a json-object "VelocityDistributionFunction", as defined in "generators/velocity_distribution_function_generator.h"
//
// if "null" is specified:
// - no further information has to be specified
//
// example:
// "path_to_distribution" : {
// "VelocityDistributionFromFunction": {
// "VelocityDistributionFunction" : { ... }
// }
// }
// or
// "path_to_distribution" : {
// "null": {}
// }
std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
Parameter& parameter,
const json_path& path_to_distribution);