diff --git a/include/simulation/logger.h b/include/simulation/logger.h index 0f7e708..0de152d 100755 --- a/include/simulation/logger.h +++ b/include/simulation/logger.h @@ -10,7 +10,12 @@ enum class DeletionType { recombination, max_interactions, max_time_alive, - cluster_formation + cluster_formation, + creation_beta, + creation_density, + creation_interaction, + creation_above_2keV, + loss_above_2keV }; class DeletionLogger { diff --git a/src/IO/hdf5_writer.cpp b/src/IO/hdf5_writer.cpp index dda2926..d2142f0 100755 --- a/src/IO/hdf5_writer.cpp +++ b/src/IO/hdf5_writer.cpp @@ -220,7 +220,7 @@ void Hdf5Writer::write(const blitz::Array& data, std::string path) { // turn error report back onby hdf5 because of check H5Dopen2 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, filespace, H5P_DEFAULT, + H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, filespace, H5P_DEFAULT, data.data()); H5Dclose(dataset); diff --git a/src/IO/simulation_output.cpp b/src/IO/simulation_output.cpp index 19f4b99..884f45b 100755 --- a/src/IO/simulation_output.cpp +++ b/src/IO/simulation_output.cpp @@ -242,6 +242,16 @@ void SimulationOutput::writeNumDeletions(DeletionLogger* logger, writer.write(pair.second, path_to_deletions + "/MaxTimeAlive"); } else if (pair.first == DeletionType::cluster_formation) { writer.write(pair.second, path_to_deletions + "/ClusterFormation"); + } else if (pair.first == DeletionType::creation_beta) { + writer.write(pair.second, path_to_deletions + "/CreationBeta"); + } else if (pair.first == DeletionType::creation_density) { + writer.write(pair.second, path_to_deletions + "/CreationDensity"); + } else if (pair.first == DeletionType::creation_interaction) { + writer.write(pair.second, path_to_deletions + "/CreationInteraction"); + } else if (pair.first == DeletionType::creation_above_2keV) { + writer.write(pair.second, path_to_deletions + "/CreationAbove2keV"); + } else if (pair.first == DeletionType::loss_above_2keV) { + writer.write(pair.second, path_to_deletions + "/LossAbove2keV"); } } } diff --git a/src/generators/logger_generator.cpp b/src/generators/logger_generator.cpp index 2280a6a..84499e7 100755 --- a/src/generators/logger_generator.cpp +++ b/src/generators/logger_generator.cpp @@ -35,6 +35,13 @@ std::shared_ptr 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); +// Debugging types, not yet able to be specified on their own, just +// in when "all" is used + used_types.push_back(DeletionType::creation_beta); + used_types.push_back(DeletionType::creation_density); + used_types.push_back(DeletionType::creation_interaction); + used_types.push_back(DeletionType::creation_above_2keV); + used_types.push_back(DeletionType::loss_above_2keV); } } diff --git a/src/interactions/cluster_formation.cpp b/src/interactions/cluster_formation.cpp index b99d7e8..60d3b36 100755 --- a/src/interactions/cluster_formation.cpp +++ b/src/interactions/cluster_formation.cpp @@ -46,6 +46,8 @@ InteractionOutput ClusterFormation::performInteraction( x_impact, DeletionType::cluster_formation); } + product_->deletionLogger()->logDeletion(x_impact, DeletionType::creation_interaction); + return output; } diff --git a/src/interactions/ionization.cpp b/src/interactions/ionization.cpp index 3d80642..25d449d 100755 --- a/src/interactions/ionization.cpp +++ b/src/interactions/ionization.cpp @@ -8,6 +8,7 @@ #include "simulation/kinematic.h" #include "simulation/particle.h" #include "simulation/velocity_distribution.h" +#include "simulation/logger.h" namespace interaction { @@ -117,6 +118,10 @@ InteractionOutput ElectronIonization::performInteraction( output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target), time_birth, weight_parent)); + ion_->deletionLogger()->logDeletion(x_impact, DeletionType::creation_interaction); + electron_->deletionLogger() + ->logDeletion(x_impact, DeletionType::creation_interaction); + return output; } diff --git a/src/simulation/injector.cpp b/src/simulation/injector.cpp index 2bc4531..8211cc6 100755 --- a/src/simulation/injector.cpp +++ b/src/simulation/injector.cpp @@ -10,6 +10,8 @@ #include "simulation/velocity_distribution.h" #include "simulation/electromagnetic_field.h" #include "simulation/random_numbers.h" +#include "simulation/logger.h" +#include "constants/physical_constants.h" #include Injector::Injector( @@ -48,6 +50,12 @@ particle::Particle Injector::rollNewParticle( DEBUG_LEVEL_3(out.str()); #endif + created_specie->deletionLogger()->logDeletion(position, DeletionType::creation_beta); + if(kinematic::kineticEnergy(velocity, created_specie->mass_kg()) + *UnitConversion::JouleToeV > 2000) { + created_specie->deletionLogger()->logDeletion(position, DeletionType::creation_above_2keV); + } + return particle::Particle(created_specie, position, CartesianVector(velocity), time_birth, weight); } @@ -135,7 +143,11 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine, particle::Particle drawn_particle(specie, position, velocity, injection_time, weight_factor*num_part_in_bin); - +// debugging + specie->deletionLogger()->logDeletion(position, DeletionType::creation_density); + if(drawn_particle.kineticEnergy_eV() > 2000) { + specie->deletionLogger()->logDeletion(position, DeletionType::creation_above_2keV); + } queue.push_back(drawn_particle); } diff --git a/src/simulation/random_numbers.cpp b/src/simulation/random_numbers.cpp index e8f221c..bf3a7e8 100755 --- a/src/simulation/random_numbers.cpp +++ b/src/simulation/random_numbers.cpp @@ -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 diff --git a/src/simulation/simulation.cpp b/src/simulation/simulation.cpp index b90e5f8..bf02047 100755 --- a/src/simulation/simulation.cpp +++ b/src/simulation/simulation.cpp @@ -229,7 +229,8 @@ void Simulation::start() { // process both density and beta events before a cpu synchronization processDensityEvents(particles_per_bin, density_weight_factor); - processEvents(events_of_cycle, beta_particle_weight); + if(num_cpu_syncs == 0) + processEvents(events_of_cycle, beta_particle_weight); #ifdef debug_level1 DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timesteps)); @@ -479,6 +480,10 @@ void Simulation::processUntilTermination( if(particle.specie()->deletionLogger()) { particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(), DeletionType::max_time_alive); + if(particle.kineticEnergy_eV() > 2000) { + particle.specie()->deletionLogger()->logDeletion(particle.cartesianPosition(), + DeletionType::loss_above_2keV); + } #ifdef debug if(!particle.wasDeposited()) { std::stringstream out; @@ -503,6 +508,10 @@ void Simulation::processUntilTermination( if (particle.specie()->deletionLogger()) { particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(), DeletionType::wall); + if(particle.kineticEnergy_eV() > 2000) { + particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(), + DeletionType::loss_above_2keV); + } } #ifdef debug if(particle.wasDeposited()) { @@ -558,6 +567,10 @@ void Simulation::processUntilTermination( if (particle.specie()->deletionLogger()) { particle.specie()->deletionLogger()->logDeletion( particle.cylinderPosition(), DeletionType::max_interactions); + if(particle.kineticEnergy_eV() > 2000) { + particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(), + DeletionType::loss_above_2keV); + } } break; }