preprocessor now filters debug output
This commit is contained in:
@@ -47,8 +47,10 @@ LIBS += $(HDF5P_LIBRARIES)
|
||||
CXXFLAGS += $(JANSSON_INCLUDES)
|
||||
LIBS += $(JANSSON_LIBRARIES)
|
||||
|
||||
|
||||
CXXFLAGS += -g
|
||||
ifeq ($(DO_DEBUGGING),true)
|
||||
CXXFLAGS += -ftemplate-depth-30 -g -DBZ_DEBUG
|
||||
CXXFLAGS += -ftemplate-depth-30 -DBZ_DEBUG
|
||||
CXXFLAGS += -Ddebug
|
||||
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
||||
endif
|
||||
|
||||
+10
-3
@@ -277,23 +277,24 @@ std::stringstream Hdf5Reader::readEngineString(std::string path) {
|
||||
std::to_string(SimConstants::engine_string_length_max) +
|
||||
", size of string: " + std::to_string(size));
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("RestartInfo: " + std::to_string(H5Tdetect_class(dtype, H5T_STRING)));
|
||||
#endif
|
||||
|
||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
||||
hsize_t dims[ndims];
|
||||
if (ndims != 1) {
|
||||
ERROR("The given dataset is not one dimensional. It has dims: " + ndims);
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(std::to_string(ndims));
|
||||
DEBUG_LEVEL_3("RestartInfo: " + std::to_string(size));
|
||||
#endif
|
||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
||||
|
||||
char data[SimConstants::engine_string_length_max];
|
||||
H5Dread(dataset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
||||
&data);
|
||||
|
||||
std::stringstream temp;
|
||||
temp << data;
|
||||
|
||||
H5Tclose(dtype);
|
||||
H5Sclose(dataspace);
|
||||
@@ -314,15 +315,21 @@ std::stringstream Hdf5Reader::readEngineString(std::string path) {
|
||||
|
||||
size_t length;
|
||||
H5Dread(dataset, H5T_NATIVE_HSIZE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &length);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("RestartInfo: read length from file: " + std::to_string(length));
|
||||
#endif
|
||||
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
H5Fclose(file);
|
||||
|
||||
#ifdef debug_level3
|
||||
std::stringstream temp;
|
||||
temp << data;
|
||||
out << temp.str().substr(0, length);
|
||||
DEBUG_LEVEL_3(std::to_string(out.str().size()));
|
||||
#endif
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -542,12 +542,16 @@ void Hdf5Writer::writeRNG(const std::string& data, std::string path_base) {
|
||||
|
||||
for(int i = 0; i < MpiCommunication::mpiSize(); ++i) {
|
||||
std::string path = path_base + std::to_string(i);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path);
|
||||
#endif
|
||||
hid_t dataset_string = H5Dcreate2(file, (path + "/string").c_str(), dtype, filespace, lcpl, H5P_DEFAULT, H5P_DEFAULT);
|
||||
// this sadly seems to be the option that takes the least amount of effort.
|
||||
// H5Lexits() would be an option but (!) each group would need to be checked for existance first, which sucks
|
||||
if(dataset_string < 0) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Dataset could not be created");
|
||||
#endif
|
||||
dataset_string = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
|
||||
if(dataset_string < 0) {
|
||||
ERROR("Dataset for string can neither be created nor opened");
|
||||
@@ -556,7 +560,9 @@ void Hdf5Writer::writeRNG(const std::string& data, std::string path_base) {
|
||||
|
||||
hid_t dataset_length = H5Dcreate2(file, (path + "/length").c_str(), H5T_NATIVE_HSIZE, filespace, lcpl, H5P_DEFAULT, H5P_DEFAULT);
|
||||
if(dataset_length < 0) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Dataset could not be created");
|
||||
#endif
|
||||
dataset_length = H5Dopen2(file, (path + "/length").c_str(), H5P_DEFAULT);
|
||||
if(dataset_length < 0) {
|
||||
ERROR("Dataset for length can neither be created nor opened");
|
||||
|
||||
@@ -27,12 +27,18 @@ void Restart::restart(std::map<std::string, std::shared_ptr<species::TrackedSpec
|
||||
if(!do_restart_) {
|
||||
return;
|
||||
}
|
||||
#ifdef debug_level1
|
||||
DEBUG_LEVEL_1("Restarting rng");
|
||||
#endif
|
||||
restartRandomNumbers(random_numbers);
|
||||
#ifdef debug_level1
|
||||
DEBUG_LEVEL_1("Restarting poisson solver.");
|
||||
#endif
|
||||
restartPoissonSolver(poisson_solver);
|
||||
|
||||
#ifdef debug_level1
|
||||
DEBUG_LEVEL_1("Restarting timer.");
|
||||
#endif
|
||||
restartTimer(species.begin()->second.get());
|
||||
|
||||
for(const auto& pair: species) {
|
||||
@@ -68,7 +74,9 @@ void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
|
||||
{
|
||||
std::string path = reference_specie->name() + "/DensityField/SimulationData/" +
|
||||
restart_identifier_ + "/PhysicalTime";
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path);
|
||||
#endif
|
||||
// probably add a function in the reader to read a single double value instead of
|
||||
// an 1d array of doubles
|
||||
blitz::Array<double, 1> restart_time = reader_.readD1Double(path);
|
||||
@@ -84,7 +92,9 @@ void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
|
||||
{
|
||||
std::string path = reference_specie->name() + "/CurrentCollector/SimulationData/" +
|
||||
restart_identifier_ + "/PhysicalTime";
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path);
|
||||
#endif
|
||||
// probably add a function in the reader to read a single double value instead of
|
||||
// a 1d array of doubles
|
||||
blitz::Array<double, 1> time_resolution = reader_.readD1Double(path);
|
||||
@@ -103,7 +113,9 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
||||
// restart TimeInBin field
|
||||
{
|
||||
std::string path_to_data = path + "/TimeInBin";
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path_to_data);
|
||||
#endif
|
||||
blitz::Array<double, 5> time_in_bin = reader_.readD5Double(path_to_data);
|
||||
field->restartTimeInBin(time_in_bin);
|
||||
}
|
||||
@@ -124,7 +136,9 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
||||
void Restart::restartPoissonSolver(PoissonSolver* solver) {
|
||||
std::string path = "PoissonSolver/SimulationData/" + restart_identifier_ +
|
||||
"/Potential/";
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path);
|
||||
#endif
|
||||
blitz::Array<double, 3> potential = reader_.readD3Double(path);
|
||||
solver->setPotential(potential);
|
||||
}
|
||||
@@ -72,7 +72,11 @@ void SimulationOutput::writeSimulationData(
|
||||
PoissonSolver* poisson_solver,
|
||||
std::mt19937* engine) {
|
||||
if (MpiCommunication::mpi_rank == 0) {
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Write density field data.");
|
||||
#endif
|
||||
|
||||
for (auto& task : tasks_density_fields_) {
|
||||
if (cpu_sync % task.intervall == 0) {
|
||||
std::string specie_path = "/" + task.specie_name;
|
||||
@@ -80,7 +84,9 @@ void SimulationOutput::writeSimulationData(
|
||||
specie_path, cpu_sync, task.overwrite_last);
|
||||
}
|
||||
}
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Write current collector data.");
|
||||
#endif
|
||||
for (auto& task : tasks_current_collector_) {
|
||||
if (cpu_sync % task.intervall == 0) {
|
||||
std::string specie_path = "/" + task.specie_name;
|
||||
@@ -88,7 +94,9 @@ void SimulationOutput::writeSimulationData(
|
||||
specie_path, cpu_sync, task.overwrite_last);
|
||||
}
|
||||
}
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Write deletion logger data.");
|
||||
#endif
|
||||
for (auto& task : tasks_deletion_logger_) {
|
||||
if (cpu_sync % task.intervall == 0) {
|
||||
std::string specie_path = "/" + task.specie_name;
|
||||
@@ -96,7 +104,9 @@ void SimulationOutput::writeSimulationData(
|
||||
specie_path, cpu_sync, task.overwrite_last);
|
||||
}
|
||||
}
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Write PoissonSolver data.");
|
||||
#endif
|
||||
if (cpu_sync % task_potential_.intervall == 0) {
|
||||
std::string poisson_path = "/" + task_potential_.specie_name;
|
||||
writeSimulationData(poisson_solver, poisson_path, cpu_sync,
|
||||
@@ -121,15 +131,23 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
||||
}
|
||||
std::string path = species_path + "/DensityField/SimulationData/" + sync_path;
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write spectrum.");
|
||||
#endif
|
||||
writeSpectrum(density_field, path);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write density.");
|
||||
#endif
|
||||
writeDensity(density_field, path);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write time in bin.");
|
||||
#endif
|
||||
writeTimeInBin(density_field, path);
|
||||
// DEBUG_LEVEL_3("Write deleted particles.");
|
||||
// writeDeletedParticles(density_field, path);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write physical time.");
|
||||
#endif
|
||||
writePhysicalTime(density_field, path);
|
||||
}
|
||||
|
||||
@@ -143,11 +161,17 @@ void SimulationOutput::writeSimulationData(CurrentCollector* current_collector,
|
||||
}
|
||||
std::string path =
|
||||
species_path + "/CurrentCollector/SimulationData/" + sync_path;
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write current crossings.");
|
||||
#endif
|
||||
writeCurrentCrossings(current_collector, path);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write current.");
|
||||
#endif
|
||||
writeCurrent(current_collector, path);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write physical time.");
|
||||
#endif
|
||||
writePhysicalTime(current_collector, path);
|
||||
}
|
||||
|
||||
@@ -160,7 +184,9 @@ void SimulationOutput::writeSimulationData(DeletionLogger* logger,
|
||||
sync_path = "LastSyncPeriod";
|
||||
}
|
||||
std::string path = species_path + "/DeletionLogger/" + sync_path;
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write number of deletions.");
|
||||
#endif
|
||||
writeNumDeletions(logger, path);
|
||||
}
|
||||
|
||||
@@ -173,7 +199,9 @@ void SimulationOutput::writeSimulationData(PoissonSolver* poisson_solver,
|
||||
sync_path = "/LastSyncPeriod";
|
||||
}
|
||||
std::string path = poisson_path + "/SimulationData" + sync_path;
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Write potential.");
|
||||
#endif
|
||||
writePotential(poisson_solver, path);
|
||||
}
|
||||
|
||||
@@ -185,10 +213,12 @@ void SimulationOutput::writeRestartData(std::mt19937* engine, int cpu_sync,
|
||||
if (overwrite_last) {
|
||||
path_base = "/RestartInfo/LastSyncPeriod/CPU_";
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(path_base);
|
||||
DEBUG_LEVEL_3("Write restart info.");
|
||||
#endif
|
||||
writeRandomEngineState(engine, path_base);
|
||||
DEBUG_LEVEL_3("Done");
|
||||
// DEBUG_LEVEL_3("Done");
|
||||
}
|
||||
|
||||
void SimulationOutput::writeRandomEngineState(std::mt19937* engine, std::string path) {
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace generator {
|
||||
|
||||
CylinderBinning buildPositionBinning(json_t* object) {
|
||||
if (json_object_by_path(object, {"CylinderBinning"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating position binning: cylinder binning.");
|
||||
#endif
|
||||
object = json_object_by_path(object, {"CylinderBinning"});
|
||||
|
||||
json_t* radial = json_object_by_path(object, {"Radial"});
|
||||
@@ -36,6 +38,7 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
||||
json_read_length(json_object_by_path(longitudinal, {"MaxLength"}), "m");
|
||||
ASSERT_POSITIVE(&max_length, "Radius must be positive");
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with number of bins radial: " +
|
||||
std::to_string(number_of_bins_radial));
|
||||
DEBUG_LEVEL_3("with number of bins azimuthal: " +
|
||||
@@ -44,6 +47,7 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
||||
std::to_string(number_of_bins_longitudinal));
|
||||
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
||||
DEBUG_LEVEL_3("with height: " + std::to_string(max_length) + " m");
|
||||
#endif
|
||||
|
||||
return CylinderBinning(number_of_bins_radial, max_radius,
|
||||
number_of_bins_azimuthal,
|
||||
@@ -59,14 +63,18 @@ CylinderBinning buildPositionBinningIncludingRedirection(
|
||||
json_path& path_to_binning) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating position binning: CreateSameAs.");
|
||||
#endif
|
||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
||||
std::stringstream path;
|
||||
for (auto& p : path_to_same) {
|
||||
path << p << " ";
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("From path: " + path.str());
|
||||
#endif
|
||||
return buildPositionBinningIncludingRedirection(parameter, path_to_same);
|
||||
} else {
|
||||
return buildPositionBinning(parameter.jsonObjectFromBase(path_to_binning));
|
||||
@@ -76,7 +84,9 @@ CylinderBinning buildPositionBinningIncludingRedirection(
|
||||
EnergyBinning buildEnergyBinning(json_t* object) {
|
||||
std::string energy_type = json_string(json_object_by_path(object, {"Type"}));
|
||||
if (energy_type == "Logarithmic") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy binning: logarithmic.");
|
||||
#endif
|
||||
int number_of_bins =
|
||||
json_int(json_object_by_path(object, {"NumberOfBins"}));
|
||||
ASSERT_POSITIVE(&number_of_bins, "Number of Bins must be positive");
|
||||
@@ -87,9 +97,11 @@ EnergyBinning buildEnergyBinning(json_t* object) {
|
||||
json_read_energy(json_object_by_path(object, {"MaxEnergy"}), "eV");
|
||||
ASSERT_POSITIVE(&max_energy, "Max Energy must be positive");
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins));
|
||||
DEBUG_LEVEL_3("with min energy: " + std::to_string(min_energy));
|
||||
DEBUG_LEVEL_3("with max energy: " + std::to_string(max_energy));
|
||||
#endif
|
||||
|
||||
return EnergyBinning(min_energy, max_energy, number_of_bins);
|
||||
|
||||
@@ -104,14 +116,22 @@ EnergyBinning buildEnergyBinningIncludingRedirection(
|
||||
json_path& path_to_binning) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy binning: CreateSameAs.");
|
||||
#endif
|
||||
|
||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
||||
|
||||
#ifdef debug_level3
|
||||
std::stringstream path;
|
||||
for (auto& p : path_to_same) {
|
||||
path << p << " ";
|
||||
}
|
||||
DEBUG_LEVEL_3("From path: " + path.str());
|
||||
#endif
|
||||
|
||||
return buildEnergyBinningIncludingRedirection(parameter, path_to_same);
|
||||
} else {
|
||||
return buildEnergyBinning(parameter.jsonObjectFromBase(path_to_binning));
|
||||
@@ -121,12 +141,18 @@ EnergyBinning buildEnergyBinningIncludingRedirection(
|
||||
PitchAngleBinning buildPitchAngleBinning(json_t* object) {
|
||||
std::string pitch_angle_type = json_string(json_object_by_path(object, {"Type"}));
|
||||
if (pitch_angle_type == "Linear") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating pitch angle binning: linear.");
|
||||
#endif
|
||||
|
||||
int number_of_bins =
|
||||
json_int(json_object_by_path(object, {"NumberOfBins"}));
|
||||
ASSERT_POSITIVE(&number_of_bins, "Number of Bins must be positive");
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins));
|
||||
#endif
|
||||
|
||||
return PitchAngleBinning(number_of_bins);
|
||||
|
||||
} else {
|
||||
@@ -140,14 +166,21 @@ PitchAngleBinning buildPitchAngleBinningIncludingRedirection(
|
||||
json_path& path_to_binning) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy binning: CreateSameAs.");
|
||||
#endif
|
||||
|
||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
||||
|
||||
#ifdef debug_level3
|
||||
std::stringstream path;
|
||||
for (auto& p : path_to_same) {
|
||||
path << p << " ";
|
||||
}
|
||||
DEBUG_LEVEL_3("From path: " + path.str());
|
||||
#endif
|
||||
|
||||
return buildPitchAngleBinningIncludingRedirection(parameter, path_to_same);
|
||||
} else {
|
||||
return buildPitchAngleBinning(parameter.jsonObjectFromBase(path_to_binning));
|
||||
|
||||
@@ -9,7 +9,9 @@ std::shared_ptr<CurrentCollector> buildCurrentCollector(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_collector,
|
||||
std::shared_ptr<Timer>& timer) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating current collector.");
|
||||
#endif
|
||||
json_path path_binning =
|
||||
json_path_append(path_to_collector, {"PositionBinning"});
|
||||
CylinderBinning position_binning =
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace generator {
|
||||
|
||||
std::shared_ptr<ConstantDensityField> buildConstantDensityField(
|
||||
json_t* object) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating constant density field.");
|
||||
#endif
|
||||
json_path path = {"ScalarField"};
|
||||
std::shared_ptr<ScalarField> field =
|
||||
buildScalarField(json_object_by_path(object, path));
|
||||
@@ -22,7 +24,9 @@ std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
||||
const json_path& path_to_field,
|
||||
std::shared_ptr<Timer>& timer) {
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating dynamic density field with pitch angle.");
|
||||
#endif
|
||||
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
||||
CylinderBinning position_binning =
|
||||
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
||||
|
||||
@@ -9,14 +9,18 @@ std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
||||
const json_path& path_to_drift_velocity) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_drift_velocity, {"VectorField"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating drift velocity: Vector field.");
|
||||
#endif
|
||||
std::shared_ptr<VectorField> field =
|
||||
buildVectorField(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_drift_velocity, {"VectorField"})));
|
||||
return std::shared_ptr<DriftVelocity>(new DriftVelocity(field));
|
||||
} else if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_drift_velocity, {"null"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating drift velocity: null.");
|
||||
#endif
|
||||
return nullptr;
|
||||
} else {
|
||||
ERROR("No drift velocity given.");
|
||||
@@ -29,14 +33,18 @@ std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
|
||||
std::stringstream cpath;
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating drift velocity: CreateSameAs.");
|
||||
#endif
|
||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_drift_velocity, {"CreateSameAs"})));
|
||||
#ifdef debug_level3
|
||||
std::stringstream path;
|
||||
for (auto& p : path_to_same) {
|
||||
path << p << " ";
|
||||
}
|
||||
DEBUG_LEVEL_3("From path: " + path.str());
|
||||
#endif
|
||||
return buildDriftVelocityIncludingRedirection(parameter, path_to_same);
|
||||
} else {
|
||||
return buildDriftVelocity(parameter, path_to_drift_velocity);
|
||||
|
||||
@@ -6,12 +6,16 @@
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<ElectricField> electricField(json_t* object) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating electric field.");
|
||||
#endif
|
||||
std::shared_ptr<VectorField> background;
|
||||
std::shared_ptr<VectorField> dynamic;
|
||||
|
||||
if (json_object_by_path(object, {"Background"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating background electric field.");
|
||||
#endif
|
||||
background = buildVectorField(
|
||||
json_object_by_path(object, {"Background", "VectorField"}));
|
||||
} else {
|
||||
@@ -19,7 +23,9 @@ std::shared_ptr<ElectricField> electricField(json_t* object) {
|
||||
}
|
||||
|
||||
if (json_object_by_path(object, {"Dynamic"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating dynamic electric field.");
|
||||
#endif
|
||||
dynamic = buildVectorField(
|
||||
json_object_by_path(object, {"Dynamic", "VectorField"}));
|
||||
} else {
|
||||
|
||||
@@ -11,21 +11,31 @@ std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
||||
json_t* object = parameter.jsonObjectFromBase(path_to_function);
|
||||
|
||||
if (json_object_by_path(object, {"TritiumBetaDecay"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
||||
#endif
|
||||
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
||||
|
||||
} else if (json_object_by_path(object, {"MaxwellBoltzmann"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
||||
#endif
|
||||
double temperature_K = json_double(json_object_by_path(
|
||||
object, {"MaxwellBoltzmann", "Temperature", "value"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with temperature: " + std::to_string(temperature_K) + " K");
|
||||
#endif
|
||||
return std::shared_ptr<EnergyDistributionFunction>(
|
||||
new MaxwellBoltzmann(temperature_K));
|
||||
} else if (json_object_by_path(object, {"Constant"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating energy distribution function: Constant.");
|
||||
#endif
|
||||
double constant_eV = json_double(
|
||||
json_object_by_path(object, {"Constant", "constant", "value"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with constant: " + std::to_string(constant_eV) + " eV");
|
||||
#endif
|
||||
return std::shared_ptr<EnergyDistributionFunction>(
|
||||
new Constant(constant_eV));
|
||||
}
|
||||
|
||||
@@ -11,14 +11,20 @@ namespace generator {
|
||||
|
||||
std::function<double(double)> function1D(json_t* object) {
|
||||
if (json_object_by_path(object, {"Constant"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function1d: constant.");
|
||||
#endif
|
||||
double constant =
|
||||
json_double(json_object_by_path(object, {"Constant", "constant"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with constant: " + std::to_string(constant));
|
||||
#endif
|
||||
return D1ToD1::Constant(constant);
|
||||
|
||||
} else if (json_object_by_path(object, {"PiecewiseLinear"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear.");
|
||||
#endif
|
||||
std::vector<double> x_values = json_vector(
|
||||
json_object_by_path(object, {"PiecewiseLinear", {"xValues"}}));
|
||||
std::vector<double> y_values = json_vector(
|
||||
@@ -31,11 +37,15 @@ std::function<double(double)> function1D(json_t* object) {
|
||||
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
||||
|
||||
} else if (json_object_by_path(object, {"PiecewiseLinearFromFile"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear from file.");
|
||||
#endif
|
||||
|
||||
std::string absolute_filename = readAbsoluteFilename(
|
||||
json_object_by_path(object, {"PiecewiseLinearFromFile", "PathToH5"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with filename: " + absolute_filename);
|
||||
#endif
|
||||
Hdf5Reader reader(absolute_filename);
|
||||
|
||||
std::string x_values_key = json_string(
|
||||
@@ -53,7 +63,9 @@ std::function<double(double)> function1D(json_t* object) {
|
||||
|
||||
double prefactor = json_double(json_object_by_path(
|
||||
object, {"PiecewiseLinearFromFile", {"prefactor"}}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with prefactor: " + std::to_string(prefactor));
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < y_values.size(); ++i) {
|
||||
y_values[i] = y_values[i] * prefactor;
|
||||
@@ -61,7 +73,9 @@ std::function<double(double)> function1D(json_t* object) {
|
||||
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
||||
|
||||
} else if (json_object_by_path(object, {"Product"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function1d: Product.");
|
||||
#endif
|
||||
json_t* function_array = json_object_by_path(object, {"Product"});
|
||||
std::vector<std::function<double(double)>> functions;
|
||||
size_t index;
|
||||
@@ -72,7 +86,9 @@ std::function<double(double)> function1D(json_t* object) {
|
||||
return D1ToD1::Product(functions);
|
||||
|
||||
} else if (json_object_by_path(object, {"Exponential"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function1d: Exponential.");
|
||||
#endif
|
||||
double prefactor = json_double(json_object_by_path(
|
||||
object, {"Exponential", {"prefactor"}}));
|
||||
double scale = json_double(json_object_by_path(
|
||||
@@ -86,12 +102,16 @@ std::function<double(double)> function1D(json_t* object) {
|
||||
|
||||
std::function<double(double, double, double)> function3D(json_t* object) {
|
||||
if (json_object_by_path(object, {"Constant3D"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function3d: Constant3D.");
|
||||
#endif
|
||||
double constant =
|
||||
json_double(json_object_by_path(object, {"Constant3D", "constant"}));
|
||||
return D3ToD1::Constant(constant);
|
||||
} else if (json_object_by_path(object, {"Product"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating function3d: Product.");
|
||||
#endif
|
||||
std::function<double(double)> fi =
|
||||
function1D(json_object_by_path(object, {"Product", "fi"}));
|
||||
std::function<double(double)> fj =
|
||||
|
||||
@@ -7,7 +7,9 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
||||
const json_path& path_to_geometry) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_geometry, {"Cylinder"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating geometry: cylinder.");
|
||||
#endif
|
||||
double radius =
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_geometry, {"Cylinder", "Radius"})),
|
||||
@@ -16,8 +18,10 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_geometry, {"Cylinder", "Height"})),
|
||||
"m");
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with radius: " + std::to_string(radius) + " m");
|
||||
DEBUG_LEVEL_3("with height: " + std::to_string(height) + " m");
|
||||
#endif
|
||||
return std::shared_ptr<Geometry>(new Cylinder(radius, height));
|
||||
} else {
|
||||
ERROR("This geometry is not implemented.");
|
||||
@@ -29,14 +33,18 @@ std::shared_ptr<Geometry> buildGeometryIncludingRedirection(
|
||||
Parameter& parameter, const json_path& path_to_geometry) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_geometry, {"CreateSameAs"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating geometry: CreateSameAs.");
|
||||
#endif
|
||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_geometry, {"CreateSameAs"})));
|
||||
std::stringstream path;
|
||||
for (auto& p : path_to_same) {
|
||||
path << p << " ";
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("From path: " + path.str());
|
||||
#endif
|
||||
return buildGeometryIncludingRedirection(parameter, path_to_same);
|
||||
} else {
|
||||
return buildGeometry(parameter, path_to_geometry);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<GravityField> gravityField(json_t* object) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating gravity field.");
|
||||
#endif
|
||||
return std::shared_ptr<GravityField>(new GravityField(
|
||||
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ std::shared_ptr<Injector> buildInjector(
|
||||
json_object_foreach(array, key, value) {
|
||||
std::string specie_name =
|
||||
json_string(json_object_by_path(value, {"TrackedSpecieName"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Injected specie: " + specie_name);
|
||||
#endif
|
||||
InjectorInfo info;
|
||||
info.created_specie = tracked_species[specie_name];
|
||||
|
||||
@@ -41,7 +43,9 @@ std::shared_ptr<Injector> buildInjector(
|
||||
}
|
||||
|
||||
// EventPositionDistribution
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating event distribution.");
|
||||
#endif
|
||||
std::shared_ptr<ScalarField> field = buildScalarField(json_object_by_path(
|
||||
object, {"EventPositionDistribution", "ScalarField"}));
|
||||
|
||||
@@ -80,7 +84,9 @@ std::shared_ptr<Injector> buildInjector(
|
||||
position_limit_phi, position_limit_z));
|
||||
|
||||
// MotherDriftVelocity
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating mother drift velocity.");
|
||||
#endif
|
||||
std::shared_ptr<DriftVelocity> drift_velocity = buildDriftVelocity(
|
||||
parameter, json_path_append(path_to_injector, {"MotherDriftVelocity"}));
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ void addInteractions(
|
||||
std::string type = json_string(json_object_by_path(value, {"Type"}));
|
||||
|
||||
if (type == "ElasticScattering") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: ElasticScattering");
|
||||
#endif
|
||||
std::function<double(double)> cross_section =
|
||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
||||
|
||||
@@ -43,7 +45,9 @@ void addInteractions(
|
||||
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with target " + target_name);
|
||||
#endif
|
||||
|
||||
std::shared_ptr<species::Specie> target =
|
||||
findTarget(target_name, tracked_species, background_species);
|
||||
@@ -53,11 +57,15 @@ void addInteractions(
|
||||
scattering_angle_distribution)));
|
||||
|
||||
} else if (type == "FreeMovement") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: FreeMovement");
|
||||
#endif
|
||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||
new interaction::FreeMovement()));
|
||||
} else if (type == "ElectronIonization") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: Ionization");
|
||||
#endif
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
std::shared_ptr<species::Specie> target =
|
||||
@@ -183,7 +191,9 @@ void addInteractions(
|
||||
ERROR("This ionization model is not implemented: " + ionization_model);
|
||||
}
|
||||
} else if (type == "Excitation") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: Excitation");
|
||||
#endif
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
std::shared_ptr<species::Specie> target =
|
||||
@@ -201,7 +211,9 @@ void addInteractions(
|
||||
cross_section, target, excitation_energy)));
|
||||
|
||||
} else if (type == "Clustering") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: Clustering");
|
||||
#endif
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
std::shared_ptr<species::Specie> target =
|
||||
@@ -217,7 +229,9 @@ void addInteractions(
|
||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||
new interaction::ClusterFormation(cross_section, target, product)));
|
||||
} else if (type == "ChargeExchange") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
||||
#endif
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
std::shared_ptr<species::Specie> target =
|
||||
@@ -228,7 +242,9 @@ void addInteractions(
|
||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||
new interaction::ChargeExchange(cross_section, target)));
|
||||
} else if (type == "Recombination") {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding interactions: Recombination");
|
||||
#endif
|
||||
std::string target_name =
|
||||
json_string(json_object_by_path(value, {"Target"}));
|
||||
std::shared_ptr<species::TrackedSpecie> target =
|
||||
@@ -471,18 +487,24 @@ std::function<double(double, double)> build2DCrossSection(json_t* object) {
|
||||
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
||||
json_t* object) {
|
||||
if (json_object_by_path(object, {"Isotropic"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Adding ScatteringAngleDistribution: Isotropic");
|
||||
#endif
|
||||
return std::shared_ptr<ScatteringAngleDistribution>(
|
||||
new IsotropicAngleDistribution());
|
||||
} else if (json_object_by_path(object, {"AngleDistributionFromFile"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2(
|
||||
"Adding ScatteringAngleDistribution: AngleDistributionFromFile");
|
||||
#endif
|
||||
std::string absolute_filepath = readAbsoluteFilename(
|
||||
json_object_by_path(object, {"AngleDistributionFromFile", "PathToH5"}));
|
||||
return std::make_shared<AngleDistributionFromFile>(absolute_filepath);
|
||||
} else if (json_object_by_path(object, {"CompositeAngleDistribution"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2(
|
||||
"Adding ScatteringAngleDistribution: CompositeAngleDistribution");
|
||||
#endif
|
||||
json_t* object_composite =
|
||||
json_object_by_path(object, {"CompositeAngleDistribution"});
|
||||
const double decider_energy = json_read_energy(
|
||||
|
||||
@@ -43,7 +43,9 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_loggers) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating deletion logger.");
|
||||
#endif
|
||||
|
||||
json_path path_logger = json_path_append(path_to_loggers, {"Deletion"});
|
||||
json_t* object = parameter.jsonObjectFromBase(path_logger);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating magnetic field.");
|
||||
#endif
|
||||
return std::shared_ptr<MagneticField>(new MagneticField(
|
||||
buildVectorField(json_object_by_path(object, {"VectorField"})),
|
||||
buildVectorField(json_object_by_path(object, {"GradientField"}))));
|
||||
|
||||
@@ -7,13 +7,17 @@ std::shared_ptr<Mover> buildMover(Parameter& parameter,
|
||||
const json_path& path_to_mover) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_mover, {"Boris"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating mover: Boris.");
|
||||
#endif
|
||||
double max_timestep_length = parameter.doubleValue(json_path_append(
|
||||
path_to_mover, {"Boris", "MaximalTimestepLength", "value"}));
|
||||
return std::shared_ptr<Mover>(new BorisMover(max_timestep_length));
|
||||
} else if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_mover, {"Drift"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating mover: Drift.");
|
||||
#endif
|
||||
double maximal_moved_distance =
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_mover, {"Drift", "MaximalMovedDistance"})));
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace generator {
|
||||
std::shared_ptr<PoissonSolver> buildPoissonSolver(
|
||||
Parameter& parameter) {
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Generating Poisson solver.");
|
||||
#endif
|
||||
std::shared_ptr<Geometry> geometry;
|
||||
|
||||
json_t* object = json_object_by_path(
|
||||
@@ -48,7 +50,9 @@ namespace generator {
|
||||
|
||||
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||
const json_path& path_to_boundaries) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Creating Boundaries.");
|
||||
#endif
|
||||
std::map<std::string, GlobalBoundary> boundary_map {
|
||||
{"Bottom", {0., BoundaryType::dirichlet}},
|
||||
{"Top", {0., BoundaryType::dirichlet}},
|
||||
@@ -63,7 +67,9 @@ namespace generator {
|
||||
json_t* value;
|
||||
json_object_foreach(parameter.jsonObjectFromBase(path_to_boundaries),
|
||||
key, value) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Creating " + std::string(key) + ": ");
|
||||
#endif
|
||||
if(!(boundary_map.find(std::string(key)) == boundary_map.end())) {
|
||||
double boundary_value =
|
||||
json_double(json_object_by_path(value, {"value"}));
|
||||
@@ -82,8 +88,10 @@ namespace generator {
|
||||
". Using default boundary (dirichtlet, value 0)");
|
||||
continue;
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with type: " + boundary_type);
|
||||
DEBUG_LEVEL_3("with value: " + std::to_string(boundary_value));
|
||||
#endif
|
||||
|
||||
} else {
|
||||
SIM_INFO(std::string(key) + ": unknown location. Is ignored.");
|
||||
|
||||
@@ -8,7 +8,9 @@ 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"})),
|
||||
@@ -16,7 +18,9 @@ std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
|
||||
return std::shared_ptr<Reflector>(new ReflectorDPS(position_z));
|
||||
} 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.");
|
||||
|
||||
@@ -7,13 +7,17 @@ namespace generator {
|
||||
DEBUG_LEVEL_3("Build Restart.");
|
||||
bool do_restart = json_bool(json_object_by_path(object, {"Do"}));
|
||||
if (!do_restart) {
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("No Restart desired.");
|
||||
#endif
|
||||
return Restart(false, "", "");
|
||||
}
|
||||
|
||||
std::string filepath = readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}))
|
||||
+ ".h5";
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Restart: file path:" + filepath);
|
||||
#endif
|
||||
|
||||
std::string identifier;
|
||||
int sync_period = json_int(json_object_by_path(object, {"SyncPeriod"}));
|
||||
@@ -27,7 +31,9 @@ namespace generator {
|
||||
identifier = "SyncPeriod_" + std::to_string(sync_period);
|
||||
}
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Restart: SyncPeriod to be started from: " + identifier);
|
||||
#endif
|
||||
|
||||
return Restart(do_restart, filepath, identifier);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,9 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
||||
}
|
||||
ASSERT_NOTNEGATIVE(&intervall, "The intervall for RestartInfo has to be either 0"
|
||||
",if no output is required or positive otherwise");
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Restart output interval: " + std::to_string(intervall));
|
||||
#endif
|
||||
|
||||
bool overwrite_last = json_bool(
|
||||
json_object_by_path(object, {"RestartInfo", "OverwriteLast"}));
|
||||
|
||||
@@ -107,13 +107,17 @@ std::shared_ptr<Timer> SpeciesBuilder::lastSyncTimer() {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::initTimer() {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Init timer.");
|
||||
#endif
|
||||
timer_ = std::shared_ptr<Timer>(new Timer());
|
||||
last_sync_timer_ = std::shared_ptr<Timer>(new Timer());
|
||||
}
|
||||
|
||||
void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Init background species info.");
|
||||
#endif
|
||||
const char* key;
|
||||
json_t* value;
|
||||
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Background"}),
|
||||
@@ -126,7 +130,9 @@ void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::initTrackedSpecies(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Init tracked species info.");
|
||||
#endif
|
||||
const char* key;
|
||||
json_t* value;
|
||||
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Tracked"}), key,
|
||||
@@ -139,11 +145,15 @@ void SpeciesBuilder::initTrackedSpecies(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillBackgroundSpecieType(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill background species type.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
std::string type = json_string(parameter.jsonObjectFromBase(
|
||||
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Type: " + type);
|
||||
#endif
|
||||
if (SpeciesAlias::isAlias(type)) {
|
||||
b.second.type = SpeciesAlias::alias(type);
|
||||
} else {
|
||||
@@ -153,11 +163,15 @@ void SpeciesBuilder::fillBackgroundSpecieType(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillTrackedSpecieType(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill tracked species type.");
|
||||
#endif
|
||||
for (auto& b : tracked_species_info) {
|
||||
std::string type = json_string(parameter.jsonObjectFromBase(
|
||||
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Type: " + type);
|
||||
#endif
|
||||
if (SpeciesAlias::isAlias(type)) {
|
||||
b.second.type = SpeciesAlias::alias(type);
|
||||
} else {
|
||||
@@ -167,7 +181,9 @@ void SpeciesBuilder::fillTrackedSpecieType(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillBackgroundDensity(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill background density.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
b.second.density = buildConstantDensityField(parameter.jsonObjectFromBase(
|
||||
json_path_append(b.second.path_in_json, {"ConstantDensityField"})));
|
||||
@@ -175,7 +191,9 @@ void SpeciesBuilder::fillBackgroundDensity(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill velocity distributions.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
b.second.velocity_distribution = buildVelocityDistribution(
|
||||
parameter,
|
||||
@@ -189,7 +207,9 @@ void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill drift velocity.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
b.second.drift_velocity = buildDriftVelocityIncludingRedirection(
|
||||
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
||||
@@ -201,7 +221,9 @@ void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillMass() {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill masses.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
b.second.mass_kg = SpeciesMasses::mass(b.second.type);
|
||||
}
|
||||
@@ -211,7 +233,9 @@ void SpeciesBuilder::fillMass() {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillCharge() {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill charges.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
b.second.charge_C = SpeciesCharges::charge(b.second.type);
|
||||
}
|
||||
@@ -221,7 +245,9 @@ void SpeciesBuilder::fillCharge() {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillMover(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill movers.");
|
||||
#endif
|
||||
for (auto& b : tracked_species_info) {
|
||||
if ((b.second.mover == nullptr)) {
|
||||
b.second.mover = buildMover(
|
||||
@@ -231,7 +257,9 @@ void SpeciesBuilder::fillMover(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillTerminator(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill terminators.");
|
||||
#endif
|
||||
for (auto& b : tracked_species_info) {
|
||||
if ((b.second.terminator == nullptr)) {
|
||||
b.second.terminator = buildTerminator(
|
||||
@@ -241,7 +269,9 @@ void SpeciesBuilder::fillTerminator(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillReflector(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill reflectors.");
|
||||
#endif
|
||||
for (auto& b : tracked_species_info) {
|
||||
if ((b.second.reflector == nullptr)) {
|
||||
b.second.reflector = buildReflector(
|
||||
@@ -252,7 +282,9 @@ void SpeciesBuilder::fillReflector(Parameter& parameter) {
|
||||
|
||||
// TBD: Fill and create dynamic density fields with pitch angle distribution
|
||||
void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill tracked density.");
|
||||
#endif
|
||||
for (auto& b : tracked_species_info) {
|
||||
b.second.density_field = buildDynamicDensityField(
|
||||
parameter,
|
||||
@@ -270,7 +302,9 @@ void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::buildSpecies() {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Build species from info.");
|
||||
#endif
|
||||
for (auto& b : background_species_info) {
|
||||
background_species[b.first] = std::shared_ptr<species::BackgroundSpecie>(
|
||||
new species::BackgroundSpecie(
|
||||
@@ -290,7 +324,9 @@ void SpeciesBuilder::buildSpecies() {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillCurrentCollector(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill current collectors.");
|
||||
#endif
|
||||
for (auto& b : tracked_species) {
|
||||
auto current_collector = buildCurrentCollector(
|
||||
parameter,
|
||||
@@ -302,7 +338,9 @@ void SpeciesBuilder::fillCurrentCollector(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillLoggers(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill loggers.");
|
||||
#endif
|
||||
for (auto& b : tracked_species) {
|
||||
auto deletion_logger = buildDeletionLogger(
|
||||
parameter,
|
||||
@@ -313,7 +351,9 @@ void SpeciesBuilder::fillLoggers(Parameter& parameter) {
|
||||
}
|
||||
|
||||
void SpeciesBuilder::fillInteractions(Parameter& parameter) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Fill interactions.");
|
||||
#endif
|
||||
for (auto& b : tracked_species) {
|
||||
json_path path = tracked_species_info[b.first].path_in_json;
|
||||
path = json_path_append(path, {"Interactions"});
|
||||
|
||||
@@ -7,13 +7,17 @@ namespace generator {
|
||||
std::shared_ptr<Terminator> buildTerminator(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_terminator) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating terminator.");
|
||||
#endif
|
||||
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
||||
json_path_append(path_to_terminator, {"MaximumInteractions"})));
|
||||
double max_time_alive = parameter.doubleValue(
|
||||
json_path_append(path_to_terminator, {"MaxTimeAlive", "value"}));
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
||||
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
||||
#endif
|
||||
|
||||
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
||||
parameter, json_path_append(path_to_terminator, {"BoundaryGeometry"}));
|
||||
|
||||
@@ -53,7 +53,9 @@ blitz::Array<double, 3> readComponentFromFile(json_t* object, int component) {
|
||||
|
||||
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||
if (json_object_by_path(object, {"VectorFieldConstant"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldConstant");
|
||||
#endif
|
||||
blitz::TinyVector<double, 3> constant = json_blitz_vector<3>(
|
||||
json_object_by_path(object, {"VectorFieldConstant", "constant"}));
|
||||
|
||||
@@ -61,13 +63,17 @@ std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||
new VectorFieldConstant(CylinderVector(constant)));
|
||||
|
||||
} else if (json_object_by_path(object, {"VectorFieldFunctionInZ"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFunctionInZ");
|
||||
#endif
|
||||
std::function<double(double, double, double)> z_function = function3D(
|
||||
json_object_by_path(object, {"VectorFieldFunctionInZ", "zFunction"}));
|
||||
return std::shared_ptr<VectorField>(new VectorFieldFunctionInZ(z_function));
|
||||
|
||||
} else if (json_object_by_path(object, {"VectorFieldFromArray"})) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
||||
#endif
|
||||
|
||||
blitz::Array<double, 3> v_radial = readComponentFromFile(
|
||||
json_object_by_path(object,
|
||||
|
||||
@@ -11,8 +11,10 @@ std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
||||
const json_path& path_to_distribution) {
|
||||
if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_distribution, {"IsotropicDistribution"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2(
|
||||
"Creating velocity distribution function: IsotropicDistribution");
|
||||
#endif
|
||||
std::shared_ptr<EnergyDistributionFunction> fE =
|
||||
buildEnergyDistributionFunction(
|
||||
parameter, json_path_append(path_to_distribution,
|
||||
@@ -26,8 +28,10 @@ std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
||||
|
||||
} else if (parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_distribution, {"DirectedDistribution"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2(
|
||||
"Creating velocity distribution function: DirectedDistribution");
|
||||
#endif
|
||||
std::shared_ptr<EnergyDistributionFunction> fE =
|
||||
buildEnergyDistributionFunction(
|
||||
parameter, json_path_append(path_to_distribution,
|
||||
|
||||
@@ -10,8 +10,10 @@ std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
||||
const json_path& path_to_distribution) {
|
||||
if (parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_distribution, {"VelocityDistributionFromFunction"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2(
|
||||
"Creating velocity distribution: VelocityDistributionFromFunction");
|
||||
#endif
|
||||
std::shared_ptr<VelocityDistributionFunction> v =
|
||||
buildVelocityDistributionFunction(
|
||||
parameter, json_path_append(path_to_distribution,
|
||||
@@ -21,7 +23,9 @@ std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
||||
new VelocityDistributionFromFunction(v));
|
||||
} else if (parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_distribution, {"null"}))) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Creating velocity distribution: null");
|
||||
#endif
|
||||
return nullptr;
|
||||
} else {
|
||||
ERROR("This velocity distribution is not implemented.");
|
||||
|
||||
@@ -13,7 +13,9 @@ ChargeExchange::ChargeExchange(std::function<double(double)> cross_section,
|
||||
InteractionOutput ChargeExchange::performInteraction(
|
||||
particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform charge exchange.");
|
||||
#endif
|
||||
|
||||
// const auto x_impact = particle.position();
|
||||
// const blitz::TinyVector<double, 3> v_target =
|
||||
|
||||
@@ -17,7 +17,9 @@ ClusterFormation::ClusterFormation(
|
||||
InteractionOutput ClusterFormation::performInteraction(
|
||||
particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform cluster formation.");
|
||||
#endif
|
||||
const auto x_impact = particle.position();
|
||||
// const blitz::TinyVector<double, 3> v_target =
|
||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
||||
|
||||
@@ -18,7 +18,9 @@ ElasticScattering::ElasticScattering(
|
||||
InteractionOutput ElasticScattering::performInteraction(
|
||||
particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform elastic scattering.");
|
||||
#endif
|
||||
const blitz::TinyVector<double, 3> v_impact =
|
||||
particle.velocity().cartesianEntries();
|
||||
// const auto x_impact = particle.position();
|
||||
|
||||
@@ -18,7 +18,9 @@ Excitation::Excitation(std::function<double(double)> cross_section,
|
||||
|
||||
InteractionOutput Excitation::performInteraction(particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform excitation.");
|
||||
#endif
|
||||
const blitz::TinyVector<double, 3> v_impact =
|
||||
particle.velocity().cartesianEntries();
|
||||
const blitz::TinyVector<double, 3> n_impact =
|
||||
|
||||
@@ -10,7 +10,9 @@ FreeMovement::FreeMovement()
|
||||
|
||||
InteractionOutput FreeMovement::performInteraction(particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform free movement.");
|
||||
#endif
|
||||
// do nothing
|
||||
return InteractionOutput();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ ElectronIonization::ElectronIonization(
|
||||
InteractionOutput ElectronIonization::performInteraction(
|
||||
particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform ionization.");
|
||||
#endif
|
||||
|
||||
const blitz::TinyVector<double, 3> v_impact =
|
||||
particle.velocity().cartesianEntries();
|
||||
|
||||
@@ -17,7 +17,9 @@ Recombination::Recombination(std::function<double(double)> cross_section,
|
||||
InteractionOutput Recombination::performInteraction(
|
||||
particle::Particle& particle,
|
||||
RandomNumbers* generator) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform recombination.");
|
||||
#endif
|
||||
|
||||
// std::vector<double> macroscopic_bin_cross_sections_m;
|
||||
// const int number_energy_bins = recombination_target_->dynamicDensityField()
|
||||
|
||||
@@ -85,14 +85,18 @@ void PoissonSolver::solvePotential(
|
||||
if (!(do_solver_) || !(solve)) {
|
||||
return;
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||
#endif
|
||||
blitz::Array<double, 3> interpolated_density =
|
||||
interpolateDensityToPotentialGrid(charge_density);
|
||||
int it = 1;
|
||||
do {
|
||||
solverIteration(interpolated_density);
|
||||
if (it % 1000 == 0) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Poisson solver, iteration: " + std::to_string(it));
|
||||
#endif
|
||||
if (converged(interpolated_density)) {
|
||||
break;
|
||||
};
|
||||
@@ -235,14 +239,18 @@ bool PoissonSolver::converged(
|
||||
|
||||
normalized_difference =
|
||||
std::sqrt(cumulated_quadradic_difference / (nr * nth * nz));
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Poisson solver reached a normalized difference of: " +
|
||||
std::to_string(normalized_difference));
|
||||
#endif
|
||||
double normalized_maximum =
|
||||
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
||||
#ifdef debug_level1
|
||||
std::ostringstream message;
|
||||
message << "Maximum Difference normalized by order of magnitude: "
|
||||
<< normalized_difference;
|
||||
DEBUG_LEVEL_0(message.str());
|
||||
DEBUG_LEVEL_1(message.str());
|
||||
#endif
|
||||
return normalized_difference < target_accuracy_;
|
||||
}
|
||||
|
||||
@@ -250,7 +258,9 @@ blitz::Array<double, 3> PoissonSolver::potential() {
|
||||
// there might be a better way to do this... (if one can do array.memberValue without
|
||||
// explicitely looping)
|
||||
blitz::Array<double, 3> potentialValues(potential_.lbound(), potential_.extent());
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Extracting potential values");
|
||||
#endif
|
||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||
@@ -293,9 +303,10 @@ blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||
//might not work that way (if not needs a loop)
|
||||
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /=
|
||||
potential_.extent(1);
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
||||
std::to_string(blitz::max(interpolatedDensity)));
|
||||
#endif
|
||||
//for r=r_max, k=k_min and k=k_max do not use an interpolation,
|
||||
//since no boundary cell needs the information about its density value
|
||||
return interpolatedDensity;
|
||||
|
||||
@@ -186,12 +186,14 @@ bool DynamicDensityField::changedPitchAngleBin(double old_mu,
|
||||
const int old_bin = pitch_angle_binning_.bin(old_mu);
|
||||
const int new_bin = pitch_angle_binning_.bin(new_mu);
|
||||
|
||||
#ifdef debug_level3
|
||||
if(!(old_bin == new_bin)) {
|
||||
DEBUG_LEVEL_3("old mu: " + std::to_string(old_mu));
|
||||
DEBUG_LEVEL_3("old bin: " + std::to_string(old_bin));
|
||||
DEBUG_LEVEL_3("new mu: " + std::to_string(new_mu));
|
||||
DEBUG_LEVEL_3("new bin: " + std::to_string(new_bin));
|
||||
}
|
||||
#endif
|
||||
|
||||
return !(old_bin == new_bin);
|
||||
}
|
||||
@@ -225,7 +227,9 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
||||
// }
|
||||
|
||||
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("recalc Density array");
|
||||
#endif
|
||||
recalculateDensityArray();
|
||||
|
||||
blitz::TinyVector<int,3> lowerbound(density_per_m3_.lbound(0),
|
||||
@@ -237,7 +241,7 @@ blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
||||
blitz::Array<double, 3> density(lowerbound, extent);
|
||||
|
||||
blitz::fourthIndex iE;
|
||||
DEBUG_LEVEL_3("density sum");
|
||||
// DEBUG_LEVEL_3("density sum");
|
||||
density = blitz::sum(density_per_m3_, iE);
|
||||
return density.copy();
|
||||
}
|
||||
@@ -303,7 +307,9 @@ void DynamicDensityField::recalculateDensityArray() {
|
||||
double DynamicDensityField::particleNumber() {
|
||||
blitz::Array<double, 3> density = densityArray();
|
||||
double particleNumber = blitz::sum(density * bin_volume_m3_);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("particle number: " + std::to_string(particleNumber));
|
||||
#endif
|
||||
return particleNumber;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,10 @@ std::vector<particle::Particle> Injector::rollNewParticles(
|
||||
for (auto& injector_info : injector_infos_) {
|
||||
|
||||
CylinderCoordinate position = position_distribution_->rollPosition(engine);
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Injected z position: " +
|
||||
std::to_string(position.cylinderEntries()(2)));
|
||||
#endif
|
||||
|
||||
// for (int i = 0; i < injector_info.multiplicity; i++) {
|
||||
new_particles.push_back(
|
||||
@@ -102,12 +104,12 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
CylinderCoordinate position =
|
||||
specie->positionDistributionFromDensity()->drawPosition(engine,
|
||||
index(0), index(1), index(2));
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Injected z position: " +
|
||||
std::to_string(position.cylinderEntries()(2)));
|
||||
DEBUG_LEVEL_3("Injected r position: " +
|
||||
std::to_string(position.cylinderEntries()(0)));
|
||||
|
||||
#endif
|
||||
// draw the velocity
|
||||
CartesianVector velocity(blitz::TinyVector<double, 3>(0,0,0));
|
||||
|
||||
|
||||
@@ -48,30 +48,42 @@ void Simulation::init(Parameter& parameter) {
|
||||
electric_field_ = generator::electricField(parameter);
|
||||
gravity_field_ = generator::gravityField(parameter);
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Creating species.");
|
||||
#endif
|
||||
generator::SpeciesBuilder builder(parameter);
|
||||
tracked_species_ = builder.trackedSpecies();
|
||||
background_species_ = builder.backgroundSpecies();
|
||||
timer_ = builder.timer();
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Creating injector.");
|
||||
#endif
|
||||
injector_ = generator::buildInjector(tracked_species_, background_species_,
|
||||
parameter);
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Init random numbers.");
|
||||
#endif
|
||||
random_ = generator::buildRandomNumbers(parameter);
|
||||
|
||||
for(auto& tracked_specie : tracked_species_) {
|
||||
tracked_specie.second->randomIndex()->reshuffle(random_->engine());
|
||||
}
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Init poisson solver.");
|
||||
#endif
|
||||
poisson_solver_ = generator::buildPoissonSolver(parameter);
|
||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Init cpu synchronizer.");
|
||||
#endif
|
||||
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Init done.");
|
||||
#endif
|
||||
|
||||
Restart restarter = generator::buildRestart(parameter);
|
||||
restarter.restart(tracked_species_, poisson_solver_.get(), random_.get());
|
||||
@@ -82,11 +94,15 @@ void Simulation::init(Parameter& parameter) {
|
||||
// writing the metadata
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Init output.");
|
||||
#endif
|
||||
output_ = generator::buildSimulationOutput(
|
||||
parameter.jsonObjectFromBase({"Output"}), tracked_species_);
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Output meta data.");
|
||||
#endif
|
||||
output_->writeMetaData(tracked_species_, poisson_solver_);
|
||||
}
|
||||
|
||||
@@ -151,7 +167,9 @@ void Simulation::start() {
|
||||
const double density_weight_factor =
|
||||
1./(MpiCommunication::mpiSize()*particles_per_bin);
|
||||
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Number of particles per bin per CPU: " + std::to_string(particles_per_bin));
|
||||
#endif
|
||||
|
||||
SIM_INFO("Number of Timesteps: " + std::to_string(number_timesteps));
|
||||
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
||||
@@ -197,9 +215,11 @@ void Simulation::start() {
|
||||
int density_events_of_cycle =
|
||||
eventsOfCycle(density_stride, leftover_density_events);
|
||||
|
||||
#ifdef debug_level1
|
||||
DEBUG_LEVEL_1("Events of cycle: " + std::to_string(events_of_cycle));
|
||||
DEBUG_LEVEL_1("Density Events of cycle: " +
|
||||
std::to_string(density_events_of_cycle));
|
||||
#endif
|
||||
|
||||
SIM_INFO("Processing timestep: " + std::to_string(timesteps));
|
||||
SIM_INFO("Leftover events this timestep this CPU: " +
|
||||
@@ -211,9 +231,11 @@ void Simulation::start() {
|
||||
processDensityEvents(particles_per_bin, density_weight_factor);
|
||||
processEvents(events_of_cycle, beta_particle_weight);
|
||||
|
||||
#ifdef debug_level1
|
||||
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timesteps));
|
||||
DEBUG_LEVEL_1("Leftover events this timestep: " +
|
||||
std::to_string(leftover_events_time_resolution));
|
||||
#endif
|
||||
|
||||
leftover_events_time_resolution -= events_of_cycle;
|
||||
leftover_density_events -= density_events_of_cycle;
|
||||
@@ -274,18 +296,24 @@ int particleNumberFromQueue(int queue_length, RandomNumbers* random) {
|
||||
}
|
||||
|
||||
void Simulation::processEvents(int events, const double beta_particle_weight) {
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Processing events.");
|
||||
#endif
|
||||
int current_event = 0;
|
||||
|
||||
while ((current_event < events) || (!queue_.empty())) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Current event: " + std::to_string(current_event));
|
||||
#endif
|
||||
|
||||
if (queue_.empty()) {
|
||||
std::vector<particle::Particle> new_particles;
|
||||
|
||||
current_event += 1;
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Inject particles to queue.");
|
||||
#endif
|
||||
SimulationTimer::eventStartPoint(std::string("ParticleInjection"));
|
||||
new_particles = determineInjectedParticles(random_.get(),
|
||||
beta_particle_weight);
|
||||
@@ -304,13 +332,17 @@ void Simulation::processEvents(int events, const double beta_particle_weight) {
|
||||
#endif
|
||||
SimulationTimer::eventStopPoint(std::string("ParticleInjection"));
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Injected particles to queue.");
|
||||
#endif
|
||||
|
||||
queue_.insert(queue_.end(), new_particles.begin(),
|
||||
new_particles.end());
|
||||
}
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Particles in queue: " +
|
||||
std::to_string(queue_.size()));
|
||||
#endif
|
||||
const int particle_number =
|
||||
particleNumberFromQueue(queue_.size(), random_.get());
|
||||
|
||||
@@ -324,7 +356,9 @@ void Simulation::processEvents(int events, const double beta_particle_weight) {
|
||||
}
|
||||
|
||||
void Simulation::processDensityEvents(int particles_per_bin, const double weight_factor) {
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Processing density events.");
|
||||
#endif
|
||||
// number of full grid traversions
|
||||
int current_event = 0;
|
||||
// set to true if all grids of all species have been visited
|
||||
@@ -340,12 +374,16 @@ void Simulation::processDensityEvents(int particles_per_bin, const double weight
|
||||
}
|
||||
|
||||
while ((current_event < particles_per_bin) || (!queue_.empty())) {
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Current event: " + std::to_string(current_event));
|
||||
#endif
|
||||
|
||||
if (queue_.empty()) {
|
||||
std::vector<particle::Particle> new_particles;
|
||||
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Current density event: " + std::to_string(current_event));
|
||||
#endif
|
||||
|
||||
SimulationTimer::eventStartPoint(std::string("DensityInjection"));
|
||||
new_particles = determineInjectedDensityParticles(random_.get(),
|
||||
@@ -381,8 +419,10 @@ void Simulation::processDensityEvents(int particles_per_bin, const double weight
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef debug_level2
|
||||
DEBUG_LEVEL_2("Particles in queue: " +
|
||||
std::to_string(queue_.size()));
|
||||
std::to_string(queue_.size()));
|
||||
#endif
|
||||
const int particle_number =
|
||||
particleNumberFromQueue(queue_.size(), random_.get());
|
||||
|
||||
@@ -397,8 +437,10 @@ void Simulation::processDensityEvents(int particles_per_bin, const double weight
|
||||
|
||||
void Simulation::processUntilTermination(
|
||||
particle::Particle& particle) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Process particle until termination");
|
||||
DEBUG_LEVEL_3("Weight of the particle: " + std::to_string(particle.weight()));
|
||||
#endif
|
||||
while (particle.specie()->terminator()->isAlive(&particle)) {
|
||||
auto old_position = particle.position();
|
||||
double old_energy = particle.kineticEnergy_eV();
|
||||
@@ -419,7 +461,9 @@ void Simulation::processUntilTermination(
|
||||
bool was_reflected = false;
|
||||
if (particle.specie()->reflector()->needsReflectionBackToDomain(
|
||||
&particle)) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Reflect particle.");
|
||||
#endif
|
||||
old_position = particle.position();
|
||||
particle.specie()->reflector()->reflectBackToDomain(&particle);
|
||||
particle.specie()->currentCollector()->collect(&particle, old_position);
|
||||
@@ -428,8 +472,10 @@ void Simulation::processUntilTermination(
|
||||
|
||||
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
||||
&particle)) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
|
||||
". Reached timeresolution.");
|
||||
#endif
|
||||
if(particle.specie()->deletionLogger()) {
|
||||
particle.specie()->deletionLogger()->logDeletion(particle.position(),
|
||||
DeletionType::max_time_alive);
|
||||
@@ -438,12 +484,12 @@ void Simulation::processUntilTermination(
|
||||
} else if (particle.specie()->terminator()->leftSimulationDomain(
|
||||
&particle)) {
|
||||
#if defined debug_level3
|
||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name()
|
||||
DEBUG_LEVEL_1("Terminate particle " + particle.specie()->name()
|
||||
+ ". Left simulation domain.");
|
||||
std::stringstream output_ss;
|
||||
output_ss << "Position (cyl): " << particle.position().cylinderEntries();
|
||||
output_ss << " (cart): " << particle.position().cartesianEntries();
|
||||
DEBUG_LEVEL_3(output_ss.str());
|
||||
// ERROR(output_ss.str());
|
||||
#endif
|
||||
if (particle.specie()->deletionLogger()) {
|
||||
particle.specie()->deletionLogger()->logDeletion(particle.position(),
|
||||
@@ -457,12 +503,12 @@ void Simulation::processUntilTermination(
|
||||
!(particle.specie()->dynamicDensityField()->changedEnergyBin(
|
||||
old_energy, particle.kineticEnergy_eV())) &&
|
||||
!was_reflected) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Perform interaction.");
|
||||
DEBUG_LEVEL_3("Number of Interactions: " +
|
||||
std::to_string(particle.interactionCounter()));
|
||||
DEBUG_LEVEL_3("Ekin before interact: " +
|
||||
std::to_string(particle.kineticEnergy_eV()));
|
||||
#if defined debug_level3
|
||||
std::stringstream output_ss;
|
||||
output_ss << "Position (cyl): " << particle.position().cylinderEntries();
|
||||
// output_ss << "\n (cart): " << particle.position().cartesianEntries();
|
||||
@@ -481,13 +527,17 @@ void Simulation::processUntilTermination(
|
||||
}
|
||||
|
||||
if (output.deleteCurrentParticle()) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3(particle.specie()->name() + " removed due to interaction.");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (particle.specie()->terminator()->reachedMaxInteractions(&particle)) {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name()
|
||||
+ ". Reached max interactions.");
|
||||
#endif
|
||||
if (particle.specie()->deletionLogger()) {
|
||||
particle.specie()->deletionLogger()->logDeletion(
|
||||
particle.position(), DeletionType::max_interactions);
|
||||
@@ -611,7 +661,9 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
||||
|
||||
if (particleNumbers[pair.first] == 0) {
|
||||
all_bins_done = all_bins_done && true;
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("No particles in density of species: " + pair.second->name());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -639,26 +691,36 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
||||
|
||||
//maybe put that into the poisson solver
|
||||
blitz::Array<double,3> Simulation::chargedensity() {
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Initialize chargedensity Array");
|
||||
#endif
|
||||
//not great but the size and bounds of the density arrays are needed...
|
||||
std::shared_ptr<species::TrackedSpecie> firstTracked =
|
||||
tracked_species_.begin()->second;
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("shared pointer extracted, key: "
|
||||
+ tracked_species_.begin()->first);
|
||||
#endif
|
||||
|
||||
if(!firstTracked)
|
||||
ERROR("Extracted pointer is null.");
|
||||
|
||||
blitz::Array<double,3> init = firstTracked->
|
||||
dynamicDensityField()->densityArray();
|
||||
blitz::Array<double, 3> chargeden(init.lbound(), init.extent());
|
||||
chargeden = 0.;
|
||||
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Collect chargedensity");
|
||||
#endif
|
||||
for (auto& pair : tracked_species_) {
|
||||
chargeden += pair.second->charge_C() * pair.second->dynamicDensityField()->
|
||||
densityArray();
|
||||
}
|
||||
#ifdef debug_level3
|
||||
DEBUG_LEVEL_3("Maximum value in the chargedensity: " +
|
||||
std::to_string(blitz::max(chargeden)));
|
||||
#endif
|
||||
|
||||
return chargeden;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user