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:
@@ -9,12 +9,14 @@ class Hdf5Reader {
|
||||
Hdf5Reader(std::string directory, std::string filename);
|
||||
Hdf5Reader(std::string absolute_filename);
|
||||
|
||||
blitz::Array<double, 5> readD5Double(std::string path);
|
||||
blitz::Array<double, 4> readD4Double(std::string path);
|
||||
blitz::Array<double, 3> readD3Double(std::string path);
|
||||
blitz::Array<double, 2> readD2Double(std::string path);
|
||||
blitz::Array<double, 1> readD1Double(std::string path);
|
||||
double readDouble(std::string path);
|
||||
|
||||
blitz::Array<long int, 5> readD5LongInt(std::string path);
|
||||
blitz::Array<long int, 4> readD4LongInt(std::string path);
|
||||
|
||||
std::stringstream readEngineString(std::string path);
|
||||
|
||||
@@ -14,7 +14,9 @@ class Hdf5Writer {
|
||||
void write(const blitz::Array<double, 2>& data, std::string path);
|
||||
void write(const blitz::Array<double, 3>& data, std::string path);
|
||||
void write(const blitz::Array<double, 4>& data, std::string path);
|
||||
void write(const blitz::Array<double, 5>& data, std::string path);
|
||||
void write(const blitz::Array<long int, 4>& data, std::string path);
|
||||
void write(const blitz::Array<long int, 5>& data, std::string path);
|
||||
void write(const blitz::TinyVector<double, 3>& data, std::string path);
|
||||
void write(const blitz::TinyVector<int, 3>& data, std::string path);
|
||||
void write(const std::vector<double>& data, std::string path);
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace species {
|
||||
}; // namespace species
|
||||
|
||||
class DynamicDensityField;
|
||||
class DynamicDensityFieldWithPitchAngle;
|
||||
class PoissonSolver;
|
||||
class RandomNumbers;
|
||||
|
||||
@@ -32,6 +33,8 @@ class Restart {
|
||||
private:
|
||||
void restartTimer(species::TrackedSpecie* reference_specie);
|
||||
void restartDrawingDensityField(DynamicDensityField* field, std::string path); // only necc densityfield for the one that is drawn from
|
||||
void restartDrawingDensityField(DynamicDensityFieldWithPitchAngle* field,
|
||||
std::string path);
|
||||
void restartPoissonSolver(PoissonSolver* solver); // only load in the potential and calc the electric field
|
||||
void restartRandomNumbers(RandomNumbers* random);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "IO/hdf5_writer.h"
|
||||
|
||||
class DynamicDensityField;
|
||||
class DynamicDensityFieldWithPitchAngle;
|
||||
class CurrentBorder;
|
||||
class Parameter;
|
||||
class CurrentCollector;
|
||||
@@ -61,12 +62,23 @@ class SimulationOutput {
|
||||
int cpu_sync,
|
||||
bool overwrite_last);
|
||||
|
||||
void writeSimulationData(DynamicDensityFieldWithPitchAngle* density_field,
|
||||
std::string species_path,
|
||||
int cpu_sync,
|
||||
bool overwrite_last);
|
||||
|
||||
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
||||
void writeSpectrum(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
||||
void writeDensity(DynamicDensityField* density_field, std::string path);
|
||||
void writeDensity(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
||||
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
||||
void writeTimeInBin(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
||||
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||
std::string path);
|
||||
void writeDeletedParticles(DynamicDensityFieldWithPitchAngle* density_field,
|
||||
std::string path);
|
||||
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
||||
void writePhysicalTime(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
||||
|
||||
void writeSimulationData(CurrentCollector* current_collector,
|
||||
std::string species_path,
|
||||
@@ -94,6 +106,7 @@ class SimulationOutput {
|
||||
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
||||
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
||||
void writeMetaData(PoissonSolver* poisson_solver, std::string path);
|
||||
void writeMetaData(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
||||
// void writeParameterFile(Parameter* parameter);
|
||||
|
||||
void writeCollectorAreas(CurrentCollector* current_collector,
|
||||
|
||||
@@ -15,6 +15,11 @@ std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
||||
const json_path& path_to_field,
|
||||
std::shared_ptr<Timer>& timer);
|
||||
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> buildDynamicDensityFieldWithPitchAngle(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_field,
|
||||
std::shared_ptr<Timer>& timer);
|
||||
|
||||
}; // namespace generator
|
||||
|
||||
#endif /* DENSITY_FIELD_GENERATOR_H */
|
||||
|
||||
@@ -25,6 +25,8 @@ struct TrackedSpeciesBuilderInfo {
|
||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
||||
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
||||
std::shared_ptr<DynamicDensityField> density_drawing_field;
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_field_pitch_angle;
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> pitch_angle_drawing;
|
||||
|
||||
double mass_kg;
|
||||
double charge_C;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "blitz/array.h"
|
||||
|
||||
class DynamicDensityField;
|
||||
class DynamicDensityFieldWithPitchAngle;
|
||||
class Timer;
|
||||
class CurrentCollector;
|
||||
class DeletionLogger;
|
||||
@@ -26,6 +27,9 @@ class CpuSynchronizer {
|
||||
void synchronize(DynamicDensityField* field,
|
||||
DynamicDensityField* density_for_drawing,
|
||||
bool reset);
|
||||
void synchronize(DynamicDensityFieldWithPitchAngle* field,
|
||||
DynamicDensityFieldWithPitchAngle* density_for_drawing,
|
||||
bool reset);
|
||||
void synchronize(CurrentCollector* collector);
|
||||
void synchronize(DeletionLogger* logger);
|
||||
void synchronize(Timer* timer, Timer* last_sync_timer);
|
||||
@@ -36,10 +40,14 @@ class CpuSynchronizer {
|
||||
*/
|
||||
void sumToAll(blitz::Array<double, 4>& array,
|
||||
blitz::Array<double, 4>& last_sync_array);
|
||||
void sumToAll(blitz::Array<double, 5>& array,
|
||||
blitz::Array<double, 5>& last_sync_array);
|
||||
void sumToAll(blitz::Array<double, 3>& array,
|
||||
blitz::Array<double, 3>& last_sync_array);
|
||||
void sumToAll(blitz::Array<long int, 4>& array,
|
||||
blitz::Array<long int, 4>& last_sync_array);
|
||||
void sumToAll(blitz::Array<long int, 5>& array,
|
||||
blitz::Array<long int, 5>& last_sync_array);
|
||||
void sumToAll(double& value, double& last_sync_value);
|
||||
void sumToAll(long int& value, long int& last_sync_value);
|
||||
};
|
||||
|
||||
@@ -105,6 +105,91 @@ class DynamicDensityField : public DensityField {
|
||||
bool timer_restarted_ = false;
|
||||
};
|
||||
|
||||
// includes a resolution of the pitch angle (i.e. cos(angle(\vec{v}, \vec{B})))
|
||||
class DynamicDensityFieldWithPitchAngle : public DensityField {
|
||||
public:
|
||||
|
||||
DynamicDensityFieldWithPitchAngle(const CylinderBinning& positionBinning,
|
||||
const EnergyBinning& energy_binning,
|
||||
const PitchAngleBinning& pitch_angle_binning,
|
||||
std::shared_ptr<Timer> timer);
|
||||
|
||||
double density(const Coordinate& position);
|
||||
double density(const Coordinate& position, double energy_eV);
|
||||
|
||||
bool changedPositionBin(const Coordinate& old_position,
|
||||
const Coordinate& new_position) const;
|
||||
|
||||
bool changedEnergyBin(double old_energy_eV, double new_energy_eV) const;
|
||||
|
||||
void logMovement(const Coordinate& position,
|
||||
double energy_eV,
|
||||
double pitch_angle,
|
||||
double time_in_bin_s);
|
||||
|
||||
void logDeletion(const Coordinate& position,
|
||||
double energy_eV,
|
||||
double pitch_angle);
|
||||
|
||||
double particleNumber();
|
||||
blitz::TinyVector<double, 5> draw(std::mt19937* engine);
|
||||
|
||||
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
||||
|
||||
blitz::Array<double, 3> densityArray();
|
||||
blitz::Array<double, 4> spectrumArray();
|
||||
blitz::Array<double, 5> timeInBinArray() const;
|
||||
blitz::Array<long int, 5> deletedParticlesArray() const;
|
||||
blitz::Array<double, 3> binVolumeArray() const;
|
||||
|
||||
const EnergyBinning* energyBinning() const;
|
||||
const CylinderBinning* positionBinning() const;
|
||||
const PitchAngleBinning* pitchAngleBinning() const;
|
||||
|
||||
double physicalTime() const;
|
||||
double timeResolution() const;
|
||||
|
||||
void resetDynamicDensityField();
|
||||
|
||||
friend class CpuSynchronizer;
|
||||
|
||||
void setDensityDistribution();
|
||||
|
||||
void restartTimer(double time, double delta_t);
|
||||
void restartTimeInBin(blitz::Array<double, 5> time_in_bin);
|
||||
void restartDeletedParticlesArray(blitz::Array<long int, 5> deleted_particles);
|
||||
|
||||
private:
|
||||
|
||||
// BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
||||
void recalculateDensityArray();
|
||||
void initPositionDistributions();
|
||||
// use ordering r, phi, z, pitch_angle, E
|
||||
|
||||
blitz::Array<double, 5> time_in_bin_s_;
|
||||
blitz::Array<long int, 5> deleted_particles_;
|
||||
|
||||
blitz::Array<double, 5> sync_time_in_bin_s_;
|
||||
blitz::Array<long int, 5> sync_deleted_particles_;
|
||||
|
||||
blitz::Array<double, 4> density_per_m3_;
|
||||
blitz::Array<double, 3> bin_volume_m3_;
|
||||
|
||||
const CylinderBinning position_binning_;
|
||||
const EnergyBinning energy_binning_;
|
||||
|
||||
// random distributions for drawing from
|
||||
std::uniform_real_distribution<double> r_dist_;
|
||||
std::uniform_real_distribution<double> phi_dist_;
|
||||
std::uniform_real_distribution<double> z_dist_;
|
||||
std::uniform_real_distribution<double> density_dist_;
|
||||
|
||||
const PitchAngleBinning pitch_angle_binning_;
|
||||
|
||||
std::shared_ptr<Timer> timer_;
|
||||
bool timer_restarted_ = false;
|
||||
};
|
||||
|
||||
class ConstantDensityField : public DensityField {
|
||||
public:
|
||||
ConstantDensityField(std::shared_ptr<ScalarField> density);
|
||||
|
||||
@@ -18,4 +18,22 @@ class EnergyBinning {
|
||||
const std::vector<double> energy_bin_borders_;
|
||||
};
|
||||
|
||||
// do a seperate class for the pitchangles now (questionable if it's
|
||||
// sensible to have it in here)
|
||||
// might become unneccessary in the future once the option for a linear
|
||||
// binning in the EnergyBinning class is implemented
|
||||
class PitchAngleBinning {
|
||||
public:
|
||||
PitchAngleBinning(int num_bins);
|
||||
|
||||
int bin(double pitch_angle) const;
|
||||
int numBins() const;
|
||||
std::vector<double> binBorders() const;
|
||||
int binIndexMin() const;
|
||||
int binIndexMax() const;
|
||||
|
||||
private:
|
||||
const std::vector<double> pitch_angle_bin_borders_;
|
||||
};
|
||||
|
||||
#endif /* ENERGY_BINNING_H */
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
class DriftVelocity;
|
||||
class VelocityDistribution;
|
||||
class DynamicDensityField;
|
||||
class MagneticField;
|
||||
|
||||
namespace particle {
|
||||
class Particle;
|
||||
@@ -45,6 +46,13 @@ class Injector {
|
||||
std::vector<particle::Particle>& queue,
|
||||
const double weight,
|
||||
const double injection_time);
|
||||
|
||||
void rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
std::shared_ptr<species::TrackedSpecie> specie,
|
||||
std::vector<particle::Particle>& queue,
|
||||
std::shared_ptr<MagneticField> field,
|
||||
const double weight,
|
||||
const double injection_time);
|
||||
|
||||
void initInjectionTimeDistribution(double delta_t);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class Reflector;
|
||||
class Injector;
|
||||
class DensityField;
|
||||
class DynamicDensityField;
|
||||
class DynamicDensityFieldWithPitchAngle;
|
||||
class ConstantDensityField;
|
||||
class DeletionLogger;
|
||||
class CurrentCollector;
|
||||
@@ -62,7 +63,9 @@ class TrackedSpecie : public Specie {
|
||||
std::shared_ptr<DynamicDensityField> density_field,
|
||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||
std::shared_ptr<DriftVelocity> drift_velocity,
|
||||
std::shared_ptr<DynamicDensityField> density_for_drawing);
|
||||
std::shared_ptr<DynamicDensityField> density_for_drawing,
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_field_pitch_angle,
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_mu_for_drawing);
|
||||
|
||||
DensityField* densityField();
|
||||
VelocityDistribution* velocityDistibution();
|
||||
@@ -78,6 +81,9 @@ class TrackedSpecie : public Specie {
|
||||
|
||||
DynamicDensityField* densityForDrawing();
|
||||
|
||||
DynamicDensityFieldWithPitchAngle* dynamicDensityFieldWithPitchAngle();
|
||||
DynamicDensityFieldWithPitchAngle* dynamicDensityFieldWithPitchAngleForDrawing();
|
||||
|
||||
CurrentCollector* currentCollector();
|
||||
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
||||
|
||||
@@ -86,6 +92,7 @@ class TrackedSpecie : public Specie {
|
||||
|
||||
private:
|
||||
std::shared_ptr<DynamicDensityField> density_field_;
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_field_pitch_angle_;
|
||||
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
||||
std::shared_ptr<DriftVelocity> drift_velocity_;
|
||||
|
||||
@@ -98,6 +105,7 @@ class TrackedSpecie : public Specie {
|
||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
||||
|
||||
std::shared_ptr<DynamicDensityField> density_for_drawing_;
|
||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_with_pitch_angle_for_drawing;
|
||||
};
|
||||
|
||||
class BackgroundSpecie : public Specie {
|
||||
|
||||
Reference in New Issue
Block a user