Finished DCS_Ionization Container.

Removed Energy Cut off for T2+ Ions.
Tested Population loggers.
This commit is contained in:
Christian
2019-06-06 16:33:42 +02:00
parent 142197d10a
commit bd64d5390f
37 changed files with 11430 additions and 388 deletions
+1
View File
@@ -13,6 +13,7 @@ typedef const double constant;
constant zero = 1e-15;
constant infinity = 1e15;
// Natural Constants
constant pi = 3.1415;
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
-82
View File
@@ -1,82 +0,0 @@
//
// dcs_container.cpp
// mc_electron
//
// Created by Christian Reiling on 22.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "dcs_container.hpp"
void DCS_Theta_Container::calc_data(std::string load_path) {
Edge_Container<dim2Map> E2D(load_path);
int number_theta_bins = theta_scale.get_dimension();
double *temp;
double sum;
for (int E_bin = 0; E_bin<=E_scale.get_max_index(); E_bin++) {
temp = new double[number_theta_bins];
sum = 0;
for (int theta_bin = 0; theta_bin < number_theta_bins; theta_bin++) {
sum += calc_bin_value(E_bin, theta_bin, &E2D);
temp[theta_bin] = sum;
}
for (int theta_bin = 0; theta_bin < number_theta_bins; theta_bin++) {
temp[theta_bin] /= sum;
}
data[E_bin] = temp;
}
}
double DCS_Theta_Container::calc_E_eV(const int &E_bin) {
double E_eV;
if (E_bin == 0) {
E_eV = E_scale.calc_upper_bound(0);
} else {
E_eV = E_scale.calc_upper_bound(E_bin-1);
E_eV +=(E_scale.calc_upper_bound(E_bin) - E_scale.calc_upper_bound(E_bin-1))/2;
}
return (E_eV);
}
double DCS_Theta_Container::calc_bin_value(const int &E_bin, const int &theta_bin, Edge_Container<dim2Map> *E2D) {
double E_eV = calc_E_eV(E_bin);
double theta = theta_scale.calc_upper_bound(theta_bin);
double val = E2D->interpolate(ddeque{E_eV, theta});
if (theta_bin == 0 || theta_bin == theta_scale.get_max_index()) {
val *= 0.5;
}
return (val);
}
double DCS_Theta_Container::roll_value(double E_eV, UniRNG *rngUni) {
int E_index = E_scale.calc_index(E_eV);
double target = rngUni->random();
for (int i=0; i<=theta_scale.get_max_index(); i++) {
if (target < data[E_index][i]) {
return (theta_scale.calc_upper_bound(i)); //upper bound represents corresponding value.
//return (roll_in_bin(i, rngUni)); // rolling in bin.
}
}
std::stringstream ss;
ss<<"DCS_Theta_Container::get_value: Overflow./n";
throw MyException (ss.str());
}
double DCS_Theta_Container::roll_in_bin(const int &theta_bin, UniRNG *rngUni) {
int lower_bin = theta_bin-1;
int upper_bin = theta_bin+1;
int max_bin = theta_scale.get_max_index();
lower_bin = (lower_bin<0) ? 0 : lower_bin;
upper_bin = (upper_bin>max_bin) ? max_bin : upper_bin;
double lower_value = theta_scale.calc_upper_bound(lower_bin);
double this_value = theta_scale.calc_upper_bound(theta_bin);
double upper_value = theta_scale.calc_upper_bound(upper_bin);
double lower_theta = lower_value + 0.5*(this_value - lower_value);
double upper_theta = this_value + 0.5*(upper_value - this_value);
double sample_value = lower_theta + rngUni->random() * (upper_theta-lower_theta);
return (sample_value);
}
-55
View File
@@ -1,55 +0,0 @@
//
// dcs_container.hpp
// mc_electron
//
// Created by Christian Reiling on 22.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef dcs_container_hpp
#define dcs_container_hpp
#include "logScale.h"
#include <string>
#include "edge_container.h"
#include "random_operations.h"
class DCS_Theta_Container {
double **data;
Log_Scale E_scale;
Lin_Scale theta_scale;
public:
~DCS_Theta_Container() {
for (int i=0; i <= E_scale.get_max_index(); i++) {
delete[] data[i];
}
};
DCS_Theta_Container(double E_min_eV, double E_max_eV, int number_E_bins, int number_theta_bins, std::string load_path) {
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
theta_scale = Lin_Scale(0,pi/2,number_theta_bins);
int E_dimension = E_scale.get_dimension();
int theta_dimension = theta_scale.get_dimension();
data = new double *[E_dimension];
for (int i = 0; i<E_dimension; i++) {
data[i] = new double [theta_dimension];
}
calc_data(load_path); //calc, whereas, load_path contains point with exact values for cross section.
}
private:
void calc_data(std::string load_path);
double calc_E_eV(const int &E_bin);
double calc_bin_value(const int &E_bin, const int &theta_bin, Edge_Container<dim2Map> *E2D);
public:
double roll_value(double E_eV, UniRNG *rngUni);
private:
double roll_in_bin(const int &theta_bin, UniRNG *rngUni);
};
#endif /* dcs_container_hpp */
+13
View File
@@ -0,0 +1,13 @@
//
// dcs_container_base.h
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef dcs_container_base_h
#define dcs_container_base_h
#endif /* dcs_container_base_h */
@@ -0,0 +1,117 @@
//
// dcs_ionization_container.cpp
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "dcs_ionization_container.hpp"
#include <algorithm>
#include "edge_container.h"
DCS_Ionization_Container::DCS_Ionization_Container(double T_min_eV, double T_max_eV, int number_T_bins, int number_W_bins, std::string load_path) {
T_scale = Log_Scale(T_min_eV, T_max_eV, number_T_bins);
W_scale = new Log_Scale[number_T_bins];
double Tmax_eV;
for (int i = 0; i < number_T_bins; i++) {
Tmax_eV = (T_scale.get_bin_mid(i) - EionT2_eV)/2;
W_scale[i] = Log_Scale(zero, Tmax_eV, number_W_bins);
}
init_data();
calc_data(load_path);
}
DCS_Ionization_Container::~DCS_Ionization_Container() {
for (int i=0; i < T_scale.get_number_bins(); i++) {
delete[] data[i];
}
delete[] data;
delete W_scale;
};
DCS_Ionization_Container::DCS_Ionization_Container(const DCS_Ionization_Container& other) {
T_scale = other.T_scale;
int num_T_bins = T_scale.get_number_bins();
W_scale = new Log_Scale[num_T_bins];
for (int i = 0; i < num_T_bins; i++) {
W_scale[i] = other.W_scale[i];
}
int num_W_bins = W_scale[0].get_number_bins();
init_data();
for (int i = 0; i<num_T_bins; i++) {
for (int j = 0; j<num_W_bins; j++) {
data[i][j] = other.data[i][j];
}
}
}
DCS_Ionization_Container& DCS_Ionization_Container::operator=(const DCS_Ionization_Container& other) {
DCS_Ionization_Container tmp(other);
std::swap(T_scale, tmp.T_scale);
std::swap(W_scale, tmp.W_scale);
std::swap(data, tmp.data);
return (*this);
}
void DCS_Ionization_Container::init_data() {
int num_T_bins = T_scale.get_number_bins();
int num_W_bins = W_scale[0].get_number_bins();
data = new double *[num_T_bins];
for (int i = 0; i<num_T_bins; i++) {
data[i] = new double [num_W_bins];
}
}
void DCS_Ionization_Container::calc_data(std::string load_path) {
Edge_Container<dim2Map> E2D(load_path);
int num_T_bins = T_scale.get_number_bins();
int num_W_bins = W_scale[0].get_number_bins();
double *temp;
double sum;
double E_eV;
for (int i = 0; i<num_T_bins; i++) {
E_eV = T_scale.get_bin_mid(i);
temp = new double[num_W_bins];
sum = 0;
for (int j = 0; j<num_W_bins; j++) {
sum += calc_bin_surface(i, j, &E2D);
temp[j] = sum;
}
for (int j = 0; j < num_W_bins; j++) {
temp[j] /= sum;
}
data[i] = temp;
}
}
double DCS_Ionization_Container::calc_bin_surface(int T_bin, int W_bin, Edge_Container<dim2Map> *E2D) {
double T_eV = T_scale.get_bin_mid(T_bin);
double W_eV = W_scale[T_bin].get_bin_mid(W_bin);
double width = T_scale.get_upper_bin_bound(T_bin) - T_scale.get_lower_bin_bound(T_bin);
double height = E2D->interpolate(ddeque{T_eV, W_eV});
return (width*height);
}
double DCS_Ionization_Container::roll_value(const double &T_eV, UniRNG *rngUni) {
int T_bin = T_scale.calc_index(T_eV);
double target = rngUni->random();
for (int j=0; j<W_scale[T_bin].get_number_bins(); j++) {
if (target < data[T_bin][j]) {
return (roll_in_bin(T_bin, j, rngUni));
}
}
std::stringstream ss;
ss<<"DCS_Ionization_Container::roll_value: Overflow./n";
throw MyException (ss.str());
}
double DCS_Ionization_Container::roll_in_bin(const int &T_bin, const int &W_bin, UniRNG *rngUni) {
double lower_value = W_scale[T_bin].get_lower_bin_bound(W_bin);
double upper_value = W_scale[T_bin].get_upper_bin_bound(W_bin);
double distance = upper_value - lower_value;
double res = lower_value + rngUni->random() * distance;
return res;
}
@@ -0,0 +1,41 @@
//
// dcs_ionization_container.hpp
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef dcs_ionization_container_hpp
#define dcs_ionization_container_hpp
#include "log_scale.h"
#include <string>
#include "edge_container.h"
#include "random_operations.h"
class DCS_Ionization_Container {
double **data;
Log_Scale T_scale;
Log_Scale *W_scale;
public:
DCS_Ionization_Container(double T_min_eV, double T_max_eV, int number_T_bins, int number_W_bins, std::string load_path);
~DCS_Ionization_Container();
DCS_Ionization_Container(const DCS_Ionization_Container& other);
DCS_Ionization_Container& operator=(const DCS_Ionization_Container& other);
private:
void init_data();
void calc_data(std::string load_path);
double calc_bin_surface(int T_bin, int W_bin, Edge_Container<dim2Map> *E2D);
public:
double roll_value(const double &T_eV, UniRNG *rngUni);
private:
double roll_in_bin(const int &T_bin, const int &W_bin, UniRNG *rngUni);
};
#endif /* dcs_ionization_container_hpp */
+110
View File
@@ -0,0 +1,110 @@
//
// dcs_theta_container.cpp
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "dcs_theta_container.hpp"
#include <algorithm>
#include "edge_container.h"
DCS_Theta_Container::DCS_Theta_Container(double E_min_eV, double E_max_eV, int number_E_bins, int number_theta_bins, std::string load_path) {
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
theta_scale = Lin_Scale (0, pi, number_theta_bins);
init_data();
calc_data(load_path);
}
DCS_Theta_Container::~DCS_Theta_Container() {
for (int i=0; i < E_scale.get_number_bins(); i++) {
delete[] data[i];
}
delete[] data;
};
DCS_Theta_Container::DCS_Theta_Container(const DCS_Theta_Container& other) {
E_scale = other.E_scale;
theta_scale = other.theta_scale;
init_data();
for (int i = 0; i<E_scale.get_number_bins(); i++) {
for (int j = 0; j<theta_scale.get_number_bins(); j++) {
data[i][j] = other.data[i][j];
}
}
}
DCS_Theta_Container& DCS_Theta_Container::operator=(const DCS_Theta_Container& other) {
DCS_Theta_Container tmp(other);
std::swap(E_scale, tmp.E_scale);
std::swap(theta_scale, tmp.theta_scale);
std::swap(data, tmp.data);
return (*this);
}
void DCS_Theta_Container::init_data() {
int number_E_bins = E_scale.get_number_bins();
int number_theta_bins = theta_scale.get_number_bins();
data = new double *[number_E_bins];
for (int i = 0; i<number_E_bins; i++) {
data[i] = new double [number_theta_bins];
}
}
void DCS_Theta_Container::calc_data(std::string load_path) {
Edge_Container<dim2Map> E2D(load_path);
int number_E_bins = E_scale.get_number_bins();
int number_theta_bins = theta_scale.get_number_bins();
double *temp;
double sum;
double E_eV;
for (int i = 0; i<number_E_bins; i++) {
E_eV = E_scale.get_bin_mid(i);
temp = new double[number_theta_bins];
sum = 0;
for (int j = 0; j<number_theta_bins; j++) {
sum += calc_bin_surface(i, j, &E2D);
temp[j] = sum;
}
for (int j = 0; j < number_theta_bins; j++) {
temp[j] /= sum;
}
data[i] = temp;
}
}
double DCS_Theta_Container::calc_bin_surface(int E_bin, int theta_bin, Edge_Container<dim2Map> *E2D) {
double E_eV = E_scale.get_bin_mid(E_bin);
double theta = theta_scale.get_bin_mid(theta_bin);
double width = E_scale.get_upper_bin_bound(E_bin) - E_scale.get_lower_bin_bound(E_bin);
double height = E2D->interpolate(ddeque{E_eV, theta});
return (width*height);
}
double DCS_Theta_Container::roll_value(const double &E_eV, UniRNG *rngUni) {
int E_bin = E_scale.calc_index(E_eV);
double target = rngUni->random();
for (int j=0; j<theta_scale.get_number_bins(); j++) {
if (target < data[E_bin][j]) {
return (roll_in_bin(j, rngUni));
}
}
std::stringstream ss;
ss<<"DCS_Theta_Container::roll_value: Overflow./n";
throw MyException (ss.str());
}
double DCS_Theta_Container::roll_in_bin(const int &theta_bin, UniRNG *rngUni) {
double lower_value = theta_scale.get_lower_bin_bound(theta_bin);
double upper_value = theta_scale.get_upper_bin_bound(theta_bin);
double distance = upper_value - lower_value;
double res = lower_value + rngUni->random() * distance;
return res;
}
+42
View File
@@ -0,0 +1,42 @@
//
// dcs_theta_container.hpp
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef dcs_theta_container_hpp
#define dcs_theta_container_hpp
#include "edge_container.h"
#include "log_scale.h"
#include "random_operations.h"
class DCS_Theta_Container {
double **data;
Log_Scale E_scale;
Lin_Scale theta_scale;
public:
DCS_Theta_Container(double E_min_eV, double E_max_eV, int number_E_bins, int number_theta_bins, std::string load_path);
~DCS_Theta_Container();
DCS_Theta_Container(const DCS_Theta_Container& other);
DCS_Theta_Container& operator=(const DCS_Theta_Container& other);
private:
void init_data();
void calc_data(std::string load_path);
double calc_bin_surface(int E_bin, int theta_bin, Edge_Container<dim2Map> *E2D);
public:
double roll_value(const double &E_eV, UniRNG *rngUni);
private:
double roll_in_bin(const int &theta_bin, UniRNG *rngUni);
};
#endif /* dcs_theta_container_hpp */
+3 -4
View File
@@ -12,7 +12,7 @@
#include "sub_interaction_base.h"
#include "uehara_eT2_elastic.hpp"
#include "tcs_container.hpp"
#include "dcs_container.hpp"
#include "dcs_theta_container.hpp"
#include "kinematics_base.h"
@@ -21,11 +21,10 @@ class eT2_Elastic : public Sub_Interaction_Base {
DCS_Theta_Container dcs_data;
Elastic_Kinematic_Base kinematics;
public:
eT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni),
tcs_data(1e-5, 2e4, 1e3, getDataPath() + "eT2_TCS_ela_concat.dat"),
dcs_data(1e-5, 2e4, 1e3, 200, getDataPath() + "eT2_DCS_ela_concat.dat"),
tcs_data(zero, 2e4, 1e3, getDataPath() + "eT2_ela_TCS.dat"),
dcs_data(zero, 2e4, 1e3, 200, getDataPath() + "eT2_ela_DCS.dat"),
kinematics(me_eV, mT2_eV) {}
double get_macroSigma_m2(const Particle &interPart);
+75 -160
View File
@@ -10,71 +10,71 @@
#define eT2_ionization_h
#include "sub_interaction_base.h"
#include "average_container.h"
#include "stacked_container.h"
#include "tcs_container.hpp"
#include "dcs_ionization_container.hpp"
#include "BED_eT2_ionization.hpp"
/*
Ionization:
Using BED-Model Kim and Rudd 1994
*/
class eT2_T2I_Ionization_Analytic : public Sub_Interaction_Base {
class eT2_T2I_Ionization_Base : public Sub_Interaction_Base {
public:
eT2_T2I_Ionization_Analytic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
eT2_T2I_Ionization_Base(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni){};
double get_macroSigma_m2(const Particle &interPart);
protected:
virtual double calc_microSigma(const double &T_eV) = 0;
public:
InteractionOut do_Interaction (Particle *interPart);
private:
protected:
vec3 roll_vLab_ms(const Particle &interPart);
double roll_ionW_eV(double T_eV);
double roll_IonTheta1(double T_eV, double W_eV);
double roll_IonTheta2(double T_eV, double W_eV);
virtual double roll_ionW_eV(const double &T_eV) = 0;
double roll_theta1(double T_eV, double W_eV);
double roll_theta2(double T_eV, double W_eV);
};
inline double eT2_T2I_Ionization_Analytic::get_macroSigma_m2(const Particle &interPart) {
inline double eT2_T2I_Ionization_Base::get_macroSigma_m2(const Particle &interPart) {
double T_eV = interPart.get_EKin_eV();
vec3 loc_m = interPart.get_Location_m();
double microSigma_m2 = BED_eT2_Ionization::calc_TCS(T_eV);
double microSigma_m2 = calc_microSigma(T_eV);
double nT2_m3 = Population->get_density_m3(loc_m);
return (microSigma_m2*nT2_m3);
}
inline InteractionOut eT2_T2I_Ionization_Analytic::do_Interaction (Particle *interPart) {
inline InteractionOut eT2_T2I_Ionization_Base::do_Interaction (Particle *interPart) {
vec3 vLab_ms = roll_vLab_ms(*interPart);
vec3 v_ms = interPart->get_Speed_ms();
vec3 vOff_ms = vLab_ms - interPart->get_Speed_ms();
double T_eV = calc_Ekin_eV_from_speed(v_ms, me_eV);
double T_eV = calc_Ekin_eV_from_speed(vLab_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_theta1(T_eV, W_eV);
double theta2 = roll_theta2(T_eV, W_eV);
double theta1 = roll_IonTheta1(T_eV, W_eV);
double theta2 = roll_IonTheta2(T_eV, W_eV);
double v1_lab_new_ms = calc_Speed_from_Ekin_eV(E1_eV, me_eV);
double v2_lab_new_ms = calc_Speed_from_Ekin_eV(W_eV, me_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 new_dir_1 = calc_newDirection(vLab_ms, theta1, phi1);
vec3 new_dir_2 = calc_newDirection(vLab_ms, theta2, phi2);
vec3 v1_new_ms = v1_lab_new_ms*new_dir_1 + vOff_ms;
vec3 v2_new_ms = v2_lab_new_ms*new_dir_2 + vOff_ms;
vec3 P1newDir, P2newDir, v1New_ms, v2New_ms ;
P1newDir = calc_newDirection(v_ms, theta1, phi1);
P2newDir = calc_newDirection(v_ms, theta2, phi2);
interPart->set_Speed_ms(v1_new_ms);
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);
vec3 loc_m = interPart->get_Location_m();
Particle eNew = Particle_Builder::createElectron(loc_m, v2New_ms, -1, interPart->get_Id());
InteractionOut InterOut;
vec3 loc_m = interPart->get_Location_m();
Particle eNew = Particle_Builder::createElectron(loc_m, v2_new_ms, -1, interPart->get_Id());
InterOut.add_new_particle(eNew);
vec3 vT_ms = Population->get_average_speed_ms(loc_m);
@@ -84,33 +84,19 @@ inline InteractionOut eT2_T2I_Ionization_Analytic::do_Interaction (Particle *int
return(InterOut);
}
inline vec3 eT2_T2I_Ionization_Analytic::roll_vLab_ms(const Particle &interPart) {
inline vec3 eT2_T2I_Ionization_Base::roll_vLab_ms(const Particle &interPart) {
vec3 v_ms = interPart.get_Speed_ms();
vec3 vT2_ms = Population->roll_speed_ms(interPart.get_Location_m());
vec3 vOff_ms = vT2_ms;
vec3 vLab_ms = v_ms - vOff_ms;
vec3 vLab_ms = v_ms - vT2_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(v_ms);
} else {
return(vLab_ms);
}
return (T_eV);
}
inline double eT2_T2I_Ionization_Analytic::roll_ionW_eV(double T_eV) {
double pmax, Wmin_eV, Wmax_eV, Wcan_eV,eta1,eta2;
pmax = BED_eT2_Ionization::calc_TCS(T_eV);
Wmin_eV = 0;
Wmax_eV = T_eV-EionT2_eV;
do {
eta1 = rngUni->random();
eta2 = rngUni->random();
Wcan_eV = Wmin_eV + eta1*(Wmax_eV - Wmin_eV);
} while(eta2*pmax > BED_eT2_Ionization::calc_SDCS(T_eV, Wcan_eV));
double W_eV = (Wcan_eV< (T_eV-EionT2_eV)/2 ) ? Wcan_eV : (T_eV-EionT2_eV) - Wcan_eV;
return(W_eV);
}
inline double eT2_T2I_Ionization_Analytic::roll_IonTheta1(double T_eV, double W_eV) {
inline double eT2_T2I_Ionization_Base::roll_theta1(double T_eV, double W_eV) {
double theta1;
if (W_eV > 100) {
double numerator = W_eV/T_eV;
@@ -122,7 +108,7 @@ inline double eT2_T2I_Ionization_Analytic::roll_IonTheta1(double T_eV, double W_
return (theta1);
}
inline double eT2_T2I_Ionization_Analytic::roll_IonTheta2(double T_eV, double W_eV) {
inline double eT2_T2I_Ionization_Base::roll_theta2(double T_eV, double W_eV) {
double theta2;
if (W_eV > 200) {
double numerator = 1- W_eV/T_eV;
@@ -142,122 +128,51 @@ inline double eT2_T2I_Ionization_Analytic::roll_IonTheta2(double T_eV, double W_
}
class eT2_T2I_Ionization_Container : public Sub_Interaction_Base {
Average_Container<dim1Map> TCS_Average;
Stacked_Container<dim2Map> SDCS_Stacked;
public:
eT2_T2I_Ionization_Container(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {
TCS_Average = Average_Container<dim1Map>(getDataPath() + "BED_average_TCS.dat");
SDCS_Stacked = Stacked_Container<dim2Map>(0, getDataPath() + "BED_stacked_SDCS.dat");
};
double get_macroSigma_m2(const Particle &interPart);
InteractionOut do_Interaction (Particle *interPart);
private:
vec3 roll_vLab_ms(const Particle &interPart);
double roll_ionW_eV(double T_eV);
double roll_IonTheta1(double T_eV, double W_eV);
double roll_IonTheta2(double T_eV, double W_eV);
class eT2_T2I_Ionization_Analytic : public eT2_T2I_Ionization_Base {
public:
eT2_T2I_Ionization_Analytic(Population_Base *T2Population, UniRNG *rngUni) : eT2_T2I_Ionization_Base(T2Population, rngUni) {};
protected:
double calc_microSigma(const double &T_eV) {
return(BED_eT2_Ionization::calc_TCS(T_eV));
}
double roll_ionW_eV(const double &T_eV) {
double pmax, Wmin_eV, Wmax_eV, Wcan_eV,eta1,eta2;
pmax = BED_eT2_Ionization::calc_TCS(T_eV);
Wmin_eV = 0;
Wmax_eV = T_eV-EionT2_eV;
do {
eta1 = rngUni->random();
eta2 = rngUni->random();
Wcan_eV = Wmin_eV + eta1*(Wmax_eV - Wmin_eV);
} while(eta2*pmax > BED_eT2_Ionization::calc_SDCS(T_eV, Wcan_eV));
double W_eV = (Wcan_eV< (T_eV-EionT2_eV)/2 ) ? Wcan_eV : (T_eV-EionT2_eV) - Wcan_eV;
return(W_eV);
}
};
inline double eT2_T2I_Ionization_Container::get_macroSigma_m2(const Particle &interPart) {
double T_eV = interPart.get_EKin_eV();
double microSigma_m2 = TCS_Average.get_value(ddeque{T_eV});
vec3 loc_m = interPart.get_Location_m();
double nT2_m3 = Population->get_density_m3(loc_m);
return (microSigma_m2*nT2_m3);
}
inline InteractionOut eT2_T2I_Ionization_Container::do_Interaction (Particle *interPart) {
vec3 vLab_ms = roll_vLab_ms(*interPart);
vec3 v_ms = interPart->get_Speed_ms();
class eT2_T2I_Ionization_Container : public eT2_T2I_Ionization_Base {
TCS_Container tcs_data;
DCS_Ionization_Container dcs_data;
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.");
public:
eT2_T2I_Ionization_Container(Population_Base *T2Population, UniRNG *rngUni) :
eT2_T2I_Ionization_Base(T2Population, rngUni),
tcs_data(zero, 2e4, 100, (getDataPath() + "eT2_ion_TCS.dat")),
dcs_data(zero, 2e4, 100, 50, (getDataPath() + "eT2_ion_DCS.dat"))
{};
protected:
double calc_microSigma(const double &T_eV) {
return tcs_data.get_value(T_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);
vec3 loc_m = interPart->get_Location_m();
Particle eNew = Particle_Builder::createElectron(loc_m, v2New_ms, -1, interPart->get_Id());
InteractionOut InterOut;
InterOut.add_new_particle(eNew);
vec3 vT_ms = Population->get_average_speed_ms(loc_m);
Particle TNew = Particle_Builder::createTritium2I(loc_m, vT_ms, -1, interPart->get_Id());
InterOut.add_new_particle(TNew);
return(InterOut);
}
inline vec3 eT2_T2I_Ionization_Container::roll_vLab_ms(const Particle &interPart) {
vec3 v_ms = interPart.get_Speed_ms();
vec3 vT2_ms = Population->roll_speed_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);
double roll_ionW_eV(const double &T_eV) {
return dcs_data.roll_value(T_eV, rngUni);
}
return (T_eV);
}
};
inline double eT2_T2I_Ionization_Container::roll_ionW_eV(double T_eV) {
return (SDCS_Stacked.sample(ddeque{T_eV}, rngUni));
}
inline double eT2_T2I_Ionization_Container::roll_IonTheta1(double T_eV, double W_eV) {
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);
}
inline double eT2_T2I_Ionization_Container::roll_IonTheta2(double T_eV, double W_eV) {
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);
}
#endif /* eT2_ionization_h */
+1 -1
View File
@@ -35,7 +35,7 @@ inline double eT2I_Recombination::get_macroSigma_m2(const Particle &interPart) {
inline InteractionOut eT2I_Recombination::do_Interaction (Particle *interPart) {
InteractionOut res;
res.set_delete_current(true);
res.set_delete_location(interPart->get_Location_m());
res.set_decrease_location(tritium2I, interPart->get_Location_m());
// Maybe add the 2 T atoms.
return(res);
}
+3 -3
View File
@@ -119,10 +119,10 @@ inline double get_r_m(const vec3 &loc_m) {
}
inline double get_phi(const vec3 &loc_m) {
if (loc_m[0] >= 0) {
return ( acos(loc_m[1]/get_r_m(loc_m)) );
if (loc_m[1] >= 0) {
return ( acos(loc_m[0]/get_r_m(loc_m)) );
} else {
return ( 2*pi - acos(loc_m[1]/get_r_m(loc_m)) );
return ( 2*pi - acos(loc_m[0]/get_r_m(loc_m)) );
}
}
+103
View File
@@ -0,0 +1,103 @@
//
// lin_scale.h
// mc_electron
//
// Created by Christian Reiling on 06.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef lin_scale_h
#define lin_scale_h
#include <cmath>
#include <sstream>
#include "error_types.h"
#include "scale.h"
class Lin_Scale : public Scale {
double min_x;
double max_x;
double delta_x;
int number_bins;
public:
Lin_Scale() {};
Lin_Scale(const double &min_x, const double &max_x, const int &number_bins);
~Lin_Scale() {};
Scale *clone() {return new Lin_Scale(*this);}
double get_lower_scale_end();
double get_upper_scale_end();
int get_number_bins();
int calc_index(const double &x);
double get_lower_bin_bound(const int &index);
double get_bin_mid(const int &index);
double get_upper_bin_bound(const int &index);
bool is_valid_index (const int &index);
friend bool operator==(const Lin_Scale &scale1, const Lin_Scale &scale2);
};
inline Lin_Scale::Lin_Scale(const double &min_x, const double &max_x, const int &number_bins) {
this->min_x = min_x;
this->max_x = max_x;
this->number_bins = number_bins;
if (number_bins<1) {
std::stringstream ss;
ss<<"Lin_Scale::Lin_Scale: Less than 1 bin not possible.\n";
throw MyException (ss.str());
}
delta_x = (max_x - min_x)/(number_bins);
}
inline double Lin_Scale::get_lower_scale_end() {
return(min_x);
}
inline double Lin_Scale::get_upper_scale_end() {
return(max_x);
}
inline int Lin_Scale::get_number_bins() {
return(number_bins);
}
inline int Lin_Scale::calc_index(const double &x) {
if (x <= min_x) {
return (0);
}
if (x >= max_x) {
return (number_bins-1);
}
return (std::ceil((x-min_x)/delta_x) - 1);
}
inline double Lin_Scale::get_lower_bin_bound(const int &index) {
return (min_x + double(index) * delta_x);
}
inline double Lin_Scale::get_bin_mid(const int &index) {
return (min_x + double(index+0.5) * delta_x);
}
inline double Lin_Scale::get_upper_bin_bound(const int &index) {
return (min_x + double(index + 1) * delta_x);
}
inline bool Lin_Scale::is_valid_index (const int &index) {
if (index < 0 || index > (number_bins-1) ) {
return (false);
} else {
return (true);
}
}
inline bool operator==(const Lin_Scale &scale1, const Lin_Scale &scale2) {
return (scale1.min_x== scale2.min_x &&
scale1.max_x== scale2.max_x &&
scale1.delta_x== scale2.delta_x &&
scale1.number_bins== scale2.number_bins);
}
#endif /* lin_scale_h */
+80
View File
@@ -0,0 +1,80 @@
//
// log_scale.h
// mc_electron
//
// Created by Christian Reiling on 06.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef log_scale_h
#define log_scale_h
#include "lin_scale.h"
class Log_Scale : public Scale {
Lin_Scale lin_scale;
public:
Log_Scale() {};
Log_Scale(const double &min_x, const double &max_x, const int &number_bins) {
lin_scale = Lin_Scale(std::log10(min_x), std::log10(max_x), number_bins);
};
~Log_Scale() {};
Scale *clone() {return new Log_Scale(*this);}
double get_lower_scale_end();
double get_upper_scale_end();
int get_number_bins();
int calc_index(const double &x);
double get_lower_bin_bound(const int &index);
double get_bin_mid(const int &index);
double get_upper_bin_bound(const int &index);
bool is_valid_index (const int &index);
friend bool operator==(const Log_Scale &scale1, const Log_Scale &scale2);
};
inline double Log_Scale::get_lower_scale_end() {
double min_x = pow(10,lin_scale.get_lower_scale_end());
return(min_x);
}
inline double Log_Scale::get_upper_scale_end() {
double max_x = pow(10,lin_scale.get_upper_scale_end());
return(max_x);
}
inline int Log_Scale::get_number_bins() {
return(lin_scale.get_number_bins());
}
inline int Log_Scale::calc_index(const double &x) {
double p = std::log10(x);
return (lin_scale.calc_index(p));
}
inline double Log_Scale::get_lower_bin_bound(const int &index) {
double p = lin_scale.get_lower_bin_bound(index);
return (pow(10,p));
}
inline double Log_Scale::get_bin_mid(const int &index) {
double p = lin_scale.get_bin_mid(index);
return (pow(10,p));
}
inline double Log_Scale::get_upper_bin_bound(const int &index) {
double p = lin_scale.get_upper_bin_bound(index);
return (pow(10,p));
}
inline bool Log_Scale::is_valid_index (const int &index) {
return (lin_scale.is_valid_index(index));
}
inline bool operator==(const Log_Scale &scale1, const Log_Scale &scale2) {
return (scale1.lin_scale == scale2.lin_scale);
}
#endif /* log_scale_h */
+1 -1
View File
@@ -38,7 +38,7 @@ Particle_Logger_Base *Particle_Logger_Builder::build_eLogger(H5_Particles *h5par
Population_Logger_Manager Population_Logger_Builder::build(H5_File *h5f, Population_Manager *populations) {
Population_Logger_Manager Population_Logger;
H5_Populations *h5pop = h5f->get_h5pop();
Thermal_Base *T2I_population = dynamic_cast<Thermal_Base*>(populations->find(tritium2I));
Thermal_Base *T2I_population = static_cast<Thermal_Base*>(populations->find(tritium2I));
Population_Logger.add(new Thermal_Population_Logger(T2I_population, h5pop->get_h5g_pop()));
return (Population_Logger);
+1 -1
View File
@@ -15,7 +15,7 @@ TARGETS = mcelectron
all: $(TARGETS)
mcelectron: main.o simulation.o\
tcs_container.o dcs_container.o population3_container.o size_container.o \
tcs_container.o dcs_theta_container.o dcs_ionization_container.o population3_container.o size_container.o \
thermalPop_container.o energeticPop_container.o \
particle.o injector.o timer.o katrin_geo.o katrin_fields.o \
h5_file.o logger_builder.o \
+15 -13
View File
@@ -15,10 +15,10 @@ using namespace std;
Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
z_scale = Lin_Scale(Katrin_Geo::get_z_RW_m(), Katrin_Geo::get_z_WGTSend_m(), num_z_bins);
r_scale = Lin_Scale(0,Katrin_Geo::get_radius_m(), num_r_bins);
phi_scale = Lin_Scale(0, 180, num_phi_bins);
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
int phi_dimension = phi_scale.get_dimension();
phi_scale = Lin_Scale(0, 2*pi, num_phi_bins);
int z_dimension = z_scale.get_number_bins();
int r_dimension = r_scale.get_number_bins();
int phi_dimension = phi_scale.get_number_bins();
data = new double **[z_dimension];
for (int i = 0; i < z_dimension; i++) {
@@ -33,8 +33,8 @@ Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins)
}
Pop3_Container::~Pop3_Container() {
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
int z_dimension = z_scale.get_number_bins();
int r_dimension = r_scale.get_number_bins();
for (int i = 0; i < z_dimension; i++) {
for(int j = 0; j < r_dimension; j++) {
delete[] data[i][j];
@@ -49,9 +49,9 @@ Pop3_Container::Pop3_Container(const Pop3_Container& other) {
z_scale = other.z_scale;
r_scale = other.r_scale;
phi_scale = other.phi_scale;
int z_dimension = z_scale.get_dimension();
int r_dimension = r_scale.get_dimension();
int phi_dimension = phi_scale.get_dimension();
int z_dimension = z_scale.get_number_bins();
int r_dimension = r_scale.get_number_bins();
int phi_dimension = phi_scale.get_number_bins();
data = new double **[z_dimension];
for (int i = 0; i < z_dimension; i++) {
@@ -65,7 +65,6 @@ Pop3_Container::Pop3_Container(const Pop3_Container& other) {
}
}
Pop3_Container& Pop3_Container::operator=(const Pop3_Container& other) {
Pop3_Container tmp(other);
swap(z_scale, tmp.z_scale);
@@ -80,6 +79,7 @@ void Pop3_Container::increase_value(const double &value, const vec3 &loc_m) {
int zbin = z_scale.calc_index(get_z_m(loc_m));
int rbin = r_scale.calc_index(get_r_m(loc_m));
int phibin = phi_scale.calc_index(get_phi(loc_m));
data[zbin][rbin][phibin] += value;
}
@@ -92,10 +92,12 @@ void Pop3_Container::increase_value(const double &value, const vec3 &loc1_m, con
int min_z_index = z_scale.calc_index(z_min_m);
int max_z_index = z_scale.calc_index(z_max_m);
// No r/phi movement, else need to calculate more exactly
int rbin = r_scale.calc_index(get_r_m(loc1_m));
int phibin = phi_scale.calc_index(get_phi(loc1_m));
double r = get_r_m(loc1_m);
int rbin = r_scale.calc_index(get_r_m(r));
double phi = get_phi(loc1_m);
int phibin = phi_scale.calc_index(phi);
for (int i = min_z_index; i<max_z_index; i++) {
for (int i = min_z_index; i<=max_z_index; i++) {
data[i][rbin][phibin] += value;
}
}
+18 -1
View File
@@ -9,7 +9,7 @@
#ifndef population3_container_hpp
#define population3_container_hpp
#include "linScale.h"
#include "lin_scale.h"
#include "katrin_geo.hpp"
#include "timer.hpp"
@@ -37,6 +37,23 @@ public:
Lin_Scale get_z_scale(){return(z_scale);}
Lin_Scale get_r_scale(){return(r_scale);}
Lin_Scale get_phi_scale(){return(phi_scale);}
void debug() {
int z_dimension = z_scale.get_number_bins();
int r_dimension = r_scale.get_number_bins();
int phi_dimension = phi_scale.get_number_bins();
for (int i = 0; i < z_dimension; i++) {
for(int j = 0; j < r_dimension; j++) {
std::cout<<i<<"\t"<<j<<"\t-\t";
for (int k = 0; k < phi_dimension; k++) {
std::cout<<data[i][j][k]<<"\t";
}
std::cout<<"\n";
}
}
std::cout<<"\n";
}
};
+31
View File
@@ -0,0 +1,31 @@
//
// Scale.h
// mc_electron
//
// Created by Christian Reiling on 04.06.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef Scale_h
#define Scale_h
class Scale {
public:
Scale() {};
virtual ~Scale() {};
virtual Scale *clone() = 0;
virtual double get_lower_scale_end() = 0;
virtual double get_upper_scale_end() = 0;
virtual int get_number_bins() = 0;
virtual int calc_index(const double &x) = 0;
virtual double get_lower_bin_bound(const int &index) = 0;
virtual double get_bin_mid(const int &index) = 0;
virtual double get_upper_bin_bound(const int &index) = 0;
virtual bool is_valid_index (const int &index) = 0;
};
#endif /* Scale_h */
+6 -7
View File
@@ -46,9 +46,8 @@ void Simulation::doit() {
Interaction_Base *interactionPtr;
Terminator_Base *terminatorPtr;
InteractionOut IntOut;
double mfp;
double macroSigma_m2, mfp_m;
std::deque<Particle> partQue;
Particle curPart;
vec3 oldLoc_m;
@@ -67,19 +66,19 @@ void Simulation::doit() {
interactionPtr = interactions.find(curPart.get_species());
terminatorPtr = terminators.find(curPart.get_species());
while (!terminatorPtr->checkTermination(curPart)) {
oldLoc_m = curPart.get_Location_m();
mfp = 1/interactionPtr->get_macroSigma_m2(curPart);
moverPtr->move(&curPart, mfp);
macroSigma_m2 = interactionPtr->get_macroSigma_m2(curPart);
mfp_m = 1/macroSigma_m2;
moverPtr->move(&curPart, mfp_m);
if (!terminatorPtr->checkTermination(curPart)) {
IntOut = interactionPtr->do_Interaction(&curPart);
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
partQue.push_back(IntOut.get_new_particles()[i]);
partQue.back().set_Id(numberTotalParticles++);
}
if (IntOut.get_delete_density()) {
// Decrease Density by one now.
if (IntOut.get_decrease_population()) {
populations.find(IntOut.get_decrease_species())->decrease_denisty(IntOut.get_decrease_location());
}
if (IntOut.get_delete_current()) {
break;
+6 -9
View File
@@ -9,7 +9,7 @@
#ifndef size_container_hpp
#define size_container_hpp
#include "linScale.h"
#include "lin_scale.h"
#include "katrin_geo.hpp"
@@ -25,20 +25,17 @@ public:
Size_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
r_scale = Lin_Scale(0, Katrin_Geo::get_radius_m(), num_r_bins);
cell_length_m = (Katrin_Geo::get_z_WGTSend_m()-Katrin_Geo::get_z_RW_m()) / (num_z_bins-1);
cell_length_m = (Katrin_Geo::get_z_WGTSend_m()-Katrin_Geo::get_z_RW_m()) / (num_z_bins);
data = new double[num_r_bins + 1];
for (int i = 0; i<=num_r_bins; i++) {
data = new double[num_r_bins];
for (int i = 0; i<num_r_bins; i++) {
data[i] = cell_length_m * calc_disc_surface_m2(i)/num_phi_bins;
}
}
double calc_disc_surface_m2 (const int &r_bin) {
if (r_bin == 0) {
return (0);
}
double previous_r_m = r_scale.calc_upper_bound(r_bin-1);
double this_r_m = r_scale.calc_upper_bound(r_bin);
double previous_r_m = r_scale.get_lower_bin_bound(r_bin);
double this_r_m = r_scale.get_upper_bin_bound(r_bin);
double A_m2 = pi * (this_r_m * this_r_m - previous_r_m * previous_r_m);
return(A_m2);
}
+18 -12
View File
@@ -23,8 +23,10 @@ class InteractionOut {
Particle new_particles[3];
int number_new_particles;
bool decrease_density;
vec3 delete_location;
bool decrease_population;
species decrease_species;
vec3 decrease_location;
public:
InteractionOut() {reset();};
@@ -32,26 +34,30 @@ public:
void reset() {
delete_current = false;
number_new_particles = 0;
decrease_density = false;
decrease_population = false;
}
void set_delete_current(const bool &delete_current) {this->delete_current = delete_current;}
bool get_delete_current() {return (delete_current);}
void add_new_particle(const Particle &newParticle) {
new_particles[number_new_particles] = newParticle;
number_new_particles++;
}
void set_delete_location (const vec3 &delete_location) {
this->delete_location = delete_location;
this->decrease_density = true;
}
bool get_delete_current() {return (delete_current);}
int get_number_new_particles() {return(number_new_particles);}
Particle *get_new_particles() {return(new_particles);}
bool get_delete_density() {return(decrease_density);}
vec3 get_delete_location() {return(delete_location);}
void set_decrease_location (const species &decrease_species, const vec3 &decrease_location) {
this->decrease_population = true;
this->decrease_species = decrease_species;
this->decrease_location = decrease_location;
}
bool get_decrease_population() {return decrease_population;}
species get_decrease_species() {return decrease_species;}
vec3 get_decrease_location() {return decrease_location;}
};
+33 -13
View File
@@ -8,7 +8,36 @@
#include "tcs_container.hpp"
#include <algorithm>
using namespace std;
TCS_Container::TCS_Container(double E_min_eV, double E_max_eV, int number_bins, std::string load_path) {
E_scale = Log_Scale(E_min_eV, E_max_eV, number_bins);
calc_data(load_path); //calc, whereas, load_path contains point with exact values for cross section.
}
TCS_Container::~TCS_Container() {
delete[] data;
};
TCS_Container::TCS_Container(const TCS_Container& other) {
E_scale = other.E_scale;
int E_dimension = E_scale.get_number_bins();
data = new double [E_dimension];
for (int i = 0; i < E_dimension; i++) {
data[i] = other.data[i];
}
}
TCS_Container& TCS_Container::operator=(const TCS_Container& other) {
TCS_Container tmp(other);
swap(E_scale, tmp.E_scale);
swap(data, tmp.data);
return (*this);
}
double TCS_Container::get_value(double E_eV) {
int index = E_scale.calc_index(E_eV);
@@ -16,21 +45,12 @@ double TCS_Container::get_value(double E_eV) {
}
void TCS_Container::calc_data(const std::string &load_path) {
int dimension = E_scale.get_dimension();
int dimension = E_scale.get_number_bins();
data = new double[dimension];
Edge_Container<dim1Map> E1D(load_path);
double E_eV;
for (int i=0; i<dimension; i++) {
data[i] = calc_bin_value(i, &E1D);
E_eV = E_scale.get_bin_mid(i);
data[i] = E1D.interpolate(std::deque<double>{E_eV});
}
}
double TCS_Container::calc_bin_value(const int &bin, Edge_Container<dim1Map> *E1D) {
double E_eV;
if (bin == 0) {
E_eV = E_scale.calc_upper_bound(bin);
} else {
E_eV = E_scale.calc_upper_bound(bin-1);
E_eV +=(E_scale.calc_upper_bound(bin) - E_scale.calc_upper_bound(bin-1))/2;
}
return (E1D->interpolate(std::deque<double>{E_eV}) );
}
+5 -10
View File
@@ -9,7 +9,7 @@
#ifndef tcs_container_hpp
#define tcs_container_hpp
#include "logScale.h"
#include "log_scale.h"
#include "edge_container.h"
#include <string>
@@ -20,19 +20,14 @@ class TCS_Container {
Log_Scale E_scale;
public:
~TCS_Container() {
delete[] data;
};
TCS_Container(double E_min_eV, double E_max_eV, int number_bins, std::string load_path) {
E_scale = Log_Scale(E_min_eV, E_max_eV, number_bins);
calc_data(load_path); //calc, whereas, load_path contains point with exact values for cross section.
}
TCS_Container(double E_min_eV, double E_max_eV, int number_bins, std::string load_path);
~TCS_Container();
TCS_Container(const TCS_Container& other);
TCS_Container& operator=(const TCS_Container& other);
double get_value(double E_eV);
private:
void calc_data(const std::string &load_path);
double calc_bin_value(const int &bin, Edge_Container<dim1Map> *E1D);
};
#endif /* tcs_container_hpp */
+7 -2
View File
@@ -33,6 +33,10 @@ public:
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
this->timer = timer;
};
Thermal_Base* get_thermal_base_ptr() {
return (this);
}
double get_density_m3 (const vec3 &loc_m);
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
@@ -41,8 +45,9 @@ public:
virtual vec3 get_average_speed_ms (const vec3 &loc_m) = 0;
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
Pop3_Container get_cumulated_time_container () const {return(cumulated_times_s);}
Pop3_Container get_number_annhilated_container () const {return(number_annhilated);}
Pop3_Container get_cumulated_time_container () {
return(cumulated_times_s);}
Pop3_Container get_number_annhilated_container () {return(number_annhilated);}
};
+12 -12
View File
@@ -84,18 +84,18 @@ inline void Thermal_Population_Logger::create_h5tb_meta(hid_t *h5g) {
meta_bin.E_bin = 0;
meta_bin.E_min_eV = NAN;
meta_bin.E_max_eV = NAN;
meta_bin.z_min_m = z_scale.get_min_val();
for (int i_z=0; i_z<z_scale.get_dimension(); i_z++) {
meta_bin.z_min_m = z_scale.get_lower_scale_end();
for (int i_z=0; i_z<z_scale.get_number_bins(); i_z++) {
meta_bin.z_bin = i_z;
meta_bin.z_max_m = z_scale.calc_upper_bound(i_z);
meta_bin.r_min_m = r_scale.get_min_val();
for (int i_r=0; i_r<r_scale.get_dimension(); i_r++) {
meta_bin.z_max_m = z_scale.get_upper_bin_bound(i_z);
meta_bin.r_min_m = r_scale.get_lower_scale_end();
for (int i_r=0; i_r<r_scale.get_number_bins(); i_r++) {
meta_bin.r_bin = i_r;
meta_bin.r_max_m = r_scale.calc_upper_bound(i_r);
meta_bin.phi_min = phi_scale.get_min_val();
for (int i_phi=0; i_phi<phi_scale.get_dimension(); i_phi++) {
meta_bin.r_max_m = r_scale.get_upper_bin_bound(i_r);
meta_bin.phi_min = phi_scale.get_lower_scale_end();
for (int i_phi=0; i_phi<phi_scale.get_number_bins(); i_phi++) {
meta_bin.phi_bin = i_phi;
meta_bin.phi_max = phi_scale.calc_upper_bound(i_phi);
meta_bin.phi_max = phi_scale.get_upper_bin_bound(i_phi);
h5tb_meta.write(meta_bin);
meta_bin.phi_min = meta_bin.phi_max;
}
@@ -111,11 +111,11 @@ inline void Thermal_Population_Logger::log(int number_decay) {
Pop3_Container anhilated = thermal_pop->get_number_annhilated_container();
pop_bin.number_decay = number_decay;
pop_bin.E_bin = -1;
for (int i_z=0; i_z<z_scale.get_dimension(); i_z++) {
for (int i_z=0; i_z<z_scale.get_number_bins(); i_z++) {
pop_bin.z_bin = i_z;
for (int i_r=0; i_r<r_scale.get_dimension(); i_r++) {
for (int i_r=0; i_r<r_scale.get_number_bins(); i_r++) {
pop_bin.r_bin = i_r;
for (int i_phi=0; i_phi<phi_scale.get_dimension(); i_phi++) {
for (int i_phi=0; i_phi<phi_scale.get_number_bins(); i_phi++) {
pop_bin.phi_bin = i_phi;
pop_bin.cumulative_time = cum_time.get_value_by_bin(i_z, i_r, i_phi);
pop_bin.offset = anhilated.get_value_by_bin(i_z, i_r, i_phi);
+1 -1
View File
@@ -26,7 +26,7 @@ inline bool T2I_Terminator::checkTermination (const Particle &movePart) {
return (true);
}
if (check_Energy(movePart)) {
return (true);
//return (true);
}
if (check_MaxInteractions(movePart)) {
return (true);
+1 -1
View File
@@ -26,7 +26,7 @@ inline bool TI_Terminator::checkTermination (const Particle &movePart) {
return (true);
}
if (check_Energy(movePart)) {
return (true);
//return (true);
}
if (check_MaxInteractions(movePart)) {
return (true);