121 lines
3.9 KiB
C++
Executable File
121 lines
3.9 KiB
C++
Executable File
#ifndef DENSITY_FIELD_H
|
|
#define DENSITY_FIELD_H
|
|
|
|
#include <memory>
|
|
#include <random>
|
|
|
|
#include "simulation/compare.h"
|
|
#include "simulation/coordinates.h"
|
|
#include "simulation/cpu_synchronizer.h"
|
|
#include "simulation/energy_binning.h"
|
|
#include "simulation/position_binning.h"
|
|
#include "simulation/timer.h"
|
|
|
|
class ScalarField;
|
|
class EventPositionDistribution;
|
|
|
|
class DensityField {
|
|
public:
|
|
virtual double density(const Coordinate& position) = 0;
|
|
virtual double density(const Coordinate& position, double energy_eV) = 0;
|
|
};
|
|
|
|
// includes a resolution of the pitch angle (i.e. cos(angle(\vec{v}, \vec{B})))
|
|
class DynamicDensityField : public DensityField {
|
|
public:
|
|
|
|
DynamicDensityField(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);
|
|
|
|
// return the particle number stored in the density of this object
|
|
double particleNumber();
|
|
|
|
// returns true if the old pitch angle and the new pitch angle are in different bins
|
|
// of the pitch angle binning
|
|
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;
|
|
|
|
// return an array of the density values at the Coordinate position (only energy
|
|
// direction left); over and underflow bin are removed
|
|
// (might not be good, since then the underflow particles are lost...)
|
|
blitz::Array<double, 1> sliceSpectrumArray(const Coordinate& position) const;
|
|
|
|
// return an array of the time in bin at the Coordinate position and the energy
|
|
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
|
blitz::Array<double, 1> sliceTimeInBinArray(const Coordinate& position,
|
|
double energy_eV) 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 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:
|
|
|
|
void recalculateDensityArray();
|
|
|
|
// 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_;
|
|
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);
|
|
|
|
double density(const Coordinate& position);
|
|
double density(const Coordinate& position, double energy_eV);
|
|
|
|
private:
|
|
std::shared_ptr<ScalarField> density_;
|
|
};
|
|
|
|
#endif /* DENSITY_FIELD_H */
|