Author SHA1 Message Date
csendlinger 5f025c667f fix alpha limiting 2025-07-10 13:43:20 +02:00
csendlinger 0237292c5c Added counting of physical losses at a wall
to deletion logger
2025-07-09 16:39:56 +02:00
csendlinger 603434e161 changed the way powerlaw drawing alpha is limited 2025-07-09 16:38:04 +02:00
csendlinger f5a4e63627 Added limiter to power of powerlaw drawing stuff 2025-07-08 11:06:40 +02:00
csendlinger c4ae430fff corrected powerlaw drawing 2025-07-02 09:54:15 +02:00
csendlinger 7ddb57e72e Changed elastic scattering to not use v_e >> v_t 2025-07-01 10:12:07 +02:00
csendlinger f9307af911 back to right sided drawing 2025-06-27 15:00:44 +02:00
csendlinger b2399c3812 central interpolation energy drawing 2025-06-26 09:42:03 +02:00
csendlinger b8a4631676 Reverted last commit.
Changed powerlaw drawing from left to right
cell for power calculation
2025-06-25 17:50:58 +02:00
csendlinger 87ffe087b8 If interaction and timeres reached at same
time log only after interaction. Some debug stuff
2025-06-25 16:05:24 +02:00
csendlinger 9ef7fcd3ca energy drawing via powerlaw 2025-06-24 15:53:26 +02:00
csendlinger d06d805465 Small bugfix for ion energy from ionization and
random index
2025-06-23 13:30:22 +02:00
csendlinger 249fbfc275 Fixed errors in when and where particles are
deposited (Boris Mover)
2025-06-17 10:48:01 +02:00
14 changed files with 344 additions and 20 deletions
+2 -1
View File
@@ -15,7 +15,8 @@ class ElasticScattering : public Interaction {
InteractionOutput performInteraction(particle::Particle& particle,
RandomNumbers* generator);
virtual double drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator);
private:
std::shared_ptr<ScatteringAngleDistribution> theta_distrib_;
};
+17 -2
View File
@@ -3,8 +3,9 @@
#include <map>
#include <vector>
#include "simulation/coordinates.h"
#include "simulation/particle.h"
// to count numerical particle deletions
enum class DeletionType {
wall,
recombination,
@@ -13,13 +14,23 @@ enum class DeletionType {
cluster_formation
};
// to count physical particle deletion
enum class PhysicalDeletionType {
wall
};
class Coordinate;
class DeletionLogger {
public:
DeletionLogger(std::vector<DeletionType> used_types);
DeletionLogger(std::vector<DeletionType> used_types,
std::vector<PhysicalDeletionType> used_phys_types);
// why a coordinate as a parameter -> not used in implementation
virtual void logDeletion(const Coordinate& coordinate, DeletionType type);
virtual void logDeletion(const particle::Particle& particle,
PhysicalDeletionType type);
std::map<DeletionType, long int> numDeletions() const;
std::map<PhysicalDeletionType, double> numPhysDeletions() const;
void numDeletions(long int new_value, DeletionType type);
long int numDeletions(DeletionType type) const;
@@ -30,6 +41,10 @@ class DeletionLogger {
private:
std::map<DeletionType, long int> num_deletions;
std::map<DeletionType, long int> sync_num_deletions;
std::map<PhysicalDeletionType, double> num_phys_deletions;
std::map<PhysicalDeletionType, double> sync_num_phys_deletions;
};
#endif /* LOGGER_H */
+5
View File
@@ -90,6 +90,11 @@ class Simulation {
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
std::vector<particle::Particle> queue_;
#ifdef debug
double phyLossAtWallIon = 0;
double createdDensity = 0;
#endif
};
#endif /* SIMULATION_H */
@@ -67,6 +67,8 @@ class VelocityDistributionFromDensityField : public VelocityDistribution {
private:
// mass of the species of which the density field is a part of
const double mass_kg_;
double alpha_lower_limit;
double alpha_upper_limit;
std::shared_ptr<DynamicDensityField> density_field_;
+7
View File
@@ -244,6 +244,13 @@ void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
writer.write(pair.second, path_to_deletions + "/ClusterFormation");
}
}
auto physDeletions = logger->numPhysDeletions();
for (auto& pair : physDeletions) {
if (pair.first == PhysicalDeletionType::wall) {
writer.write(pair.second, path_to_deletions + "/Wall(physical)");
}
}
}
void SimulationOutput::writeCurrentCrossings(
+5 -1
View File
@@ -7,6 +7,7 @@ namespace generator {
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
std::vector<DeletionType> used_types;
std::vector<PhysicalDeletionType> used_phys_types;
json_t* type = json_object_by_path(object, {"Type"});
if (json_is_array(type)) {
@@ -24,6 +25,8 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
used_types.push_back(DeletionType::max_time_alive);
} else if (type_alias == "cluster_formation") {
used_types.push_back(DeletionType::cluster_formation);
} else if (type_alias == "wall_physical") {
used_phys_types.push_back(PhysicalDeletionType::wall);
}else {
ERROR("This deletion type " + type_alias + " is not known.");
}
@@ -35,10 +38,11 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
used_types.push_back(DeletionType::max_interactions);
used_types.push_back(DeletionType::max_time_alive);
used_types.push_back(DeletionType::cluster_formation);
used_phys_types.push_back(PhysicalDeletionType::wall);
}
}
return std::make_shared<DeletionLogger>(used_types);
return std::make_shared<DeletionLogger>(used_types, used_phys_types);
}
std::shared_ptr<DeletionLogger> buildDeletionLogger(
Parameter& parameter,
+74 -2
View File
@@ -6,7 +6,8 @@
#include "simulation/kinematic.h"
#include "simulation/scattering_angle_distribution.h"
#include "simulation/velocity_distribution.h"
#include "constants/sim_constants.h"
#include "simulation/density_field.h"
namespace interaction {
ElasticScattering::ElasticScattering(
@@ -48,9 +49,80 @@ InteractionOutput ElasticScattering::performInteraction(
target_->mass_kg(), theta, phi);
particle.velocity(CartesianVector(v_impact_new));
// no Gyrocentrum movement because boris push is used;
return InteractionOutput();
}
double ElasticScattering::drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator) {
CartesianVector particle_velocity = particle.velocity();
target_velocity_ = target_->velocityDistribution()->
rollVelocity(particle.cylinderPosition(),
generator->engine());
// // if no drift velocity is present, then assume target at rest otherwise
// // use the drift velocity
if(target_->driftVelocity()) {
// auto tmp = target_->driftVelocity()->driftVelocity(particle.position());
target_velocity_.add(target_->driftVelocity()->driftVelocity(
particle.cartesianPosition(), particle.cylinderPosition()),
particle.cartesianPosition());
}
// masses are irrelevant for the transformation
const blitz::TinyVector<double, 3> velocity_target_fixed =
kinematic::velocityTargetFixed(particle_velocity.cartesianEntries(),
target_velocity_.cartesianEntries(), 0, 0);
const double relative_velocity = kinematic::norm(velocity_target_fixed);
// std::stringstream out;
// out << "particle "<< particle.specie()->name() <<" velocity: "
// << particle_velocity.cartesianEntries();
// out << "\ntarget "<< target_->name() <<" velocity: "
// << target_velocity_.cartesianEntries();
// out << "\nabsolute relative velocity: " << relative_velocity;
// check if the relative velocity is smaller than an epsilon compared to the larger
// of the two present velocities (to avoid division by 0 if either is 0) probably
// a better version possible
if(relative_velocity/std::max(
kinematic::norm(particle_velocity.cartesianEntries()),
kinematic::norm(target_velocity_.cartesianEntries())
) < SimConstants::compare_epsilon) {
return std::numeric_limits<double>::max();
}
const double energy_eV =
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
UnitConversion::JouleToeV;
// out << "energy collision time: " << energy_eV;
const double crosssection = microscopicCrossSection(energy_eV);
// out << "\ncross section: " << crosssection;
const double density = target_->densityField()->density(particle.cylinderPosition());
// out << "\ninverse mfp: " << crosssection*density << ", sigma: " << crosssection;
// out << ", density: " << density;
const double random_number = generator->rollUniform(0.,1.);
if (random_number == 0) {
return std::numeric_limits<double>::max();
}
const double distance_target_fixed =
- 1./(crosssection * density) * log(random_number);
// out << "\ndistance in target fixed frame: " << distance_target_fixed;
const double time = distance_target_fixed / relative_velocity;
// out << "\ntime before collision: " << time;
// if(density != 0)
// DEBUG_LEVEL_1(out.str());
return time;
}
}; // namespace interaction
+3
View File
@@ -45,6 +45,9 @@ InteractionOutput ElectronIonization::performInteraction(
->driftVelocity(x_impact, particle.cylinderPosition())
.cartesianEntries();
}
v_target *= std::sqrt(target_->mass_kg()/ion_->mass_kg());
blitz::TinyVector<double, 3> v_laboratory = kinematic::velocityTargetFixed(
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(), target_->mass_kg()
);
+9
View File
@@ -145,6 +145,15 @@ void CpuSynchronizer::synchronize(DeletionLogger* logger) {
pair.second = last_sync_num_deletion;
logger->sync_num_deletions[pair.first] = last_sync_num_deletion;
}
for (auto& pair : logger->num_phys_deletions) {
double num_deletion = pair.second;
double last_sync_num_deletion = logger->sync_num_phys_deletions[pair.first];
sumToAll(num_deletion, last_sync_num_deletion);
// last_sync_num_deletion now contains the total number of deletions
// across all cpus -> update the values in the objects
pair.second = last_sync_num_deletion;
logger->sync_num_phys_deletions[pair.first] = last_sync_num_deletion;
}
}
}
+24 -1
View File
@@ -1,10 +1,16 @@
#include "simulation/logger.h"
#include "simulation/coordinates.h"
DeletionLogger::DeletionLogger(std::vector<DeletionType> used_types) {
DeletionLogger::DeletionLogger(std::vector<DeletionType> used_types,
std::vector<PhysicalDeletionType> used_phys_types) {
for (auto& type : used_types) {
num_deletions[type] = 0;
sync_num_deletions[type] = 0;
}
for (auto& type: used_phys_types) {
num_phys_deletions[type] = 0.;
sync_num_phys_deletions[type] = 0.;
}
}
void DeletionLogger::logDeletion(const Coordinate& coordinate,
@@ -14,10 +20,21 @@ void DeletionLogger::logDeletion(const Coordinate& coordinate,
}
}
void DeletionLogger::logDeletion(const particle::Particle& particle,
PhysicalDeletionType type) {
if (num_phys_deletions.count(type) > 0) {
num_phys_deletions.at(type) += particle.weight();
}
}
std::map<DeletionType, long int> DeletionLogger::numDeletions() const {
return num_deletions;
}
std::map<PhysicalDeletionType, double> DeletionLogger::numPhysDeletions() const {
return num_phys_deletions;
}
void DeletionLogger::numDeletions(long int new_value, DeletionType type) {
if (num_deletions.count(type)) {
num_deletions.at(type) = new_value;
@@ -39,4 +56,10 @@ void DeletionLogger::resetDeletionLogger() {
for (auto& pair : sync_num_deletions) {
pair.second = 0;
}
for(auto& pair : num_phys_deletions) {
pair.second = 0;
}
for (auto& pair : sync_num_phys_deletions) {
pair.second = 0;
}
}
+26 -9
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) {
@@ -61,6 +62,7 @@ void BorisMover::move(particle::Particle* particle,
old_mu = kinematic::cosPitchAngle(
B_old, particle->velocity().cartesianEntries(old_position_cart));
}
new_mu = old_mu;
double timestep = 0;
@@ -75,7 +77,7 @@ void BorisMover::move(particle::Particle* particle,
bool changed_energy_bin = false;
bool left_simulation_domain = false;
bool changed_mu_bin = false;
bool died_in_bin = false;
bool died_in_bin = particle->specie()->terminator()->reachedMaxTimeAlive(particle);
while (
!(changed_position_bin || changed_energy_bin || left_simulation_domain ||
@@ -110,7 +112,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());
@@ -130,6 +131,19 @@ void BorisMover::move(particle::Particle* particle,
changed_energy_bin =
particle->specie()->dynamicDensityField()->changedEnergyBin(
old_kinetic_energy, particle->kineticEnergy_eV());
// #ifdef debug
// if(changed_energy_bin &&
// particle->specie()->type() == species::ImplementedSpecies::Tplus) {
// std::stringstream out;
// out << "Changed energy bin from: " << particle->specie()->dynamicDensityField()
// ->energyBinning()->bin(old_kinetic_energy);
// out << " (" << old_kinetic_energy << ") to: ";
// out << particle->specie()->dynamicDensityField()->energyBinning()
// ->bin(particle->kineticEnergy_eV());
// out << " (" << particle->kineticEnergy_eV() << ")\n";
// DEBUG(out.str());
// }
// #endif
left_simulation_domain =
particle->specie()->terminator()->leftSimulationDomain(particle);
@@ -147,12 +161,15 @@ 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) {
// && (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(
old_position_cyl, old_kinetic_energy, old_mu, particle->weight());
#ifdef debug
particle->cylinderPosition(), particle->kineticEnergy_eV(), new_mu,
particle->weight());
particle->deposited();
#endif
}
// particle->resetTimeInBin();
particle->specie()->currentCollector()->collect(particle, old_position_cyl);
@@ -232,10 +249,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 +260,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));
+1 -1
View File
@@ -40,7 +40,7 @@ void RandomIndex::reshuffle(std::mt19937* engine) {
}
bool RandomIndex::visited_all() {
return current_index_in_vector_ == total_bin_number_ - 1;
return current_index_in_vector_ == total_bin_number_;
}
// return the next index in the shuffled index vector. Returns the last
+61
View File
@@ -270,7 +270,21 @@ void Simulation::start() {
SimulationTimer::eventStartPoint("Reset");
if(reset) {
SIM_INFO("Do resets and increase the timestep for timeresolution.");
#ifdef debug
std::stringstream out;
out << "Ions (T+) lost at wall (physical value): " << phyLossAtWallIon;
phyLossAtWallIon = 0.;
double total_tp = 0;
double total_tp_sync = 0.;
#endif
for(auto& pair : tracked_species_) {
#ifdef debug
if(pair.second->type() == species::ImplementedSpecies::Tplus) {
total_tp = blitz::sum(pair.second->dynamicDensityField()->timeInBinArray());
total_tp_sync = blitz::sum(
pair.second->densityForDrawing()->timeInBinArray());
}
#endif
pair.second->dynamicDensityField()->resetDynamicDensityField();
pair.second->currentCollector()->resetCurrentCollector();
@@ -280,6 +294,17 @@ void Simulation::start() {
// the density from which new particles are drawn is only updated after a timestep
pair.second->positionDistributionFromDensity()->setMaximumDensity();
}
#ifdef debug
out << "\n\ttotal number in tp: " << total_tp;
out << "\n\tdiff to expected: " << (timesteps+1)*0.02 - total_tp;
out << "\n\ttotal number created: " << createdDensity;
out << "\n\tdiff to expected: " << (timesteps)*0.02/MpiCommunication::mpiSize()
- createdDensity;
out << "\n\ttotal number in density drawing field: " << total_tp_sync;
out << "\n\tdiff to in density: " << total_tp_sync - total_tp;
DEBUG(out.str());
createdDensity = 0;
#endif
leftover_events_time_resolution = beta_decay_events;
leftover_density_events = particles_per_bin;
@@ -471,6 +496,8 @@ void Simulation::processUntilTermination(
}
if (particle.specie()->terminator()->reachedMaxTimeAlive(
&particle) &&
!particle.specie()->terminator()->leftSimulationDomain(
&particle)) {
#ifdef debug_level3
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
@@ -503,8 +530,13 @@ void Simulation::processUntilTermination(
if (particle.specie()->deletionLogger()) {
particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(),
DeletionType::wall);
particle.specie()->deletionLogger()->logDeletion(particle,
PhysicalDeletionType::wall);
}
#ifdef debug
if(particle.specie()->type() == species::ImplementedSpecies::Tplus) {
phyLossAtWallIon += particle.weight();
}
if(particle.wasDeposited()) {
std::stringstream out;
out << "particle " << particle.specie()->name();
@@ -537,6 +569,21 @@ void Simulation::processUntilTermination(
// macroscopic_cross_sections_m);
SimulationTimer::eventStopPoint(std::string("Interaction"));
// particle has reached time resolution, but was not deposited due to
// the interaction taking place at the same time.
// If the particle is not destroyed in the interaction put it into the mover
// 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");
// }
// }
particle.increaseInteractionCounter();
for (auto& new_particle : output.newParticles()) {
@@ -698,6 +745,20 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
injector_->drawNewParticleFromDensityField(random->engine(),
pair.second, new_particles, magnetic_field_,
weight_factor, injection_time);
#ifdef debug
if(!new_particles.empty()) {
if(new_particles.back().specie()->type() == species::ImplementedSpecies::Tplus
&& pair.second->type() == species::ImplementedSpecies::Tplus) {
// if(createdDensity + new_particles.back().weight() == createdDensity){
// std::stringstream out;
// out << "catastrophic cancellation!\ncreated density: " << createdDensity;
// out << "\n\tweight: " << new_particles.back().weight();
// DEBUG(out.str());
// }
createdDensity += new_particles.back().weight();
}
}
#endif
}
// if species is not done tmp_done && ... = false
+107 -2
View File
@@ -37,6 +37,10 @@ VelocityDistributionFromDensityField::VelocityDistributionFromDensityField(
pitchAngleBinBorders_(density_field->pitchAngleBinning()->binBorders()),
theta_distribution_(std::uniform_real_distribution<double>(0.,1.)),
mass_kg_(mass_kg) {
double maxAbsExponent = std::max(std::abs(std::log10(energyBinBorders_.front())),
std::abs(std::log10(energyBinBorders_.back())));
alpha_lower_limit = -300/maxAbsExponent;
alpha_upper_limit = 300/maxAbsExponent;
// necessary to include the underflow bin in the energy domain
energyBinBorders_.insert(energyBinBorders_.begin(), 0);
}
@@ -210,8 +214,78 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
const double pitch_angle_step = pitchAngleBinBorders_[index(3) + 1]
- pitchAngleBinBorders_[index(3)];
double energy_eV = energyBinBorders_[index(4) + 1]
+ theta_distribution_(*engine)*energy_step;
// double energy_eV = energyBinBorders_[index(4) + 1]
// + theta_distribution_(*engine)*energy_step;
double energy_eV;
double alpha = 1;
if(index(4) == -1) {
// linear drawing inbetween E=0, N(0)=0 to E=Er and N(Er)=Nr
energy_eV = energyBinBorders_[index(4) + 2]*
std::sqrt(theta_distribution_(*engine));
// #ifdef debug
// std::stringstream out;
// out << "underflow bin.\n\tdrawn energy: " << energy_eV;
// out << "\n\tenergy value left: " << energyBinBorders_[index(4)+1];
// out << "\n\tenergy value right: " << energyBinBorders_[index(4)+2];
// DEBUG(out.str());
// #endif
} else {
double nl = density_field_->particleNumber(index);
double nr = density_field_->particleNumber(index +
blitz::TinyVector<int, 5>(0,0,0,0,1));
// double alpha;
// no reason for specific values, just to avoid these cases
if(nl == 0) {
alpha = 1;
} else if (nr == 0) {
alpha = -1;
} else if (nr == 0 && nl == 0) {
alpha = 0;
} else {
alpha = std::log(nr/nl)/std::log(energyBinBorders_[index(4) + 2]/
energyBinBorders_[index(4) + 1]);
}
// alpha = std::abs(alpha) > 100 ?(alpha/std::abs(alpha))*100 : alpha;
alpha = std::min(std::max(alpha, alpha_lower_limit), alpha_upper_limit);
if(alpha == -1) {
energy_eV = std::pow(energyBinBorders_[index(4) + 2]
/ energyBinBorders_[index(4) + 1], theta_distribution_(*engine)) *
energyBinBorders_[index(4) + 1];
// energy_eV = (std::pow(2, theta_distribution_(*engine)) - 1)*energy_step
// + energyBinBorders_[index(4) + 1];
// #ifdef debug
// std::stringstream out;
// out << "alpha = -1\n\tdrawn energy: " << energy_eV;
// out << "\n\tenergy value left: " << energyBinBorders_[index(4)+1];
// out << "\n\tenergy value right: " << energyBinBorders_[index(4)+2];
// DEBUG(out.str());
// #endif
} else {
double xl_alphap1 = std::pow(energyBinBorders_[index(4) + 1], alpha + 1);
double xr_alphap1 = std::pow(energyBinBorders_[index(4) + 2], alpha + 1);
energy_eV = std::pow((xr_alphap1 - xl_alphap1)*
theta_distribution_(*engine) + xl_alphap1, 1/(alpha + 1));
// #ifdef debug
// if(std::abs(alpha) > 100) {
// std::stringstream out;
// out << "alpha: " << alpha;
// out << "\nxl_alphap1: " << xl_alphap1;
// out << "\nxr_alphap1: " << xr_alphap1;
// DEBUG(out.str());
// }
// #endif
// #ifdef debug
// std::stringstream out;
// out << "alpha = "<< alpha << "\n\tdrawn energy: " << energy_eV;
// out << "\n\tenergy value left: " << energyBinBorders_[index(4)+1];
// out << "\n\tenergy value right: " << energyBinBorders_[index(4)+2];
// DEBUG(out.str());
// #endif
}
}
double pitchAngle = pitchAngleBinBorders_[index(3)]
+ theta_distribution_(*engine)*pitch_angle_step;
@@ -221,6 +295,15 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
std::stringstream out;
out << "pitchAngle: " << pitchAngle;
out << "\nenergy value: " << energy_eV;
out << "\nalpha: " << alpha;
out << "\ncurrent index: " << index;
out << "\nNl: " << density_field_->particleNumber(index);
out << "\nNl: " << density_field_->particleNumber(index +
blitz::TinyVector<int, 5>(0,0,0,0,1));
out << "\nEl: " << energyBinBorders_[index(4) + 1];
out << "\nEr: " << energyBinBorders_[index(4) + 2];
out << "\nEl^(alpha+1): " << std::pow(energyBinBorders_[index(4) + 1], alpha + 1);
out << "\nEr^(alpha+1): " << std::pow(energyBinBorders_[index(4) + 2], alpha + 1);
// out << "\nenergy values: " << energyValues;
// out << "\npitch angle values: " << pitchAngleValues;
out << "\nenergy bin borders: [ ";
@@ -231,6 +314,28 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
ERROR(out.str());
}
// if(std::isinf(energy_eV)) {
// std::stringstream out;
// out << "pitchAngle: " << pitchAngle;
// out << "\nenergy value: " << energy_eV;
// out << "\ncurrent index: " << index;
// out << "\nalpha: " << alpha;
// out << "\nNl: " << density_field_->particleNumber(index);
// out << "\nNl: " << density_field_->particleNumber(index +
// blitz::TinyVector<int, 5>(0,0,0,0,1));
// out << "\nEl: " << energyBinBorders_[index(4) + 1];
// out << "\nEr: " << energyBinBorders_[index(4) + 2];
// // out << "\nenergy values: " << energyValues;
// // out << "\npitch angle values: " << pitchAngleValues;
// out << "\nenergy bin borders: [ ";
// for(auto element : energyBinBorders_) {
// out << element << " ";
// }
// out << "]";
// ERROR(out.str());
// }
#endif
#ifdef debug_level2