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
+44
View File
@@ -9,46 +9,79 @@
#include "simulation/position_binning.h"
#include "simulation/timer.h"
// defined in "simulation/scalar_field.h"
class ScalarField;
// defined in "simulation/event_position_dirstribution.h"
class EventPositionDistribution;
// class for a generic density field, specifying the minimum requirements
class DensityField {
public:
// pure virtual function requiring that a function to obtain the density (m^-3) at
// the Coordinate position is returned
virtual double density(const Coordinate& position) = 0;
// pure virtual function requiring that a function to obtain the density (m^-3) at
// the Coordinate position and energy energy_eV is returned
virtual double density(const Coordinate& position, double energy_eV) = 0;
};
// class for the density field for TrackedSpecies, i.e. simulated species
class DynamicDensityField : public DensityField {
public:
// Constructor: create the necessary array storing the time particles (4d r,phi,z,E) have spent in a bin,
// a corresponding array that stores the number of deletions (4d r,phi,z,E) in a bin
// as well as the 4d array for the actual density (in m^-3) and the
// array with the volumes of the individual bins from the CylinderBinning and EnergyBinnig
DynamicDensityField(const CylinderBinning& position_binning,
const EnergyBinning& energy_binning,
std::shared_ptr<Timer> timer);
// returns true if the bin of the old_position Coordinate and the bin of the
// new_position Coordinate are different otherwise returns false
bool changedPositionBin(const Coordinate& old_position,
const Coordinate& new_position) const;
// returns true if the bin of old_energy_eV is different than the bin of new_energy_eV
// otherwise returns false
bool changedEnergyBin(double old_energy_eV, double new_energy_eV) const;
// increases the value of the time_in_bin array by time_in_bin_s at the bin index
// determined by the Coordinate position and energy_eV
void logMovement(const Coordinate& position,
double energy_eV,
double time_in_bin_s);
// increases the value of the deleted_particles array by 1 at the bin index determined
// by position and energy_eV
void logDeletion(const Coordinate& position, double energy_eV);
// return the value of the density_per_m3 array at the bin index
// determined by the Coordinate position summed over all energy bins
double density(const Coordinate& position);
// return the value of the density_per_m3 array at the bin index
// determined by the Coordinate position and energy_eV
double density(const Coordinate& position, double energy_eV);
// calculate and return the 3d density array (m^-3), no resolution in the energy direction
blitz::Array<double, 3> densityArray();
// calculate and return the 4d density array (m^-3), with a resolution in energy direction
blitz::Array<double, 4> spectrumArray();
// getter for the time_in_bin array
blitz::Array<double, 4> timeInBinArray() const;
// getter for the deleted_particles array
blitz::Array<long int, 4> deletedParticlesArray() const;
// getter for the bin_volume_m3 array
blitz::Array<double, 3> binVolumeArray() const;
// return a raw pointer to the EnergyBinning member object
const EnergyBinning* energyBinning() const;
// return a raw pointer to the CylinderBinning member object
const CylinderBinning* positionBinning() const;
// return the time from the timer member
double physicalTime() const;
// make the private member variables accessable by the CpuSynchronizer
friend class CpuSynchronizer;
private:
@@ -66,11 +99,17 @@ class DynamicDensityField : public DensityField {
// 0, ..., num_bin_z-1: 0 <= z < z_max
// num_bin_z: z >= z_max
BinCoordinate densityBin(const CylinderCoordinate& position) const;
// uses time_in_bin, deleted_particles (4d), bin_volume_m3 (3d) and the timer to
// recalculate the density_per_m3 array (4d)
void recalculateDensityArray();
// array storing the cumulative time particles of a species have spent in certain bins
blitz::Array<double, 4> time_in_bin_s_;
// array storing the cumulative time particles of a species have been deleted due to recombination
blitz::Array<long int, 4> deleted_particles_;
// array storing the physical density (units: m^-3), histogram in energy dimension
blitz::Array<double, 4> density_per_m3_;
// arrya storing the volumes of the individual bins of the time_in_bin array (or rather the CylinderBinning object)
blitz::Array<double, 3> bin_volume_m3_;
const CylinderBinning position_binning_;
@@ -79,11 +118,16 @@ class DynamicDensityField : public DensityField {
std::shared_ptr<Timer> timer_;
};
// class for the density field for BackgroundSpecies, i.e. non-simulated species
class ConstantDensityField : public DensityField {
public:
// Constructor: making the shared_ptr density a member variable
ConstantDensityField(std::shared_ptr<ScalarField> density);
// return the value of the of the ScalarField density at the position Coordinate position
double density(const Coordinate& position);
// return the value of the of the ScalarField density at the position Coordinate position
// (energy_eV is ignored, since ScalarField does not have an energy resolution)
double density(const Coordinate& position, double energy_eV);
private: