Fixed errors in when and where particles are

deposited (Boris Mover)
This commit is contained in:
2025-06-17 10:48:01 +02:00
parent 05125a3fc1
commit 249fbfc275
2 changed files with 11 additions and 6 deletions
+9 -6
View File
@@ -51,6 +51,7 @@ void BorisMover::move(particle::Particle* particle,
magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
double old_mu;
double new_mu;
// if magnetic field is 0 use e_z as a reference for the pitch angle
// calculation (don't know if best approach, probably not...)
if (kinematic::norm(B_old) == 0) {
@@ -110,7 +111,6 @@ void BorisMover::move(particle::Particle* particle,
magnetic_field->value(particle->cylinderPosition()).
cartesianEntries(new_position_cart);
double new_mu;
if (kinematic::norm(B_new) == 0) {
new_mu = kinematic::cosPitchAngle(
blitz::TinyVector<double, 3>(0,0,1), new_velocity.cartesianEntries());
@@ -147,9 +147,12 @@ void BorisMover::move(particle::Particle* particle,
? delta_timeresolution*SimConstants::compare_epsilon
: (max_time_alive - timestep);
}
if(died_in_bin) {
if(died_in_bin && !left_simulation_domain) {
// use new values, since that is necessary if died_in_bin and a change in
// bin can occur at the same time
particle->specie()->dynamicDensityField()->logMovement(
old_position_cyl, old_kinetic_energy, old_mu, particle->weight());
particle->cylinderPosition(), particle->kineticEnergy_eV(), new_mu,
particle->weight());
#ifdef debug
particle->deposited();
#endif
@@ -232,10 +235,10 @@ void BorisMover::movementStep(
/*
Might be slower, but essentially the same code */
const blitz::TinyVector<double, 3> u_minus =
v + (acceleration * maximal_time_step_s_) / (2.);
v + (acceleration * timestep) / (2.);
const double gamma = kinematic::relativisticGamma(u_minus);;
const blitz::TinyVector<double, 3> temp_1 =
(q * magnetic_field * maximal_time_step_s_) / (2. * m * gamma);
(q * magnetic_field * timestep) / (2. * m * gamma);
const blitz::TinyVector<double, 3> u_prime =
u_minus + (blitz::cross(u_minus, temp_1));
const blitz::TinyVector<double, 3> temp_2 =
@@ -243,7 +246,7 @@ void BorisMover::movementStep(
const blitz::TinyVector<double, 3> u_plus =
u_minus + (blitz::cross(u_prime, temp_2));
const blitz::TinyVector<double, 3> u_new =
u_plus + (acceleration * maximal_time_step_s_) / (2.);
u_plus + (acceleration * timestep) / (2.);
particle->velocity(CartesianVector(u_new));