From fb20c896eba69ff460d96eb41954d3108bbebfe6 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 5 Nov 2019 11:12:00 +0100 Subject: [PATCH] Minor Changes Time Calculation changed to based on 1e11 with 100%CD --- src/mc_electron/T2Ie_recombination.h | 2 +- src/mc_electron/T5Ie_recombination.h | 2 +- src/mc_electron/h5_file.hpp | 1 + src/mc_electron/h5tb_particle_interface.cpp | 8 +++++++- src/mc_electron/h5tb_particle_interface.hpp | 1 + src/mc_electron/h5tb_population_interface.cpp | 8 +++++++- src/mc_electron/h5tb_population_interface.hpp | 2 +- src/mc_electron/h5tb_population_meta_interface.cpp | 7 ++++++- src/mc_electron/h5tb_population_meta_interface.hpp | 1 + src/mc_electron/multiz_particle_logger.h | 6 ++++++ src/mc_electron/off_particle_logger.h | 1 + src/mc_electron/particle_logger_base.h | 1 + src/mc_electron/particle_looper.cpp | 13 +++++++++++++ src/mc_electron/particle_looper.hpp | 2 ++ src/mc_electron/population_container.cpp | 5 +---- src/mc_electron/population_logger_base.h | 11 +++++++++++ src/mc_electron/sf_particle_logger.h | 5 +++++ src/mc_electron/simulation.cpp | 9 ++------- src/mc_electron/simulation.hpp | 2 +- src/mc_electron/timer.cpp | 1 + 20 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/mc_electron/T2Ie_recombination.h b/src/mc_electron/T2Ie_recombination.h index ae43952..aca8f4d 100644 --- a/src/mc_electron/T2Ie_recombination.h +++ b/src/mc_electron/T2Ie_recombination.h @@ -23,7 +23,7 @@ public: inline InteractionOut T2Ie_Recombination::do_Interaction (Particle *interPart) { InteractionOut res; res.set_delete_current(true); - double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances. + //double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances. //Population->decrease_denisty(interPart->get_x_m(), E_eV); // Maybe add the 2 T atoms. diff --git a/src/mc_electron/T5Ie_recombination.h b/src/mc_electron/T5Ie_recombination.h index f67017d..614705b 100644 --- a/src/mc_electron/T5Ie_recombination.h +++ b/src/mc_electron/T5Ie_recombination.h @@ -28,7 +28,7 @@ public: inline InteractionOut T5Ie_Recombination::do_Interaction (Particle *interPart) { InteractionOut res; res.set_delete_current(true); - double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances. + //double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances. //Population->decrease_denisty(interPart->get_x_m(), E_eV); // Maybe add the 5 T atoms. diff --git a/src/mc_electron/h5_file.hpp b/src/mc_electron/h5_file.hpp index ba9ae2b..f8fc83b 100644 --- a/src/mc_electron/h5_file.hpp +++ b/src/mc_electron/h5_file.hpp @@ -27,6 +27,7 @@ public: hid_t *get_h5f() {return &h5f;} std::string get_h5g_particles_path() {return h5g_particles_path;} std::string get_h5g_populations_path() {return h5g_populations_path;} + private: void create(std::string output_path); //std::string get_file_name(); diff --git a/src/mc_electron/h5tb_particle_interface.cpp b/src/mc_electron/h5tb_particle_interface.cpp index b432a61..9a903d4 100644 --- a/src/mc_electron/h5tb_particle_interface.cpp +++ b/src/mc_electron/h5tb_particle_interface.cpp @@ -63,8 +63,14 @@ void H5TB_Particle_Interface::write(const Particle &logPart) { buffer_count = 0; } } -H5TB_Particle_Interface::~H5TB_Particle_Interface() { + +void H5TB_Particle_Interface::flush() { H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer); + buffer_count = 0; +} + +H5TB_Particle_Interface::~H5TB_Particle_Interface() { + flush(); } loggerParticle H5TB_Particle_Interface::transform(const Particle &logPart) { diff --git a/src/mc_electron/h5tb_particle_interface.hpp b/src/mc_electron/h5tb_particle_interface.hpp index 6ee1ea5..724bb44 100644 --- a/src/mc_electron/h5tb_particle_interface.hpp +++ b/src/mc_electron/h5tb_particle_interface.hpp @@ -54,6 +54,7 @@ private: public: void write(const Particle &logPart); + void flush(); private: loggerParticle transform(const Particle &logPart); }; diff --git a/src/mc_electron/h5tb_population_interface.cpp b/src/mc_electron/h5tb_population_interface.cpp index 5303f6b..176cafd 100644 --- a/src/mc_electron/h5tb_population_interface.cpp +++ b/src/mc_electron/h5tb_population_interface.cpp @@ -70,6 +70,12 @@ void H5TB_Population_Interface::write(const pop_bin &log_bin) { } } -H5TB_Population_Interface::~H5TB_Population_Interface() { +void H5TB_Population_Interface::flush() { H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer); + buffer_count = 0; +} + +H5TB_Population_Interface::~H5TB_Population_Interface() { + flush(); + } diff --git a/src/mc_electron/h5tb_population_interface.hpp b/src/mc_electron/h5tb_population_interface.hpp index 0bef93c..a791f24 100644 --- a/src/mc_electron/h5tb_population_interface.hpp +++ b/src/mc_electron/h5tb_population_interface.hpp @@ -55,7 +55,7 @@ private: public: void write(const pop_bin &log_bin); - + void flush(); }; diff --git a/src/mc_electron/h5tb_population_meta_interface.cpp b/src/mc_electron/h5tb_population_meta_interface.cpp index 4527e84..43dc45c 100644 --- a/src/mc_electron/h5tb_population_meta_interface.cpp +++ b/src/mc_electron/h5tb_population_meta_interface.cpp @@ -92,6 +92,11 @@ void H5TB_Population_Meta_Interface::write(const pop_bin_meta_info &log_meta_bin } } -H5TB_Population_Meta_Interface::~H5TB_Population_Meta_Interface() { +void H5TB_Population_Meta_Interface::flush() { H5TBappend_records(*loc_id, table_name.c_str() , buffer_count, size, offset, sizes, &buffer); + buffer_count = 0; +} + +H5TB_Population_Meta_Interface::~H5TB_Population_Meta_Interface() { + flush(); } diff --git a/src/mc_electron/h5tb_population_meta_interface.hpp b/src/mc_electron/h5tb_population_meta_interface.hpp index a0c00a9..9cf8d0d 100644 --- a/src/mc_electron/h5tb_population_meta_interface.hpp +++ b/src/mc_electron/h5tb_population_meta_interface.hpp @@ -62,6 +62,7 @@ private: public: void write(const pop_bin_meta_info &log_meta_bin); + void flush(); }; diff --git a/src/mc_electron/multiz_particle_logger.h b/src/mc_electron/multiz_particle_logger.h index 71a8934..9db4b5d 100644 --- a/src/mc_electron/multiz_particle_logger.h +++ b/src/mc_electron/multiz_particle_logger.h @@ -38,6 +38,7 @@ private: public: void log(const Particle &logPart, const vec3 &oldLoc_m); + void flush(); }; @@ -74,4 +75,9 @@ inline void MultiZ_Particle_Logger::log(const Particle &logPart, const vec3 &old } } +inline void MultiZ_Particle_Logger::flush() { + for (int i = 0; i < numberZBins; i++) { + h5tb[i].flush(); + } +} #endif /* multiz_particle_logger_h */ diff --git a/src/mc_electron/off_particle_logger.h b/src/mc_electron/off_particle_logger.h index 5a0e1f5..a941f56 100644 --- a/src/mc_electron/off_particle_logger.h +++ b/src/mc_electron/off_particle_logger.h @@ -14,6 +14,7 @@ class Off_Particle_Logger : public Particle_Logger_Base { public: Off_Particle_Logger(species this_species) : Particle_Logger_Base(this_species) {}; void log(const Particle &logPart, const vec3 &oldLoc_m) {}; + void flush() {}; }; diff --git a/src/mc_electron/particle_logger_base.h b/src/mc_electron/particle_logger_base.h index e0a6f13..1c2fbc6 100644 --- a/src/mc_electron/particle_logger_base.h +++ b/src/mc_electron/particle_logger_base.h @@ -18,6 +18,7 @@ protected: public: Particle_Logger_Base(species this_species) : Process_Base(this_species) {}; virtual void log(const Particle &logPart, const vec3 &oldLoc_m) = 0; + virtual void flush() = 0; void set_logging(const bool &logging) { this->logging = logging; } diff --git a/src/mc_electron/particle_looper.cpp b/src/mc_electron/particle_looper.cpp index e86330b..f7560ee 100644 --- a/src/mc_electron/particle_looper.cpp +++ b/src/mc_electron/particle_looper.cpp @@ -93,3 +93,16 @@ void Particle_Looper::set_logging(bool logging) { } } } + +void Particle_Looper::flush() { + // Dirty workaround since deconstructors are not properly called due to bad pointer situation. + vector all_species = get_all_species_vector(); + species current_species; + for (vector::iterator itr = all_species.begin(); itr != all_species.end(); itr++) { + current_species = *itr; + if (part_loggers.exists(current_species)) { + part_loggers.find(current_species)->flush(); + } + pop_loggers.flush(); + } +} diff --git a/src/mc_electron/particle_looper.hpp b/src/mc_electron/particle_looper.hpp index 0b7062b..4e755bd 100644 --- a/src/mc_electron/particle_looper.hpp +++ b/src/mc_electron/particle_looper.hpp @@ -91,6 +91,8 @@ public: Terminator_Manager *get_terminators() { return &terminators; } + + void flush(); }; diff --git a/src/mc_electron/population_container.cpp b/src/mc_electron/population_container.cpp index 758ef83..ca5d08c 100644 --- a/src/mc_electron/population_container.cpp +++ b/src/mc_electron/population_container.cpp @@ -71,12 +71,11 @@ void Population_Container::init_size_array() { double bin_length_m = scales.z.get_delta(); size_data_m3 = new double[scales.r.get_number_bins()]; for (int r_bin = 0; r_binflush(); + } +} #endif /* Population_Logger_h */ diff --git a/src/mc_electron/sf_particle_logger.h b/src/mc_electron/sf_particle_logger.h index 785eb60..efadee5 100644 --- a/src/mc_electron/sf_particle_logger.h +++ b/src/mc_electron/sf_particle_logger.h @@ -27,6 +27,7 @@ private: void create(H5_File *h5_file, species this_species); public: void log(const Particle &logPart, const vec3 &oldLoc_m); + void flush(); }; @@ -44,5 +45,9 @@ inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_ h5tb.write(logPart); } +inline void SF_Particle_Logger::flush() { + h5tb.flush(); +} + #endif /* sf_particle_logger_h */ diff --git a/src/mc_electron/simulation.cpp b/src/mc_electron/simulation.cpp index e57ec25..44eea5e 100644 --- a/src/mc_electron/simulation.cpp +++ b/src/mc_electron/simulation.cpp @@ -39,7 +39,6 @@ void Simulation::init_pop_arrays() { // Init C-arrays used for MPI-Allgather com pop_species = new species[number_pop_species]; pop_array_lengths = new int[number_pop_species]; global_cum_time_s = new double *[number_pop_species]; - global_offset = new double *[number_pop_species]; Population_Base *population; @@ -51,10 +50,8 @@ void Simulation::init_pop_arrays() { // Init C-arrays used for MPI-Allgather com pop_array_lengths[i] = population->access_container()->data_size; global_cum_time_s[i] = new double[pop_array_lengths[i]]; - global_offset[i] = new double[pop_array_lengths[i]]; for (int j = 0; jcum_times_s[j] = global_cum_time_s[i][j]; } diff --git a/src/mc_electron/simulation.hpp b/src/mc_electron/simulation.hpp index e9034dc..c25d0c3 100644 --- a/src/mc_electron/simulation.hpp +++ b/src/mc_electron/simulation.hpp @@ -32,7 +32,7 @@ class Simulation { int number_pop_species; species *pop_species; int *pop_array_lengths; - double **global_cum_time_s, **global_offset; + double **global_cum_time_s; public: Simulation(); diff --git a/src/mc_electron/timer.cpp b/src/mc_electron/timer.cpp index 88f3685..e462e1b 100644 --- a/src/mc_electron/timer.cpp +++ b/src/mc_electron/timer.cpp @@ -40,6 +40,7 @@ void Timer::set_T2_activity_s() { double V_m3 = pi*r_m*r_m*l_m; double NT2 = (wgtsT2MaxDensity_m3/2)*V_m3; T2_activity_s = NT2*decayConstT2_s; + T2_activity_s = wgtsT2MaxDensity_m3/1e21*1e11; // Analytical calculation 1e21 = 100% CD, 1e11 = Activity at 1e21. } double Timer::get_time_s() {