From b8a463167625ea447751dd24bd410b08e00caa2a Mon Sep 17 00:00:00 2001 From: csendlinger Date: Wed, 25 Jun 2025 17:50:58 +0200 Subject: [PATCH] Reverted last commit. Changed powerlaw drawing from left to right cell for power calculation --- src/simulation/mover.cpp | 6 +++--- src/simulation/simulation.cpp | 19 +++++++++---------- src/simulation/velocity_distribution.cpp | 14 +++++++++++--- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/simulation/mover.cpp b/src/simulation/mover.cpp index 6b03a67..bf6d5d4 100755 --- a/src/simulation/mover.cpp +++ b/src/simulation/mover.cpp @@ -161,9 +161,9 @@ void BorisMover::move(particle::Particle* particle, ? delta_timeresolution*SimConstants::compare_epsilon : (max_time_alive - timestep); } - if(died_in_bin && !left_simulation_domain - && (leftover_time > SimConstants::compare_epsilon || - changed_energy_bin || changed_mu_bin || changed_position_bin)) { +if(died_in_bin && !left_simulation_domain) { + // && (leftover_time > SimConstants::compare_epsilon || + // changed_energy_bin || changed_mu_bin || changed_position_bin)) { // 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( diff --git a/src/simulation/simulation.cpp b/src/simulation/simulation.cpp index 3c79002..e27528e 100755 --- a/src/simulation/simulation.cpp +++ b/src/simulation/simulation.cpp @@ -498,8 +498,7 @@ void Simulation::processUntilTermination( if (particle.specie()->terminator()->reachedMaxTimeAlive( &particle) && !particle.specie()->terminator()->leftSimulationDomain( - &particle) && - particle.wasDeposited()) { + &particle)) { #ifdef debug_level3 DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() + ". Reached timeresolution."); @@ -574,14 +573,14 @@ void Simulation::processUntilTermination( // in order to log the position. (Not ideal, but otherwise it would be a bit // more effort to calculate the pitchangle here again...) // should work, since the check for died in bin should immediatly happen (hopefully) - if(particle.specie()->terminator()->reachedMaxTimeAlive(&particle) - && !particle.wasDeposited() && !output.deleteCurrentParticle()) { - particle.specie()->mover()->move(&particle, 1, - electric_field_.get(), magnetic_field_.get(), gravity_field_.get()); - if(!particle.wasDeposited()) { - ERROR("particle was not deposited even though it should have been"); - } - } + // if(particle.specie()->terminator()->reachedMaxTimeAlive(&particle) + // && !particle.wasDeposited() && !output.deleteCurrentParticle()) { + // particle.specie()->mover()->move(&particle, 1, + // electric_field_.get(), magnetic_field_.get(), gravity_field_.get()); + // if(!particle.wasDeposited()) { + // ERROR("particle was not deposited even though it should have been"); + // } + // } particle.increaseInteractionCounter(); diff --git a/src/simulation/velocity_distribution.cpp b/src/simulation/velocity_distribution.cpp index 6c1ad2a..89fd12e 100755 --- a/src/simulation/velocity_distribution.cpp +++ b/src/simulation/velocity_distribution.cpp @@ -225,11 +225,19 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity( // DEBUG(out.str()); // #endif } else { - double nl = density_field_->particleNumber(index - - blitz::TinyVector(0,0,0,0,1)); - double nr = density_field_->particleNumber(index); +// check missing for if nl or nr = 0! -> what alpha to choose? + double nl = density_field_->particleNumber(index); + double nr = density_field_->particleNumber(index+ + blitz::TinyVector(0,0,0,0,1)); + double alpha = std::log(nr/nl)/std::log(energyBinBorders_[index(4) + 2]/ energyBinBorders_[index(4) + 1]); +// no reason for specific values, just to avoid these cases + if(nl == 0) { + alpha = 1; + } else if (nr == 0) { + alpha = -1; + } if(alpha == -1) { energy_eV = (std::pow(2, theta_distribution_(*engine)) - 1)*energy_step + energyBinBorders_[index(4) + 1];