Merge branch 'reiling-development'
Commit KARL code, version as used for results in thesis
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -93,3 +93,16 @@ double BED_eT2_Ionization::calc_Dt(const double &t) {
|
||||
return res;
|
||||
}
|
||||
|
||||
double BED_eT2_Ionization::roll_W_eV(const double &T_eV, UniRNG *rngUni) {
|
||||
double pmax, Wmin_eV, Wmax_eV, Wcan_eV, eta1, eta2;
|
||||
Wmin_eV = 1e-5; // Properly fix this...
|
||||
Wmax_eV = T_eV-EionT2_eV;
|
||||
pmax =calc_SDCS(T_eV, Wmin_eV);
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Wcan_eV = Wmin_eV + eta1*(Wmax_eV - Wmin_eV);
|
||||
} while(eta2*pmax > calc_SDCS(T_eV, Wcan_eV));
|
||||
double W_eV = (Wcan_eV< (T_eV-EionT2_eV)/2 ) ? Wcan_eV : (T_eV-EionT2_eV) - Wcan_eV;
|
||||
return W_eV;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef BED_eT2_ionization_hpp
|
||||
#define BED_eT2_ionization_hpp
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
// BED Ionization model from Kim, Y.-K. and Rudd, M. E. 1994
|
||||
class BED_eT2_Ionization {
|
||||
@@ -24,12 +25,14 @@ public:
|
||||
static double calc_TCS(const double &T_eV);
|
||||
static double calc_SDCS(const double &T_eV, const double &W_eV);
|
||||
|
||||
static double roll_W_eV(const double &T_eV, UniRNG *rngUni);
|
||||
private:
|
||||
static double calc_t(const double &T);
|
||||
static double calc_w(const double &W);
|
||||
|
||||
static double calc_dfdw(const double &w);
|
||||
static double calc_Dt(const double &t);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -9,25 +9,25 @@
|
||||
#ifndef T2IT2_cluster_h
|
||||
#define T2IT2_cluster_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "janev_T2IT2_cluster.h"
|
||||
|
||||
|
||||
class T2IT2_Cluster : public Sub_Interaction_Base {
|
||||
class T2IT2_Cluster : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T2IT2_Cluster(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {}
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_T2IT2_Cluster::get_TCS(E_eV);}
|
||||
T2IT2_Cluster(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_T2IT2_Cluster::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut T2IT2_Cluster::do_Interaction (Particle *interPart) {
|
||||
InteractionOut InterOut;
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
vec3 vLab_ms = interPart->get_v_ms() - v2_ms;
|
||||
//vec3 v1_ms = roll_uniform_direction(rngUni) * calc_vec3_abs(vLab_ms) + v2_ms;
|
||||
//Particle TNew = Particle_Builder::create_T(loc_m, v1_ms, -1, interPart->get_Id());
|
||||
Particle T3New = Particle_Builder::create_T3I(loc_m, v2_ms, -1, interPart->get_Id());
|
||||
vec3 v_ms = interPart->get_v_ms();
|
||||
Particle T3New = Particle_Builder::create_T3I(loc_m, v_ms, -1, interPart->get_Id());
|
||||
|
||||
//InterOut.add_new_particle(TNew);
|
||||
InterOut.add_new_particle(T3New);
|
||||
|
||||
@@ -9,16 +9,18 @@
|
||||
#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"
|
||||
|
||||
|
||||
class T2IT2_CX : public Sub_Interaction_Base {
|
||||
class T2IT2_CX : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
public:
|
||||
T2IT2_CX(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni), kinematics(2*mT_eV, 2*mT_eV) {}
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_T2IT2_CX::get_TCS(E_eV);}
|
||||
T2IT2_CX(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 2*mT_eV), kinematics(2*mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_T2IT2_CX::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
#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 Sub_Interaction_Base {
|
||||
|
||||
class T2Ie_DissExc : public Interaction_Base {
|
||||
public:
|
||||
T2Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||
T2Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Interaction_Base(ePopulation, rngUni) {}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_eT2I_DissExc::get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT2I_DissExc::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -30,8 +31,8 @@ inline InteractionOut T2Ie_DissExc::do_Interaction (Particle *interPart) {
|
||||
vec3 vTI_ms = interPart->get_v_ms();
|
||||
Particle TI = Particle_Builder::create_TI(loc_m, vTI_ms, -1, interPart->get_Id());
|
||||
res.add_new_particle(TI);
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
//Population->decrease_denisty(loc_m, E_eV);
|
||||
/*double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(loc_m, E_eV);*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,26 +9,29 @@
|
||||
#ifndef T2Ie_recombination_h
|
||||
#define T2Ie_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT2I_recombination.h"
|
||||
|
||||
class T2Ie_Recombination : public Sub_Interaction_Base {
|
||||
|
||||
class T2Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut T2Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
/*
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
#ifndef T3IT2_elastic_h
|
||||
#define T3IT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "tabata_T3IT2_elastic.h"
|
||||
|
||||
|
||||
class T3IT2_Elastic : public Sub_Interaction_Base {
|
||||
class T3IT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_T3IT2_Elastic tcs_gen;
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
T3IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni), kinematics(3*mT_eV, 2*mT_eV) {};
|
||||
T3IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 3*mT_eV), kinematics(3*mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return tcs_gen.get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_gen.get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
#ifndef T3IT2_radasc_h
|
||||
#define T3IT2_radasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Gerlich:
|
||||
#include "TI_rate_base.h"
|
||||
|
||||
class T3IT2_RadAsc : public Sub_Interaction_Base {
|
||||
|
||||
class T3IT2_RadAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||
|
||||
public:
|
||||
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 1) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
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);
|
||||
};
|
||||
@@ -27,8 +29,8 @@ public:
|
||||
inline InteractionOut T3IT2_RadAsc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut InterOut;
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
Particle T5INew = Particle_Builder::create_T5I(loc_m, v2_ms, -1, interPart->get_Id());
|
||||
vec3 v_ms = interPart->get_v_ms();
|
||||
Particle T5INew = Particle_Builder::create_T5I(loc_m, v_ms, -1, interPart->get_Id());
|
||||
|
||||
InterOut.add_new_particle(T5INew);
|
||||
InterOut.set_delete_current(true);
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
#ifndef T3IT2_terasc_h
|
||||
#define T3IT2_terasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Gerlich:
|
||||
#include "TI_rate_base.h"
|
||||
|
||||
class T3IT2_TerAsc : public Sub_Interaction_Base {
|
||||
|
||||
class T3IT2_TerAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||
|
||||
public:
|
||||
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 2) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, 3*mT_eV);
|
||||
return 7e-41*Population->get_density_m3(loc_m)/v_ms;
|
||||
return 7e-41*v_ms; // CS from Gerlich:1990aa
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
@@ -27,8 +29,8 @@ public:
|
||||
inline InteractionOut T3IT2_TerAsc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut InterOut;
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
Particle T5INew = Particle_Builder::create_T5I(loc_m, v2_ms, -1, interPart->get_Id());
|
||||
vec3 v_ms = interPart->get_v_ms();
|
||||
Particle T5INew = Particle_Builder::create_T5I(loc_m, v_ms, -1, interPart->get_Id());
|
||||
|
||||
InterOut.add_new_particle(T5INew);
|
||||
InterOut.set_delete_current(true);
|
||||
|
||||
@@ -9,14 +9,16 @@
|
||||
#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 Sub_Interaction_Base {
|
||||
|
||||
class T3Ie_DissExc : public Interaction_Base {
|
||||
public:
|
||||
T3Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||
T3Ie_DissExc(Population_Base *ePopulation, UniRNG *rngUni) : Interaction_Base(ePopulation, rngUni) {}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_eT3I_DissExc::get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT3I_DissExc::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -30,7 +32,7 @@ inline InteractionOut T3Ie_DissExc::do_Interaction (Particle *interPart) {
|
||||
Particle TI = Particle_Builder::create_TI(loc_m, vTI_ms, -1, interPart->get_Id());
|
||||
res.add_new_particle(TI);
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
//Population->decrease_denisty(loc_m, E_eV);
|
||||
Population->decrease_denisty(loc_m, E_eV);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,25 +9,29 @@
|
||||
#ifndef T3Ie_recombination_h
|
||||
#define T3Ie_recombination_h
|
||||
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
|
||||
class T3Ie_Recombination : public Sub_Interaction_Base {
|
||||
|
||||
class T3Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 3*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT3I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut T3Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
/*
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,18 @@
|
||||
#ifndef T5IT2_elastic_h
|
||||
#define T5IT2_elastic_h
|
||||
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
class T5IT2_Elastic : public Sub_Interaction_Base {
|
||||
class T5IT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_T3IT2_Elastic tcs_gen; // Obviously wrong, but should be good enough.
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
T5IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni), kinematics(5*mT_eV, 2*mT_eV) {};
|
||||
T5IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 5*mT_eV), kinematics(5*mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return tcs_gen.get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_gen.get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,29 +9,32 @@
|
||||
#ifndef T5Ie_recombination_h
|
||||
#define T5Ie_recombination_h
|
||||
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "petterson_eT5I_recombination.h"
|
||||
|
||||
class T5Ie_Recombination : public Sub_Interaction_Base {
|
||||
|
||||
class T5Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T5Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
T5Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 5*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Pettersson_eT5I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline InteractionOut T5Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
/*
|
||||
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,19 +9,21 @@
|
||||
#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"
|
||||
|
||||
|
||||
class TIT2_Elastic : public Sub_Interaction_Base {
|
||||
class TIT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_TIT2_Elastic tcs_gen;
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
TIT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni), kinematics(mT_eV, 2*mT_eV) {};
|
||||
TIT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, mT_eV), kinematics(mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return tcs_gen.get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_gen.get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,17 +9,18 @@
|
||||
#ifndef TIT2_radasc_h
|
||||
#define TIT2_radasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Plasil:2012
|
||||
#include "TI_rate_base.h"
|
||||
|
||||
class TIT2_RadAsc : public Sub_Interaction_Base {
|
||||
class TIT2_RadAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||
|
||||
public:
|
||||
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 1) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
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);
|
||||
};
|
||||
@@ -27,8 +28,8 @@ public:
|
||||
inline InteractionOut TIT2_RadAsc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut InterOut;
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
Particle T3INew = Particle_Builder::create_T3I(loc_m, v2_ms, -1, interPart->get_Id());
|
||||
vec3 v_ms = interPart->get_v_ms();
|
||||
Particle T3INew = Particle_Builder::create_T3I(loc_m, v_ms, -1, interPart->get_Id());
|
||||
|
||||
InterOut.add_new_particle(T3INew);
|
||||
InterOut.set_delete_current(true);
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
#ifndef TIT2_terasc_h
|
||||
#define TIT2_terasc_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
// CS from Plasil:2012
|
||||
#include "TI_rate_base.h"
|
||||
|
||||
class TIT2_TerAsc : public Sub_Interaction_Base {
|
||||
|
||||
class TIT2_TerAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||
|
||||
public:
|
||||
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 2) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
double v_ms = calc_v_ms_from_E_eV(E_eV, mT_eV);
|
||||
return 2.6e-41*Population->get_density_m3(loc_m)/v_ms;
|
||||
return 2.6e-41/v_ms; // CS from Plasil:2012
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
@@ -27,8 +29,8 @@ public:
|
||||
inline InteractionOut TIT2_TerAsc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut InterOut;
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
Particle T3INew = Particle_Builder::create_T3I(loc_m, v2_ms, -1, interPart->get_Id());
|
||||
vec3 v_ms = interPart->get_v_ms();
|
||||
Particle T3INew = Particle_Builder::create_T3I(loc_m, v_ms, -1, interPart->get_Id());
|
||||
|
||||
InterOut.add_new_particle(T3INew);
|
||||
InterOut.set_delete_current(true);
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// 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) {
|
||||
//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);
|
||||
|
||||
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, 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,80 @@
|
||||
//
|
||||
// TI_rate_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TI_rate_base_h
|
||||
#define TI_rate_base_h
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
|
||||
class TI_thermal_Rate_Interaction_Base : public Interaction_Base { // Binary interactions of tritium ions with thermal Populations
|
||||
protected:
|
||||
int n;
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : tritium ion
|
||||
|
||||
public:
|
||||
TI_thermal_Rate_Interaction_Base(Population_Base *Population, UniRNG *rngUni, int n) : Interaction_Base(Population, rngUni) {
|
||||
this-> n = n;
|
||||
}
|
||||
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_Rate_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
|
||||
double TI_thermal_Rate_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
return calc_microSigma_m2(E_eV) * pow (Population->get_density_m3(loc_m), n);
|
||||
}
|
||||
double TI_thermal_Rate_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||
return get_microSigma_m2(E_eV);
|
||||
}
|
||||
|
||||
|
||||
class TI_thermal_Rate_Precomputed_Interaction_Base : public TI_thermal_Rate_Interaction_Base { // + Using precomputed values
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
TI_thermal_Rate_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_Rate_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_Rate_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_Rate_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_thermal_Rate_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), n);
|
||||
}
|
||||
|
||||
#endif /* TI_rate_base_h */
|
||||
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// 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);
|
||||
// Integration over theta and v
|
||||
auto integrand = [&](double v2_ms, 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 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);
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N, 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_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
inline double TI_thermal_tenary_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
|
||||
inline double TI_thermal_tenary_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
return calc_microSigma_divbyn_m2(E_eV)*pow(Population->get_density_m3(loc_m), 2);
|
||||
}
|
||||
|
||||
inline double TI_thermal_tenary_Interaction_Base::calc_microSigma_divbyn_m2(const double &E_eV) {
|
||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
}
|
||||
|
||||
class TI_thermal_tenary_Precomputed_Interaction_Base : public TI_thermal_tenary_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
TI_thermal_tenary_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_tenary_Interaction_Base(Population, rngUni, m_eV), E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N) {
|
||||
precomputed_values = new double [E_scale.get_number_bins()];
|
||||
}
|
||||
void calc_values(); // must be called by derived class, can't call in this constructor, due to virtual pure
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
private:
|
||||
double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
};
|
||||
|
||||
inline void TI_thermal_tenary_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int i=0; 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 */
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "katrin_geo.h"
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -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 = load_parameter("INT_N"); // 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 */
|
||||
|
||||
@@ -70,9 +70,9 @@ void DCS_Ionization_Container::calc_data(std::string load_path) {
|
||||
int num_W_bins = W_scale[0].get_number_bins();
|
||||
double *temp;
|
||||
double sum;
|
||||
double E_eV;
|
||||
//double E_eV;
|
||||
for (int i = 0; i<num_T_bins; i++) {
|
||||
E_eV = T_scale.get_bin_mid(i);
|
||||
//E_eV = T_scale.get_bin_mid(i);
|
||||
temp = new double[num_W_bins];
|
||||
sum = 0;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void DCS_Theta_Container::calc_data(std::string load_path) {
|
||||
double sum;
|
||||
double E_eV;
|
||||
for (int i = 0; i<number_E_bins; i++) {
|
||||
E_eV = E_scale.get_bin_mid(i);
|
||||
//E_eV = E_scale.get_bin_mid(i);
|
||||
temp = new double[number_theta_bins];
|
||||
sum = 0;
|
||||
|
||||
|
||||
@@ -17,30 +17,30 @@ class Drift_Base : public Mover_Base {
|
||||
public:
|
||||
Drift_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
||||
|
||||
void move(Particle *movePart, const double ¯oSigma_m);
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
|
||||
protected:
|
||||
double get_zNew_m(Particle *movePart, const double ¯oSigma_m);
|
||||
double get_zNew_m(Particle *movePart, const double ¯o_sigma_m);
|
||||
virtual void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) = 0;
|
||||
virtual void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m) = 0;
|
||||
virtual void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) = 0;
|
||||
|
||||
};
|
||||
|
||||
inline void Drift_Base::move(Particle *movePart, const double ¯oSigma_m) {
|
||||
inline void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
double znew_m = get_zNew_m(movePart, macroSigma_m);
|
||||
double znew_m = get_zNew_m(movePart, macro_sigma_m);
|
||||
doWallInteraction(movePart, &oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
movePart->set_x_m(newLoc_m);
|
||||
do_E_calculus(movePart, oldLoc_m, macroSigma_m);
|
||||
do_E_calculus(movePart, oldLoc_m, macro_sigma_m);
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
}
|
||||
|
||||
inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯oSigma_m) {
|
||||
inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sigma_m) {
|
||||
double zold_m = movePart->get_x_m()[2];
|
||||
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
@@ -48,14 +48,14 @@ inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯oSigm
|
||||
double vForwardAbs_ms = calc_vec3_abs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] <= 0 ? -1 : 1;
|
||||
double znew_m;
|
||||
if (macroSigma_m == 0) {
|
||||
if (macro_sigma_m == 0) {
|
||||
if (zDir == -1) {
|
||||
znew_m = z_RW_m - 2*l_WGTS_m;
|
||||
} else {
|
||||
znew_m = z_WGTS_end_m + 2*l_WGTS_m;
|
||||
}
|
||||
} else {
|
||||
double distance_m = 1/macroSigma_m;
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
}
|
||||
return znew_m;
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
#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 {
|
||||
public:
|
||||
eT2I_DissExc(Population_Base *T2IPopulation, UniRNG *rngUni, DCS_Base *dcs_gen) : Excitation_Base(T2IPopulation, rngUni, Janev_eT2I_DissExc::get_deltaE_eV(), dcs_gen) {}
|
||||
eT2I_DissExc(Population_Base *T2IPopulation, UniRNG *rngUni, DCS_Base *dcs_gen) : Excitation_Base(T2IPopulation, rngUni, me_eV, Janev_eT2I_DissExc::get_deltaE_eV(), dcs_gen) {}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_eT2I_DissExc::get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT2I_DissExc::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -25,11 +26,11 @@ inline InteractionOut eT2I_DissExc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res = Excitation_Base::do_Interaction(interPart);
|
||||
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
//Population->decrease_denisty(interPart->get_x_m(), 0); // dummy since thermal population
|
||||
|
||||
vec3 vTI_ms = Population->roll_v_ms(loc_m);
|
||||
Particle TI = Particle_Builder::create_TI(loc_m, vTI_ms, -1, interPart->get_Id());
|
||||
res.add_new_particle(TI);
|
||||
//Population->decrease_denisty(interPart->get_x_m(), 0); // dummy since thermal population
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
#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 Sub_Interaction_Base {
|
||||
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
public:
|
||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : Sub_Interaction_Base(T2IPopulation, rngUni) {}
|
||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#ifndef eT2_elastic_h
|
||||
#define eT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_theta_container.hpp"
|
||||
@@ -17,19 +19,22 @@
|
||||
#include "dcs_base.h"
|
||||
|
||||
|
||||
class eT2_Elastic : public Sub_Interaction_Base {
|
||||
class eT2_Elastic : public e_thermal_Precomputed_Interaction_Base {
|
||||
TCS_Container tcs_data;
|
||||
DCS_Base *dcs_gen;
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
eT2_Elastic(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen) : Sub_Interaction_Base(T2Population, rngUni),
|
||||
eT2_Elastic(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen) : e_thermal_Precomputed_Interaction_Base(T2Population, rngUni, me_eV),
|
||||
tcs_data(scale_start, scale_end, 1e3, get_data_path() + "eT2_ela_TCS.dat"),
|
||||
kinematics(me_eV, 2*mT_eV) {
|
||||
this->dcs_gen = dcs_gen;
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return tcs_data.get_value(E_eV);}
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
return e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_data.get_value(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,15 +9,18 @@
|
||||
#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:
|
||||
eT2_ElExc_Nu_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_Nu janev_Nu_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, janev_Nu_in.get_deltaE_eV(), dcs_gen), janev_Nu(janev_Nu_in) {};
|
||||
eT2_ElExc_Nu_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_Nu janev_Nu_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, me_eV, janev_Nu_in.get_deltaE_eV(), dcs_gen), janev_Nu(janev_Nu_in) {};
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return janev_Nu.get_TCS_m2(E_eV);
|
||||
}
|
||||
};
|
||||
@@ -26,10 +29,10 @@ private:
|
||||
class eT2_ElExc_Ng_Analytic : public Excitation_Base {
|
||||
Janev_eT2_ElExc_Ng janev_Ng;
|
||||
public:
|
||||
eT2_ElExc_Ng_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_Ng janev_Ng_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, janev_Ng_in.get_deltaE_eV(), dcs_gen), janev_Ng(janev_Ng_in) {};
|
||||
eT2_ElExc_Ng_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_Ng janev_Ng_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, me_eV, janev_Ng_in.get_deltaE_eV(), dcs_gen), janev_Ng(janev_Ng_in) {};
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return janev_Ng.get_TCS_m2(E_eV);
|
||||
}
|
||||
};
|
||||
@@ -38,10 +41,10 @@ private:
|
||||
class eT2_ElExc_n_Analytic : public Excitation_Base {
|
||||
Janev_eT2_ElExc_n janev_n;
|
||||
public:
|
||||
eT2_ElExc_n_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_n janev_n_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, janev_n_in.get_deltaE_eV(), dcs_gen), janev_n(janev_n_in) {};
|
||||
eT2_ElExc_n_Analytic(Population_Base *T2Population, UniRNG *rngUni, Janev_eT2_ElExc_n janev_n_in, DCS_Base *dcs_gen) : Excitation_Base(T2Population, rngUni, me_eV, janev_n_in.get_deltaE_eV(), dcs_gen), janev_n(janev_n_in) {};
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return janev_n.get_TCS_m2(E_eV);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -19,15 +20,22 @@
|
||||
Ionization:
|
||||
Using BED-Model Kim and Rudd 1994
|
||||
*/
|
||||
class eT2_Ionization_Base : public Sub_Interaction_Base {
|
||||
class eT2_Ionization_Base : public e_thermal_Interaction_Base {
|
||||
double deltaE_eV;
|
||||
public:
|
||||
eT2_Ionization_Base(Population_Base *T2Population, UniRNG *rngUni, double deltaE_eV) : Sub_Interaction_Base(T2Population, rngUni){
|
||||
eT2_Ionization_Base(Population_Base *T2Population, UniRNG *rngUni, double deltaE_eV) : e_thermal_Interaction_Base(T2Population, rngUni, me_eV){
|
||||
this->deltaE_eV = deltaE_eV;
|
||||
};
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
if (interPart.get_E_eV() < deltaE_eV) {
|
||||
return 0;
|
||||
} else {
|
||||
return e_thermal_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) = 0;
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
public:
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
@@ -121,9 +129,6 @@ class eT2_Ionization_BED_Base : public eT2_Ionization_Base {
|
||||
public:
|
||||
eT2_Ionization_BED_Base(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, EionT2_eV){};
|
||||
|
||||
protected:
|
||||
//virtual double get_microSigma_m2(const double &T_eV) = 0;
|
||||
|
||||
protected:
|
||||
void add_Tritiums(InteractionOut *InterOut, const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
@@ -139,60 +144,48 @@ public:
|
||||
eT2_Ionization_BED_Analytic(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_BED_Base(T2Population, rngUni) {};
|
||||
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return BED_eT2_Ionization::calc_TCS(E_eV);
|
||||
}
|
||||
double roll_ionW_eV(const double &T_eV) {
|
||||
double pmax, Wmin_eV, Wmax_eV, Wcan_eV,eta1,eta2;
|
||||
pmax = BED_eT2_Ionization::calc_TCS(T_eV);
|
||||
Wmin_eV = 0;
|
||||
Wmax_eV = T_eV-EionT2_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Wcan_eV = Wmin_eV + eta1*(Wmax_eV - Wmin_eV);
|
||||
} while(eta2*pmax > BED_eT2_Ionization::calc_SDCS(T_eV, Wcan_eV));
|
||||
double W_eV = (Wcan_eV< (T_eV-EionT2_eV)/2 ) ? Wcan_eV : (T_eV-EionT2_eV) - Wcan_eV;
|
||||
return W_eV;
|
||||
return BED_eT2_Ionization::roll_W_eV(T_eV, rngUni);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class eT2_Ionization_BED_Container : public eT2_Ionization_BED_Base {
|
||||
TCS_Container tcs_data;
|
||||
DCS_Ionization_Container dcs_data;
|
||||
//DCS_Ionization_Container dcs_data; //BUGGY
|
||||
|
||||
public:
|
||||
eT2_Ionization_BED_Container(Population_Base *T2Population, UniRNG *rngUni) :
|
||||
eT2_Ionization_BED_Base(T2Population, rngUni),
|
||||
tcs_data(scale_start, scale_end, 100, (get_data_path() + "eT2_ion_TCS.dat")),
|
||||
dcs_data(EionT2_eV, scale_end, 100, 50, (get_data_path() + "eT2_ion_DCS.dat"))
|
||||
tcs_data(scale_start, scale_end, 100, (get_data_path() + "eT2_ion_TCS.dat"))
|
||||
//dcs_data(EionT2_eV, scale_end, 100, 50, (get_data_path() + "eT2_ion_DCS.dat"))
|
||||
{};
|
||||
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return tcs_data.get_value(E_eV);
|
||||
}
|
||||
double roll_ionW_eV(const double &T_eV) {
|
||||
return dcs_data.roll_value(T_eV, rngUni);
|
||||
return BED_eT2_Ionization::roll_W_eV(T_eV, rngUni); //dcs_data.roll_value(T_eV, rngUni);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Not very fancy from here. Either one function for all 3 or base class with dcs_data, genereally only load the data once.
|
||||
class eT2_Ionization_Janev_ndiss : public eT2_Ionization_Base {
|
||||
DCS_Ionization_Container dcs_data;
|
||||
|
||||
public:
|
||||
eT2_Ionization_Janev_ndiss(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_ndiss::get_deltaE_eV()), dcs_data(Janev_eT2_Ionization_ndiss::get_deltaE_eV(), scale_end, 100, 50, (get_data_path() + "eT2_ion_DCS.dat")) {};
|
||||
eT2_Ionization_Janev_ndiss(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_ndiss::get_deltaE_eV()) {};
|
||||
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2_Ionization_ndiss::get_TCS_m2(E_eV);
|
||||
}
|
||||
|
||||
double roll_ionW_eV(const double &T_eV) {
|
||||
return dcs_data.roll_value(T_eV, rngUni);
|
||||
return BED_eT2_Ionization::roll_W_eV(T_eV, rngUni); //dcs_data.roll_value(T_eV, rngUni);
|
||||
}
|
||||
|
||||
void add_Tritiums(InteractionOut *InterOut, const Particle &interPart) {
|
||||
@@ -205,18 +198,17 @@ protected:
|
||||
|
||||
|
||||
class eT2_Ionization_Janev_diss_g : public eT2_Ionization_Base {
|
||||
DCS_Ionization_Container dcs_data;
|
||||
|
||||
public:
|
||||
eT2_Ionization_Janev_diss_g(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_diss_g::get_deltaE_eV()), dcs_data(Janev_eT2_Ionization_diss_g::get_deltaE_eV(), scale_end, 100, 50, (get_data_path() + "eT2_ion_DCS.dat")) {};
|
||||
eT2_Ionization_Janev_diss_g(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_diss_g::get_deltaE_eV()) {};
|
||||
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2_Ionization_diss_g::get_TCS_m2(E_eV);
|
||||
}
|
||||
|
||||
double roll_ionW_eV(const double &T_eV) {
|
||||
return dcs_data.roll_value(T_eV, rngUni);
|
||||
return BED_eT2_Ionization::roll_W_eV(T_eV, rngUni); //dcs_data.roll_value(T_eV, rngUni);
|
||||
}
|
||||
|
||||
void add_Tritiums(InteractionOut *InterOut, const Particle &interPart) {
|
||||
@@ -234,18 +226,16 @@ protected:
|
||||
|
||||
|
||||
class eT2_Ionization_Janev_diss_u : public eT2_Ionization_Base {
|
||||
DCS_Ionization_Container dcs_data;
|
||||
|
||||
public:
|
||||
eT2_Ionization_Janev_diss_u(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_diss_u::get_deltaE_eV()), dcs_data(Janev_eT2_Ionization_diss_u::get_deltaE_eV(), scale_end, 100, 50, (get_data_path() + "eT2_ion_DCS.dat")) {};
|
||||
eT2_Ionization_Janev_diss_u(Population_Base *T2Population, UniRNG *rngUni) : eT2_Ionization_Base(T2Population, rngUni, Janev_eT2_Ionization_diss_u::get_deltaE_eV()) {};
|
||||
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2_Ionization_diss_u::get_TCS_m2(E_eV);
|
||||
}
|
||||
|
||||
double roll_ionW_eV(const double &T_eV) {
|
||||
return dcs_data.roll_value(T_eV, rngUni);
|
||||
return BED_eT2_Ionization::roll_W_eV(T_eV, rngUni); //dcs_data.roll_value(T_eV, rngUni);
|
||||
}
|
||||
|
||||
void add_Tritiums(InteractionOut *InterOut, const Particle &interPart) {
|
||||
@@ -260,4 +250,5 @@ protected:
|
||||
InterOut->add_new_particle(newPart);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* eT2_ionization_h */
|
||||
|
||||
@@ -10,29 +10,31 @@
|
||||
#define eT2_vibexc0102_h
|
||||
|
||||
#include "exc_base.h"
|
||||
|
||||
#include "janev_eT2_vibexc0102.h"
|
||||
|
||||
class eT2_VibExc01 : public Excitation_Base {
|
||||
|
||||
class eT2_VibExc01 : public Excitation_Precomputed_Base {
|
||||
Janev_eT2_VibExc calculator;
|
||||
public:
|
||||
eT2_VibExc01(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen) : calculator(1),
|
||||
Excitation_Base(T2Population, rngUni, 0.516, dcs_gen) {};
|
||||
Excitation_Precomputed_Base(T2Population, rngUni, me_eV, 0.516, dcs_gen) {};
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return calculator.get_TCS(E_eV);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class eT2_VibExc02 : public Excitation_Base {
|
||||
class eT2_VibExc02 : public Excitation_Precomputed_Base {
|
||||
Janev_eT2_VibExc calculator;
|
||||
public:
|
||||
eT2_VibExc02(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen) : calculator(2),
|
||||
Excitation_Base(T2Population, rngUni, 1.003, dcs_gen) {};
|
||||
Excitation_Precomputed_Base(T2Population, rngUni, me_eV, 1.003, dcs_gen) {};
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return calculator.get_TCS(E_eV);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
#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 {
|
||||
public:
|
||||
eT3I_DissExc(Population_Base *T3IPopulation, UniRNG *rngUni, DCS_Base *dcs_gen) : Excitation_Base(T3IPopulation, rngUni, Janev_eT3I_DissExc::get_deltaE_eV(), dcs_gen) {}
|
||||
eT3I_DissExc(Population_Base *T3IPopulation, UniRNG *rngUni, DCS_Base *dcs_gen) : Excitation_Base(T3IPopulation, rngUni, me_eV, Janev_eT3I_DissExc::get_deltaE_eV(), dcs_gen) {}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_eT3I_DissExc::get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT3I_DissExc::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
@@ -24,11 +25,11 @@ public:
|
||||
inline InteractionOut eT3I_DissExc::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res = Excitation_Base::do_Interaction(interPart);
|
||||
vec3 loc_m = interPart->get_x_m();
|
||||
//Population->decrease_denisty(loc_m, 0); // dummy since thermal population
|
||||
|
||||
vec3 vTI_ms = Population->roll_v_ms(loc_m);
|
||||
Particle TI = Particle_Builder::create_TI(loc_m, vTI_ms, -1, interPart->get_Id());
|
||||
res.add_new_particle(TI);
|
||||
//Population->decrease_denisty(loc_m, 0); // dummy since thermal population
|
||||
return res;
|
||||
}
|
||||
#endif /* eT3I_disexc_h */
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
#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 Sub_Interaction_Base {
|
||||
class eT3I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
public:
|
||||
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni) : Sub_Interaction_Base(T3IPopulation, rngUni) {}
|
||||
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T3IPopulation, rngUni, me_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {return Janev_eT3I_Recombination::get_TCS(E_eV);}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT3I_Recombination::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
#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 Sub_Interaction_Base {
|
||||
class eT5I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
public:
|
||||
eT5I_Recombination(Population_Base *T5IPopulation, UniRNG *rngUni) : Sub_Interaction_Base(T5IPopulation, rngUni) {}
|
||||
eT5I_Recombination(Population_Base *T5IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T5IPopulation, rngUni, me_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Pettersson_eT5I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// e_kinetic_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef e_kinetic_base_h
|
||||
#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-
|
||||
double m2_eV; // energy of massive: TI
|
||||
int num_EI_bins; // number of Ee_bins in Populations
|
||||
double *EI_mids; // values for energy mids of Ee_bins in Populations
|
||||
double *vI_mids; // corresponding v_values
|
||||
|
||||
public:
|
||||
e_kinetic_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
m1_eV = m_eV;
|
||||
m2_eV = Population->get_m_eV();
|
||||
|
||||
num_EI_bins = Population->get_number_E_bins();
|
||||
if (num_EI_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when expected kinetic.");
|
||||
}
|
||||
EI_mids = new double[num_EI_bins];
|
||||
vI_mids = new double[num_EI_bins];
|
||||
|
||||
for (int EI_bin = 0; EI_bin<num_EI_bins; EI_bin++) {
|
||||
EI_mids[EI_bin] = Population->get_E_bin_mid_eV(EI_bin);
|
||||
vI_mids[EI_bin] = calc_v_ms_from_E_eV(EI_mids[EI_bin], m2_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 &E_eV, const int &EI_bin);
|
||||
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_kinetic_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
|
||||
inline double e_kinetic_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 EI_bin = 0; EI_bin<num_EI_bins; EI_bin++) {
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, EI_bin) * Population->get_density_m3(EI_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline double e_kinetic_Interaction_Base::calc_microSigma_m2(const double &E_eV, const int &EI_bin) {
|
||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||
double v2_ms = vI_mids[EI_bin];
|
||||
|
||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||
return get_microSigma_m2(E_eV);
|
||||
} 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, simpson())/pi;
|
||||
}
|
||||
}
|
||||
|
||||
inline vec3 e_kinetic_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_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
|
||||
double **precomputed_values;
|
||||
|
||||
public:
|
||||
e_kinetic_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : e_kinetic_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_EI_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 e_kinetic_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int Ee_bin=0; Ee_bin<E_scale.get_number_bins(); Ee_bin++) {
|
||||
for (int EI_bin = 0; EI_bin<num_EI_bins; EI_bin++) {
|
||||
precomputed_values[Ee_bin][EI_bin] = calc_microSigma_m2(E_scale.get_bin_mid(Ee_bin), EI_bin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline double e_kinetic_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 e_kinetic_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
int Ee_bin = E_scale.calc_index(E_eV);
|
||||
double *microSigmas = precomputed_values[Ee_bin];
|
||||
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
|
||||
for (int EI_bin = 0; EI_bin<num_EI_bins; EI_bin++) {
|
||||
macro_sigma_m += microSigmas[EI_bin] * Population->get_density_m3(EI_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
|
||||
#endif /* e_kinetic_base_h */
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// 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) {
|
||||
//return get_microSigma_m2(E_eV); //No Integration... Only e- energy
|
||||
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);
|
||||
// Integration over theta and v
|
||||
auto integrand = [&](double v2_ms, 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 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
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -17,14 +17,14 @@ class E_Mover_E_Drift : public E_Mover_Drift {
|
||||
public:
|
||||
E_Mover_E_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : E_Mover_Drift(Logger, Population) {};
|
||||
protected:
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
inline void E_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m) {
|
||||
if (macroSigma_m <= 0) {
|
||||
inline void E_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
double t_s = 1/macroSigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
double B_T = calc_vec3_abs( 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m)) );
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
this->dt_s = dt_s;
|
||||
};
|
||||
|
||||
void move(Particle *movePart, const double ¯oSigma_m);
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
|
||||
private:
|
||||
double doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T);
|
||||
@@ -28,18 +28,18 @@ private:
|
||||
void doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m);
|
||||
};
|
||||
|
||||
void E_Mover_Boris::move(Particle *movePart, const double ¯oSigma_m) {
|
||||
void E_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
|
||||
if (macroSigma_m == 0) { // If infinite movement distance let electron leave at only exit... Prob extremly faulty, but also impossible.
|
||||
if (macro_sigma_m == 0) { // If infinite movement distance let electron leave at only exit... Prob extremly faulty, but also impossible.
|
||||
movePart->set_x_m(z_RW_m);
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double distance_m = 1/macroSigma_m;
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
E_Mover_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : Drift_Base(electron, Logger, Population) {};
|
||||
protected:
|
||||
void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
inline void E_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
@@ -41,7 +41,7 @@ inline void E_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m,
|
||||
}
|
||||
}
|
||||
|
||||
inline void E_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m) {
|
||||
inline void E_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,23 +9,30 @@
|
||||
#ifndef exc_base_h
|
||||
#define exc_base_h
|
||||
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_base.h"
|
||||
|
||||
class Excitation_Base : public Sub_Interaction_Base {
|
||||
class Excitation_Base : public e_thermal_Interaction_Base {
|
||||
DCS_Base *dcs_gen;
|
||||
protected:
|
||||
double deltaE_eV;
|
||||
|
||||
public:
|
||||
Excitation_Base(Population_Base *Population, UniRNG *rngUni, double deltaE_eV, DCS_Base *dcs_gen) : Sub_Interaction_Base(Population, rngUni) {
|
||||
Excitation_Base(Population_Base *Population, UniRNG *rngUni, double m_eV, double deltaE_eV, DCS_Base *dcs_gen) : e_thermal_Interaction_Base(Population, rngUni, m_eV) {
|
||||
this->deltaE_eV = deltaE_eV;
|
||||
this->dcs_gen = dcs_gen;
|
||||
}
|
||||
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
if (interPart.get_E_eV() < deltaE_eV) {
|
||||
return 0;
|
||||
} else {
|
||||
return e_thermal_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
private:
|
||||
//virtual double get_microSigma_m2(const double &Ekin_EV) = 0;
|
||||
};
|
||||
|
||||
inline InteractionOut Excitation_Base::do_Interaction (Particle *interPart) {
|
||||
@@ -46,11 +53,12 @@ inline InteractionOut Excitation_Base::do_Interaction (Particle *interPart) {
|
||||
class Exp_Excitation_Base : public Excitation_Base {
|
||||
TCS_Container tcs_data;
|
||||
public:
|
||||
Exp_Excitation_Base(Population_Base *T2Population, UniRNG *rngUni, double deltaE_eV, DCS_Base *dcs_gen, std::string load_file_name) : Excitation_Base(T2Population, rngUni, deltaE_eV, dcs_gen),
|
||||
Exp_Excitation_Base(Population_Base *T2Population, UniRNG *rngUni, double m_eV, double deltaE_eV, DCS_Base *dcs_gen, std::string load_file_name) : Excitation_Base(T2Population, rngUni, m_eV, deltaE_eV, dcs_gen),
|
||||
tcs_data(scale_start, scale_end, 1e3, get_data_path() + load_file_name) {};
|
||||
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) {
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
if (E_eV < deltaE_eV) {
|
||||
return 0;
|
||||
} else {
|
||||
@@ -60,4 +68,58 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class Excitation_Precomputed_Base : public e_thermal_Precomputed_Interaction_Base {
|
||||
DCS_Base *dcs_gen;
|
||||
protected:
|
||||
double deltaE_eV;
|
||||
|
||||
public:
|
||||
Excitation_Precomputed_Base(Population_Base *Population, UniRNG *rngUni, double m_eV, double deltaE_eV, DCS_Base *dcs_gen) : e_thermal_Precomputed_Interaction_Base(Population, rngUni, m_eV) {
|
||||
this->deltaE_eV = deltaE_eV;
|
||||
this->dcs_gen = dcs_gen;
|
||||
}
|
||||
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
if (interPart.get_E_eV() < deltaE_eV) {
|
||||
return 0;
|
||||
} else {
|
||||
return e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut Excitation_Precomputed_Base::do_Interaction (Particle *interPart) {
|
||||
vec3 vOff_ms = get_vOff_ms(*interPart, deltaE_eV);
|
||||
vec3 vLab_ms = interPart->get_v_ms() - vOff_ms;
|
||||
double EkinLab_eV = calc_E_eV_from_v_ms(vLab_ms, me_eV);
|
||||
double EkinLabNew_eV = EkinLab_eV - deltaE_eV;
|
||||
double theta_lab = dcs_gen->get_theta(EkinLab_eV);
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
vec3 n0 = calc_n_new(vLab_ms, theta_lab, phi_lab);
|
||||
vec3 vnew_ms = n0 * calc_v_ms_from_E_eV(EkinLabNew_eV, me_eV) + vOff_ms;
|
||||
interPart->set_v_ms(vnew_ms);
|
||||
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
|
||||
class Exp_Excitation_Precomputed_Base : public Excitation_Precomputed_Base {
|
||||
TCS_Container tcs_data;
|
||||
public:
|
||||
Exp_Excitation_Precomputed_Base(Population_Base *T2Population, UniRNG *rngUni, double m_eV, double deltaE_eV, DCS_Base *dcs_gen, std::string load_file_name) : Excitation_Precomputed_Base(T2Population, rngUni, m_eV, deltaE_eV, dcs_gen),
|
||||
tcs_data(scale_start, scale_end, 1e3, get_data_path() + load_file_name) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
if (E_eV < deltaE_eV) {
|
||||
return 0;
|
||||
} else {
|
||||
return tcs_data.get_value(E_eV);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif /* exc_base_h */
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// injector.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
#include "injector.hpp"
|
||||
#include "katrin_geo.h"
|
||||
|
||||
const int Injector::injectionMethod = load_parameter("INJECTION");
|
||||
const double Injector::injectionEnergy_eV = load_parameter("INJ_E");
|
||||
|
||||
Particle Injector::injectElectron (const int &newId) {
|
||||
|
||||
double r_m = r_WGTS_m*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double z_WGTSstart_m = z_WGTS_start_m;
|
||||
double wgtsLength_m = l_WGTS_m;
|
||||
|
||||
double z_WGTS_start_to_half_pos_m = sqrt(rngUni->random())*wgtsLength_m/2;
|
||||
double z_m = (rngUni->random()<0.5) ? z_WGTS_start_to_half_pos_m : wgtsLength_m - z_WGTS_start_to_half_pos_m;
|
||||
z_m += z_WGTSstart_m;
|
||||
|
||||
vec3 loc_m = vec3 (r_m*cos(phi),r_m*sin(phi),z_m);
|
||||
double E_eV;
|
||||
switch(injectionMethod) {
|
||||
case 0: // Fermi
|
||||
E_eV = roll_FermiEnergy_eV();
|
||||
break;
|
||||
case 1: //Delta
|
||||
E_eV = injectionEnergy_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
E_eV = roll_MBEnergy(injectionEnergy_eV/kb_eVK,me_eV, rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
return PartFac.create_e(loc_m, v_ms, newId, newId);
|
||||
|
||||
//double v_ms = calc_v_ms_from_E_eV(pow(rngUni->random(),1./3.), me_eV);
|
||||
//double v_ms = -100;
|
||||
//return PartFac.create_e(vec3(0,0,z_WGTS_end_m), vec3(0,0,-v_ms),newId, newId);
|
||||
}
|
||||
|
||||
double Injector::roll_FermiEnergy_eV() {
|
||||
double pmax,E_min_eV, E_max_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
E_min_eV = scale_start;
|
||||
E_max_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = E_min_eV + eta1*(E_max_eV - E_min_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return Ecan_eV;
|
||||
}
|
||||
|
||||
double Injector::get_FermiDecaySpectrumDensity(const double &E_eV) {
|
||||
if (E_eV>TritiumDecayEndpoint_eV) {
|
||||
return 0;
|
||||
} else{
|
||||
double p_eV = sqrt(E_eV*E_eV + 2 * E_eV * me_eV);
|
||||
return BetaDecayConst*get_FermiFunction(2, E_eV)*p_eV*(E_eV+me_eV)*pow(TritiumDecayEndpoint_eV-E_eV,2);
|
||||
}
|
||||
}
|
||||
|
||||
double Injector::get_FermiFunction(const double &Z, const double &E_eV) {
|
||||
double gamma = 1+ E_eV/me_eV;
|
||||
double beta = sqrt(1 - pow(gamma,-2));
|
||||
double eta =Z/beta/137.;
|
||||
return 2*pi*eta/(1-exp(-2*pi*eta));
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// injector.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef injector_h
|
||||
#define injector_h
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
#include <vector>
|
||||
#include "random_operations.h"
|
||||
|
||||
|
||||
class Injector : RNG_Base {
|
||||
int method;
|
||||
double energy_eV;
|
||||
int ions;
|
||||
Population_Base *T2Population;
|
||||
|
||||
Particle_Builder PartFac;
|
||||
|
||||
public:
|
||||
Injector() : RNG_Base(nullptr, nullptr) {};
|
||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal, Population_Base *T2Population, int method, double energy_eV, int ions) : RNG_Base(rngUni, rngNormal){
|
||||
this->T2Population = T2Population;
|
||||
this->method = method;
|
||||
this->energy_eV = energy_eV;
|
||||
this->ions = ions;
|
||||
};
|
||||
|
||||
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &E_eV);
|
||||
double get_FermiFunction(const double &Z, const double &E_eV);
|
||||
};
|
||||
|
||||
inline int Injector::inject (std::vector<Particle> *particle_queue, const int &last_ID) {
|
||||
vec3 loc_m = T2Population->roll_x_ms();
|
||||
|
||||
double E_eV;
|
||||
switch(method) {
|
||||
case 0: // Fermi
|
||||
E_eV = roll_FermiEnergy_eV();
|
||||
break;
|
||||
case 1: //Delta
|
||||
E_eV = energy_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
E_eV = roll_MBEnergy(energy_eV/kb_eVK, me_eV, rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
|
||||
if (ions == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
vec3 vTI_ms = T2Population->roll_v_ms(loc_m);
|
||||
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline double Injector::roll_FermiEnergy_eV() {
|
||||
double pmax,E_min_eV, E_max_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
E_min_eV = scale_start;
|
||||
E_max_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = E_min_eV + eta1*(E_max_eV - E_min_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return Ecan_eV;
|
||||
}
|
||||
|
||||
inline double Injector::get_FermiDecaySpectrumDensity(const double &E_eV) {
|
||||
if (E_eV>TritiumDecayEndpoint_eV) {
|
||||
return 0;
|
||||
} else{
|
||||
double p_eV = sqrt(E_eV*E_eV + 2 * E_eV * me_eV);
|
||||
return BetaDecayConst*get_FermiFunction(2, E_eV)*p_eV*(E_eV+me_eV)*pow(TritiumDecayEndpoint_eV-E_eV,2);
|
||||
}
|
||||
}
|
||||
|
||||
inline double Injector::get_FermiFunction(const double &Z, const double &E_eV) {
|
||||
double gamma = 1+ E_eV/me_eV;
|
||||
double beta = sqrt(1 - pow(gamma,-2));
|
||||
double eta =Z/beta/137.;
|
||||
return 2*pi*eta/(1-exp(-2*pi*eta));
|
||||
}
|
||||
|
||||
|
||||
#endif /* injector_h */
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// injector.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef injector_hpp
|
||||
#define injector_hpp
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
|
||||
class Injector : RNG_Base {
|
||||
static const int injectionMethod;
|
||||
static const double injectionEnergy_eV;
|
||||
|
||||
Particle_Builder PartFac;
|
||||
|
||||
public:
|
||||
Injector() : RNG_Base(nullptr, nullptr) {};
|
||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){};
|
||||
|
||||
Particle injectElectron (const int &newId);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &E_eV);
|
||||
double get_FermiFunction(const double &Z, const double &E_eV);
|
||||
};
|
||||
|
||||
|
||||
#endif /* injector_hpp */
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// injector_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "injector_builder.hpp"
|
||||
|
||||
const int Injector_Builder::method = load_parameter("INJECTION");
|
||||
const double Injector_Builder::energy_eV = load_parameter("INJ_E");
|
||||
const int Injector_Builder::ions = load_parameter("INJ_TI");
|
||||
|
||||
Injector Injector_Builder::build(UniRNG *rngUni, NormalRNG *rngNormal, Population_Manager *populations) {
|
||||
Population_Base *T2Population = populations->find(tritium2);
|
||||
return Injector(rngUni, rngNormal, T2Population, method, energy_eV, ions);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// injector_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef injector_builder_hpp
|
||||
#define injector_builder_hpp
|
||||
|
||||
#include "injector.h"
|
||||
#include "population_builder.hpp"
|
||||
|
||||
|
||||
class Injector_Builder {
|
||||
static const int method;
|
||||
static const double energy_eV;
|
||||
static const int ions;
|
||||
|
||||
public:
|
||||
Injector_Builder() {};
|
||||
|
||||
static Injector build(UniRNG *rngUni, NormalRNG *rngNormal, Population_Manager *populations);
|
||||
};
|
||||
#endif /* injector_builder_hpp */
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// integrater.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef integrater_h
|
||||
#define integrater_h
|
||||
|
||||
// Integrater from https://rosettacode.org/wiki/Numerical_integration#C.2B.2B
|
||||
|
||||
// the integration routine
|
||||
template<typename Method, typename F, typename Float>
|
||||
double integrate(F f, Float a, Float b, int steps, Method m)
|
||||
{
|
||||
double s = 0;
|
||||
double h = (b-a)/steps;
|
||||
for (int i = 0; i < steps; ++i)
|
||||
s += m(f, a + h*i, h);
|
||||
return h*s;
|
||||
}
|
||||
|
||||
// methods
|
||||
class rectangular
|
||||
{
|
||||
public:
|
||||
enum position_type { left, middle, right };
|
||||
rectangular(position_type pos): position(pos) {}
|
||||
template<typename F, typename Float>
|
||||
double operator()(F f, Float x, Float h) const
|
||||
{
|
||||
switch(position)
|
||||
{
|
||||
case left:
|
||||
return f(x);
|
||||
case middle:
|
||||
return f(x+h/2);
|
||||
case right:
|
||||
return f(x+h);
|
||||
}
|
||||
}
|
||||
private:
|
||||
const position_type position;
|
||||
};
|
||||
|
||||
class trapezium
|
||||
{
|
||||
public:
|
||||
template<typename F, typename Float>
|
||||
double operator()(F f, Float x, Float h) const
|
||||
{
|
||||
return (f(x) + f(x+h))/2;
|
||||
}
|
||||
};
|
||||
|
||||
class simpson
|
||||
{
|
||||
public:
|
||||
template<typename F, typename Float>
|
||||
double operator()(F f, Float x, Float h) const
|
||||
{
|
||||
return (f(x) + 4*f(x+h/2) + f(x+h))/6;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename F, typename Double>
|
||||
double double_simpson_integrate(F f, Double xmin, Double xmax, Double ymin, Double ymax, int nx, int ny) {
|
||||
// Adapted from https://www.geeksforgeeks.org/program-to-calculate-double-integration/
|
||||
// and http://www.physics.usyd.edu.au/teach_res/mp/doc/math_integration_2D.pdf
|
||||
// and http://mathfaculty.fullerton.edu/mathews/n2003/SimpsonsRule2DMod.html
|
||||
|
||||
// Make number of steps even
|
||||
if (nx % 2 != 0) {
|
||||
nx += 1;
|
||||
}
|
||||
if (ny % 2 != 0) {
|
||||
ny += 1;
|
||||
}
|
||||
// Calculating the step sizes
|
||||
Double xsteps = (xmax - xmin)/(nx-1);
|
||||
Double ysteps = (ymax - ymin)/(ny-1);
|
||||
|
||||
// Lambda for calculating function value in respect to x and y bins
|
||||
auto f_bin = [&](int ix, int iy) {
|
||||
return f(xmin + ix * xsteps, ymin + iy * ysteps);
|
||||
};
|
||||
// Lambda for calculating the integral over y for a ix bin
|
||||
auto x_integral = [&](int ix) {
|
||||
Double res = 0;
|
||||
for (int iy = 0; iy < ny; iy++) {
|
||||
if (iy == 0 || iy == ny - 1)
|
||||
res += f_bin(ix, iy);
|
||||
else if (iy % 2 == 0)
|
||||
res += 2 * f_bin(ix, iy);
|
||||
else
|
||||
res += 4 * f_bin(ix, iy);
|
||||
}
|
||||
res *= (ysteps / 3);
|
||||
return res;
|
||||
};
|
||||
|
||||
// Calculating the final integral value over x
|
||||
Double res = 0;
|
||||
for (int ix = 0; ix < nx; ix++) {
|
||||
if (ix == 0 || ix == nx - 1)
|
||||
res += x_integral(ix);
|
||||
else if (ix % 2 == 0)
|
||||
res += 2 * x_integral(ix);
|
||||
else
|
||||
res += 4 * x_integral(ix);
|
||||
}
|
||||
res *= (xsteps / 3);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* integrater_h */
|
||||
@@ -9,71 +9,52 @@
|
||||
#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_Base : public Process_Base {
|
||||
Sub_Interaction_Base **SubInteractions;
|
||||
int numSubInteractions = 0;
|
||||
|
||||
UniRNG *rngUni;
|
||||
class InteractionOut {
|
||||
bool delete_current;
|
||||
Particle new_particles[3];
|
||||
int number_new_particles;
|
||||
|
||||
public:
|
||||
Interaction_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(Sub_Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macroSigma_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_Base::do_Interaction(Particle *interPart) {
|
||||
double macroSigma_m = get_macroSigma_m(*interPart);
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macroSigma_m;
|
||||
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
currentStackedSigma += SubInteractions[i]->get_macroSigma_m(*interPart);
|
||||
if (currentStackedSigma >= targetStackedSigma) {
|
||||
return SubInteractions[i]->do_Interaction(interPart);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
inline double Interaction_Base::get_macroSigma_m(const Particle &interPart) {
|
||||
double macroSigma_m = 0;
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
macroSigma_m += SubInteractions[i]->get_macroSigma_m(interPart);
|
||||
}
|
||||
return macroSigma_m;
|
||||
}
|
||||
|
||||
inline void Interaction_Base::add(Sub_Interaction_Base *addSubInteraction) {
|
||||
if (numSubInteractions != 0) {
|
||||
Sub_Interaction_Base *tempArray[numSubInteractions];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
tempArray[i] = SubInteractions[i];
|
||||
}
|
||||
delete[] SubInteractions;
|
||||
SubInteractions = new Sub_Interaction_Base *[numSubInteractions + 1];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
SubInteractions[i] = tempArray[i];
|
||||
}
|
||||
} else {
|
||||
SubInteractions = new Sub_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"
|
||||
@@ -57,8 +58,8 @@ Interaction_Manager Interaction_Builder::build(Population_Manager *Populations,
|
||||
Interactions.add(build_tritium5I(Populations, rngUni));
|
||||
return Interactions;
|
||||
}
|
||||
Interaction_Base* Interaction_Builder::build_electron(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *eInteraction = new Interaction_Base(electron, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *eInteraction = new Interaction_Channel_Base(electron, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *T2IPopulation = Populations->find(tritium2I);
|
||||
Population_Base *T3IPopulation = Populations->find(tritium3I);
|
||||
@@ -86,14 +87,14 @@ Interaction_Base* Interaction_Builder::build_electron(Population_Manager *Popula
|
||||
eInteraction->add(new eT2_Ionization_Janev_diss_g(T2Population, rngUni));
|
||||
eInteraction->add(new eT2_Ionization_Janev_diss_u(T2Population, rngUni));
|
||||
} else if (load_parameter("eT2_ION") == 2){
|
||||
eInteraction->add(new eT2_Ionization_BED_Container(T2Population, rngUni));
|
||||
eInteraction->add(new eT2_Ionization_BED_Analytic(T2Population, rngUni));
|
||||
} else if(load_parameter("eT2_ION") != 0) {
|
||||
throw MyException ("eT2_ION invalid.");
|
||||
}
|
||||
|
||||
|
||||
if (load_parameter("eT2_ROT") == 2) {
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 4.41e-4, exc_dcs, "rot_exc_j02.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Precomputed_Base(T2Population, rngUni, me_eV, 4.41e-2, exc_dcs, "rot_exc_j02.dat"));
|
||||
} else if (load_parameter("eT2_ROT") != 0) {
|
||||
throw MyException ("eT2_ROT invalid.");
|
||||
}
|
||||
@@ -102,7 +103,7 @@ Interaction_Base* Interaction_Builder::build_electron(Population_Manager *Popula
|
||||
eInteraction->add(new eT2_VibExc01(T2Population, rngUni, exc_dcs));
|
||||
eInteraction->add(new eT2_VibExc02(T2Population, rngUni, exc_dcs));
|
||||
} else if (load_parameter("eT2_VIB") == 2) {
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 0.516, exc_dcs, "vib_exc_v01.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Precomputed_Base(T2Population, rngUni, me_eV, 0.516, exc_dcs, "vib_exc_v01.dat"));
|
||||
} else if (load_parameter("eT2_VIB") != 0) {
|
||||
throw MyException ("eT2_VIB invalid.");
|
||||
}
|
||||
@@ -130,7 +131,7 @@ Interaction_Base* Interaction_Builder::build_electron(Population_Manager *Popula
|
||||
return eInteraction;
|
||||
}
|
||||
|
||||
void Interaction_Builder::build_e_el_janev(Interaction_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs) {
|
||||
void Interaction_Builder::build_e_el_janev(Interaction_Channel_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs) {
|
||||
eInteraction->add(new eT2_ElExc_Nu_Analytic(T2Population, rngUni, Janev_eT2_ElExc_Nu(B1Sigmau), exc_dcs));
|
||||
eInteraction->add(new eT2_ElExc_Nu_Analytic(T2Population, rngUni, Janev_eT2_ElExc_Nu(Bp1Sigu), exc_dcs));
|
||||
eInteraction->add(new eT2_ElExc_Nu_Analytic(T2Population, rngUni, Janev_eT2_ElExc_Nu(Bpp1Sigu), exc_dcs));
|
||||
@@ -150,24 +151,24 @@ void Interaction_Builder::build_e_el_janev(Interaction_Base* eInteraction, UniRN
|
||||
eInteraction->add(new eT2_ElExc_n_Analytic(T2Population, rngUni, Janev_eT2_ElExc_n(d3Piu), exc_dcs));
|
||||
}
|
||||
|
||||
void Interaction_Builder::build_e_el_exp(Interaction_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs) {
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 8.48, exc_dcs, "el_exc_b3sigpu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 11.18, exc_dcs, "el_exc_B1sigpu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 11.76, exc_dcs, "el_exc_c3piu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 11.79, exc_dcs, "el_exc_a3sigpg.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 12.29, exc_dcs, "el_exc_C1piu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 12.3, exc_dcs, "el_exc_EF1sigpg.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, 13.23, exc_dcs, "el_exc_e3sigpu.dat"));
|
||||
void Interaction_Builder::build_e_el_exp(Interaction_Channel_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs) {
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 8.48, exc_dcs, "el_exc_b3sigpu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 11.18, exc_dcs, "el_exc_B1sigpu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 11.76, exc_dcs, "el_exc_c3piu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 11.79, exc_dcs, "el_exc_a3sigpg.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 12.29, exc_dcs, "el_exc_C1piu.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 12.3, exc_dcs, "el_exc_EF1sigpg.dat"));
|
||||
eInteraction->add(new Exp_Excitation_Base(T2Population, rngUni, me_eV, 13.23, exc_dcs, "el_exc_e3sigpu.dat"));
|
||||
}
|
||||
|
||||
|
||||
Interaction_Base* Interaction_Builder::build_tritium(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *T_Interaction = new Interaction_Base(tritium, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritium(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *T_Interaction = new Interaction_Channel_Base(tritium, rngUni);
|
||||
return T_Interaction;
|
||||
}
|
||||
|
||||
Interaction_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *TI_Interaction = new Interaction_Base(tritiumI, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *TI_Interaction = new Interaction_Channel_Base(tritiumI, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||
@@ -175,8 +176,8 @@ Interaction_Base* Interaction_Builder::build_tritiumI(Population_Manager *Popula
|
||||
return TI_Interaction;
|
||||
}
|
||||
|
||||
Interaction_Base* Interaction_Builder::build_tritium2I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *T2I_Interaction = new Interaction_Base(tritium2I, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritium2I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *T2I_Interaction = new Interaction_Channel_Base(tritium2I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
|
||||
@@ -191,8 +192,8 @@ Interaction_Base* Interaction_Builder::build_tritium2I(Population_Manager *Popul
|
||||
return T2I_Interaction ;
|
||||
}
|
||||
|
||||
Interaction_Base* Interaction_Builder::build_tritium3I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *T3I_Interaction = new Interaction_Base(tritium3I, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *T3I_Interaction = new Interaction_Channel_Base(tritium3I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||
@@ -209,8 +210,8 @@ Interaction_Base* Interaction_Builder::build_tritium3I(Population_Manager *Popul
|
||||
return T3I_Interaction ;
|
||||
}
|
||||
|
||||
Interaction_Base* Interaction_Builder::build_tritium5I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Base *T5I_Interaction = new Interaction_Base(tritium5I, rngUni);
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritium5I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *T5I_Interaction = new Interaction_Channel_Base(tritium5I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
T5I_Interaction->add(new T5IT2_Elastic(T2Population, rngUni));
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
#ifndef interaction_builder_hpp
|
||||
#define interaction_builder_hpp
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
#include "manager_base.h"
|
||||
|
||||
#include "exc_base.h"
|
||||
#include "interaction_channel_base.h"
|
||||
#include "population_builder.hpp"
|
||||
#include "dcs_base.h"
|
||||
|
||||
typedef Manager_Base<Interaction_Base> Interaction_Manager;
|
||||
|
||||
typedef Manager_Base<Interaction_Channel_Base> Interaction_Manager;
|
||||
|
||||
class Interaction_Builder {
|
||||
public:
|
||||
@@ -23,15 +24,15 @@ public:
|
||||
|
||||
static Interaction_Manager build(Population_Manager *Populations, UniRNG *rngUni);
|
||||
private:
|
||||
static Interaction_Base* build_electron(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static void build_e_el_janev(Interaction_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs);
|
||||
static void build_e_el_exp(Interaction_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs);
|
||||
static Interaction_Channel_Base* build_electron(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static void build_e_el_janev(Interaction_Channel_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs);
|
||||
static void build_e_el_exp(Interaction_Channel_Base* eInteraction, UniRNG *rngUni, Population_Base *T2Population, DCS_Base *exc_dcs);
|
||||
|
||||
static Interaction_Base* build_tritium(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Base* build_tritiumI(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Base* build_tritium2I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Base* build_tritium3I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Base* build_tritium5I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritiumI(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium2I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium3I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium5I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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 */
|
||||
@@ -10,7 +10,6 @@
|
||||
#define katrin_fields_hpp
|
||||
|
||||
#include "error_types.h"
|
||||
#include "katrin_geo.h"
|
||||
#include "read_system.h"
|
||||
#include "vec3_container.hpp"
|
||||
|
||||
@@ -23,20 +22,10 @@ public:
|
||||
Katrin_Fields() {};
|
||||
|
||||
static vec3 getMagField_T(vec3 loc_m) {
|
||||
if (!in_Katrin(loc_m)) {
|
||||
std::stringstream ss;
|
||||
ss<<"Katrin_Fields::getMagField_T: loc_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return vec3(0,0,wgtsMagField_T);
|
||||
}
|
||||
|
||||
static vec3 getElField_Vm(vec3 loc_m) {
|
||||
if (!in_Katrin(loc_m)) {
|
||||
std::stringstream ss;
|
||||
ss<<"Katrin_Fields::getElField_Vm: loc_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return e_field.get_data (loc_m);
|
||||
//return vec3(0,0,0);
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// katrin_geo.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 11.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef katrin_geo_h
|
||||
#define katrin_geo_h
|
||||
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
|
||||
inline bool in_WGTS(vec3 loc_m) {
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt(loc_m[0]*loc_m[0] + loc_m[1]*loc_m[1]);
|
||||
if (z_m < z_WGTS_start_m) {
|
||||
return false;
|
||||
} else if (z_m > z_WGTS_end_m) {
|
||||
return false;
|
||||
} else if (r_m > r_WGTS_m) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool in_Katrin(vec3 loc_m) {
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt(loc_m[0]*loc_m[0] + loc_m[1]*loc_m[1]);
|
||||
if (z_m < z_RW_m) {
|
||||
return false;
|
||||
} else if (z_m > z_DPS_end_m) {
|
||||
return false;
|
||||
} else if (r_m > r_WGTS_m) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* katrin_geo_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#define energetic_base_h
|
||||
|
||||
|
||||
#include "katrin_geo.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "population_container.hpp"
|
||||
@@ -25,22 +23,27 @@ 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, double E_max_eV);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||
double get_density_m3(const vec3 &loc_m){throw MyException("Method for non kinetic populations.\n");}
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
int get_number_E_bins();
|
||||
Bins get_loc_bin(const vec3 & loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
virtual vec3 roll_v_ms (const vec3 &loc_m);
|
||||
|
||||
virtual Population_Container *access_container();
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m);
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return vec3(0,0,0);} // Dummy as integration is made over energy mids
|
||||
double get_thermal_v_ms() {return 0;} // Dummy as integration is made over energy mids
|
||||
double get_v_pdf(const double &v_ms) {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
Population_Container *access_container();
|
||||
};
|
||||
|
||||
|
||||
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, double E_max_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, E_max_eV) {
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
};
|
||||
@@ -53,31 +56,31 @@ inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const doubl
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
||||
std::stringstream ss;
|
||||
ss<<"Kinetic_Population::get_density_m3: method for non kinetic populations.\n";
|
||||
throw MyException(ss.str());
|
||||
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||
}
|
||||
|
||||
inline Content Kinetic_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
inline double Kinetic_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||
}
|
||||
|
||||
inline Sum_bounds Kinetic_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||
return container.get_sumation_bounds(loc_m);
|
||||
int Kinetic_Population::get_number_E_bins() {
|
||||
return container.get_number_E_bins();
|
||||
}
|
||||
Bins Kinetic_Population::get_loc_bin(const vec3 & loc_m) {
|
||||
return container.calc_loc_bin(loc_m);
|
||||
}
|
||||
|
||||
double Kinetic_Population::get_E_bin_mid_eV(const int &E_bin) {
|
||||
return container.get_E_bin_mid_eV(E_bin);
|
||||
}
|
||||
|
||||
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
||||
Sum_bounds bounds = container.get_sumation_bounds(loc_m);
|
||||
Bins loc_bins = get_loc_bin(loc_m);
|
||||
double target = 0;
|
||||
for (int E_bin = 0; E_bin<bounds.num_E_bins; E_bin++) {
|
||||
target += get_density_m3(E_bin, bounds.loc_bins).n_m3;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
target += get_density_m3(E_bin, loc_bins);
|
||||
}
|
||||
target *= rngUni->random();
|
||||
double current = 0;
|
||||
for (int E_bin = 0; E_bin<bounds.num_E_bins; E_bin++) {
|
||||
current += get_density_m3(E_bin, bounds.loc_bins).n_m3;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
current += get_density_m3(E_bin, loc_bins);
|
||||
if (current >= target) {
|
||||
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
int get_number_bins();
|
||||
|
||||
int calc_index(const double &x);
|
||||
bool in_scale(const double &x);
|
||||
double get_lower_bin_bound(const int &index);
|
||||
double get_bin_mid(const int &index);
|
||||
double get_upper_bin_bound(const int &index);
|
||||
@@ -75,6 +76,10 @@ inline int Lin_Scale::calc_index(const double &x) {
|
||||
return std::ceil((x-min_x)/delta_x) - 1;
|
||||
}
|
||||
|
||||
inline bool Lin_Scale::in_scale(const double &x) {
|
||||
return (x >= min_x) && (x <= max_x);
|
||||
}
|
||||
|
||||
inline double Lin_Scale::get_lower_bin_bound(const int &index) {
|
||||
return min_x + double(index) * delta_x;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
int get_number_bins();
|
||||
|
||||
int calc_index(const double &x);
|
||||
bool in_scale(const double &x);
|
||||
double get_lower_bin_bound(const int &index);
|
||||
double get_bin_mid(const int &index);
|
||||
double get_upper_bin_bound(const int &index);
|
||||
@@ -52,6 +53,11 @@ inline int Log_Scale::calc_index(const double &x) {
|
||||
return lin_scale.calc_index(p);
|
||||
}
|
||||
|
||||
inline bool Log_Scale::in_scale(const double &x) {
|
||||
double p = std::log10(x);
|
||||
return lin_scale.in_scale(p);
|
||||
}
|
||||
|
||||
inline double Log_Scale::get_lower_bin_bound(const int &index) {
|
||||
double p = lin_scale.get_lower_bin_bound(index);
|
||||
return pow(10,p);
|
||||
|
||||
@@ -4,7 +4,7 @@ OBJS := particle_looper.o \
|
||||
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
||||
population_container.o velocity_container.o vec3_container.o \
|
||||
thermalPop_container.o energeticPop_container.o \
|
||||
particle.o injector.o timer.o katrin_fields.o \
|
||||
particle.o injector_builder.o timer.o katrin_fields.o \
|
||||
h5_file.o logger_builder.o population_load_saver.o \
|
||||
h5tb_particle_interface.o h5tb_population_interface.o h5tb_population_meta_interface.o \
|
||||
population_builder.o \
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define mover_base_h
|
||||
|
||||
#include "process_base.h"
|
||||
#include "katrin_geo.h"
|
||||
#include "katrin_fields.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
@@ -29,7 +28,7 @@ public:
|
||||
this->Population = Population;
|
||||
}
|
||||
|
||||
virtual void move(Particle *movePart, const double ¯oSigma_m) = 0;
|
||||
virtual void move(Particle *movePart, const double ¯o_sigma_m) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@ class Neutral_Mover : public Mover_Base {
|
||||
public:
|
||||
Neutral_Mover(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
||||
|
||||
void move(Particle *movePart, const double ¯oSigma_m);
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
private:
|
||||
void wall_correction(vec3 *newLoc_m, const vec3 &oldLoc_m);
|
||||
};
|
||||
|
||||
inline void Neutral_Mover::move(Particle *movePart, const double ¯oSigma_m) {
|
||||
inline void Neutral_Mover::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
vec3 move_direction = v_ms/calc_vec3_abs(v_ms);
|
||||
double distance = (macroSigma_m <= 0) ? 1e3 : 1/macroSigma_m; //sloppy trick to "leave" wgts
|
||||
double distance = (macro_sigma_m <= 0) ? 1e3 : 1/macro_sigma_m; //sloppy trick to "leave" wgts
|
||||
|
||||
vec3 newLoc_m = oldLoc_m + distance * move_direction;
|
||||
wall_correction(&newLoc_m, oldLoc_m);
|
||||
@@ -35,18 +35,16 @@ inline void Neutral_Mover::move(Particle *movePart, const double ¯oSigma_m)
|
||||
}
|
||||
|
||||
inline void Neutral_Mover::wall_correction(vec3 *newLoc_m, const vec3 &oldLoc_m) {
|
||||
if (!in_Katrin(*newLoc_m)) {
|
||||
if (*newLoc_m[2] < z_RW_m) {
|
||||
newLoc_m[2] = z_RW_m;
|
||||
}
|
||||
if (*newLoc_m[2] > z_WGTS_end_m) {
|
||||
newLoc_m[2] = z_WGTS_end_m;
|
||||
}
|
||||
if (calc_r_m(*newLoc_m) > r_WGTS_m) {
|
||||
double phi = calc_phi(*newLoc_m);
|
||||
newLoc_m[0] = r_WGTS_m * cos(phi);
|
||||
newLoc_m[1] = r_WGTS_m * sin(phi);
|
||||
}
|
||||
if (*newLoc_m[2] < z_RW_m) {
|
||||
newLoc_m[2] = z_RW_m;
|
||||
}
|
||||
if (*newLoc_m[2] > z_WGTS_end_m) {
|
||||
newLoc_m[2] = z_WGTS_end_m;
|
||||
}
|
||||
if (calc_r_m(*newLoc_m) > r_WGTS_m) {
|
||||
double phi = calc_phi(*newLoc_m);
|
||||
newLoc_m[0] = r_WGTS_m * cos(phi);
|
||||
newLoc_m[1] = r_WGTS_m * sin(phi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ void Particle_Looper::init_managers() {
|
||||
part_loggers = Particle_Logger_Builder::build(&h5f);
|
||||
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
||||
|
||||
injector = Injector(&rngUni, &rngNormal);
|
||||
injector = Injector_Builder::build(&rngUni, &rngNormal, &populations);
|
||||
movers = Mover_Builder::build(&part_loggers, &populations);
|
||||
interactions = Interaction_Builder::build(&populations, &rngUni);
|
||||
terminators = Terminator_Builder::build();
|
||||
@@ -26,38 +26,42 @@ void Particle_Looper::init_managers() {
|
||||
}
|
||||
|
||||
void Particle_Looper::do_loops(int target_decays) {
|
||||
queue<Particle> particle_queue;
|
||||
vector<Particle> particle_queue;
|
||||
int number_decays = 0;
|
||||
while ( (number_decays < target_decays) || (!particle_queue.empty()) ) {
|
||||
if (particle_queue.empty()) {
|
||||
particle_queue.push(injector.injectElectron(get_new_id()));
|
||||
number_decays++;
|
||||
local_decays++;
|
||||
int num_new = injector.inject(&particle_queue, get_last_id());
|
||||
number_decays = number_decays + 1;
|
||||
local_decays = local_decays + 1;
|
||||
ID_counter = ID_counter + num_new;
|
||||
}
|
||||
process_first(&particle_queue);
|
||||
process_one(&particle_queue);
|
||||
}
|
||||
pop_loggers.log();
|
||||
}
|
||||
|
||||
void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
|
||||
Particle curPart = particle_queue->front();
|
||||
void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
||||
int i = floor(rngUni.random()*particle_queue->size());
|
||||
Particle curPart = particle_queue->at(i);
|
||||
//Particle curPart = particle_queue->front();
|
||||
Mover_Base *moverPtr = movers.find(curPart.get_species());
|
||||
Interaction_Base *interactionPtr = interactions.find(curPart.get_species());
|
||||
Interaction_Channel_Base *interactionPtr = interactions.find(curPart.get_species());
|
||||
Terminator_Base *terminatorPtr = terminators.find(curPart.get_species());
|
||||
|
||||
InteractionOut IntOut;
|
||||
double macroSigma_m;
|
||||
double macro_sigma_m;
|
||||
vec3 oldLoc_m;
|
||||
while (!terminatorPtr->check_terminlization(curPart)) {
|
||||
oldLoc_m = curPart.get_x_m();
|
||||
macroSigma_m = interactionPtr->get_macroSigma_m(curPart);
|
||||
moverPtr->move(&curPart, macroSigma_m);
|
||||
macro_sigma_m = interactionPtr->get_macro_sigma_m(curPart);
|
||||
|
||||
moverPtr->move(&curPart, macro_sigma_m);
|
||||
if (terminatorPtr->check_terminlization(curPart)) {
|
||||
break; // Don't double check terminlization, else n_double.
|
||||
} else {
|
||||
IntOut = interactionPtr->do_Interaction(&curPart);
|
||||
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
||||
particle_queue->push(IntOut.get_new_particles()[i]);
|
||||
particle_queue->push_back(IntOut.get_new_particles()[i]);
|
||||
particle_queue->back().set_Id(get_new_id());
|
||||
}
|
||||
if (IntOut.get_delete_current()) {
|
||||
@@ -66,12 +70,16 @@ void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
|
||||
}
|
||||
}
|
||||
}
|
||||
particle_queue->pop();
|
||||
particle_queue->erase(particle_queue->begin() + i);
|
||||
}
|
||||
|
||||
long int Particle_Looper::get_new_id() {
|
||||
long int res = ID_offset + ID_counter;
|
||||
ID_counter++;
|
||||
return ID_offset + ID_counter;
|
||||
}
|
||||
|
||||
long int Particle_Looper::get_last_id() {
|
||||
long int res = ID_offset + ID_counter;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef particle_looper_hpp
|
||||
#define particle_looper_hpp
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include "h5_file.hpp"
|
||||
#include "timer.hpp"
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "logger_builder.hpp"
|
||||
#include "population_builder.hpp"
|
||||
|
||||
#include "injector.hpp"
|
||||
#include "injector_builder.hpp"
|
||||
#include "mover_builder.hpp"
|
||||
#include "interaction_builder.hpp"
|
||||
#include "terminator_builder.hpp"
|
||||
@@ -67,8 +67,9 @@ private:
|
||||
public:
|
||||
void do_loops(int target_decays);
|
||||
private:
|
||||
void process_first(std::queue<Particle> *particle_queue);
|
||||
void process_one(std::vector<Particle> *particle_queue);
|
||||
long int get_new_id();
|
||||
long int get_last_id();
|
||||
|
||||
public:
|
||||
void do_logging_off_loops(int target_decays);
|
||||
|
||||
@@ -21,21 +21,30 @@
|
||||
|
||||
|
||||
class Population_Base : public Process_Base {
|
||||
|
||||
double m_eV;
|
||||
public:
|
||||
Population_Base(species this_species) : Process_Base(this_species) {};
|
||||
Population_Base(species this_species) : Process_Base(this_species) {
|
||||
m_eV = get_species_mass(this_species);
|
||||
};
|
||||
|
||||
virtual void increase_density (const Particle &upPart, const vec3 &oldLoc_m) = 0;
|
||||
virtual void decrease_denisty (const vec3 &loc_m, const double &E_eV) = 0;
|
||||
|
||||
virtual double get_density_m3(const vec3 &loc_m) = 0;
|
||||
virtual Content get_density_m3(const int &E_bin, const Bins &loc_bins) = 0;
|
||||
virtual Sum_bounds get_sumation_bounds(const vec3 &loc_m) = 0;
|
||||
virtual double get_density_m3(const int &E_bin, const Bins &loc_bins) = 0;
|
||||
virtual int get_number_E_bins() = 0;
|
||||
virtual Bins get_loc_bin(const vec3 & loc_m) = 0;
|
||||
virtual double get_E_bin_mid_eV(const int &E_bin) = 0;
|
||||
|
||||
double get_m_eV() {return m_eV;}
|
||||
|
||||
virtual vec3 roll_x_ms() = 0;
|
||||
virtual vec3 roll_v_ms (const vec3 &loc_m) = 0;
|
||||
virtual vec3 get_drift_v_ms(const vec3 &loc_m) = 0;
|
||||
virtual double get_thermal_v_ms() = 0;
|
||||
virtual double get_v_pdf(const double &v_ms) = 0;
|
||||
|
||||
virtual Population_Container *access_container() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -13,17 +13,24 @@
|
||||
|
||||
#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::POP_E_END = load_parameter("POP_E_END");
|
||||
|
||||
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 = 20;
|
||||
int num_r_bins = 10;
|
||||
int num_phi_bins = 12;
|
||||
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, POP_E_END));
|
||||
|
||||
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));
|
||||
@@ -39,6 +46,22 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
||||
Populations.add(new Thermal_Population(tritium5I, new Lin_Kinematics(5*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
||||
}
|
||||
/*
|
||||
if (v_flow == -1) {
|
||||
Populations.add(new Kinetic_Population(tritium, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritiumI, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium2I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium3I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium5I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new T2_Population(new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), rngUni, rngNormal));
|
||||
} else {
|
||||
Populations.add(new Kinetic_Population(tritium, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritiumI, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium2I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium3I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new Kinetic_Population(tritium5I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
||||
}*/
|
||||
return Populations;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
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 POP_E_END;
|
||||
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, double E_max_eV) {
|
||||
init_scales(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV, E_max_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, 2e4) {}
|
||||
|
||||
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, double E_max_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, E_max_eV, num_E_bins);
|
||||
}
|
||||
|
||||
void Population_Container::init_bin_offsets() {
|
||||
@@ -128,10 +130,10 @@ void Population_Container::increase_offset(const vec3 &loc_m, const double &E_eV
|
||||
double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s) {
|
||||
Bins loc_bins = calc_loc_bin(loc_m);
|
||||
int E_bin = E_scale.calc_index(E_eV);
|
||||
return get_density_m3(E_bin, loc_bins, time_s).n_m3;
|
||||
return get_density_m3(E_bin, loc_bins, time_s);
|
||||
}
|
||||
|
||||
Content Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s) {
|
||||
double Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s) {
|
||||
int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||
double cum_time_s = cum_times_s[data_bin];
|
||||
int offset = offsets[data_bin];
|
||||
@@ -141,19 +143,11 @@ Content Population_Container::get_density_m3(const int &E_bin, const Bins &loc_b
|
||||
if (n_m3<0) {
|
||||
n_m3 = 0;
|
||||
}
|
||||
double E_eV = E_scale.get_bin_mid(E_bin);
|
||||
return Content({E_eV, n_m3});
|
||||
return n_m3;
|
||||
}
|
||||
|
||||
Sum_bounds Population_Container::get_sumation_bounds(const vec3 &loc_m) {
|
||||
Bins loc_bins = calc_loc_bin(loc_m);
|
||||
return Sum_bounds{loc_bins, E_scale.get_number_bins()};
|
||||
}
|
||||
|
||||
double Population_Container::roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni) {
|
||||
double low = E_scale.get_lower_bin_bound(E_bin);
|
||||
double up = E_scale.get_upper_bin_bound(E_bin);
|
||||
return low + rngUni->random()*(up-low);
|
||||
int Population_Container::get_number_E_bins() {
|
||||
return E_scale.get_number_bins();
|
||||
}
|
||||
|
||||
Bins Population_Container::calc_loc_bin(const vec3 &loc_m) {
|
||||
@@ -164,6 +158,16 @@ Bins Population_Container::calc_loc_bin(const vec3 &loc_m) {
|
||||
return res;
|
||||
}
|
||||
|
||||
double Population_Container::get_E_bin_mid_eV(const int &E_bin) {
|
||||
return E_scale.get_bin_mid(E_bin);
|
||||
}
|
||||
|
||||
double Population_Container::roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni) {
|
||||
double low = E_scale.get_lower_bin_bound(E_bin);
|
||||
double up = E_scale.get_upper_bin_bound(E_bin);
|
||||
return low + rngUni->random()*(up-low);
|
||||
}
|
||||
|
||||
int Population_Container::calc_data_bin(const Bins &loc_bin, const double &E_bin) {
|
||||
return bin_offsets.z * loc_bin.z + bin_offsets.r*loc_bin.r + bin_offsets.phi*loc_bin.phi + E_bin;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "log_scale.h"
|
||||
#include "random_operations.h"
|
||||
#include "katrin_geo.h"
|
||||
|
||||
|
||||
struct Bins {
|
||||
@@ -55,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, double E_max_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, double E_max_eV);
|
||||
void init_bin_offsets();
|
||||
void init_content_arrays();
|
||||
void init_size_array();
|
||||
@@ -71,14 +71,15 @@ public:
|
||||
|
||||
public:
|
||||
double get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s);
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s);
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s);
|
||||
int get_number_E_bins();
|
||||
Bins calc_loc_bin(const vec3 &loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
double get_E_eV (const int &E_bin);
|
||||
double roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni);
|
||||
|
||||
private:
|
||||
Bins calc_loc_bin(const vec3 &loc_m);
|
||||
int calc_data_bin(const Bins &loc_bin, const double &E_bin);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define positive_terminator_h
|
||||
|
||||
#include "terminator_base.h"
|
||||
#include "katrin_geo.h"
|
||||
|
||||
class PosNeu_Terminator : public Terminator_Base {
|
||||
public:
|
||||
|
||||
@@ -16,15 +16,15 @@ public:
|
||||
Positive_Mover_E_Drift(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Positive_Mover_Drift(this_species, Logger, Population) {};
|
||||
|
||||
protected:
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
|
||||
inline void Positive_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m) {
|
||||
if (macroSigma_m <= 0) {
|
||||
inline void Positive_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
double t_s = 1/macroSigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
double B_T = calc_vec3_abs( 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m)) );
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
protected:
|
||||
void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m);
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ inline void Positive_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *ol
|
||||
}
|
||||
}
|
||||
|
||||
inline void Positive_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯oSigma_m) {
|
||||
inline void Positive_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ void Simulation::doit() {
|
||||
do_decays(simulationStepWidth);
|
||||
}
|
||||
do_decays(simulationStepWidth + num_remaining);
|
||||
looper.flush();
|
||||
print_term_stats();
|
||||
cout<<"Total particles: "<<looper.get_number_total_particles()<<"\n";
|
||||
};
|
||||
|
||||
@@ -46,3 +48,21 @@ void Simulation::do_statusUpdate() {
|
||||
cout<<number_current_decays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
|
||||
void Simulation::print_term_stats() {
|
||||
Terminator_Manager *terminators = looper.get_terminators();
|
||||
vector<species> all_species = get_all_species_vector();
|
||||
Termination_Stats stats;
|
||||
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||
if (terminators->exists(*itr)) {
|
||||
stats = terminators->find(*itr)->get_stats();
|
||||
std::cout<<"# "<<*itr<<"\n";
|
||||
std::cout<<"n_total\t"<<stats.n_total<<"\n";
|
||||
std::cout<<"n_rw\t"<<stats.n_rw<<"\n";
|
||||
std::cout<<"n_dipole\t"<<stats.n_dipole<<"\n";
|
||||
std::cout<<"n_radial\t"<<stats.n_radial<<"\n";
|
||||
std::cout<<"n_max\t"<<stats.n_max<<"\n";
|
||||
std::cout<<"n_energy\t"<<stats.n_energy<<"\n";
|
||||
std::cout<<"n_reaction\t"<<stats.n_reaction<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
private:
|
||||
void do_decays(int number_decays);
|
||||
void do_statusUpdate();
|
||||
void print_term_stats();
|
||||
};
|
||||
|
||||
#endif /* simulation_serial_hpp */
|
||||
|
||||
@@ -1,112 +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 "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 Sub_Interaction_Base {
|
||||
protected:
|
||||
Population_Base *Population;
|
||||
UniRNG *rngUni;
|
||||
|
||||
public:
|
||||
Sub_Interaction_Base(Population_Base *Population, UniRNG *rngUni) {
|
||||
this->Population = Population;
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
|
||||
double get_macroSigma_m(const Particle &interPart);
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV, const vec3 &loc_m) = 0;
|
||||
double get_macroSigma_m_thermal(const Particle &interPart);
|
||||
double get_macroSigma_m_kinetic(const Particle &interPart, const Sum_bounds &bounds);
|
||||
|
||||
public:
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||
|
||||
protected:
|
||||
vec3 get_vOff_ms(const Particle &interPart, const double &minE_eV);
|
||||
};
|
||||
|
||||
inline double Sub_Interaction_Base::get_macroSigma_m(const Particle &interPart) {
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(interPart.get_x_m());
|
||||
if (bounds.num_E_bins <= 1) { //thermal
|
||||
return get_macroSigma_m_thermal(interPart);
|
||||
} else { //kinetic
|
||||
return get_macroSigma_m_kinetic(interPart, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
inline double Sub_Interaction_Base::get_macroSigma_m_thermal(const Particle &interPart) {
|
||||
double E_eV = interPart.get_E_eV();
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double microSigma_m2 = get_microSigma_m2(E_eV, loc_m);
|
||||
double n_target_m3 = Population->get_density_m3(loc_m);
|
||||
return microSigma_m2*n_target_m3;
|
||||
}
|
||||
|
||||
inline double Sub_Interaction_Base::get_macroSigma_m_kinetic(const Particle &interPart, const Sum_bounds &bounds) {
|
||||
// integrate over all energy bins, consider interPart.E_eV << E_eV.
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
Content cont;
|
||||
double macro_Sigma_m2 = 0;
|
||||
for (int E_bin = 0; E_bin< bounds.num_E_bins; E_bin++) {
|
||||
macro_Sigma_m2 += get_microSigma_m2(cont.E_eV, loc_m) * cont.n_m3;
|
||||
}
|
||||
return macro_Sigma_m2;
|
||||
}
|
||||
|
||||
inline vec3 Sub_Interaction_Base::get_vOff_ms(const Particle &interPart, const double &minE_eV) {
|
||||
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<<"Sub_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;
|
||||
}
|
||||
#endif /* sub_interaction_base_h */
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "process_base.h"
|
||||
#include "particle.hpp"
|
||||
#include "katrin_geo.h"
|
||||
|
||||
struct Termination_Stats {
|
||||
int n_total = 0;
|
||||
@@ -22,6 +21,16 @@ struct Termination_Stats {
|
||||
int n_energy = 0;
|
||||
int n_reaction = 0;
|
||||
|
||||
void reset () {
|
||||
n_total = 0;
|
||||
n_rw = 0;
|
||||
n_dipole = 0;
|
||||
n_radial = 0;
|
||||
n_max = 0;
|
||||
n_energy = 0;
|
||||
n_reaction = 0;
|
||||
}
|
||||
|
||||
void to_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
||||
array [0] = n_total;
|
||||
array [1] = n_rw;
|
||||
@@ -65,7 +74,9 @@ public:
|
||||
Termination_Stats get_stats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
void reset_stats() {
|
||||
stats.reset();
|
||||
}
|
||||
void increase_n_reaction() {
|
||||
stats.n_reaction += 1;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#ifndef Thermal_Population_h
|
||||
#define Thermal_Population_h
|
||||
|
||||
#include "katrin_geo.h"
|
||||
|
||||
#include "population_base.h"
|
||||
#include "wgts_kinematics.h"
|
||||
|
||||
@@ -21,42 +19,30 @@ class Thermal_Population : public Population_Base, private RNG_Base {
|
||||
Timer *timer;
|
||||
Base_Kinematics *kinematics;
|
||||
|
||||
|
||||
public:
|
||||
Thermal_Population(species this_species, Base_Kinematics *kinematics, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, 1) {
|
||||
this->timer = timer;
|
||||
this->kinematics = kinematics;
|
||||
}
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||
container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());
|
||||
}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {container.increase_offset(loc_m, E_eV);}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m) {
|
||||
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||
}
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
std::stringstream ss;
|
||||
ss<<"Thermal_Population::get_density_m3: method for non thermal populations.\n";
|
||||
throw MyException(ss.str());
|
||||
//return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||
}
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m) {
|
||||
Sum_bounds res;
|
||||
res.num_E_bins = 1;
|
||||
return res;
|
||||
}
|
||||
double get_density_m3(const vec3 &loc_m) {return container.get_density_m3(loc_m, 0, timer->get_time_s());}
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
virtual vec3 roll_v_ms (const vec3 &loc_m) {
|
||||
return kinematics->get_v_ms(loc_m);
|
||||
}
|
||||
|
||||
virtual Population_Container *access_container() {
|
||||
return &container;
|
||||
}
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||
|
||||
Population_Container *access_container() {return &container;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "timer.hpp"
|
||||
|
||||
#include "constants.h"
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#ifndef timer_hpp
|
||||
#define timer_hpp
|
||||
|
||||
#include "katrin_geo.h"
|
||||
|
||||
class Timer {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
|
||||
@@ -38,10 +38,17 @@ public:
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||
|
||||
Population_Container *access_container() {return nullptr;};
|
||||
|
||||
@@ -80,16 +87,19 @@ inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Content T2_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
std::stringstream ss;
|
||||
ss<<"T2_Population::get_density_m3: method for non thermal populations.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Sum_bounds T2_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||
Sum_bounds res;
|
||||
res.num_E_bins = 0;
|
||||
return res;
|
||||
|
||||
inline vec3 T2_Population::roll_x_ms() {
|
||||
double r_m = r_WGTS_m*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double eta1, eta2, z_can_m;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
z_can_m = z_RW_m + eta1*(z_WGTS_end_m - z_RW_m);
|
||||
} while(eta2*wgtsT2MaxDensity_m3 > get_density_m3(vec3(0,0, z_can_m)));
|
||||
return vec3 (r_m*cos(phi) ,r_m*sin(phi) ,z_can_m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Base_Kinematics {
|
||||
UniRNG *rngUni;
|
||||
NormalRNG *rngNormal;
|
||||
double m_eV, wgtsTemp_K;
|
||||
double v_thermal;
|
||||
|
||||
public:
|
||||
Base_Kinematics(double m_eV, double wgtsTemp_K, UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
@@ -23,12 +24,16 @@ public:
|
||||
this->wgtsTemp_K = wgtsTemp_K;
|
||||
this->rngUni = rngUni;
|
||||
this->rngNormal = rngNormal;
|
||||
v_thermal = sqrt(2*kb_eVK*wgtsTemp_K/m_eV)*c_ms; // most probable speed sqrt(2*kb*T/m)
|
||||
};
|
||||
vec3 get_v_ms(const vec3&loc_m) {
|
||||
return roll_v_thermal_ms() + get_v_offset_ms(loc_m);
|
||||
|
||||
vec3 get_v_ms(const vec3&loc_m) {return roll_v_thermal_ms() + get_v_offset_ms(loc_m);}
|
||||
double get_thermal_v_ms() {return v_thermal;}
|
||||
virtual vec3 get_v_offset_ms(const vec3 &loc_m) = 0;
|
||||
double get_v_pdf(const double &v_ms) {
|
||||
return pow(2/pi, 0.5) * pow(m_eV*pow(c_ms, -2)/kb_eVK/wgtsTemp_K, 1.5) * pow(v_ms, 2) * exp(-m_eV * pow(v_ms/c_ms, 2)/2/kb_eVK/wgtsTemp_K);
|
||||
}
|
||||
private:
|
||||
virtual vec3 get_v_offset_ms(const vec3 &loc_m) = 0;
|
||||
vec3 roll_v_thermal_ms() {
|
||||
double E_eV = roll_MBEnergy(wgtsTemp_K, m_eV, rngNormal);
|
||||
double Speed_ms = calc_v_ms_from_E_eV(E_eV, m_eV);
|
||||
@@ -41,7 +46,7 @@ class WGTS_Kinematics : public Base_Kinematics {
|
||||
Velocity_Container v_data;
|
||||
public:
|
||||
WGTS_Kinematics(double m_eV, double wgtsTemp_K, UniRNG *rngUni, NormalRNG *rngNormal) : Base_Kinematics(m_eV, wgtsTemp_K, rngUni, rngNormal), v_data(get_data_path() + "velocity.dat") {}
|
||||
private:
|
||||
|
||||
vec3 get_v_offset_ms(const vec3 &loc_m) {
|
||||
if (calc_z_m(loc_m)<z_WGTS_start_m) {
|
||||
return vec3(0,0,0);
|
||||
@@ -57,13 +62,10 @@ public:
|
||||
Lin_Kinematics(double m_eV, double wgtsTemp_K, double v_flow_ms, UniRNG *rngUni, NormalRNG *rngNormal) : Base_Kinematics(m_eV, wgtsTemp_K, rngUni, rngNormal) {
|
||||
this->v_flow_ms = v_flow_ms;
|
||||
}
|
||||
private:
|
||||
vec3 get_v_offset_ms(const vec3 &loc_m) {
|
||||
return vec3(0,0,v_flow_ms);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* wgts_kinematics_h */
|
||||
|
||||
@@ -13,8 +13,6 @@ enum cordStyle{xyz, zrphi};
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "katrin_geo.h"
|
||||
|
||||
#include "kinematics.h"
|
||||
#include "base_container.h"
|
||||
|
||||
|
||||
@@ -7,46 +7,21 @@
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "../mc_electron/integrater.h"
|
||||
#include <vector>
|
||||
#include <gsl/gsl_integration.h>
|
||||
using namespace std;
|
||||
|
||||
class data_holder {
|
||||
int data;
|
||||
friend class data_setter;
|
||||
public:
|
||||
data_holder() {
|
||||
data = 3;
|
||||
}
|
||||
int get_data() {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
class data_interface {
|
||||
data_holder data;
|
||||
friend class data_setter;
|
||||
public:
|
||||
data_interface() {};
|
||||
void show_data() {
|
||||
cout<<"data = \t"<<data.get_data()<<"\n";
|
||||
}
|
||||
};
|
||||
|
||||
class data_setter {
|
||||
data_interface *data;
|
||||
public:
|
||||
data_setter(data_interface *data) {
|
||||
this->data = data;
|
||||
}
|
||||
void set_data(int input) {
|
||||
data->data.data = input;
|
||||
}
|
||||
};
|
||||
|
||||
double f(double x, double y, double a) { return a*x*y; }
|
||||
|
||||
// Change the function according to your need
|
||||
float givenFunction(float x, float y)
|
||||
{
|
||||
return pow(pow(x, 4) + pow(y, 5), 0.5);
|
||||
}
|
||||
|
||||
int main() {
|
||||
data_interface data;
|
||||
data_setter data_s(&data);
|
||||
data_s.set_data(5);
|
||||
data.show_data();
|
||||
printf("%f \n", double_simpson_integrate(givenFunction, 2.3, 2.5, 3.7, 4.3, 100, 100));
|
||||
//printf("%f", doubleIntegral(h, k, lx, ux, ly, uy));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user