// // TI_thermal_tenary_base.h // mc_electron // // Created by Christian Reiling on 18.11.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #ifndef TI_thermal_tenary_base_h #define TI_thermal_tenary_base_h #include "interaction_base.h" class TI_thermal_tenary_Interaction_Base : public Interaction_Base { // Tenary interactions of tritium ions with thermal Populations protected: double m1_eV; // energy of kinetic particle for CS measurement : tritum ion double v_therm; // typical spped for thermal population public: TI_thermal_tenary_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) { if (Population->get_number_E_bins() > 1) { throw MyException("Population is not thermal, when expected thermal."); } m1_eV = m_eV; v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur" } double get_macro_sigma_m(const Particle &interPart); protected: double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m); double calc_microSigma_divbyn_m2(const double &E_eV); private: virtual double get_microSigma_m2(const double &E_eV) = 0; }; inline double TI_thermal_tenary_Interaction_Base::get_macro_sigma_m(const Particle &interPart) { vec3 loc_m = interPart.get_x_m(); double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur" double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration return calc_macro_sigma_m(E_eV, loc_m); } inline double TI_thermal_tenary_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) { return calc_microSigma_divbyn_m2(E_eV)*pow(Population->get_density_m3(loc_m), 2); } inline double TI_thermal_tenary_Interaction_Base::calc_microSigma_divbyn_m2(const double &E_eV) { double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV); auto integrand = [&](double theta) { double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2); return get_microSigma_m2(E_eV); }; return integrate(integrand, 0., pi, INT_N, simpson())/pi; } class TI_thermal_tenary_Precomputed_Interaction_Base : public TI_thermal_tenary_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations Log_Scale E_scale; // E_scale for Interpolation calculation double *precomputed_values; public: TI_thermal_tenary_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_tenary_Interaction_Base(Population, rngUni, m_eV), E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N) { precomputed_values = new double [E_scale.get_number_bins()]; } void calc_values(); // must be called by derived class, can't call in this constructor, due to virtual pure double get_macro_sigma_m(const Particle &interPart); private: double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m); }; inline void TI_thermal_tenary_Precomputed_Interaction_Base::calc_values() { for (int i=0; iget_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur" double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration if (E_scale.in_scale(E_eV)) { return lookup_macro_sigma_m(E_eV, loc_m); } else { return calc_macro_sigma_m(E_eV, loc_m); } } inline double TI_thermal_tenary_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) { int i = E_scale.calc_index(E_eV); return precomputed_values[i] * pow(Population->get_density_m3(loc_m),2); } #endif /* TI_thermal_tenary_base_h */