From 7fca174042775e6415e1e2ed9d2adf254e58646c Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 13 Nov 2019 14:07:36 +0100 Subject: [PATCH] Bug fix: Forgot factor c_ms**-2 --- src/mc_electron/sub_interaction_base.h | 8 ++++---- src/mc_electron/terminator_base.h | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/mc_electron/sub_interaction_base.h b/src/mc_electron/sub_interaction_base.h index 69ea4de..de01b80 100644 --- a/src/mc_electron/sub_interaction_base.h +++ b/src/mc_electron/sub_interaction_base.h @@ -87,8 +87,8 @@ inline double Sub_Interaction_Base::get_macroSigma_m_thermal(const Particle &int double m_eV = interPart.get_m_eV(); double v1_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur" double v2_ms = Population->get_thermal_v_ms(loc_m); // Typical Speed of "Thermal Blur" - double E_min_eV = m_eV/2*pow(v1_ms - v2_ms,2); - double E_max_eV = m_eV/2*pow(v1_ms + v2_ms,2); + double E_min_eV = m_eV/2*pow(v1_ms - v2_ms,2)/c_ms/c_ms; + double E_max_eV = m_eV/2*pow(v1_ms + v2_ms,2)/c_ms/c_ms; return (get_microSigma_m2(E_min_eV, loc_m) + get_microSigma_m2(E_max_eV, loc_m))/2*Population->get_density_m3(loc_m); } @@ -113,8 +113,8 @@ inline double Sub_Interaction_Base::get_macroSigma_m_kinetic(const Particle &int for (int E_bin = 0; E_binget_density_m3(E_bin, bounds.loc_bins); v2_ms = sqrt(2*cont.E_eV/m_eV); - E_min_eV = m_eV/2*pow(v1_ms - v2_ms,2); - E_max_eV = m_eV/2*pow(v1_ms + v2_ms,2); + E_min_eV = m_eV/2*pow(v1_ms - v2_ms,2)/c_ms/c_ms; + E_max_eV = m_eV/2*pow(v1_ms + v2_ms,2)/c_ms/c_ms; macro_Sigma_m2 += (get_microSigma_m2(E_min_eV, loc_m)+get_microSigma_m2(E_max_eV, loc_m))/2 * cont.n_m3; } return macro_Sigma_m2; diff --git a/src/mc_electron/terminator_base.h b/src/mc_electron/terminator_base.h index 11ea093..1c2c6eb 100644 --- a/src/mc_electron/terminator_base.h +++ b/src/mc_electron/terminator_base.h @@ -22,6 +22,16 @@ struct Termination_Stats { int n_energy = 0; int n_reaction = 0; + void reset () { + n_total = 0; + n_rw = 0; + n_dipole = 0; + n_radial = 0; + n_max = 0; + n_energy = 0; + n_reaction = 0; + } + void to_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast array [0] = n_total; array [1] = n_rw; @@ -65,7 +75,9 @@ public: Termination_Stats get_stats() { return stats; } - + void reset_stats() { + stats.reset(); + } void increase_n_reaction() { stats.n_reaction += 1; }