Bug fixes and formatting
This commit is contained in:
@@ -31,6 +31,14 @@ void BorisMover::move(particle::Particle* particle,
|
||||
// keep hard coded for now; has to be decided to be either kept (new field for Boris
|
||||
// mover in json file) or removed again
|
||||
const double max_distance = 1e-4;
|
||||
const double delta_timeresolution = particle->specie()->
|
||||
dynamicDensityField()->timeResolution();
|
||||
// in order to try to minimize the overshoot in the time domain (i.e. if particle
|
||||
// can only life a time dt < min(distance/v, maximal_timestep), which might even be
|
||||
// a lot larger than dt, which would increase the influence of the particle on the
|
||||
// density)
|
||||
double max_time_alive = particle->specie()->dynamicDensityField()->physicalTime() -
|
||||
particle->timeAlive();
|
||||
double leftover_distance = mfp_m;
|
||||
|
||||
auto old_position = particle->position();
|
||||
@@ -54,12 +62,12 @@ void BorisMover::move(particle::Particle* particle,
|
||||
|
||||
double timestep = 0;
|
||||
|
||||
if (old_kinetic_energy < 1E-9) {
|
||||
// Guard against small enegies taking up much time without contributing to
|
||||
// density
|
||||
SIM_INFO("particle skipped due to energy.");
|
||||
return;
|
||||
}
|
||||
// if (old_kinetic_energy < 1E-9) {
|
||||
// // Guard against small enegies taking up much time without contributing to
|
||||
// // density
|
||||
// SIM_INFO("particle skipped due to energy.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
bool changed_position_bin = false;
|
||||
bool changed_energy_bin = false;
|
||||
@@ -77,6 +85,7 @@ void BorisMover::move(particle::Particle* particle,
|
||||
timestep = std::min(maximal_time_step_s_,
|
||||
(leftover_distance + SimConstants::random_lower_limit) / old_velocity);
|
||||
timestep = std::min(timestep, max_distance / old_velocity);
|
||||
timestep = std::min(timestep, max_time_alive);
|
||||
|
||||
double moved_distance = 0.;
|
||||
|
||||
@@ -127,6 +136,14 @@ void BorisMover::move(particle::Particle* particle,
|
||||
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||
|
||||
leftover_distance -= moved_distance;
|
||||
|
||||
// if max_time_alive == 0 but the difference between the time alive and
|
||||
// the endtime > 0 (think can happen due to numerical accuracy)
|
||||
// an infinite loop is created. Therefore catch that case and
|
||||
// allow for a small overshoot in the timedomain (see comment in drift mover)
|
||||
max_time_alive = ((max_time_alive - timestep) <= 0)
|
||||
? delta_timeresolution*SimConstants::compare_epsilon
|
||||
: (max_time_alive - timestep);
|
||||
}
|
||||
|
||||
particle->specie()->dynamicDensityField()->logMovement(
|
||||
@@ -386,7 +403,7 @@ void DriftMover::move(particle::Particle* particle,
|
||||
particle->increaseTimeAlive(timestep);
|
||||
particle->increaseTimeInBin(timestep);
|
||||
// if instead of eps*deltaT 0.0 is used the integral would be conserved
|
||||
// if no particles were lost. however in that case the terminator does not
|
||||
// if no particles are lost at a boundary. however in that case the terminator does not
|
||||
// return the correct value if the time the particle is alive is identical
|
||||
// to the physical time... -> increases computation time alot
|
||||
// The version below means that each timestep the density can grow by
|
||||
|
||||
Reference in New Issue
Block a user