Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
961f1a2a8e | ||
|
|
21edce8f92 | ||
|
|
844c0dfcc3 | ||
|
|
531ace797a | ||
|
|
f529804ee6 | ||
|
|
d08407c773 | ||
|
|
204b2817da | ||
|
|
095dd6eb3d | ||
|
|
03321880d8 | ||
|
|
a1444bceaa | ||
|
|
f097f2b7ff | ||
|
|
f82cbf4c47 | ||
|
|
fea00f9a0a | ||
|
|
d6ee7e8be8 | ||
|
|
fcbff96f17 | ||
|
|
77fa8d175a | ||
|
|
cac5e6ff5d | ||
|
|
93a51acbda | ||
|
|
30b0178e5f | ||
|
|
ab7c6f20cc |
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,8 @@ std::function<double(double)> Constant(double constant);
|
|||||||
|
|
||||||
std::function<double(double)> Product(
|
std::function<double(double)> Product(
|
||||||
std::vector<std::function<double(double)>> functions);
|
std::vector<std::function<double(double)>> functions);
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale);
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef GRAVITY_FIELD_GENERATOR_H
|
||||||
|
#define GRAVITY_FIELD_GENERATOR_H
|
||||||
|
|
||||||
|
#include "simulation/electromagnetic_field.h"
|
||||||
|
#include "simulation/parameter.h"
|
||||||
|
|
||||||
|
namespace generator {
|
||||||
|
std::shared_ptr<GravityField> gravityField(json_t* object);
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(Parameter& parameter);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* GRAVITY_FIELD_GENERATOR_H */
|
||||||
@@ -55,11 +55,10 @@ class PoissonSolver {
|
|||||||
std::vector<std::shared_ptr<Electrode>> electrodes,
|
std::vector<std::shared_ptr<Electrode>> electrodes,
|
||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
int solver_intervall,
|
bool do_solver);
|
||||||
int solver_offset);
|
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 3> charge_density,
|
void solvePotential(const blitz::Array<double, 3> charge_density,
|
||||||
int cpu_sync);
|
const bool solve);
|
||||||
blitz::Array<double, 3> potential();
|
blitz::Array<double, 3> potential();
|
||||||
std::shared_ptr<VectorField> staticElectricField();
|
std::shared_ptr<VectorField> staticElectricField();
|
||||||
const CylinderBinning* densityBinning();
|
const CylinderBinning* densityBinning();
|
||||||
@@ -73,8 +72,7 @@ class PoissonSolver {
|
|||||||
const CylinderBinning density_binning_;
|
const CylinderBinning density_binning_;
|
||||||
const double target_accuracy_;
|
const double target_accuracy_;
|
||||||
const int num_cycles_;
|
const int num_cycles_;
|
||||||
const int solver_intervall_;
|
const bool do_solver_;
|
||||||
const int solver_offset_;
|
|
||||||
|
|
||||||
// density binning defined on the cell centers, potential defined
|
// density binning defined on the cell centers, potential defined
|
||||||
// such that it exists on the cell edges so that the azimuthal
|
// such that it exists on the cell edges so that the azimuthal
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class CurrentCollector {
|
|||||||
|
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
|
void resetCurrentCollector();
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class DynamicDensityField : public DensityField {
|
|||||||
double density(const Coordinate& position);
|
double density(const Coordinate& position);
|
||||||
double density(const Coordinate& position, double energy_eV);
|
double density(const Coordinate& position, double energy_eV);
|
||||||
|
|
||||||
|
void resetDynamicDensityField();
|
||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 3> densityArray();
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 4> spectrumArray();
|
||||||
blitz::Array<double, 4> timeInBinArray() const;
|
blitz::Array<double, 4> timeInBinArray() const;
|
||||||
|
|||||||
@@ -23,9 +23,21 @@ class ElectricField {
|
|||||||
|
|
||||||
class MagneticField {
|
class MagneticField {
|
||||||
public:
|
public:
|
||||||
MagneticField(std::shared_ptr<VectorField> field);
|
MagneticField(std::shared_ptr<VectorField> field,
|
||||||
|
std::shared_ptr<VectorField> gradient);
|
||||||
|
|
||||||
CylinderVector value(const Coordinate& position) const;
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
CylinderVector gradientValue(const Coordinate& position) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<VectorField> field_;
|
||||||
|
std::shared_ptr<VectorField> gradient_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GravityField {
|
||||||
|
public:
|
||||||
|
GravityField(std::shared_ptr<VectorField> field);
|
||||||
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VectorField> field_;
|
std::shared_ptr<VectorField> field_;
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ class Injector {
|
|||||||
std::shared_ptr<EventPositionDistribution> position_distribution,
|
std::shared_ptr<EventPositionDistribution> position_distribution,
|
||||||
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
||||||
|
|
||||||
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine);
|
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
|
||||||
|
const double current_time,
|
||||||
|
const int time_resolution_events);
|
||||||
double timePassed() const;
|
double timePassed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -48,7 +50,8 @@ class Injector {
|
|||||||
std::mt19937* engine,
|
std::mt19937* engine,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution);
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
||||||
|
const double time_birth);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* INJECTOR_H */
|
#endif /* INJECTOR_H */
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class DeletionLogger {
|
|||||||
void numDeletions(long int new_value, DeletionType type);
|
void numDeletions(long int new_value, DeletionType type);
|
||||||
long int numDeletions(DeletionType type) const;
|
long int numDeletions(DeletionType type) const;
|
||||||
|
|
||||||
|
void resetDeletionLogger();
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ class Mover {
|
|||||||
virtual void move(particle::Particle* particle,
|
virtual void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) = 0;
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BorisMover : public Mover {
|
class BorisMover : public Mover {
|
||||||
@@ -19,7 +20,8 @@ class BorisMover : public Mover {
|
|||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field);
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double maximal_time_step_s_;
|
const double maximal_time_step_s_;
|
||||||
@@ -37,14 +39,15 @@ class DriftMover : public Mover {
|
|||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field);
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double maximal_distance_m_;
|
const double maximal_distance_m_;
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> driftVelocity(
|
blitz::TinyVector<double, 3> driftVelocity(
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||||
const blitz::TinyVector<double, 3>& electric_field) const;
|
const blitz::TinyVector<double, 3>& magnetic_field) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MOVER_H */
|
#endif /* MOVER_H */
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class Particle {
|
|||||||
// Vector* velocity);
|
// Vector* velocity);
|
||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity);
|
const Vector& velocity,
|
||||||
|
const double time_birth);
|
||||||
|
|
||||||
void position(const Coordinate& new_position);
|
void position(const Coordinate& new_position);
|
||||||
CartesianCoordinate position() const;
|
CartesianCoordinate position() const;
|
||||||
@@ -46,6 +47,8 @@ class Particle {
|
|||||||
void resetTimeInBin();
|
void resetTimeInBin();
|
||||||
double timeInBin() const;
|
double timeInBin() const;
|
||||||
|
|
||||||
|
long int ID() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CartesianVector velocity_;
|
CartesianVector velocity_;
|
||||||
CartesianCoordinate position_;
|
CartesianCoordinate position_;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class RandomNumbers;
|
|||||||
class InteractionOutput;
|
class InteractionOutput;
|
||||||
class MagneticField;
|
class MagneticField;
|
||||||
class ElectricField;
|
class ElectricField;
|
||||||
|
class GravityField;
|
||||||
class Timer;
|
class Timer;
|
||||||
class Injector;
|
class Injector;
|
||||||
class SimulationOutput;
|
class SimulationOutput;
|
||||||
@@ -33,13 +34,12 @@ class Simulation {
|
|||||||
void init(Parameter& parameter);
|
void init(Parameter& parameter);
|
||||||
void start();
|
void start();
|
||||||
void finalize();
|
void finalize();
|
||||||
void processEvents(int events);
|
void processEvents(int events, const int time_resolution_events);
|
||||||
void processUntilTermination(particle::Particle& particle,
|
void processUntilTermination(particle::Particle& particle);
|
||||||
std::vector<particle::Particle>& particle_queue);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<particle::Particle> determineInjectedParticles(
|
std::vector<particle::Particle> determineInjectedParticles(
|
||||||
RandomNumbers* random);
|
RandomNumbers* random, const int time_resolution_events);
|
||||||
|
|
||||||
double meanFreePath(particle::Particle& particle, RandomNumbers* random);
|
double meanFreePath(particle::Particle& particle, RandomNumbers* random);
|
||||||
|
|
||||||
@@ -57,6 +57,7 @@ class Simulation {
|
|||||||
|
|
||||||
std::shared_ptr<MagneticField> magnetic_field_;
|
std::shared_ptr<MagneticField> magnetic_field_;
|
||||||
std::shared_ptr<ElectricField> electric_field_;
|
std::shared_ptr<ElectricField> electric_field_;
|
||||||
|
std::shared_ptr<GravityField> gravity_field_;
|
||||||
|
|
||||||
std::shared_ptr<PoissonSolver> poisson_solver_;
|
std::shared_ptr<PoissonSolver> poisson_solver_;
|
||||||
|
|
||||||
@@ -67,6 +68,10 @@ class Simulation {
|
|||||||
|
|
||||||
std::shared_ptr<SimulationOutput> output_;
|
std::shared_ptr<SimulationOutput> output_;
|
||||||
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
||||||
|
|
||||||
|
std::vector<particle::Particle> queues_[2];
|
||||||
|
int active_queue_;
|
||||||
|
int non_active_queue_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SIMULATION_H */
|
#endif /* SIMULATION_H */
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
class Geometry;
|
class Geometry;
|
||||||
|
class DynamicDensityField;
|
||||||
class Terminator {
|
class Terminator {
|
||||||
public:
|
public:
|
||||||
Terminator(long int max_interactions,
|
Terminator(long int max_interactions,
|
||||||
|
|||||||
@@ -10,9 +10,13 @@ class Timer {
|
|||||||
double time() const;
|
double time() const;
|
||||||
void increaseTimestep(double time_s);
|
void increaseTimestep(double time_s);
|
||||||
void setTime(double time_s);
|
void setTime(double time_s);
|
||||||
|
void resetTime();
|
||||||
|
void setDeltaT(double deltaT);
|
||||||
|
double getDeltaT() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double current_time_s_;
|
double current_time_s_;
|
||||||
|
double delta_t_time_resolution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TIMER_H */
|
#endif /* TIMER_H */
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ TARGET_TEST=$(BIN_DIR)/karl_test
|
|||||||
|
|
||||||
# Compile logic
|
# Compile logic
|
||||||
|
|
||||||
all: blitz hdf5 jansson karl
|
all: blitz jansson karl
|
||||||
|
|
||||||
check_homebase:
|
check_homebase:
|
||||||
ifeq ($(HOMEBASE),)
|
ifeq ($(HOMEBASE),)
|
||||||
@@ -99,12 +99,6 @@ endif
|
|||||||
blitz: check_homebase
|
blitz: check_homebase
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
ifeq ($(MAKE_BLITZ), true)
|
||||||
$(MAKE) -C external/blitz
|
$(MAKE) -C external/blitz
|
||||||
$(MAKE) -C external/blitz install
|
|
||||||
endif
|
|
||||||
|
|
||||||
hdf5: check_homebase
|
|
||||||
ifeq ($(MAKE_H5), true)
|
|
||||||
$(MAKE) -C external/h5
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
jansson: check_homebase
|
jansson: check_homebase
|
||||||
|
|||||||
@@ -25,6 +25,16 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"elastic_example3": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT_elastic_scattering"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ionization_example1": {
|
"ionization_example1": {
|
||||||
"Type": "ElectronIonization",
|
"Type": "ElectronIonization",
|
||||||
"IonizationModel": "JanevNonDiss",
|
"IonizationModel": "JanevNonDiss",
|
||||||
@@ -46,6 +56,13 @@
|
|||||||
"OutgoingElectron": "e-",
|
"OutgoingElectron": "e-",
|
||||||
"OutgoingIon": "T+"
|
"OutgoingIon": "T+"
|
||||||
},
|
},
|
||||||
|
"ionization_example4": {
|
||||||
|
"Type": "ElectronIonization",
|
||||||
|
"IonizationModel": "JanevAtomic",
|
||||||
|
"Target": "T",
|
||||||
|
"OutgoingElectron": "e-",
|
||||||
|
"OutgoingIon": "T+"
|
||||||
|
},
|
||||||
"excitation_example0": {
|
"excitation_example0": {
|
||||||
"Type": "Excitation",
|
"Type": "Excitation",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
@@ -141,12 +158,53 @@
|
|||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"ExcitationState": "england_rotational_j1_to_j3"
|
"ExcitationState": "england_rotational_j1_to_j3"
|
||||||
},
|
},
|
||||||
|
"excitation_example19": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n2"
|
||||||
|
},
|
||||||
|
"excitation_example20": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n3"
|
||||||
|
},
|
||||||
|
"excitation_example21": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n4"
|
||||||
|
},
|
||||||
|
"excitation_example22": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n5"
|
||||||
|
},
|
||||||
|
"recombination_example1": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eTp_recombination_kotelnikov"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination_example2": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T2+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination_example3": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T3+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT3p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"T+ standart interactions": {
|
"T+ standart interactions": {
|
||||||
"elastic scattering": {
|
"elastic scattering1": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
@@ -156,6 +214,23 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"elastic scattering2": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_elastic_scattering_schultz"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"charge exchange": {
|
||||||
|
"Type": "ChargeExchange",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_charge_exchange_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"clustering1": {
|
"clustering1": {
|
||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
@@ -172,6 +247,21 @@
|
|||||||
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"clustering3": {
|
||||||
|
"Type": "Clustering",
|
||||||
|
"Target": "T",
|
||||||
|
"Product": "T2+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_clustering_tertiary_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eTp_recombination_kotelnikov"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
@@ -192,6 +282,13 @@
|
|||||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
"PredefinedFunction": "T2pT2_clustering_janev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
@@ -207,6 +304,13 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT3p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -570,15 +570,60 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"GravityField": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"PoissonSolver": {
|
"PoissonSolver": {
|
||||||
"UseInSimulation": "false"
|
"BoundaryGeometry": {
|
||||||
|
"Cylinder": {
|
||||||
|
"Radius": {
|
||||||
|
"value": 4.5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"Height": {
|
||||||
|
"value": 1600,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Boundary": {
|
||||||
|
"Top": {
|
||||||
|
"type": "neumann",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Bottom": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Hull": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"TargetAccuracy": 1e-7,
|
||||||
|
"NumCycles": 2e4,
|
||||||
|
"Intervall": 1,
|
||||||
|
"Offset": 9
|
||||||
},
|
},
|
||||||
"Simulation": {
|
"Simulation": {
|
||||||
"SimulatedEvents": 1,
|
"SimulatedEvents": 1,
|
||||||
"EventStride": 1
|
"EventStride": 1
|
||||||
},
|
},
|
||||||
"Output": {
|
"Output": {
|
||||||
"folder": "output",
|
"folder": "output_",
|
||||||
"filename": "test",
|
"filename": "test",
|
||||||
"DensityFields": {
|
"DensityFields": {
|
||||||
"Species": "all",
|
"Species": "all",
|
||||||
@@ -599,6 +644,10 @@
|
|||||||
],
|
],
|
||||||
"Intervall": "EachSync",
|
"Intervall": "EachSync",
|
||||||
"OverwriteLast": "true"
|
"OverwriteLast": "true"
|
||||||
|
},
|
||||||
|
"PoissonSolver": {
|
||||||
|
"Intervall": "EachSync",
|
||||||
|
"OverwriteLast": "true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"RandomNumbers": {
|
"RandomNumbers": {
|
||||||
|
|||||||
Executable
+536
@@ -0,0 +1,536 @@
|
|||||||
|
{
|
||||||
|
"GlobalPositionBinning": {
|
||||||
|
"CylinderBinning": {
|
||||||
|
"Radial": {
|
||||||
|
"NumberOfBins": 10,
|
||||||
|
"MaxRadius": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Longitudinal": {
|
||||||
|
"NumberOfBins": 75,
|
||||||
|
"MaxLength": {
|
||||||
|
"value": 300,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Azimuthal": {
|
||||||
|
"NumberOfBins": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SourceGeometry": {
|
||||||
|
"Cylinder": {
|
||||||
|
"Radius": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"Height": {
|
||||||
|
"value": 300,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Species": {
|
||||||
|
"Background": {
|
||||||
|
"TritiumGas": {
|
||||||
|
"ParticleType": "T",
|
||||||
|
"ConstantDensityField": {
|
||||||
|
"ScalarField": {
|
||||||
|
"ScalarFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Product": {
|
||||||
|
"fi": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fj": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fk": {
|
||||||
|
"Exponential": {
|
||||||
|
"scale": -7.1307e-4,
|
||||||
|
"prefactor": 1E17
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VelocityDistribution": {
|
||||||
|
"VelocityDistributionFromFunction": {
|
||||||
|
"VelocityDistributionFunction": {
|
||||||
|
"IsotropicDistribution": {
|
||||||
|
"EnergyDistributionFunction": {
|
||||||
|
"MaxwellBoltzmann": {
|
||||||
|
"Temperature": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "K"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Mass": {
|
||||||
|
"FromParticleType": "T"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DriftVelocity": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Product": {
|
||||||
|
"fi": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fj": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fk": {
|
||||||
|
"PiecewiseLinear": {
|
||||||
|
"xValues": [
|
||||||
|
0,
|
||||||
|
16
|
||||||
|
],
|
||||||
|
"yValues": [
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"prefactor": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Tracked": {
|
||||||
|
"e-": {
|
||||||
|
"ParticleType": "electron",
|
||||||
|
"Mover": {
|
||||||
|
"Drift": {
|
||||||
|
"MaximalMovedDistance": {
|
||||||
|
"value": 1e-3,
|
||||||
|
"unit": "m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Terminator": {
|
||||||
|
"MaximumInteractions": 1E6,
|
||||||
|
"MaxTimeAlive": {
|
||||||
|
"value": 1,
|
||||||
|
"unit": "s"
|
||||||
|
},
|
||||||
|
"BoundaryGeometry": {
|
||||||
|
"Cylinder": {
|
||||||
|
"Radius": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"Height": {
|
||||||
|
"value": 300,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Reflector": {
|
||||||
|
"NoReflector": {}
|
||||||
|
},
|
||||||
|
"DensityField": {
|
||||||
|
"DynamicDensityField": {
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"EnergyBinning": {
|
||||||
|
"Type": "Logarithmic",
|
||||||
|
"NumberOfBins": 100,
|
||||||
|
"MinEnergy": {
|
||||||
|
"value": 1E-6,
|
||||||
|
"unit": "eV"
|
||||||
|
},
|
||||||
|
"MaxEnergy": {
|
||||||
|
"value": 20E3,
|
||||||
|
"unit": "eV"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VelocityDistribution": {
|
||||||
|
"null": {}
|
||||||
|
},
|
||||||
|
"DriftVelocity": {
|
||||||
|
"null": {}
|
||||||
|
},
|
||||||
|
"Loggers": {
|
||||||
|
"Deletion": {
|
||||||
|
"Type": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CurrentCollector": {
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Interactions": {
|
||||||
|
"freeMovement": {
|
||||||
|
"Type": "FreeMovement"
|
||||||
|
},
|
||||||
|
"elastic": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "TritiumGas",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2_elastic_scattering_constant"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"T+": {
|
||||||
|
"ParticleType": "T+",
|
||||||
|
"Mover": {
|
||||||
|
"Drift":{
|
||||||
|
"MaximalMovedDistance": {
|
||||||
|
"value": 1e-3,
|
||||||
|
"unit": "m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Terminator": {
|
||||||
|
"MaximumInteractions": 1E6,
|
||||||
|
"MaxTimeAlive": {
|
||||||
|
"value": 1,
|
||||||
|
"unit": "s"
|
||||||
|
},
|
||||||
|
"BoundaryGeometry": {
|
||||||
|
"Cylinder": {
|
||||||
|
"Radius": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"Height": {
|
||||||
|
"value": 300,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Reflector": {
|
||||||
|
"NoReflector": {}
|
||||||
|
},
|
||||||
|
"DensityField": {
|
||||||
|
"DynamicDensityField": {
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"EnergyBinning": {
|
||||||
|
"Type": "Logarithmic",
|
||||||
|
"NumberOfBins": 100,
|
||||||
|
"MinEnergy": {
|
||||||
|
"value": 1E-6,
|
||||||
|
"unit": "eV"
|
||||||
|
},
|
||||||
|
"MaxEnergy": {
|
||||||
|
"value": 1E3,
|
||||||
|
"unit": "eV"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VelocityDistribution": {
|
||||||
|
"null": {}
|
||||||
|
},
|
||||||
|
"DriftVelocity": {
|
||||||
|
"null": {}
|
||||||
|
},
|
||||||
|
"Loggers": {
|
||||||
|
"Deletion": {
|
||||||
|
"Type": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CurrentCollector": {
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Interactions": {
|
||||||
|
"name1": {
|
||||||
|
"Type": "FreeMovement"
|
||||||
|
},
|
||||||
|
"elastic": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "TritiumGas",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2_elastic_scattering_constant"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Injector": {
|
||||||
|
"CreatedSpecies": {
|
||||||
|
"specie1": {
|
||||||
|
"TrackedSpecieName": "e-",
|
||||||
|
"CreationVelocityDistribution": {
|
||||||
|
"VelocityDistributionFromFunction": {
|
||||||
|
"VelocityDistributionFunction": {
|
||||||
|
"DirectedDistribution": {
|
||||||
|
"EnergyDistributionFunction": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": {
|
||||||
|
"value": 4.30867e-4,
|
||||||
|
"unit": "eV"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Mass": {
|
||||||
|
"FromParticleType": "electron"
|
||||||
|
},
|
||||||
|
"Direction":{
|
||||||
|
"vector": [1, 0, 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specie2": {
|
||||||
|
"TrackedSpecieName": "T+",
|
||||||
|
"CreationVelocityDistribution": {
|
||||||
|
"VelocityDistributionFromFunction": {
|
||||||
|
"VelocityDistributionFunction": {
|
||||||
|
"DirectedDistribution": {
|
||||||
|
"EnergyDistributionFunction": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": {
|
||||||
|
"unit": "eV",
|
||||||
|
"value": 4.30867e-4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Mass": {
|
||||||
|
"FromParticleType": "T"
|
||||||
|
},
|
||||||
|
"Direction": {
|
||||||
|
"vector": [1, 0, 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"EventPositionDistribution": {
|
||||||
|
"ScalarField": {
|
||||||
|
"ScalarFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Product": {
|
||||||
|
"fi": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fj": {
|
||||||
|
"Constant": {
|
||||||
|
"constant": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fk": {
|
||||||
|
"PiecewiseLinear": {
|
||||||
|
"xValues": [0.0, 3.0],
|
||||||
|
"yValues": [1.0, 1.0],
|
||||||
|
"prefactor": 1E15
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DensityLimit": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 1E15
|
||||||
|
},
|
||||||
|
"PositionLimits": {
|
||||||
|
"rPosition": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 0.05
|
||||||
|
},
|
||||||
|
"phiPosition": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 6.28318530718
|
||||||
|
},
|
||||||
|
"zPosition": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 0.3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"MotherDriftVelocity": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldConstant": {
|
||||||
|
"constant": {
|
||||||
|
"vector": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "m/s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Activity": {
|
||||||
|
"value": 1e7,
|
||||||
|
"unit": "Bq"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ElectricField": {
|
||||||
|
"Background": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldConstant": {
|
||||||
|
"constant": {
|
||||||
|
"vector": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "V/m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Dynamic": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldConstant": {
|
||||||
|
"constant": {
|
||||||
|
"vector": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "V/m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"MagneticField": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 2.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GradientField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GravityField": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": -9.81
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PoissonSolver": {
|
||||||
|
"BoundaryGeometry": {
|
||||||
|
"CreateSameAs": ["SourceGeometry"]
|
||||||
|
},
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Boundary": {
|
||||||
|
"Top": {
|
||||||
|
"type": "neumann",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Bottom": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Hull": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"TargetAccuracy": 1e-6,
|
||||||
|
"NumCycles": 2e4,
|
||||||
|
"DoSolver": "true"
|
||||||
|
},
|
||||||
|
"Simulation": {
|
||||||
|
"SimulatedEvents": 200000,
|
||||||
|
"EventStride": 5000,
|
||||||
|
"TimeResolutionEvents": 20000,
|
||||||
|
"commentTimeRes": "number of events over all cpus defining the timeresolution"
|
||||||
|
},
|
||||||
|
"Output": {
|
||||||
|
"folder": "output",
|
||||||
|
"filename": "timerestest3",
|
||||||
|
"DensityFields": {
|
||||||
|
"Species": "all",
|
||||||
|
"Intervall": 1,
|
||||||
|
"OverwriteLast": "false"
|
||||||
|
},
|
||||||
|
"CurrentBorders": {
|
||||||
|
"Species": [
|
||||||
|
"e-",
|
||||||
|
"T+"
|
||||||
|
],
|
||||||
|
"Intervall": "EachSync",
|
||||||
|
"OverwriteLast": "false"
|
||||||
|
},
|
||||||
|
"DeletionLogger": {
|
||||||
|
"Species": "all",
|
||||||
|
"Intervall": "EachSync",
|
||||||
|
"OverwriteLast": "false"
|
||||||
|
},
|
||||||
|
"PoissonSolver": {
|
||||||
|
"Intervall": "EachSync",
|
||||||
|
"OverwriteLast": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RandomNumbers": {
|
||||||
|
"Seed": 1337
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,10 @@ std::function<double(double)> Product(
|
|||||||
return product;
|
return product;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale) {
|
||||||
|
return [=](double x) { return prefactor * std::exp(scale * x); };
|
||||||
|
}
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
}
|
}
|
||||||
return D1ToD1::Product(functions);
|
return D1ToD1::Product(functions);
|
||||||
|
|
||||||
|
} else if (json_object_by_path(object, {"Exponential"})) {
|
||||||
|
DEBUG_LEVEL_2("Creating function1d: Exponential.");
|
||||||
|
double prefactor = json_double(json_object_by_path(
|
||||||
|
object, {"Exponential", {"prefactor"}}));
|
||||||
|
double scale = json_double(json_object_by_path(
|
||||||
|
object, {"Exponential", {"scale"}}));
|
||||||
|
return D1ToD1::Exponential(prefactor, scale);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This 1d to 1d function is not implemented.");
|
ERROR("This 1d to 1d function is not implemented.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#include "generators/gravity_field_generator.h"
|
||||||
|
|
||||||
|
#include "generators/vector_field_generator.h"
|
||||||
|
|
||||||
|
namespace generator {
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(json_t* object) {
|
||||||
|
DEBUG_LEVEL_2("Generating gravity field.");
|
||||||
|
return std::shared_ptr<GravityField>(new GravityField(
|
||||||
|
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(Parameter& parameter) {
|
||||||
|
return gravityField(
|
||||||
|
json_object_by_path(parameter.jsonFile(), {"GravityField"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -7,7 +7,8 @@ namespace generator {
|
|||||||
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
||||||
DEBUG_LEVEL_2("Generating magnetic field.");
|
DEBUG_LEVEL_2("Generating magnetic field.");
|
||||||
return std::shared_ptr<MagneticField>(new MagneticField(
|
return std::shared_ptr<MagneticField>(new MagneticField(
|
||||||
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
buildVectorField(json_object_by_path(object, {"VectorField"})),
|
||||||
|
buildVectorField(json_object_by_path(object, {"GradientField"}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MagneticField> magneticField(Parameter& parameter) {
|
std::shared_ptr<MagneticField> magneticField(Parameter& parameter) {
|
||||||
|
|||||||
@@ -30,20 +30,6 @@ namespace generator {
|
|||||||
|
|
||||||
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
||||||
|
|
||||||
int solver_intervall = json_int(json_object_by_path(object, {"Intervall"}));
|
|
||||||
if (solver_intervall == 0 &&
|
|
||||||
json_string(json_object_by_path(
|
|
||||||
object, {"Intervall"})) == "EachSync") {
|
|
||||||
solver_intervall = 1;
|
|
||||||
}
|
|
||||||
ASSERT_POSITIVE(&solver_intervall,
|
|
||||||
"The intervall for poisson solver stride must be positive"
|
|
||||||
" or 'EachSync'");
|
|
||||||
|
|
||||||
int solver_offset = json_int(json_object_by_path(object, {"Offset"}));
|
|
||||||
ASSERT_NOTNEGATIVE(&solver_offset,
|
|
||||||
"The offset for poisson solver has to be non-negative");
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
||||||
|
|
||||||
double target_accuracy = parameter.doubleValue(
|
double target_accuracy = parameter.doubleValue(
|
||||||
@@ -52,9 +38,12 @@ namespace generator {
|
|||||||
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
||||||
{"NumCycles"}));
|
{"NumCycles"}));
|
||||||
|
|
||||||
|
bool do_solver = parameter.boolValue(
|
||||||
|
json_path_append({"PoissonSolver"}, {"DoSolver"}), false);
|
||||||
|
|
||||||
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
||||||
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
||||||
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset));
|
electrodes, target_accuracy, num_cycles, do_solver));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ blitz::Array<double, 3> readComponentFromFile(json_t* object, int component) {
|
|||||||
std::string absolute_filename =
|
std::string absolute_filename =
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||||
std::string key = json_string(
|
std::string key = json_string(
|
||||||
json_array_get(json_object_by_path(object, {"PathToH5"}), component));
|
json_array_get(json_object_by_path(object, {"Keys"}), component));
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD3Double(key);
|
return reader.readD3Double(key);
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
const blitz::TinyVector<double, 3> v_cluster =
|
const blitz::TinyVector<double, 3> v_cluster =
|
||||||
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
||||||
v_target / kinematic::norm(v_target);
|
v_target / kinematic::norm(v_target);
|
||||||
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster));
|
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
||||||
|
particle.timeAlive());
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(cluster);
|
output.add(cluster);
|
||||||
|
|||||||
@@ -93,10 +93,14 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
|
|
||||||
particle.velocity(v_impact_new);
|
particle.velocity(v_impact_new);
|
||||||
|
|
||||||
|
|
||||||
|
const double time_birth = particle.timeAlive();
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(
|
output.add(
|
||||||
particle::Particle(electron_, x_impact, CartesianVector(v_ejected)));
|
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
||||||
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target)));
|
time_birth));
|
||||||
|
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target),
|
||||||
|
time_birth));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
std::vector<std::shared_ptr<Electrode>> electrodes,
|
std::vector<std::shared_ptr<Electrode>> electrodes,
|
||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
int solver_intervall,
|
bool do_solver)
|
||||||
int solver_offset)
|
|
||||||
: bottom_boundary_(bottom_boundary),
|
: bottom_boundary_(bottom_boundary),
|
||||||
top_boundary_(top_boundary),
|
top_boundary_(top_boundary),
|
||||||
hull_boundary_(hull_boundary),
|
hull_boundary_(hull_boundary),
|
||||||
@@ -33,8 +32,7 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
electrodes_(electrodes),
|
electrodes_(electrodes),
|
||||||
target_accuracy_(target_accuracy),
|
target_accuracy_(target_accuracy),
|
||||||
num_cycles_(num_cycles),
|
num_cycles_(num_cycles),
|
||||||
solver_intervall_(solver_intervall),
|
do_solver_(do_solver) {
|
||||||
solver_offset_(solver_offset) {
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
@@ -79,13 +77,12 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
blitz::Range(density_binning.binIndexMin()(2),
|
blitz::Range(density_binning.binIndexMin()(2),
|
||||||
density_binning.binIndexMax()(2)));
|
density_binning.binIndexMax()(2)));
|
||||||
zero_chargedensity = 0.;
|
zero_chargedensity = 0.;
|
||||||
solvePotential(zero_chargedensity, 0);
|
solvePotential(zero_chargedensity, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 3> charge_density, int cpu_sync) {
|
const blitz::Array<double, 3> charge_density, const bool solve) {
|
||||||
if ((cpu_sync % solver_intervall_ != 0) || ((cpu_sync <= solver_offset_)
|
if (!(do_solver_) || !(solve)) {
|
||||||
&& (cpu_sync > 0))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||||
@@ -243,7 +240,7 @@ bool PoissonSolver::converged(
|
|||||||
double normalized_maximum =
|
double normalized_maximum =
|
||||||
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Maximum Differenece normalized by order of magnitude: "
|
message << "Maximum Difference normalized by order of magnitude: "
|
||||||
<< normalized_difference;
|
<< normalized_difference;
|
||||||
DEBUG_LEVEL_0(message.str());
|
DEBUG_LEVEL_0(message.str());
|
||||||
return normalized_difference < target_accuracy_;
|
return normalized_difference < target_accuracy_;
|
||||||
|
|||||||
@@ -133,9 +133,10 @@ void CpuSynchronizer::synchronize(
|
|||||||
tracked_species) {
|
tracked_species) {
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
auto it = tracked_species.begin();
|
auto it = tracked_species.begin();
|
||||||
DEBUG_LEVEL_3("Timer Synchronization.");
|
// drops due to time being a global variable now
|
||||||
synchronize(it->second->dynamicDensityField()->timer_.get(),
|
//DEBUG_LEVEL_3("Timer Synchronization.");
|
||||||
it->second->lastSyncDensityField()->timer_.get());
|
//synchronize(it->second->dynamicDensityField()->timer_.get(),
|
||||||
|
// it->second->lastSyncDensityField()->timer_.get());
|
||||||
|
|
||||||
for (auto& pair : tracked_species) {
|
for (auto& pair : tracked_species) {
|
||||||
// DEBUG_LEVEL_3("dynden Synchronization.");
|
// DEBUG_LEVEL_3("dynden Synchronization.");
|
||||||
|
|||||||
@@ -238,5 +238,16 @@ blitz::Array<double, 3> CurrentCollector::currentInR() const {
|
|||||||
return current_in_r;
|
return current_in_r;
|
||||||
}
|
}
|
||||||
double CurrentCollector::physicalTime() const {
|
double CurrentCollector::physicalTime() const {
|
||||||
return timer_->time();
|
return timer_->getDeltaT();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurrentCollector::resetCurrentCollector() {
|
||||||
|
z_negative_crossings = 0.;
|
||||||
|
z_positive_crossings = 0.;
|
||||||
|
|
||||||
|
phi_negative_crossings = 0.;
|
||||||
|
phi_positive_crossings = 0.;
|
||||||
|
|
||||||
|
r_negative_crossings = 0.;
|
||||||
|
r_positive_crossings = 0.;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ 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());
|
||||||
|
|
||||||
const double t = timer_->time();
|
const double t = timer_->getDeltaT();
|
||||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
||||||
position_bin(0), position_bin(1), position_bin(2), blitz::Range::all()));
|
position_bin(0), position_bin(1), position_bin(2), blitz::Range::all()));
|
||||||
const long int deleted_particles = blitz::sum(deleted_particles_(
|
const long int deleted_particles = blitz::sum(deleted_particles_(
|
||||||
@@ -146,7 +146,7 @@ double DynamicDensityField::density(const Coordinate& position,
|
|||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
const double t = timer_->time();
|
const double t = timer_->getDeltaT();
|
||||||
const double time_in_bin = time_in_bin_s_(position_bin(0), position_bin(1),
|
const double time_in_bin = time_in_bin_s_(position_bin(0), position_bin(1),
|
||||||
position_bin(2), energy_bin);
|
position_bin(2), energy_bin);
|
||||||
const long deleted_particles = deleted_particles_(
|
const long deleted_particles = deleted_particles_(
|
||||||
@@ -177,7 +177,7 @@ void DynamicDensityField::recalculateDensityArray() {
|
|||||||
blitz::thirdIndex iz;
|
blitz::thirdIndex iz;
|
||||||
blitz::fourthIndex iE;
|
blitz::fourthIndex iE;
|
||||||
|
|
||||||
const double t = timer_->time();
|
const double t = timer_->getDeltaT();
|
||||||
density_per_m3_ = (time_in_bin_s_(ir, iphi, iz, iE) / t -
|
density_per_m3_ = (time_in_bin_s_(ir, iphi, iz, iE) / t -
|
||||||
deleted_particles_(ir, iphi, iz, iE)) /
|
deleted_particles_(ir, iphi, iz, iE)) /
|
||||||
bin_volume_m3_(ir, iphi, iz);
|
bin_volume_m3_(ir, iphi, iz);
|
||||||
@@ -205,6 +205,13 @@ double DynamicDensityField::physicalTime() const {
|
|||||||
return timer_->time();
|
return timer_->time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
|
//timer_->resetTime(); // time stays global
|
||||||
|
time_in_bin_s_ = 0.;
|
||||||
|
deleted_particles_ = 0.;
|
||||||
|
density_per_m3_ = 0.;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -16,9 +16,25 @@ void ElectricField::updateDynamicField(std::shared_ptr<VectorField> field) {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
MagneticField::MagneticField(std::shared_ptr<VectorField> field)
|
MagneticField::MagneticField(std::shared_ptr<VectorField> field,
|
||||||
: field_(field) {}
|
std::shared_ptr<VectorField> gradient)
|
||||||
|
: field_(field), gradient_(gradient) {}
|
||||||
|
|
||||||
CylinderVector MagneticField::value(const Coordinate& position) const {
|
CylinderVector MagneticField::value(const Coordinate& position) const {
|
||||||
return field_->value(position);
|
return field_->value(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CylinderVector MagneticField::gradientValue(const Coordinate& position) const {
|
||||||
|
return gradient_->value(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GravityField::GravityField(std::shared_ptr<VectorField> field):
|
||||||
|
field_(field) {}
|
||||||
|
|
||||||
|
CylinderVector GravityField::value(const Coordinate& position) const {
|
||||||
|
return field_->value(position);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
#include "simulation/species.h"
|
#include "simulation/species.h"
|
||||||
#include "simulation/velocity_distribution.h"
|
#include "simulation/velocity_distribution.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
Injector::Injector(
|
Injector::Injector(
|
||||||
std::vector<InjectorInfo>& injector_info,
|
std::vector<InjectorInfo>& injector_info,
|
||||||
@@ -26,7 +27,8 @@ particle::Particle Injector::rollNewParticle(
|
|||||||
std::mt19937* engine,
|
std::mt19937* engine,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution) {
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
||||||
|
const double time_birth) {
|
||||||
blitz::TinyVector<double, 3> velocity =
|
blitz::TinyVector<double, 3> velocity =
|
||||||
creation_velocity_distribution->rollVelocity(position, engine)
|
creation_velocity_distribution->rollVelocity(position, engine)
|
||||||
.cartesianEntries();
|
.cartesianEntries();
|
||||||
@@ -35,20 +37,29 @@ particle::Particle Injector::rollNewParticle(
|
|||||||
velocity,
|
velocity,
|
||||||
mother_drift_velocity_->driftVelocity(position).cartesianEntries());
|
mother_drift_velocity_->driftVelocity(position).cartesianEntries());
|
||||||
}
|
}
|
||||||
|
std::stringstream out;
|
||||||
|
out << created_specie->name() << " created at time: " << time_birth << "s.";
|
||||||
|
DEBUG_LEVEL_3(out.str());
|
||||||
return particle::Particle(created_specie, position,
|
return particle::Particle(created_specie, position,
|
||||||
CartesianVector(velocity));
|
CartesianVector(velocity), time_birth);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<particle::Particle> Injector::rollNewParticles(
|
std::vector<particle::Particle> Injector::rollNewParticles(
|
||||||
std::mt19937* engine) {
|
std::mt19937* engine, const double current_time,
|
||||||
|
const int time_resolution_events) {
|
||||||
CylinderCoordinate position = position_distribution_->rollPosition(engine);
|
CylinderCoordinate position = position_distribution_->rollPosition(engine);
|
||||||
DEBUG_LEVEL_3("Injected z position: " +
|
DEBUG_LEVEL_3("Injected z position: " +
|
||||||
std::to_string(position.cylinderEntries()(2)));
|
std::to_string(position.cylinderEntries()(2)));
|
||||||
std::vector<particle::Particle> new_particles;
|
std::vector<particle::Particle> new_particles;
|
||||||
|
const double delta_t = time_resolution_events*timePassed();
|
||||||
|
std::uniform_real_distribution<> injection_time(current_time - delta_t,
|
||||||
|
current_time);
|
||||||
|
const double time_birth = injection_time(*engine);
|
||||||
for (auto& injector_info : injector_infos_) {
|
for (auto& injector_info : injector_infos_) {
|
||||||
new_particles.push_back(
|
new_particles.push_back(
|
||||||
rollNewParticle(engine, position, injector_info.created_specie,
|
rollNewParticle(engine, position, injector_info.created_specie,
|
||||||
injector_info.creation_velocity_distribution));
|
injector_info.creation_velocity_distribution,
|
||||||
|
time_birth));
|
||||||
}
|
}
|
||||||
return new_particles;
|
return new_particles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,3 +30,9 @@ long int DeletionLogger::numDeletions(DeletionType type) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeletionLogger::resetDeletionLogger() {
|
||||||
|
for(auto& pair : num_deletions) {
|
||||||
|
pair.second = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+65
-18
@@ -22,7 +22,8 @@ BorisMover::BorisMover(double maximal_time_step_s)
|
|||||||
void BorisMover::move(particle::Particle* particle,
|
void BorisMover::move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) {
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) {
|
||||||
double leftover_distance = mfp_m;
|
double leftover_distance = mfp_m;
|
||||||
|
|
||||||
auto old_position = particle->position();
|
auto old_position = particle->position();
|
||||||
@@ -172,7 +173,8 @@ DriftMover::DriftMover(double maximal_distance)
|
|||||||
void DriftMover::move(particle::Particle* particle,
|
void DriftMover::move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) {
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) {
|
||||||
double leftover_distance = mfp_m;
|
double leftover_distance = mfp_m;
|
||||||
|
|
||||||
auto old_position = particle->position();
|
auto old_position = particle->position();
|
||||||
@@ -185,7 +187,9 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
// if particle too slow -> timestep > maximum time the particle lives
|
// if particle too slow -> timestep > maximum time the particle lives
|
||||||
// -> add maximal timestep to time in bin and stop moving the particle
|
// -> add maximal timestep to time in bin and stop moving the particle
|
||||||
bool died_in_bin = false;
|
bool died_in_bin = false;
|
||||||
const double max_time_alive = particle->specie()->terminator()->maxTimeAlive();
|
const double max_time_alive =
|
||||||
|
particle->specie()->dynamicDensityField()->physicalTime() -
|
||||||
|
particle->timeAlive();
|
||||||
|
|
||||||
while (
|
while (
|
||||||
!(changed_position_bin || changed_energy_bin || left_simulation_domain) &&
|
!(changed_position_bin || changed_energy_bin || left_simulation_domain) &&
|
||||||
@@ -195,12 +199,17 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> E =
|
blitz::TinyVector<double, 3> force_over_charge =
|
||||||
electric_field->value(old_position).cartesianEntries(old_position);
|
electric_field->value(old_position).cartesianEntries(old_position) +
|
||||||
|
gravity_field->value(old_position).cartesianEntries(old_position) *
|
||||||
|
particle->mass_kg() / particle->charge_C();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> B =
|
const blitz::TinyVector<double, 3> B =
|
||||||
magnetic_field->value(old_position).cartesianEntries(old_position);
|
magnetic_field->value(old_position).cartesianEntries(old_position);
|
||||||
const double B_norm = kinematic::norm(B);
|
const double B_norm = kinematic::norm(B);
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> gradB =
|
||||||
|
magnetic_field->gradientValue(old_position).cartesianEntries(old_position);
|
||||||
// Todo: add calculation of divB here
|
// Todo: add calculation of divB here
|
||||||
// use Kassiopeia paper for reference
|
// use Kassiopeia paper for reference
|
||||||
|
|
||||||
@@ -212,7 +221,18 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
||||||
const double v_perp_norm = kinematic::norm(v_perp);
|
const double v_perp_norm = kinematic::norm(v_perp);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_drift = driftVelocity(B, E);
|
// magnetic moment
|
||||||
|
const double magnetic_moment = (particle->mass_kg()*(v_perp_norm*v_perp_norm)/2)/B_norm;
|
||||||
|
|
||||||
|
force_over_charge += -(magnetic_moment / particle->charge_C() * gradB);
|
||||||
|
|
||||||
|
// curvature force
|
||||||
|
force_over_charge += -(particle->mass_kg()/particle->charge_C() *
|
||||||
|
(v_parallel_norm*v_parallel_norm) *
|
||||||
|
kinematic::perpendicularVector(gradB, B) /
|
||||||
|
B_norm);
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> v_drift = driftVelocity(force_over_charge, B);
|
||||||
const double v_drift_norm = kinematic::norm(v_drift);
|
const double v_drift_norm = kinematic::norm(v_drift);
|
||||||
|
|
||||||
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
||||||
@@ -226,14 +246,15 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
v_parallel * timestep;
|
v_parallel * timestep;
|
||||||
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
|
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> E_parallel =
|
const blitz::TinyVector<double, 3> force_over_charge_parallel =
|
||||||
kinematic::parallelVector(E, B);
|
kinematic::parallelVector(force_over_charge, B);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> dv_electric =
|
const blitz::TinyVector<double, 3> dv_electric =
|
||||||
timestep * particle->charge_C() * E_parallel / particle->mass_kg();
|
timestep * particle->charge_C() * force_over_charge_parallel / particle->mass_kg();
|
||||||
|
|
||||||
if (v_perp_norm > SimConstants::compare_epsilon) {
|
if (v_perp_norm > SimConstants::compare_epsilon) {
|
||||||
const double gyro_radius = particle->mass_kg() * v_perp_norm /
|
const double gyro_radius = particle->mass_kg() * v_perp_norm /
|
||||||
(B_norm * std::abs(particle->charge_C()));
|
(B_norm * particle->charge_C());
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> velocity_normal =
|
const blitz::TinyVector<double, 3> velocity_normal =
|
||||||
(-1) * blitz::cross(B, v_perp);
|
(-1) * blitz::cross(B, v_perp);
|
||||||
@@ -243,20 +264,43 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
const double gyro_frequency =
|
const double gyro_frequency =
|
||||||
particle->charge_C() * B_norm / particle->mass_kg();
|
particle->charge_C() * B_norm / particle->mass_kg();
|
||||||
const double total_rotation_angle = gyro_frequency * timestep;
|
const double total_rotation_angle = -gyro_frequency * timestep;
|
||||||
const blitz::TinyVector<double, 3> movement_around_gyro_center =
|
const blitz::TinyVector<double, 3> movement_around_gyro_center =
|
||||||
|
offset_to_gyro_center -
|
||||||
kinematic::rotateVector(offset_to_gyro_center, B,
|
kinematic::rotateVector(offset_to_gyro_center, B,
|
||||||
total_rotation_angle) -
|
total_rotation_angle);
|
||||||
offset_to_gyro_center;
|
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_perp_rotated =
|
const blitz::TinyVector<double, 3> v_perp_rotated =
|
||||||
kinematic::rotateVector(v_perp, B, total_rotation_angle);
|
kinematic::rotateVector(v_perp, B, total_rotation_angle);
|
||||||
|
|
||||||
|
const double v_parallel_norm_new = kinematic::norm(v_parallel + dv_electric);
|
||||||
|
// might be better to do after the actual movement and then just extract
|
||||||
|
// the position again from the particle
|
||||||
|
const blitz::TinyVector<double, 3> new_position = old_position.cartesianEntries()
|
||||||
|
+ movement_parallel
|
||||||
|
+ movement_drift
|
||||||
|
+ movement_around_gyro_center;
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> B_new =
|
||||||
|
magnetic_field->value(CartesianCoordinate(new_position)).
|
||||||
|
cartesianEntries(CartesianCoordinate(new_position));
|
||||||
|
|
||||||
|
const double v_perp_norm_new =
|
||||||
|
sqrt(2*magnetic_moment*kinematic::norm(B_new)/particle->mass_kg());
|
||||||
|
|
||||||
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
|
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
|
||||||
movement_around_gyro_center));
|
movement_around_gyro_center));
|
||||||
|
|
||||||
particle->velocity(
|
const blitz::TinyVector<double, 3> v_parallel_new =
|
||||||
CartesianVector(v_parallel + v_perp_rotated + dv_electric));
|
kinematic::parallelVector(v_parallel + dv_electric, B_new);
|
||||||
|
const blitz::TinyVector<double, 3> v_perp_new =
|
||||||
|
kinematic::perpendicularVector(v_perp_rotated, B_new);
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> v_new =
|
||||||
|
v_parallel_new/kinematic::norm(v_parallel_new)*v_parallel_norm_new +
|
||||||
|
v_perp_new/kinematic::norm(v_perp_new)*v_perp_norm_new;
|
||||||
|
|
||||||
|
particle->velocity(CartesianVector(v_new));
|
||||||
} else {
|
} else {
|
||||||
particle->move(CartesianCoordinate(movement_parallel + movement_drift));
|
particle->move(CartesianCoordinate(movement_parallel + movement_drift));
|
||||||
particle->velocity(CartesianVector(v_parallel + dv_electric));
|
particle->velocity(CartesianVector(v_parallel + dv_electric));
|
||||||
@@ -269,6 +313,9 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
died_in_bin =
|
died_in_bin =
|
||||||
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||||
|
if(died_in_bin) {
|
||||||
|
DEBUG_LEVEL_3("Mover: particle died in bin.");
|
||||||
|
}
|
||||||
|
|
||||||
changed_position_bin =
|
changed_position_bin =
|
||||||
particle->specie()->dynamicDensityField()->changedPositionBin(
|
particle->specie()->dynamicDensityField()->changedPositionBin(
|
||||||
@@ -291,8 +338,8 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||||
const blitz::TinyVector<double, 3>& electric_field) const {
|
const blitz::TinyVector<double, 3>& magnetic_field) const {
|
||||||
return blitz::cross(magnetic_field, electric_field) /
|
return blitz::cross(force_field_over_charge, magnetic_field) /
|
||||||
blitz::dot(magnetic_field, magnetic_field);
|
blitz::dot(magnetic_field, magnetic_field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|||||||
|
|
||||||
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity)
|
const Vector& velocity,
|
||||||
|
const double time_birth)
|
||||||
: specie_(specie),
|
: specie_(specie),
|
||||||
position_(position),
|
position_(position),
|
||||||
velocity_(velocity, position),
|
velocity_(velocity, position),
|
||||||
id_(this->last_id_),
|
id_(this->last_id_),
|
||||||
time_alive_s_(0.),
|
time_alive_s_(time_birth),
|
||||||
time_in_bin_s_(0.),
|
time_in_bin_s_(0.),
|
||||||
interaction_counter_(0) {
|
interaction_counter_(0) {
|
||||||
last_id_++;
|
last_id_++;
|
||||||
@@ -110,4 +111,8 @@ double Particle::timeInBin() const {
|
|||||||
return time_in_bin_s_;
|
return time_in_bin_s_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long int Particle::ID() const {
|
||||||
|
return id_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace particle
|
} // namespace particle
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "generators/simulation_output_generator.h"
|
#include "generators/simulation_output_generator.h"
|
||||||
#include "generators/species_generator.h"
|
#include "generators/species_generator.h"
|
||||||
#include "generators/poisson_solver_generator.h"
|
#include "generators/poisson_solver_generator.h"
|
||||||
|
#include "generators/gravity_field_generator.h"
|
||||||
|
|
||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ Simulation::Simulation(std::string parameter_filename)
|
|||||||
void Simulation::init(Parameter& parameter) {
|
void Simulation::init(Parameter& parameter) {
|
||||||
magnetic_field_ = generator::magneticField(parameter);
|
magnetic_field_ = generator::magneticField(parameter);
|
||||||
electric_field_ = generator::electricField(parameter);
|
electric_field_ = generator::electricField(parameter);
|
||||||
|
gravity_field_ = generator::gravityField(parameter);
|
||||||
|
|
||||||
DEBUG_LEVEL_0("Creating species.");
|
DEBUG_LEVEL_0("Creating species.");
|
||||||
generator::SpeciesBuilder builder(parameter);
|
generator::SpeciesBuilder builder(parameter);
|
||||||
@@ -67,6 +69,9 @@ void Simulation::init(Parameter& parameter) {
|
|||||||
DEBUG_LEVEL_0("Init cpu synchronizer.");
|
DEBUG_LEVEL_0("Init cpu synchronizer.");
|
||||||
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
|
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
|
||||||
DEBUG_LEVEL_3("Init done.");
|
DEBUG_LEVEL_3("Init done.");
|
||||||
|
|
||||||
|
active_queue_ = 0;
|
||||||
|
non_active_queue_ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eventsThisCpu(int events_all_cpus) {
|
int eventsThisCpu(int events_all_cpus) {
|
||||||
@@ -86,6 +91,11 @@ int eventsOfCycle(int stride, int leftover_events) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switch_active(int& active, int& non_active) {
|
||||||
|
non_active = active;
|
||||||
|
active = (active + 1)%2;
|
||||||
|
}
|
||||||
|
|
||||||
void Simulation::finalize() {
|
void Simulation::finalize() {
|
||||||
SIM_INFO("Simulation ended.");
|
SIM_INFO("Simulation ended.");
|
||||||
}
|
}
|
||||||
@@ -97,21 +107,47 @@ void Simulation::start() {
|
|||||||
parameter_.intValue(json_path({"Simulation", "EventStride"}), 1);
|
parameter_.intValue(json_path({"Simulation", "EventStride"}), 1);
|
||||||
const int total_simulated_events =
|
const int total_simulated_events =
|
||||||
parameter_.intValue(json_path({"Simulation", "SimulatedEvents"}), 1);
|
parameter_.intValue(json_path({"Simulation", "SimulatedEvents"}), 1);
|
||||||
|
const int time_resolution_events =
|
||||||
|
parameter_.intValue(json_path({"Simulation", "TimeResolutionEvents"}),
|
||||||
|
total_simulated_events);
|
||||||
|
|
||||||
SIM_INFO("Total simulated events: " + std::to_string(total_simulated_events));
|
SIM_INFO("Total simulated events: " + std::to_string(total_simulated_events));
|
||||||
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
||||||
const int events_this_cpu = eventsThisCpu(total_simulated_events);
|
const int events_this_cpu = eventsThisCpu(total_simulated_events);
|
||||||
|
const int time_resolution_this_cpu = eventsThisCpu(time_resolution_events);
|
||||||
SIM_INFO("Events per cpu (approx.): " + std::to_string(events_this_cpu));
|
SIM_INFO("Events per cpu (approx.): " + std::to_string(events_this_cpu));
|
||||||
int leftover_events = events_this_cpu;
|
int leftover_events = events_this_cpu;
|
||||||
|
int leftover_events_time_resolution = time_resolution_this_cpu;
|
||||||
|
|
||||||
|
const double delta_t = time_resolution_events*injector_->timePassed();
|
||||||
|
timer_->setDeltaT(delta_t);
|
||||||
|
|
||||||
int num_cpu_syncs = 0;
|
int num_cpu_syncs = 0;
|
||||||
|
bool reset = true;
|
||||||
|
|
||||||
|
queues_[0].reserve(events_this_cpu);
|
||||||
|
queues_[1].reserve(events_this_cpu);
|
||||||
|
// bring some order into the reset checks
|
||||||
|
|
||||||
|
timer_->increaseTimestep(delta_t);
|
||||||
while (leftover_events > 0) {
|
while (leftover_events > 0) {
|
||||||
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events);
|
std::stringstream out;
|
||||||
|
out << "Timeinterval: " << timer_->time() << "s.";
|
||||||
|
out << "\n size of particle: " << sizeof(particle::Particle);
|
||||||
|
DEBUG_LEVEL_3(out.str());
|
||||||
|
|
||||||
|
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events_time_resolution);
|
||||||
SIM_INFO("Leftover events on first cpu: " +
|
SIM_INFO("Leftover events on first cpu: " +
|
||||||
std::to_string(leftover_events));
|
std::to_string(leftover_events));
|
||||||
processEvents(events_of_cylcle);
|
processEvents(events_of_cylcle, time_resolution_events);
|
||||||
|
DEBUG_LEVEL_3("Size of backup queue: " +
|
||||||
|
std::to_string(queues_[non_active_queue_].size()));
|
||||||
|
|
||||||
DEBUG_LEVEL_1("Leftover events: " + std::to_string(leftover_events));
|
DEBUG_LEVEL_1("Leftover events: " + std::to_string(leftover_events));
|
||||||
leftover_events -= events_of_cylcle;
|
leftover_events -= events_of_cylcle;
|
||||||
|
leftover_events_time_resolution -= events_of_cylcle;
|
||||||
|
|
||||||
|
reset = !(leftover_events_time_resolution > 0);
|
||||||
|
|
||||||
SIM_INFO("Cpu sync.");
|
SIM_INFO("Cpu sync.");
|
||||||
SimulationTimer::eventStartPoint(std::string("CpuSync"));
|
SimulationTimer::eventStartPoint(std::string("CpuSync"));
|
||||||
@@ -121,7 +157,7 @@ void Simulation::start() {
|
|||||||
|
|
||||||
SIM_INFO("Poisson step.");
|
SIM_INFO("Poisson step.");
|
||||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||||
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs);
|
poisson_solver_->solvePotential(chargedensity(), reset);
|
||||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||||
|
|
||||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||||
@@ -130,6 +166,28 @@ void Simulation::start() {
|
|||||||
SimulationTimer::eventStartPoint(std::string("Output"));
|
SimulationTimer::eventStartPoint(std::string("Output"));
|
||||||
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
|
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
|
||||||
SimulationTimer::eventStopPoint(std::string("Output"));
|
SimulationTimer::eventStopPoint(std::string("Output"));
|
||||||
|
|
||||||
|
if(reset) {
|
||||||
|
SIM_INFO("Do resets and increase the timestep for timeresolution.");
|
||||||
|
timer_->increaseTimestep(delta_t);
|
||||||
|
for(auto& pair : tracked_species_) {
|
||||||
|
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
||||||
|
pair.second->lastSyncDensityField()->resetDynamicDensityField();
|
||||||
|
|
||||||
|
// questionable if they need to be reset:
|
||||||
|
// + time res in current
|
||||||
|
// - ions very slow -> very unlikely that an ion crosses a boundary
|
||||||
|
pair.second->currentCollector()->resetCurrentCollector();
|
||||||
|
pair.second->lastSyncCurrentCollector()->resetCurrentCollector();
|
||||||
|
|
||||||
|
// do not need to be reset, since the time resolution considers the same
|
||||||
|
// set of particles
|
||||||
|
// pair.second->deletionLogger()->resetDeletionLogger();
|
||||||
|
// pair.second->lastSyncDeletionLogger()->resetDeletionLogger();
|
||||||
|
}
|
||||||
|
leftover_events_time_resolution = time_resolution_this_cpu;
|
||||||
|
switch_active(active_queue_, non_active_queue_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,20 +195,18 @@ int particleNumberFromQueue(int queue_length, RandomNumbers* random) {
|
|||||||
return random->rollUniform(0, queue_length);
|
return random->rollUniform(0, queue_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::processEvents(int events) {
|
void Simulation::processEvents(int events, const int time_resolution_events) {
|
||||||
DEBUG_LEVEL_0("Processing events.");
|
DEBUG_LEVEL_0("Processing events.");
|
||||||
std::vector<particle::Particle> particle_queue;
|
|
||||||
particle_queue.reserve(100);
|
|
||||||
int current_event = 0;
|
int current_event = 0;
|
||||||
while ((current_event < events) || (!particle_queue.empty())) {
|
while ((current_event < events) || (!queues_[active_queue_].empty())) {
|
||||||
DEBUG_LEVEL_2("Current event: " + std::to_string(current_event));
|
DEBUG_LEVEL_2("Current event: " + std::to_string(current_event));
|
||||||
|
|
||||||
if (particle_queue.empty()) {
|
if (queues_[active_queue_].empty()) {
|
||||||
current_event += 1;
|
current_event += 1;
|
||||||
DEBUG_LEVEL_2("Inject particles to queue.");
|
DEBUG_LEVEL_2("Inject particles to queue.");
|
||||||
SimulationTimer::eventStartPoint(std::string("ParticleInjection"));
|
SimulationTimer::eventStartPoint(std::string("ParticleInjection"));
|
||||||
std::vector<particle::Particle> new_particles =
|
std::vector<particle::Particle> new_particles =
|
||||||
determineInjectedParticles(random_.get());
|
determineInjectedParticles(random_.get(), time_resolution_events);
|
||||||
#if defined debug_level3
|
#if defined debug_level3
|
||||||
for(auto& particle : new_particles) {
|
for(auto& particle : new_particles) {
|
||||||
std::stringstream output_ss;
|
std::stringstream output_ss;
|
||||||
@@ -164,25 +220,27 @@ void Simulation::processEvents(int events) {
|
|||||||
SimulationTimer::eventStopPoint(std::string("ParticleInjection"));
|
SimulationTimer::eventStopPoint(std::string("ParticleInjection"));
|
||||||
DEBUG_LEVEL_2("Injected particles to queue.");
|
DEBUG_LEVEL_2("Injected particles to queue.");
|
||||||
|
|
||||||
particle_queue.insert(particle_queue.end(), new_particles.begin(),
|
queues_[active_queue_].insert(queues_[active_queue_].end(), new_particles.begin(),
|
||||||
new_particles.end());
|
new_particles.end());
|
||||||
}
|
}
|
||||||
DEBUG_LEVEL_2("Particles in queue: " + std::to_string(particle_queue.size()));
|
DEBUG_LEVEL_2("Particles in queue: " +
|
||||||
|
std::to_string(queues_[active_queue_].size()));
|
||||||
|
DEBUG_LEVEL_2("Particles in backup queue: " +
|
||||||
|
std::to_string(queues_[non_active_queue_].size()));
|
||||||
const int particle_number =
|
const int particle_number =
|
||||||
particleNumberFromQueue(particle_queue.size(), random_.get());
|
particleNumberFromQueue(queues_[active_queue_].size(), random_.get());
|
||||||
|
|
||||||
// extract particle here from queue, so that an extension of the queue does
|
// extract particle here from queue, so that an extension of the queue does
|
||||||
// not mess up the reference
|
// not mess up the reference
|
||||||
particle::Particle particle = particle_queue.at(particle_number);
|
particle::Particle particle = queues_[active_queue_].at(particle_number);
|
||||||
particle_queue.erase(particle_queue.begin() + particle_number);
|
queues_[active_queue_].erase(queues_[active_queue_].begin() + particle_number);
|
||||||
|
|
||||||
processUntilTermination(particle, particle_queue);
|
processUntilTermination(particle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::processUntilTermination(
|
void Simulation::processUntilTermination(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle) {
|
||||||
std::vector<particle::Particle>& particle_queue) {
|
|
||||||
DEBUG_LEVEL_3("Process particle until termination");
|
DEBUG_LEVEL_3("Process particle until termination");
|
||||||
while (particle.specie()->terminator()->isAlive(&particle)) {
|
while (particle.specie()->terminator()->isAlive(&particle)) {
|
||||||
auto old_position = particle.position();
|
auto old_position = particle.position();
|
||||||
@@ -194,7 +252,7 @@ void Simulation::processUntilTermination(
|
|||||||
|
|
||||||
SimulationTimer::eventStartPoint(std::string("Mover"));
|
SimulationTimer::eventStartPoint(std::string("Mover"));
|
||||||
particle.specie()->mover()->move(&particle, mfp_m, electric_field_.get(),
|
particle.specie()->mover()->move(&particle, mfp_m, electric_field_.get(),
|
||||||
magnetic_field_.get());
|
magnetic_field_.get(), gravity_field_.get());
|
||||||
SimulationTimer::eventStopPoint(std::string("Mover"));
|
SimulationTimer::eventStopPoint(std::string("Mover"));
|
||||||
|
|
||||||
bool was_reflected = false;
|
bool was_reflected = false;
|
||||||
@@ -209,12 +267,9 @@ void Simulation::processUntilTermination(
|
|||||||
|
|
||||||
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
||||||
&particle)) {
|
&particle)) {
|
||||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name()
|
DEBUG_LEVEL_3("Move particle " + particle.specie()->name()
|
||||||
+". Reached max time alive.");
|
+" to backup queue.");
|
||||||
if (particle.specie()->deletionLogger()) {
|
queues_[non_active_queue_].push_back(particle);
|
||||||
particle.specie()->deletionLogger()->logDeletion(
|
|
||||||
particle.position(), DeletionType::max_time_alive);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else if (particle.specie()->terminator()->leftSimulationDomain(
|
} else if (particle.specie()->terminator()->leftSimulationDomain(
|
||||||
&particle)) {
|
&particle)) {
|
||||||
@@ -253,7 +308,7 @@ void Simulation::processUntilTermination(
|
|||||||
particle.increaseInteractionCounter();
|
particle.increaseInteractionCounter();
|
||||||
|
|
||||||
for (auto& new_particle : output.newParticles()) {
|
for (auto& new_particle : output.newParticles()) {
|
||||||
particle_queue.push_back(new_particle);
|
queues_[active_queue_].push_back(new_particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.deleteCurrentParticle()) {
|
if (output.deleteCurrentParticle()) {
|
||||||
@@ -322,9 +377,10 @@ interaction::InteractionOutput Simulation::interact(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<particle::Particle> Simulation::determineInjectedParticles(
|
std::vector<particle::Particle> Simulation::determineInjectedParticles(
|
||||||
RandomNumbers* random) {
|
RandomNumbers* random, const int time_resolution_events) {
|
||||||
timer_->increaseTimestep(injector_->timePassed());
|
// timer_->increaseTimestep(injector_->timePassed());
|
||||||
return injector_->rollNewParticles(random->engine());
|
return injector_->rollNewParticles(random->engine(),
|
||||||
|
timer_->time(), time_resolution_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
//maybe put that into the poisson solver
|
//maybe put that into the poisson solver
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "simulation/errors.h"
|
#include "simulation/errors.h"
|
||||||
#include "simulation/geometry.h"
|
#include "simulation/geometry.h"
|
||||||
|
#include "simulation/density_field.h"
|
||||||
|
|
||||||
Terminator::Terminator(long int max_interactions,
|
Terminator::Terminator(long int max_interactions,
|
||||||
double max_time_alive,
|
double max_time_alive,
|
||||||
@@ -31,7 +32,8 @@ bool Terminator::reachedMaxInteractions(
|
|||||||
return particle->interactionCounter() > max_interactions_;
|
return particle->interactionCounter() > max_interactions_;
|
||||||
}
|
}
|
||||||
bool Terminator::reachedMaxTimeAlive(const particle::Particle* particle) const {
|
bool Terminator::reachedMaxTimeAlive(const particle::Particle* particle) const {
|
||||||
return particle->timeAlive() > max_time_alive_;
|
return particle->timeAlive() >= particle->specie()->dynamicDensityField()
|
||||||
|
->physicalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Terminator::leftSimulationDomain(
|
bool Terminator::leftSimulationDomain(
|
||||||
|
|||||||
@@ -13,3 +13,15 @@ void Timer::increaseTimestep(double time_s) {
|
|||||||
void Timer::setTime(double time_s) {
|
void Timer::setTime(double time_s) {
|
||||||
current_time_s_ = time_s;
|
current_time_s_ = time_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timer::resetTime() {
|
||||||
|
setTime(0.);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::setDeltaT(double deltaT) {
|
||||||
|
delta_t_time_resolution_ = deltaT;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Timer::getDeltaT() const {
|
||||||
|
return delta_t_time_resolution_;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user