included guard against very large (or inf) timesteps
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -37,4 +37,8 @@ bool Terminator::reachedMaxTimeAlive(const particle::Particle* particle) const {
|
||||
bool Terminator::leftSimulationDomain(
|
||||
const particle::Particle* particle) const {
|
||||
return !(geometry_->isInside(particle->position()));
|
||||
}
|
||||
|
||||
double Terminator::maxTimeAlive() const {
|
||||
return max_time_alive_;
|
||||
}
|
||||
Reference in New Issue
Block a user