Bug fixes in mass terms.
Restructured Interaction Base classes and reviewed. Added Parameters for Setting Number of Integration Points for CS and for Population sices.
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
#ifndef T2IT2_cluster_h
|
||||
#define T2IT2_cluster_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "janev_T2IT2_cluster.h"
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef T2IT2_cx_h
|
||||
#define T2IT2_cx_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
#include "kinematics_base.h"
|
||||
#include "janev_T2IT2_cx.h"
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#ifndef T2Ie_disexc_h
|
||||
#define T2Ie_disexc_h
|
||||
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "janev_eT2I_disexc.h"
|
||||
|
||||
|
||||
class T2Ie_DissExc : public Interaction_Base {
|
||||
public:
|
||||
T2Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Interaction_Base(ePopulation, rngUni) {}
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#ifndef T2Ie_recombination_h
|
||||
#define T2Ie_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "precomputed_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT2I_recombination.h"
|
||||
|
||||
|
||||
class T2Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 2*mT_eV) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef T3IT2_elastic_h
|
||||
#define T3IT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "tabata_T3IT2_elastic.h"
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef T3IT2_radasc_h
|
||||
#define T3IT2_radasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Gerlich:
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
|
||||
class T3IT2_RadAsc : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, 3*mT_eV);
|
||||
return 5e-23/v_ms;
|
||||
return 5e-23/v_ms; // CS from Gerlich:1990aa
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef T3IT2_terasc_h
|
||||
#define T3IT2_terasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Gerlich:
|
||||
#include "TI_thermal_tenary_base.h"
|
||||
|
||||
|
||||
class T3IT2_TerAsc : public TI_thermal_tenary_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
double get_microSigma_divbyn_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, 3*mT_eV);
|
||||
return 7e-41*v_ms;
|
||||
return 7e-41*v_ms; // CS from Gerlich:1990aa
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
#ifndef T3Ie_disexc_h
|
||||
#define T3Ie_disexc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT3I_disexc.h"
|
||||
|
||||
|
||||
class T3Ie_DissExc : public Interaction_Base {
|
||||
public:
|
||||
T3Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Interaction_Base(ePopulation, rngUni) {}
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#ifndef T3Ie_recombination_h
|
||||
#define T3Ie_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "precomputed_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
|
||||
|
||||
class T3Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 3*mT_eV) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef T5IT2_elastic_h
|
||||
#define T5IT2_elastic_h
|
||||
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
class T5IT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_T3IT2_Elastic tcs_gen; // Obviously wrong, but should be good enough.
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
#ifndef T5Ie_recombination_h
|
||||
#define T5Ie_recombination_h
|
||||
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "precomputed_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "petterson_eT5I_recombination.h"
|
||||
|
||||
|
||||
class T5Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T5Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 5*mT_eV) {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef TIT2_elastic_h
|
||||
#define TIT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "kinematics_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "tabata_TIT2_elastic.h"
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#ifndef TIT2_radasc_h
|
||||
#define TIT2_radasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Plasil:2012
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
class TIT2_RadAsc : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -21,7 +20,7 @@ public:
|
||||
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, mT_eV);
|
||||
return 5e-23/v_ms;
|
||||
return 5e-23/v_ms; // CS from Plasil:2012
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef TIT2_terasc_h
|
||||
#define TIT2_terasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Plasil:2012
|
||||
#include "TI_thermal_tenary_base.h"
|
||||
|
||||
|
||||
class TIT2_TerAsc : public TI_thermal_tenary_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
double get_microSigma_divbyn_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, mT_eV);
|
||||
return 2.6e-41/v_ms;
|
||||
return 2.6e-41/v_ms; // CS from Plasil:2012
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// TI_kinetic_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TI_kinetic_base_h
|
||||
#define TI_kinetic_base_h
|
||||
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
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) {
|
||||
double v1_ms = ve_mids[Ee_bin];
|
||||
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV);
|
||||
|
||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||
} else {
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson())/pi;
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// TI_thermal_binary_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TI_thermal_binary_base_h
|
||||
#define TI_thermal_binary_base_h
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
|
||||
class TI_thermal_binary_Interaction_Base : public Interaction_Base { // Binary interactions of tritium ions with thermal Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : tritium ion
|
||||
double v_therm; // typical speed for thermal population
|
||||
|
||||
public:
|
||||
TI_thermal_binary_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_m2(const double &E_eV);
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
inline double TI_thermal_binary_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_binary_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 TI_thermal_binary_Interaction_Base::calc_microSigma_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_INTPOINTS, simpson())/pi;
|
||||
}
|
||||
|
||||
|
||||
class TI_thermal_binary_Precomputed_Interaction_Base : public TI_thermal_binary_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
TI_thermal_binary_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_binary_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_binary_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 TI_thermal_binary_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 TI_thermal_binary_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 /* TI_thermal_binary_base_h */
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// 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_divbyn_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_divbyn_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N_INTPOINTS, 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; i<E_scale.get_number_bins(); i++) {
|
||||
precomputed_values[i] = calc_microSigma_divbyn_m2(E_scale.get_bin_mid(i));
|
||||
}
|
||||
}
|
||||
|
||||
inline double TI_thermal_tenary_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 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 */
|
||||
@@ -9,12 +9,12 @@
|
||||
#ifndef constants_h
|
||||
#define constants_h
|
||||
|
||||
typedef const double constant;
|
||||
#include "read_system.h"
|
||||
|
||||
typedef const double constant;
|
||||
|
||||
constant scale_start = 1e-7;
|
||||
constant scale_end = 2e4;
|
||||
constant infinity = 1e15;
|
||||
|
||||
// Natural Constants
|
||||
constant pi = 3.1415;
|
||||
@@ -53,4 +53,10 @@ constant reduction_WGTS_rear = 0.033;
|
||||
constant reduction_tot_front = 5e-4;
|
||||
constant reduction_tot_rear = 5e-4;
|
||||
|
||||
// For interaction integration
|
||||
const int INT_N_INTPOINTS = load_parameter("INT_N_INTPOINTS"); // Number of points for theta integration
|
||||
const double INT_PRE_START = load_parameter("INT_PRE_START"); // Start energy for precomputed cross sections
|
||||
const double INT_PRE_END = load_parameter("INT_PRE_END"); // End energy for precomputed cross sections
|
||||
const int INT_PRE_N = load_parameter("INT_PRE_N"); //Number of points for precomputed cross sections
|
||||
|
||||
#endif /* constants_h */
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT2I_disexc_h
|
||||
#define eT2I_disexc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "exc_base.h"
|
||||
|
||||
#include "janev_eT2I_disexc.h"
|
||||
|
||||
class eT2I_DissExc : public Excitation_Base {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT2I_recombination_h
|
||||
#define eT2I_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "janev_eT2I_recombination.h"
|
||||
|
||||
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#ifndef eT2_elastic_h
|
||||
#define eT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "precomputed_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_theta_container.hpp"
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
#ifndef eT2_elexc_analytic_h
|
||||
#define eT2_elexc_analytic_h
|
||||
|
||||
#include "exc_base.h"
|
||||
|
||||
#include "janev_eT2_elexc.h"
|
||||
|
||||
|
||||
class eT2_ElExc_Nu_Analytic : public Excitation_Base {
|
||||
Janev_eT2_ElExc_Nu janev_Nu;
|
||||
public:
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT2_ionization_h
|
||||
#define eT2_ionization_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_ionization_container.hpp"
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#define eT2_vibexc0102_h
|
||||
|
||||
#include "exc_base.h"
|
||||
|
||||
#include "janev_eT2_vibexc0102.h"
|
||||
|
||||
|
||||
class eT2_VibExc01 : public Excitation_Base {
|
||||
Janev_eT2_VibExc calculator;
|
||||
public:
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT3I_disexc_h
|
||||
#define eT3I_disexc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "exc_base.h"
|
||||
|
||||
#include "janev_eT3I_disexc.h"
|
||||
|
||||
class eT3I_DissExc : public Excitation_Base {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT3I_recombination_h
|
||||
#define eT3I_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
|
||||
class eT3I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef eT5I_recombination_h
|
||||
#define eT5I_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "petterson_eT5I_recombination.h"
|
||||
|
||||
class eT5I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// e_thermal_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef e_thermal_base_h
|
||||
#define e_thermal_base_h
|
||||
|
||||
#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-
|
||||
|
||||
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) {
|
||||
if (E_eV > E_limit) {
|
||||
return get_microSigma_m2(E_eV);
|
||||
} else {
|
||||
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_INTPOINTS, simpson())/pi;
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef exc_base_h
|
||||
#define exc_base_h
|
||||
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_base.h"
|
||||
|
||||
|
||||
@@ -9,71 +9,51 @@
|
||||
#ifndef interaction_base_hpp
|
||||
#define interaction_base_hpp
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "particle.hpp"
|
||||
#include "population_base.h"
|
||||
|
||||
#include "process_base.h"
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
#include "integrater.h"
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
class Interaction_Channel_Base : public Process_Base {
|
||||
Interaction_Base **SubInteractions;
|
||||
int numSubInteractions = 0;
|
||||
|
||||
UniRNG *rngUni;
|
||||
class InteractionOut {
|
||||
bool delete_current;
|
||||
Particle new_particles[3];
|
||||
int number_new_particles;
|
||||
|
||||
public:
|
||||
Interaction_Channel_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
InteractionOut() {reset();};
|
||||
void reset() {
|
||||
delete_current = false;
|
||||
number_new_particles = 0;
|
||||
}
|
||||
|
||||
void add(Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
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;}
|
||||
};
|
||||
|
||||
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
||||
double macro_sigma_m = get_macro_sigma_m(*interPart);
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macro_sigma_m;
|
||||
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
currentStackedSigma += SubInteractions[i]->get_macro_sigma_m(*interPart);
|
||||
if (currentStackedSigma >= targetStackedSigma) {
|
||||
return SubInteractions[i]->do_Interaction(interPart);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
inline double Interaction_Channel_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
double macro_sigma_m = 0;
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
macro_sigma_m += SubInteractions[i]->get_macro_sigma_m(interPart);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||
if (numSubInteractions != 0) {
|
||||
Interaction_Base *tempArray[numSubInteractions];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
tempArray[i] = SubInteractions[i];
|
||||
}
|
||||
delete[] SubInteractions;
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
SubInteractions[i] = tempArray[i];
|
||||
}
|
||||
} else {
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
}
|
||||
SubInteractions[numSubInteractions] = addSubInteraction;
|
||||
numSubInteractions += 1;
|
||||
}
|
||||
|
||||
class Interaction_Base {
|
||||
protected:
|
||||
Population_Base *Population;
|
||||
UniRNG *rngUni;
|
||||
public:
|
||||
Interaction_Base(Population_Base *Population, UniRNG *rngUni) {
|
||||
this->Population = Population;
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
virtual double get_macro_sigma_m(const Particle &interPart) = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||
};
|
||||
|
||||
#endif /* interaction_base_h */
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "interaction_builder.hpp"
|
||||
|
||||
#include "exc_base.h"
|
||||
|
||||
// e impact
|
||||
#include "eT2_elastic.h"
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
#ifndef interaction_builder_hpp
|
||||
#define interaction_builder_hpp
|
||||
|
||||
#include "interaction_base.h"
|
||||
#include "manager_base.h"
|
||||
|
||||
#include "exc_base.h"
|
||||
#include "manager_base.h"
|
||||
#include "interaction_channel_base.h"
|
||||
#include "population_builder.hpp"
|
||||
#include "dcs_base.h"
|
||||
|
||||
|
||||
typedef Manager_Base<Interaction_Channel_Base> Interaction_Manager;
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// interaction_channel_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef interaction_channel_base_h
|
||||
#define interaction_channel_base_h
|
||||
|
||||
#include "process_base.h"
|
||||
#include "interaction_base.h"
|
||||
|
||||
|
||||
class Interaction_Channel_Base : public Process_Base {
|
||||
Interaction_Base **SubInteractions;
|
||||
int numSubInteractions = 0;
|
||||
|
||||
UniRNG *rngUni;
|
||||
|
||||
public:
|
||||
Interaction_Channel_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
|
||||
void add(Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
||||
double macro_sigma_m = get_macro_sigma_m(*interPart);
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macro_sigma_m;
|
||||
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
currentStackedSigma += SubInteractions[i]->get_macro_sigma_m(*interPart);
|
||||
if (currentStackedSigma >= targetStackedSigma) {
|
||||
return SubInteractions[i]->do_Interaction(interPart);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
inline double Interaction_Channel_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
double macro_sigma_m = 0;
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
macro_sigma_m += SubInteractions[i]->get_macro_sigma_m(interPart);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||
if (numSubInteractions != 0) {
|
||||
Interaction_Base *tempArray[numSubInteractions];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
tempArray[i] = SubInteractions[i];
|
||||
}
|
||||
delete[] SubInteractions;
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
SubInteractions[i] = tempArray[i];
|
||||
}
|
||||
} else {
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
}
|
||||
SubInteractions[numSubInteractions] = addSubInteraction;
|
||||
numSubInteractions += 1;
|
||||
}
|
||||
|
||||
#endif /* interaction_channel_base_h */
|
||||
@@ -22,98 +22,16 @@ typedef blitz::TinyVector<double,3> vec3;
|
||||
inline double calc_vec3_abs(const vec3 &vec) {
|
||||
return sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
inline double calc_gamma_from_beta(const double &beta) {
|
||||
if (beta>=1) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_gamma_from_beta(): Input beta ="<<beta<<" equal or exeeds 1.";
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<=0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_gamma_from_beta(): Input beta ="<<beta<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
return pow(1 - pow(beta,2),-0.5);
|
||||
}
|
||||
*/
|
||||
|
||||
inline double calc_E_eV_from_v_ms(const double &v_ms, const double &m_eV) {
|
||||
/*
|
||||
double beta = v_ms/c_ms;
|
||||
if (beta>=1) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_E_eV_from_v_ms(): Input speed v="<<v_ms<<" m/s equal or exeeds speed of light.";
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_E_eV_from_v_ms(): Input speed v="<<v_ms<<" m/s is expected to be absolute value therfore >0.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double gamma = calc_gamma_from_beta(beta);
|
||||
if (gamma == 1) {
|
||||
return 0.5*beta*beta*m_eV;
|
||||
} else {
|
||||
return (gamma-1) * m_eV;
|
||||
}
|
||||
*/
|
||||
return 0.5*v_ms/c_ms*v_ms/c_ms*m_eV;
|
||||
return m_eV/2 * pow(v_ms/c_ms,2);
|
||||
}
|
||||
|
||||
inline double calc_E_eV_from_v_ms(const vec3 &v_ms, const double &m_eV) {
|
||||
return calc_E_eV_from_v_ms(calc_vec3_abs(v_ms), m_eV);
|
||||
}
|
||||
|
||||
/*
|
||||
inline double calc_beta_from_gamma(const double &gamma) {
|
||||
|
||||
if (gamma<1) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_beta_from_gamma(): Input gamma ="<<gamma<<" smaller 1.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return sqrt(1 - pow(gamma,-2));
|
||||
|
||||
}
|
||||
|
||||
inline double calc_gamma_from_E_eV(const double &E_eV, const double &m_eV) {
|
||||
|
||||
if (E_eV<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_gamma_from_E_eV(): Input E_eV ="<<E_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return 1 + E_eV/m_eV;
|
||||
|
||||
}
|
||||
|
||||
inline double calc_beta_from_E_eV(const double &E_eV, const double &m_eV) {
|
||||
|
||||
return calc_beta_from_gamma(calc_gamma_from_E_eV(E_eV, m_eV));
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
inline double calc_v_ms_from_E_eV(const double &E_eV, const double &m_eV) {
|
||||
/*
|
||||
if (E_eV<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_v_ms_from_E_eV(): Input E_eV ="<<E_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
double gamma = calc_gamma_from_E_eV(E_eV, m_eV);
|
||||
double beta = calc_beta_from_gamma(gamma);
|
||||
if (beta == 0) {
|
||||
return sqrt(2*E_eV/m_eV) * c_ms;
|
||||
} else {
|
||||
return beta*c_ms;
|
||||
}
|
||||
*/
|
||||
return sqrt(2*E_eV/m_eV) * c_ms;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Kinetic_Population : public Population_Base, private RNG_Base {
|
||||
double m_eV;
|
||||
|
||||
public:
|
||||
Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
||||
Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
inline Kinetic_Population::Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins) {
|
||||
inline Kinetic_Population::Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV) {
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
};
|
||||
|
||||
@@ -13,17 +13,22 @@
|
||||
|
||||
#include "tritium2_population.h"
|
||||
|
||||
const int Population_Builder::POP_N_R = load_parameter("POP_N_R");
|
||||
const int Population_Builder::POP_N_PHI = load_parameter("POP_N_PHI");
|
||||
const int Population_Builder::POP_N_Z = load_parameter("POP_N_Z");
|
||||
const int Population_Builder::POP_N_E = load_parameter("POP_N_E");
|
||||
const double Population_Builder::POP_E_START = load_parameter("POP_E_START");
|
||||
|
||||
const double Population_Builder::wgtsTemp_K = load_parameter("TEMP");
|
||||
const int Population_Builder::v_flow = load_parameter("T2_VELO");
|
||||
|
||||
Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
Population_Manager Populations;
|
||||
int num_z_bins = 13;
|
||||
int num_r_bins = 5;
|
||||
int num_phi_bins = 1;
|
||||
int num_E_bins = 50;
|
||||
Populations.add(new Kinetic_Population(electron, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins));
|
||||
int num_z_bins = POP_N_Z;
|
||||
int num_r_bins = POP_N_R;
|
||||
int num_phi_bins = POP_N_PHI;
|
||||
int num_E_bins = POP_N_E;
|
||||
Populations.add(new Kinetic_Population(electron, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
if (v_flow == -1) {
|
||||
Populations.add(new Thermal_Population(tritium, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritiumI, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
typedef Manager_Base<Population_Base> Population_Manager;
|
||||
|
||||
class Population_Builder {
|
||||
static const int POP_N_R;
|
||||
static const int POP_N_PHI;
|
||||
static const int POP_N_Z;
|
||||
static const int POP_N_E;
|
||||
static const double POP_E_START;
|
||||
static const double wgtsTemp_K;
|
||||
static const int v_flow;
|
||||
public:
|
||||
|
||||
@@ -13,13 +13,15 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
Population_Container::Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) {
|
||||
init_scales(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
||||
Population_Container::Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV) {
|
||||
init_scales(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV);
|
||||
init_bin_offsets();
|
||||
init_content_arrays();
|
||||
init_size_array();
|
||||
}
|
||||
|
||||
Population_Container::Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) : Population_Container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, 1e-7) {}
|
||||
|
||||
Population_Container::~Population_Container() {
|
||||
delete[] cum_times_s;
|
||||
delete[] offsets;
|
||||
@@ -50,11 +52,11 @@ Population_Container &Population_Container::operator=(const Population_Container
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Population_Container::init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) {
|
||||
void Population_Container::init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV) {
|
||||
scales.z = Lin_Scale(z_RW_m, z_WGTS_end_m, num_z_bins);
|
||||
scales.r = Lin_Scale(0,r_WGTS_m, num_r_bins);
|
||||
scales.phi = Lin_Scale(0, 2*pi, num_phi_bins);
|
||||
E_scale = Log_Scale(scale_start, scale_end, num_E_bins);
|
||||
E_scale = Log_Scale(E_min_eV, scale_end, num_E_bins);
|
||||
}
|
||||
|
||||
void Population_Container::init_bin_offsets() {
|
||||
|
||||
@@ -54,12 +54,13 @@ class Population_Container {
|
||||
double *size_data_m3;
|
||||
|
||||
public:
|
||||
Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV);
|
||||
Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
||||
~Population_Container();
|
||||
Population_Container(const Population_Container& other);
|
||||
Population_Container& operator=(const Population_Container& other);
|
||||
private:
|
||||
void init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
||||
void init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV);
|
||||
void init_bin_offsets();
|
||||
void init_content_arrays();
|
||||
void init_size_array();
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
//
|
||||
// precomputed_interaction_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef precomputed_interaction_base_h
|
||||
#define precomputed_interaction_base_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "log_scale.h"
|
||||
|
||||
|
||||
class e_thermal_Precomputed_Interaction_Base : public e_thermal_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations
|
||||
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(1e-6, 1e-1, 1e5) {
|
||||
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 = m_eV/2*pow(v_ms/c_ms, 2); // 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);
|
||||
}
|
||||
|
||||
|
||||
class TI_thermal_binary_Precomputed_Interaction_Base : public TI_thermal_binary_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
TI_thermal_binary_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_binary_Interaction_Base(Population, rngUni, m_eV), E_scale(1e-6, 1e-1, 1e5) {
|
||||
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_binary_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 TI_thermal_binary_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 = m_eV/2*pow(v_ms/c_ms, 2); // 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_binary_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);
|
||||
}
|
||||
|
||||
|
||||
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(1e-6, 1e-1, 1e5) {
|
||||
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; i<E_scale.get_number_bins(); i++) {
|
||||
precomputed_values[i] = calc_microSigma_divbyn_m2(E_scale.get_bin_mid(i));
|
||||
}
|
||||
}
|
||||
|
||||
inline double TI_thermal_tenary_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 = m_eV/2*pow(v_ms/c_ms, 2); // 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);
|
||||
}
|
||||
|
||||
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 mI_eV) : TI_e_Interaction_Base(Population, rngUni, mI_eV), E_scale(1e-6, 1e-1, 1e5) {
|
||||
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 /* precomputed_interaction_base_h */
|
||||
@@ -1,263 +0,0 @@
|
||||
//
|
||||
// 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 <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "population_base.h"
|
||||
|
||||
#include "constants.h"
|
||||
#include "integrater.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 Interaction_Base {
|
||||
protected:
|
||||
Population_Base *Population;
|
||||
UniRNG *rngUni;
|
||||
public:
|
||||
Interaction_Base(Population_Base *Population, UniRNG *rngUni) {
|
||||
this->Population = Population;
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
virtual double get_macro_sigma_m(const Particle &interPart) = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||
};
|
||||
|
||||
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double E_limit;
|
||||
|
||||
double m_eV; // energy of kinetic particle for CS measurement : e-
|
||||
double mI_eV; // energy of massic initial particle : TI
|
||||
|
||||
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.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
mI_eV = Population->get_m_eV();
|
||||
v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||
E_limit = m_eV/2*pow(v_therm/c_ms * 2000, 2);
|
||||
}
|
||||
|
||||
double 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 = m_eV/2*pow(v_ms/c_ms, 2); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
|
||||
protected:
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
double calc_microSigma_m2(const double &E_eV) {
|
||||
if (E_eV > E_limit) { // 0.005 represents 1% variation in energy
|
||||
return get_microSigma_m2(E_eV);
|
||||
} else {
|
||||
double v1_ms = sqrt(2*E_eV/mI_eV)*c_ms;
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m_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, 30, simpson())/pi;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 get_vOff_ms(const Particle &interPart, const double &minE_eV) { // Implemented for derived classes
|
||||
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<<"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 TI_thermal_binary_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double m_eV; // energy of kinetic particle for CS measurement : TI
|
||||
double m2_eV; // energy of massic initial particle : T2
|
||||
double v_therm; // typical spped for thermal population
|
||||
|
||||
public:
|
||||
TI_thermal_binary_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.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
m2_eV = Population->get_m_eV();
|
||||
v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||
}
|
||||
|
||||
double 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 = m_eV/2*pow(v_ms/c_ms, 2); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
|
||||
protected:
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
double calc_microSigma_m2(const double &E_eV) {
|
||||
double v1_ms = sqrt(2*E_eV/m2_eV)*c_ms;
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m_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, 30, simpson())/pi;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TI_thermal_tenary_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double m_eV; // energy of kinetic particle for CS measurement : TI
|
||||
double m2_eV; // energy of massic initial particle : T2
|
||||
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.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
m2_eV = Population->get_m_eV();
|
||||
v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||
}
|
||||
|
||||
double 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 = m_eV/2*pow(v_ms/c_ms, 2); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
private:
|
||||
virtual double get_microSigma_divbyn_m2(const double &E_eV) = 0;
|
||||
|
||||
protected:
|
||||
double 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);
|
||||
}
|
||||
|
||||
double calc_microSigma_divbyn_m2(const double &E_eV) {
|
||||
double v1_ms = sqrt(2*E_eV/m2_eV)*c_ms;
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_divbyn_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, 0., pi, 30, simpson())/pi;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TI_e_Interaction_Base : public Interaction_Base { // Interactions of ions with kinetic e Populations
|
||||
protected:
|
||||
double m_eV; // energy of kinetic particle for CS measurement : e-
|
||||
double mI_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 mI_eV) : Interaction_Base(Population, rngUni) {
|
||||
m_eV = Population->get_m_eV();
|
||||
this->mI_eV = mI_eV;
|
||||
|
||||
num_Ee_bins = Population->get_number_E_bins();
|
||||
if (num_Ee_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when kinetic thermal.");
|
||||
}
|
||||
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] = sqrt(2*Ee_mids[Ee_bin]/m_eV)*c_ms;
|
||||
}
|
||||
}
|
||||
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
protected:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
|
||||
double 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;
|
||||
}
|
||||
|
||||
double calc_microSigma_m2(const double &E1_eV, const int &Ee_bin) {
|
||||
double v1_ms = sqrt(2*E1_eV/mI_eV)*c_ms;
|
||||
double v2_ms = ve_mids[Ee_bin];
|
||||
|
||||
if (v2_ms*0.005 > v1_ms) { // 0.005 represents 1% variation in energy
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]); // location is dummy again...
|
||||
} else {
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV); // location is dummy again...
|
||||
};
|
||||
return integrate(integrand, 0., pi, 30, simpson())/pi;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* sub_interaction_base_h */
|
||||
Reference in New Issue
Block a user