Changed distance drawing procedure;
Changed mover to work with times instead of distance; Changed how interactions are done (recombination still tbd)
This commit is contained in:
+19
-18
@@ -21,7 +21,7 @@ BorisMover::BorisMover(double maximal_time_step_s)
|
||||
|
||||
// TBD: include F_g (simply add to electric force)
|
||||
void BorisMover::move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
double collision_time_s,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field) {
|
||||
@@ -39,7 +39,7 @@ void BorisMover::move(particle::Particle* particle,
|
||||
// density)
|
||||
double max_time_alive = particle->specie()->dynamicDensityField()->physicalTime() -
|
||||
particle->timeAlive();
|
||||
double leftover_distance = mfp_m;
|
||||
double leftover_time = collision_time_s;
|
||||
|
||||
auto old_position = particle->position();
|
||||
double old_kinetic_energy = particle->kineticEnergy_eV();
|
||||
@@ -77,17 +77,17 @@ void BorisMover::move(particle::Particle* particle,
|
||||
|
||||
while (
|
||||
!(changed_position_bin || changed_energy_bin || left_simulation_domain ||
|
||||
changed_mu_bin || died_in_bin) && (leftover_distance > 0.)) {
|
||||
changed_mu_bin || died_in_bin) && (leftover_time > 0.)) {
|
||||
old_position = particle->position();
|
||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||
|
||||
double old_velocity = particle->absoluteVelocity();
|
||||
timestep = std::min(maximal_time_step_s_,
|
||||
(leftover_distance + SimConstants::random_lower_limit) / old_velocity);
|
||||
timestep = std::min(maximal_time_step_s_, leftover_time);
|
||||
timestep = std::min(timestep, max_distance / old_velocity);
|
||||
timestep = std::min(timestep, max_time_alive);
|
||||
|
||||
double moved_distance = 0.;
|
||||
// can probably be removed
|
||||
// double moved_distance = 0.;
|
||||
|
||||
const blitz::TinyVector<double, 3> E =
|
||||
electric_field->value(old_position).cartesianEntries(old_position);
|
||||
@@ -96,7 +96,7 @@ void BorisMover::move(particle::Particle* particle,
|
||||
const blitz::TinyVector<double, 3> g =
|
||||
gravity_field->value(old_position).cartesianEntries(old_position);
|
||||
|
||||
movementStep(particle, E, B, g, moved_distance, timestep);
|
||||
movementStep(particle, E, B, g, timestep);
|
||||
particle->increaseTimeAlive(timestep);
|
||||
// particle->increaseTimeInBin(timestep);
|
||||
|
||||
@@ -135,7 +135,7 @@ void BorisMover::move(particle::Particle* particle,
|
||||
died_in_bin =
|
||||
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||
|
||||
leftover_distance -= moved_distance;
|
||||
leftover_time -= timestep;
|
||||
|
||||
// if max_time_alive == 0 but the difference between the time alive and
|
||||
// the endtime > 0 (think can happen due to numerical accuracy)
|
||||
@@ -157,7 +157,7 @@ void BorisMover::movementStep(
|
||||
const blitz::TinyVector<double, 3>& electric_field,
|
||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||
const blitz::TinyVector<double, 3>& gravity_field,
|
||||
double& moved_distance,
|
||||
// double& moved_distance,
|
||||
double timestep) const {
|
||||
const blitz::TinyVector<double, 3> v =
|
||||
particle->velocity().cartesianEntries();
|
||||
@@ -241,8 +241,8 @@ void BorisMover::movementStep(
|
||||
const CartesianCoordinate distance(u_new * timestep);
|
||||
particle->move(distance);
|
||||
|
||||
moved_distance += std::sqrt(
|
||||
blitz::dot(distance.cartesianEntries(), distance.cartesianEntries()));
|
||||
// moved_distance += std::sqrt(
|
||||
// blitz::dot(distance.cartesianEntries(), distance.cartesianEntries()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -253,11 +253,11 @@ DriftMover::DriftMover(double maximal_distance)
|
||||
: maximal_distance_m_(maximal_distance){};
|
||||
|
||||
void DriftMover::move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
double collision_time_s,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field) {
|
||||
double leftover_distance = mfp_m;
|
||||
double leftover_time = collision_time_s;
|
||||
|
||||
auto old_position = particle->position();
|
||||
auto old_velocity = particle->velocity();
|
||||
@@ -280,7 +280,7 @@ void DriftMover::move(particle::Particle* particle,
|
||||
while (
|
||||
!(changed_position_bin || changed_energy_bin || changed_mu_bin
|
||||
|| left_simulation_domain) &&
|
||||
(leftover_distance > 0.) && !(died_in_bin)) {
|
||||
(leftover_time > 0.) && !(died_in_bin)) {
|
||||
old_position = particle->position();
|
||||
old_velocity = particle->velocity();
|
||||
|
||||
@@ -324,14 +324,15 @@ void DriftMover::move(particle::Particle* particle,
|
||||
driftVelocity(force_over_charge, B);
|
||||
const double v_drift_norm = kinematic::norm(v_drift);
|
||||
|
||||
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
||||
// const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
||||
// 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 / std::sqrt(v_parallel_norm*v_parallel_norm +
|
||||
double timestep = std::min(
|
||||
maximal_distance_m_ / std::sqrt(v_parallel_norm*v_parallel_norm +
|
||||
v_perp_norm*v_perp_norm +
|
||||
v_drift_norm*v_drift_norm),
|
||||
max_time_alive);
|
||||
timestep = std::min(timestep, collision_time_s);
|
||||
|
||||
const blitz::TinyVector<double, 3> movement_parallel =
|
||||
v_parallel * timestep;
|
||||
@@ -452,7 +453,7 @@ void DriftMover::move(particle::Particle* particle,
|
||||
left_simulation_domain =
|
||||
particle->specie()->terminator()->leftSimulationDomain(particle);
|
||||
|
||||
leftover_distance -= stepsize;
|
||||
// leftover_distance -= stepsize;
|
||||
}
|
||||
|
||||
// only log a particle in the bin where its movement ends, i.e. if
|
||||
|
||||
Reference in New Issue
Block a user