Reworked Container structure and wrote template for n-dim Containers.

This commit is contained in:
Christian
2019-04-09 10:32:12 +02:00
parent e5d66411bb
commit b5a73da3b8
22 changed files with 43402 additions and 311 deletions
+67 -72
View File
@@ -16,78 +16,73 @@
#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} ;
double BED_Ionization::get_TCS(double T_eV) {
if (T_eV<=0) {
stringstream ss;
ss<<"get_TCS(double T_eV): Input energy T_eV="<<T_eV<<" eV < 0.";
throw MyException(ss.str());
namespace BED_Ionization {
double get_TCS(double T_eV) {
if (T_eV<=0) {
stringstream ss;
ss<<"get_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 fac = S_m2/(t+u+1);
double sum1 = get_Dt(t)*log(t);
double sum2 = (2-Ni/N)*( (t-1)/t - log(t)/(t+1) );
return(fac*(sum1 + sum2) );
}
}
if (T_eV<=B_eV) {
return (0);
} else {
double t = get_t(T_eV);
double fac = S_m2/(t+u+1);
double sum1 = get_Dt(t)*log(t);
double sum2 = (2-Ni/N)*( (t-1)/t - log(t)/(t+1) );
return(fac*(sum1 + sum2) );
double get_SDCS (double T_eV, 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.";
throw MyException(ss.str());
} else if (W_eV<0) {
stringstream ss;
ss<<"getSDCS(double T_eV, double W_eV): Input energy W_eV="<<W_eV<<" eV < 0.";
throw MyException(ss.str());
}
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 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);
return(fac*(sum1 + sum2 + sum3));
}
}
inline double get_t(double T_eV) {
return(T_eV/B_eV);
}
inline double get_w(double W_eV) {
return(W_eV/B_eV);
}
inline double get_dfdw(double w) {
double y = 1/(w+1);
double res = 0;
for (int i=0;i<4;i++) {
res += c[i]*pow(y,i+3);
}
return(res);
}
inline double get_Dt(double t) {
double yh = 2/(t+1);
double res = 0;
for (int i=0;i<4;i++) {
res += c[i]/(i+3)*(1-pow(yh,i+3));
}
res = res/N;
return(res);
}
}
double BED_Ionization::get_SDCS (double T_eV, 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.";
throw MyException(ss.str());
} else if (W_eV<0) {
stringstream ss;
ss<<"getSDCS(double T_eV, double W_eV): Input energy W_eV="<<W_eV<<" eV < 0.";
throw MyException(ss.str());
}
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 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);
return(fac*(sum1 + sum2 + sum3));
}
}
double BED_Ionization::get_t(double T_eV) {
return(T_eV/B_eV);
}
double BED_Ionization::get_w(double W_eV) {
return(W_eV/B_eV);
}
double BED_Ionization::get_dfdw(double w) {
double y = 1/(w+1);
double res = 0;
for (int i=0;i<4;i++) {
res += c[i]*pow(y,i+3);
}
return(res);
}
double BED_Ionization::get_Dt(double t) {
double yh = 2/(t+1);
double res = 0;
for (int i=0;i<4;i++) {
res += c[i]/(i+3)*(1-pow(yh,i+3));
}
res = res/N;
return(res);
}
+11 -14
View File
@@ -9,29 +9,26 @@
#ifndef bedionization_hpp
#define bedionization_hpp
#include "constants.hpp"
// BED Ionization model from Kim, Y.-K. and Rudd, M. E. 1994
class BED_Ionization {
public:
BED_Ionization(){};
namespace BED_Ionization {
const double S_m2 = 5.4721e-20;
const double B_eV = EionT2_eV;
const double u = 1.664;
const double N = 2;
const double Ni = 1.173;
const double c[4] = {1.1262 , 6.3982 , -7.8055, 2.1449} ;
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 */
+208
View File
@@ -0,0 +1,208 @@
//
// 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 "functions.hpp"
#include "constants.hpp"
#include <string>
#include <map>
#include <fstream>
#include <sstream>
#include <deque>
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 interpolat_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 interpolat_Value(const T &Map, deque<double> Cord) {
double x = *Cord.begin();
Cord.pop_front();
if (x < Map.begin()->first) {
return ( interpolat_Value(Map.begin()->second, Cord) );
} else if (x > Map.rbegin()->first){
return ( interpolat_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 = interpolat_Value(lowAnker_Itr->second, Cord);
double upAnker_x = upAnker_Itr->first;
double upAnker_fxy = interpolat_Value(upAnker_Itr->second, Cord);
double res = lowAnker_fxy + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fxy-lowAnker_fxy);
return (res);
}
} // namespace
#endif /* container_base_functions_h */
File diff suppressed because it is too large Load Diff
+316
View File
@@ -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
+316
View File
@@ -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
+23
View File
@@ -0,0 +1,23 @@
//
// density_container.cpp
// mc_electron
//
// Created by Christian Reiling on 06.04.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "density_container.hpp"
//void fillFromFunction(double (*f)(double), double minX, double maxX, int numpointsPerOrder);
void Skalar_DenContainer::fillFromCSV(std::string loadFilePath) {
}
void Skalar_DenContainer::add_ankerpoint(double x, double y, double z, double fxyz) {
}
void Skalar_DenContainer::exportToFile(std::string exportFilePath) {
}
+48
View File
@@ -0,0 +1,48 @@
//
// 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 <stdio.h>
#include <map>
#include <string>
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> skalar3Map;
typedef std::pair<double,dim2Map> skalar3Pair;
class Skalar_DenContainer {
public:
Skalar_DenContainer() {};
Skalar_DenContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
void fillFromCSV(std::string loadFilePath);
void add_ankerpoint(double x, double y, double z, double fxyz);
void exportToFile(std::string exportFilePath);
skalar3Map get_Map() {return (Map);}
protected:
double lower_z;
double lower_r;
double lower_phi;
skalar3Map Map;
};
#endif /* density_container_hpp */
+19 -6
View File
@@ -7,12 +7,20 @@
//
#include "electron.hpp"
#include <sstream>
using namespace std;
const int Electron::ionOn = getParameter("ionOn");
const int Electron::elaOn = getParameter("elaOn");
Average1D_FuncContainer Electron::BED_TCS_average_container=Average1D_FuncContainer(getHomebase() + "data/BED_average_TCS.dat");
Stacked2D_FuncContainer Electron::BED_SDCS_stacked_container=Stacked2D_FuncContainer(getHomebase() + "data/BED_stacked_SDCS.dat");
double Electron::get_SigmaTotal_m2(vec3 speedT2_ms) {
vector<double> Sigmas = get_SigmaVector_m2(speedT2_ms);
double sigmaTot_m2 = 0;
@@ -120,7 +128,9 @@ 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));
//return (ionTCS_container.interpolate(T_eV));
//return (BED_Ionization::get_TCS(T_eV));
return (BED_TCS_average_container.get_Value(T_eV));
}
Electron Electron::do_Ionization(vec3 speedT2_ms, int newId, ranlib::Uniform<double> *rngUni) {
@@ -138,7 +148,8 @@ Electron Electron::do_Ionization(vec3 speedT2_ms, int newId, ranlib::Uniform<dou
throw MyException("Electron::do_Ionization: Ekin_eV < EIonT2_eV.");
}
double W_eV = roll_ionW_eV(T_eV, rngUni);
//double W_eV = roll_ionW_eV(T_eV, rngUni);
double W_eV = BED_SDCS_stacked_container.sample_Value(T_eV, rngUni);
double E1_eV = T_eV-EionT2_eV - W_eV;
double phi1 = rngUni->random()*2*pi;
@@ -167,7 +178,8 @@ Electron Electron::do_Ionization(vec3 speedT2_ms, int newId, ranlib::Uniform<dou
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 = ionTCS_container.interpolate(T_eV);
pmax = BED_Ionization::get_TCS(T_eV);
Wmin_eV = 0;
Wmax_eV = T_eV-EionT2_eV;
@@ -176,6 +188,7 @@ double Electron::roll_ionW_eV(double T_eV, ranlib::Uniform<double> *rngUni) {
eta2 = rngUni->random();
Wcan_eV = Wmin_eV + eta1*(Wmax_eV - Wmin_eV);
} while(eta2*pmax > BED_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);
}
@@ -211,6 +224,6 @@ double Electron::roll_IonTheta2(double T_eV, double W_eV, ranlib::Uniform<double
return(theta2);
}
/*
Func_Container Electron::elaTCS_container = Func_Container("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/yoon_TCS_elastic.dat");
*/
//Edge1D_Container Electron::ionTCS_container= Edge1D_Container("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_ionization_TCS.dat");
//Edge2D_Container Electron::ionSDCS_container= Edge2D_Container("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_ionization_SDCS.dat");
+5 -2
View File
@@ -14,7 +14,7 @@
#include "function_container.hpp"
class Electron : public Particle, private BED_Ionization {
class Electron : public Particle {
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) {};
@@ -49,7 +49,10 @@ protected:
// Testing Container
//static Func_Container elaTCS_container;
//static Edge1D_Container ionTCS_container;
//static Edge2D_Container ionSDCS_container;
static Average1D_FuncContainer BED_TCS_average_container;
static Stacked2D_FuncContainer BED_SDCS_stacked_container;
};
+154 -166
View File
@@ -8,194 +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 (dim1Map *stackedMap, ranlib::Uniform<double> *rngUni) {
return (stackedMap->lower_bound(rngUni->random())->second);
}
// Base1D_Container
// AddData
void Base1D_FuncContainer::fillFromFunction(double (*f)(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. \n loadFilePath= "<<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)(double,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)(double,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 ));
}
}
void Func_Container::exportToFile(std::string exportFilePath) {
ofstream outFile;
outFile.open(exportFilePath);
if (!outFile.good()) {
stringstream ss;
ss<<"Func_Container::exportToFile: Could not open file. \n exportFilePath= "<<exportFilePath<<endl;
throw MyException(ss.str());
}
outFile<<"# Automatically generated Data of Function_Container class by exportToFile().\n";
outFile<<"# Generated on "<<getTimeString()<<".\n";
outFile<<"#key (usually Energy)\tparameter (usually TCS)\n";
dim1Map::iterator AnkerItr;
for (AnkerItr = Map.begin();AnkerItr!=Map.end();AnkerItr++) {
outFile<<AnkerItr->first<<"\t"<<AnkerItr->second<<"\n";
}
outFile.close();
void Stacked2D_FuncContainer::set_Map(Average2D_FuncContainer &averageContainer) {
dim2Map averageMap = averageContainer.get_Map();
set_Map(averageMap);
}
// Func2D_Container
Func2D_Container::Func2D_Container(std::string loadFilePath) {
readFromCSV(loadFilePath);
}
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) {
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();
}
+112 -23
View File
@@ -9,42 +9,131 @@
#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);
void averageMap_from_edgeMap (dim1Map *averageMap, dim1Map &edgeMap);
void stackedMap_from_averageMap (dim1Map *stackedMap, dim1Map &averageMap, double lowerEdge = 0);
double sampleValue_from_stackedMap (dim1Map *stackedMap, ranlib::Uniform<double> *rngUni);
};
// 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);
void exportToFile(std::string exportFilePath);
private:
Base1D_FuncContainer() {};
Base1D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
void fillFromFunction(double (*f)(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) {container_base::export_To_Csv(Map, exportFilePath);};
dim1Map get_Map() {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) {return (container_base::interpolat_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){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() {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) {return (container_base::interpolat_Value(Map,deque<double>{x,y}));};
void get_Ionization_fromFunction(double (*f)(double,double), double minX, double maxX, int numpointsPerXOrder, int numpointsPerYOrder);
void get_Elastic_fromFunction(double (*f)(double,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){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);
};
#endif /* function_container_hpp */
+11 -3
View File
@@ -27,7 +27,7 @@ double getParameter(string parName) {
if (parfile == "") {
throw MyException("Parameter::getParameter: Environment variable parfile not defined.");
}
makePath(parpath);
parpath = makePath(parpath);
string loadFilePath = parpath + parfile;
ifstream fileStream(loadFilePath);
@@ -67,6 +67,7 @@ double getParameter(string parName) {
}
ss.clear();
ss.str("");
ss<<"Parameter::getParameter: Parameter not found in file.\n parName =\t"<<parName<<"\n loadFilePath = \t"<<loadFilePath;
throw MyException(ss.str());
}
@@ -78,11 +79,11 @@ std::string getEnv (std::string envName) {
return val == NULL ? std::string("") : std::string(val);
}
void makePath (std::string &path) {
string makePath (std::string path) {
if (path.back() != '/') {
path = path + '/';
}
return;
return (path);
}
bool checkIgnoreLine(std::string lineFromFile) {
@@ -121,6 +122,13 @@ string getTimeString() {
return(str);
}
string getHomebase() {
std::string file = __FILE__;
file.erase(file.length()-13);
return(file);
}
// Calculate Kinematic Relations
double get_Ekin_eV_from_speed(double Speed_ms, double mass_eV) {
double beta = Speed_ms/c_ms;
+2 -1
View File
@@ -35,13 +35,14 @@ 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.
std::string 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
// System Read out
std::string getTimeString();
std::string getHomebase();
// Calculate Kinematic Relations
double get_Speed_from_Ekin_eV(double Ekin_eV, double mass_eV);
+85 -1
View File
@@ -12,8 +12,82 @@
using namespace std;
int main(int argc, const char * argv[]) {
void createBED_TCS_Func_container() {
Edge1D_FuncContainer BED_edge_TCS;
BED_edge_TCS.fillFromFunction(BED_Ionization::get_TCS, 15, 20000, 100);
BED_edge_TCS.add_ankerpoint(EionT2_eV, BED_Ionization::get_TCS(EionT2_eV));
BED_edge_TCS.add_ankerpoint(EionT2_eV+1e-4, BED_Ionization::get_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_Ionization::get_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_Ionization::get_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");
}
void testSpeed() {
double dummy;
Edge1D_FuncContainer TCS = Edge1D_FuncContainer("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_TCS.dat");
Edge2D_FuncContainer SDCS = Edge2D_FuncContainer("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_SDCS.dat");
clock_t start = clock();
int imax = 1000;
double T_eV = 20;
double W_eV = 1;
cout<<"TCS function call:\n";
for (int i = 0;i<imax;i++) {
dummy = BED_Ionization::get_TCS(T_eV);
}
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
start = clock();
cout<<"TCS container call:\n";
for (int i = 0;i<imax;i++) {
dummy = TCS.interpolate(T_eV);
}
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
start = clock();
cout<<"SDCS function call:\n";
for (int i = 0;i<imax;i++) {
dummy = BED_Ionization::get_SDCS(T_eV,W_eV);
}
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
start = clock();
cout<<"SDCS container call:\n";
for (int i = 0;i<imax;i++) {
dummy = SDCS.interpolate(T_eV,W_eV);
}
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
}
int main(int argc, const char * argv[]) {
/*
try {
Simulation Sim;
@@ -23,7 +97,17 @@ int main(int argc, const char * argv[]) {
exit(1);
}
*/
//testSpeed();
clock_t start = clock();
Simulation Sim;
Sim.doit();
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
//createBED_TCS_Func_container();
//createBED_SDCS_Func2D_container();
}