From 0902d3d7acf20bdcb1db8409158bc65e610e0e57 Mon Sep 17 00:00:00 2001 From: csendlinger Date: Wed, 18 Dec 2024 15:07:19 +0100 Subject: [PATCH] Corrections in the comments; Small code fixes --- .../generators/velocity_distribution_function_generator.h | 2 +- include/simulation/jansson_additionals.h | 6 +++--- src/generators/velocity_distribution_generator.cpp | 6 +++++- src/simulation/mover.cpp | 5 +++-- src/simulation/simulation.cpp | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/generators/velocity_distribution_function_generator.h b/include/generators/velocity_distribution_function_generator.h index ed38b24..d73c488 100755 --- a/include/generators/velocity_distribution_function_generator.h +++ b/include/generators/velocity_distribution_function_generator.h @@ -19,7 +19,7 @@ namespace generator { // if "DirectedDistribution" is specified: // - has to include a json-object "EnergyDistributionFunction" as defined in "generators/energy_distribtion_function_generator.h" // - has to include a json-object "Mass" as defined in "generators/mass_generator.h" -// - has to include a json-array of size 3, defining the direction in cartesian coordinates (x,y,z) +// - has to include a json-object "Direction", including a json-array "vector" containing the direction in cartesian coordinates // - returns a DirectedDistribution object (see simulation/energy_distribtion.h) // // (example in "simulation_config/velocity_distribution_function_examples.json") diff --git a/include/simulation/jansson_additionals.h b/include/simulation/jansson_additionals.h index 4545d87..9d6ded7 100755 --- a/include/simulation/jansson_additionals.h +++ b/include/simulation/jansson_additionals.h @@ -63,9 +63,9 @@ inline bool json_bool(json_t* object, bool default_value = false) { } } -// returns a blitz::TinyVector with the values from a json_t pointer which points to -// a json-array; if the json_t pointer is not an array or the array has a different size than -// the specified template parameter s an error is thrown and the execution of the program terminated +// return the json-array "vector" in the given json-object object as a blitz::TinyVector +// if the "vector" json-array does not exist or does not contain the same number of elements as +// specified in the template parameter s an error is thrown template blitz::TinyVector json_blitz_vector(json_t* object) { blitz::TinyVector vector; diff --git a/src/generators/velocity_distribution_generator.cpp b/src/generators/velocity_distribution_generator.cpp index e731296..c1941e8 100755 --- a/src/generators/velocity_distribution_generator.cpp +++ b/src/generators/velocity_distribution_generator.cpp @@ -24,7 +24,11 @@ std::shared_ptr buildVelocityDistribution( DEBUG_LEVEL_2("Creating velocity distribution: null"); return nullptr; } else { - ERROR("This velocity distribution is not implemented."); + std::string path = ""; + for(auto element : path_to_distribution) { + path += element; + } + ERROR("This velocity distribution is not implemented: " + path); return nullptr; } } diff --git a/src/simulation/mover.cpp b/src/simulation/mover.cpp index 73b69de..7f48244 100755 --- a/src/simulation/mover.cpp +++ b/src/simulation/mover.cpp @@ -216,8 +216,9 @@ void DriftMover::move(particle::Particle* particle, const blitz::TinyVector dv_electric = timestep * particle->charge_C() * E_parallel / particle->mass_kg(); -// check if the particle has a gyroradius > 0 - if (v_perp_norm > SimConstants::compare_epsilon) { +// if the angle between v and B < epsilon, consider the movement as +// if it had a gyroradius of 0 + if (v_perp_norm/v_parallel_norm > SimConstants::compare_epsilon) { const double gyro_radius = particle->mass_kg() * v_perp_norm / (B_norm * particle->charge_C()); diff --git a/src/simulation/simulation.cpp b/src/simulation/simulation.cpp index a78019d..4468f7c 100755 --- a/src/simulation/simulation.cpp +++ b/src/simulation/simulation.cpp @@ -296,7 +296,7 @@ double Simulation::meanFreePath(particle::Particle& particle, if (rnd_number <= 0) { return std::numeric_limits::max(); } else { - return 1. / total_macroscopic_cross_section_m * log(1. / rnd_number); + return - 1. / total_macroscopic_cross_section_m * log(rnd_number); } } }