Prelimary final

This commit is contained in:
Christian
2019-11-30 09:50:25 +01:00
parent 98d4b6194d
commit ea7248868f
3 changed files with 7 additions and 199 deletions
+4 -103
View File
@@ -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
@@ -60,6 +60,7 @@ inline double TI_e_Interaction_Base::calc_macro_sigma_m(const double &E_eV, cons
}
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]); No Integration... ONly e- energy
double v1_ms = ve_mids[Ee_bin];
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV);
@@ -111,108 +112,6 @@ inline double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(const Particl
}
}
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;
} */
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];
@@ -225,4 +124,6 @@ inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const doub
}
return macro_sigma_m;
}
#endif /* TI_kinetic_base_h */