From 2fccef7132ea5be7ca395ffee7e2eae39185ae14 Mon Sep 17 00:00:00 2001 From: Christian Sendlinger Date: Fri, 15 Mar 2024 15:49:40 +0100 Subject: [PATCH] Minor changes in debug output, added information to error messages --- src/generators/binning_generator.cpp | 2 +- src/generators/drift_velocity_generator.cpp | 2 +- src/generators/electric_field_generator.cpp | 4 ++-- .../energy_distribution_function_generator.cpp | 2 +- src/generators/injector_generator.cpp | 4 ++-- src/generators/interaction_generator.cpp | 13 +++++++------ src/generators/logger_generator.cpp | 2 +- src/generators/mass_generator.cpp | 2 +- src/generators/reflector_generator.cpp | 2 +- src/generators/scalar_field_generator.cpp | 2 +- src/generators/simulation_output_generator.cpp | 11 +++++++---- src/generators/species_generator.cpp | 2 +- src/interactions/excitation.cpp | 2 +- src/interactions/recombination.cpp | 5 +++-- src/poisson_solver/poisson_solver.cpp | 9 ++++++--- src/simulation/cpu_synchronizer.cpp | 2 +- src/simulation/energy_binning.cpp | 1 + src/simulation/simulation.cpp | 2 +- src/simulation/unit_converter.cpp | 4 ++-- 19 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/generators/binning_generator.cpp b/src/generators/binning_generator.cpp index 240b8b4..928da9d 100755 --- a/src/generators/binning_generator.cpp +++ b/src/generators/binning_generator.cpp @@ -85,7 +85,7 @@ EnergyBinning buildEnergyBinning(json_t* object) { ASSERT_POSITIVE(&min_energy, "Min Energy must be positive"); double max_energy = json_read_energy(json_object_by_path(object, {"MaxEnergy"}), "eV"); - ASSERT_POSITIVE(&max_energy, "Min Energy must be positive"); + ASSERT_POSITIVE(&max_energy, "Max Energy must be positive"); DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins)); DEBUG_LEVEL_3("with min energy: " + std::to_string(min_energy)); diff --git a/src/generators/drift_velocity_generator.cpp b/src/generators/drift_velocity_generator.cpp index 200ae95..9937448 100755 --- a/src/generators/drift_velocity_generator.cpp +++ b/src/generators/drift_velocity_generator.cpp @@ -29,7 +29,7 @@ std::shared_ptr buildDriftVelocityIncludingRedirection( std::stringstream cpath; if (parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) { - DEBUG_LEVEL_2("Creating Drift velocity: CreateSameAs."); + DEBUG_LEVEL_2("Creating drift velocity: CreateSameAs."); json_path path_to_same = json_path_get(parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"CreateSameAs"}))); std::stringstream path; diff --git a/src/generators/electric_field_generator.cpp b/src/generators/electric_field_generator.cpp index cea6cc0..143ba33 100755 --- a/src/generators/electric_field_generator.cpp +++ b/src/generators/electric_field_generator.cpp @@ -15,7 +15,7 @@ std::shared_ptr electricField(json_t* object) { background = buildVectorField( json_object_by_path(object, {"Background", "VectorField"})); } else { - ERROR("Can not find background for electric field"); + ERROR("Can not find background for electric field."); } if (json_object_by_path(object, {"Dynamic"})) { @@ -23,7 +23,7 @@ std::shared_ptr electricField(json_t* object) { dynamic = buildVectorField( json_object_by_path(object, {"Dynamic", "VectorField"})); } else { - ERROR("Can not find dynamic for electric field"); + ERROR("Can not find dynamic for electric field."); } return std::shared_ptr(new ElectricField(background, dynamic)); diff --git a/src/generators/energy_distribution_function_generator.cpp b/src/generators/energy_distribution_function_generator.cpp index 64c27b7..05e5059 100755 --- a/src/generators/energy_distribution_function_generator.cpp +++ b/src/generators/energy_distribution_function_generator.cpp @@ -29,7 +29,7 @@ std::shared_ptr buildEnergyDistributionFunction( return std::shared_ptr( new Constant(constant_eV)); } - ERROR("This Energy Distribution is not implemented"); + ERROR("This Energy Distribution is not implemented."); return nullptr; } diff --git a/src/generators/injector_generator.cpp b/src/generators/injector_generator.cpp index 90a8a7d..2f8d5d9 100755 --- a/src/generators/injector_generator.cpp +++ b/src/generators/injector_generator.cpp @@ -37,7 +37,7 @@ std::shared_ptr buildInjector( } // EventPositionDistribution - DEBUG_LEVEL_2("Creating event distribution"); + DEBUG_LEVEL_2("Creating event distribution."); std::shared_ptr field = buildScalarField(json_object_by_path( object, {"EventPositionDistribution", "ScalarField"})); @@ -76,7 +76,7 @@ std::shared_ptr buildInjector( position_limit_phi, position_limit_z)); // MotherDriftVelocity - DEBUG_LEVEL_2("Creating mother drift velocity"); + DEBUG_LEVEL_2("Creating mother drift velocity."); std::shared_ptr drift_velocity = buildDriftVelocity( parameter, json_path_append(path_to_injector, {"MotherDriftVelocity"})); diff --git a/src/generators/interaction_generator.cpp b/src/generators/interaction_generator.cpp index 3606b81..0fe0af3 100755 --- a/src/generators/interaction_generator.cpp +++ b/src/generators/interaction_generator.cpp @@ -43,7 +43,7 @@ void addInteractions( std::string target_name = json_string(json_object_by_path(value, {"Target"})); - DEBUG_LEVEL_3("with target" + target_name); + DEBUG_LEVEL_3("with target " + target_name); std::shared_ptr target = findTarget(target_name, tracked_species, background_species); @@ -180,7 +180,7 @@ void addInteractions( ionization_energy_distribution, scattering_angle_distribution, ionization_energy_eV)); } else { - ERROR("This ionization model is not implemented."); + ERROR("This ionization model is not implemented: " + ionization_model); } } else if (type == "Excitation") { DEBUG_LEVEL_2("Adding interactions: Excitation"); @@ -228,6 +228,7 @@ void addInteractions( specie->addInteraction(std::shared_ptr( new interaction::ChargeExchange(cross_section, target))); } else if (type == "Recombination") { + DEBUG_LEVEL_2("Adding interactions: Recombination"); std::string target_name = json_string(json_object_by_path(value, {"Target"})); std::shared_ptr target = @@ -305,7 +306,7 @@ std::function buildTotalCrossSection(json_t* object) { json_object_by_path(object, {"ExcitationFunction", "ExcitationState"})); return buildExcitationCrossSection(excitation_state); } else { - ERROR("This type of cross section is not implemented"); + ERROR("This type of cross section is not implemented."); return nullptr; } } @@ -443,7 +444,7 @@ std::function buildExcitationCrossSection( } else { ERROR( "This type of cross section ExcitationState is not implemented in " - "buildExcitationCrossSection."); + "buildExcitationCrossSection: " + excitation_state); return nullptr; } } @@ -513,7 +514,7 @@ std::shared_ptr findTarget( } else if (tracked_species.count(target_name)) { return tracked_species.at(target_name); } else { - ERROR("The specified target does not exist."); + ERROR("The specified target " + target_name + " does not exist."); return nullptr; } }; @@ -525,7 +526,7 @@ std::shared_ptr findTracked( if (tracked_species.count(target_name)) { return tracked_species.at(target_name); } else { - ERROR("The specified target does not exist."); + ERROR("The specified target " + target_name + " does not exist."); return nullptr; } } diff --git a/src/generators/logger_generator.cpp b/src/generators/logger_generator.cpp index b994744..c480074 100755 --- a/src/generators/logger_generator.cpp +++ b/src/generators/logger_generator.cpp @@ -25,7 +25,7 @@ std::shared_ptr buildDeletionLogger(json_t* object) { } else if (type_alias == "cluster_formation") { used_types.push_back(DeletionType::cluster_formation); } else { - ERROR("This deletion type is not known"); + ERROR("This deletion type " + type_alias + " is not known."); } } } else { diff --git a/src/generators/mass_generator.cpp b/src/generators/mass_generator.cpp index 2bac8db..00873da 100755 --- a/src/generators/mass_generator.cpp +++ b/src/generators/mass_generator.cpp @@ -27,7 +27,7 @@ double buildMass(json_t* object) { if (SpeciesAlias::isAlias(name)) { return SpeciesMasses::mass(SpeciesAlias::alias(name)); } else { - ERROR("This specie type is not known."); + ERROR("The specie type " + name + " is not known."); return 0.; } } else if (json_object_by_path(object, {"value"})) { diff --git a/src/generators/reflector_generator.cpp b/src/generators/reflector_generator.cpp index 3cc62d5..e1720ff 100755 --- a/src/generators/reflector_generator.cpp +++ b/src/generators/reflector_generator.cpp @@ -19,7 +19,7 @@ std::shared_ptr buildReflector(Parameter& parameter, DEBUG_LEVEL_2("Create reflector: NoReflector"); return std::shared_ptr(new NoReflector()); } else { - ERROR("This reflector is not implemented"); + ERROR("This reflector is not implemented."); return nullptr; } } diff --git a/src/generators/scalar_field_generator.cpp b/src/generators/scalar_field_generator.cpp index 3f71ba7..f5c8630 100755 --- a/src/generators/scalar_field_generator.cpp +++ b/src/generators/scalar_field_generator.cpp @@ -12,7 +12,7 @@ std::shared_ptr buildScalarField(json_t* object) { json_object_by_path(object, {"ScalarFieldFunctionInZ", "zFunction"})); return std::shared_ptr(new ScalarFieldFunctionInZ(z_function)); } else { - ERROR("This scalar field is not implemented"); + ERROR("This scalar field is not implemented."); return nullptr; } return nullptr; diff --git a/src/generators/simulation_output_generator.cpp b/src/generators/simulation_output_generator.cpp index 5f5c975..54a10fa 100755 --- a/src/generators/simulation_output_generator.cpp +++ b/src/generators/simulation_output_generator.cpp @@ -47,7 +47,8 @@ std::shared_ptr buildSimulationOutput( output->addDensityFieldOutput(task); } } else { - ERROR("This species can not be outputted."); + ERROR("DensityFields: Species to be outputted have to be " + "given as an array or using the keyword \"all\"."); } } } @@ -84,7 +85,8 @@ std::shared_ptr buildSimulationOutput( output->addCurrentBorderOutput(task); } } else { - ERROR("This species can not be outputted."); + ERROR("CurrentBorders: Species to be outputted have to be " + "given as an array or using the keyword \"all\"."); } } } @@ -124,7 +126,8 @@ std::shared_ptr buildSimulationOutput( output->addDeletionLoggerOutput(task); } } else { - ERROR("This species can not be outputted."); + ERROR("DeletionLogger: Species to be outputted have to be " + "given as an array or using the keyword \"all\"."); } } } @@ -140,7 +143,7 @@ std::shared_ptr buildSimulationOutput( intervall = 1; } ASSERT_POSITIVE(&intervall, - "The intervall for the potential must be positive"); + "The intervall for the poisson solver output must be positive"); bool overwrite_last = json_bool( json_object_by_path(object, {"PoissonSolver", "OverwriteLast"})); diff --git a/src/generators/species_generator.cpp b/src/generators/species_generator.cpp index 1d1f969..e983c86 100755 --- a/src/generators/species_generator.cpp +++ b/src/generators/species_generator.cpp @@ -211,7 +211,7 @@ void SpeciesBuilder::fillMass() { } void SpeciesBuilder::fillCharge() { - DEBUG_LEVEL_2("Fill charges"); + DEBUG_LEVEL_2("Fill charges."); for (auto& b : background_species_info) { b.second.charge_C = SpeciesCharges::charge(b.second.type); } diff --git a/src/interactions/excitation.cpp b/src/interactions/excitation.cpp index 77a82d2..a0c8123 100755 --- a/src/interactions/excitation.cpp +++ b/src/interactions/excitation.cpp @@ -13,7 +13,7 @@ Excitation::Excitation(std::function cross_section, : Interaction(cross_section, target), excitation_energy_eV_(excitation_energy_eV) { ASSERT_POSITIVE(&excitation_energy_eV_, - "The exitationenergy must be positive."); + "The exitation energy must be positive."); } InteractionOutput Excitation::performInteraction(particle::Particle& particle, diff --git a/src/interactions/recombination.cpp b/src/interactions/recombination.cpp index bf16ad3..0734c68 100755 --- a/src/interactions/recombination.cpp +++ b/src/interactions/recombination.cpp @@ -65,8 +65,9 @@ InteractionOutput Recombination::performInteraction( macroscopic_bin_cross_sections_m.end(), 0.0); if(total_macroscopic_cross_section_m <= 0.) { - ERROR("Total cross section is " + std::to_string(total_macroscopic_cross_section_m) + - ". But recombination was chosen."); + ERROR("Total cross section is " + + std::to_string(total_macroscopic_cross_section_m) + + ". But recombination was chosen."); } std::discrete_distribution energy_bin_decider( diff --git a/src/poisson_solver/poisson_solver.cpp b/src/poisson_solver/poisson_solver.cpp index b6eae08..0addade 100755 --- a/src/poisson_solver/poisson_solver.cpp +++ b/src/poisson_solver/poisson_solver.cpp @@ -54,6 +54,7 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary, potential_(i,j,k) = {BoundaryType::no_boundary, 0.}; break; default: + // include position in output ERROR("Something went terribly wrong. Position is nowhere."); break; } @@ -246,9 +247,11 @@ blitz::Array PoissonSolver::potential() { return potentialValues; } -blitz::Array PoissonSolver::interpolateDensityToPotentialGrid(const blitz::Array density) { - if((potential_.extent(0) - 1 != density.extent(0)) || (potential_.extent(1) != density.extent(1)) - || (potential_.extent(2) - 1 != density.extent(2))) { +blitz::Array PoissonSolver::interpolateDensityToPotentialGrid( + const blitz::Array density) { + if((potential_.extent(0) - 1 != density.extent(0)) || + (potential_.extent(1) != density.extent(1)) || + (potential_.extent(2) - 1 != density.extent(2))) { ERROR("Extent of the cylinder binning and the provided chargedensity do not match."); } //probably include a check for the lowerbound of the provided chargedensity diff --git a/src/simulation/cpu_synchronizer.cpp b/src/simulation/cpu_synchronizer.cpp index a00bdc5..17bd45a 100755 --- a/src/simulation/cpu_synchronizer.cpp +++ b/src/simulation/cpu_synchronizer.cpp @@ -55,7 +55,7 @@ void CpuSynchronizer::sumToAll(long int& value, long int& last_sync_value) { void CpuSynchronizer::synchronize(Timer* timer, Timer* last_sync_timer) { if(timer == last_sync_timer) { - ERROR("Synchronization of timers cannot work, point to same object"); + ERROR("Synchronization of timers cannot work, point to same object."); } double time_s = timer->time(); double last_sync_time_s = last_sync_timer->time(); diff --git a/src/simulation/energy_binning.cpp b/src/simulation/energy_binning.cpp index d3c48ec..29a523e 100755 --- a/src/simulation/energy_binning.cpp +++ b/src/simulation/energy_binning.cpp @@ -2,6 +2,7 @@ #include #include +// probably rename to indicate what type of borders are created std::vector generateBinBorders(double bin_min, double bin_max, int num_bins) { diff --git a/src/simulation/simulation.cpp b/src/simulation/simulation.cpp index 7e2e9d2..45bae53 100755 --- a/src/simulation/simulation.cpp +++ b/src/simulation/simulation.cpp @@ -337,7 +337,7 @@ blitz::Array Simulation::chargedensity() { std::shared_ptr firstTracked = tracked_species_.begin()->second; DEBUG_LEVEL_3("shared pointer extracted, key: " + tracked_species_.begin()->first); if(!firstTracked) - ERROR("extracted pointer is null"); + ERROR("Extracted pointer is null."); blitz::Array init = firstTracked->dynamicDensityField()->densityArray(); blitz::Array chargeden(init.lbound(), init.extent()); chargeden = 0.; diff --git a/src/simulation/unit_converter.cpp b/src/simulation/unit_converter.cpp index ff202a0..7b1d5ea 100755 --- a/src/simulation/unit_converter.cpp +++ b/src/simulation/unit_converter.cpp @@ -12,7 +12,7 @@ double lengthPrefactor(const std::string& unit) { } else if (unit == "mm") { return 1E-3; } else { - ERROR("I dont know this length unit."); + ERROR("I dont know this length unit: " + unit); return 0; } } @@ -32,7 +32,7 @@ double energyPrefactor(const std::string& unit) { } else if (unit == "J") { return 1 / SI::e; } else { - ERROR("I dont know this energy unit."); + ERROR("I dont know this energy unit: " + unit); return 0; } }