Changed distance drawing procedure;

Changed mover to work with times instead of distance;
Changed how interactions are done (recombination still tbd)
This commit is contained in:
2025-05-08 09:56:25 +02:00
parent 2c79c567d8
commit 60430abcba
16 changed files with 225 additions and 76 deletions
+2
View File
@@ -15,6 +15,8 @@ class FreeMovement : public Interaction {
double microscopicCrossSection(double energy_eV);
double macroscopicCrossSection(particle::Particle& particle);
double drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator);
};
}; // namespace interaction
+7
View File
@@ -33,12 +33,19 @@ class Interaction {
virtual double microscopicCrossSection(double energy_eV);
virtual double macroscopicCrossSection(particle::Particle& particle);
// return the time the given particle can travel in the laboratory frame
// before this specific interaction occurs (also stores the velocity of the
// target particle)
virtual double drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator);
virtual InteractionOutput performInteraction(particle::Particle& particle,
RandomNumbers* generator) = 0;
protected:
std::function<double(double)> cross_section_;
std::shared_ptr<species::Specie> target_;
CartesianVector target_velocity_;
};
}; // namespace interaction
+9 -4
View File
@@ -4,10 +4,15 @@
#include "simulation/electromagnetic_field.h"
#include "simulation/particle.h"
/*
change the mfp_m variable to a time_s variable!
*/
class Mover {
public:
virtual void move(particle::Particle* particle,
double mfp_m,
double collision_time_s,
ElectricField* electric_field,
MagneticField* magnetic_field,
GravityField* gravity_field) = 0;
@@ -18,7 +23,7 @@ class BorisMover : public Mover {
BorisMover(double maximal_time_step_s);
void move(particle::Particle* particle,
double mfp_m,
double collision_time_s,
ElectricField* electric_field,
MagneticField* magnetic_field,
GravityField* gravity_field);
@@ -30,7 +35,7 @@ class BorisMover : public Mover {
const blitz::TinyVector<double, 3>& electric_field,
const blitz::TinyVector<double, 3>& magnetic_field,
const blitz::TinyVector<double, 3>& gravity_field,
double& moved_distance,
// double& moved_distance,
double timestep) const;
};
@@ -39,7 +44,7 @@ class DriftMover : public Mover {
DriftMover(double maximal_distance);
void move(particle::Particle* particle,
double mfp_m,
double collision_time_s,
ElectricField* electric_field,
MagneticField* magnetic_field,
GravityField* gravity_field);
+6
View File
@@ -48,6 +48,9 @@ class Particle {
double weight() const;
void indexNextInteration(const int index) { index_next_interaction_ = index; };
int indexNextInteraction() { return index_next_interaction_; };
private:
double weight_;
@@ -58,6 +61,9 @@ class Particle {
// double time_in_bin_s_;
long int interaction_counter_;
// index of the interaction with the sortest distance (-1 if that's none of them)
int index_next_interaction_ = -1;
std::shared_ptr<species::TrackedSpecie> specie_;
long int id_;
+8
View File
@@ -53,6 +53,14 @@ class Simulation {
double meanFreePath(particle::Particle& particle, RandomNumbers* random,
std::vector<double>& macroscopic_cross_sections_m);
// draw the individual collision times of the possible interactions and return the
// minimum of them. Also sets the "nextInteractionIndex" in the particle to the
// interaction of the chosen time.
double collisionTime(particle::Particle& particle, RandomNumbers* random);
interaction::InteractionOutput interact(particle::Particle& particle,
RandomNumbers* random);
interaction::InteractionOutput interact(particle::Particle& particle,
RandomNumbers* random,
std::vector<double>& macroscopic_cross_sections_m);
+3 -3
View File
@@ -42,7 +42,7 @@ class Specie {
std::string name() const;
virtual DensityField* densityField() = 0;
virtual VelocityDistribution* velocityDistibution() = 0;
virtual VelocityDistribution* velocityDistribution() = 0;
virtual DriftVelocity* driftVelocity() = 0;
protected:
@@ -67,7 +67,7 @@ class TrackedSpecie : public Specie {
std::shared_ptr<DynamicDensityField> density_for_drawing);
DensityField* densityField();
VelocityDistribution* velocityDistibution();
VelocityDistribution* velocityDistribution();
DriftVelocity* driftVelocity();
DynamicDensityField* dynamicDensityField();
@@ -122,7 +122,7 @@ class BackgroundSpecie : public Specie {
std::shared_ptr<DriftVelocity> drift_velocity);
DensityField* densityField();
VelocityDistribution* velocityDistibution();
VelocityDistribution* velocityDistribution();
DriftVelocity* driftVelocity();
private: