Particles don't reset interaction between timesteps,

added possibility to stride the injection of new
beta particles
This commit is contained in:
2025-08-20 14:54:03 +02:00
parent ddfa5672df
commit abab8810f3
7 changed files with 160 additions and 166 deletions
+50 -13
View File
@@ -21,19 +21,19 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
// requires the name of a species "spec_name" to be smaller than 16 characters
// this is not! checked here and will lead to undefined behaviour if this
// requirement is not fulfilled
SerializedParticle::SerializedParticle(double time_birth, double weight,
SerializedParticle::SerializedParticle(double weight,
blitz::TinyVector<double, 3> cartPos,
blitz::TinyVector<double, 3> cartVel,
std::string spec_name) :
time_birth_(time_birth), weight_(weight),
std::string spec_name,
int idx_nxt_interaction,
double time_until_collision) :
weight_(weight),
cartesian_position_(cartPos),
cartesian_velocity_(cartVel) {
cartesian_velocity_(cartVel),
idx_nxt_interaction_(idx_nxt_interaction),
time_until_interaction_(time_until_collision) {
std::copy(spec_name.begin(), spec_name.end(), specie_name_.data());
specie_name_[spec_name.length()] = '\0';
}
double SerializedParticle::timeBirth() {
return time_birth_;
specie_name_[spec_name.length()] = '\0';
}
double SerializedParticle::weight() {
@@ -52,6 +52,14 @@ std::string SerializedParticle::specieName() {
return std::string (specie_name_.data());
}
double SerializedParticle::timeUntilCollision() {
return time_until_interaction_;
}
int SerializedParticle::indexNextInteraction() {
return idx_nxt_interaction_;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -71,6 +79,21 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
last_id_++;
}
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
const Coordinate& position,
const Vector& velocity,
const double weight)
: specie_(specie),
position_cart_(position),
position_cyl_(position),
velocity_(velocity, position),
id_(this->last_id_),
time_alive_s_(0.),
interaction_counter_(0),
weight_(weight) {
last_id_++;
}
Particle::Particle(particle::SerializedParticle sparticle, std::map<std::string,
std::shared_ptr<species::TrackedSpecie>>& tracked_species) :
specie_(tracked_species[sparticle.specieName()]),
@@ -78,9 +101,11 @@ Particle::Particle(particle::SerializedParticle sparticle, std::map<std::string,
position_cyl_(blitz::TinyVector<double, 3>(0,0,0)),
velocity_(sparticle.cartesianVelocity()),
id_(this->last_id_),
time_alive_s_(sparticle.timeBirth()),
time_alive_s_(0.),
interaction_counter_(0),
weight_(sparticle.weight()) {
weight_(sparticle.weight()),
index_next_interaction_(sparticle.indexNextInteraction()),
time_until_collision_(sparticle.timeUntilCollision()) {
last_id_++;
position_cyl_ = CylinderCoordinate(position_cart_);
}
@@ -174,10 +199,22 @@ bool Particle::wasDeposited() {
return deposited_;
}
void Particle::timeUntilCollision(const double time_until_collision) {
time_until_collision_ = time_until_collision;
}
double Particle::timeUntilCollision() const {
return time_until_collision_;
}
void Particle::reduceTimeUntilCollision(double delta) {
time_until_collision_ -= delta;
}
particle::SerializedParticle Particle::serialize() {
return particle::SerializedParticle(time_alive_s_, weight_,
return particle::SerializedParticle(weight_,
position_cart_.cartesianEntries(), velocity_.cartesianEntries(),
specie_->name());
specie_->name(), index_next_interaction_, time_until_collision_);
}
} // namespace particle