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:
@@ -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