Fixed errors in when and where particles are
deposited (Boris Mover)
This commit is contained in:
@@ -51,6 +51,7 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
|
|
||||||
double old_mu;
|
double old_mu;
|
||||||
|
double new_mu;
|
||||||
// if magnetic field is 0 use e_z as a reference for the pitch angle
|
// if magnetic field is 0 use e_z as a reference for the pitch angle
|
||||||
// calculation (don't know if best approach, probably not...)
|
// calculation (don't know if best approach, probably not...)
|
||||||
if (kinematic::norm(B_old) == 0) {
|
if (kinematic::norm(B_old) == 0) {
|
||||||
@@ -110,7 +111,6 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
magnetic_field->value(particle->cylinderPosition()).
|
magnetic_field->value(particle->cylinderPosition()).
|
||||||
cartesianEntries(new_position_cart);
|
cartesianEntries(new_position_cart);
|
||||||
|
|
||||||
double new_mu;
|
|
||||||
if (kinematic::norm(B_new) == 0) {
|
if (kinematic::norm(B_new) == 0) {
|
||||||
new_mu = kinematic::cosPitchAngle(
|
new_mu = kinematic::cosPitchAngle(
|
||||||
blitz::TinyVector<double, 3>(0,0,1), new_velocity.cartesianEntries());
|
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
|
? delta_timeresolution*SimConstants::compare_epsilon
|
||||||
: (max_time_alive - timestep);
|
: (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(
|
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
|
#ifdef debug
|
||||||
particle->deposited();
|
particle->deposited();
|
||||||
#endif
|
#endif
|
||||||
@@ -232,10 +235,10 @@ void BorisMover::movementStep(
|
|||||||
/*
|
/*
|
||||||
Might be slower, but essentially the same code */
|
Might be slower, but essentially the same code */
|
||||||
const blitz::TinyVector<double, 3> u_minus =
|
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 double gamma = kinematic::relativisticGamma(u_minus);;
|
||||||
const blitz::TinyVector<double, 3> temp_1 =
|
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 =
|
const blitz::TinyVector<double, 3> u_prime =
|
||||||
u_minus + (blitz::cross(u_minus, temp_1));
|
u_minus + (blitz::cross(u_minus, temp_1));
|
||||||
const blitz::TinyVector<double, 3> temp_2 =
|
const blitz::TinyVector<double, 3> temp_2 =
|
||||||
@@ -243,7 +246,7 @@ void BorisMover::movementStep(
|
|||||||
const blitz::TinyVector<double, 3> u_plus =
|
const blitz::TinyVector<double, 3> u_plus =
|
||||||
u_minus + (blitz::cross(u_prime, temp_2));
|
u_minus + (blitz::cross(u_prime, temp_2));
|
||||||
const blitz::TinyVector<double, 3> u_new =
|
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));
|
particle->velocity(CartesianVector(u_new));
|
||||||
|
|
||||||
|
|||||||
@@ -471,6 +471,8 @@ void Simulation::processUntilTermination(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
||||||
|
&particle) &&
|
||||||
|
!particle.specie()->terminator()->leftSimulationDomain(
|
||||||
&particle)) {
|
&particle)) {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
|
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
|
||||||
|
|||||||
Reference in New Issue
Block a user