Implemented pitch angle resolution.

Still includes (and uses) the non-pitch angle
resolved fields as well; have to be either removed
completely or refactored s.t. one of the two options
is chosen.
Pitch angle distribution has a hardcoded number of
bins for now, and exists in 'energy_binning.h'
This commit is contained in:
2024-10-28 15:00:19 +01:00
parent b4cbd8c44c
commit 5fc227e1b1
24 changed files with 1126 additions and 42 deletions
+107 -3
View File
@@ -46,6 +46,8 @@ void SimulationOutput::writeMetaData(
std::string specie_path = "/" + task.specie_name;
writeMetaData(species.at(task.specie_name)->dynamicDensityField(),
specie_path);
writeMetaData(species.at(task.specie_name)->dynamicDensityFieldWithPitchAngle(),
specie_path);
}
for (auto& task : tasks_current_collector_) {
@@ -60,6 +62,7 @@ void SimulationOutput::writeMetaData(
}
}
}
void SimulationOutput::writeSimulationData(
int cpu_sync,
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
@@ -70,6 +73,8 @@ void SimulationOutput::writeSimulationData(
for (auto& task : tasks_density_fields_) {
if (cpu_sync % task.intervall == 0) {
std::string specie_path = "/" + task.specie_name;
writeSimulationData(species.at(task.specie_name)->dynamicDensityFieldWithPitchAngle(),
specie_path, cpu_sync, task.overwrite_last);
writeSimulationData(species.at(task.specie_name)->dynamicDensityField(),
specie_path, cpu_sync, task.overwrite_last);
}
@@ -99,7 +104,7 @@ void SimulationOutput::writeSimulationData(
}
// if the rng intervall = 0 (no neg. intervalls allowed) -> no output,
// otherwise the intervall used the same as for the other output
// otherwise the intervall used the same as for the other outputs
if((task_rng_.intervall > 0) && (cpu_sync%task_rng_.intervall == 0)) {
writeRestartData(engine, cpu_sync, task_rng_.overwrite_last);
}
@@ -127,6 +132,28 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
writePhysicalTime(density_field, path);
}
void SimulationOutput::writeSimulationData(DynamicDensityFieldWithPitchAngle* density_field,
std::string species_path,
int cpu_sync,
bool overwrite_last) {
std::string sync_path = "SyncPeriod_" + std::to_string(cpu_sync);
if (overwrite_last) {
sync_path = "LastSyncPeriod";
}
std::string path = species_path + "/DensityFieldWithPitchAngle/SimulationData/" + sync_path;
DEBUG_LEVEL_3("Write spectrum.");
writeSpectrum(density_field, path);
DEBUG_LEVEL_3("Write density.");
writeDensity(density_field, path);
DEBUG_LEVEL_3("Write time in bin.");
writeTimeInBin(density_field, path);
DEBUG_LEVEL_3("Write deleted particles.");
writeDeletedParticles(density_field, path);
DEBUG_LEVEL_3("Write physical time.");
writePhysicalTime(density_field, path);
}
void SimulationOutput::writeSimulationData(CurrentCollector* current_collector,
std::string species_path,
int cpu_sync,
@@ -188,8 +215,6 @@ void SimulationOutput::writeRestartData(std::mt19937* engine, int cpu_sync,
void SimulationOutput::writeRandomEngineState(std::mt19937* engine, std::string path) {
std::ostringstream engine_state;
engine_state << (*engine);
DEBUG_LEVEL_0(std::to_string(engine_state.str().size()));
DEBUG_LEVEL_0(std::to_string(sizeof(*engine)));
writer.writeRNG(engine_state.str(), path);
}
@@ -248,23 +273,55 @@ void SimulationOutput::writeSpectrum(DynamicDensityField* density_field,
writer.write(density_field->spectrumArray(), path + "/Spectrum");
}
void SimulationOutput::writeSpectrum(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
writer.write(density_field->spectrumArray(), path + "/Spectrum");
}
void SimulationOutput::writeDensity(DynamicDensityField* density_field,
std::string path) {
writer.write(density_field->densityArray(), path + "/Density");
}
void SimulationOutput::writeDensity(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
writer.write(density_field->densityArray(), path + "/Density");
}
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
std::string path) {
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
}
void SimulationOutput::writeTimeInBin(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
}
void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
std::string path) {
writer.write(density_field->deletedParticlesArray(),
path + "/DeletedParticles");
}
void SimulationOutput::writeDeletedParticles(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
writer.write(density_field->deletedParticlesArray(),
path + "/DeletedParticles");
}
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
std::string path) {
writer.write(density_field->physicalTime(), path + "/PhysicalTime");
}
void SimulationOutput::writePhysicalTime(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
writer.write(density_field->physicalTime(), path + "/PhysicalTime");
}
void SimulationOutput::writePotential(PoissonSolver* poisson_solver, std::string path) {
writer.write(poisson_solver->potential(), path + "/Potential");
}
@@ -285,6 +342,53 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
writeNumBins(density_field, path_to_field);
}
void SimulationOutput::writeMetaData(DynamicDensityFieldWithPitchAngle* density_field,
std::string path) {
std::string path_to_field = path + "/DensityFieldWithPitchAngle";
// write bin volumes
{
std::string path_to_volume = path_to_field + "/BinVolumes";
writer.write(density_field->binVolumeArray(), path_to_volume);
}
// write bin borders
{
std::string path_to_bin_borders = path_to_field + "/BinBorders";
std::vector<double> energy_bin_borders =
density_field->energyBinning()->binBorders();
writer.write(energy_bin_borders, path_to_bin_borders + "/energy");
std::vector<double> mu_bin_borders =
density_field->pitchAngleBinning()->binBorders();
writer.write(mu_bin_borders, path_to_bin_borders + "/pitchAngle");
std::vector<double> radial_bin_borders =
density_field->positionBinning()->radial_binning.binBorders();
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
std::vector<double> azimuth_bin_borders =
density_field->positionBinning()->azimuth_binning.binBorders();
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
std::vector<double> longitudinal_bin_borders =
density_field->positionBinning()->longitudinal_binning.binBorders();
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
}
// write num bins
{
std::string path_to_num_bins = path_to_field + "/NumBins";
blitz::TinyVector<int, 4> num_bins = density_field->spectrumArray().extent();
writer.write(num_bins(0), path_to_num_bins + "/energy");
writer.write(num_bins(1), path_to_num_bins + "/radial");
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
}
}
void SimulationOutput::writeMetaData(CurrentCollector* current_collector,
std::string path) {
std::string path_to_collector = path + "/CurrentCollector";