removed the 4d density field
This commit is contained in:
@@ -13,7 +13,6 @@ namespace species {
|
|||||||
}; // namespace species
|
}; // namespace species
|
||||||
|
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class DynamicDensityFieldWithPitchAngle;
|
|
||||||
class PoissonSolver;
|
class PoissonSolver;
|
||||||
class RandomNumbers;
|
class RandomNumbers;
|
||||||
|
|
||||||
@@ -33,8 +32,6 @@ class Restart {
|
|||||||
private:
|
private:
|
||||||
void restartTimer(species::TrackedSpecie* reference_specie);
|
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(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 restartPoissonSolver(PoissonSolver* solver); // only load in the potential and calc the electric field
|
||||||
void restartRandomNumbers(RandomNumbers* random);
|
void restartRandomNumbers(RandomNumbers* random);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "IO/hdf5_writer.h"
|
#include "IO/hdf5_writer.h"
|
||||||
|
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class DynamicDensityFieldWithPitchAngle;
|
|
||||||
class CurrentBorder;
|
class CurrentBorder;
|
||||||
class Parameter;
|
class Parameter;
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
@@ -62,23 +61,12 @@ class SimulationOutput {
|
|||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
bool overwrite_last);
|
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(DynamicDensityField* density_field, std::string path);
|
||||||
void writeSpectrum(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
|
||||||
void writeDensity(DynamicDensityField* 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(DynamicDensityField* density_field, std::string path);
|
||||||
void writeTimeInBin(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
|
||||||
void writeDeletedParticles(DynamicDensityField* density_field,
|
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
std::string path);
|
std::string path);
|
||||||
void writeDeletedParticles(DynamicDensityFieldWithPitchAngle* density_field,
|
|
||||||
std::string path);
|
|
||||||
void writePhysicalTime(DynamicDensityField* 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,
|
void writeSimulationData(CurrentCollector* current_collector,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
@@ -106,7 +94,6 @@ class SimulationOutput {
|
|||||||
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
||||||
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
||||||
void writeMetaData(PoissonSolver* poisson_solver, std::string path);
|
void writeMetaData(PoissonSolver* poisson_solver, std::string path);
|
||||||
void writeMetaData(DynamicDensityFieldWithPitchAngle* density_field, std::string path);
|
|
||||||
// void writeParameterFile(Parameter* parameter);
|
// void writeParameterFile(Parameter* parameter);
|
||||||
|
|
||||||
void writeCollectorAreas(CurrentCollector* current_collector,
|
void writeCollectorAreas(CurrentCollector* current_collector,
|
||||||
|
|||||||
@@ -15,11 +15,6 @@ std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
|||||||
const json_path& path_to_field,
|
const json_path& path_to_field,
|
||||||
std::shared_ptr<Timer>& timer);
|
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
|
}; // namespace generator
|
||||||
|
|
||||||
#endif /* DENSITY_FIELD_GENERATOR_H */
|
#endif /* DENSITY_FIELD_GENERATOR_H */
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ struct TrackedSpeciesBuilderInfo {
|
|||||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
std::shared_ptr<DriftVelocity> drift_velocity;
|
||||||
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
||||||
std::shared_ptr<DynamicDensityField> density_drawing_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 mass_kg;
|
||||||
double charge_C;
|
double charge_C;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class DynamicDensityFieldWithPitchAngle;
|
|
||||||
class Timer;
|
class Timer;
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
class DeletionLogger;
|
class DeletionLogger;
|
||||||
@@ -27,9 +26,6 @@ class CpuSynchronizer {
|
|||||||
void synchronize(DynamicDensityField* field,
|
void synchronize(DynamicDensityField* field,
|
||||||
DynamicDensityField* density_for_drawing,
|
DynamicDensityField* density_for_drawing,
|
||||||
bool reset);
|
bool reset);
|
||||||
void synchronize(DynamicDensityFieldWithPitchAngle* field,
|
|
||||||
DynamicDensityFieldWithPitchAngle* density_for_drawing,
|
|
||||||
bool reset);
|
|
||||||
void synchronize(CurrentCollector* collector);
|
void synchronize(CurrentCollector* collector);
|
||||||
void synchronize(DeletionLogger* logger);
|
void synchronize(DeletionLogger* logger);
|
||||||
void synchronize(Timer* timer, Timer* last_sync_timer);
|
void synchronize(Timer* timer, Timer* last_sync_timer);
|
||||||
|
|||||||
@@ -20,96 +20,11 @@ class DensityField {
|
|||||||
virtual double density(const Coordinate& position, double energy_eV) = 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 {
|
class DynamicDensityField : public DensityField {
|
||||||
public:
|
public:
|
||||||
DynamicDensityField(const CylinderBinning& position_binning,
|
|
||||||
const EnergyBinning& energy_binning,
|
|
||||||
std::shared_ptr<Timer> timer);
|
|
||||||
|
|
||||||
bool changedPositionBin(const Coordinate& old_position,
|
DynamicDensityField(const CylinderBinning& positionBinning,
|
||||||
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 time_in_bin_s);
|
|
||||||
|
|
||||||
void logDeletion(const Coordinate& position, double energy_eV);
|
|
||||||
|
|
||||||
double density(const Coordinate& position);
|
|
||||||
double density(const Coordinate& position, double energy_eV);
|
|
||||||
|
|
||||||
double particleNumber();
|
|
||||||
blitz::TinyVector<double, 4> drawPositionAndEnergy(std::mt19937* engine);
|
|
||||||
|
|
||||||
void resetDynamicDensityField();
|
|
||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
|
||||||
blitz::Array<double, 4> spectrumArray();
|
|
||||||
blitz::Array<double, 4> timeInBinArray() const;
|
|
||||||
blitz::Array<long int, 4> deletedParticlesArray() const;
|
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
|
||||||
|
|
||||||
const EnergyBinning* energyBinning() const;
|
|
||||||
const CylinderBinning* positionBinning() const;
|
|
||||||
|
|
||||||
double physicalTime() const;
|
|
||||||
double timeResolution() const;
|
|
||||||
|
|
||||||
void restartTimer(double time, double delta_t);
|
|
||||||
void restartTimeInBin(blitz::Array<double, 4> time_in_bin);
|
|
||||||
void restartDeletedParticlesArray(blitz::Array<long int, 4> deleted_particles);
|
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
|
||||||
|
|
||||||
void setDensityDistribution();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// coordinate ordering: r, phi, z, E
|
|
||||||
// bin numbering
|
|
||||||
// radial:
|
|
||||||
// 0, ..., num_bin_r-1: r < r_max
|
|
||||||
// num_bin_r: r >= r_max
|
|
||||||
//
|
|
||||||
// azimuthal:
|
|
||||||
// 0, ..., num_bin_phi: all
|
|
||||||
//
|
|
||||||
// longitudinal:
|
|
||||||
// -1: z < 0
|
|
||||||
// 0, ..., num_bin_z-1: 0 <= z < z_max
|
|
||||||
// num_bin_z: z >= z_max
|
|
||||||
BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
|
||||||
void recalculateDensityArray();
|
|
||||||
void initPositionDistributions();
|
|
||||||
|
|
||||||
blitz::Array<double, 4> time_in_bin_s_;
|
|
||||||
blitz::Array<long int, 4> deleted_particles_;
|
|
||||||
|
|
||||||
blitz::Array<double, 4> sync_time_in_bin_s_;
|
|
||||||
blitz::Array<long int, 4> sync_deleted_particles_;
|
|
||||||
|
|
||||||
blitz::Array<double, 4> density_per_m3_;
|
|
||||||
blitz::Array<double, 3> bin_volume_m3_;
|
|
||||||
|
|
||||||
std::uniform_real_distribution<double> r_dist_;
|
|
||||||
std::uniform_real_distribution<double> phi_dist_;
|
|
||||||
std::uniform_real_distribution<double> z_dist_;
|
|
||||||
std::piecewise_constant_distribution<double> E_dist_;
|
|
||||||
std::uniform_real_distribution<double> density_dist_;
|
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
|
||||||
const EnergyBinning energy_binning_;
|
|
||||||
|
|
||||||
std::shared_ptr<Timer> timer_;
|
|
||||||
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 EnergyBinning& energy_binning,
|
||||||
const PitchAngleBinning& pitch_angle_binning,
|
const PitchAngleBinning& pitch_angle_binning,
|
||||||
std::shared_ptr<Timer> timer);
|
std::shared_ptr<Timer> timer);
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ class Injector {
|
|||||||
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
|
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
|
||||||
const double current_time);
|
const double current_time);
|
||||||
|
|
||||||
void rollNewParticleFromDensityField(std::mt19937* engine,
|
// void rollNewParticleFromDensityField(std::mt19937* engine,
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
// std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
std::vector<particle::Particle>& queue,
|
// std::vector<particle::Particle>& queue,
|
||||||
const double weight,
|
// const double weight,
|
||||||
const double injection_time);
|
// const double injection_time);
|
||||||
|
|
||||||
void rollNewParticleFromDensityField(std::mt19937* engine,
|
void rollNewParticleFromDensityField(std::mt19937* engine,
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ blitz::TinyVector<double, 3> velocityVector(
|
|||||||
const blitz::TinyVector<double, 3>& random_unit_vector,
|
const blitz::TinyVector<double, 3>& random_unit_vector,
|
||||||
double mass_kg);
|
double mass_kg);
|
||||||
|
|
||||||
|
double cosPitchAngle(blitz::TinyVector<double, 3> vector1,
|
||||||
|
blitz::TinyVector<double, 3> vector2);
|
||||||
|
|
||||||
}; // namespace kinematic
|
}; // namespace kinematic
|
||||||
|
|
||||||
#endif /* KINEMATIC_H */
|
#endif /* KINEMATIC_H */
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Reflector;
|
|||||||
class Injector;
|
class Injector;
|
||||||
class DensityField;
|
class DensityField;
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class DynamicDensityFieldWithPitchAngle;
|
|
||||||
class ConstantDensityField;
|
class ConstantDensityField;
|
||||||
class DeletionLogger;
|
class DeletionLogger;
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
@@ -63,9 +62,7 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity,
|
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();
|
DensityField* densityField();
|
||||||
VelocityDistribution* velocityDistibution();
|
VelocityDistribution* velocityDistibution();
|
||||||
@@ -81,9 +78,6 @@ class TrackedSpecie : public Specie {
|
|||||||
|
|
||||||
DynamicDensityField* densityForDrawing();
|
DynamicDensityField* densityForDrawing();
|
||||||
|
|
||||||
DynamicDensityFieldWithPitchAngle* dynamicDensityFieldWithPitchAngle();
|
|
||||||
DynamicDensityFieldWithPitchAngle* dynamicDensityFieldWithPitchAngleForDrawing();
|
|
||||||
|
|
||||||
CurrentCollector* currentCollector();
|
CurrentCollector* currentCollector();
|
||||||
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
@@ -92,7 +86,6 @@ class TrackedSpecie : public Specie {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DynamicDensityField> density_field_;
|
std::shared_ptr<DynamicDensityField> density_field_;
|
||||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_field_pitch_angle_;
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity_;
|
std::shared_ptr<DriftVelocity> drift_velocity_;
|
||||||
|
|
||||||
@@ -105,7 +98,6 @@ class TrackedSpecie : public Specie {
|
|||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
||||||
|
|
||||||
std::shared_ptr<DynamicDensityField> density_for_drawing_;
|
std::shared_ptr<DynamicDensityField> density_for_drawing_;
|
||||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> density_with_pitch_angle_for_drawing;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackgroundSpecie : public Specie {
|
class BackgroundSpecie : public Specie {
|
||||||
|
|||||||
+3
-11
@@ -35,20 +35,10 @@ void Restart::restart(std::map<std::string, std::shared_ptr<species::TrackedSpec
|
|||||||
restartTimer(species.begin()->second.get());
|
restartTimer(species.begin()->second.get());
|
||||||
|
|
||||||
for(const auto& pair: species) {
|
for(const auto& pair: species) {
|
||||||
{
|
|
||||||
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
||||||
restart_identifier_;
|
restart_identifier_;
|
||||||
restartDrawingDensityField(pair.second->densityForDrawing(), path);
|
restartDrawingDensityField(pair.second->densityForDrawing(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
std::string path = pair.second->name() +
|
|
||||||
"/DensityFieldWithPitchAngle/SimulationData/" +
|
|
||||||
restart_identifier_;
|
|
||||||
restartDrawingDensityField(pair.second->dynamicDensityFieldWithPitchAngleForDrawing(),
|
|
||||||
path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Restart::restartRandomNumbers(RandomNumbers* random) {
|
void Restart::restartRandomNumbers(RandomNumbers* random) {
|
||||||
@@ -107,6 +97,7 @@ void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string path) {
|
void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string path) {
|
||||||
// restart TimeInBin field
|
// restart TimeInBin field
|
||||||
{
|
{
|
||||||
@@ -130,8 +121,9 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void Restart::restartDrawingDensityField(DynamicDensityFieldWithPitchAngle* field, std::string path) {
|
void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string path) {
|
||||||
// restart TimeInBin field
|
// restart TimeInBin field
|
||||||
{
|
{
|
||||||
std::string path_to_data = path + "/TimeInBin";
|
std::string path_to_data = path + "/TimeInBin";
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ void SimulationOutput::writeMetaData(
|
|||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
writeMetaData(species.at(task.specie_name)->dynamicDensityField(),
|
writeMetaData(species.at(task.specie_name)->dynamicDensityField(),
|
||||||
specie_path);
|
specie_path);
|
||||||
writeMetaData(species.at(task.specie_name)->dynamicDensityFieldWithPitchAngle(),
|
|
||||||
specie_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& task : tasks_current_collector_) {
|
for (auto& task : tasks_current_collector_) {
|
||||||
@@ -73,8 +71,6 @@ void SimulationOutput::writeSimulationData(
|
|||||||
for (auto& task : tasks_density_fields_) {
|
for (auto& task : tasks_density_fields_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
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(),
|
writeSimulationData(species.at(task.specie_name)->dynamicDensityField(),
|
||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
@@ -132,28 +128,6 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
|||||||
writePhysicalTime(density_field, path);
|
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,
|
void SimulationOutput::writeSimulationData(CurrentCollector* current_collector,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
@@ -273,55 +247,27 @@ void SimulationOutput::writeSpectrum(DynamicDensityField* density_field,
|
|||||||
writer.write(density_field->spectrumArray(), path + "/Spectrum");
|
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,
|
void SimulationOutput::writeDensity(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->densityArray(), path + "/Density");
|
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,
|
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
|
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,
|
void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->deletedParticlesArray(),
|
writer.write(density_field->deletedParticlesArray(),
|
||||||
path + "/DeletedParticles");
|
path + "/DeletedParticles");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeDeletedParticles(DynamicDensityFieldWithPitchAngle* density_field,
|
|
||||||
std::string path) {
|
|
||||||
writer.write(density_field->deletedParticlesArray(),
|
|
||||||
path + "/DeletedParticles");
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
|
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->physicalTime(), path + "/PhysicalTime");
|
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) {
|
void SimulationOutput::writePotential(PoissonSolver* poisson_solver, std::string path) {
|
||||||
writer.write(poisson_solver->potential(), path + "/Potential");
|
writer.write(poisson_solver->potential(), path + "/Potential");
|
||||||
}
|
}
|
||||||
@@ -333,6 +279,7 @@ void SimulationOutput::writeMetaData(species::TrackedSpecie* specie) {
|
|||||||
writer.write(specie->charge_C(), specie_path + "/Charge");
|
writer.write(specie->charge_C(), specie_path + "/Charge");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
std::string path_to_field = path + "/DensityField";
|
std::string path_to_field = path + "/DensityField";
|
||||||
@@ -341,10 +288,12 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|||||||
writeBinBorders(density_field, path_to_field);
|
writeBinBorders(density_field, path_to_field);
|
||||||
writeNumBins(density_field, path_to_field);
|
writeNumBins(density_field, path_to_field);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void SimulationOutput::writeMetaData(DynamicDensityFieldWithPitchAngle* density_field,
|
// Todo: use the functions again (as in the method thats uncommented above)
|
||||||
|
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
std::string path_to_field = path + "/DensityFieldWithPitchAngle";
|
std::string path_to_field = path + "/DensityField";
|
||||||
|
|
||||||
// write bin volumes
|
// write bin volumes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,22 +21,6 @@ std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
|||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_field,
|
const json_path& path_to_field,
|
||||||
std::shared_ptr<Timer>& timer) {
|
std::shared_ptr<Timer>& timer) {
|
||||||
DEBUG_LEVEL_2("Creating dynamic density field.");
|
|
||||||
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
|
||||||
CylinderBinning position_binning =
|
|
||||||
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
|
||||||
json_path path_energy_binning =
|
|
||||||
json_path_append(path_to_field, {"EnergyBinning"});
|
|
||||||
EnergyBinning energy_binning =
|
|
||||||
buildEnergyBinningIncludingRedirection(parameter, path_energy_binning);
|
|
||||||
return std::shared_ptr<DynamicDensityField>(
|
|
||||||
new DynamicDensityField(position_binning, energy_binning, timer));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<DynamicDensityFieldWithPitchAngle> buildDynamicDensityFieldWithPitchAngle(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_field,
|
|
||||||
std::shared_ptr<Timer>& timer) {
|
|
||||||
|
|
||||||
DEBUG_LEVEL_2("Creating dynamic density field with pitch angle.");
|
DEBUG_LEVEL_2("Creating dynamic density field with pitch angle.");
|
||||||
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
||||||
@@ -51,8 +35,8 @@ std::shared_ptr<DynamicDensityFieldWithPitchAngle> buildDynamicDensityFieldWithP
|
|||||||
json_path_append(path_to_field, {"PitchAngleBinning"});
|
json_path_append(path_to_field, {"PitchAngleBinning"});
|
||||||
PitchAngleBinning pitch_angle_binning =
|
PitchAngleBinning pitch_angle_binning =
|
||||||
buildPitchAngleBinningIncludingRedirection(parameter, path_pitch_angle_binning);
|
buildPitchAngleBinningIncludingRedirection(parameter, path_pitch_angle_binning);
|
||||||
return std::shared_ptr<DynamicDensityFieldWithPitchAngle>(
|
return std::shared_ptr<DynamicDensityField>(
|
||||||
new DynamicDensityFieldWithPitchAngle(position_binning, energy_binning,
|
new DynamicDensityField(position_binning, energy_binning,
|
||||||
pitch_angle_binning, timer));
|
pitch_angle_binning, timer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,16 +266,6 @@ void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
|||||||
json_path_append(b.second.path_in_json,
|
json_path_append(b.second.path_in_json,
|
||||||
{"DensityField", "DynamicDensityField"}),
|
{"DensityField", "DynamicDensityField"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
|
||||||
b.second.density_field_pitch_angle = buildDynamicDensityFieldWithPitchAngle(
|
|
||||||
parameter,
|
|
||||||
json_path_append(b.second.path_in_json, {"DensityField", "DynamicDensityField"}),
|
|
||||||
timer_);
|
|
||||||
|
|
||||||
b.second.pitch_angle_drawing = buildDynamicDensityFieldWithPitchAngle(
|
|
||||||
parameter,
|
|
||||||
json_path_append(b.second.path_in_json, {"DensityField", "DynamicDensityField"}),
|
|
||||||
timer_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,9 +285,7 @@ void SpeciesBuilder::buildSpecies() {
|
|||||||
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
||||||
b.second.mover, b.second.terminator, b.second.reflector,
|
b.second.mover, b.second.terminator, b.second.reflector,
|
||||||
b.second.density_field, b.second.velocity_distribution,
|
b.second.density_field, b.second.velocity_distribution,
|
||||||
b.second.drift_velocity, b.second.density_drawing_field,
|
b.second.drift_velocity, b.second.density_drawing_field));
|
||||||
b.second.density_field_pitch_angle,
|
|
||||||
b.second.pitch_angle_drawing));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,8 +317,8 @@ void SpeciesBuilder::fillInteractions(Parameter& parameter) {
|
|||||||
for (auto& b : tracked_species) {
|
for (auto& b : tracked_species) {
|
||||||
json_path path = tracked_species_info[b.first].path_in_json;
|
json_path path = tracked_species_info[b.first].path_in_json;
|
||||||
path = json_path_append(path, {"Interactions"});
|
path = json_path_append(path, {"Interactions"});
|
||||||
addInteractions(b.second, tracked_species, background_species, parameter,
|
addInteractions(b.second, tracked_species, background_species,
|
||||||
path);
|
parameter, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "simulation/kinematic.h"
|
#include "simulation/kinematic.h"
|
||||||
#include "constants/physical_constants.h"
|
#include "constants/physical_constants.h"
|
||||||
#include "simulation/drift_velocity.h"
|
#include "simulation/drift_velocity.h"
|
||||||
|
#include "simulation/electromagnetic_field.h"
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
@@ -78,8 +79,36 @@ InteractionOutput Recombination::performInteraction(
|
|||||||
const double energy_eV = (energyBinBorders[energy_bin] +
|
const double energy_eV = (energyBinBorders[energy_bin] +
|
||||||
energyBinBorders[energy_bin+1]) / 2.;
|
energyBinBorders[energy_bin+1]) / 2.;
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> position_bins = recombination_target_->dynamicDensityField()
|
||||||
|
->positionBinning()->bin(particle.position().cylinderEntries());
|
||||||
|
|
||||||
|
const blitz::Array<double, 1> mu_distribution =
|
||||||
|
recombination_target_->dynamicDensityField()
|
||||||
|
->timeInBinArray()(position_bins(0),
|
||||||
|
position_bins(1),
|
||||||
|
position_bins(2),
|
||||||
|
blitz::Range::all(),
|
||||||
|
energy_bin);
|
||||||
|
|
||||||
|
std::vector<double> mu_borders = recombination_target_->dynamicDensityField()
|
||||||
|
->pitchAngleBinning()->binBorders();
|
||||||
|
|
||||||
|
std::discrete_distribution<int> mu_bin_decider(mu_distribution.begin(),
|
||||||
|
mu_distribution.end());
|
||||||
|
|
||||||
|
const int mu_bin = mu_bin_decider(*(generator->engine()));
|
||||||
|
|
||||||
|
if((mu_bin == 0) || (mu_bin == mu_distribution.size()-1)) {
|
||||||
|
ERROR("Recombination: drawn mu is from over- or underflow bin!");
|
||||||
|
std::stringstream out;
|
||||||
|
out << "mu distribution values: n";
|
||||||
|
out << mu_distribution;
|
||||||
|
DEBUG_LEVEL_3(out.str());
|
||||||
|
}
|
||||||
|
const double mu = (mu_borders[mu_bin - 1] + mu_borders[mu_bin])/2.;
|
||||||
|
|
||||||
recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
||||||
energy_eV);
|
energy_eV, mu);
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.deleteCurrentParticle(true);
|
output.deleteCurrentParticle(true);
|
||||||
|
|||||||
@@ -106,22 +106,6 @@ void CpuSynchronizer::synchronize(DynamicDensityField* field,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::synchronize(DynamicDensityFieldWithPitchAngle* field,
|
|
||||||
DynamicDensityFieldWithPitchAngle* density_for_drawing,
|
|
||||||
bool reset) {
|
|
||||||
if (field) {
|
|
||||||
sumToAll(field->time_in_bin_s_, field->sync_time_in_bin_s_);
|
|
||||||
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
|
||||||
sumToAll(field->deleted_particles_, field->sync_deleted_particles_);
|
|
||||||
field->deleted_particles_ = field->sync_deleted_particles_;
|
|
||||||
}
|
|
||||||
if (reset) {
|
|
||||||
density_for_drawing->time_in_bin_s_ = field->time_in_bin_s_;
|
|
||||||
density_for_drawing->deleted_particles_ = field->deleted_particles_;
|
|
||||||
density_for_drawing->setDensityDistribution();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CpuSynchronizer::synchronize(CurrentCollector* collector) {
|
void CpuSynchronizer::synchronize(CurrentCollector* collector) {
|
||||||
if (collector) {
|
if (collector) {
|
||||||
sumToAll(collector->z_negative_crossings,
|
sumToAll(collector->z_negative_crossings,
|
||||||
@@ -180,9 +164,6 @@ void CpuSynchronizer::synchronize(
|
|||||||
// DEBUG_LEVEL_3("dynden Synchronization.");
|
// DEBUG_LEVEL_3("dynden Synchronization.");
|
||||||
synchronize(pair.second->dynamicDensityField(),
|
synchronize(pair.second->dynamicDensityField(),
|
||||||
pair.second->densityForDrawing(), reset);
|
pair.second->densityForDrawing(), reset);
|
||||||
synchronize(pair.second->dynamicDensityFieldWithPitchAngle(),
|
|
||||||
pair.second->dynamicDensityFieldWithPitchAngleForDrawing(),
|
|
||||||
reset);
|
|
||||||
// DEBUG_LEVEL_3("cc Synchronization.");
|
// DEBUG_LEVEL_3("cc Synchronization.");
|
||||||
synchronize(pair.second->currentCollector());
|
synchronize(pair.second->currentCollector());
|
||||||
// DEBUG_LEVEL_3("dellogger Synchronization.");
|
// DEBUG_LEVEL_3("dellogger Synchronization.");
|
||||||
|
|||||||
@@ -51,338 +51,6 @@ blitz::Array<double, 3> initiateVolumeArray(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicDensityField::DynamicDensityField(
|
DynamicDensityField::DynamicDensityField(
|
||||||
const CylinderBinning& position_binning,
|
|
||||||
const EnergyBinning& energy_binning,
|
|
||||||
std::shared_ptr<Timer> timer)
|
|
||||||
: position_binning_(position_binning),
|
|
||||||
energy_binning_(energy_binning),
|
|
||||||
timer_(timer),
|
|
||||||
time_in_bin_s_(initiate4DArray<double>(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
|
||||||
energy_binning.binIndexMax()))),
|
|
||||||
sync_time_in_bin_s_(initiate4DArray<double>(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
|
||||||
energy_binning.binIndexMax()))),
|
|
||||||
deleted_particles_(initiate4DArray<long int>(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
|
||||||
energy_binning.binIndexMax()))),
|
|
||||||
sync_deleted_particles_(initiate4DArray<long int>(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
|
||||||
energy_binning.binIndexMax()))),
|
|
||||||
density_per_m3_(initiate4DArray<double>(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
|
||||||
energy_binning.binIndexMax()))),
|
|
||||||
bin_volume_m3_(initiateVolumeArray(
|
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
|
||||||
position_binning.radial_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
|
||||||
position_binning.stepsize())) {
|
|
||||||
if (!timer) {
|
|
||||||
ERROR("Timer is necessary for calculation of density field");
|
|
||||||
}
|
|
||||||
initPositionDistributions();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DynamicDensityField::changedPositionBin(
|
|
||||||
const Coordinate& old_position,
|
|
||||||
const Coordinate& new_position) const {
|
|
||||||
const blitz::TinyVector<int, 3> old_bin =
|
|
||||||
position_binning_.bin(old_position.cylinderEntries());
|
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> new_bin =
|
|
||||||
position_binning_.bin(new_position.cylinderEntries());
|
|
||||||
|
|
||||||
return !((old_bin(0) == new_bin(0)) && (old_bin(1) == new_bin(1)) &&
|
|
||||||
(old_bin(2) == new_bin(2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DynamicDensityField::changedEnergyBin(double old_energy_eV,
|
|
||||||
double new_energy_eV) const {
|
|
||||||
const int old_bin = energy_binning_.bin(old_energy_eV);
|
|
||||||
const int new_bin = energy_binning_.bin(new_energy_eV);
|
|
||||||
return !(old_bin == new_bin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::logMovement(const Coordinate& position,
|
|
||||||
double energy_eV,
|
|
||||||
double time_in_bin_s) {
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
|
||||||
position_binning_.bin(position.cylinderEntries());
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
|
||||||
|
|
||||||
// std::stringstream out;
|
|
||||||
// out << "Energy bin " << energy_bin << "\n";
|
|
||||||
// out << "time in bin" << time_in_bin_s;
|
|
||||||
// DEBUG_LEVEL_3(out.str());
|
|
||||||
|
|
||||||
time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
|
||||||
energy_bin) += time_in_bin_s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::logDeletion(const Coordinate& position,
|
|
||||||
double energy_eV) {
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
|
||||||
position_binning_.bin(position.cylinderEntries());
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
|
||||||
|
|
||||||
deleted_particles_(position_bin(0), position_bin(1), position_bin(2),
|
|
||||||
energy_bin) += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position) {
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
|
||||||
position_binning_.bin(position.cylinderEntries());
|
|
||||||
|
|
||||||
const double t = timer_->getDeltaT();
|
|
||||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
|
||||||
position_bin(0), position_bin(1), position_bin(2), blitz::Range::all()));
|
|
||||||
const long int deleted_particles = blitz::sum(deleted_particles_(
|
|
||||||
position_bin(0), position_bin(1), position_bin(2), blitz::Range::all()));
|
|
||||||
|
|
||||||
return (time_in_bin / t - deleted_particles) /
|
|
||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position,
|
|
||||||
double energy_eV) {
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
|
||||||
position_binning_.bin(position.cylinderEntries());
|
|
||||||
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
|
||||||
const double t = timer_->getDeltaT();
|
|
||||||
const double time_in_bin = time_in_bin_s_(position_bin(0), position_bin(1),
|
|
||||||
position_bin(2), energy_bin);
|
|
||||||
const long deleted_particles = deleted_particles_(
|
|
||||||
position_bin(0), position_bin(1), position_bin(2), energy_bin);
|
|
||||||
|
|
||||||
return (time_in_bin / t - deleted_particles) /
|
|
||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
|
||||||
recalculateDensityArray();
|
|
||||||
|
|
||||||
blitz::Array<double, 3> density(density_per_m3_(
|
|
||||||
blitz::Range::all(), blitz::Range::all(), blitz::Range::all(), 0));
|
|
||||||
blitz::fourthIndex iE;
|
|
||||||
density = blitz::sum(density_per_m3_, iE);
|
|
||||||
return density.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
double DynamicDensityField::particleNumber() {
|
|
||||||
blitz::Array<double, 3> density = densityArray();
|
|
||||||
double particleNumber = blitz::sum(density * bin_volume_m3_);
|
|
||||||
DEBUG_LEVEL_3("particle number: " + std::to_string(particleNumber));
|
|
||||||
return particleNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::initPositionDistributions() {
|
|
||||||
double rmin, rmax;
|
|
||||||
double phimin, phimax;
|
|
||||||
double zmin, zmax;
|
|
||||||
|
|
||||||
auto rbins = position_binning_.radial_binning.binBorders();
|
|
||||||
auto zbins = position_binning_.longitudinal_binning.binBorders();
|
|
||||||
auto phibins = position_binning_.azimuth_binning.binBorders();
|
|
||||||
|
|
||||||
rmin = rbins.front();
|
|
||||||
rmax = rbins.back();
|
|
||||||
DEBUG_LEVEL_3("rmax: " + std::to_string(rmax));
|
|
||||||
|
|
||||||
zmin = zbins.front();
|
|
||||||
zmax = zbins.back();
|
|
||||||
DEBUG_LEVEL_3("zmax: " + std::to_string(zmax));
|
|
||||||
|
|
||||||
phimin = phibins.front();
|
|
||||||
phimax = phibins.back();
|
|
||||||
DEBUG_LEVEL_3("phimax: " + std::to_string(phimax));
|
|
||||||
|
|
||||||
r_dist_ = std::uniform_real_distribution<double>(rmin*rmin, rmax*rmax);
|
|
||||||
phi_dist_ = std::uniform_real_distribution<double>(phimin, phimax);
|
|
||||||
z_dist_ = std::uniform_real_distribution<double>(zmin, zmax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::setDensityDistribution() {
|
|
||||||
density_dist_ =
|
|
||||||
std::uniform_real_distribution<double>(0., blitz::max(densityArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 4> DynamicDensityField::drawPositionAndEnergy(
|
|
||||||
std::mt19937* engine) {
|
|
||||||
// if the density is empty, then return a TinyVector filled with 0s as
|
|
||||||
// an indiction of that (probably not the best solution)
|
|
||||||
|
|
||||||
// stuff below not optimal, since it's done for every particle that is drawn,
|
|
||||||
// but maybe not certain that otherwise the density is right...
|
|
||||||
// recalculateDensityArray();
|
|
||||||
if (isEqual(blitz::max(density_per_m3_), 0.)) {
|
|
||||||
DEBUG_LEVEL_3("Density is empty");
|
|
||||||
return blitz::TinyVector<double, 4> (0,0,0,0);
|
|
||||||
}
|
|
||||||
// setDensityDistribution();
|
|
||||||
double random_r, random_z, random_phi, random_E, random_n;
|
|
||||||
double density_in_random_cell;
|
|
||||||
|
|
||||||
do {
|
|
||||||
DEBUG_LEVEL_3("Missed.");
|
|
||||||
random_r = std::sqrt(r_dist_(*engine));
|
|
||||||
random_phi = phi_dist_(*engine);
|
|
||||||
random_z = z_dist_(*engine);
|
|
||||||
random_n = density_dist_(*engine);
|
|
||||||
|
|
||||||
density_in_random_cell = density(CylinderCoordinate(
|
|
||||||
blitz::TinyVector<double, 3> (random_r, random_phi, random_z)));
|
|
||||||
DEBUG_LEVEL_3("Density in drawn cell: " + std::to_string(density_in_random_cell));
|
|
||||||
DEBUG_LEVEL_3("drawn density: " + std::to_string(random_n));
|
|
||||||
} while (random_n >= density_in_random_cell);
|
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
|
||||||
position_binning_.bin(CylinderCoordinate(
|
|
||||||
blitz::TinyVector<double, 3> (random_r, random_phi, random_z))
|
|
||||||
.cylinderEntries());
|
|
||||||
|
|
||||||
std::vector<double> energyBins = energy_binning_.binBorders();
|
|
||||||
energyBins.insert(energyBins.begin(), 0.);
|
|
||||||
blitz::Array<double, 1> densityAtPosition = density_per_m3_(position_bin(0),
|
|
||||||
position_bin(1),
|
|
||||||
position_bin(2),
|
|
||||||
blitz::Range::all());
|
|
||||||
|
|
||||||
E_dist_ = std::piecewise_constant_distribution<double>(energyBins.begin(),
|
|
||||||
energyBins.end(),
|
|
||||||
densityAtPosition.begin());
|
|
||||||
|
|
||||||
random_E = E_dist_(*engine);
|
|
||||||
DEBUG_LEVEL_3("energy: " + std::to_string(random_E));
|
|
||||||
|
|
||||||
return blitz::TinyVector<double, 4> (random_r, random_phi, random_z, random_E);
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
|
||||||
recalculateDensityArray();
|
|
||||||
return density_per_m3_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::recalculateDensityArray() {
|
|
||||||
blitz::firstIndex ir;
|
|
||||||
blitz::secondIndex iphi;
|
|
||||||
blitz::thirdIndex iz;
|
|
||||||
blitz::fourthIndex iE;
|
|
||||||
|
|
||||||
const double t = timer_->getDeltaT();
|
|
||||||
density_per_m3_ = (time_in_bin_s_(ir, iphi, iz, iE) / t -
|
|
||||||
deleted_particles_(ir, iphi, iz, iE)) /
|
|
||||||
bin_volume_m3_(ir, iphi, iz);
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<double, 4> DynamicDensityField::timeInBinArray() const {
|
|
||||||
return time_in_bin_s_;
|
|
||||||
}
|
|
||||||
blitz::Array<long int, 4> DynamicDensityField::deletedParticlesArray() const {
|
|
||||||
return deleted_particles_;
|
|
||||||
}
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::binVolumeArray() const {
|
|
||||||
return bin_volume_m3_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const EnergyBinning* DynamicDensityField::energyBinning() const {
|
|
||||||
return &energy_binning_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CylinderBinning* DynamicDensityField::positionBinning() const {
|
|
||||||
return &position_binning_;
|
|
||||||
}
|
|
||||||
|
|
||||||
double DynamicDensityField::physicalTime() const {
|
|
||||||
return timer_->time();
|
|
||||||
}
|
|
||||||
|
|
||||||
double DynamicDensityField::timeResolution() const {
|
|
||||||
return timer_->getDeltaT();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::resetDynamicDensityField() {
|
|
||||||
//timer_->resetTime(); // time stays global
|
|
||||||
time_in_bin_s_ = 0.;
|
|
||||||
deleted_particles_ = 0.;
|
|
||||||
density_per_m3_ = 0.;
|
|
||||||
sync_time_in_bin_s_ = 0.;
|
|
||||||
sync_deleted_particles_ = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
|
||||||
// make sure that the timer can only be restarted once (per dynamicDensityField object)
|
|
||||||
// probably not necessary, but whatever...
|
|
||||||
if(timer_restarted_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timer_restarted_ = true;
|
|
||||||
timer_->setTime(time);
|
|
||||||
timer_->setDeltaT(delta_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::restartTimeInBin(blitz::Array<double, 4> time_in_bin) {
|
|
||||||
if(!blitz::all(time_in_bin_s_.length() == time_in_bin.length())) {
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Expected a size of " << time_in_bin_s_.length();
|
|
||||||
out << ", received a length of " << time_in_bin.length();
|
|
||||||
out << " for time_in_bin array";
|
|
||||||
ERROR(out.str());
|
|
||||||
}
|
|
||||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicDensityField::restartDeletedParticlesArray(
|
|
||||||
blitz::Array<long int, 4> deleted_particles) {
|
|
||||||
if(!blitz::all(deleted_particles_.length() == deleted_particles.length())) {
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Expected a size of " << deleted_particles_.length();
|
|
||||||
out << ", received a length of " << deleted_particles.length();
|
|
||||||
out << " for deleted_particles array";
|
|
||||||
ERROR(out.str());
|
|
||||||
}
|
|
||||||
deleted_particles_ = deleted_particles.copy().reindex(deleted_particles_.lbound());
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// TBD
|
|
||||||
DynamicDensityFieldWithPitchAngle::DynamicDensityFieldWithPitchAngle(
|
|
||||||
const CylinderBinning& position_binning,
|
const CylinderBinning& position_binning,
|
||||||
const EnergyBinning& energy_binning,
|
const EnergyBinning& energy_binning,
|
||||||
const PitchAngleBinning& pitch_angle_binning,
|
const PitchAngleBinning& pitch_angle_binning,
|
||||||
@@ -458,7 +126,7 @@ DynamicDensityFieldWithPitchAngle::DynamicDensityFieldWithPitchAngle(
|
|||||||
initPositionDistributions();
|
initPositionDistributions();
|
||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityFieldWithPitchAngle::density(const Coordinate& position) {
|
double DynamicDensityField::density(const Coordinate& position) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 3> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
@@ -474,7 +142,7 @@ double DynamicDensityFieldWithPitchAngle::density(const Coordinate& position) {
|
|||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityFieldWithPitchAngle::density(const Coordinate& position,
|
double DynamicDensityField::density(const Coordinate& position,
|
||||||
double energy_eV) {
|
double energy_eV) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 3> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
@@ -492,7 +160,7 @@ double DynamicDensityFieldWithPitchAngle::density(const Coordinate& position,
|
|||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityFieldWithPitchAngle::changedPositionBin(
|
bool DynamicDensityField::changedPositionBin(
|
||||||
const Coordinate& old_position,
|
const Coordinate& old_position,
|
||||||
const Coordinate& new_position) const {
|
const Coordinate& new_position) const {
|
||||||
const blitz::TinyVector<int, 3> old_bin =
|
const blitz::TinyVector<int, 3> old_bin =
|
||||||
@@ -505,7 +173,7 @@ bool DynamicDensityFieldWithPitchAngle::changedPositionBin(
|
|||||||
(old_bin(2) == new_bin(2)));
|
(old_bin(2) == new_bin(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityFieldWithPitchAngle::changedEnergyBin(
|
bool DynamicDensityField::changedEnergyBin(
|
||||||
double old_energy_eV,
|
double old_energy_eV,
|
||||||
double new_energy_eV) const {
|
double new_energy_eV) const {
|
||||||
const int old_bin = energy_binning_.bin(old_energy_eV);
|
const int old_bin = energy_binning_.bin(old_energy_eV);
|
||||||
@@ -513,7 +181,7 @@ bool DynamicDensityFieldWithPitchAngle::changedEnergyBin(
|
|||||||
return !(old_bin == new_bin);
|
return !(old_bin == new_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityFieldWithPitchAngle::changedPitchAngleBin(
|
bool DynamicDensityField::changedPitchAngleBin(
|
||||||
double old_mu,
|
double old_mu,
|
||||||
double new_mu) const {
|
double new_mu) const {
|
||||||
const int old_bin = pitch_angle_binning_.bin(old_mu);
|
const int old_bin = pitch_angle_binning_.bin(old_mu);
|
||||||
@@ -529,7 +197,7 @@ bool DynamicDensityFieldWithPitchAngle::changedPitchAngleBin(
|
|||||||
return !(old_bin == new_bin);
|
return !(old_bin == new_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::logMovement(
|
void DynamicDensityField::logMovement(
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
double energy_eV,
|
double energy_eV,
|
||||||
double pitch_angle,
|
double pitch_angle,
|
||||||
@@ -551,7 +219,7 @@ void DynamicDensityFieldWithPitchAngle::logMovement(
|
|||||||
pitch_angle_bin, energy_bin) += time_in_bin_s;
|
pitch_angle_bin, energy_bin) += time_in_bin_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::logDeletion(
|
void DynamicDensityField::logDeletion(
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
double energy_eV,
|
double energy_eV,
|
||||||
double pitch_angle) {
|
double pitch_angle) {
|
||||||
@@ -566,7 +234,7 @@ void DynamicDensityFieldWithPitchAngle::logDeletion(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityFieldWithPitchAngle::densityArray() {
|
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
||||||
DEBUG_LEVEL_3("recalc Density array");
|
DEBUG_LEVEL_3("recalc Density array");
|
||||||
recalculateDensityArray();
|
recalculateDensityArray();
|
||||||
|
|
||||||
@@ -578,44 +246,44 @@ blitz::Array<double, 3> DynamicDensityFieldWithPitchAngle::densityArray() {
|
|||||||
return density.copy();
|
return density.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 4> DynamicDensityFieldWithPitchAngle::spectrumArray() {
|
blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
||||||
recalculateDensityArray();
|
recalculateDensityArray();
|
||||||
return density_per_m3_;
|
return density_per_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 5> DynamicDensityFieldWithPitchAngle::timeInBinArray() const {
|
blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
||||||
return time_in_bin_s_;
|
return time_in_bin_s_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<long int, 5> DynamicDensityFieldWithPitchAngle::deletedParticlesArray() const {
|
blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
||||||
return deleted_particles_;
|
return deleted_particles_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityFieldWithPitchAngle::binVolumeArray() const {
|
blitz::Array<double, 3> DynamicDensityField::binVolumeArray() const {
|
||||||
return bin_volume_m3_;
|
return bin_volume_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnergyBinning* DynamicDensityFieldWithPitchAngle::energyBinning() const {
|
const EnergyBinning* DynamicDensityField::energyBinning() const {
|
||||||
return &energy_binning_;
|
return &energy_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CylinderBinning* DynamicDensityFieldWithPitchAngle::positionBinning() const {
|
const CylinderBinning* DynamicDensityField::positionBinning() const {
|
||||||
return &position_binning_;
|
return &position_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PitchAngleBinning* DynamicDensityFieldWithPitchAngle::pitchAngleBinning() const {
|
const PitchAngleBinning* DynamicDensityField::pitchAngleBinning() const {
|
||||||
return &pitch_angle_binning_;
|
return &pitch_angle_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityFieldWithPitchAngle::physicalTime() const {
|
double DynamicDensityField::physicalTime() const {
|
||||||
return timer_->time();
|
return timer_->time();
|
||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityFieldWithPitchAngle::timeResolution() const {
|
double DynamicDensityField::timeResolution() const {
|
||||||
return timer_->getDeltaT();
|
return timer_->getDeltaT();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::recalculateDensityArray() {
|
void DynamicDensityField::recalculateDensityArray() {
|
||||||
blitz::firstIndex ir;
|
blitz::firstIndex ir;
|
||||||
blitz::secondIndex iphi;
|
blitz::secondIndex iphi;
|
||||||
blitz::thirdIndex iz;
|
blitz::thirdIndex iz;
|
||||||
@@ -634,19 +302,19 @@ void DynamicDensityFieldWithPitchAngle::recalculateDensityArray() {
|
|||||||
bin_volume_m3_(ir, iphi, iz);
|
bin_volume_m3_(ir, iphi, iz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::setDensityDistribution() {
|
void DynamicDensityField::setDensityDistribution() {
|
||||||
density_dist_ =
|
density_dist_ =
|
||||||
std::uniform_real_distribution<double>(0., blitz::max(densityArray()));
|
std::uniform_real_distribution<double>(0., blitz::max(densityArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityFieldWithPitchAngle::particleNumber() {
|
double DynamicDensityField::particleNumber() {
|
||||||
blitz::Array<double, 3> density = densityArray();
|
blitz::Array<double, 3> density = densityArray();
|
||||||
double particleNumber = blitz::sum(density * bin_volume_m3_);
|
double particleNumber = blitz::sum(density * bin_volume_m3_);
|
||||||
DEBUG_LEVEL_3("particle number: " + std::to_string(particleNumber));
|
DEBUG_LEVEL_3("particle number: " + std::to_string(particleNumber));
|
||||||
return particleNumber;
|
return particleNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::initPositionDistributions() {
|
void DynamicDensityField::initPositionDistributions() {
|
||||||
double rmin, rmax;
|
double rmin, rmax;
|
||||||
double phimin, phimax;
|
double phimin, phimax;
|
||||||
double zmin, zmax;
|
double zmin, zmax;
|
||||||
@@ -674,7 +342,7 @@ void DynamicDensityFieldWithPitchAngle::initPositionDistributions() {
|
|||||||
|
|
||||||
// don't know if it's even good to have the drawing stuff in the
|
// don't know if it's even good to have the drawing stuff in the
|
||||||
// density distributions...
|
// density distributions...
|
||||||
blitz::TinyVector<double, 5> DynamicDensityFieldWithPitchAngle::
|
blitz::TinyVector<double, 5> DynamicDensityField::
|
||||||
draw(std::mt19937* engine) {
|
draw(std::mt19937* engine) {
|
||||||
recalculateDensityArray();
|
recalculateDensityArray();
|
||||||
if (isEqual(blitz::max(density_per_m3_), 0.)) {
|
if (isEqual(blitz::max(density_per_m3_), 0.)) {
|
||||||
@@ -737,7 +405,7 @@ blitz::TinyVector<double, 5> DynamicDensityFieldWithPitchAngle::
|
|||||||
return blitz::TinyVector<double, 5> (random_r, random_phi, random_z, random_mu, random_E);
|
return blitz::TinyVector<double, 5> (random_r, random_phi, random_z, random_mu, random_E);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::resetDynamicDensityField() {
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
//timer_->resetTime(); // time stays global
|
//timer_->resetTime(); // time stays global
|
||||||
time_in_bin_s_ = 0.;
|
time_in_bin_s_ = 0.;
|
||||||
deleted_particles_ = 0.;
|
deleted_particles_ = 0.;
|
||||||
@@ -746,7 +414,7 @@ void DynamicDensityFieldWithPitchAngle::resetDynamicDensityField() {
|
|||||||
sync_deleted_particles_ = 0.;
|
sync_deleted_particles_ = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::restartTimer(double time, double delta_t) {
|
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
||||||
// make sure that the timer can only be restarted once (per dynamicDensityField object)
|
// make sure that the timer can only be restarted once (per dynamicDensityField object)
|
||||||
// probably not necessary, but whatever...
|
// probably not necessary, but whatever...
|
||||||
if(timer_restarted_) {
|
if(timer_restarted_) {
|
||||||
@@ -757,7 +425,7 @@ void DynamicDensityFieldWithPitchAngle::restartTimer(double time, double delta_t
|
|||||||
timer_->setDeltaT(delta_t);
|
timer_->setDeltaT(delta_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::restartTimeInBin(blitz::Array<double, 5> time_in_bin) {
|
void DynamicDensityField::restartTimeInBin(blitz::Array<double, 5> time_in_bin) {
|
||||||
if(!blitz::all(time_in_bin_s_.length() == time_in_bin.length())) {
|
if(!blitz::all(time_in_bin_s_.length() == time_in_bin.length())) {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "Expected a size of " << time_in_bin_s_.length();
|
out << "Expected a size of " << time_in_bin_s_.length();
|
||||||
@@ -768,7 +436,7 @@ void DynamicDensityFieldWithPitchAngle::restartTimeInBin(blitz::Array<double, 5>
|
|||||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityFieldWithPitchAngle::restartDeletedParticlesArray(
|
void DynamicDensityField::restartDeletedParticlesArray(
|
||||||
blitz::Array<long int, 5> deleted_particles) {
|
blitz::Array<long int, 5> deleted_particles) {
|
||||||
if(!blitz::all(deleted_particles_.length() == deleted_particles.length())) {
|
if(!blitz::all(deleted_particles_.length() == deleted_particles.length())) {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ std::vector<particle::Particle> Injector::rollNewParticles(
|
|||||||
return new_particles;
|
return new_particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
std::vector<particle::Particle>& queue,
|
std::vector<particle::Particle>& queue,
|
||||||
@@ -122,6 +123,7 @@ void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
|||||||
|
|
||||||
queue.push_back(drawn_particle);
|
queue.push_back(drawn_particle);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
@@ -130,7 +132,7 @@ void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
|||||||
const double weight,
|
const double weight,
|
||||||
const double injection_time) {
|
const double injection_time) {
|
||||||
blitz::TinyVector<double, 5> particle_specs =
|
blitz::TinyVector<double, 5> particle_specs =
|
||||||
specie->dynamicDensityFieldWithPitchAngleForDrawing()->draw(engine);
|
specie->densityForDrawing()->draw(engine);
|
||||||
|
|
||||||
// check if density was empty (i.e. Energy component is 0)
|
// check if density was empty (i.e. Energy component is 0)
|
||||||
if (particle_specs[4] == 0) {
|
if (particle_specs[4] == 0) {
|
||||||
|
|||||||
@@ -166,4 +166,10 @@ blitz::TinyVector<double, 3> rotateVector(
|
|||||||
std::sin(angle) * cross;
|
std::sin(angle) * cross;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double cosPitchAngle(blitz::TinyVector<double, 3> vector1,
|
||||||
|
blitz::TinyVector<double, 3> vector2) {
|
||||||
|
const double divisor = kinematic::norm(vector1) * kinematic::norm(vector2);
|
||||||
|
return blitz::dot(vector1, vector2)/divisor;
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace kinematic
|
}; // namespace kinematic
|
||||||
@@ -13,12 +13,6 @@
|
|||||||
|
|
||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
double cosAngleBetweenVectors(blitz::TinyVector<double, 3> vector_1,
|
|
||||||
blitz::TinyVector<double, 3> vector_2) {
|
|
||||||
const double divisor = kinematic::norm(vector_1) * kinematic::norm(vector_2);
|
|
||||||
return blitz::dot(vector_1, vector_2)/divisor;
|
|
||||||
}
|
|
||||||
|
|
||||||
BorisMover::BorisMover(double maximal_time_step_s)
|
BorisMover::BorisMover(double maximal_time_step_s)
|
||||||
: maximal_time_step_s_(maximal_time_step_s) {
|
: maximal_time_step_s_(maximal_time_step_s) {
|
||||||
ASSERT_POSITIVE(&maximal_time_step_s_,
|
ASSERT_POSITIVE(&maximal_time_step_s_,
|
||||||
@@ -78,8 +72,9 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
leftover_distance -= moved_distance;
|
leftover_distance -= moved_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: pitchangle stuff in Boris mover
|
||||||
particle->specie()->dynamicDensityField()->logMovement(
|
particle->specie()->dynamicDensityField()->logMovement(
|
||||||
old_position, old_kinetic_energy, particle->timeInBin());
|
old_position, old_kinetic_energy, 0, particle->timeInBin());
|
||||||
particle->resetTimeInBin();
|
particle->resetTimeInBin();
|
||||||
particle->specie()->currentCollector()->collect(particle, old_position);
|
particle->specie()->currentCollector()->collect(particle, old_position);
|
||||||
}
|
}
|
||||||
@@ -186,7 +181,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
auto old_position = particle->position();
|
auto old_position = particle->position();
|
||||||
auto old_velocity = particle->velocity();
|
auto old_velocity = particle->velocity();
|
||||||
double old_kinetic_energy = particle->kineticEnergy_eV();
|
double old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
double old_mu = cosAngleBetweenVectors(
|
double old_mu = kinematic::cosPitchAngle(
|
||||||
magnetic_field->value(old_position).cartesianEntries(old_position),
|
magnetic_field->value(old_position).cartesianEntries(old_position),
|
||||||
old_velocity.cartesianEntries(old_position));
|
old_velocity.cartesianEntries(old_position));
|
||||||
|
|
||||||
@@ -353,11 +348,11 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
particle->specie()->dynamicDensityField()->changedEnergyBin(
|
particle->specie()->dynamicDensityField()->changedEnergyBin(
|
||||||
old_kinetic_energy, particle->kineticEnergy_eV());
|
old_kinetic_energy, particle->kineticEnergy_eV());
|
||||||
|
|
||||||
const double new_mu = cosAngleBetweenVectors(magnetic_field
|
const double new_mu = kinematic::cosPitchAngle(magnetic_field
|
||||||
->value(new_position).cartesianEntries(new_position),
|
->value(new_position).cartesianEntries(new_position),
|
||||||
particle->velocity().cartesianEntries(new_position));
|
particle->velocity().cartesianEntries(new_position));
|
||||||
|
|
||||||
changed_mu_bin = particle->specie()->dynamicDensityFieldWithPitchAngle()
|
changed_mu_bin = particle->specie()->dynamicDensityField()
|
||||||
->changedPitchAngleBin(old_mu, new_mu);
|
->changedPitchAngleBin(old_mu, new_mu);
|
||||||
|
|
||||||
if(changed_mu_bin) {
|
if(changed_mu_bin) {
|
||||||
@@ -371,9 +366,9 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
leftover_distance -= stepsize;
|
leftover_distance -= stepsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// particle->specie()->dynamicDensityField()->logMovement(
|
||||||
|
// old_position, old_kinetic_energy, particle->timeInBin());
|
||||||
particle->specie()->dynamicDensityField()->logMovement(
|
particle->specie()->dynamicDensityField()->logMovement(
|
||||||
old_position, old_kinetic_energy, particle->timeInBin());
|
|
||||||
particle->specie()->dynamicDensityFieldWithPitchAngle()->logMovement(
|
|
||||||
old_position, old_kinetic_energy, old_mu, particle->timeInBin());
|
old_position, old_kinetic_energy, old_mu, particle->timeInBin());
|
||||||
particle->resetTimeInBin();
|
particle->resetTimeInBin();
|
||||||
particle->specie()->currentCollector()->collect(particle, old_position);
|
particle->specie()->currentCollector()->collect(particle, old_position);
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ void Simulation::start() {
|
|||||||
timer_->increaseTimestep(delta_t);
|
timer_->increaseTimestep(delta_t);
|
||||||
for(auto& pair : tracked_species_) {
|
for(auto& pair : tracked_species_) {
|
||||||
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
||||||
pair.second->dynamicDensityFieldWithPitchAngle()->resetDynamicDensityField();
|
// pair.second->dynamicDensityFieldWithPitchAngle()->resetDynamicDensityField();
|
||||||
|
|
||||||
// questionable if they need to be reset:
|
// questionable if they need to be reset:
|
||||||
// + time res in current
|
// + time res in current
|
||||||
@@ -249,7 +249,7 @@ void Simulation::start() {
|
|||||||
|
|
||||||
// do not need to be reset, since the time resolution considers the same
|
// do not need to be reset, since the time resolution considers the same
|
||||||
// set of particles
|
// set of particles
|
||||||
// pair.second->deletionLogger()->resetDeletionLogger();
|
pair.second->deletionLogger()->resetDeletionLogger();
|
||||||
}
|
}
|
||||||
leftover_events_time_resolution = time_resolution_this_cpu;
|
leftover_events_time_resolution = time_resolution_this_cpu;
|
||||||
timesteps++;
|
timesteps++;
|
||||||
@@ -494,8 +494,6 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
|||||||
const double particleNumberFromDensity =
|
const double particleNumberFromDensity =
|
||||||
pair.second->densityForDrawing()->particleNumber();
|
pair.second->densityForDrawing()->particleNumber();
|
||||||
|
|
||||||
const double particleNumberFromDensity_ =
|
|
||||||
pair.second->dynamicDensityFieldWithPitchAngleForDrawing()->particleNumber();
|
|
||||||
if (particleNumberFromDensity == 0) {
|
if (particleNumberFromDensity == 0) {
|
||||||
DEBUG_LEVEL_3("No particles in density of species: " + pair.second->name());
|
DEBUG_LEVEL_3("No particles in density of species: " + pair.second->name());
|
||||||
continue;
|
continue;
|
||||||
@@ -503,8 +501,8 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
|||||||
if (current == 0) {
|
if (current == 0) {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << pair.second->name();
|
out << pair.second->name();
|
||||||
out << "difference: ";
|
out << "particle number from density: ";
|
||||||
out << std::fabs(particleNumberFromDensity_ - particleNumberFromDensity)/particleNumberFromDensity;
|
out << particleNumberFromDensity;
|
||||||
DEBUG_LEVEL_3(out.str());
|
DEBUG_LEVEL_3(out.str());
|
||||||
}
|
}
|
||||||
injector_->rollNewParticleFromDensityField(random->engine(),
|
injector_->rollNewParticleFromDensityField(random->engine(),
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ TrackedSpecie::TrackedSpecie(
|
|||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity,
|
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)
|
|
||||||
: Specie(type, name, mass_kg, charge_C),
|
: Specie(type, name, mass_kg, charge_C),
|
||||||
mover_(mover),
|
mover_(mover),
|
||||||
terminator_(terminator),
|
terminator_(terminator),
|
||||||
@@ -54,9 +52,7 @@ TrackedSpecie::TrackedSpecie(
|
|||||||
current_collector_(std::shared_ptr<CurrentCollector>(nullptr)),
|
current_collector_(std::shared_ptr<CurrentCollector>(nullptr)),
|
||||||
velocity_distribution_(velocity_distribution),
|
velocity_distribution_(velocity_distribution),
|
||||||
drift_velocity_(drift_velocity),
|
drift_velocity_(drift_velocity),
|
||||||
density_for_drawing_(density_for_drawing),
|
density_for_drawing_(density_for_drawing) {}
|
||||||
density_field_pitch_angle_(density_field_pitch_angle),
|
|
||||||
density_with_pitch_angle_for_drawing(density_mu_for_drawing) {}
|
|
||||||
|
|
||||||
DensityField* TrackedSpecie::densityField() {
|
DensityField* TrackedSpecie::densityField() {
|
||||||
return density_field_.get();
|
return density_field_.get();
|
||||||
@@ -77,14 +73,6 @@ DynamicDensityField* TrackedSpecie::densityForDrawing() {
|
|||||||
return density_for_drawing_.get();
|
return density_for_drawing_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicDensityFieldWithPitchAngle* TrackedSpecie::dynamicDensityFieldWithPitchAngle() {
|
|
||||||
return density_field_pitch_angle_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicDensityFieldWithPitchAngle* TrackedSpecie::dynamicDensityFieldWithPitchAngleForDrawing() {
|
|
||||||
return density_with_pitch_angle_for_drawing.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Mover* TrackedSpecie::mover() {
|
Mover* TrackedSpecie::mover() {
|
||||||
return mover_.get();
|
return mover_.get();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user