// // sub_interaction_base.h // mc_electron // // Created by Christian Reiling on 19.05.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #ifndef sub_interaction_base_h #define sub_interaction_base_h #include #include #include "particle.hpp" #include "population_base.h" #include "error_types.h" class InteractionOut { bool delete_current; Particle new_particles[3]; int number_new_particles; public: InteractionOut() {reset();}; void reset() { delete_current = false; number_new_particles = 0; } void set_delete_current(const bool &delete_current) {this->delete_current = delete_current;} bool get_delete_current() {return delete_current;} void add_new_particle(const Particle &newParticle) { new_particles[number_new_particles] = newParticle; number_new_particles++; } int get_number_new_particles() {return number_new_particles;} Particle *get_new_particles() {return new_particles;} }; class Sub_Interaction_Base { protected: Population_Base *Population; UniRNG *rngUni; public: Sub_Interaction_Base(Population_Base *Population, UniRNG *rngUni) { this->Population = Population; this->rngUni = rngUni; }; double get_macroSigma_m(const Particle &interPart); private: virtual double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) = 0; double get_macroSigma_m_thermal(const Particle &interPart); double get_macroSigma_m_kinetic(const Particle &interPart, const Sum_bounds &bounds); public: virtual InteractionOut do_Interaction (Particle *interPart) = 0; protected: vec3 get_vOff_ms(const Particle &interPart, const double &minE_eV); }; inline double Sub_Interaction_Base::get_macroSigma_m(const Particle &interPart) { Sum_bounds bounds = Population->get_sumation_bounds(interPart.get_x_m()); if (bounds.num_E_bins <= 1) { //thermal return get_macroSigma_m_thermal(interPart); } else { //kinetic return get_macroSigma_m_kinetic(interPart, bounds); } } inline double Sub_Interaction_Base::get_macroSigma_m_thermal(const Particle &interPart) { double E_eV = interPart.get_E_eV(); vec3 loc_m = interPart.get_x_m(); double microSigma_m2 = get_microSigma_m2(E_eV, loc_m); double n_target_m3 = Population->get_density_m3(loc_m); return microSigma_m2*n_target_m3; } inline double Sub_Interaction_Base::get_macroSigma_m_kinetic(const Particle &interPart, const Sum_bounds &bounds) { // integrate over all energy bins, consider interPart.E_eV << E_eV. vec3 loc_m = interPart.get_x_m(); Content cont; double macro_Sigma_m2 = 0; for (int E_bin = 0; E_bin< bounds.num_E_bins; E_bin++) { macro_Sigma_m2 += get_microSigma_m2(cont.E_eV, loc_m) * cont.n_m3; } return macro_Sigma_m2; } inline vec3 Sub_Interaction_Base::get_vOff_ms(const Particle &interPart, const double &minE_eV) { double m_eV = interPart.get_m_eV(); vec3 v1_ms = interPart.get_v_ms(); vec3 v2_ms = Population->roll_v_ms(interPart.get_x_m()); vec3 v1Lab_ms = v1_ms - v2_ms; double T_eV = calc_E_eV_from_v_ms(v1Lab_ms, m_eV); if (T_eV < minE_eV) { T_eV = calc_E_eV_from_v_ms(v1_ms, m_eV); if (T_eV < minE_eV) { std::stringstream ss; ss<<"Sub_Interaction_Base::get_vOff_ms: T_eV < minE_eV.\nT_eV= "<< T_eV<<"\t minE_eV= "<