Merge branch 'working'
This commit is contained in:
@@ -1,48 +1,49 @@
|
||||
//
|
||||
// bedionization.cpp
|
||||
// BED_eT2_ionization.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 22.02.19.
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
|
||||
#include "bedionization.hpp"
|
||||
|
||||
#include "functions.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const double BED_Ionization::S_m2 = 5.4721e-20;
|
||||
const double BED_Ionization::B_eV = EionT2_eV;
|
||||
const double BED_Ionization::u = 1.664;
|
||||
const double BED_Ionization::N = 2;
|
||||
const double BED_Ionization::Ni = 1.173;
|
||||
const double BED_Ionization::c[4] = {1.1262 , 6.3982 , -7.8055, 2.1449} ;
|
||||
const double BED_eT2_Ionization::S_m2 = 5.4721e-20;
|
||||
const double BED_eT2_Ionization::B_eV = EionT2_eV;
|
||||
const double BED_eT2_Ionization::u = 1.664;
|
||||
const double BED_eT2_Ionization::N = 2;
|
||||
const double BED_eT2_Ionization::Ni = 1.173;
|
||||
const double BED_eT2_Ionization::c[4] = {1.1262 , 6.3982 , -7.8055, 2.1449} ;
|
||||
|
||||
double BED_Ionization::get_TCS(double T_eV) {
|
||||
|
||||
double BED_eT2_Ionization::calc_TCS(const double &T_eV) {
|
||||
if (T_eV<=0) {
|
||||
stringstream ss;
|
||||
ss<<"get_TCS(double T_eV): Input energy T_eV="<<T_eV<<" eV < 0.";
|
||||
ss<<"calc_TCS(double T_eV): Input energy T_eV="<<T_eV<<" eV < 0.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
if (T_eV<=B_eV) {
|
||||
return (0);
|
||||
} else {
|
||||
double t = get_t(T_eV);
|
||||
double t = calc_t(T_eV);
|
||||
double fac = S_m2/(t+u+1);
|
||||
double sum1 = get_Dt(t)*log(t);
|
||||
double sum1 = calc_Dt(t)*log(t);
|
||||
double sum2 = (2-Ni/N)*( (t-1)/t - log(t)/(t+1) );
|
||||
return(fac*(sum1 + sum2) );
|
||||
}
|
||||
}
|
||||
|
||||
double BED_Ionization::get_SDCS (double T_eV, double W_eV) {
|
||||
double BED_eT2_Ionization::calc_SDCS (const double &T_eV, const double &W_eV) {
|
||||
if (T_eV<0) {
|
||||
stringstream ss;
|
||||
ss<<"getSDCS(double T_eV, double W_eV): Input energy T_eV="<<T_eV<<" eV < 0.";
|
||||
@@ -56,24 +57,25 @@ double BED_Ionization::get_SDCS (double T_eV, double W_eV) {
|
||||
if ( (T_eV<=B_eV) ||(W_eV >= (T_eV-B_eV) ) ) {
|
||||
return (0);
|
||||
} else {
|
||||
double t = get_t(T_eV);
|
||||
double w = get_w(W_eV);
|
||||
double t = calc_t(T_eV);
|
||||
double w = calc_w(W_eV);
|
||||
double fac = S_m2/B_eV/(t+u+1);
|
||||
double sum1 = (Ni/N - 2)/(t+1) * (1/(w+1) + 1/(t-w));
|
||||
double sum2 = (2-Ni/N) * (pow(w+1,-2) + pow(t-w,-2));
|
||||
double sum3 = log(t)/(N*(w+1)) * get_dfdw(w);
|
||||
double sum3 = log(t)/(N*(w+1)) * calc_dfdw(w);
|
||||
return(fac*(sum1 + sum2 + sum3));
|
||||
}
|
||||
}
|
||||
|
||||
double BED_Ionization::get_t(double T_eV) {
|
||||
double BED_eT2_Ionization::calc_t(const double &T_eV) {
|
||||
return(T_eV/B_eV);
|
||||
}
|
||||
double BED_Ionization::get_w(double W_eV) {
|
||||
|
||||
double BED_eT2_Ionization::calc_w(const double &W_eV) {
|
||||
return(W_eV/B_eV);
|
||||
}
|
||||
|
||||
double BED_Ionization::get_dfdw(double w) {
|
||||
double BED_eT2_Ionization::calc_dfdw(const double &w) {
|
||||
double y = 1/(w+1);
|
||||
double res = 0;
|
||||
for (int i=0;i<4;i++) {
|
||||
@@ -82,7 +84,7 @@ double BED_Ionization::get_dfdw(double w) {
|
||||
return(res);
|
||||
}
|
||||
|
||||
double BED_Ionization::get_Dt(double t) {
|
||||
double BED_eT2_Ionization::calc_Dt(const double &t) {
|
||||
double yh = 2/(t+1);
|
||||
double res = 0;
|
||||
for (int i=0;i<4;i++) {
|
||||
@@ -91,3 +93,4 @@ double BED_Ionization::get_Dt(double t) {
|
||||
res = res/N;
|
||||
return(res);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// BED_eT2_ionization.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BED_eT2_ionization_hpp
|
||||
#define BED_eT2_ionization_hpp
|
||||
|
||||
|
||||
|
||||
// BED Ionization model from Kim, Y.-K. and Rudd, M. E. 1994
|
||||
class BED_eT2_Ionization {
|
||||
static const double S_m2;
|
||||
static const double B_eV;
|
||||
static const double u;
|
||||
static const double N;
|
||||
static const double Ni;
|
||||
static const double c[4];
|
||||
public:
|
||||
BED_eT2_Ionization(){};
|
||||
|
||||
static double calc_TCS(const double &T_eV);
|
||||
static double calc_SDCS(const double &T_eV, const double &W_eV);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
#endif /* BED_eT2_ionization_hpp */
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// bedionization.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 22.02.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef bedionization_hpp
|
||||
#define bedionization_hpp
|
||||
|
||||
|
||||
// BED Ionization model from Kim, Y.-K. and Rudd, M. E. 1994
|
||||
|
||||
class BED_Ionization {
|
||||
public:
|
||||
BED_Ionization(){};
|
||||
double get_TCS(double T_eV);
|
||||
double get_SDCS(double T_eV, double W_eV);
|
||||
protected:
|
||||
static const double S_m2;
|
||||
private:
|
||||
static const double B_eV;
|
||||
static const double u;
|
||||
static const double N,Ni;
|
||||
static const double c[4];
|
||||
|
||||
double get_t(double T);
|
||||
double get_w(double W);
|
||||
|
||||
double get_dfdw(double w);
|
||||
double get_Dt(double t);
|
||||
} ;
|
||||
|
||||
|
||||
#endif /* bedionization_hpp */
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//
|
||||
// constants.hpp
|
||||
// constants.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 08.10.18.
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef constants_hpp
|
||||
#define constants_hpp
|
||||
#ifndef constants_h
|
||||
#define constants_h
|
||||
|
||||
|
||||
typedef const double constant;
|
||||
@@ -32,5 +32,5 @@ constant BetaDecayConst = 1.2072343416696292e-47;
|
||||
constant TritiumDecayEndpoint_eV = 18.574e3;
|
||||
|
||||
|
||||
#endif /* constants_hpp */
|
||||
#endif /* constants_h */
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
//
|
||||
// container_base_functions.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 08.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef container_base_functions_h
|
||||
#define container_base_functions_h
|
||||
|
||||
#include "error_types.h"
|
||||
#include "read_system.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <deque>
|
||||
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include "blitz/array.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
typedef std::map<double,double> dim1Map;
|
||||
|
||||
using namespace std;
|
||||
namespace container_base {
|
||||
inline void add_To_Map(map<double,double> *Map, const deque<double> &queIn) { //Iteration End
|
||||
if (queIn.size()!=2) {
|
||||
stringstream ss;
|
||||
ss<<"addTo_Map: vecIn not big enough.";
|
||||
cout<<ss.str()<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x1 = *queIn.begin();
|
||||
double f = *queIn.rbegin();
|
||||
if ( Map->find(x1)!=Map->end() ) {
|
||||
stringstream ss;
|
||||
ss<<"HIT: Key x="<<x1<<" already exists.";
|
||||
cout<<ss.str()<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
Map->insert(pair<double,double>(x1, f));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void add_To_Map (map<double,T> *Map, deque<double> queIn) {
|
||||
double xN = *queIn.begin();
|
||||
queIn.pop_front();
|
||||
T tempMap;
|
||||
if ( Map->find(xN)==Map->end() ) { // No such element -> generate new Map and insert
|
||||
T tempMap;
|
||||
add_To_Map(&tempMap, queIn);
|
||||
Map->insert(pair<double,T>(xN,tempMap));
|
||||
} else { // Found such element -> Insert to existing map using iteration
|
||||
add_To_Map(&Map->find(xN)->second, queIn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline void add_From_Csv (T *Map, const int &dim, const string &loadFilePath) {
|
||||
ifstream fileStream(loadFilePath);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func_Container::readFromCSV: Could not open file. \n loadFilePath= "<<loadFilePath<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
string lineFromFile;
|
||||
stringstream ss;
|
||||
double temp;
|
||||
deque<double> dequeTemp;
|
||||
bool lineReadError = false;
|
||||
|
||||
while (getline(fileStream, lineFromFile)) {
|
||||
removeLeadingWhites(lineFromFile);
|
||||
replaceDelimiter(lineFromFile);
|
||||
if ( checkIgnoreLine(lineFromFile) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
ss.str(lineFromFile);
|
||||
dequeTemp.clear();
|
||||
for (int i =0;i<=dim;i++) {
|
||||
if (ss>>temp) {
|
||||
dequeTemp.push_back(temp);
|
||||
} else if (!lineReadError) {
|
||||
cout<<"Func_Container::readFromCSV: Warning could not read line in inputFile. \nloadFilePath = "<<loadFilePath<<endl;
|
||||
lineReadError = true;
|
||||
|
||||
}
|
||||
}
|
||||
if (dequeTemp.size() == dim+1) {
|
||||
add_To_Map(Map, dequeTemp);
|
||||
}
|
||||
}
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
inline void write_To_Csv(const dim1Map &Map, ofstream *outFile, string preset = "") { //Iteration End
|
||||
for (dim1Map::const_iterator Itr = Map.begin();Itr!=Map.end();Itr++) {
|
||||
(*outFile)<<preset<<Itr->first<<"\t"<<Itr->second<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void write_To_Csv(const T &Map, ofstream *outFile, string preset = "") {
|
||||
stringstream ss;
|
||||
for (typename T::const_iterator Itr = Map.begin();Itr!=Map.end();Itr++) {
|
||||
ss.clear();
|
||||
ss.str("");
|
||||
ss<<preset<<Itr->first<<"\t";
|
||||
write_To_Csv(Itr->second, outFile, ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void export_To_Csv(const T &Map, string exportFilePath) {
|
||||
ofstream outFile;
|
||||
outFile.open(exportFilePath);
|
||||
if (!outFile.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func2D_Container::exportToFile: Could not open file. \n exportFilePath= "<<exportFilePath<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
outFile<<"# Automatically generated Data of Function2D_Container class by exportToFile().\n";
|
||||
outFile<<"# Generated on "<<getTimeString()<<".\n";
|
||||
outFile<<"#key1 (usually Energy)\tkey2 (angluar distribution or secondary energy)\tparameter (usually SDCS)\n";
|
||||
|
||||
write_To_Csv(Map,&outFile);
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
inline double get_Value(const dim1Map &Map, deque<double> Cord) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
ss<<"getValue: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x = *Cord.begin();
|
||||
if (Map.rbegin()->first < x) {
|
||||
return(Map.rbegin()->second);
|
||||
} else {
|
||||
return (Map.lower_bound(x)->second);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline double get_Value(const T &Map, deque<double> Cord) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
if (Map.rbegin()->first < x) {
|
||||
return( get_Value(Map.rbegin()->second, Cord) );
|
||||
} else {
|
||||
return ( get_Value(Map.lower_bound(x)->second, Cord) );
|
||||
}
|
||||
}
|
||||
|
||||
inline double interpolate_Value(const dim1Map &Map, deque<double> Cord) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
ss<<"interpolat_Value: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x = *Cord.begin();
|
||||
if (Map.begin() == Map.lower_bound(x) ) {
|
||||
return (Map.begin()->second);
|
||||
} else if (Map.end() == Map.lower_bound(x)){
|
||||
return ( (--Map.end())->second );
|
||||
}
|
||||
|
||||
dim1Map::const_iterator lowAnker_Itr = --Map.lower_bound(x);
|
||||
dim1Map::const_iterator upAnker_Itr = Map.lower_bound(x);
|
||||
double lowAnker_x = lowAnker_Itr->first;
|
||||
double lowAnker_fx = lowAnker_Itr->second;
|
||||
double upAnker_x = upAnker_Itr->first;
|
||||
double upAnker_fx = upAnker_Itr->second;
|
||||
|
||||
double res = lowAnker_fx + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fx-lowAnker_fx);
|
||||
return (res);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline double interpolate_Value(const T &Map, deque<double> Cord) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
|
||||
if (x < Map.begin()->first) {
|
||||
return ( interpolate_Value(Map.begin()->second, Cord) );
|
||||
} else if (x > Map.rbegin()->first){
|
||||
return ( interpolate_Value( (Map.rbegin())->second, Cord) );
|
||||
}
|
||||
|
||||
typename T::const_iterator lowAnker_Itr = --Map.lower_bound(x);
|
||||
typename T::const_iterator upAnker_Itr = Map.lower_bound(x);
|
||||
double lowAnker_x = lowAnker_Itr->first;
|
||||
double lowAnker_fxy = interpolate_Value(lowAnker_Itr->second, Cord);
|
||||
double upAnker_x = upAnker_Itr->first;
|
||||
double upAnker_fxy = interpolate_Value(upAnker_Itr->second, Cord);
|
||||
|
||||
double res = lowAnker_fxy + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fxy-lowAnker_fxy);
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
inline void set_Itr(dim1Map Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
ss<<"set_Itr: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x = *Cord.begin();
|
||||
|
||||
if (x>Map.rbegin()->first) {
|
||||
Itr = (--Map.end());
|
||||
} else {
|
||||
Itr = Map.lower_bound(x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void set_Itr(T Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
if (x>Map.rbegin()->first) {
|
||||
set_Itr(Map.rbegin()->second,Cord,Itr);
|
||||
} else {
|
||||
set_Itr(Map.lower_bound(x)->second,Cord,Itr);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline dim1Map::iterator get_Itr(T &Map, deque<double> Cord) {
|
||||
dim1Map::iterator res;
|
||||
set_Itr(Map, Cord, res);
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
// Write some iterator over all bins in maps.
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif /* container_base_functions_h */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,316 @@
|
||||
# Automatically generated Data of Function2D_Container class by exportToFile().
|
||||
# Generated on 20190408.
|
||||
#key1 (usually Energy) key2 (angluar distribution or secondary energy) parameter (usually SDCS)
|
||||
15.0244 0
|
||||
15.3146 0
|
||||
15.43 0
|
||||
15.4934 6.84064e-26
|
||||
15.7398 8.62796e-23
|
||||
16.1102 3.30713e-22
|
||||
16.4893 5.73975e-22
|
||||
16.8773 8.16127e-22
|
||||
17.2744 1.05721e-21
|
||||
17.6809 1.29723e-21
|
||||
18.0969 1.53617e-21
|
||||
18.5228 1.77401e-21
|
||||
18.9586 2.01069e-21
|
||||
19.4048 2.24613e-21
|
||||
19.8614 2.48025e-21
|
||||
20.3287 2.71295e-21
|
||||
20.8071 2.94411e-21
|
||||
21.2967 3.17358e-21
|
||||
21.7978 3.40125e-21
|
||||
22.3108 3.62695e-21
|
||||
22.8357 3.85053e-21
|
||||
23.3731 4.07183e-21
|
||||
23.9231 4.29068e-21
|
||||
24.486 4.50692e-21
|
||||
25.0622 4.72036e-21
|
||||
25.6519 4.93084e-21
|
||||
26.2556 5.13818e-21
|
||||
26.8734 5.34222e-21
|
||||
27.5057 5.54278e-21
|
||||
28.153 5.73971e-21
|
||||
28.8154 5.93285e-21
|
||||
29.4935 6.12203e-21
|
||||
30.1875 6.30712e-21
|
||||
30.8979 6.48797e-21
|
||||
31.6249 6.66445e-21
|
||||
32.3691 6.83643e-21
|
||||
33.1308 7.00379e-21
|
||||
33.9104 7.16643e-21
|
||||
34.7083 7.32424e-21
|
||||
35.525 7.47712e-21
|
||||
36.361 7.62501e-21
|
||||
37.2166 7.76781e-21
|
||||
38.0923 7.90547e-21
|
||||
38.9887 8.03794e-21
|
||||
39.9061 8.16515e-21
|
||||
40.8451 8.28709e-21
|
||||
41.8063 8.40371e-21
|
||||
42.79 8.515e-21
|
||||
43.7969 8.62094e-21
|
||||
44.8275 8.72154e-21
|
||||
45.8823 8.81679e-21
|
||||
46.962 8.90671e-21
|
||||
48.0671 8.99132e-21
|
||||
49.1981 9.07064e-21
|
||||
50.3558 9.14471e-21
|
||||
51.5407 9.21357e-21
|
||||
52.7535 9.27726e-21
|
||||
53.9949 9.33584e-21
|
||||
55.2654 9.38936e-21
|
||||
56.5659 9.43789e-21
|
||||
57.8969 9.48149e-21
|
||||
59.2593 9.52023e-21
|
||||
60.6537 9.55419e-21
|
||||
62.081 9.58346e-21
|
||||
63.5418 9.6081e-21
|
||||
65.037 9.62821e-21
|
||||
66.5674 9.64388e-21
|
||||
68.1338 9.6552e-21
|
||||
69.7371 9.66226e-21
|
||||
71.3781 9.66516e-21
|
||||
73.0577 9.664e-21
|
||||
74.7768 9.65887e-21
|
||||
76.5364 9.64988e-21
|
||||
78.3373 9.63713e-21
|
||||
80.1807 9.62072e-21
|
||||
82.0674 9.60075e-21
|
||||
83.9986 9.57734e-21
|
||||
85.9751 9.55058e-21
|
||||
87.9982 9.52057e-21
|
||||
90.0689 9.48743e-21
|
||||
92.1883 9.45125e-21
|
||||
94.3576 9.41214e-21
|
||||
96.5779 9.3702e-21
|
||||
98.8505 9.32554e-21
|
||||
101.177 9.27826e-21
|
||||
103.557 9.22845e-21
|
||||
105.994 9.17623e-21
|
||||
108.488 9.12168e-21
|
||||
111.041 9.06491e-21
|
||||
113.654 9.00602e-21
|
||||
116.328 8.94509e-21
|
||||
119.066 8.88223e-21
|
||||
121.868 8.81752e-21
|
||||
124.735 8.75106e-21
|
||||
127.67 8.68294e-21
|
||||
130.675 8.61325e-21
|
||||
133.749 8.54207e-21
|
||||
136.897 8.4695e-21
|
||||
140.118 8.3956e-21
|
||||
143.415 8.32047e-21
|
||||
146.79 8.24419e-21
|
||||
150.244 8.16682e-21
|
||||
153.779 8.08846e-21
|
||||
157.398 8.00918e-21
|
||||
161.102 7.92904e-21
|
||||
164.893 7.84812e-21
|
||||
168.773 7.7665e-21
|
||||
172.744 7.68422e-21
|
||||
176.809 7.60137e-21
|
||||
180.969 7.51801e-21
|
||||
185.228 7.4342e-21
|
||||
189.586 7.35e-21
|
||||
194.048 7.26546e-21
|
||||
198.614 7.18065e-21
|
||||
203.287 7.09561e-21
|
||||
208.071 7.01041e-21
|
||||
212.967 6.9251e-21
|
||||
217.978 6.83972e-21
|
||||
223.108 6.75432e-21
|
||||
228.357 6.66895e-21
|
||||
233.731 6.58365e-21
|
||||
239.231 6.49847e-21
|
||||
244.86 6.41344e-21
|
||||
250.622 6.32861e-21
|
||||
256.519 6.24402e-21
|
||||
262.556 6.1597e-21
|
||||
268.734 6.07568e-21
|
||||
275.057 5.992e-21
|
||||
281.53 5.9087e-21
|
||||
288.154 5.8258e-21
|
||||
294.935 5.74333e-21
|
||||
301.875 5.66132e-21
|
||||
308.979 5.5798e-21
|
||||
316.249 5.49878e-21
|
||||
323.691 5.41831e-21
|
||||
331.308 5.33839e-21
|
||||
339.104 5.25905e-21
|
||||
347.083 5.1803e-21
|
||||
355.25 5.10218e-21
|
||||
363.61 5.02469e-21
|
||||
372.166 4.94785e-21
|
||||
380.923 4.87169e-21
|
||||
389.887 4.7962e-21
|
||||
399.061 4.72141e-21
|
||||
408.451 4.64733e-21
|
||||
418.063 4.57397e-21
|
||||
427.9 4.50134e-21
|
||||
437.969 4.42944e-21
|
||||
448.275 4.3583e-21
|
||||
458.823 4.28792e-21
|
||||
469.62 4.2183e-21
|
||||
480.671 4.14945e-21
|
||||
491.981 4.08138e-21
|
||||
503.558 4.01409e-21
|
||||
515.407 3.94759e-21
|
||||
527.535 3.88188e-21
|
||||
539.949 3.81695e-21
|
||||
552.654 3.75283e-21
|
||||
565.659 3.6895e-21
|
||||
578.969 3.62697e-21
|
||||
592.593 3.56524e-21
|
||||
606.537 3.5043e-21
|
||||
620.81 3.44417e-21
|
||||
635.418 3.38483e-21
|
||||
650.37 3.32628e-21
|
||||
665.674 3.26854e-21
|
||||
681.338 3.21158e-21
|
||||
697.371 3.15541e-21
|
||||
713.781 3.10003e-21
|
||||
730.577 3.04544e-21
|
||||
747.768 2.99162e-21
|
||||
765.364 2.93857e-21
|
||||
783.373 2.8863e-21
|
||||
801.807 2.8348e-21
|
||||
820.674 2.78405e-21
|
||||
839.986 2.73407e-21
|
||||
859.751 2.68483e-21
|
||||
879.982 2.63634e-21
|
||||
900.689 2.58859e-21
|
||||
921.883 2.54158e-21
|
||||
943.576 2.49529e-21
|
||||
965.779 2.44972e-21
|
||||
988.505 2.40487e-21
|
||||
1011.77 2.36073e-21
|
||||
1035.57 2.31728e-21
|
||||
1059.94 2.27453e-21
|
||||
1084.88 2.23247e-21
|
||||
1110.41 2.19109e-21
|
||||
1136.54 2.15039e-21
|
||||
1163.28 2.11034e-21
|
||||
1190.66 2.07096e-21
|
||||
1218.68 2.03223e-21
|
||||
1247.35 1.99414e-21
|
||||
1276.7 1.95669e-21
|
||||
1306.75 1.91986e-21
|
||||
1337.49 1.88366e-21
|
||||
1368.97 1.84807e-21
|
||||
1401.18 1.81308e-21
|
||||
1434.15 1.77869e-21
|
||||
1467.9 1.74489e-21
|
||||
1502.44 1.71168e-21
|
||||
1537.79 1.67904e-21
|
||||
1573.98 1.64696e-21
|
||||
1611.02 1.61544e-21
|
||||
1648.93 1.58448e-21
|
||||
1687.73 1.55406e-21
|
||||
1727.44 1.52417e-21
|
||||
1768.09 1.49481e-21
|
||||
1809.69 1.46598e-21
|
||||
1852.28 1.43766e-21
|
||||
1895.86 1.40984e-21
|
||||
1940.48 1.38252e-21
|
||||
1986.14 1.35569e-21
|
||||
2032.87 1.32935e-21
|
||||
2080.71 1.30348e-21
|
||||
2129.67 1.27808e-21
|
||||
2179.78 1.25314e-21
|
||||
2231.08 1.22866e-21
|
||||
2283.57 1.20462e-21
|
||||
2337.31 1.18103e-21
|
||||
2392.31 1.15787e-21
|
||||
2448.6 1.13513e-21
|
||||
2506.22 1.11282e-21
|
||||
2565.19 1.09091e-21
|
||||
2625.56 1.06942e-21
|
||||
2687.34 1.04832e-21
|
||||
2750.57 1.02762e-21
|
||||
2815.3 1.0073e-21
|
||||
2881.54 9.87368e-22
|
||||
2949.35 9.67807e-22
|
||||
3018.75 9.48613e-22
|
||||
3089.79 9.29781e-22
|
||||
3162.49 9.11304e-22
|
||||
3236.91 8.93177e-22
|
||||
3313.08 8.75393e-22
|
||||
3391.04 8.57947e-22
|
||||
3470.83 8.40833e-22
|
||||
3552.5 8.24044e-22
|
||||
3636.1 8.07576e-22
|
||||
3721.66 7.91423e-22
|
||||
3809.23 7.75579e-22
|
||||
3898.87 7.6004e-22
|
||||
3990.61 7.44798e-22
|
||||
4084.51 7.2985e-22
|
||||
4180.63 7.1519e-22
|
||||
4279 7.00814e-22
|
||||
4379.69 6.86715e-22
|
||||
4482.75 6.72889e-22
|
||||
4588.23 6.59331e-22
|
||||
4696.2 6.46036e-22
|
||||
4806.71 6.33e-22
|
||||
4919.81 6.20217e-22
|
||||
5035.58 6.07684e-22
|
||||
5154.07 5.95395e-22
|
||||
5275.35 5.83347e-22
|
||||
5399.49 5.71534e-22
|
||||
5526.54 5.59953e-22
|
||||
5656.59 5.48599e-22
|
||||
5789.69 5.37468e-22
|
||||
5925.93 5.26555e-22
|
||||
6065.37 5.15858e-22
|
||||
6208.1 5.05371e-22
|
||||
6354.18 4.95092e-22
|
||||
6503.7 4.85015e-22
|
||||
6656.74 4.75138e-22
|
||||
6813.38 4.65456e-22
|
||||
6973.71 4.55966e-22
|
||||
7137.81 4.46664e-22
|
||||
7305.77 4.37547e-22
|
||||
7477.68 4.28611e-22
|
||||
7653.64 4.19852e-22
|
||||
7833.73 4.11268e-22
|
||||
8018.07 4.02855e-22
|
||||
8206.74 3.9461e-22
|
||||
8399.86 3.8653e-22
|
||||
8597.51 3.78611e-22
|
||||
8799.82 3.7085e-22
|
||||
9006.89 3.63245e-22
|
||||
9218.83 3.55792e-22
|
||||
9435.76 3.48488e-22
|
||||
9657.79 3.41331e-22
|
||||
9885.05 3.34318e-22
|
||||
10117.7 3.27445e-22
|
||||
10355.7 3.20711e-22
|
||||
10599.4 3.14112e-22
|
||||
10848.8 3.07646e-22
|
||||
11104.1 3.01311e-22
|
||||
11365.4 2.95103e-22
|
||||
11632.8 2.89021e-22
|
||||
11906.6 2.83061e-22
|
||||
12186.8 2.77222e-22
|
||||
12473.5 2.71501e-22
|
||||
12767 2.65896e-22
|
||||
13067.5 2.60405e-22
|
||||
13374.9 2.55024e-22
|
||||
13689.7 2.49753e-22
|
||||
14011.8 2.44589e-22
|
||||
14341.5 2.39529e-22
|
||||
14679 2.34572e-22
|
||||
15024.4 2.29717e-22
|
||||
15377.9 2.24959e-22
|
||||
15739.8 2.20299e-22
|
||||
16110.2 2.15734e-22
|
||||
16489.3 2.11261e-22
|
||||
16877.3 2.0688e-22
|
||||
17274.4 2.02588e-22
|
||||
17680.9 1.98384e-22
|
||||
18096.9 1.94265e-22
|
||||
18522.8 1.90231e-22
|
||||
18958.6 1.86279e-22
|
||||
19404.8 1.82408e-22
|
||||
19861.4 1.78617e-22
|
||||
20092.3 1.74902e-22
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,316 @@
|
||||
# Automatically generated Data of Function2D_Container class by exportToFile().
|
||||
# Generated on 20190408.
|
||||
#key1 (usually Energy) key2 (angluar distribution or secondary energy) parameter (usually SDCS)
|
||||
14.8497 0
|
||||
15.1991 0
|
||||
15.43 0
|
||||
15.4301 6.84064e-26
|
||||
15.5568 8.62796e-23
|
||||
15.9228 3.30713e-22
|
||||
16.2975 5.73975e-22
|
||||
16.681 8.16127e-22
|
||||
17.0735 1.05721e-21
|
||||
17.4753 1.29723e-21
|
||||
17.8865 1.53617e-21
|
||||
18.3074 1.77401e-21
|
||||
18.7382 2.01069e-21
|
||||
19.1791 2.24613e-21
|
||||
19.6304 2.48025e-21
|
||||
20.0923 2.71295e-21
|
||||
20.5651 2.94411e-21
|
||||
21.049 3.17358e-21
|
||||
21.5443 3.40125e-21
|
||||
22.0513 3.62695e-21
|
||||
22.5702 3.85053e-21
|
||||
23.1013 4.07183e-21
|
||||
23.6449 4.29068e-21
|
||||
24.2013 4.50692e-21
|
||||
24.7708 4.72036e-21
|
||||
25.3536 4.93084e-21
|
||||
25.9502 5.13818e-21
|
||||
26.5609 5.34222e-21
|
||||
27.1859 5.54278e-21
|
||||
27.8256 5.73971e-21
|
||||
28.4804 5.93285e-21
|
||||
29.1505 6.12203e-21
|
||||
29.8365 6.30712e-21
|
||||
30.5386 6.48797e-21
|
||||
31.2572 6.66445e-21
|
||||
31.9927 6.83643e-21
|
||||
32.7455 7.00379e-21
|
||||
33.516 7.16643e-21
|
||||
34.3047 7.32424e-21
|
||||
35.1119 7.47712e-21
|
||||
35.9381 7.62501e-21
|
||||
36.7838 7.76781e-21
|
||||
37.6494 7.90547e-21
|
||||
38.5353 8.03794e-21
|
||||
39.4421 8.16515e-21
|
||||
40.3702 8.28709e-21
|
||||
41.3201 8.40371e-21
|
||||
42.2924 8.515e-21
|
||||
43.2876 8.62094e-21
|
||||
44.3062 8.72154e-21
|
||||
45.3488 8.81679e-21
|
||||
46.4159 8.90671e-21
|
||||
47.5081 8.99132e-21
|
||||
48.626 9.07064e-21
|
||||
49.7702 9.14471e-21
|
||||
50.9414 9.21357e-21
|
||||
52.1401 9.27726e-21
|
||||
53.367 9.33584e-21
|
||||
54.6228 9.38936e-21
|
||||
55.9081 9.43789e-21
|
||||
57.2237 9.48149e-21
|
||||
58.5702 9.52023e-21
|
||||
59.9484 9.55419e-21
|
||||
61.3591 9.58346e-21
|
||||
62.8029 9.6081e-21
|
||||
64.2807 9.62821e-21
|
||||
65.7933 9.64388e-21
|
||||
67.3415 9.6552e-21
|
||||
68.9261 9.66226e-21
|
||||
70.548 9.66516e-21
|
||||
72.2081 9.664e-21
|
||||
73.9072 9.65887e-21
|
||||
75.6463 9.64988e-21
|
||||
77.4264 9.63713e-21
|
||||
79.2483 9.62072e-21
|
||||
81.1131 9.60075e-21
|
||||
83.0218 9.57734e-21
|
||||
84.9753 9.55058e-21
|
||||
86.9749 9.52057e-21
|
||||
89.0215 9.48743e-21
|
||||
91.1163 9.45125e-21
|
||||
93.2603 9.41214e-21
|
||||
95.4548 9.3702e-21
|
||||
97.701 9.32554e-21
|
||||
100 9.27826e-21
|
||||
102.353 9.22845e-21
|
||||
104.762 9.17623e-21
|
||||
107.227 9.12168e-21
|
||||
109.75 9.06491e-21
|
||||
112.332 9.00602e-21
|
||||
114.976 8.94509e-21
|
||||
117.681 8.88223e-21
|
||||
120.45 8.81752e-21
|
||||
123.285 8.75106e-21
|
||||
126.186 8.68294e-21
|
||||
129.155 8.61325e-21
|
||||
132.194 8.54207e-21
|
||||
135.305 8.4695e-21
|
||||
138.489 8.3956e-21
|
||||
141.747 8.32047e-21
|
||||
145.083 8.24419e-21
|
||||
148.497 8.16682e-21
|
||||
151.991 8.08846e-21
|
||||
155.568 8.00918e-21
|
||||
159.228 7.92904e-21
|
||||
162.975 7.84812e-21
|
||||
166.81 7.7665e-21
|
||||
170.735 7.68422e-21
|
||||
174.753 7.60137e-21
|
||||
178.865 7.51801e-21
|
||||
183.074 7.4342e-21
|
||||
187.382 7.35e-21
|
||||
191.791 7.26546e-21
|
||||
196.304 7.18065e-21
|
||||
200.923 7.09561e-21
|
||||
205.651 7.01041e-21
|
||||
210.49 6.9251e-21
|
||||
215.443 6.83972e-21
|
||||
220.513 6.75432e-21
|
||||
225.702 6.66895e-21
|
||||
231.013 6.58365e-21
|
||||
236.449 6.49847e-21
|
||||
242.013 6.41344e-21
|
||||
247.708 6.32861e-21
|
||||
253.536 6.24402e-21
|
||||
259.502 6.1597e-21
|
||||
265.609 6.07568e-21
|
||||
271.859 5.992e-21
|
||||
278.256 5.9087e-21
|
||||
284.804 5.8258e-21
|
||||
291.505 5.74333e-21
|
||||
298.365 5.66132e-21
|
||||
305.386 5.5798e-21
|
||||
312.572 5.49878e-21
|
||||
319.927 5.41831e-21
|
||||
327.455 5.33839e-21
|
||||
335.16 5.25905e-21
|
||||
343.047 5.1803e-21
|
||||
351.119 5.10218e-21
|
||||
359.381 5.02469e-21
|
||||
367.838 4.94785e-21
|
||||
376.494 4.87169e-21
|
||||
385.353 4.7962e-21
|
||||
394.421 4.72141e-21
|
||||
403.702 4.64733e-21
|
||||
413.201 4.57397e-21
|
||||
422.924 4.50134e-21
|
||||
432.876 4.42944e-21
|
||||
443.062 4.3583e-21
|
||||
453.488 4.28792e-21
|
||||
464.159 4.2183e-21
|
||||
475.081 4.14945e-21
|
||||
486.26 4.08138e-21
|
||||
497.702 4.01409e-21
|
||||
509.414 3.94759e-21
|
||||
521.401 3.88188e-21
|
||||
533.67 3.81695e-21
|
||||
546.228 3.75283e-21
|
||||
559.081 3.6895e-21
|
||||
572.237 3.62697e-21
|
||||
585.702 3.56524e-21
|
||||
599.484 3.5043e-21
|
||||
613.591 3.44417e-21
|
||||
628.029 3.38483e-21
|
||||
642.807 3.32628e-21
|
||||
657.933 3.26854e-21
|
||||
673.415 3.21158e-21
|
||||
689.261 3.15541e-21
|
||||
705.48 3.10003e-21
|
||||
722.081 3.04544e-21
|
||||
739.072 2.99162e-21
|
||||
756.463 2.93857e-21
|
||||
774.264 2.8863e-21
|
||||
792.483 2.8348e-21
|
||||
811.131 2.78405e-21
|
||||
830.218 2.73407e-21
|
||||
849.753 2.68483e-21
|
||||
869.749 2.63634e-21
|
||||
890.215 2.58859e-21
|
||||
911.163 2.54158e-21
|
||||
932.603 2.49529e-21
|
||||
954.548 2.44972e-21
|
||||
977.01 2.40487e-21
|
||||
1000 2.36073e-21
|
||||
1023.53 2.31728e-21
|
||||
1047.62 2.27453e-21
|
||||
1072.27 2.23247e-21
|
||||
1097.5 2.19109e-21
|
||||
1123.32 2.15039e-21
|
||||
1149.76 2.11034e-21
|
||||
1176.81 2.07096e-21
|
||||
1204.5 2.03223e-21
|
||||
1232.85 1.99414e-21
|
||||
1261.86 1.95669e-21
|
||||
1291.55 1.91986e-21
|
||||
1321.94 1.88366e-21
|
||||
1353.05 1.84807e-21
|
||||
1384.89 1.81308e-21
|
||||
1417.47 1.77869e-21
|
||||
1450.83 1.74489e-21
|
||||
1484.97 1.71168e-21
|
||||
1519.91 1.67904e-21
|
||||
1555.68 1.64696e-21
|
||||
1592.28 1.61544e-21
|
||||
1629.75 1.58448e-21
|
||||
1668.1 1.55406e-21
|
||||
1707.35 1.52417e-21
|
||||
1747.53 1.49481e-21
|
||||
1788.65 1.46598e-21
|
||||
1830.74 1.43766e-21
|
||||
1873.82 1.40984e-21
|
||||
1917.91 1.38252e-21
|
||||
1963.04 1.35569e-21
|
||||
2009.23 1.32935e-21
|
||||
2056.51 1.30348e-21
|
||||
2104.9 1.27808e-21
|
||||
2154.43 1.25314e-21
|
||||
2205.13 1.22866e-21
|
||||
2257.02 1.20462e-21
|
||||
2310.13 1.18103e-21
|
||||
2364.49 1.15787e-21
|
||||
2420.13 1.13513e-21
|
||||
2477.08 1.11282e-21
|
||||
2535.36 1.09091e-21
|
||||
2595.02 1.06942e-21
|
||||
2656.09 1.04832e-21
|
||||
2718.59 1.02762e-21
|
||||
2782.56 1.0073e-21
|
||||
2848.04 9.87368e-22
|
||||
2915.05 9.67807e-22
|
||||
2983.65 9.48613e-22
|
||||
3053.86 9.29781e-22
|
||||
3125.72 9.11304e-22
|
||||
3199.27 8.93177e-22
|
||||
3274.55 8.75393e-22
|
||||
3351.6 8.57947e-22
|
||||
3430.47 8.40833e-22
|
||||
3511.19 8.24044e-22
|
||||
3593.81 8.07576e-22
|
||||
3678.38 7.91423e-22
|
||||
3764.94 7.75579e-22
|
||||
3853.53 7.6004e-22
|
||||
3944.21 7.44798e-22
|
||||
4037.02 7.2985e-22
|
||||
4132.01 7.1519e-22
|
||||
4229.24 7.00814e-22
|
||||
4328.76 6.86715e-22
|
||||
4430.62 6.72889e-22
|
||||
4534.88 6.59331e-22
|
||||
4641.59 6.46036e-22
|
||||
4750.81 6.33e-22
|
||||
4862.6 6.20217e-22
|
||||
4977.02 6.07684e-22
|
||||
5094.14 5.95395e-22
|
||||
5214.01 5.83347e-22
|
||||
5336.7 5.71534e-22
|
||||
5462.28 5.59953e-22
|
||||
5590.81 5.48599e-22
|
||||
5722.37 5.37468e-22
|
||||
5857.02 5.26555e-22
|
||||
5994.84 5.15858e-22
|
||||
6135.91 5.05371e-22
|
||||
6280.29 4.95092e-22
|
||||
6428.07 4.85015e-22
|
||||
6579.33 4.75138e-22
|
||||
6734.15 4.65456e-22
|
||||
6892.61 4.55966e-22
|
||||
7054.8 4.46664e-22
|
||||
7220.81 4.37547e-22
|
||||
7390.72 4.28611e-22
|
||||
7564.63 4.19852e-22
|
||||
7742.64 4.11268e-22
|
||||
7924.83 4.02855e-22
|
||||
8111.31 3.9461e-22
|
||||
8302.18 3.8653e-22
|
||||
8497.53 3.78611e-22
|
||||
8697.49 3.7085e-22
|
||||
8902.15 3.63245e-22
|
||||
9111.63 3.55792e-22
|
||||
9326.03 3.48488e-22
|
||||
9545.48 3.41331e-22
|
||||
9770.1 3.34318e-22
|
||||
10000 3.27445e-22
|
||||
10235.3 3.20711e-22
|
||||
10476.2 3.14112e-22
|
||||
10722.7 3.07646e-22
|
||||
10975 3.01311e-22
|
||||
11233.2 2.95103e-22
|
||||
11497.6 2.89021e-22
|
||||
11768.1 2.83061e-22
|
||||
12045 2.77222e-22
|
||||
12328.5 2.71501e-22
|
||||
12618.6 2.65896e-22
|
||||
12915.5 2.60405e-22
|
||||
13219.4 2.55024e-22
|
||||
13530.5 2.49753e-22
|
||||
13848.9 2.44589e-22
|
||||
14174.7 2.39529e-22
|
||||
14508.3 2.34572e-22
|
||||
14849.7 2.29717e-22
|
||||
15199.1 2.24959e-22
|
||||
15556.8 2.20299e-22
|
||||
15922.8 2.15734e-22
|
||||
16297.5 2.11261e-22
|
||||
16681 2.0688e-22
|
||||
17073.5 2.02588e-22
|
||||
17475.3 1.98384e-22
|
||||
17886.5 1.94265e-22
|
||||
18307.4 1.90231e-22
|
||||
18738.2 1.86279e-22
|
||||
19179.1 1.82408e-22
|
||||
19630.4 1.78617e-22
|
||||
20092.3 1.74902e-22
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,316 @@
|
||||
# Total Ionization Cross Section from
|
||||
# BED Theory
|
||||
# Initial Energy (eV) Cross section (m^2)
|
||||
14.8497 0
|
||||
15.1991 0
|
||||
15.43 0
|
||||
15.4301 6.84064e-26
|
||||
15.5568 8.62796e-23
|
||||
15.9228 3.30713e-22
|
||||
16.2975 5.73975e-22
|
||||
16.681 8.16127e-22
|
||||
17.0735 1.05721e-21
|
||||
17.4753 1.29723e-21
|
||||
17.8865 1.53617e-21
|
||||
18.3074 1.77401e-21
|
||||
18.7382 2.01069e-21
|
||||
19.1791 2.24613e-21
|
||||
19.6304 2.48025e-21
|
||||
20.0923 2.71295e-21
|
||||
20.5651 2.94411e-21
|
||||
21.049 3.17358e-21
|
||||
21.5443 3.40125e-21
|
||||
22.0513 3.62695e-21
|
||||
22.5702 3.85053e-21
|
||||
23.1013 4.07183e-21
|
||||
23.6449 4.29068e-21
|
||||
24.2013 4.50692e-21
|
||||
24.7708 4.72036e-21
|
||||
25.3536 4.93084e-21
|
||||
25.9502 5.13818e-21
|
||||
26.5609 5.34222e-21
|
||||
27.1859 5.54278e-21
|
||||
27.8256 5.73971e-21
|
||||
28.4804 5.93285e-21
|
||||
29.1505 6.12203e-21
|
||||
29.8365 6.30712e-21
|
||||
30.5386 6.48797e-21
|
||||
31.2572 6.66445e-21
|
||||
31.9927 6.83643e-21
|
||||
32.7455 7.00379e-21
|
||||
33.516 7.16643e-21
|
||||
34.3047 7.32424e-21
|
||||
35.1119 7.47712e-21
|
||||
35.9381 7.62501e-21
|
||||
36.7838 7.76781e-21
|
||||
37.6494 7.90547e-21
|
||||
38.5353 8.03794e-21
|
||||
39.4421 8.16515e-21
|
||||
40.3702 8.28709e-21
|
||||
41.3201 8.40371e-21
|
||||
42.2924 8.515e-21
|
||||
43.2876 8.62094e-21
|
||||
44.3062 8.72154e-21
|
||||
45.3488 8.81679e-21
|
||||
46.4159 8.90671e-21
|
||||
47.5081 8.99132e-21
|
||||
48.626 9.07064e-21
|
||||
49.7702 9.14471e-21
|
||||
50.9414 9.21357e-21
|
||||
52.1401 9.27726e-21
|
||||
53.367 9.33584e-21
|
||||
54.6228 9.38936e-21
|
||||
55.9081 9.43789e-21
|
||||
57.2237 9.48149e-21
|
||||
58.5702 9.52023e-21
|
||||
59.9484 9.55419e-21
|
||||
61.3591 9.58346e-21
|
||||
62.8029 9.6081e-21
|
||||
64.2807 9.62821e-21
|
||||
65.7933 9.64388e-21
|
||||
67.3415 9.6552e-21
|
||||
68.9261 9.66226e-21
|
||||
70.548 9.66516e-21
|
||||
72.2081 9.664e-21
|
||||
73.9072 9.65887e-21
|
||||
75.6463 9.64988e-21
|
||||
77.4264 9.63713e-21
|
||||
79.2483 9.62072e-21
|
||||
81.1131 9.60075e-21
|
||||
83.0218 9.57734e-21
|
||||
84.9753 9.55058e-21
|
||||
86.9749 9.52057e-21
|
||||
89.0215 9.48743e-21
|
||||
91.1163 9.45125e-21
|
||||
93.2603 9.41214e-21
|
||||
95.4548 9.3702e-21
|
||||
97.701 9.32554e-21
|
||||
100 9.27826e-21
|
||||
102.353 9.22845e-21
|
||||
104.762 9.17623e-21
|
||||
107.227 9.12168e-21
|
||||
109.75 9.06491e-21
|
||||
112.332 9.00602e-21
|
||||
114.976 8.94509e-21
|
||||
117.681 8.88223e-21
|
||||
120.45 8.81752e-21
|
||||
123.285 8.75106e-21
|
||||
126.186 8.68294e-21
|
||||
129.155 8.61325e-21
|
||||
132.194 8.54207e-21
|
||||
135.305 8.4695e-21
|
||||
138.489 8.3956e-21
|
||||
141.747 8.32047e-21
|
||||
145.083 8.24419e-21
|
||||
148.497 8.16682e-21
|
||||
151.991 8.08846e-21
|
||||
155.568 8.00918e-21
|
||||
159.228 7.92904e-21
|
||||
162.975 7.84812e-21
|
||||
166.81 7.7665e-21
|
||||
170.735 7.68422e-21
|
||||
174.753 7.60137e-21
|
||||
178.865 7.51801e-21
|
||||
183.074 7.4342e-21
|
||||
187.382 7.35e-21
|
||||
191.791 7.26546e-21
|
||||
196.304 7.18065e-21
|
||||
200.923 7.09561e-21
|
||||
205.651 7.01041e-21
|
||||
210.49 6.9251e-21
|
||||
215.443 6.83972e-21
|
||||
220.513 6.75432e-21
|
||||
225.702 6.66895e-21
|
||||
231.013 6.58365e-21
|
||||
236.449 6.49847e-21
|
||||
242.013 6.41344e-21
|
||||
247.708 6.32861e-21
|
||||
253.536 6.24402e-21
|
||||
259.502 6.1597e-21
|
||||
265.609 6.07568e-21
|
||||
271.859 5.992e-21
|
||||
278.256 5.9087e-21
|
||||
284.804 5.8258e-21
|
||||
291.505 5.74333e-21
|
||||
298.365 5.66132e-21
|
||||
305.386 5.5798e-21
|
||||
312.572 5.49878e-21
|
||||
319.927 5.41831e-21
|
||||
327.455 5.33839e-21
|
||||
335.16 5.25905e-21
|
||||
343.047 5.1803e-21
|
||||
351.119 5.10218e-21
|
||||
359.381 5.02469e-21
|
||||
367.838 4.94785e-21
|
||||
376.494 4.87169e-21
|
||||
385.353 4.7962e-21
|
||||
394.421 4.72141e-21
|
||||
403.702 4.64733e-21
|
||||
413.201 4.57397e-21
|
||||
422.924 4.50134e-21
|
||||
432.876 4.42944e-21
|
||||
443.062 4.3583e-21
|
||||
453.488 4.28792e-21
|
||||
464.159 4.2183e-21
|
||||
475.081 4.14945e-21
|
||||
486.26 4.08138e-21
|
||||
497.702 4.01409e-21
|
||||
509.414 3.94759e-21
|
||||
521.401 3.88188e-21
|
||||
533.67 3.81695e-21
|
||||
546.228 3.75283e-21
|
||||
559.081 3.6895e-21
|
||||
572.237 3.62697e-21
|
||||
585.702 3.56524e-21
|
||||
599.484 3.5043e-21
|
||||
613.591 3.44417e-21
|
||||
628.029 3.38483e-21
|
||||
642.807 3.32628e-21
|
||||
657.933 3.26854e-21
|
||||
673.415 3.21158e-21
|
||||
689.261 3.15541e-21
|
||||
705.48 3.10003e-21
|
||||
722.081 3.04544e-21
|
||||
739.072 2.99162e-21
|
||||
756.463 2.93857e-21
|
||||
774.264 2.8863e-21
|
||||
792.483 2.8348e-21
|
||||
811.131 2.78405e-21
|
||||
830.218 2.73407e-21
|
||||
849.753 2.68483e-21
|
||||
869.749 2.63634e-21
|
||||
890.215 2.58859e-21
|
||||
911.163 2.54158e-21
|
||||
932.603 2.49529e-21
|
||||
954.548 2.44972e-21
|
||||
977.01 2.40487e-21
|
||||
1000 2.36073e-21
|
||||
1023.53 2.31728e-21
|
||||
1047.62 2.27453e-21
|
||||
1072.27 2.23247e-21
|
||||
1097.5 2.19109e-21
|
||||
1123.32 2.15039e-21
|
||||
1149.76 2.11034e-21
|
||||
1176.81 2.07096e-21
|
||||
1204.5 2.03223e-21
|
||||
1232.85 1.99414e-21
|
||||
1261.86 1.95669e-21
|
||||
1291.55 1.91986e-21
|
||||
1321.94 1.88366e-21
|
||||
1353.05 1.84807e-21
|
||||
1384.89 1.81308e-21
|
||||
1417.47 1.77869e-21
|
||||
1450.83 1.74489e-21
|
||||
1484.97 1.71168e-21
|
||||
1519.91 1.67904e-21
|
||||
1555.68 1.64696e-21
|
||||
1592.28 1.61544e-21
|
||||
1629.75 1.58448e-21
|
||||
1668.1 1.55406e-21
|
||||
1707.35 1.52417e-21
|
||||
1747.53 1.49481e-21
|
||||
1788.65 1.46598e-21
|
||||
1830.74 1.43766e-21
|
||||
1873.82 1.40984e-21
|
||||
1917.91 1.38252e-21
|
||||
1963.04 1.35569e-21
|
||||
2009.23 1.32935e-21
|
||||
2056.51 1.30348e-21
|
||||
2104.9 1.27808e-21
|
||||
2154.43 1.25314e-21
|
||||
2205.13 1.22866e-21
|
||||
2257.02 1.20462e-21
|
||||
2310.13 1.18103e-21
|
||||
2364.49 1.15787e-21
|
||||
2420.13 1.13513e-21
|
||||
2477.08 1.11282e-21
|
||||
2535.36 1.09091e-21
|
||||
2595.02 1.06942e-21
|
||||
2656.09 1.04832e-21
|
||||
2718.59 1.02762e-21
|
||||
2782.56 1.0073e-21
|
||||
2848.04 9.87368e-22
|
||||
2915.05 9.67807e-22
|
||||
2983.65 9.48613e-22
|
||||
3053.86 9.29781e-22
|
||||
3125.72 9.11304e-22
|
||||
3199.27 8.93177e-22
|
||||
3274.55 8.75393e-22
|
||||
3351.6 8.57947e-22
|
||||
3430.47 8.40833e-22
|
||||
3511.19 8.24044e-22
|
||||
3593.81 8.07576e-22
|
||||
3678.38 7.91423e-22
|
||||
3764.94 7.75579e-22
|
||||
3853.53 7.6004e-22
|
||||
3944.21 7.44798e-22
|
||||
4037.02 7.2985e-22
|
||||
4132.01 7.1519e-22
|
||||
4229.24 7.00814e-22
|
||||
4328.76 6.86715e-22
|
||||
4430.62 6.72889e-22
|
||||
4534.88 6.59331e-22
|
||||
4641.59 6.46036e-22
|
||||
4750.81 6.33e-22
|
||||
4862.6 6.20217e-22
|
||||
4977.02 6.07684e-22
|
||||
5094.14 5.95395e-22
|
||||
5214.01 5.83347e-22
|
||||
5336.7 5.71534e-22
|
||||
5462.28 5.59953e-22
|
||||
5590.81 5.48599e-22
|
||||
5722.37 5.37468e-22
|
||||
5857.02 5.26555e-22
|
||||
5994.84 5.15858e-22
|
||||
6135.91 5.05371e-22
|
||||
6280.29 4.95092e-22
|
||||
6428.07 4.85015e-22
|
||||
6579.33 4.75138e-22
|
||||
6734.15 4.65456e-22
|
||||
6892.61 4.55966e-22
|
||||
7054.8 4.46664e-22
|
||||
7220.81 4.37547e-22
|
||||
7390.72 4.28611e-22
|
||||
7564.63 4.19852e-22
|
||||
7742.64 4.11268e-22
|
||||
7924.83 4.02855e-22
|
||||
8111.31 3.9461e-22
|
||||
8302.18 3.8653e-22
|
||||
8497.53 3.78611e-22
|
||||
8697.49 3.7085e-22
|
||||
8902.15 3.63245e-22
|
||||
9111.63 3.55792e-22
|
||||
9326.03 3.48488e-22
|
||||
9545.48 3.41331e-22
|
||||
9770.1 3.34318e-22
|
||||
10000 3.27445e-22
|
||||
10235.3 3.20711e-22
|
||||
10476.2 3.14112e-22
|
||||
10722.7 3.07646e-22
|
||||
10975 3.01311e-22
|
||||
11233.2 2.95103e-22
|
||||
11497.6 2.89021e-22
|
||||
11768.1 2.83061e-22
|
||||
12045 2.77222e-22
|
||||
12328.5 2.71501e-22
|
||||
12618.6 2.65896e-22
|
||||
12915.5 2.60405e-22
|
||||
13219.4 2.55024e-22
|
||||
13530.5 2.49753e-22
|
||||
13848.9 2.44589e-22
|
||||
14174.7 2.39529e-22
|
||||
14508.3 2.34572e-22
|
||||
14849.7 2.29717e-22
|
||||
15199.1 2.24959e-22
|
||||
15556.8 2.20299e-22
|
||||
15922.8 2.15734e-22
|
||||
16297.5 2.11261e-22
|
||||
16681 2.0688e-22
|
||||
17073.5 2.02588e-22
|
||||
17475.3 1.98384e-22
|
||||
17886.5 1.94265e-22
|
||||
18307.4 1.90231e-22
|
||||
18738.2 1.86279e-22
|
||||
19179.1 1.82408e-22
|
||||
19630.4 1.78617e-22
|
||||
20092.3 1.74902e-22
|
||||
@@ -0,0 +1,49 @@
|
||||
# Total Elastic Scattering Cross Section from
|
||||
# Yoon et al, Cross Sections for Electron Collisions with Hydrogen Molecules, 2008
|
||||
# Energy (eV) Cross section (m^2)
|
||||
|
||||
0.02 7.41e-20
|
||||
0.03 7.71e-20
|
||||
0.04 8.08e-20
|
||||
0.05 8.32e-20
|
||||
0.06 8.51e-20
|
||||
0.07 8.69e-20
|
||||
0.08 8.84e-20
|
||||
0.09 8.99e-20
|
||||
0.1 9.13e-20
|
||||
0.12 9.33e-20
|
||||
0.15 9.55e-20
|
||||
0.2 9.83e-20
|
||||
0.25 10.04e-20
|
||||
0.3 10.24e-20
|
||||
0.4 10.61e-20
|
||||
0.5 10.95e-20
|
||||
0.6 11.28e-20
|
||||
0.7 11.59e-20
|
||||
0.8 11.88e-20
|
||||
0.9 12.16e-20
|
||||
1.0 12.36e-20
|
||||
1.25 13.00e-20
|
||||
1.5 13.55e-20
|
||||
2.0 14.11e-20
|
||||
3.0 14.12e-20
|
||||
4.0 13.40e-20
|
||||
5.0 12.51e-20
|
||||
6.0 11.45e-20
|
||||
8.0 9.85e-20
|
||||
10.0 8.58e-20
|
||||
12.0 7.61e-20
|
||||
14.0 6.92e-20
|
||||
16.0 6.32e-20
|
||||
18.0 5.78e-20
|
||||
20.0 5.26e-20
|
||||
25.0 4.23e-20
|
||||
30.0 3.40e-20
|
||||
35.0 2.81e-20
|
||||
40.0 2.36e-20
|
||||
50.0 1.73e-20
|
||||
60.0 1.31e-20
|
||||
70.0 1.06e-20
|
||||
80.0 0.89e-20
|
||||
90.0 0.81e-20
|
||||
100.0 0.74e-20
|
||||
@@ -0,0 +1,61 @@
|
||||
# Total Ionization Cross Section from
|
||||
# Yoon et al, Cross Sections for Electron Collisions with Hydrogen Molecules, 2008
|
||||
# Energy (eV) Cross section (m^2)
|
||||
|
||||
16.0 0.0299e-20
|
||||
16.5 0.0607e-20
|
||||
17.0 0.0924e-20
|
||||
17.5 0.123e-20
|
||||
18.0 0.156e-20
|
||||
18.5 0.187e-20
|
||||
19.0 0.22e-20
|
||||
19.5 0.249e-20
|
||||
20.0 0.28e-20
|
||||
20.5 0.31e-20
|
||||
21.0 0.336e-20
|
||||
21.5 0.362e-20
|
||||
22.0 0.39e-20
|
||||
22.5 0.414e-20
|
||||
23.0 0.439e-20
|
||||
23.5 0.461e-20
|
||||
24.0 0.484e-20
|
||||
24.5 0.505e-20
|
||||
25.0 0.524e-20
|
||||
30.0 0.651e-20
|
||||
35.0 0.76e-20
|
||||
40.0 0.84e-20
|
||||
45.0 0.88e-20
|
||||
50.0 0.908e-20
|
||||
55.0 0.931e-20
|
||||
60.0 0.944e-20
|
||||
65.0 0.948e-20
|
||||
70.0 0.949e-20
|
||||
80.0 0.937e-20
|
||||
85.0 0.928e-20
|
||||
90.0 0.919e-20
|
||||
95.0 0.911e-20
|
||||
100.0 0.9e-20
|
||||
110.0 0.872e-20
|
||||
120.0 0.852e-20
|
||||
140.0 0.806e-20
|
||||
160.0 0.763e-20
|
||||
180.0 0.714e-20
|
||||
200.0 0.676e-20
|
||||
225.0 0.636e-20
|
||||
250.0 0.596e-20
|
||||
275.0 0.556e-20
|
||||
300.0 0.529e-20
|
||||
350.0 0.477e-20
|
||||
400.0 0.436e-20
|
||||
450.0 0.398e-20
|
||||
500.0 0.373e-20
|
||||
550.0 0.339e-20
|
||||
600.0 0.317e-20
|
||||
650.0 0.302e-20
|
||||
700.0 0.283e-20
|
||||
750.0 0.272e-20
|
||||
800.0 0.257e-20
|
||||
850.0 0.248e-20
|
||||
900.0 0.235e-20
|
||||
950.0 0.222e-20
|
||||
1000.0 0.211e-20
|
||||
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// density_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "density_container.hpp"
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
WGTS_Geo::WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) {
|
||||
this->z_min_m = z_min_m;
|
||||
this->z_max_m = z_max_m;
|
||||
this->r_max_m = r_max_m;
|
||||
this->zrphi_numBins = zrphi_numBins;
|
||||
dim1Map bin_l_m;
|
||||
dim1Map bin_V_m3;
|
||||
init_bin_maps();
|
||||
}
|
||||
|
||||
void WGTS_Geo::init_bin_maps() {
|
||||
int n_z = zrphi_numBins[0];
|
||||
int n_r = zrphi_numBins[1];
|
||||
int n_phi = zrphi_numBins[2];
|
||||
double len_m = (z_max_m-z_min_m)/n_z;
|
||||
double rad_step_m = r_max_m/n_r;
|
||||
|
||||
double z_m,r_m;
|
||||
for (int i_z=1;i_z<=n_z;i_z++) {
|
||||
z_m = z_min_m + i_z * len_m;
|
||||
bin_l_m.insert(dim1Pair(z_m,len_m));
|
||||
}
|
||||
double V_m3;
|
||||
for (int i_r=1;i_r<=n_r;i_r++) {
|
||||
r_m = i_r * rad_step_m;
|
||||
V_m3 = (pi*pow(r_m,2)-pi*pow(r_m-rad_step_m,2))/n_phi;
|
||||
bin_V_m3.insert(dim1Pair(r_m,V_m3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double WGTS_Geo::get_Bin_l_m (double z_m) const {
|
||||
if (check_z_outside(z_m)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS_Geo_Container::get_Bin_l_m: z_m not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (bin_l_m.lower_bound(z_m)->second);
|
||||
}
|
||||
|
||||
double WGTS_Geo::get_Bin_V_m3(double r_m) const {
|
||||
if (check_r_outside(r_m)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS_Geo_Container::get_Bin_V_m3: r_m not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (bin_V_m3.lower_bound(r_m)->second);
|
||||
}
|
||||
|
||||
bool WGTS_Geo::outside_Container(vec3 Cords, cordStyle cordStyleIn) const {
|
||||
Cords = zrphiCords(Cords, cordStyleIn);
|
||||
return (check_z_outside (Cords[0]) || check_r_outside(Cords[1]));
|
||||
}
|
||||
bool WGTS_Geo::check_z_outside (double z_m) const {
|
||||
if (z_m<z_min_m) {
|
||||
return (true);
|
||||
}
|
||||
if (z_m>z_max_m) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
bool WGTS_Geo::check_r_outside (double r_m) const {
|
||||
if (r_m>r_max_m) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
vec3 WGTS_Geo::zrphiCords(vec3 Cords, cordStyle cordStyleIn) const {
|
||||
if (cordStyleIn == zrphi) {
|
||||
return (Cords);
|
||||
}
|
||||
double z = Cords[0];
|
||||
double r = sqrt(Cords[1]*Cords[1] + Cords[2]*Cords[2]);
|
||||
double phi;
|
||||
if (Cords[1] >= 0) {
|
||||
phi = acos(Cords[2]/r);
|
||||
} else {
|
||||
phi = 2*pi - acos(Cords[2]/r);
|
||||
}
|
||||
return (vec3(z,r,phi));
|
||||
}
|
||||
|
||||
|
||||
WGTS3D_ParticleTime_s_Container::WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) : WGTS_Geo(z_min_m, z_max_m, r_max_m, zrphi_numBins) {
|
||||
init_Map();
|
||||
}
|
||||
|
||||
|
||||
void WGTS3D_ParticleTime_s_Container::init_Map() {
|
||||
// Give posibility for non linear Bins....
|
||||
int n_z = zrphi_numBins[0];
|
||||
int n_r = zrphi_numBins[1];
|
||||
int n_phi = zrphi_numBins[2];
|
||||
double step_z_m = (z_max_m-z_min_m)/n_z;
|
||||
double step_r_m = r_max_m/n_r;
|
||||
double step_phi = 2*pi/n_phi;
|
||||
|
||||
double z_m,r_m,phi;
|
||||
for (int i_z=1;i_z<=n_z;i_z++) {
|
||||
z_m = z_min_m + i_z * step_z_m;
|
||||
for (int i_r=1;i_r<=n_r;i_r++) {
|
||||
r_m = i_r * step_r_m;
|
||||
for (int i_phi=1;i_phi<=n_phi;i_phi++) {
|
||||
phi = step_phi * i_phi;
|
||||
add_ankerpoint(z_m, r_m, phi, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double WGTS3D_ParticleTime_s_Container::getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn) const {
|
||||
if (outside_Container(loc_m, cordStyleIn)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS3D_ParticleTime_s_Container::getDensity: loc_old or loc_new not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
loc_m = zrphiCords(loc_m);
|
||||
return (findBin(loc_m)->second/simTime_s);
|
||||
}
|
||||
|
||||
void WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn) {
|
||||
if (outside_Container(loc_old, cordStyleIn) || outside_Container(loc_new, cordStyleIn)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density: loc_old or loc_new not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
vec3 loc_min = zrphiCords(loc_old, cordStyleIn);
|
||||
vec3 loc_max = zrphiCords(loc_new, cordStyleIn);
|
||||
double zmin_m = loc_min[0];
|
||||
double zmax_m = loc_min[0];
|
||||
if (zmax_m<zmin_m) {
|
||||
swap (zmin_m, zmax_m);
|
||||
swap (loc_min, loc_max);
|
||||
}
|
||||
// Check start and end in same r and phi bin
|
||||
|
||||
dim3Map::iterator zItr_min = Map.lower_bound(zmin_m);
|
||||
dim3Map::iterator zItr_max = Map.lower_bound(zmax_m);
|
||||
double r_m = loc_min[1];
|
||||
double phi = loc_min[2];
|
||||
double l_m;
|
||||
for (dim3Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||
l_m = get_Bin_l_m(Itr->first);
|
||||
container_base::get_Itr(Itr->second, deque<double> {r_m,phi})->second += l_m/vAbs_ms;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// density_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef density_container_hpp
|
||||
#define density_container_hpp
|
||||
|
||||
#include "container_base_functions.h"
|
||||
|
||||
typedef std::map<double,double> dim1Map;
|
||||
typedef std::pair<double,double> dim1Pair;
|
||||
|
||||
typedef std::map<double,dim1Map> dim2Map;
|
||||
typedef std::pair<double,dim1Map> dim2Pair;
|
||||
|
||||
typedef std::map<double,dim2Map> dim3Map;
|
||||
typedef std::pair<double,dim2Map> dim3Pair;
|
||||
|
||||
typedef enum cordStyle{xyz, zrphi} cordStyle;
|
||||
|
||||
|
||||
class Base3D_FuncContainer {
|
||||
public:
|
||||
Base3D_FuncContainer() {};
|
||||
Base3D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv(&Map, 3, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double z, double fxyz){container_base::add_To_Map(&Map, deque<double> {x,y,z,fxyz});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) const {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim3Map get_Map() const {return (Map);}
|
||||
protected:
|
||||
dim3Map Map;
|
||||
};
|
||||
|
||||
|
||||
class WGTS_Geo {
|
||||
public:
|
||||
WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
protected:
|
||||
void init_bin_maps();
|
||||
|
||||
double get_Bin_l_m (double z_m) const ;
|
||||
double get_Bin_V_m3(double r_m) const;
|
||||
|
||||
bool outside_Container(vec3 Cords, cordStyle cordStyleIn = xyz) const;
|
||||
bool check_z_outside (double z_m) const;
|
||||
bool check_r_outside (double r_m) const;
|
||||
vec3 zrphiCords(vec3 Cords, cordStyle cordStyleIn = xyz) const;
|
||||
|
||||
double z_min_m;
|
||||
double z_max_m;
|
||||
double r_max_m;
|
||||
vec3 zrphi_numBins;
|
||||
dim1Map bin_l_m;
|
||||
dim1Map bin_V_m3;
|
||||
};
|
||||
|
||||
// WGTS3D_ParticleTime_s_Container Contains cumulative duration of stay in bin.
|
||||
class WGTS3D_ParticleTime_s_Container : public Base3D_FuncContainer , public WGTS_Geo {
|
||||
public:
|
||||
WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
protected:
|
||||
void init_Map();
|
||||
using Base3D_FuncContainer::add_ankerpoint;
|
||||
using Base3D_FuncContainer::fillFromCSV;
|
||||
|
||||
public:
|
||||
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz) const;
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
|
||||
protected:
|
||||
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords) const {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
};
|
||||
// Add option to load default from file...
|
||||
//Part3D_WGTS_Container(std::string loadFilePath, double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
//void check_Bins()
|
||||
|
||||
/*
|
||||
typedef std::map<double,dim3Map> dim4Map;
|
||||
typedef std::pair<double,dim3Map> dim4Pair;
|
||||
|
||||
class Base4D_FuncContainer {
|
||||
public:
|
||||
Base4D_FuncContainer() {};
|
||||
Base4D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv(&Map, 4, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double z, double E, double fxyzE){container_base::add_To_Map(&Map, deque<double> {x,y,z,E,fxyzE});};
|
||||
|
||||
void exportToFile(std::string exportFilePath){container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim4Map get_Map() {return (Map);}
|
||||
protected:
|
||||
dim4Map Map;
|
||||
};
|
||||
|
||||
class WGTS4D_ParticleTime_s_Container : public Base4D_FuncContainer , public WGTS_Geo {
|
||||
public:
|
||||
WGTS4D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
protected:
|
||||
void init_Map();
|
||||
using Base4D_FuncContainer::add_ankerpoint;
|
||||
using Base4D_FuncContainer::fillFromCSV;
|
||||
|
||||
|
||||
public:
|
||||
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz);
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
|
||||
protected:
|
||||
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords) {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
};
|
||||
*/
|
||||
|
||||
#endif /* density_container_hpp */
|
||||
@@ -1,216 +0,0 @@
|
||||
//
|
||||
// electron.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.01.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "electron.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int Electron::ionOn = getParameter("ionOn");
|
||||
const int Electron::elaOn = getParameter("elaOn");
|
||||
|
||||
double Electron::get_SigmaTotal_m2(vec3 speedT2_ms) {
|
||||
vector<double> Sigmas = get_SigmaVector_m2(speedT2_ms);
|
||||
double sigmaTot_m2 = 0;
|
||||
for (vector<double>::iterator SigmasIt = Sigmas.begin() ; SigmasIt != Sigmas.end(); SigmasIt++) {
|
||||
sigmaTot_m2 += *SigmasIt;
|
||||
}
|
||||
return(sigmaTot_m2);
|
||||
}
|
||||
|
||||
vector<double> Electron::get_SigmaVector_m2(vec3 speedT2_ms) {
|
||||
vector<double> Sigmas;
|
||||
if (elaOn == 1) {
|
||||
Sigmas.push_back(get_elaSigma_m2(speedT2_ms));
|
||||
} else {
|
||||
Sigmas.push_back(0.);
|
||||
}
|
||||
|
||||
if (ionOn == 1) {
|
||||
Sigmas.push_back(get_ionSigma_m2(speedT2_ms));
|
||||
} else {
|
||||
Sigmas.push_back(0.);
|
||||
}
|
||||
return(Sigmas);
|
||||
}
|
||||
|
||||
int Electron::roll_Interaction(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni) {
|
||||
vector<double> Sigmas = get_SigmaVector_m2(speedT2_ms);
|
||||
double RandPoint = rngUni->random() * get_SigmaTotal_m2(speedT2_ms);
|
||||
double Sum = 0;
|
||||
|
||||
for (int i=0; i<Sigmas.size();i++ ) {
|
||||
Sum += Sigmas[i];
|
||||
if (RandPoint<Sum) {
|
||||
return(i+1);
|
||||
}
|
||||
}
|
||||
throw MyException("Electron::roll_Interaction(): Error in finding Interaction.");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Elastic Scattering:
|
||||
Using Rutherford Model with screening parameter following
|
||||
Cross-sections for water vapour for the Monte Carlo electron track structure code from 10eV to the MeV region
|
||||
S Uehara et al 1993 Phys. Med. Biol. 38 1841
|
||||
*/
|
||||
|
||||
void Electron::do_elaScattering (vec3 speedT2_ms, ranlib::Uniform<double> *rngUni) {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
double thetaLab = roll_elaTheta(speedT2_ms, rngUni);
|
||||
double phiLab = rngUni->random() * 2 * pi;
|
||||
do_elaKinetics(speedT2_ms,thetaLab, phiLab);
|
||||
}
|
||||
|
||||
|
||||
double Electron::get_elaSigma_m2(vec3 speedT2_ms) {
|
||||
double SigmaEla_m2;
|
||||
vec3 speedLab_ms = v_ms - speedT2_ms;
|
||||
double betaLab = get_vecAbs(speedLab_ms)/c_ms;
|
||||
//double EkinLab_eV = get_Ekin_eV_from_speed(speedLab_ms, m_eV);
|
||||
double elaEta = get_elaEta(speedLab_ms);
|
||||
double numerator = pi*ZT2*(ZT2+1)*re_m*re_m * (1-pow(betaLab,2));
|
||||
double denominator = elaEta * (elaEta+1)*pow(betaLab,4);
|
||||
SigmaEla_m2 = numerator/denominator;
|
||||
return ( SigmaEla_m2 );
|
||||
}
|
||||
|
||||
|
||||
double Electron::get_elaEta(vec3 speedLab_ms) {
|
||||
double Ekin_eVLab_eV = get_Ekin_eV_from_speed(get_vecAbs(speedLab_ms), m_eV);
|
||||
double betaLab = get_vecAbs(speedLab_ms)/c_ms;
|
||||
double etac = (Ekin_eVLab_eV < 50e3)? 1.198 : 1.13+3.76*pow(ZT2/(137*betaLab),2);
|
||||
double elaTau = Ekin_eVLab_eV/m_eV;
|
||||
return (etac * 1.7e-5 * pow(ZT2,2./3.) /(elaTau*(elaTau+2) ));
|
||||
}
|
||||
|
||||
double Electron::roll_elaTheta(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni) {
|
||||
vec3 speedLab_ms = v_ms - speedT2_ms;
|
||||
double betaLab = get_vecAbs(speedLab_ms)/c_ms;
|
||||
double elaEta = get_elaEta(speedLab_ms);
|
||||
double const1 = 2*pi/get_elaSigma_m2(speedT2_ms)*ZT2*(ZT2+1)*re_m*re_m*(1- pow(betaLab,2) )* pow(betaLab,-4);
|
||||
double fac = pow( rngUni->random()/const1-pow(2*elaEta,-1) , -1 ) +1+2*elaEta;
|
||||
double theta = acos( fac);
|
||||
|
||||
return(theta);
|
||||
}
|
||||
|
||||
|
||||
void Electron::do_elaKinetics(vec3 speedT2_ms, double thetaLab, double phiLab) {
|
||||
// Following Landau Lifschitz I Chapter 4 Paragraph 17
|
||||
vec3 n0, speedLab_ms, v1New_ms, v2New_ms;
|
||||
speedLab_ms = v_ms - speedT2_ms;
|
||||
n0 = get_Newdirection(speedLab_ms, thetaLab, phiLab);
|
||||
v1New_ms = (mT2_eV*get_vecAbs(speedLab_ms)*n0 + m_eV*speedLab_ms)/(m_eV+mT2_eV) + speedT2_ms;
|
||||
//v2New_ms = (-1*mass_eV*get_vecAbs(speedLab_ms)*n0 + mass_eV*speedLab_ms)/(mass_eV+mT2_eV()) + speedT2_ms;
|
||||
v_ms = v1New_ms; // In "Real frame": both particles moving
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Ionization:
|
||||
Using BED-Model Kim and Rudd 1994
|
||||
*/
|
||||
|
||||
double Electron::get_ionSigma_m2(vec3 speedT2_ms) {
|
||||
vec3 speedLab_ms = v_ms - speedT2_ms;
|
||||
double T_eV = get_Ekin_eV_from_speed(get_vecAbs(speedLab_ms), m_eV);
|
||||
return (BED_Ionization::get_TCS(T_eV));
|
||||
}
|
||||
|
||||
Electron Electron::do_Ionization(vec3 speedT2_ms, int newId, ranlib::Uniform<double> *rngUni) {
|
||||
vec3 speedOffset_ms = speedT2_ms;
|
||||
vec3 speedLab_ms = v_ms - speedOffset_ms;
|
||||
double T_eV = get_Ekin_eV_from_speed(get_vecAbs(speedLab_ms), m_eV);
|
||||
|
||||
if (T_eV < EionT2_eV) { // Deviation, since Interaction-Process sample using v=0, but Interaction uses v!=0
|
||||
speedOffset_ms = 0;
|
||||
speedLab_ms = v_ms - speedOffset_ms;
|
||||
T_eV = get_Ekin_eV_from_speed(get_SpeedAbs_ms(), m_eV);
|
||||
}
|
||||
|
||||
if (T_eV < EionT2_eV) {
|
||||
throw MyException("Electron::do_Ionization: Ekin_eV < EIonT2_eV.");
|
||||
}
|
||||
|
||||
double W_eV = roll_ionW_eV(T_eV, rngUni);
|
||||
double E1_eV = T_eV-EionT2_eV - W_eV;
|
||||
|
||||
double phi1 = rngUni->random()*2*pi;
|
||||
double phi2 = phi1-pi;
|
||||
|
||||
double theta1 = roll_IonTheta1(T_eV, W_eV, rngUni);
|
||||
double theta2 = roll_IonTheta2(T_eV, W_eV, rngUni);
|
||||
|
||||
double v1Absnew_ms = get_Speed_from_Ekin_eV(E1_eV, m_eV);
|
||||
double v2Absnew_ms = get_Speed_from_Ekin_eV(W_eV, m_eV);
|
||||
|
||||
vec3 P1newDir, P2newDir, v1New_ms, v2New_ms ;
|
||||
P1newDir = get_Newdirection(v_ms, theta1, phi1);
|
||||
P2newDir = get_Newdirection(v_ms, theta2, phi2);
|
||||
|
||||
v1New_ms = v1Absnew_ms*P1newDir + speedOffset_ms;
|
||||
v2New_ms = v2Absnew_ms*P2newDir + speedOffset_ms;
|
||||
|
||||
set_Speed_ms(v1New_ms);
|
||||
Electron eNew = Electron(x_m, v2New_ms, newId, get_Id());
|
||||
|
||||
// Update Ion matrix here
|
||||
return(eNew);
|
||||
}
|
||||
|
||||
|
||||
double Electron::roll_ionW_eV(double T_eV, ranlib::Uniform<double> *rngUni) {
|
||||
double pmax, Wmin_eV, Wmax_eV, Wcan_eV,eta1,eta2;
|
||||
//pmax = get_ionSigma_m2(); //
|
||||
pmax = BED_Ionization::get_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_Ionization::get_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);
|
||||
}
|
||||
|
||||
double Electron::roll_IonTheta1(double T_eV, double W_eV, ranlib::Uniform<double> *rngUni) {
|
||||
double theta1;
|
||||
if (W_eV > 100) {
|
||||
double numerator = W_eV/T_eV;
|
||||
double denominator = (1-W_eV / T_eV)*(T_eV/(2*m_eV)) + 1;
|
||||
theta1 = asin(sqrt(numerator/denominator));
|
||||
} else {
|
||||
theta1 = rngUni->random()*pi/4;
|
||||
}
|
||||
return (theta1);
|
||||
}
|
||||
|
||||
double Electron::roll_IonTheta2(double T_eV, double W_eV, ranlib::Uniform<double> *rngUni) {
|
||||
double theta2;
|
||||
if (W_eV > 200) {
|
||||
double numerator = 1- W_eV/T_eV;
|
||||
double denominator = 1 + W_eV/(2*m_eV);
|
||||
theta2 = asin(sqrt(numerator/denominator));
|
||||
} else if (W_eV >= 50) {
|
||||
double decider = rngUni->random();
|
||||
if (decider < 0.9) {
|
||||
theta2 = 1 + rngUni->random() * pi/4 + pi/4;
|
||||
} else {
|
||||
theta2 = rngUni->random() * pi;
|
||||
}
|
||||
} else {
|
||||
theta2 = rngUni->random() * pi;
|
||||
}
|
||||
return(theta2);
|
||||
}
|
||||
|
||||
/*
|
||||
Func_Container Electron::elaTCS_container = Func_Container("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/yoon_TCS_elastic.dat");
|
||||
*/
|
||||
@@ -1,58 +0,0 @@
|
||||
//
|
||||
// electron.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.01.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_hpp
|
||||
#define electron_hpp
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "bedionization.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
|
||||
class Electron : public Particle, private BED_Ionization {
|
||||
public:
|
||||
virtual ~Electron() {}
|
||||
Electron(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) : Particle::Particle(me_eV, 1 , loc_m, speed_ms, idnum, parentIdnum, electron) {};
|
||||
|
||||
// Interactions
|
||||
public:
|
||||
double get_SigmaTotal_m2(vec3 speedT2_ms);
|
||||
std::vector<double> get_SigmaVector_m2(vec3 speedT2_ms);
|
||||
int roll_Interaction(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||
private:
|
||||
static const int ionOn;
|
||||
static const int elaOn;
|
||||
|
||||
// Elastic Scattering
|
||||
public:
|
||||
void do_elaScattering (vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||
double get_elaSigma_m2(vec3 speedT2_ms);
|
||||
protected:
|
||||
double get_elaEta(vec3 speedLab_ms);
|
||||
double roll_elaTheta(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||
void do_elaKinetics(vec3 speedT2_ms, double theta, double phi);
|
||||
|
||||
// Ionization
|
||||
public:
|
||||
double get_ionSigma_m2(vec3 speedT2_ms);
|
||||
Electron do_Ionization(vec3 speedT2_ms, int newId, ranlib::Uniform<double> *rngUni);
|
||||
protected:
|
||||
double roll_ionW_eV(double T_eV, ranlib::Uniform<double> *rngUni);
|
||||
|
||||
double roll_IonTheta1(double T_eV, double W_eV, ranlib::Uniform<double> *rngUni);
|
||||
double roll_IonTheta2(double T_eV, double W_eV, ranlib::Uniform<double> *rngUni);
|
||||
|
||||
|
||||
// Testing Container
|
||||
//static Func_Container elaTCS_container;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* electron_hpp */
|
||||
@@ -0,0 +1,159 @@
|
||||
//
|
||||
// electron_interactions.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "electron_interactions.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
|
||||
|
||||
double e_T2_elasticScattering::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double Ekin_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = Uehara_eT2_ElasticScattering::calc_TCS(Ekin_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Kat->getTritiumDensity_m3(loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
InteractionOut e_T2_elasticScattering::do_Interaction (Particle *interPart) const {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 vT2_ms = Kat->roll_totEqSpeed_ms(interPart->get_Location_m());
|
||||
vec3 vLab_ms = v_ms - vT2_ms;
|
||||
double T_eV = calc_Ekin_eV_from_speed(vLab_ms, me_eV);
|
||||
double thetaLab = Uehara_eT2_ElasticScattering::roll_theta(T_eV, rngUni);
|
||||
double phiLab = rngUni->random() * 2 * pi;
|
||||
interPart->set_Speed_ms( calc_vNew_ms(v_ms, vT2_ms, thetaLab, phiLab) );
|
||||
return (InteractionOut());
|
||||
}
|
||||
|
||||
|
||||
vec3 e_T2_elasticScattering::calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab) const {
|
||||
// Following Landau Lifschitz I Chapter 4 Paragraph 17
|
||||
vec3 speedLab_ms = vOld_ms - vT2_ms;
|
||||
vec3 n0 = calc_newDirection(speedLab_ms, thetaLab, phiLab);
|
||||
vec3 vNew_ms = (mT2_eV*vec3Abs(speedLab_ms)*n0 + me_eV*speedLab_ms)/(me_eV+mT2_eV) + vT2_ms;
|
||||
//vec3 v2New_ms = (-1*mass_eV*vec3Abs(speedLab_ms)*n0 + mass_eV*speedLab_ms)/(mass_eV+mT2_eV()) + speedT2_ms;
|
||||
return (vNew_ms);
|
||||
}
|
||||
|
||||
|
||||
Average1D_FuncContainer e_T2_ionization::BED_TCS_average_container=Average1D_FuncContainer( getDataPath() + "BED_average_TCS.dat");
|
||||
Stacked2D_FuncContainer e_T2_ionization::BED_SDCS_stacked_container=Stacked2D_FuncContainer( getDataPath() + "BED_stacked_SDCS.dat");
|
||||
|
||||
|
||||
double e_T2_ionization::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double T_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = BED_TCS_average_container.get_Value(T_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Kat->getTritiumDensity_m3(loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
InteractionOut e_T2_ionization::do_Interaction (Particle *interPart) const {
|
||||
vec3 vLab_ms = roll_vLab_ms(*interPart);
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
|
||||
double T_eV = calc_Ekin_eV_from_speed(v_ms, me_eV);
|
||||
if (T_eV < EionT2_eV) {
|
||||
throw MyException("Electron::do_Ionization: Ekin_eV < EIonT2_eV.");
|
||||
}
|
||||
double W_eV = roll_ionW_eV(T_eV);
|
||||
|
||||
double E1_eV = T_eV-EionT2_eV - W_eV;
|
||||
|
||||
double phi1 = rngUni->random()*2*pi;
|
||||
double phi2 = phi1-pi;
|
||||
|
||||
double theta1 = roll_IonTheta1(T_eV, W_eV);
|
||||
double theta2 = roll_IonTheta2(T_eV, W_eV);
|
||||
|
||||
double v1Absnew_ms = calc_Speed_from_Ekin_eV(E1_eV, me_eV);
|
||||
double v2Absnew_ms = calc_Speed_from_Ekin_eV(W_eV, me_eV);
|
||||
|
||||
vec3 P1newDir, P2newDir, v1New_ms, v2New_ms ;
|
||||
P1newDir = calc_newDirection(v_ms, theta1, phi1);
|
||||
P2newDir = calc_newDirection(v_ms, theta2, phi2);
|
||||
|
||||
vec3 vOff_ms = vLab_ms - v_ms;
|
||||
v1New_ms = v1Absnew_ms*P1newDir + vOff_ms;
|
||||
v2New_ms = v2Absnew_ms*P2newDir + vOff_ms;
|
||||
|
||||
interPart->set_Speed_ms(v1New_ms);
|
||||
Particle eNew = PartBuilder.createElectron(interPart->get_Location_m(), v2New_ms, -1, interPart->get_Id());
|
||||
InteractionOut InterOut;
|
||||
InterOut.add_newParticle(eNew);
|
||||
|
||||
return(InterOut);
|
||||
}
|
||||
|
||||
vec3 e_T2_ionization::roll_vLab_ms(const Particle &interPart) const {
|
||||
vec3 v_ms = interPart.get_Speed_ms();
|
||||
vec3 vT2_ms = Kat->roll_totEqSpeed_ms(interPart.get_Location_m());
|
||||
vec3 vOff_ms = vT2_ms;
|
||||
vec3 vLab_ms = v_ms - vOff_ms;
|
||||
double T_eV = calc_Ekin_eV_from_speed(vLab_ms, me_eV);
|
||||
if (T_eV < EionT2_eV) { // Set Tritium Speed to 0 if unlucky roll
|
||||
T_eV = calc_Ekin_eV_from_speed(v_ms, me_eV);
|
||||
}
|
||||
return (T_eV);
|
||||
}
|
||||
|
||||
double e_T2_ionization::roll_ionW_eV(double T_eV) const {
|
||||
return (BED_SDCS_stacked_container.sample_Value(T_eV, rngUni));
|
||||
/*
|
||||
double pmax, Wmin_eV, Wmax_eV, Wcan_eV,eta1,eta2;
|
||||
|
||||
//pmax = ionTCS_container.interpolate(T_eV);
|
||||
pmax = BED_eT2_Ionization::get_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::get_SDCS(T_eV, Wcan_eV));
|
||||
//} while(eta2*pmax > ionSDCS_container.interpolate(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);
|
||||
*/
|
||||
}
|
||||
|
||||
double e_T2_ionization::roll_IonTheta1(double T_eV, double W_eV) const {
|
||||
double theta1;
|
||||
if (W_eV > 100) {
|
||||
double numerator = W_eV/T_eV;
|
||||
double denominator = (1-W_eV / T_eV)*(T_eV/(2*me_eV)) + 1;
|
||||
theta1 = asin(sqrt(numerator/denominator));
|
||||
} else {
|
||||
theta1 = rngUni->random()*pi/4;
|
||||
}
|
||||
return (theta1);
|
||||
}
|
||||
|
||||
double e_T2_ionization::roll_IonTheta2(double T_eV, double W_eV) const {
|
||||
double theta2;
|
||||
if (W_eV > 200) {
|
||||
double numerator = 1- W_eV/T_eV;
|
||||
double denominator = 1 + W_eV/(2*me_eV);
|
||||
theta2 = asin(sqrt(numerator/denominator));
|
||||
} else if (W_eV >= 50) {
|
||||
double decider = rngUni->random();
|
||||
if (decider < 0.9) {
|
||||
theta2 = 1 + rngUni->random() * pi/4 + pi/4;
|
||||
} else {
|
||||
theta2 = rngUni->random() * pi;
|
||||
}
|
||||
} else {
|
||||
theta2 = rngUni->random() * pi;
|
||||
}
|
||||
return(theta2);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// electron_interactions.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_interactions_hpp
|
||||
#define electron_interactions_hpp
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
/*
|
||||
Elastic Scattering:
|
||||
Using Rutherford Model with screening parameter following
|
||||
Cross-sections for water vapour for the Monte Carlo electron track structure code from 10eV to the MeV region
|
||||
S Uehara et al 1993 Phys. Med. Biol. 38 1841
|
||||
*/
|
||||
class e_T2_elasticScattering : public Interaction {
|
||||
public:
|
||||
e_T2_elasticScattering(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(Kat, rngUni, rngNormal) {};
|
||||
|
||||
species get_Species() const {return(electron);}
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
InteractionOut do_Interaction (Particle *interPart) const;
|
||||
|
||||
private:
|
||||
vec3 calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab) const;
|
||||
};
|
||||
|
||||
/*
|
||||
Ionization:
|
||||
Using BED-Model Kim and Rudd 1994
|
||||
*/
|
||||
class e_T2_ionization : public Interaction {
|
||||
static Average1D_FuncContainer BED_TCS_average_container;
|
||||
static Stacked2D_FuncContainer BED_SDCS_stacked_container;
|
||||
|
||||
ParticleBuilder PartBuilder;
|
||||
|
||||
public:
|
||||
e_T2_ionization(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(Kat, rngUni, rngNormal) {};
|
||||
|
||||
species get_Species() const {return(electron);}
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
InteractionOut do_Interaction (Particle *interPart) const;
|
||||
private:
|
||||
vec3 roll_vLab_ms(const Particle &interPart) const;
|
||||
double roll_ionW_eV(double T_eV) const;
|
||||
double roll_IonTheta1(double T_eV, double W_eV) const;
|
||||
double roll_IonTheta2(double T_eV, double W_eV) const;
|
||||
};
|
||||
|
||||
|
||||
#endif /* electron_interactions_hpp */
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// error_types.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef error_types_h
|
||||
#define error_types_h
|
||||
|
||||
/*
|
||||
#include "constants.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
#include <blitz/array.h>
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
*/
|
||||
#include <iostream>
|
||||
|
||||
struct MyException : public std::exception
|
||||
{
|
||||
std::string s;
|
||||
MyException(std::string errorMessage) : s(errorMessage) {}
|
||||
~MyException() throw () {}
|
||||
const char* what() const throw() { return s.c_str(); }
|
||||
};
|
||||
#endif /* error_types_h */
|
||||
@@ -8,176 +8,182 @@
|
||||
|
||||
#include "function_container.hpp"
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Func_Container::Func_Container(std::string loadFilePath) {
|
||||
readFromCSV(loadFilePath);
|
||||
inline void Base_FuncContainer::averageMap_from_edgeMap (dim1Map *averageMap, dim1Map &edgeMap) {
|
||||
averageMap->clear();
|
||||
dim1Map::iterator curItr, afterItr;
|
||||
afterItr = edgeMap.begin();
|
||||
curItr = edgeMap.begin();
|
||||
afterItr++;
|
||||
while (afterItr!=edgeMap.end()) {
|
||||
averageMap->insert(dim1Pair( curItr->first + (afterItr->first-curItr->first)/2, curItr->second ));
|
||||
curItr++;
|
||||
afterItr++;
|
||||
}
|
||||
averageMap->insert(dim1Pair( curItr->first , curItr->second ));
|
||||
}
|
||||
|
||||
double Func_Container::interpolate(double x) {
|
||||
if (Map.empty()) {
|
||||
throw MyException("Func_Container: Container is empty.");
|
||||
inline void Base_FuncContainer::stackedMap_from_averageMap (dim1Map *stackedMap, dim1Map &averageMap, double lowerEdge) {
|
||||
double tot = 0;
|
||||
dim1Map::iterator prevItr, currItr;
|
||||
prevItr = averageMap.begin();
|
||||
currItr = averageMap.begin();
|
||||
tot += (currItr->first - lowerEdge) * currItr->second;
|
||||
currItr ++;
|
||||
while (currItr!=averageMap.end()) {
|
||||
tot += (currItr->first - prevItr->first) * currItr->second;
|
||||
currItr++;
|
||||
prevItr++;
|
||||
}
|
||||
//tot = tot/(averageMap.rbegin()->first - lowerEdge);
|
||||
|
||||
if (Map.begin() == Map.lower_bound(x) ) {
|
||||
return (Map.begin()->second);
|
||||
} else if (Map.end() == Map.lower_bound(x)){
|
||||
return ( (--Map.end())->second );
|
||||
stackedMap->clear();
|
||||
prevItr = averageMap.begin();
|
||||
currItr = averageMap.begin();
|
||||
double curVal = (currItr->first - lowerEdge)* currItr->second/tot;
|
||||
container_base::add_To_Map(stackedMap, deque<double> {curVal,currItr->first});
|
||||
currItr ++;
|
||||
while (currItr!=averageMap.end()) {
|
||||
curVal += (currItr->first - prevItr->first)*currItr->second/tot;
|
||||
container_base::add_To_Map(stackedMap, deque<double> {curVal,currItr->first});
|
||||
currItr++;
|
||||
prevItr++;
|
||||
}
|
||||
|
||||
dim1Map::iterator lowAnker_Itr = --Map.lower_bound(x);
|
||||
dim1Map::iterator upAnker_Itr = Map.lower_bound(x);
|
||||
double lowAnker_x = lowAnker_Itr->first;
|
||||
double lowAnker_fx = lowAnker_Itr->second;
|
||||
double upAnker_x = upAnker_Itr->first;
|
||||
double upAnker_fx = upAnker_Itr->second;
|
||||
|
||||
double res = lowAnker_fx + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fx-lowAnker_fx);
|
||||
return (res);
|
||||
}
|
||||
|
||||
inline double Base_FuncContainer::sampleValue_from_stackedMap (const dim1Map &stackedMap, ranlib::Uniform<double> *rngUni) const {
|
||||
return (stackedMap.lower_bound(rngUni->random())->second);
|
||||
}
|
||||
|
||||
// Base1D_Container
|
||||
// AddData
|
||||
void Base1D_FuncContainer::fillFromFunction(double (*f)(const double &), double minKey, double maxKey, int numpointsPerOrder) {
|
||||
int interval = numpointsPerOrder -1;
|
||||
int minI = floor(log10(minKey)*interval);
|
||||
int maxI = ceil(log10(maxKey)*interval);
|
||||
double x, fx;
|
||||
try {
|
||||
x = pow(10,double (minI)/double(interval));
|
||||
fx = f(x);
|
||||
} catch (...) {
|
||||
fx = f(x);
|
||||
}
|
||||
add_ankerpoint(x, fx);
|
||||
try {
|
||||
x = pow(10,double (maxI)/double(interval));
|
||||
fx = f(x);
|
||||
} catch (...) {
|
||||
fx = f(x);
|
||||
}
|
||||
add_ankerpoint(x, fx);
|
||||
for (int i = minI + 1;i<maxI;i++) {
|
||||
x = pow(10,double (i)/double(interval));
|
||||
fx = f(x);
|
||||
add_ankerpoint(x, fx);
|
||||
}
|
||||
}
|
||||
|
||||
// average1D_Container
|
||||
void Average1D_FuncContainer::set_Map(dim1Map &edgeMap) {
|
||||
averageMap_from_edgeMap (&Map, edgeMap);
|
||||
}
|
||||
|
||||
void Average1D_FuncContainer::set_Map(Edge1D_FuncContainer &edgeContainer) {
|
||||
dim1Map edgeMap = edgeContainer.get_Map();
|
||||
set_Map(edgeMap);
|
||||
}
|
||||
|
||||
|
||||
void Func_Container::add_ankerpoint(double x, double fx) {
|
||||
if ( Map.find(x)!=Map.end() ) {
|
||||
stringstream ss;
|
||||
ss<<"Func_Container::add_ankerpoint: Key x="<<x<<" already exists.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
Map.insert(dim1Pair(x, fx));
|
||||
return;
|
||||
}
|
||||
|
||||
void Func_Container::readFromCSV(std::string loadFilePath) {
|
||||
ifstream fileStream(loadFilePath);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func_Container::readFromCSV: Could not open file: "<<loadFilePath<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
// edge2D_Container
|
||||
|
||||
string lineFromFile;
|
||||
stringstream ss;
|
||||
double xTemp, fxTemp;
|
||||
bool lineReadError = false;
|
||||
void Edge2D_FuncContainer::get_Ionization_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numYpoints) {
|
||||
int Xinterval = numpointsPerXOrder -1;
|
||||
int minXI = floor(log10(minX)*Xinterval);
|
||||
int maxXI = ceil(log10(maxX)*Xinterval);
|
||||
|
||||
while (getline(fileStream, lineFromFile)) {
|
||||
removeLeadingWhites(lineFromFile);
|
||||
replaceDelimiter(lineFromFile);
|
||||
if ( checkIgnoreLine(lineFromFile) ) {
|
||||
int Yinterval = numYpoints-1;
|
||||
double minY, maxY;
|
||||
int minYI, maxYI;
|
||||
double x, y, fxy;
|
||||
|
||||
for (int XI = minXI; XI<=maxXI; XI++) {
|
||||
x = pow(10,double (XI)/double(Xinterval));
|
||||
minY = 1e-5;
|
||||
maxY = (x-EionT2_eV)/2;
|
||||
if (maxY<0) {
|
||||
add_ankerpoint(x,0,0);
|
||||
continue;
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
ss.str(lineFromFile);
|
||||
|
||||
if (ss>>xTemp && ss>>fxTemp) {
|
||||
add_ankerpoint(xTemp, fxTemp);
|
||||
} else {
|
||||
if (!lineReadError) {
|
||||
cout<<"Func_Container::readFromCSV: Warning could not read line in inputFile. \nloadFilePath = "<<loadFilePath<<endl;
|
||||
lineReadError = true;
|
||||
}
|
||||
minYI = floor(log10(minY)*Yinterval);
|
||||
maxYI = ceil(log10(maxY)*Yinterval);
|
||||
for (int YI = minYI; YI<maxYI; YI++) {
|
||||
y = pow(10,double (YI)/double(Yinterval));
|
||||
fxy = f(x,y);
|
||||
add_ankerpoint(x, y,fxy);
|
||||
}
|
||||
add_ankerpoint(x,maxY,f(x,maxY));
|
||||
}
|
||||
}
|
||||
|
||||
void Edge2D_FuncContainer::get_Elastic_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numpointsOverY) {
|
||||
int Xinterval = numpointsPerXOrder -1;
|
||||
int minXI = floor(log10(minX)*Xinterval);
|
||||
int maxXI = ceil(log10(maxX)*Xinterval);
|
||||
double x, y, fxy;
|
||||
|
||||
for (int XI = minXI; XI<=maxXI; XI++) {
|
||||
x = pow(10,double (XI)/double(Xinterval));
|
||||
for (int YI = 0; YI<numpointsOverY; YI++) {
|
||||
y = YI/(numpointsOverY-1)*pi;
|
||||
fxy = f(x,y);
|
||||
add_ankerpoint(x, y,fxy);
|
||||
}
|
||||
}
|
||||
fileStream.close();
|
||||
|
||||
}
|
||||
|
||||
void Func_Container::printAnkerpoints() {
|
||||
dim1Map::iterator AnkerItr;
|
||||
for (AnkerItr = Map.begin();AnkerItr!=Map.end();AnkerItr++) {
|
||||
cout<<AnkerItr->first<<"\t"<<AnkerItr->second<<"\n";
|
||||
// Average2D_Container
|
||||
void Average2D_FuncContainer::set_Map(dim2Map &edgeMap) {
|
||||
// should template averageMap_from_edgeMap function and reuse it for first iteration...
|
||||
Map.clear();
|
||||
dim2Map::iterator curItr, afterItr;
|
||||
afterItr = edgeMap.begin();
|
||||
curItr = edgeMap.begin();
|
||||
afterItr++;
|
||||
dim1Map tempMap;
|
||||
while (afterItr!=edgeMap.end()) {
|
||||
averageMap_from_edgeMap (&tempMap, curItr->second);
|
||||
Map.insert(dim2Pair( curItr->first + (afterItr->first-curItr->first)/2, tempMap ));
|
||||
curItr++;
|
||||
afterItr++;
|
||||
}
|
||||
averageMap_from_edgeMap (&tempMap, curItr->second);
|
||||
Map.insert(dim2Pair( curItr->first , tempMap ));
|
||||
}
|
||||
|
||||
void Average2D_FuncContainer::set_Map(Edge2D_FuncContainer &edgeContainer) {
|
||||
dim2Map edgeMap = edgeContainer.get_Map();
|
||||
set_Map(edgeMap);
|
||||
}
|
||||
|
||||
// Stacked2D_Container:
|
||||
void Stacked2D_FuncContainer::set_Map(dim2Map &averageMap) {
|
||||
Map.clear();
|
||||
dim1Map tempMap;
|
||||
for (dim2Map::iterator Itr=averageMap.begin(); Itr!=averageMap.end() ; Itr++) {
|
||||
stackedMap_from_averageMap (&tempMap, Itr->second, 0);
|
||||
Map.insert(dim2Pair( Itr->first , tempMap ));
|
||||
}
|
||||
}
|
||||
|
||||
// Func2D_Container
|
||||
Func2D_Container::Func2D_Container(std::string loadFilePath) {
|
||||
readFromCSV(loadFilePath);
|
||||
void Stacked2D_FuncContainer::set_Map(Average2D_FuncContainer &averageContainer) {
|
||||
dim2Map averageMap = averageContainer.get_Map();
|
||||
set_Map(averageMap);
|
||||
}
|
||||
|
||||
double Func2D_Container::interpolate(double x, double y) {
|
||||
// Method might be improved, since first check for x bins, and afterwards check for y bins, so theoretically not choosing closest neighbour in terms of y but giving priority to x-closeness.
|
||||
// Avoid Mistakes by having complete set of y-data and uniform grid or improve code later.
|
||||
|
||||
|
||||
if (Map.empty()) {
|
||||
throw MyException("Func2D_Container: Container is empty.");
|
||||
}
|
||||
|
||||
if (Map.begin() == Map.lower_bound(x) ) {
|
||||
return (Map.begin()->second.interpolate(y));
|
||||
} else if (Map.end() == Map.lower_bound(x)){
|
||||
return ( (--Map.end())->second.interpolate(y) );
|
||||
}
|
||||
|
||||
dim2Map::iterator lowAnker_Itr = --Map.lower_bound(x);
|
||||
dim2Map::iterator upAnker_Itr = Map.lower_bound(x);
|
||||
double lowAnker_x = lowAnker_Itr->first;
|
||||
double lowAnker_fxy = lowAnker_Itr->second.interpolate(y);
|
||||
double upAnker_x = upAnker_Itr->first;
|
||||
double upAnker_fxy = upAnker_Itr->second.interpolate(y);
|
||||
|
||||
double res = lowAnker_fxy + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fxy-lowAnker_fxy);
|
||||
return (res);
|
||||
|
||||
}
|
||||
|
||||
void Func2D_Container::add_ankerpoint(double x, double y, double fxy) {
|
||||
if ( Map.find(x)==Map.end() ) {
|
||||
Func_Container Temp_Container;
|
||||
Temp_Container.add_ankerpoint(y, fxy);
|
||||
Map.insert(dim2Pair (x, Temp_Container));
|
||||
double Stacked2D_FuncContainer::sample_Value(double x, ranlib::Uniform<double> *rngUni) const {
|
||||
if (Map.rbegin()->first < x) {
|
||||
return (sampleValue_from_stackedMap (Map.rbegin()->second, rngUni));
|
||||
} else {
|
||||
try {
|
||||
Map.find(x)->second.add_ankerpoint(y,fxy);
|
||||
} catch (MyException& caught) {
|
||||
stringstream ss;
|
||||
ss<<"Func2D_Container::add_ankerpoint: Error from "<<caught.what();
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (sampleValue_from_stackedMap (Map.lower_bound(x)->second, rngUni));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Func2D_Container::readFromCSV(std::string loadFilePath) {
|
||||
ifstream fileStream(loadFilePath);
|
||||
if (!fileStream.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func_Container::readFromCSV: Could not open file.\nloadFilePath= "<<loadFilePath<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
string lineFromFile;
|
||||
stringstream ss;
|
||||
double xTemp,yTemp,fxyTemp;
|
||||
bool lineReadError = false;
|
||||
|
||||
while (getline(fileStream, lineFromFile)) {
|
||||
removeLeadingWhites(lineFromFile);
|
||||
replaceDelimiter(lineFromFile);
|
||||
if ( checkIgnoreLine(lineFromFile) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
ss.str(lineFromFile);
|
||||
|
||||
if (ss>>xTemp && ss>>yTemp&& ss>>fxyTemp) {
|
||||
add_ankerpoint(xTemp, yTemp, fxyTemp);
|
||||
} else {
|
||||
if (!lineReadError) {
|
||||
cout<<"Func_Container::readFromCSV: Warning could not read line in inputFile. \nloadFilePath = "<<loadFilePath<<endl;
|
||||
lineReadError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,41 +9,130 @@
|
||||
#ifndef function_container_hpp
|
||||
#define function_container_hpp
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "container_base_functions.h"
|
||||
|
||||
#include <random/uniform.h>
|
||||
|
||||
|
||||
typedef std::map<double,double> dim1Map;
|
||||
typedef std::pair<double,double> dim1Pair;
|
||||
|
||||
class Func_Container {
|
||||
// Base_FuncContainer: Provide Operation on dim1Maps.
|
||||
class Base_FuncContainer {
|
||||
protected:
|
||||
double interpolateFrom_Map (dim1Map &Map, double x) const;
|
||||
void averageMap_from_edgeMap (dim1Map *averageMap, dim1Map &edgeMap);
|
||||
void stackedMap_from_averageMap (dim1Map *stackedMap, dim1Map &averageMap, double lowerEdge = 0);
|
||||
double sampleValue_from_stackedMap (const dim1Map &stackedMap, ranlib::Uniform<double> *rngUni) const;
|
||||
};
|
||||
|
||||
// Base1D_Container: Provide Map and input output methods of the map.
|
||||
class Base1D_FuncContainer : protected Base_FuncContainer {
|
||||
public:
|
||||
Func_Container() {};
|
||||
Func_Container(std::string loadFilePath);
|
||||
void add_ankerpoint(double x, double fx);
|
||||
double interpolate(double x);
|
||||
private:
|
||||
Base1D_FuncContainer() {};
|
||||
Base1D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromFunction(double (*f)(const double &), double minX, double maxX, int numpointsPerOrder);
|
||||
void fillFromCSV(std::string loadFilePath) {container_base::add_From_Csv (&Map, 1, loadFilePath);};
|
||||
void add_ankerpoint(double x, double fx) {container_base::add_To_Map(&Map, deque<double> {x,fx});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) const {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim1Map get_Map() const {return (Map);}
|
||||
protected:
|
||||
dim1Map Map;
|
||||
void readFromCSV(std::string loadFilePath);
|
||||
public:
|
||||
void printAnkerpoints();
|
||||
} ;
|
||||
|
||||
|
||||
typedef std::map<double,Func_Container> dim2Map;
|
||||
typedef std::pair<double,Func_Container> dim2Pair;
|
||||
|
||||
class Func2D_Container {
|
||||
// Edge1D_Container: To store values calculated values at given points.
|
||||
class Edge1D_FuncContainer : public Base1D_FuncContainer {
|
||||
public:
|
||||
Func2D_Container() {};
|
||||
Func2D_Container(std::string loadFilePath);
|
||||
double interpolate(double x, double y);
|
||||
Edge1D_FuncContainer() : Base1D_FuncContainer() {};
|
||||
Edge1D_FuncContainer(std::string loadFilePath) : Base1D_FuncContainer(loadFilePath){};
|
||||
|
||||
double interpolate(double x) const {return (container_base::interpolate_Value(Map,deque<double>{x}));};
|
||||
};
|
||||
|
||||
// Average1D_Container: Calculates new edges, so values from edge bin correspond to mean value.
|
||||
// From old edge bins let f(x_i,old)=f_i,old, for i=1,...,m
|
||||
// Calculate new edges for average bins: x_i,new = |x_i,old + x_i+1,old|/2 for i=1,...,m-1
|
||||
// x_m,new = x_m,old
|
||||
// for x_i,new < x <= x_(i+1) -> f(x) = f_(i+1),old for i=1,...,m-1
|
||||
// for x < x_1 -> f(x) = f_1,old and fox x > x_m -> f(x) = f_m,old
|
||||
class Average1D_FuncContainer : public Base1D_FuncContainer {
|
||||
public:
|
||||
Average1D_FuncContainer() : Base1D_FuncContainer() {};
|
||||
Average1D_FuncContainer(std::string loadFilePath) : Base1D_FuncContainer(loadFilePath){};
|
||||
Average1D_FuncContainer (dim1Map &edgeMap) {set_Map(edgeMap);};
|
||||
Average1D_FuncContainer (Edge1D_FuncContainer &edgeContainer) {set_Map(edgeContainer);};
|
||||
|
||||
void add_ankerpoint(double x, double y, double fxy);
|
||||
private:
|
||||
void set_Map(dim1Map &edgeMap);
|
||||
void set_Map(Edge1D_FuncContainer &edgeContainer);
|
||||
|
||||
double get_Value(double x) const {return ( container_base::get_Value(Map, deque<double> {x}) );};
|
||||
};
|
||||
|
||||
|
||||
typedef std::map<double,dim1Map> dim2Map;
|
||||
typedef std::pair<double,dim1Map> dim2Pair;
|
||||
|
||||
// Base2D_Container: Analog to Base1D_Container but in 2 dimensions. Map stores a Map.
|
||||
class Base2D_FuncContainer : protected Base_FuncContainer {
|
||||
public:
|
||||
Base2D_FuncContainer() {};
|
||||
Base2D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv (&Map, 2, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double fxy) {container_base::add_To_Map(&Map, deque<double> {x,y,fxy});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim2Map get_Map() const {return (Map);}
|
||||
protected:
|
||||
dim2Map Map;
|
||||
void readFromCSV(std::string loadFilePath);
|
||||
|
||||
} ;
|
||||
|
||||
// Edge2D_Container: Analog to Edge1D_Container
|
||||
class Edge2D_FuncContainer : public Base2D_FuncContainer {
|
||||
public:
|
||||
Edge2D_FuncContainer() : Base2D_FuncContainer() {};
|
||||
Edge2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath) {};
|
||||
|
||||
double interpolate(double x, double y) const {return (container_base::interpolate_Value(Map,deque<double>{x,y}));};
|
||||
|
||||
void get_Ionization_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numpointsPerYOrder);
|
||||
void get_Elastic_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numpointsOverY);
|
||||
};
|
||||
|
||||
// Average2D_Container:
|
||||
// Analog to Average1D_Container. First calculate new x bins.
|
||||
// Then within each new x bin calculate new y bins
|
||||
class Average2D_FuncContainer : public Base2D_FuncContainer {
|
||||
public:
|
||||
Average2D_FuncContainer() : Base2D_FuncContainer() {};
|
||||
Average2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath){};
|
||||
Average2D_FuncContainer (dim2Map &edgeMap) {set_Map(edgeMap);};
|
||||
Average2D_FuncContainer (Edge2D_FuncContainer &edgeContainer) {set_Map(edgeContainer);};
|
||||
|
||||
void set_Map(dim2Map &edgeMap);
|
||||
void set_Map(Edge2D_FuncContainer &edgeContainer);
|
||||
double get_Value(double x, double y) const {return ( container_base::get_Value(Map, deque<double> {x,y}) );};
|
||||
};
|
||||
|
||||
// Stacked2D_Container:
|
||||
// first key corresponds to x, second key to stacked up values f(x,y) from average Map normed and value to y
|
||||
class Stacked2D_FuncContainer : public Base2D_FuncContainer {
|
||||
public:
|
||||
Stacked2D_FuncContainer() : Base2D_FuncContainer() {};
|
||||
Stacked2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath){};
|
||||
Stacked2D_FuncContainer (Average2D_FuncContainer &averageContainer) {set_Map(averageContainer);};
|
||||
Stacked2D_FuncContainer (dim2Map &averageMap) {set_Map(averageMap);};
|
||||
|
||||
void set_Map(dim2Map &averageMap);
|
||||
void set_Map(Average2D_FuncContainer &averageContainer);
|
||||
|
||||
double sample_Value(double x, ranlib::Uniform<double> *rngUni) const;
|
||||
};
|
||||
|
||||
|
||||
#endif /* function_container_hpp */
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
//
|
||||
// functions.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.02.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
#include "constants.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Read Parameters from file
|
||||
double getParameter(string parName) {
|
||||
string parpath = getEnv("parpath");
|
||||
string parfile = getEnv("parfile");
|
||||
if (parpath == "") {
|
||||
throw MyException("Parameter::getParameter: Environment variable parpath not defined.");
|
||||
}
|
||||
if (parfile == "") {
|
||||
throw MyException("Parameter::getParameter: Environment variable parfile not defined.");
|
||||
}
|
||||
makePath(parpath);
|
||||
string loadFilePath = parpath + parfile;
|
||||
ifstream fileStream(loadFilePath);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Parameter::getParameter: Could not open file.\n loadFilePath =\t"<<loadFilePath<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
string lineFromFile;
|
||||
stringstream ss;
|
||||
string parNameTemp;
|
||||
double parTemp;
|
||||
bool lineReadError = false;
|
||||
|
||||
while (getline(fileStream, lineFromFile)) {
|
||||
removeLeadingWhites(lineFromFile);
|
||||
replaceDelimiter(lineFromFile);
|
||||
if ( checkIgnoreLine(lineFromFile) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
ss.str(lineFromFile);
|
||||
|
||||
if (ss>>parNameTemp && ss>>parTemp) {
|
||||
if (parNameTemp == parName) {
|
||||
fileStream.close();
|
||||
return (parTemp);
|
||||
}
|
||||
} else {
|
||||
if (!lineReadError) {
|
||||
cout<<"Parameter::getParameter: Line in parameter file faulty. \n path =\t"<<loadFilePath<<endl;
|
||||
lineReadError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ss.clear();
|
||||
ss<<"Parameter::getParameter: Parameter not found in file.\n parName =\t"<<parName<<"\n loadFilePath = \t"<<loadFilePath;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
|
||||
//String Manipulations for Read in from files
|
||||
std::string getEnv (std::string envName) {
|
||||
char * val = getenv( envName.c_str() );
|
||||
return val == NULL ? std::string("") : std::string(val);
|
||||
}
|
||||
|
||||
void makePath (std::string &path) {
|
||||
if (path.back() != '/') {
|
||||
path = path + '/';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool checkIgnoreLine(std::string lineFromFile) {
|
||||
if (lineFromFile[0] =='#') {
|
||||
return true;
|
||||
} else if ( lineFromFile.empty() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
void removeLeadingWhites(std::string &lineFromFile) {
|
||||
static const std::string WHITESPACE = " \n\r\t\f\v";
|
||||
size_t start = lineFromFile.find_first_not_of(WHITESPACE);
|
||||
lineFromFile = (start == std::string::npos) ? "" : lineFromFile.substr(start);
|
||||
return;
|
||||
}
|
||||
|
||||
void replaceDelimiter(std::string &lineFromFile) {
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), ';', ' ');
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), ',', ' ');
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), '=', ' ');
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate Kinematic Relations
|
||||
double get_Ekin_eV_from_speed(double Speed_ms, double mass_eV) {
|
||||
double beta = Speed_ms/c_ms;
|
||||
if (beta>=1) {
|
||||
stringstream ss;
|
||||
ss<<"get_Ekin_eV_from_speed(): Input speed v="<<Speed_ms<<" m/s equal or exeeds speed of light.";
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
stringstream ss;
|
||||
ss<<"get_Ekin_eV_from_speed(): Input speed v="<<Speed_ms<<" m/s is expected to be absolute value therfore >0.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double gamma = get_gamma_from_beta(beta);
|
||||
return ( (gamma-1) * mass_eV );
|
||||
}
|
||||
|
||||
double get_gamma_from_beta(double beta) {
|
||||
if (beta>=1) {
|
||||
stringstream ss;
|
||||
ss<<"get_gamma_from_beta(): Input beta ="<<beta<<" equal or exeeds 1.";
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
stringstream ss;
|
||||
ss<<"get_gamma_from_beta(): Input beta ="<<beta<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
return( pow(1 - pow(beta,2),-0.5) ) ;
|
||||
}
|
||||
|
||||
double get_Speed_from_Ekin_eV(double Ekin_eV, double mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
stringstream ss;
|
||||
ss<<"get_Speed_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
double gamma = get_gamma_from_Ekin_eV(Ekin_eV, mass_eV);
|
||||
double beta = get_beta_from_gamma(gamma);
|
||||
return(beta * c_ms);
|
||||
}
|
||||
|
||||
double get_gamma_from_Ekin_eV(double Ekin_eV, double mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
stringstream ss;
|
||||
ss<<"get_gamma_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (1. + Ekin_eV/mass_eV);
|
||||
}
|
||||
|
||||
double get_beta_from_gamma(double gamma) {
|
||||
if (gamma<1) {
|
||||
stringstream ss;
|
||||
ss<<"get_beta_from_gamma(): Input gamma ="<<gamma<<" smaller 1.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return( sqrt(1 - pow(gamma,-2)) );
|
||||
}
|
||||
|
||||
|
||||
// Operations on 3 dimensional Vectors
|
||||
double get_vecAbs(vec3 vec) {
|
||||
return( sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2)) );
|
||||
}
|
||||
|
||||
vec3 get_Newdirection(vec3 direction_old, double theta_change,double phi_change) {
|
||||
// Transformation of direction following Plante and Cucinotta
|
||||
double theta_old = acos(direction_old[2]/get_vecAbs(direction_old));
|
||||
double phi_old = atan2(direction_old[1],direction_old[0]);
|
||||
|
||||
double A3 = sin(theta_change)*cos(phi_change);
|
||||
double A4 = A3*cos(theta_old) + cos(theta_change)*sin(theta_old);
|
||||
double A5 = sin(theta_change)*sin(phi_change);
|
||||
double A11 = A4*cos(phi_old) - A5*sin(phi_old);
|
||||
double A21 = A4*sin(phi_old) + A5*cos(phi_old);
|
||||
double theta_new = acos( cos(theta_old)*cos(theta_change)-A3*sin(theta_old) );
|
||||
|
||||
// Get right phi1, maybe more elegant way later. Problem comes from reverse functions only being on range of pi. So combine both statements to get proper phi over 2pi.
|
||||
int digits = 6;
|
||||
double fac = pow(10,digits);
|
||||
double phi_new = -1;
|
||||
double phi_new_candidates [4];
|
||||
phi_new_candidates[0] = acos( roundf ( A11/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[1] = 2*pi - phi_new_candidates[0];
|
||||
phi_new_candidates[2] = asin ( roundf ( A21/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[3] = pi - phi_new_candidates[2];
|
||||
phi_new_candidates[2] = (phi_new_candidates[2] > 0) ? phi_new_candidates[2] : 2*pi + phi_new_candidates[2];
|
||||
for (int i=0;i<3;i++) {
|
||||
for (int j=i+1;j<4;j++) {
|
||||
if (phi_new_candidates[i]-phi_new_candidates[j] < 0.0001) {
|
||||
phi_new = phi_new_candidates[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (phi_new == -1) {
|
||||
throw MyException("Interaction::getElaNewDir: phi1 not found.");
|
||||
}
|
||||
return(vec3(sin(theta_new)*cos(phi_new) , sin(theta_new)*sin(phi_new) , cos(theta_new)));
|
||||
}
|
||||
|
||||
|
||||
// Functions for Random Sampling
|
||||
vec3 roll_uniform_direction(ranlib::Uniform<double> *rngUni) {
|
||||
vec3 dir;
|
||||
double phi = 2*pi*rngUni->random();
|
||||
double theta = pi*rngUni->random();
|
||||
dir = sin(theta)*cos(phi) , sin(theta)*sin(phi) , cos(theta);
|
||||
return(dir);
|
||||
}
|
||||
|
||||
double roll_MBEnergy(double Temp_K,double mass_eV,ranlib::NormalUnit<double> *rngNormal) {
|
||||
|
||||
double C = kb_eVK*Temp_K/mass_eV;
|
||||
double beta = 0;
|
||||
double sum = 0;
|
||||
for (int i=0;i<3;i++) {
|
||||
sum += pow(rngNormal->random(),2);
|
||||
}
|
||||
beta = sqrt(C*(sum));
|
||||
|
||||
return((get_gamma_from_beta(beta)-1)*mass_eV);
|
||||
}
|
||||
|
||||
double roll_Rejectionmethod(double (*pdf)(double), double xmin, double xmax, double pmax, ranlib::Uniform<double> *rngUni) {
|
||||
// get Energy distribution using Rejection Method
|
||||
double xcan,eta1,eta2;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
xcan = xmin + eta1*(xmax - xmin);
|
||||
} while( eta2*pmax > pdf(xcan) );
|
||||
return(xcan);
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
//
|
||||
// functions.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.02.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef functions_hpp
|
||||
#define functions_hpp
|
||||
|
||||
|
||||
#include <iostream>
|
||||
// #include <string>
|
||||
|
||||
#include <blitz/array.h>
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
|
||||
|
||||
// Custom Error Type
|
||||
struct MyException : public std::exception
|
||||
{
|
||||
std::string s;
|
||||
MyException(std::string errorMessage) : s(errorMessage) {}
|
||||
~MyException() throw () {}
|
||||
const char* what() const throw() { return s.c_str(); }
|
||||
};
|
||||
|
||||
// Read Parameters from file
|
||||
double getParameter(std::string parName);
|
||||
|
||||
//String Manipulations for Read in from files
|
||||
std::string getEnv (std::string envName); // string version of C function getenv.
|
||||
void makePath (std::string &path); // append '/' if necessary to path.
|
||||
bool checkIgnoreLine(std::string lineFromFile); // true if line is empty or starts with #
|
||||
void removeLeadingWhites(std::string &lineFromFile);
|
||||
void replaceDelimiter(std::string &lineFromFile); // replaces delimiter (';'',''=') with whitespace
|
||||
|
||||
// Calculate Kinematic Relations
|
||||
double get_Speed_from_Ekin_eV(double Ekin_eV, double mass_eV);
|
||||
double get_gamma_from_Ekin_eV(double Ekin_eV, double mass_eV);
|
||||
double get_beta_from_gamma(double gamma);
|
||||
double get_Ekin_eV_from_speed(double Speed, double mass_eV);
|
||||
double get_gamma_from_beta(double beta);
|
||||
|
||||
// Operations on 3 dimensional Vectors
|
||||
double get_vecAbs(vec3 vec);
|
||||
vec3 get_Newdirection(vec3 oldDir, double theta,double phi); // Calculates new Direction after Interaction with (theta, phi)
|
||||
|
||||
// Functions for Random Sampling
|
||||
vec3 roll_uniform_direction(ranlib::Uniform<double> *rngUni);
|
||||
double roll_MBEnergy(double Temp_K,double mass_eV,ranlib::NormalUnit<double> *rngNormal);
|
||||
double doRejectionMethod(double pdf(double), double xmin, double xmax, double pmax, ranlib::Uniform<double> *rngUni);
|
||||
|
||||
|
||||
#endif /* functions_hpp */
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// injector.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "injector.hpp"
|
||||
|
||||
const int Injector::injectionMethod = getParameter("injectionMethod");
|
||||
const double Injector::injectionEnergy_eV = getParameter("injectionEnergy_eV");
|
||||
|
||||
Particle Injector::injectElectron (const int &newId) {
|
||||
double r_m = Kat->get_radius_m()*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double z_WGTSstart_m = Kat->get_z_WGTSstart_m();
|
||||
double z_WGTSend_m = Kat->get_z_WGTSend_m();
|
||||
double wgtsLength_m = z_WGTSend_m - z_WGTSstart_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 Ekin_eV;
|
||||
switch(injectionMethod) {
|
||||
case 0: // Fermi
|
||||
Ekin_eV = roll_FermiEnergy_eV();
|
||||
break;
|
||||
case 1: //Delta
|
||||
Ekin_eV = injectionEnergy_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
Ekin_eV = roll_MBEnergy(injectionEnergy_eV/kb_eVK,me_eV, rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
vec3 speed_ms = roll_uniform_direction(rngUni) * calc_Speed_from_Ekin_eV(Ekin_eV,me_eV);
|
||||
return ( PartFac.createElectron(loc_m, speed_ms,newId,newId) );
|
||||
}
|
||||
|
||||
double Injector::roll_FermiEnergy_eV() {
|
||||
// get Energy distribution using Rejection Method
|
||||
double pmax,Emin_eV, Emax_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
Emin_eV = 1e-15;
|
||||
Emax_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = Emin_eV + eta1*(Emax_eV - Emin_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return(Ecan_eV);
|
||||
}
|
||||
|
||||
double Injector::get_FermiDecaySpectrumDensity(const double &Ekin_eV) {
|
||||
if (Ekin_eV>TritiumDecayEndpoint_eV) {
|
||||
return (0.);
|
||||
} else{
|
||||
double p_eV = sqrt(Ekin_eV*Ekin_eV + 2 * Ekin_eV * me_eV);
|
||||
return( BetaDecayConst * get_FermiFunction(2, Ekin_eV) * p_eV*(Ekin_eV+me_eV)*pow(TritiumDecayEndpoint_eV-Ekin_eV,2) );
|
||||
}
|
||||
}
|
||||
|
||||
double Injector::get_FermiFunction(const double &Z, const double &Ekin_eV) {
|
||||
double gamma = 1+ Ekin_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,36 @@
|
||||
//
|
||||
// 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 "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
class Injector : RNG_Base {
|
||||
public:
|
||||
Injector(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){
|
||||
this->Kat = Kat;
|
||||
};
|
||||
|
||||
Particle injectElectron (const int &newId);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &Ekin_eV);
|
||||
double get_FermiFunction(const double &Z, const double &Ekin_eV);
|
||||
|
||||
Katrin *Kat;
|
||||
ParticleBuilder PartFac;
|
||||
|
||||
static const int injectionMethod;
|
||||
static const double injectionEnergy_eV;
|
||||
};
|
||||
#endif /* injector_hpp */
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// interaction_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef interaction_base_hpp
|
||||
#define interaction_base_hpp
|
||||
|
||||
#include "error_types.h"
|
||||
#include "particle.hpp"
|
||||
#include "katrin.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
class InteractionOut {
|
||||
bool deleteCur;
|
||||
deque <Particle> newParticles;
|
||||
|
||||
public:
|
||||
InteractionOut() {reset();};
|
||||
|
||||
void reset() {
|
||||
deleteCur = false;
|
||||
newParticles.empty();
|
||||
}
|
||||
|
||||
void set_deleteCur(const bool &deleteCur) {this->deleteCur = deleteCur;}
|
||||
void set_newParticles(const deque<Particle> &newParticles) {this->newParticles = newParticles;}
|
||||
void add_newParticle(const Particle &newParticle) {newParticles.push_back(newParticle);}
|
||||
|
||||
bool get_deleteCur() const {return(deleteCur);};
|
||||
deque<Particle> get_newParticles() const {return(newParticles);};
|
||||
};
|
||||
|
||||
|
||||
class Interaction : public RNG_Base {
|
||||
protected:
|
||||
Katrin *Kat;
|
||||
|
||||
public:
|
||||
Interaction(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
};
|
||||
|
||||
virtual species get_Species() const = 0;
|
||||
|
||||
virtual double get_macroSigma_m2(const Particle &interPart) const = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* interaction_base_h */
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// interaction_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "interaction_builder.hpp"
|
||||
|
||||
|
||||
const int InteractionBuilder::eT2elastic = getParameter("eT2elastic");
|
||||
const int InteractionBuilder::eT2ionization = getParameter("eT2ionization");
|
||||
|
||||
InteractionProcessor InteractionBuilder::build_InteractionProcessor() {
|
||||
InteractionProcessor InterProcessor(Kat,rngUni,rngNormal);
|
||||
InterProcessor.add_ParticleInteraction(build_eInteractions());
|
||||
return(InterProcessor);
|
||||
}
|
||||
|
||||
ParticleInteractions* InteractionBuilder::build_eInteractions() {
|
||||
ParticleInteractions* eInteractions = new ParticleInteractions(Kat, rngUni, rngNormal, electron);
|
||||
if (eT2elastic == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_elasticScattering(Kat, rngUni, rngNormal));
|
||||
}
|
||||
if (eT2ionization == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_ionization(Kat, rngUni, rngNormal));
|
||||
}
|
||||
return(eInteractions);
|
||||
}
|
||||
|
||||
/*
|
||||
ParticleInteractions InteractionBuilder::build_T2Interactions() {
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// interaction_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef interaction_builder_hpp
|
||||
#define interaction_builder_hpp
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
|
||||
|
||||
#include "interaction_processor.hpp"
|
||||
#include "interaction_species.hpp"
|
||||
#include "electron_interactions.hpp"
|
||||
|
||||
class InteractionBuilder : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
|
||||
static const int eT2ionization;
|
||||
static const int eT2elastic;
|
||||
|
||||
public:
|
||||
InteractionBuilder(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
}
|
||||
InteractionProcessor build_InteractionProcessor();
|
||||
|
||||
|
||||
private:
|
||||
ParticleInteractions* build_eInteractions();
|
||||
//ParticleInteractions* build_T2Interactions();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* interaction_builder_hpp */
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// interaction_processor.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "interaction_processor.hpp"
|
||||
|
||||
|
||||
InteractionOut InteractionProcessor::do_Interaction(Particle *interPart) const {
|
||||
species Species = interPart->get_Species();
|
||||
ParticleInteractionsVec::const_iterator Itr = find_ParticleInteraction(Species);
|
||||
if (Itr == ParticleInteractions.end()) {
|
||||
stringstream ss;
|
||||
ss<<"InteractionProcessor::do_Interaction: No Interaction declare for Particles of Species:\n"<<Species<<"\n";
|
||||
throw MyException (ss.str());
|
||||
|
||||
}
|
||||
return ( (*Itr)->do_Interaction(interPart) );
|
||||
}
|
||||
|
||||
double InteractionProcessor::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double macroSigma_m2 = 0;
|
||||
species Species = interPart.get_Species();
|
||||
ParticleInteractionsVec::const_iterator Itr = find_ParticleInteraction(Species);
|
||||
if (Itr != ParticleInteractions.end()) {
|
||||
macroSigma_m2 = (*Itr)->get_macroSigma_m2(interPart);
|
||||
} else {
|
||||
cout<<"Warning: No Interaction for Particle of Species"<<Species<<"\n";
|
||||
}
|
||||
macroSigma_m2 = macroSigma_m2==0 ? 1e-15 : macroSigma_m2; // Small Value will lead to huge mfp and particle will get out of WGTS
|
||||
return (macroSigma_m2);
|
||||
}
|
||||
|
||||
|
||||
void InteractionProcessor::add_ParticleInteraction(class ParticleInteractions* particleInteraction) {
|
||||
if (empty()) {
|
||||
} else if (find_ParticleInteraction(particleInteraction->get_Species()) != ParticleInteractions.end()) {
|
||||
stringstream ss;
|
||||
ss<<"InteractionProcessor::add_ParticleInteraction: Species already exists.\nSpecies:\t"<<particleInteraction->get_Species()<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
ParticleInteractions.push_back(particleInteraction);
|
||||
}
|
||||
|
||||
ParticleInteractionsVec::const_iterator InteractionProcessor::find_ParticleInteraction (species findSpec) const {
|
||||
ParticleInteractionsVec::const_iterator Itr;
|
||||
if (empty()) {
|
||||
Itr = ParticleInteractions.cend();
|
||||
} else {
|
||||
Itr = ParticleInteractions.cbegin();
|
||||
while (Itr != ParticleInteractions.end()) {
|
||||
if ((*Itr)->get_Species() == findSpec) {
|
||||
break;
|
||||
}
|
||||
Itr++;
|
||||
}
|
||||
}
|
||||
return (Itr);
|
||||
}
|
||||
|
||||
ParticleInteractionsVec::iterator InteractionProcessor::find_ParticleInteraction (species findSpec) {
|
||||
ParticleInteractionsVec::iterator Itr;
|
||||
if (empty()) {
|
||||
Itr = ParticleInteractions.end();
|
||||
} else {
|
||||
Itr = ParticleInteractions.begin();
|
||||
while (Itr != ParticleInteractions.end() || (*Itr)->get_Species() == findSpec) {
|
||||
Itr++;
|
||||
}
|
||||
}
|
||||
return (Itr);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// interaction_processor.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef interaction_processor_hpp
|
||||
#define interaction_processor_hpp
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
|
||||
|
||||
|
||||
typedef std::vector <ParticleInteractions*> ParticleInteractionsVec;
|
||||
|
||||
class InteractionProcessor : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
ParticleInteractionsVec ParticleInteractions;
|
||||
|
||||
public:
|
||||
InteractionProcessor(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){
|
||||
this->Kat = Kat;
|
||||
};
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart) const;
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
|
||||
public:
|
||||
void add_ParticleInteraction(class ParticleInteractions* particleInteraction);
|
||||
|
||||
bool empty() const {return (ParticleInteractions.size()==0 ? true : false);}
|
||||
private:
|
||||
ParticleInteractionsVec::const_iterator find_ParticleInteraction (species findSpec) const;
|
||||
ParticleInteractionsVec::iterator find_ParticleInteraction (species findSpec);
|
||||
};
|
||||
|
||||
#endif /* interaction_processor_hpp */
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// interaction_species.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 27.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
InteractionOut ParticleInteractions::do_Interaction(Particle *interPart) const {
|
||||
double macroSigma_m2 = get_macroSigma_m2(*interPart);
|
||||
if (macroSigma_m2 == 0) {
|
||||
stringstream ss;
|
||||
ss<<"ParticleInteractions::do_Interaction: Interaction Cross Section = 0 for particle of Species "<<get_Species()<<".\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macroSigma_m2;
|
||||
InteractionsVec::const_iterator Itr = Interactions.cbegin();
|
||||
do {
|
||||
currentStackedSigma += (*Itr)->get_macroSigma_m2(*interPart);
|
||||
Itr++;
|
||||
} while(currentStackedSigma < targetStackedSigma);
|
||||
Itr--;
|
||||
return ((*Itr)->do_Interaction(interPart));
|
||||
}
|
||||
|
||||
double ParticleInteractions::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double macroSigma_m2 = 0;
|
||||
if (empty()) {
|
||||
cout<<"Warning: No Interaction for Particle of Type "<<get_Species()<<"\n";
|
||||
} else {
|
||||
for (InteractionsVec::const_iterator Itr = Interactions.begin();Itr!=Interactions.end();Itr++) {
|
||||
macroSigma_m2 += (*Itr)->get_macroSigma_m2(interPart);
|
||||
}
|
||||
}
|
||||
return(macroSigma_m2);
|
||||
}
|
||||
|
||||
void ParticleInteractions::add_Interaction(Interaction* addInteraction) {
|
||||
if (Interactions.size()>0) {
|
||||
for (InteractionsVec::iterator Itr = Interactions.begin();Itr!=Interactions.end();Itr++) {
|
||||
if ( typeid(addInteraction) == typeid(Itr)) {
|
||||
stringstream ss;
|
||||
ss<<"ParticleInteractions::add_Interaction: Interactions already exists.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addInteraction->get_Species() != get_Species()) {
|
||||
stringstream ss;
|
||||
ss<<"ParticleInteractions::add_Interaction: Species of adding Interaction missmatches this ParticleInteractions species: \nThis Species:\t"<<get_Species()<<"\nadding Species:\t"<<addInteraction->get_Species()<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
Interactions.push_back(addInteraction);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// interaction_species.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 27.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef interaction_species_hpp
|
||||
#define interaction_species_hpp
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
typedef std::vector<Interaction*> InteractionsVec;
|
||||
|
||||
class ParticleInteractions : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
species Species;
|
||||
InteractionsVec Interactions;
|
||||
|
||||
public:
|
||||
ParticleInteractions(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal, species Species) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
this->Species = Species;
|
||||
};
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart) const;
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
|
||||
void add_Interaction(Interaction* addInteraction);
|
||||
|
||||
species get_Species() const {return (Species);};
|
||||
bool empty() const {return (Interactions.size()==0 ? true : false);}
|
||||
};
|
||||
|
||||
#endif /* interaction_species_hpp */
|
||||
+29
-239
@@ -9,270 +9,60 @@
|
||||
|
||||
#include "katrin.hpp"
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
|
||||
#include "sstream"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const double Katrin::wgtsMagField_T = getParameter("wgtsMagField_T");
|
||||
const double Katrin::wgtsLength_m = getParameter("wgtsLength_m");
|
||||
const double Katrin::rearwallZ_m = getParameter("rearwallZ_m");
|
||||
const double Katrin::wgtsStartZ_m = getParameter("wgtsStartZ_m");
|
||||
const double Katrin::wgtsEndZ_m = getParameter("wgtsEndZ_m");
|
||||
const double Katrin::wgtsRadius_m = getParameter("wgtsRadius_m");
|
||||
|
||||
const double Katrin::wgtsMagField_T = getParameter("wgtsMagField_T");
|
||||
|
||||
const double Katrin::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
const double Katrin::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double Katrin::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
const int Katrin::injectionMethod = getParameter("injectionMethod");
|
||||
const double Katrin::injectionEnergy_eV = getParameter("injectionEnergy_eV");
|
||||
|
||||
const double Katrin::dt_s = getParameter("dt_s");
|
||||
|
||||
const double Katrin::cutoffEnergy_eV = getParameter("cutoffEnergy_eV");
|
||||
|
||||
vec3 Katrin::getMagField_T(vec3 loc_m) {
|
||||
vec3 MagField_T;
|
||||
MagField_T = 0,0,wgtsMagField_T;
|
||||
return(MagField_T);
|
||||
}
|
||||
|
||||
vec3 Katrin::getElField_Vm(vec3 loc_m) {
|
||||
return (vec3(0,0,0));
|
||||
void Katrin::check_Properties() {
|
||||
// Geometrics
|
||||
stringstream ss;
|
||||
ss<<"Katrin::check_Properties: ";
|
||||
if (rearwallZ_m>wgtsStartZ_m) {
|
||||
ss<<"rearwallZ_m>wgtsStartZ_m"<<endl;
|
||||
MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
double Katrin::getTritiumDensity_m3(vec3 loc_m) {
|
||||
double mid_m = wgtsLength_m/2;
|
||||
double zProjection_m = (loc_m[2] < mid_m) ? loc_m[2] : wgtsLength_m - loc_m[2] ;
|
||||
double reductget_ionFactor = zProjection_m/mid_m;
|
||||
double z_wgtsCords_m = loc_m[2] - wgtsStartZ_m; // New Cords, where wgtsStart equals z=0
|
||||
double reductget_ionFactor;
|
||||
if (z_wgtsCords_m<0) { //outside of tank
|
||||
reductget_ionFactor = 1e-9;
|
||||
} else {
|
||||
double zProjection_m = (z_wgtsCords_m < wgtsLength_m()/2) ? z_wgtsCords_m : wgtsLength_m() - z_wgtsCords_m;
|
||||
reductget_ionFactor = zProjection_m/wgtsLength_m()*2; //Correction since reflection
|
||||
}
|
||||
return(reductget_ionFactor * wgtsT2MaxDensity_m3);
|
||||
}
|
||||
|
||||
vec3 Katrin::getTotSpeedT2_ms(vec3 loc_m, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal) {
|
||||
return ( getFlowSpeedT2_ms(loc_m) + getTempSpeedT2_ms(loc_m, rngUni, rngNormal) );
|
||||
vec3 Katrin::roll_totEqSpeed_ms(vec3 loc_m) {
|
||||
return ( get_flowEqSpeed_ms(loc_m) + roll_thermEqSpeed_ms(loc_m) );
|
||||
}
|
||||
|
||||
vec3 Katrin::getFlowSpeedT2_ms(vec3 loc_m) {
|
||||
vec3 Katrin::get_flowEqSpeed_ms(vec3 loc_m) {
|
||||
vec3 speed_ms;
|
||||
double sign = (loc_m[2] < wgtsLength_m/2.) ? -1 : 1;
|
||||
double sign = (loc_m[2] < wgtsStartZ_m + wgtsLength_m()/2.) ? -1 : 1;
|
||||
double flow_ms = sign*wgtsT2FlowSpeed_ms;
|
||||
speed_ms = 0,0,flow_ms;
|
||||
return (speed_ms);
|
||||
}
|
||||
|
||||
vec3 Katrin::getTempSpeedT2_ms(vec3 loc_m, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal) {
|
||||
double tempOffsetABS_ms = get_Speed_from_Ekin_eV(roll_MBEnergy(wgtsTemp_K,mT2_eV,rngNormal), mT2_eV);
|
||||
vec3 Katrin::roll_thermEqSpeed_ms(vec3 loc_m) {
|
||||
double tempOffsetABS_ms = calc_Speed_from_Ekin_eV(roll_MBEnergy(wgtsTemp_K,mT2_eV,rngNormal), mT2_eV);
|
||||
vec3 speed_ms = roll_uniform_direction(rngUni)*tempOffsetABS_ms;
|
||||
return(speed_ms);
|
||||
}
|
||||
|
||||
Electron Katrin::injectElectron(int newId, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal) {
|
||||
double r_m = wgtsRadius_m*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double z_0tohalf_m = sqrt(rngUni->random())*wgtsLength_m/2;
|
||||
double z_m = (rngUni->random()<0.5)? z_0tohalf_m : wgtsLength_m - z_0tohalf_m;
|
||||
|
||||
vec3 loc_m = vec3 (r_m*cos(phi),r_m*sin(phi),z_m);
|
||||
double Ekin_eV;
|
||||
switch(injectionMethod) {
|
||||
case 0: // Fermi
|
||||
Ekin_eV = roll_FermiEnergy_eV(rngUni);
|
||||
break;
|
||||
case 1: //Delta
|
||||
Ekin_eV = injectionEnergy_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
Ekin_eV = roll_MBEnergy(injectionEnergy_eV/kb_eVK,me_eV, rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
vec3 speed_ms = roll_uniform_direction(rngUni) * get_Speed_from_Ekin_eV(Ekin_eV,me_eV);
|
||||
return (Electron(loc_m, speed_ms,newId,newId));
|
||||
}
|
||||
|
||||
double Katrin::roll_FermiEnergy_eV(ranlib::Uniform<double> *rngUni) {
|
||||
// get Energy distribution using Rejection Method
|
||||
double pmax,Emin_eV, Emax_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
Emin_eV = 1e-15;
|
||||
Emax_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = Emin_eV + eta1*(Emax_eV - Emin_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return(Ecan_eV);
|
||||
}
|
||||
|
||||
double Katrin::get_FermiDecaySpectrumDensity(double Ekin_eV) {
|
||||
if (Ekin_eV>TritiumDecayEndpoint_eV) {
|
||||
return (0.);
|
||||
} else{
|
||||
double p_eV = sqrt(Ekin_eV*Ekin_eV + 2 * Ekin_eV * me_eV);
|
||||
return( BetaDecayConst * get_FermiFunction(2, Ekin_eV) * p_eV*(Ekin_eV+me_eV)*pow(TritiumDecayEndpoint_eV-Ekin_eV,2) );
|
||||
}
|
||||
}
|
||||
|
||||
double Katrin::get_FermiFunction(double Z, double Ekin_eV) {
|
||||
double gamma = 1+ Ekin_eV/me_eV;
|
||||
double beta = sqrt(1 - pow(gamma,-2));
|
||||
double eta =Z/beta/137.;
|
||||
return( 2*pi*eta/(1-exp(-2*pi*eta)) );
|
||||
}
|
||||
|
||||
// Move Electrons and Log
|
||||
void Katrin::do_BorisPushMovement(Electron *moveElectron, double distance_m, H5_Logger *Log) {
|
||||
// Rework, with Logging and Reflection at wall
|
||||
vec3 loc_m;
|
||||
|
||||
double oldzDir = moveElectron->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = moveElectron->get_Location_m();
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = moveElectron->get_Location_m();
|
||||
|
||||
traveledDistance_m += moveElectron->do_BorisStep_m(getElField_Vm(loc_m) , getMagField_T(loc_m) , dt_s);
|
||||
|
||||
doBoris_WallInteraction(moveElectron);
|
||||
|
||||
if (check_WallTermination(*moveElectron) == 0) {
|
||||
Log->log_Electron(moveElectron, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(moveElectron, &oldzDir, &oldLoc_m, Log);
|
||||
|
||||
}
|
||||
Log->log_Electron(moveElectron, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
void Katrin::doBoris_WallInteraction(Electron *moveElectron) {
|
||||
vec3 loc_m = moveElectron->get_Location_m();
|
||||
double r_m = moveElectron->get_Radius_m();
|
||||
if (loc_m[2]<=0) { // Rear Wall Termination
|
||||
vec3 newLoc_m = moveElectron->get_Location_m();
|
||||
newLoc_m[2] = 0;
|
||||
moveElectron->set_Location_m(newLoc_m);
|
||||
} else if (r_m>=wgtsRadius_m) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = moveElectron->get_Location_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (wgtsRadius_m * 1.01)/get_vecAbs(newLoc_m) * newLoc_m; //1.01 to move Electron slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
} else if (loc_m[2]>=wgtsLength_m) { // Spectrometer Reflection
|
||||
moveElectron->set_Speed_ms( -1*(moveElectron->get_Speed_ms()) );
|
||||
}
|
||||
}
|
||||
|
||||
void Katrin::doBoris_LogzDirChange(Electron *moveElectron, double *oldzDir, vec3 *oldLoc_m, H5_Logger *Log) {
|
||||
double zDir = moveElectron->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Log->log_Electron(moveElectron, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = moveElectron->get_Location_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Katrin::do_DriftApproximationMovement(Electron *moveElectron, double distance_m, H5_Logger *Log) {
|
||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||
vec3 oldLoc_m = moveElectron->get_Location_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
double znew_m = getDrift_znew_m(distance_m, moveElectron);
|
||||
doDrift_WallInteraction(&oldLoc_m, &znew_m, moveElectron, Log);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
moveElectron->set_Location_m(newLoc_m);
|
||||
Log->log_Electron(moveElectron, oldLoc_m);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
double Katrin::getDrift_znew_m(double distance_m, Electron *moveElectron) {
|
||||
double zold_m = moveElectron->get_Location_m()[2];
|
||||
|
||||
vec3 v_ms = moveElectron->get_Speed_ms();
|
||||
double vTotAbs_ms = get_vecAbs(v_ms);
|
||||
double vForwardAbs_ms = get_vecAbs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] < 0 ? -1 : 1;
|
||||
|
||||
double znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
return (znew_m);
|
||||
}
|
||||
|
||||
void Katrin::doDrift_WallInteraction(vec3 *oldLoc_m, double *znew_m, Electron *moveElectron, H5_Logger *Log) {
|
||||
if (*znew_m >= wgtsLength_m) { // Moveing into Spectrometer and reversing Speed.
|
||||
vec3 reverseLoc_m = *oldLoc_m;
|
||||
reverseLoc_m[2] = wgtsLength_m;
|
||||
moveElectron->set_Location_m(reverseLoc_m);
|
||||
|
||||
Log->log_Electron(moveElectron, *oldLoc_m);
|
||||
|
||||
*oldLoc_m = reverseLoc_m;
|
||||
*znew_m = 2*wgtsLength_m - *znew_m;
|
||||
|
||||
moveElectron->set_Speed_ms( -1*(moveElectron->get_Speed_ms()) );
|
||||
}
|
||||
if (*znew_m <= 0) {
|
||||
*znew_m = 0;
|
||||
}
|
||||
}
|
||||
|
||||
double Katrin::get_MFP_m(Electron *moveElectron) {
|
||||
//Rework for inserting vector of Interactions
|
||||
vec3 loc_m, speedT2_ms;
|
||||
double sigmaTot_m2, density_m3, MFP_m;
|
||||
loc_m = moveElectron->get_Location_m();
|
||||
speedT2_ms = getFlowSpeedT2_ms(loc_m);
|
||||
|
||||
sigmaTot_m2 = moveElectron->get_SigmaTotal_m2(speedT2_ms);
|
||||
density_m3 = getTritiumDensity_m3(loc_m);
|
||||
MFP_m = 1/(density_m3 * sigmaTot_m2);
|
||||
return(MFP_m);
|
||||
}
|
||||
|
||||
// Terminate Electrons
|
||||
bool Katrin::check_Termination(Electron checkElectron) {
|
||||
return ( check_EnergyTermination(checkElectron) || check_WallTermination(checkElectron) );
|
||||
}
|
||||
|
||||
bool Katrin::check_EnergyTermination(double Ekin_eV) {
|
||||
double ETemp_eV = kb_eVK*wgtsTemp_K;
|
||||
if (ETemp_eV<0) {
|
||||
throw MyException("Katrin::checkTermination: ETemp_eV < 0.");
|
||||
}
|
||||
|
||||
if (Ekin_eV<=cutoffEnergy_eV) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
bool Katrin::check_EnergyTermination(Electron checkElectron) {
|
||||
double Ekin_eV = checkElectron.get_EKin_eV();
|
||||
return (check_EnergyTermination(Ekin_eV));
|
||||
}
|
||||
|
||||
bool Katrin::check_WallTermination(vec3 loc_m) {
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <=0) {
|
||||
return (true);
|
||||
} else if (r_m >= wgtsRadius_m) {
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
bool Katrin::check_WallTermination(Electron checkElectron) {
|
||||
vec3 loc_m = checkElectron.get_Location_m();
|
||||
return (check_WallTermination(loc_m));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+46
-50
@@ -9,72 +9,68 @@
|
||||
#ifndef katrin_hpp
|
||||
#define katrin_hpp
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "electron.hpp"
|
||||
#include "constants.h"
|
||||
#include "random_operations.h"
|
||||
|
||||
#include "density_container.hpp"
|
||||
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include "blitz/array.h"
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
|
||||
|
||||
class Katrin {
|
||||
|
||||
class Katrin : public RNG_Base{
|
||||
public:
|
||||
Katrin() {};
|
||||
Katrin(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
check_Properties ();
|
||||
};
|
||||
|
||||
// Katrin Properties
|
||||
private:
|
||||
void check_Properties();
|
||||
// Geometrics
|
||||
public:
|
||||
vec3 getMagField_T(vec3 loc_m);
|
||||
vec3 getElField_Vm(vec3 loc_m);
|
||||
double getTritiumDensity_m3(vec3 loc_m);
|
||||
double get_z_RW_m() const {return(rearwallZ_m);};
|
||||
double get_z_WGTSstart_m() const {return(wgtsStartZ_m);};
|
||||
double get_z_WGTSend_m() const {return(wgtsEndZ_m);};
|
||||
double get_radius_m() const {return(wgtsRadius_m);};
|
||||
|
||||
vec3 getTotSpeedT2_ms(vec3 loc_m, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal);
|
||||
vec3 getFlowSpeedT2_ms(vec3 loc_m);
|
||||
vec3 getTempSpeedT2_ms(vec3 loc_m, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal);
|
||||
bool outside(vec3 loc_m) const;
|
||||
private:
|
||||
double wgtsLength_m() const {return (get_z_WGTSend_m() - get_z_WGTSstart_m());};
|
||||
|
||||
static const double rearwallZ_m;
|
||||
static const double wgtsStartZ_m;
|
||||
static const double wgtsEndZ_m;
|
||||
static const double wgtsRadius_m;
|
||||
|
||||
|
||||
// EM-Fields
|
||||
public:
|
||||
vec3 getMagField_T(vec3 loc_m) const { return (vec3(0,0,wgtsMagField_T)); };
|
||||
vec3 getElField_Vm(vec3 loc_m) const {return (vec3(0,0,0));};
|
||||
private:
|
||||
static const double wgtsMagField_T;
|
||||
static const double wgtsLength_m;
|
||||
static const double wgtsRadius_m;
|
||||
|
||||
|
||||
//Particle Densities
|
||||
public:
|
||||
double getTritiumDensity_m3(vec3 loc_m);
|
||||
|
||||
// Maxwell Boltzmann Part
|
||||
public:
|
||||
vec3 roll_totEqSpeed_ms(vec3 loc_m);
|
||||
vec3 get_flowEqSpeed_ms(vec3 loc_m);
|
||||
vec3 roll_thermEqSpeed_ms(vec3 loc_m);
|
||||
private:
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
static const double wgtsTemp_K;
|
||||
static const double wgtsT2FlowSpeed_ms;
|
||||
|
||||
// Electron Injection
|
||||
public:
|
||||
Electron injectElectron(int newId, ranlib::Uniform<double> *rngUni, ranlib::NormalUnit<double> *rngNormal);
|
||||
private:
|
||||
double roll_FermiEnergy_eV(ranlib::Uniform<double> *rngUni);
|
||||
double get_FermiDecaySpectrumDensity(double Ekin_eV);
|
||||
double get_FermiFunction(double Z, double Ekin_eV);
|
||||
|
||||
static const int injectionMethod;
|
||||
static const double injectionEnergy_eV;
|
||||
|
||||
// Move Electrons
|
||||
public:
|
||||
double get_MFP_m(Electron *moveElectron);
|
||||
void do_BorisPushMovement(Electron *moveElectron, double distance_m, H5_Logger *Log);
|
||||
void do_DriftApproximationMovement(Electron *moveElectron, double distance_m, H5_Logger *Log);
|
||||
private:
|
||||
double getDrift_znew_m(double MFP_m, Electron *moveElectron);
|
||||
void doDrift_WallInteraction(vec3 *oldLoc_m, double *znew_m, Electron *moveElectron, H5_Logger *Log);
|
||||
void doBoris_WallInteraction(Electron *moveElectron);
|
||||
void doBoris_LogzDirChange(Electron *moveElectron, double *oldzDir, vec3 *oldLoc_m, H5_Logger *Log);
|
||||
|
||||
static const double dt_s;
|
||||
|
||||
|
||||
// Terminate Electrons
|
||||
public:
|
||||
bool check_Termination(Electron checkElectron);
|
||||
private:
|
||||
bool check_EnergyTermination(double Ekin_eV);
|
||||
bool check_EnergyTermination(Electron checkElectron);
|
||||
bool check_WallTermination(vec3 loc_m);
|
||||
bool check_WallTermination(Electron checkElectron);
|
||||
|
||||
static const double cutoffEnergy_eV;
|
||||
//Skalar_WGTS_Container Ion_Container = Skalar_WGTS_Container(0, wgtsLength_m, wgtsRadius_m, vec3(10,10,12));
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* katrin_hpp */
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// kinematics.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef kinematics_h
|
||||
#define kinematics_h
|
||||
|
||||
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
|
||||
inline double vec3Abs(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_Ekin_eV_from_speed(const double &speed_ms, const double &mass_eV) {
|
||||
double beta = speed_ms/c_ms;
|
||||
if (beta>=1) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_Ekin_eV_from_speed(): Input speed v="<<speed_ms<<" m/s equal or exeeds speed of light.";
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_Ekin_eV_from_speed(): Input speed v="<<speed_ms<<" m/s is expected to be absolute value therfore >0.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double gamma = calc_gamma_from_beta(beta);
|
||||
return ( (gamma-1) * mass_eV );
|
||||
}
|
||||
|
||||
inline double calc_Ekin_eV_from_speed(const vec3 &speed_ms, const double &mass_eV) {
|
||||
return (calc_Ekin_eV_from_speed(vec3Abs(speed_ms), mass_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_Ekin_eV(const double &Ekin_eV, const double &mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_gamma_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (1. + Ekin_eV/mass_eV);
|
||||
}
|
||||
|
||||
inline double calc_beta_from_Ekin_eV(const double &Ekin_eV, const double &mass_eV) {
|
||||
return ( calc_beta_from_gamma(calc_gamma_from_Ekin_eV(Ekin_eV, mass_eV)) );
|
||||
}
|
||||
|
||||
inline double calc_Speed_from_Ekin_eV(const double &Ekin_eV, const double &mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
std::stringstream ss;
|
||||
ss<<"calc_Speed_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
double gamma = calc_gamma_from_Ekin_eV(Ekin_eV, mass_eV);
|
||||
double beta = calc_beta_from_gamma(gamma);
|
||||
return(beta * c_ms);
|
||||
}
|
||||
|
||||
inline vec3 calc_newDirection(const vec3 &direction_old, const double &theta_change, const double &phi_change) {
|
||||
// Transformation of direction following Plante and Cucinotta
|
||||
double theta_old = acos(direction_old[2]/vec3Abs(direction_old));
|
||||
double phi_old = atan2(direction_old[1],direction_old[0]);
|
||||
|
||||
double A3 = sin(theta_change)*cos(phi_change);
|
||||
double A4 = A3*cos(theta_old) + cos(theta_change)*sin(theta_old);
|
||||
double A5 = sin(theta_change)*sin(phi_change);
|
||||
double A11 = A4*cos(phi_old) - A5*sin(phi_old);
|
||||
double A21 = A4*sin(phi_old) + A5*cos(phi_old);
|
||||
double theta_new = acos( cos(theta_old)*cos(theta_change)-A3*sin(theta_old) );
|
||||
|
||||
// Get right phi1, maybe more elegant way later. Problem comes from reverse functions only being on range of pi. So combine both statements to get proper phi over 2pi.
|
||||
int digits = 6;
|
||||
double fac = pow(10,digits);
|
||||
double phi_new = -1;
|
||||
double phi_new_candidates [4];
|
||||
phi_new_candidates[0] = acos( roundf ( A11/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[1] = 2*pi - phi_new_candidates[0];
|
||||
phi_new_candidates[2] = asin ( roundf ( A21/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[3] = pi - phi_new_candidates[2];
|
||||
phi_new_candidates[2] = (phi_new_candidates[2] > 0) ? phi_new_candidates[2] : 2*pi + phi_new_candidates[2];
|
||||
for (int i=0;i<3;i++) {
|
||||
for (int j=i+1;j<4;j++) {
|
||||
if (phi_new_candidates[i]-phi_new_candidates[j] < 0.0001) {
|
||||
phi_new = phi_new_candidates[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (phi_new == -1) {
|
||||
throw MyException("Interaction::getElaNewDir: phi1 not found.");
|
||||
}
|
||||
return(vec3(sin(theta_new)*cos(phi_new) , sin(theta_new)*sin(phi_new) , cos(theta_new)));
|
||||
}
|
||||
|
||||
#endif /* kinematics_h */
|
||||
+183
-161
@@ -19,10 +19,10 @@ using namespace std;
|
||||
|
||||
|
||||
const int Base_Logger::numberZBins = getParameter("numberZBins");
|
||||
const double Base_Logger::wgtsLength_m = getParameter("wgtsLength_m");
|
||||
|
||||
// Base_Logger
|
||||
Base_Logger::Base_Logger() {
|
||||
Base_Logger::Base_Logger(Katrin *Kat) {
|
||||
this->Kat = Kat;
|
||||
if (numberZBins == 0) {
|
||||
cout<<"Logging turned off."<<endl;
|
||||
logging = false;
|
||||
@@ -37,28 +37,21 @@ void Base_Logger::set_zLogValues() {
|
||||
if (numberZBins == -1) {
|
||||
cout<<"Logging everything to one file."<<endl;
|
||||
} else if (numberZBins == 1) {
|
||||
cout<<"Logging 1 z-Value: "<<wgtsLength_m<<endl;
|
||||
zLogValues.push_back(wgtsLength_m);
|
||||
cout<<"Logging 1 z-Value: "<<Kat->get_z_WGTSend_m()<<endl;
|
||||
zLogValues.push_back(Kat->get_z_WGTSend_m());
|
||||
} else {
|
||||
double z_m;
|
||||
double length_m = Kat->get_z_WGTSend_m() - Kat->get_z_RW_m();
|
||||
double stepLength_m = length_m/(numberZBins-1);
|
||||
for (int i = 0;i<numberZBins;i++) {
|
||||
zLogValues.push_back( i*wgtsLength_m/(numberZBins-1) );
|
||||
z_m = Kat->get_z_RW_m() + stepLength_m*i;
|
||||
zLogValues.push_back(z_m);
|
||||
}
|
||||
cout<<"Logging "<<numberZBins<<" z-Values."<<endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
string Base_Logger::getTimeString() {
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
char buffer[80];
|
||||
time (&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
strftime(buffer,sizeof(buffer),"%Y%m%d",timeinfo);
|
||||
string str(buffer);
|
||||
return(str);
|
||||
}
|
||||
|
||||
std::string Base_Logger::getparName() {
|
||||
string parpath = getenv("parpath");
|
||||
string parfile = remove_catEnding(getenv("parfile"));
|
||||
@@ -88,170 +81,33 @@ bool Base_Logger::isDir(std::string dirPath) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
// H5_Logger
|
||||
H5_Logger::H5_Logger() : Base_Logger() {
|
||||
set_outH5FName();
|
||||
create_outH5F();
|
||||
create_H5Gs();
|
||||
create_particle_electronH5TBs();
|
||||
//set_outStream();
|
||||
}
|
||||
|
||||
// File
|
||||
void H5_Logger::set_outH5FName() {
|
||||
string parname = getparName();
|
||||
stringstream H5name;
|
||||
int i = 1;
|
||||
do {
|
||||
H5name.str(std::string());
|
||||
H5name << parname << "_" << getTimeString() << "_" << i++<<".h5";
|
||||
} while ( isFile(H5name.str()) );
|
||||
outH5FName = H5name.str();
|
||||
return;
|
||||
}
|
||||
|
||||
void H5_Logger::create_outH5F() {
|
||||
const string consth5Name = outH5FName;
|
||||
outH5F = H5Fcreate(consth5Name.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
|
||||
// Groups
|
||||
void H5_Logger::create_H5Gs() {
|
||||
particleH5G = H5Gcreate2(outH5F, "/Particles", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
if (numberZBins == -1) {
|
||||
particle_zH5G = new hid_t[1];
|
||||
particle_zH5G[0] = H5Gcreate2(outH5F, "/Particles/z=all", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
} else {
|
||||
particle_zH5G = new hid_t [numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "/Particles/z=" << zLogValues[i];
|
||||
particle_zH5G[i] = H5Gcreate2(outH5F, ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Electrons
|
||||
const size_t H5_Logger::particle_electronH5TB_size = sizeof(logElectron);
|
||||
const char *H5_Logger::particle_electronH5TB_fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
|
||||
const size_t H5_Logger::particle_electronH5TB_offset[8] = {
|
||||
HOFFSET(logElectron, Id),
|
||||
HOFFSET(logElectron, parentId),
|
||||
HOFFSET(logElectron, x_m),
|
||||
HOFFSET(logElectron, y_m),
|
||||
HOFFSET(logElectron, z_m),
|
||||
HOFFSET(logElectron, vx_ms),
|
||||
HOFFSET(logElectron, vy_ms),
|
||||
HOFFSET(logElectron, vz_ms)};
|
||||
const hid_t H5_Logger::particle_electronH5TB_fieldTypes[8] = {
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE};
|
||||
const hsize_t H5_Logger::particle_electronH5TB_chunkSize = 4096;
|
||||
|
||||
logElectron sampleLogElectron = {0,0,0,0,0,0,0,0};
|
||||
const size_t H5_Logger::particle_electronH5TB_sizes[8] = {
|
||||
sizeof( sampleLogElectron.Id),
|
||||
sizeof( sampleLogElectron.parentId),
|
||||
sizeof( sampleLogElectron.x_m),
|
||||
sizeof( sampleLogElectron.y_m),
|
||||
sizeof( sampleLogElectron.z_m),
|
||||
sizeof( sampleLogElectron.vx_ms),
|
||||
sizeof( sampleLogElectron.vy_ms),
|
||||
sizeof( sampleLogElectron.vz_ms)};
|
||||
|
||||
void H5_Logger::test_log() {
|
||||
Electron testElectron = Electron(vec3(1,2,3), vec3(4,5,6), 7, 8);
|
||||
log_Electron(&testElectron, vec3(9,10,7));
|
||||
return;
|
||||
}
|
||||
|
||||
void H5_Logger::log_Electron(Electron *inElectron,blitz::TinyVector<double,3> oldLoc_m) {
|
||||
if (!logging) {
|
||||
return;
|
||||
}
|
||||
logElectron logElectron_buffer = Electron_to_logElectron(inElectron);
|
||||
// Assumption: no change of sign in v_z
|
||||
if (numberZBins == -1) {
|
||||
H5TBappend_records(particle_zH5G[0], "electrons", 1, particle_electronH5TB_size, particle_electronH5TB_offset, particle_electronH5TB_sizes, &logElectron_buffer );
|
||||
} else {
|
||||
double zold = oldLoc_m[2];
|
||||
double znew = inElectron->get_Location_m()[2];
|
||||
double zmin = min(zold,znew);
|
||||
double zmax = max(zold,znew);
|
||||
|
||||
for (int i=0;i<numberZBins;i++) {
|
||||
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
|
||||
H5TBappend_records(particle_zH5G[i], "electrons", 1, particle_electronH5TB_size, particle_electronH5TB_offset, particle_electronH5TB_sizes, &logElectron_buffer ); // Location wrong, because it s the new Location.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void H5_Logger::create_particle_electronH5TBs() {
|
||||
if (numberZBins == -1) {
|
||||
particle_electronH5T = new hid_t[1];
|
||||
particle_electronH5T[0] = H5TBmake_table( "Electron Table", particle_zH5G[0], "electrons", 8, 0,
|
||||
particle_electronH5TB_size, particle_electronH5TB_fieldNames, particle_electronH5TB_offset, particle_electronH5TB_fieldTypes,
|
||||
particle_electronH5TB_chunkSize, NULL, 0, NULL);
|
||||
} else {
|
||||
particle_electronH5T = new hid_t[numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
particle_electronH5T[i] = H5TBmake_table( "Electron Table", particle_zH5G[i], "electrons",8,0,
|
||||
particle_electronH5TB_size, particle_electronH5TB_fieldNames, particle_electronH5TB_offset, particle_electronH5TB_fieldTypes,
|
||||
particle_electronH5TB_chunkSize, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logElectron H5_Logger::Electron_to_logElectron(Electron *inElectron) {
|
||||
logElectron res;
|
||||
res.Id = inElectron->get_Id();
|
||||
res.parentId = inElectron->get_ParentId();
|
||||
res.x_m = inElectron->get_Location_m()[0];
|
||||
res.y_m = inElectron->get_Location_m()[1];
|
||||
res.z_m = inElectron->get_Location_m()[2];
|
||||
res.vx_ms = inElectron->get_Speed_ms()[0];
|
||||
res.vy_ms = inElectron->get_Speed_ms()[1];
|
||||
res.vz_ms = inElectron->get_Speed_ms()[2];
|
||||
return (res);
|
||||
}
|
||||
|
||||
// ASCI_Logger
|
||||
ASCI_Logger::ASCI_Logger() : Base_Logger() {
|
||||
ASCI_Logger::ASCI_Logger(Katrin *Kat) : Base_Logger(Kat) {
|
||||
set_outdirName();
|
||||
create_outdir();
|
||||
set_outStream();
|
||||
}
|
||||
|
||||
void ASCI_Logger::log_Electron(Electron *inElectron, blitz::TinyVector<double,3> oldLoc_m) {
|
||||
void ASCI_Logger::log_Particle(Particle *logPart, blitz::TinyVector<double,3> oldLoc_m) {
|
||||
if (!logging) {
|
||||
return;
|
||||
}
|
||||
if (logPart->get_Species() != electron) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Assumption: no change of sign in v_z
|
||||
if (numberZBins == -1) {
|
||||
outStream[0]<<*inElectron<<endl;
|
||||
outStream[0]<<*logPart<<endl;
|
||||
} else {
|
||||
double zold = oldLoc_m[2];
|
||||
double znew = inElectron->get_Location_m()[2];
|
||||
double znew = logPart->get_Location_m()[2];
|
||||
double zmin = min(zold,znew);
|
||||
double zmax = max(zold,znew);
|
||||
|
||||
for (int i=0;i<numberZBins;i++) {
|
||||
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
|
||||
outStream[i]<<*inElectron<<endl; // Location wrong, because it s the new Location.
|
||||
outStream[i]<<*logPart<<endl; // Location wrong, because it s the new Location.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,3 +150,169 @@ void ASCI_Logger::set_outStream() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ParticleH5TB_Properties
|
||||
const size_t ParticleH5TB_Properties::size = sizeof(logParticle);
|
||||
const char *ParticleH5TB_Properties::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
|
||||
const size_t ParticleH5TB_Properties::offset[8] = {
|
||||
HOFFSET(logParticle, Id),
|
||||
HOFFSET(logParticle, parentId),
|
||||
HOFFSET(logParticle, x_m),
|
||||
HOFFSET(logParticle, y_m),
|
||||
HOFFSET(logParticle, z_m),
|
||||
HOFFSET(logParticle, vx_ms),
|
||||
HOFFSET(logParticle, vy_ms),
|
||||
HOFFSET(logParticle, vz_ms)};
|
||||
const hid_t ParticleH5TB_Properties::fieldTypes[8] = {
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE};
|
||||
const hsize_t ParticleH5TB_Properties::chunkSize = 4096;
|
||||
|
||||
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
|
||||
const size_t ParticleH5TB_Properties::sizes[8] = {
|
||||
sizeof( samplelogParticle.Id),
|
||||
sizeof( samplelogParticle.parentId),
|
||||
sizeof( samplelogParticle.x_m),
|
||||
sizeof( samplelogParticle.y_m),
|
||||
sizeof( samplelogParticle.z_m),
|
||||
sizeof( samplelogParticle.vx_ms),
|
||||
sizeof( samplelogParticle.vy_ms),
|
||||
sizeof( samplelogParticle.vz_ms)};
|
||||
|
||||
|
||||
// ParticleLogger
|
||||
void ParticleLogger::create_particle_H5TBs() {
|
||||
if (numberZBins == -1) {
|
||||
particle_H5TB = new hid_t[1];
|
||||
particle_H5TB[0] = H5TBmake_table(speciesIdentifier.c_str(), particle_zH5G[0], speciesIdentifier.c_str(), 8, 0,
|
||||
size, fieldNames, offset, fieldTypes,
|
||||
chunkSize, NULL, 0, NULL);
|
||||
} else {
|
||||
particle_H5TB = new hid_t[numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
particle_H5TB[i] = H5TBmake_table( speciesIdentifier.c_str(), particle_zH5G[i], speciesIdentifier.c_str(),8,0,
|
||||
size, fieldNames, offset, fieldTypes,
|
||||
chunkSize, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleLogger::log_Particle(const Particle &logPart, const vec3 &oldLoc_m) {
|
||||
check_Species(logPart);
|
||||
|
||||
logParticle logParticle_buffer = transformTo_logParticle(logPart);
|
||||
// Assumption: no change of sign in v_z
|
||||
if (singleFile) {
|
||||
H5TBappend_records(particle_zH5G[0], speciesIdentifier.c_str() , 1, size, offset, sizes, &logParticle_buffer );
|
||||
} else {
|
||||
double zold = oldLoc_m[2];
|
||||
double znew = logPart.get_Location_m()[2];
|
||||
double zmin = min(zold,znew);
|
||||
double zmax = max(zold,znew);
|
||||
|
||||
for (int i=0;i<numberZBins;i++) {
|
||||
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
|
||||
H5TBappend_records(particle_zH5G[i], speciesIdentifier.c_str(), 1, size, offset, sizes, &logParticle_buffer ); // Location wrong, because it s the new Location.
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void ParticleLogger::check_Species(const Particle &logPart) {
|
||||
if (logPart.get_Species() != Species) {
|
||||
stringstream ss;
|
||||
ss<<"ParticleLogger::check_Species: Wrong Species\nExpected:\t"<<Species<<"\nInput:\t"<<logPart.get_Species()<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
logParticle ParticleLogger::transformTo_logParticle(const Particle &logPart) {
|
||||
logParticle res;
|
||||
res.Id = logPart.get_Id();
|
||||
res.parentId = logPart.get_ParentId();
|
||||
res.x_m = logPart.get_Location_m()[0];
|
||||
res.y_m = logPart.get_Location_m()[1];
|
||||
res.z_m = logPart.get_Location_m()[2];
|
||||
res.vx_ms = logPart.get_Speed_ms()[0];
|
||||
res.vy_ms = logPart.get_Speed_ms()[1];
|
||||
res.vz_ms = logPart.get_Speed_ms()[2];
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
// H5_Logger
|
||||
void H5_Logger::create_outH5F() {
|
||||
const string constH5Name = get_outH5F_fullPath();
|
||||
outH5F = H5Fcreate(constH5Name.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
|
||||
string H5_Logger::get_outH5F_fullPath() {
|
||||
string parname = getparName();
|
||||
stringstream H5name;
|
||||
int i = 1;
|
||||
do {
|
||||
H5name.str(std::string());
|
||||
H5name << parname << "_" << getTimeString() << "_" << i++<<".h5";
|
||||
} while ( isFile(H5name.str()) );
|
||||
return (H5name.str());
|
||||
}
|
||||
|
||||
void H5_Logger::create_particleH5G() {
|
||||
particleH5G = H5Gcreate2(outH5F, "/Particles", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
|
||||
void H5_Logger::create_particle_zH5G() {
|
||||
if (numberZBins == -1) {
|
||||
particle_zH5G = new hid_t[1];
|
||||
particle_zH5G[0] = H5Gcreate2(particleH5G, "/z=all", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
} else {
|
||||
particle_zH5G = new hid_t [numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "/z=" << zLogValues[i];
|
||||
particle_zH5G[i] = H5Gcreate2(particleH5G, ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void H5_Logger::add_ParticleLogger(ParticleLogger* addParticleLogger){
|
||||
if (find_ParticleLogger(addParticleLogger->get_Species()) != ParticleLoggers.end()) {
|
||||
stringstream ss;
|
||||
ss<<"H5_Logger::add_ParticleLogger: Species already exists.\nSpecies:\t"<<addParticleLogger->get_Species()<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
ParticleLoggers.push_back(addParticleLogger);
|
||||
}
|
||||
|
||||
ParticleLoggerVec::iterator H5_Logger::find_ParticleLogger (species findSpec) {
|
||||
if (ParticleLoggers.size() == 0) {
|
||||
return (ParticleLoggers.end());
|
||||
}
|
||||
ParticleLoggerVec::iterator Itr;
|
||||
Itr = ParticleLoggers.begin();
|
||||
while (Itr != ParticleLoggers.end()) {
|
||||
if ((*Itr)->get_Species() == findSpec ) {
|
||||
return (Itr);
|
||||
}
|
||||
Itr++;
|
||||
}
|
||||
return (Itr);
|
||||
}
|
||||
|
||||
void H5_Logger::log_Particle(const Particle &logPart, vec3 oldLoc_m) {
|
||||
ParticleLoggerVec::iterator Itr;
|
||||
Itr = find_ParticleLogger(logPart.get_Species());
|
||||
if (Itr!= ParticleLoggers.end()) {
|
||||
(*Itr)->log_Particle(logPart, oldLoc_m);
|
||||
}
|
||||
}
|
||||
|
||||
+93
-49
@@ -9,11 +9,12 @@
|
||||
#ifndef logger_hpp
|
||||
#define logger_hpp
|
||||
|
||||
#include "electron.hpp"
|
||||
#include "particle.hpp"
|
||||
#include "katrin.hpp"
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
typedef struct logElectron {
|
||||
typedef struct logParticle {
|
||||
unsigned int Id;
|
||||
unsigned int parentId;
|
||||
double x_m;
|
||||
@@ -22,17 +23,16 @@ typedef struct logElectron {
|
||||
double vx_ms;
|
||||
double vy_ms;
|
||||
double vz_ms;
|
||||
} logElectron;
|
||||
} logParticle;
|
||||
|
||||
|
||||
// Base_Logger: Base_Class for all Logger: Reading Paramter and calculating z-Barrieres.
|
||||
class Base_Logger {
|
||||
public:
|
||||
Base_Logger();
|
||||
Base_Logger(Katrin *Kat);
|
||||
|
||||
protected:
|
||||
static const int numberZBins;
|
||||
static const double wgtsLength_m;
|
||||
|
||||
bool logging;
|
||||
std::vector<double> zLogValues;
|
||||
@@ -40,59 +40,20 @@ protected:
|
||||
void set_zLogValues();
|
||||
|
||||
std::string getparName();
|
||||
std::string getTimeString();
|
||||
std::string remove_catEnding (std::string inString);
|
||||
bool isFile(std::string fileName);
|
||||
bool isDir(std::string dirPath);
|
||||
|
||||
Katrin *Kat;
|
||||
};
|
||||
|
||||
// H5_Logger: Logging to HDF5 file format.
|
||||
class H5_Logger : private Base_Logger {
|
||||
|
||||
|
||||
public:
|
||||
H5_Logger();
|
||||
|
||||
|
||||
private:
|
||||
// File
|
||||
std::string outH5FName;
|
||||
hid_t outH5F;
|
||||
|
||||
void set_outH5FName();
|
||||
void create_outH5F();
|
||||
|
||||
// Groups
|
||||
hid_t particleH5G;
|
||||
hid_t *particle_zH5G;
|
||||
|
||||
void create_H5Gs();
|
||||
|
||||
// Electrons
|
||||
public:
|
||||
void test_log();
|
||||
void log_Electron(Electron *inElectron,blitz::TinyVector<double,3> oldLoc_m);
|
||||
private:
|
||||
static const size_t particle_electronH5TB_size;
|
||||
static const char *particle_electronH5TB_fieldNames[8];
|
||||
static const size_t particle_electronH5TB_offset[8];
|
||||
static const hid_t particle_electronH5TB_fieldTypes[8];
|
||||
static const hsize_t particle_electronH5TB_chunkSize;
|
||||
static const size_t particle_electronH5TB_sizes[8];
|
||||
|
||||
hid_t *particle_electronH5T;
|
||||
|
||||
void create_particle_electronH5TBs();
|
||||
|
||||
logElectron Electron_to_logElectron(Electron *inElectron);
|
||||
};
|
||||
|
||||
// ASCI_Logger: Log to ASCI-File. Only Electron Logger. Not very efficient.
|
||||
class ASCI_Logger : private Base_Logger {
|
||||
class ASCI_Logger : public Base_Logger {
|
||||
public:
|
||||
ASCI_Logger();
|
||||
ASCI_Logger(Katrin *Kat);
|
||||
|
||||
void log_Electron(Electron *inElectron,blitz::TinyVector<double,3> oldLoc_m);
|
||||
void log_Particle(Particle *inPart , vec3 oldLoc_m);
|
||||
private:
|
||||
std::string outdirName;
|
||||
std::ofstream *outStream;
|
||||
@@ -103,4 +64,87 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class ParticleH5TB_Properties {
|
||||
public:
|
||||
ParticleH5TB_Properties() {};
|
||||
protected:
|
||||
static const size_t size;
|
||||
static const char *fieldNames[8];
|
||||
static const size_t offset[8];
|
||||
static const hid_t fieldTypes[8];
|
||||
static const hsize_t chunkSize;
|
||||
static const size_t sizes[8];
|
||||
};
|
||||
|
||||
|
||||
class ParticleLogger : ParticleH5TB_Properties{
|
||||
public:
|
||||
ParticleLogger(species Species, hid_t *particle_zH5G, std::vector<double> zLogValues) {
|
||||
this->Species = Species;
|
||||
this->particle_zH5G = particle_zH5G;
|
||||
this->zLogValues = zLogValues;
|
||||
numberZBins = zLogValues.size();
|
||||
singleFile = (numberZBins == 1) ? true : false;
|
||||
stringstream ss;
|
||||
ss<<Species;
|
||||
speciesIdentifier = ss.str();
|
||||
create_particle_H5TBs();
|
||||
};
|
||||
private:
|
||||
void create_particle_H5TBs();
|
||||
|
||||
private:
|
||||
hid_t *particle_zH5G;
|
||||
std::vector<double> zLogValues;
|
||||
hid_t *particle_H5TB;
|
||||
species Species;
|
||||
|
||||
int numberZBins;
|
||||
bool singleFile;
|
||||
std::string speciesIdentifier;
|
||||
public:
|
||||
void log_Particle(const Particle &logPart, const vec3 &oldLoc_m);
|
||||
private:
|
||||
logParticle transformTo_logParticle(const Particle &logPart);
|
||||
public:
|
||||
species get_Species() const {return(Species);};
|
||||
private:
|
||||
void check_Species(const Particle &logPart);
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<ParticleLogger*> ParticleLoggerVec;
|
||||
|
||||
class H5_Logger : private Base_Logger {
|
||||
public:
|
||||
H5_Logger(Katrin *Kat) : Base_Logger(Kat) {
|
||||
create_outH5F();
|
||||
create_particleH5G();
|
||||
create_particle_zH5G();
|
||||
add_ParticleLogger(new ParticleLogger(electron, particle_zH5G,zLogValues));
|
||||
};
|
||||
|
||||
private:
|
||||
hid_t outH5F;
|
||||
hid_t particleH5G;
|
||||
hid_t *particle_zH5G;
|
||||
|
||||
ParticleLoggerVec ParticleLoggers;
|
||||
|
||||
private:
|
||||
void create_outH5F();
|
||||
std::string get_outH5F_fullPath();
|
||||
void create_particleH5G();
|
||||
void create_particle_zH5G();
|
||||
|
||||
public:
|
||||
void add_ParticleLogger(ParticleLogger* addParticleLogger);
|
||||
private:
|
||||
ParticleLoggerVec::iterator find_ParticleLogger (species findSpec);
|
||||
|
||||
public:
|
||||
void log_Particle(const Particle &logPart, vec3 oldLoc_m);
|
||||
};
|
||||
|
||||
|
||||
#endif /* logger_hpp */
|
||||
|
||||
+41
-10
@@ -7,23 +7,54 @@
|
||||
//
|
||||
|
||||
#include "simulation.hpp"
|
||||
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void createBED_TCS_Func_container() {
|
||||
Edge1D_FuncContainer BED_edge_TCS;
|
||||
BED_edge_TCS.fillFromFunction(BED_eT2_Ionization::calc_TCS, 15, 20000, 100);
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV, BED_eT2_Ionization::calc_TCS(EionT2_eV));
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV+1e-4, BED_eT2_Ionization::calc_TCS(EionT2_eV+1e-4));
|
||||
BED_edge_TCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_edge_TCS.dat");
|
||||
|
||||
Average1D_FuncContainer BED_average_TCS;
|
||||
BED_average_TCS.set_Map(BED_edge_TCS);
|
||||
BED_average_TCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_average_TCS.dat");
|
||||
}
|
||||
|
||||
void createBED_SDCS_Func2D_container() {
|
||||
Edge2D_FuncContainer BED_edge_SDCS;
|
||||
BED_edge_SDCS.get_Ionization_fromFunction(BED_eT2_Ionization::calc_SDCS, 15, 20000, 50, 10);
|
||||
BED_edge_SDCS.add_ankerpoint(EionT2_eV, 0,0);
|
||||
double xmin =EionT2_eV+1e-4;
|
||||
double ymin = (xmin-EionT2_eV)/2;
|
||||
BED_edge_SDCS.add_ankerpoint(xmin, ymin,BED_eT2_Ionization::calc_SDCS(xmin,ymin));
|
||||
BED_edge_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_edge_SDCS.dat");
|
||||
|
||||
Average2D_FuncContainer BED_average_SDCS;
|
||||
BED_average_SDCS.set_Map(BED_edge_SDCS);
|
||||
BED_average_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_average_SDCS.dat");
|
||||
|
||||
|
||||
Stacked2D_FuncContainer BED_stacked_SDCS;
|
||||
BED_stacked_SDCS.set_Map(BED_average_SDCS);
|
||||
BED_stacked_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_stacked_SDCS.dat");
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
clock_t start = clock();
|
||||
/*
|
||||
try {
|
||||
Simulation Sim;
|
||||
Sim.doit();
|
||||
} catch (MyException& caught) {
|
||||
cout<<caught.what()<<endl;
|
||||
exit(1);
|
||||
}
|
||||
*/
|
||||
Simulation Sim;
|
||||
Sim.doit();
|
||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
||||
|
||||
//createBED_TCS_Func_container();
|
||||
//createBED_SDCS_Func2D_container();
|
||||
//Katrin Kat;
|
||||
//Skalar_WGTS_Container Ion_Container(0, 10, 0.045, vec3(10,10,10));
|
||||
//Ion_Container.set_Bins_from_Function(tritiumDens);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,14 @@ TARGETS = mcelectron
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
mcelectron: main.o simulation.o\
|
||||
functions.o function_container.o katrin.o logger.o \
|
||||
particle.o electron.o bedionization.o
|
||||
mcelectron: main.o \
|
||||
function_container.o density_container.o \
|
||||
simulation.o logger.o \
|
||||
BED_eT2_ionization.o \
|
||||
katrin.o injector.o mover.o terminator.o \
|
||||
interaction_processor.o interaction_species.o interaction_builder.o \
|
||||
electron_interactions.o \
|
||||
particle.o
|
||||
$(CXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||
|
||||
%.o : %.cpp
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// mover.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "mover.hpp"
|
||||
|
||||
const int Mover::propagationMethod = getParameter("propagationMethod");
|
||||
const double Mover::dt_s = getParameter("dt_s");
|
||||
|
||||
void Mover::moveParticle(Particle *movePart, const double &distance_m) {
|
||||
this->movePart = movePart;
|
||||
if (propagationMethod==0) {
|
||||
do_DriftApproximationMovement(distance_m);
|
||||
} else if (propagationMethod==1) {
|
||||
do_BorisPushMovement(distance_m);
|
||||
} else {
|
||||
stringstream ss;
|
||||
ss<<"Simulation::move_electron: propagationMethod="<<propagationMethod<<" not valid.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||
void Mover::do_DriftApproximationMovement(const double &distance_m) {
|
||||
vec3 oldLoc_m = movePart->get_Location_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
double znew_m = getDrift_znew_m(distance_m);
|
||||
doDrift_WallInteraction(&oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
movePart->set_Location_m(newLoc_m);
|
||||
Log->log_Particle(*movePart,oldLoc_m);
|
||||
}
|
||||
double Mover::getDrift_znew_m(const double &distance_m) {
|
||||
double zold_m = movePart->get_Location_m()[2];
|
||||
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
double vTotAbs_ms = vec3Abs(v_ms);
|
||||
double vForwardAbs_ms = vec3Abs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] < 0 ? -1 : 1;
|
||||
|
||||
double znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
return (znew_m);
|
||||
}
|
||||
|
||||
void Mover::doDrift_WallInteraction(vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= Kat->get_z_WGTSend_m()) { // Moveing into Spectrometer and reversing Speed.
|
||||
vec3 reverseLoc_m = *oldLoc_m;
|
||||
|
||||
// Log Movement before Reflection
|
||||
reverseLoc_m[2] = Kat->get_z_WGTSend_m();
|
||||
movePart->set_Location_m(reverseLoc_m);
|
||||
Log->log_Particle(*movePart,*oldLoc_m);
|
||||
|
||||
// Final Movement
|
||||
*oldLoc_m = reverseLoc_m;
|
||||
*znew_m = Kat->get_z_WGTSend_m() - (*znew_m - Kat->get_z_WGTSend_m());
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
if (*znew_m <= Kat->get_z_RW_m()) {
|
||||
*znew_m = Kat->get_z_RW_m();
|
||||
}
|
||||
}
|
||||
|
||||
void Mover::do_BorisPushMovement(const double &distance_m) {
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_Location_m();
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_Location_m();
|
||||
E_Vm = Kat->getElField_Vm(loc_m);
|
||||
B_T = Kat->getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(E_Vm, B_T);
|
||||
if (doBoris_WallInteraction() == true) {
|
||||
Log->log_Particle(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(&oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Log->log_Particle(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double Mover::doBoris_singleStep_m(const vec3 &E_Vm , const vec3 &B_T) {
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_Location_m();
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * vec3Abs(v_ms);
|
||||
doBoris_speedChange(E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * vec3Abs(v_ms);
|
||||
movePart->set_Location_m(x_m);
|
||||
return(distance_m);
|
||||
}
|
||||
|
||||
void Mover::doBoris_speedChange(const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Charge_nat() * e_C;
|
||||
double m_kg = movePart->get_Mass_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_Speed_ms(v_ms);
|
||||
}
|
||||
|
||||
bool Mover::doBoris_WallInteraction() {
|
||||
vec3 loc_m = movePart->get_Location_m();
|
||||
double r_m = movePart->get_Radius_m();
|
||||
if (loc_m[2]<=Kat->get_z_RW_m()) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_Location_m(newLoc_m);
|
||||
return (true);
|
||||
}
|
||||
if (r_m>=Kat->get_radius_m()) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (Kat->get_radius_m() * 1.01)/vec3Abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return (true);
|
||||
}
|
||||
if (loc_m[2]>=Kat->get_z_WGTSend_m()) { // Spectrometer Reflection
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
void Mover::doBoris_LogzDirChange(double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Log->log_Particle(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_Location_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// mover.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef mover_hpp
|
||||
#define mover_hpp
|
||||
|
||||
#include "kinematics.h"
|
||||
#include "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
// Mover: Moves Particles within WGTS using parameter propagationMethod to determine Method.
|
||||
// Also Logging during movement
|
||||
class Mover {
|
||||
public:
|
||||
Mover(Katrin *Kat, H5_Logger *Log) {
|
||||
this->Kat = Kat;
|
||||
this->Log = Log;
|
||||
};
|
||||
|
||||
void moveParticle(Particle *movePart, const double &distance_m);
|
||||
|
||||
private:
|
||||
void do_DriftApproximationMovement(const double &distance_m);
|
||||
double getDrift_znew_m(const double &distance_m);
|
||||
void doDrift_WallInteraction(vec3 *oldLoc_m, double *znew_m);
|
||||
|
||||
void do_BorisPushMovement(const double &distance_m);
|
||||
double doBoris_singleStep_m(const vec3 &E_Vm , const vec3 &B_T);
|
||||
void doBoris_speedChange(const vec3 &E_Vm, const vec3 &B_T);
|
||||
bool doBoris_WallInteraction();
|
||||
void doBoris_LogzDirChange(double *oldzDir, vec3 *oldLoc_m);
|
||||
|
||||
static const int propagationMethod;
|
||||
static const double dt_s;
|
||||
|
||||
Particle *movePart;
|
||||
|
||||
Katrin *Kat;
|
||||
H5_Logger *Log;
|
||||
};
|
||||
#endif /* mover_hpp */
|
||||
@@ -74,25 +74,4 @@ Particle::Particle(double mass_eV, double charge_e,vec3 loc_m, vec3 speed_ms, do
|
||||
s = spec;
|
||||
}
|
||||
|
||||
double Particle::do_BorisStep_m(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s) {
|
||||
double distance_m;
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * get_SpeedAbs_ms();
|
||||
this->doBoris_SpeedChange(E_Vm , B_T , dt_s);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * get_SpeedAbs_ms();
|
||||
return(distance_m);
|
||||
}
|
||||
|
||||
void Particle::doBoris_SpeedChange(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s) {
|
||||
blitz::TinyVector<double, 3> vMinus_ms, vPlus_ms, vPrime_ms, t, s;
|
||||
double q_C = -1*Z * e_C;
|
||||
double m_kg = m_eV*e_C/c_ms/c_ms;
|
||||
|
||||
t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
s = (2*t)/(1+dot(t,t));
|
||||
vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef particle_hpp
|
||||
#define particle_hpp
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "functions.hpp"
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
#include "iostream"
|
||||
#include "blitz/tinyvec2.h"
|
||||
@@ -23,6 +23,7 @@ std::ostream& operator<<(std::ostream& os, const species& SpecOut);
|
||||
|
||||
class Particle {
|
||||
public:
|
||||
Particle() {};
|
||||
Particle(double mass_eV, double charge_e,vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum, species spec);
|
||||
|
||||
protected:
|
||||
@@ -34,35 +35,39 @@ protected:
|
||||
unsigned int Id;
|
||||
unsigned int parentId;
|
||||
|
||||
|
||||
public:
|
||||
// Get Properties Methods
|
||||
double get_Mass_eV() { return(m_eV); }
|
||||
double get_Charge_e() { return(Z); }
|
||||
vec3 get_Location_m() { return(x_m); }
|
||||
vec3 get_Speed_ms() { return(v_ms); }
|
||||
species get_Species() {return(s); }
|
||||
double get_Id() { return(Id); }
|
||||
double get_ParentId() { return(parentId); }
|
||||
double get_Mass_eV() { return(m_eV); };
|
||||
double get_Charge_nat() { return(Z); };
|
||||
vec3 get_Location_m() const { return(x_m); };
|
||||
vec3 get_Speed_ms() const { return(v_ms); };
|
||||
species get_Species() const {return(s); };
|
||||
double get_Id() const { return(Id); };
|
||||
double get_ParentId() const { return(parentId); };
|
||||
|
||||
// Get Properties
|
||||
double get_Radius_m() { return ( sqrt( pow(x_m[0],2) + pow(x_m[1],2) ) ); }
|
||||
double get_SpeedAbs_ms() { return ( get_vecAbs(v_ms) ); }
|
||||
double get_EKin_eV() { return ( get_Ekin_eV_from_speed(get_SpeedAbs_ms(), m_eV) ); }
|
||||
double get_Radius_m() { return ( sqrt( pow(x_m[0],2) + pow(x_m[1],2) ) ); } ;
|
||||
double get_SpeedAbs_ms() const { return ( vec3Abs(v_ms) ); } ;
|
||||
double get_EKin_eV() const { return ( calc_Ekin_eV_from_speed(v_ms, m_eV) ); } ;
|
||||
|
||||
// Set Properties Methods
|
||||
void set_Location_m(blitz::TinyVector<double, 3> xnew_m) {x_m = xnew_m; };
|
||||
void set_Speed_ms(blitz::TinyVector<double, 3> vnew_ms) {v_ms = vnew_ms; };
|
||||
|
||||
//Boris Push: Propagate Flight for one timestep dt_s in E_Vm and B_T and returns distance.
|
||||
public:
|
||||
double do_BorisStep_m(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s);
|
||||
protected:
|
||||
void doBoris_SpeedChange(blitz::TinyVector<double, 3> E_Vm,blitz::TinyVector<double, 3> B_T , double dt_s);
|
||||
|
||||
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const Particle& partOut);
|
||||
};
|
||||
|
||||
class ParticleBuilder {
|
||||
public:
|
||||
ParticleBuilder() {};
|
||||
|
||||
Particle createElectron(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) const {
|
||||
return ( Particle(me_eV, -1 , loc_m, speed_ms, idnum, parentIdnum, electron));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* particle_hpp */
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// random_operations.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef random_operations_h
|
||||
#define random_operations_h
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
|
||||
typedef ranlib::Uniform<double> UniRNG;
|
||||
typedef ranlib::NormalUnit<double> NormalRNG;
|
||||
|
||||
|
||||
class RNG_Base {
|
||||
public:
|
||||
RNG_Base(UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
this->rngUni = rngUni;
|
||||
this->rngNormal = rngNormal;
|
||||
};
|
||||
protected:
|
||||
UniRNG *rngUni;
|
||||
NormalRNG *rngNormal;
|
||||
};
|
||||
|
||||
|
||||
inline vec3 roll_uniform_direction(ranlib::Uniform<double> *rngUni) {
|
||||
vec3 dir;
|
||||
double phi = 2*pi*rngUni->random();
|
||||
double theta = pi*rngUni->random();
|
||||
dir = sin(theta)*cos(phi) , sin(theta)*sin(phi) , cos(theta);
|
||||
return(dir);
|
||||
}
|
||||
|
||||
inline double roll_MBEnergy(const double &Temp_K, const double &mass_eV,ranlib::NormalUnit<double> *rngNormal) {
|
||||
|
||||
double C = kb_eVK*Temp_K/mass_eV;
|
||||
double beta = 0;
|
||||
double sum = 0;
|
||||
for (int i=0;i<3;i++) {
|
||||
sum += pow(rngNormal->random(),2);
|
||||
}
|
||||
beta = sqrt(C*(sum));
|
||||
|
||||
return((calc_gamma_from_beta(beta)-1)*mass_eV);
|
||||
}
|
||||
|
||||
inline double roll_Rejectionmethod(double (*pdf)(double), double xmin, double xmax, double pmax, ranlib::Uniform<double> *rngUni) {
|
||||
// get Energy distribution using Rejection Method
|
||||
double xcan,eta1,eta2;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
xcan = xmin + eta1*(xmax - xmin);
|
||||
} while( eta2*pmax > pdf(xcan) );
|
||||
return(xcan);
|
||||
}
|
||||
|
||||
#endif /* random_operations_h */
|
||||
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// read_system.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef read_system_h
|
||||
#define read_system_h
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
inline double getParameterValue(std::string lineFromFile) {
|
||||
std::stringstream ss;
|
||||
ss.str(lineFromFile);
|
||||
std::string nameDummy;
|
||||
double parValue = NAN;
|
||||
if ( !(ss>>nameDummy && ss>>parValue) ) {
|
||||
std::stringstream sserr;
|
||||
sserr<<"isParameterLine: Could not read line.\n";
|
||||
throw MyException(sserr.str());
|
||||
}
|
||||
return (parValue);
|
||||
}
|
||||
|
||||
inline bool isParameterLine(std::string lineFromFile, const std::string &parName) {
|
||||
std::stringstream ss;
|
||||
ss.str(lineFromFile);
|
||||
std::string parNameTemp;
|
||||
if ( !(ss>>parNameTemp) ) {
|
||||
std::stringstream sserr;
|
||||
sserr<<"isParameterLine: Could not read line.\n";
|
||||
throw MyException(sserr.str());
|
||||
}
|
||||
if (parNameTemp == parName) {
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isFaulty(std::string lineFromFile) {
|
||||
std::stringstream ss;
|
||||
ss.str(lineFromFile);
|
||||
std::string nameDummy;
|
||||
double valueDummy;
|
||||
if (ss>>nameDummy && ss>>valueDummy) {
|
||||
return (false);
|
||||
} else {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool checkIgnoreLine(const std::string &lineFromFile) { // true if line is empty or starts with #
|
||||
if (lineFromFile[0] =='#') {
|
||||
return true;
|
||||
} else if ( lineFromFile.empty() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void replaceDelimiter(std::string &lineFromFile) { // replaces delimiter (';'',''=') with whitespace
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), ';', ' ');
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), ',', ' ');
|
||||
replace(lineFromFile.begin(), lineFromFile.end(), '=', ' ');
|
||||
}
|
||||
|
||||
inline void removeLeadingWhites(std::string &lineFromFile) {
|
||||
static const std::string WHITESPACE = " \n\r\t\f\v";
|
||||
size_t start = lineFromFile.find_first_not_of(WHITESPACE);
|
||||
lineFromFile = (start == std::string::npos) ? "" : lineFromFile.substr(start);
|
||||
}
|
||||
|
||||
inline double findParameter(std::ifstream *fileStream, const std::string &parName) {
|
||||
std::string lineFromFile;
|
||||
double parValue = NAN;
|
||||
while (getline(*fileStream, lineFromFile)) {
|
||||
removeLeadingWhites(lineFromFile);
|
||||
replaceDelimiter(lineFromFile);
|
||||
if ( checkIgnoreLine(lineFromFile) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isFaulty(lineFromFile) ) {
|
||||
std::cout<<"Line in parameter file faulty.\n\tline:\t"<<lineFromFile<<"\n";
|
||||
} else if ( isParameterLine(lineFromFile, parName) ) {
|
||||
parValue = getParameterValue(lineFromFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (parValue);
|
||||
}
|
||||
|
||||
inline std::string makePath (const std::string &path) { // append '/' if necessary to path.
|
||||
if (path.back() != '/') {
|
||||
return (path + '/');
|
||||
} else {
|
||||
return (path);
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string getEnv (const std::string &envName) { // string version of C function getenv.
|
||||
char * val = getenv( envName.c_str() );
|
||||
return val == NULL ? std::string("") : std::string(val);
|
||||
}
|
||||
|
||||
inline std::string getParameterLoadFilePath() {
|
||||
std::string parpath = getEnv("parpath");
|
||||
if (parpath == "") {
|
||||
throw MyException("Parameter::getParameter: Environment variable parpath not defined.");
|
||||
}
|
||||
std::string parfile = getEnv("parfile");
|
||||
if (parfile == "") {
|
||||
throw MyException("Parameter::getParameter: Environment variable parfile not defined.");
|
||||
}
|
||||
|
||||
parpath = makePath(parpath);
|
||||
return (parpath + parfile);
|
||||
}
|
||||
|
||||
inline double getParameter(const std::string &parName) {
|
||||
std::string loadFilePath = getParameterLoadFilePath();
|
||||
|
||||
std::ifstream fileStream(loadFilePath);
|
||||
if (!fileStream.good()) {
|
||||
std::stringstream ss;
|
||||
ss<<"Parameter::getParameter: Could not open file.\n loadFilePath:\t"<<loadFilePath<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double parValue = findParameter(&fileStream, parName);
|
||||
|
||||
if ( isnan(parValue) ) {
|
||||
std::stringstream ss;
|
||||
ss<<"Parameter::getParameter: Parameter not found in file.\n parName:\t"<<parName<<"\n loadFilePath: \t"<<loadFilePath;
|
||||
throw MyException(ss.str());
|
||||
} else {
|
||||
return (parValue);
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string getTimeString() {
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
char buffer[80];
|
||||
time (&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
strftime(buffer,sizeof(buffer),"%Y%m%d",timeinfo);
|
||||
std::string str(buffer);
|
||||
return(str);
|
||||
}
|
||||
|
||||
inline std::string getHomebase() {
|
||||
std::string Homebase = getEnv("HOMEBASE");
|
||||
Homebase = makePath(Homebase);
|
||||
return (Homebase);
|
||||
}
|
||||
|
||||
inline std::string getDataPath() {
|
||||
return (getHomebase() + "src/mc_electron/data/");
|
||||
}
|
||||
#endif /* read_system_h */
|
||||
@@ -9,60 +9,47 @@
|
||||
|
||||
#include "simulation.hpp"
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "functions.hpp"
|
||||
|
||||
#include "fstream"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const long int Simulation::seed = getParameter("seed");
|
||||
const long int Simulation::numberTotalDecays = getParameter("numberTotalDecays");
|
||||
const int Simulation::propagationMethod = getParameter("propagationMethod");
|
||||
const int Simulation::maxInteractions = getParameter("maxInteractions");
|
||||
|
||||
Simulation::Simulation() {
|
||||
numberTotalElectrons = 0;
|
||||
numberDecays = 0;
|
||||
rngUni.seed(seed);
|
||||
updater_fraction = numberTotalDecays/100;
|
||||
updater_numberOfPrevious = 0;
|
||||
}
|
||||
|
||||
void Simulation::doit() {
|
||||
int numberInteractionsThisElectron = 0;
|
||||
while ( (numberDecays < numberTotalDecays) || (electronQue.size() > 0) ) {
|
||||
if (electronQue.empty()) {
|
||||
electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal));
|
||||
InteractionOut IntOut;
|
||||
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
||||
if (partQue.empty()) {
|
||||
curPart = Inj.injectElectron(numberTotalElectrons);
|
||||
numberDecays++;
|
||||
numberTotalElectrons++;
|
||||
do_statusUpdate();
|
||||
} else {
|
||||
curPart = partQue.front();
|
||||
partQue.pop_front();
|
||||
}
|
||||
actionElectronPtr = &electronQue.front();
|
||||
do_statusUpdate();
|
||||
move_electron(actionElectronPtr, &Log);
|
||||
if (!Kat.check_Termination (*actionElectronPtr) ) {
|
||||
do_interaction(actionElectronPtr);
|
||||
}
|
||||
if (Kat.check_Termination (*actionElectronPtr) || check_NumberInteractions(numberInteractionsThisElectron)) {
|
||||
electronQue.pop_front();
|
||||
numberInteractionsThisElectron = 0;
|
||||
while (!Term.check_Termination(curPart)) {
|
||||
mfp = 1/Inter.get_macroSigma_m2(curPart);
|
||||
Mov.moveParticle(&curPart, mfp);
|
||||
if (!Term.check_Termination(curPart)) {
|
||||
IntOut = Inter.do_Interaction(&curPart);
|
||||
//appy_Inter_Output(IntOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool Simulation::check_NumberInteractions(int &numberInteractionsThisElectron) {
|
||||
if (maxInteractions == 0) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (numberInteractionsThisElectron < maxInteractions) {
|
||||
numberInteractionsThisElectron++;
|
||||
return(false);
|
||||
} else {
|
||||
return(true);
|
||||
void Simulation::do_statusUpdate() {
|
||||
if (numberDecays%updater_fraction == 0){
|
||||
if (updater_numberOfPrevious!=numberDecays) {
|
||||
cout<<numberDecays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
updater_numberOfPrevious = numberDecays;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void Simulation::doTC6() {
|
||||
cout<<endl<<"Simulation::doTC6: Doing Testcase 6."<<endl<<endl;
|
||||
parameterCheck_TC6();
|
||||
@@ -79,28 +66,6 @@ void Simulation::doTC6() {
|
||||
}
|
||||
};
|
||||
|
||||
void Simulation::do_statusUpdate() {
|
||||
if (numberDecays%updater_fraction == 0){
|
||||
if (updater_numberOfPrevious!=numberDecays) {
|
||||
cout<<numberDecays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
updater_numberOfPrevious = numberDecays;
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::move_electron(Electron *moveElectron, H5_Logger *Log) {
|
||||
double MFP_m = Kat.get_MFP_m(&electronQue.front());
|
||||
if (propagationMethod==0) {
|
||||
Kat.do_DriftApproximationMovement(moveElectron, MFP_m, Log);
|
||||
} else if (propagationMethod==1) {
|
||||
Kat.do_BorisPushMovement(moveElectron, MFP_m, Log); // If moved outside set v = 0,0,0;
|
||||
} else {
|
||||
stringstream ss;
|
||||
ss<<"Simulation::move_electron: propagationMethod="<<propagationMethod<<" not valid.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::do_interaction(Electron *interactElectron) {
|
||||
vec3 newLoc_m = electronQue.front().get_Location_m();
|
||||
if (Kat.check_Termination(*interactElectron)) {
|
||||
@@ -108,13 +73,13 @@ void Simulation::do_interaction(Electron *interactElectron) {
|
||||
ss<<"Simulation::do_interaction: Particle already terminated.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
int process = interactElectron->roll_Interaction(Kat.getFlowSpeedT2_ms(newLoc_m),&rngUni);
|
||||
int process = interactElectron->roll_Interaction(Kat.get_T2_flowSpeed_ms(newLoc_m),&rngUni);
|
||||
switch (process) {
|
||||
case 1: // Elastic Scattering
|
||||
interactElectron->do_elaScattering(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni);
|
||||
interactElectron->do_elaScattering(Kat.roll_T2_speed_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni);
|
||||
break;
|
||||
case 2: // Ionization
|
||||
electronQue.push_back( interactElectron->do_Ionization(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal), numberTotalElectrons, &rngUni) );
|
||||
electronQue.push_back( interactElectron->do_Ionization(Kat.roll_T2_speed_ms(newLoc_m, &rngUni, &rngNormal), numberTotalElectrons, &rngUni) );
|
||||
numberTotalElectrons++;
|
||||
// Update Ions...
|
||||
break;
|
||||
@@ -141,3 +106,4 @@ void Simulation::parameterCheck_TC6() {
|
||||
throw MyException("Simulation::parameterCheck_TC6: Some Parameter is wrong");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -11,43 +11,61 @@
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
#include "electron.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "injector.hpp"
|
||||
#include "mover.hpp"
|
||||
#include "terminator.hpp"
|
||||
#include "interaction_processor.hpp"
|
||||
#include "interaction_builder.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
|
||||
class Simulation {
|
||||
public:
|
||||
Simulation();
|
||||
|
||||
Simulation() : Kat(&rngUni, &rngNormal),
|
||||
Inj(&Kat, &rngUni, &rngNormal),
|
||||
Log(&Kat),
|
||||
Mov(&Kat, &Log),
|
||||
Inter(&Kat, &rngUni, &rngNormal),
|
||||
Term(&Kat) {
|
||||
rngUni.seed(seed);
|
||||
rngNormal.seed(seed);
|
||||
updater_fraction = numberTotalDecays/100;
|
||||
updater_fraction = updater_fraction==0 ? 1 : updater_fraction;
|
||||
InteractionBuilder InterBuilder(&Kat, &rngUni, &rngNormal);
|
||||
Inter = InterBuilder.build_InteractionProcessor();
|
||||
}
|
||||
void doit();
|
||||
private:
|
||||
void do_statusUpdate();
|
||||
void move_electron(Electron *moveElectron, H5_Logger *Log);
|
||||
void do_interaction(Electron *interactElectron);
|
||||
bool check_NumberInteractions(int &numberInteractionsThisElectron);
|
||||
|
||||
Katrin Kat;
|
||||
Injector Inj;
|
||||
H5_Logger Log;
|
||||
Mover Mov;
|
||||
InteractionProcessor Inter;
|
||||
Terminator Term;
|
||||
|
||||
ranlib::Uniform<double> rngUni;
|
||||
ranlib::NormalUnit<double> rngNormal;
|
||||
|
||||
int numberTotalElectrons;
|
||||
int numberDecays;
|
||||
double mfp;
|
||||
std::deque<Particle> partQue;
|
||||
Particle curPart;
|
||||
//InterOutput IntOut;
|
||||
|
||||
std::deque<Electron> electronQue;
|
||||
Electron *actionElectronPtr;
|
||||
int numberTotalElectrons = 0;
|
||||
int numberDecays = 0;
|
||||
|
||||
//Updater
|
||||
int updater_numberOfPrevious;
|
||||
int numberTotalIons = 0;
|
||||
|
||||
int updater_numberOfPrevious = 0;
|
||||
int updater_fraction;
|
||||
|
||||
// Parameters
|
||||
static const long int seed;
|
||||
static const long int numberTotalDecays;
|
||||
|
||||
static const int propagationMethod;
|
||||
static const int maxInteractions;
|
||||
public:
|
||||
void doTC6();
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// terminator.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "terminator.hpp"
|
||||
|
||||
const double Terminator::cutoffEnergy_eV = getParameter("cutoffEnergy_eV");
|
||||
|
||||
bool Terminator::check_Termination(const Particle &checkPart) {
|
||||
double Ekin_eV = checkPart.get_EKin_eV();
|
||||
vec3 loc_m = checkPart.get_Location_m();
|
||||
bool E_check = check_EnergyTermination(Ekin_eV);
|
||||
bool loc_check = check_WallTermination(loc_m);
|
||||
return(E_check || loc_check);
|
||||
}
|
||||
|
||||
bool Terminator::check_EnergyTermination(const double &Ekin_eV) {
|
||||
if (Ekin_eV<=cutoffEnergy_eV) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
bool Terminator::check_WallTermination(const vec3 &loc_m) {
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <=Kat->get_z_RW_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (r_m >= Kat->get_radius_m()) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// terminator.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef terminator_hpp
|
||||
#define terminator_hpp
|
||||
|
||||
#include "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
// Terminate Electrons
|
||||
class Terminator {
|
||||
public:
|
||||
Terminator(Katrin *Kat) {
|
||||
this->Kat = Kat;
|
||||
}
|
||||
|
||||
bool check_Termination(const Particle &checkPart);
|
||||
private:
|
||||
bool check_EnergyTermination(const double &Ekin_eV);
|
||||
bool check_WallTermination(const vec3 &loc_m);
|
||||
|
||||
|
||||
static const double cutoffEnergy_eV;
|
||||
|
||||
Katrin *Kat;
|
||||
};
|
||||
|
||||
#endif /* terminator_hpp */
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// tritium_interactions.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "tritium_interactions.hpp"
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// tritium_interactions.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium_interactions_hpp
|
||||
#define tritium_interactions_hpp
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
|
||||
/*
|
||||
class TIon_InteractionProcessor : public Base_ParticleInteractionsProcessors {
|
||||
public:
|
||||
TIon_InteractionProcessor(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Base_ParticleInteractionsProcessors(Kat, rngUni, rngNormal) {};
|
||||
|
||||
InterOutput do_Interaction(Particle *interPart);
|
||||
private:
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
#endif /* tritium_interactions_hpp */
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// uehara_eT2_elastic.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
double Uehara_eT2_ElasticScattering::calc_TCS(const double &T_eV) {
|
||||
double beta = calc_beta_from_Ekin_eV(T_eV,me_eV);
|
||||
double eta = calc_eta(T_eV);
|
||||
double numerator = pi*ZT2*(ZT2+1)*re_m*re_m * (1-pow(beta,2));
|
||||
double denominator = eta * (eta+1)*pow(beta,4);
|
||||
return (numerator/denominator);
|
||||
}
|
||||
|
||||
double Uehara_eT2_ElasticScattering::calc_SDCS(const double &T_eV, const double &theta) {
|
||||
double beta = calc_beta_from_Ekin_eV(T_eV,me_eV);
|
||||
double eta = calc_eta(T_eV);
|
||||
double numerator = ZT2*(ZT2+1)*re_m*re_m * (1-pow(beta,2));
|
||||
double denominator = pow(beta,4)*pow(1-cos(theta)+2*eta, 2);
|
||||
return (numerator/denominator);
|
||||
}
|
||||
|
||||
double Uehara_eT2_ElasticScattering::roll_theta(const double &T_eV, UniRNG *rngUni) {
|
||||
double beta = calc_beta_from_Ekin_eV(T_eV,me_eV);
|
||||
double elaEta = calc_eta(T_eV);
|
||||
double const1 = 2*pi/calc_TCS(T_eV)*ZT2*(ZT2+1)*re_m*re_m*(1- pow(beta,2) )* pow(beta,-4);
|
||||
double fac = pow( rngUni->random()/const1-pow(2*elaEta,-1) , -1 ) +1+2*elaEta;
|
||||
double theta = acos(fac);
|
||||
return(theta);
|
||||
}
|
||||
|
||||
double Uehara_eT2_ElasticScattering::calc_eta(const double &T_eV) {
|
||||
double beta = calc_beta_from_Ekin_eV(T_eV, me_eV);
|
||||
double etac = (T_eV < 50e3)? 1.198 : 1.13+3.76*pow(ZT2/(137*beta),2);
|
||||
double elaTau = T_eV/me_eV;
|
||||
return (etac * 1.7e-5 * pow(ZT2,2./3.) /(elaTau*(elaTau+2) ));
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// uehara_eT2_elastic.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef uehara_eT2_elastic_hpp
|
||||
#define uehara_eT2_elastic_hpp
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
// Cross secton by Uehara 1993: Rutherford CS with screening parameter. Originally for water vapor.
|
||||
class Uehara_eT2_ElasticScattering {
|
||||
|
||||
public:
|
||||
Uehara_eT2_ElasticScattering(){};
|
||||
|
||||
static double calc_TCS(const double &T_eV);
|
||||
static double calc_SDCS(const double &T_eV, const double &theta);
|
||||
|
||||
static double roll_theta(const double &T_eV, UniRNG *rngUni);
|
||||
private:
|
||||
static double calc_eta(const double &T_eV);
|
||||
};
|
||||
|
||||
#endif /* uehara_eT2_elastic_hpp */
|
||||
@@ -8,38 +8,16 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
//#include <mpi.h>
|
||||
#include "hdf5.h"
|
||||
|
||||
#include <map>
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
const std::string filePath = "/Users/ChristianReiling/Desktop/hdf5_example/examplefile.h5";
|
||||
|
||||
hid_t file_id, dataset_id, dataspace_id; /* identifiers */
|
||||
hsize_t dims[2];
|
||||
herr_t status;
|
||||
|
||||
/* Create a new file using default properties. */
|
||||
file_id = H5Fcreate(filePath.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
/* Create the data space for the dataset. */
|
||||
dims[0] = 4;
|
||||
dims[1] = 6;
|
||||
dataspace_id = H5Screate_simple(2, dims, NULL);
|
||||
|
||||
/* Create the dataset. */
|
||||
dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
|
||||
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
/* End access to the dataset and release resources used by it. */
|
||||
status = H5Dclose(dataset_id);
|
||||
|
||||
/* Terminate access to the data space. */
|
||||
status = H5Sclose(dataspace_id);
|
||||
|
||||
/* Close the file. */
|
||||
status = H5Fclose(file_id);
|
||||
|
||||
int *test;
|
||||
test = new int[3];
|
||||
test[2] = 3;
|
||||
cout<<test[7];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user