Version for "Ignore Ion energy, just used electron energy for mcs-calculation"
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
class TI_e_Interaction_Base : public Interaction_Base { // Interactions of ions with kinetic e Populations
|
||||
/*class TI_e_Interaction_Base : public Interaction_Base { // Interactions of ions with kinetic e Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : e-
|
||||
double m2_eV; // energy of massic initial particle : TI
|
||||
@@ -122,6 +122,107 @@ inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const doub
|
||||
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
} */
|
||||
|
||||
|
||||
class TI_e_Interaction_Base : public Interaction_Base { // Interactions of ions with kinetic e Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : e-
|
||||
double m2_eV; // energy of massic initial particle : TI
|
||||
int num_Ee_bins; // number of Ee_bins in Populations
|
||||
double *Ee_mids; // values for energy mids of Ee_bins in Populations
|
||||
double *ve_mids; // corresponding v_values
|
||||
|
||||
public:
|
||||
TI_e_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
m1_eV = Population->get_m_eV();
|
||||
m2_eV = m_eV;
|
||||
|
||||
num_Ee_bins = Population->get_number_E_bins();
|
||||
if (num_Ee_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when expected kinetic.");
|
||||
}
|
||||
ve_mids = new double[num_Ee_bins];
|
||||
Ee_mids = new double[num_Ee_bins];
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
Ee_mids[Ee_bin] = Population->get_E_bin_mid_eV(Ee_bin);
|
||||
ve_mids[Ee_bin] = calc_v_ms_from_E_eV(Ee_mids[Ee_bin], m1_eV);
|
||||
}
|
||||
}
|
||||
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_m2(const double &E1_eV, const int &Ee_bin);
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
inline double TI_e_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
|
||||
inline double TI_e_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline double TI_e_Interaction_Base::calc_microSigma_m2(const double &E2_eV, const int &Ee_bin) {
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||
}
|
||||
|
||||
class TI_e_Precomputed_Interaction_Base : public TI_e_Interaction_Base { // Precompute Interactions of ions with kinetic e Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double **precomputed_values;
|
||||
|
||||
public:
|
||||
TI_e_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_e_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()];
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
precomputed_values[EI_bin] = new double[num_Ee_bins];
|
||||
}
|
||||
}
|
||||
void calc_values();
|
||||
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_e_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
precomputed_values[EI_bin][Ee_bin] = calc_microSigma_m2(E_scale.get_bin_mid(EI_bin), Ee_bin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double E_eV = interPart.get_E_eV();
|
||||
|
||||
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_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
int EI_bin = E_scale.calc_index(E_eV);
|
||||
double *microSigmas = precomputed_values[EI_bin];
|
||||
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
#endif /* TI_kinetic_base_h */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define e_kinetic_base_h
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
/*
|
||||
class e_kinetic_Interaction_Base : public Interaction_Base { // Interactions of electrons with kinetic resolved TI (but thermal)
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : e-
|
||||
@@ -90,7 +90,7 @@ inline vec3 e_kinetic_Interaction_Base::get_vOff_ms(const Particle &interPart, c
|
||||
}
|
||||
return v2_ms;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
class e_kinetic_Precomputed_Interaction_Base : public e_kinetic_Interaction_Base { // Precompute Interactions of ions with kinetic e Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
|
||||
/*
|
||||
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle in CS measurement : e-
|
||||
@@ -60,12 +60,6 @@ inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV)
|
||||
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||
};
|
||||
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||
/* // Integration over theta
|
||||
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)/pi;
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N, simpson());*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +116,101 @@ inline double e_thermal_Precomputed_Interaction_Base::lookup_macro_sigma_m(const
|
||||
int i = E_scale.calc_index(E_eV);
|
||||
return precomputed_values[i] * Population->get_density_m3(loc_m);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle in CS measurement : e-
|
||||
|
||||
double E_limit; // limit for integration calculation
|
||||
double v_therm; // typical spped for thermal population
|
||||
|
||||
public:
|
||||
e_thermal_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"
|
||||
E_limit = calc_E_eV_from_v_ms(v_therm * 2000, m1_eV); // 2000 represents 1% variation in energy
|
||||
}
|
||||
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_m2(const double &E_eV);
|
||||
vec3 get_vOff_ms(const Particle &interPart, const double &minE_eV); // For derived class -> Roll energy loss
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
inline double e_thermal_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 e_thermal_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||
return get_microSigma_m2(E_eV);
|
||||
}
|
||||
|
||||
inline vec3 e_thermal_Interaction_Base::get_vOff_ms(const Particle &interPart, const double &minE_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, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
T_eV = calc_E_eV_from_v_ms(v1_ms, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Base::get_vOff_ms: T_eV < minE_eV.\nT_eV= "<< T_eV<<"\t minE_eV= "<<minE_eV<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
return v2_ms;
|
||||
}
|
||||
|
||||
|
||||
class e_thermal_Precomputed_Interaction_Base : public e_thermal_Interaction_Base { // + Using precomputed values
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
e_thermal_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : e_thermal_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 e_thermal_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
||||
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
||||
}
|
||||
}
|
||||
|
||||
inline double e_thermal_Precomputed_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
|
||||
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 e_thermal_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] * Population->get_density_m3(loc_m);
|
||||
}
|
||||
#endif /* e_thermal_base_h */
|
||||
|
||||
@@ -182,7 +182,7 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium2I(Population_Manage
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
|
||||
if (load_parameter("e_REC") == 1) {
|
||||
//T2I_Interaction->add(new T2Ie_Recombination(ePopulation, rngUni));
|
||||
T2I_Interaction->add(new T2Ie_Recombination(ePopulation, rngUni));
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
@@ -201,7 +201,7 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manage
|
||||
T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
||||
|
||||
if (load_parameter("e_REC") == 1) {
|
||||
//T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
||||
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
@@ -217,7 +217,7 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium5I(Population_Manage
|
||||
T5I_Interaction->add(new T5IT2_Elastic(T2Population, rngUni));
|
||||
|
||||
if (load_parameter("e_REC") == 1) {
|
||||
//T5I_Interaction->add(new T5Ie_Recombination(ePopulation, rngUni));
|
||||
T5I_Interaction->add(new T5Ie_Recombination(ePopulation, rngUni));
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user