included guard against very large (or inf) timesteps

This commit is contained in:
2024-03-13 13:15:12 +01:00
parent 18ace1d64b
commit be5ab2fbb0
3 changed files with 10 additions and 2 deletions
+5 -2
View File
@@ -212,8 +212,11 @@ void DriftMover::move(particle::Particle* particle,
const double v_drift_norm = kinematic::norm(v_drift);
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
const double timestep =
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm);
// guard against very large timesteps i.e. v ~ 0 -> timestep = Inf
// should be a very rare case (but has happend)
const double timestep = std::min(
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
particle->specie()->terminator()->maxTimeAlive());
const blitz::TinyVector<double, 3> movement_parallel =
v_parallel * timestep;