fixed guard against very low energies in drift mover
This commit is contained in:
@@ -165,10 +165,14 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
bool changed_position_bin = false;
|
bool changed_position_bin = false;
|
||||||
bool changed_energy_bin = false;
|
bool changed_energy_bin = false;
|
||||||
bool left_simulation_domain = false;
|
bool left_simulation_domain = false;
|
||||||
|
// if particle too slow -> timestep > maximum time the particle lives
|
||||||
|
// -> add maximal timestep to time in bin and stop moving the particle
|
||||||
|
bool died_in_bin = false;
|
||||||
|
const double max_time_alive = particle->specie()->terminator()->maxTimeAlive();
|
||||||
|
|
||||||
while (
|
while (
|
||||||
!(changed_position_bin || changed_energy_bin || left_simulation_domain) &&
|
!(changed_position_bin || changed_energy_bin || left_simulation_domain) &&
|
||||||
(leftover_distance > 0.)) {
|
(leftover_distance > 0.) && !(died_in_bin)) {
|
||||||
old_position = particle->position();
|
old_position = particle->position();
|
||||||
old_velocity = particle->velocity();
|
old_velocity = particle->velocity();
|
||||||
|
|
||||||
@@ -197,7 +201,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
// should be a very rare case (but has happend)
|
// should be a very rare case (but has happend)
|
||||||
const double timestep = std::min(
|
const double timestep = std::min(
|
||||||
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
|
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
|
||||||
particle->specie()->terminator()->maxTimeAlive());
|
max_time_alive);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> movement_parallel =
|
const blitz::TinyVector<double, 3> movement_parallel =
|
||||||
v_parallel * timestep;
|
v_parallel * timestep;
|
||||||
@@ -244,6 +248,9 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
const auto new_position = particle->position();
|
const auto new_position = particle->position();
|
||||||
|
|
||||||
|
died_in_bin =
|
||||||
|
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||||
|
|
||||||
changed_position_bin =
|
changed_position_bin =
|
||||||
particle->specie()->dynamicDensityField()->changedPositionBin(
|
particle->specie()->dynamicDensityField()->changedPositionBin(
|
||||||
old_position, new_position);
|
old_position, new_position);
|
||||||
|
|||||||
Reference in New Issue
Block a user