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 */
+1
View File
@@ -250,4 +250,5 @@ protected:
InterOut->add_new_particle(newPart);
}
};
#endif /* eT2_ionization_h */
+2 -96
View File
@@ -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-
@@ -50,6 +50,7 @@ inline double e_thermal_Interaction_Base::calc_macro_sigma_m(const double &E_eV,
}
inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
//return get_microSigma_m2(E_eV); No Integration... ONly e- energy
if (E_eV > E_limit) {
return get_microSigma_m2(E_eV);
} else {
@@ -116,101 +117,6 @@ 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 */