Major changes:
- Added individul operators for species and better selecting process. - Switched to C arrays for main loop operations and calculating array indizes using knowledge of binning instead of doing sorted search - Added Recombination - Reworked elastic scattering kinematics - Added inelastic scattering kinematics
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// TT2_elastic.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TT2_elastic_h
|
||||
#define TT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "hardsphere_elastic.h"
|
||||
|
||||
class TT2_Elastic : public Sub_Interaction_Base {
|
||||
Hardsphere_elasticScattering HardSphere = Hardsphere_elasticScattering(1e-20); //3.4614e-15);
|
||||
public:
|
||||
TT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart);
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
|
||||
private:
|
||||
vec3 calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab);
|
||||
};
|
||||
|
||||
|
||||
inline double TT2_Elastic::get_macroSigma_m2(const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double n_m3 = (Population->get_density_m3(loc_m));
|
||||
return (HardSphere.get_TCS() * n_m3);
|
||||
}
|
||||
|
||||
inline InteractionOut TT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 loc_m = interPart->get_Location_m();
|
||||
vec3 vT2_ms = (Population->roll_speed_ms(loc_m));
|
||||
vec3 vLab_ms = v_ms - vT2_ms;
|
||||
double thetaLab = HardSphere.roll_theta(rngUni);
|
||||
double phiLab = rngUni->random() * 2 * pi;
|
||||
interPart->set_Speed_ms( calc_vNew_ms(v_ms, vT2_ms, thetaLab, phiLab) );
|
||||
return (InteractionOut());
|
||||
}
|
||||
|
||||
inline vec3 TT2_Elastic::calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab) {
|
||||
vec3 speedLab_ms = vOld_ms - vT2_ms;
|
||||
vec3 n0 = calc_newDirection(speedLab_ms, thetaLab, phiLab);
|
||||
vec3 vNew_ms = (mT2_eV*vec3Abs(speedLab_ms)*n0 + me_eV*speedLab_ms)/(me_eV+mT2_eV) + vT2_ms;
|
||||
return (vNew_ms);
|
||||
}
|
||||
|
||||
|
||||
#endif /* TT2_elastic_h */
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// asci_logger.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "asci_logger.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// Redundant Code with h5, but ASCI Logger is kept in code as relict.
|
||||
const int ASCI_Logger::numberZBins = getParameter("numberZBins");
|
||||
|
||||
ASCI_Logger::ASCI_Logger() {
|
||||
if (numberZBins == 0) {
|
||||
logging = false;
|
||||
} else if (numberZBins == -1 || numberZBins > 0) {
|
||||
logging = true;
|
||||
set_zLogValues();
|
||||
print_logInfo();
|
||||
|
||||
set_outdirName();
|
||||
create_outdir();
|
||||
set_outStream();
|
||||
} else {
|
||||
stringstream ss;
|
||||
ss<<"H5_Logger::Parameter numberZBins invalid value.\nnumberZBins:\t"<<numberZBins<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ASCI_Logger::set_zLogValues() {
|
||||
zLogValues.clear();
|
||||
if (logging) {
|
||||
double start_m = Katrin_Geo::get_z_RW_m();
|
||||
double length_m = Katrin_Geo::get_z_WGTSend_m() - start_m;
|
||||
double stepLength_m = length_m/(numberZBins-1);
|
||||
double z_m;
|
||||
for (int i = 0;i<numberZBins;i++) {
|
||||
z_m = Katrin_Geo::get_z_RW_m() + stepLength_m*i;
|
||||
zLogValues.push_back(z_m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ASCI_Logger::print_logInfo() {
|
||||
stringstream ss;
|
||||
ss<<"Logger\t ";
|
||||
if (!logging) {
|
||||
ss<<"Logging disabled.\n";
|
||||
} else if (numberZBins == -1) {
|
||||
ss<<"Logging after every Interaction to one file.\n";
|
||||
} else if (numberZBins == 1) {
|
||||
ss<<"Only Logging Rearwall Output.\n";
|
||||
} else {
|
||||
ss<<"Logging at "<<numberZBins<<" z values.\n";
|
||||
}
|
||||
cout<<ss.str();
|
||||
}
|
||||
|
||||
|
||||
void ASCI_Logger::log_Particle(Particle *logPart, blitz::TinyVector<double,3> oldLoc_m) {
|
||||
if (!logging) {
|
||||
return;
|
||||
}
|
||||
if (logPart->get_species() != electron) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Assumption: no change of sign in v_z
|
||||
if (numberZBins == -1) {
|
||||
outStream[0]<<*logPart<<endl;
|
||||
} else {
|
||||
double zold = oldLoc_m[2];
|
||||
double znew = logPart->get_Location_m()[2];
|
||||
double zmin = min(zold,znew);
|
||||
double zmax = max(zold,znew);
|
||||
|
||||
for (int i=0;i<numberZBins;i++) {
|
||||
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
|
||||
outStream[i]<<*logPart<<endl; // Location wrong, because it s the new Location.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ASCI_Logger::set_outdirName() {
|
||||
string parname = getparName();
|
||||
stringstream dirname;
|
||||
int i = 1;
|
||||
do {
|
||||
dirname.str(std::string());
|
||||
dirname << parname << "_" << getTimeString() << "_" << i++;
|
||||
} while ( isDir(dirname.str()) );
|
||||
outdirName = dirname.str();
|
||||
return;
|
||||
}
|
||||
|
||||
void ASCI_Logger::create_outdir() {
|
||||
if (mkdir(outdirName.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||
stringstream ss;
|
||||
ss<<"ASCI_Logger::create_outdir: Could not create output directiory.\n outdirName = "<<outdirName<<endl;
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void ASCI_Logger::set_outStream() {
|
||||
if (numberZBins == -1) {
|
||||
outStream = new ofstream [1];
|
||||
stringstream ss;
|
||||
ss <<outdirName << "/all" << ".dat";
|
||||
outStream[0].open(ss.str().c_str());
|
||||
} else {
|
||||
outStream = new ofstream [numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << outdirName << "/z=" << zLogValues[i] << ".dat";
|
||||
outStream[i].open(ss.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// asci_logger.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef asci_logger_hpp
|
||||
#define asci_logger_hpp
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
class ASCI_Logger {
|
||||
static const int numberZBins;
|
||||
bool logging;
|
||||
std::vector<double> zLogValues;
|
||||
|
||||
std::string outdirName;
|
||||
std::ofstream *outStream;
|
||||
|
||||
public:
|
||||
ASCI_Logger();
|
||||
private:
|
||||
void set_zLogValues();
|
||||
void print_logInfo();
|
||||
void set_outdirName();
|
||||
void create_outdir();
|
||||
void set_outStream();
|
||||
|
||||
public:
|
||||
void log_Particle(Particle *inPart , vec3 oldLoc_m);
|
||||
};
|
||||
|
||||
|
||||
#endif /* asci_logger_hpp */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,131 @@
|
||||
# E sig_tot
|
||||
1.00000e-05 2.85516e-20
|
||||
1.20000e-05 2.92114e-20
|
||||
1.40000e-05 2.97811e-20
|
||||
1.60000e-05 3.02836e-20
|
||||
1.80000e-05 3.07339e-20
|
||||
2.00000e-05 3.11423e-20
|
||||
2.50000e-05 3.20254e-20
|
||||
3.00000e-05 3.27655e-20
|
||||
3.50000e-05 3.34045e-20
|
||||
4.00000e-05 3.39681e-20
|
||||
5.00000e-05 3.49313e-20
|
||||
6.00000e-05 3.57386e-20
|
||||
7.00000e-05 3.64356e-20
|
||||
8.00000e-05 3.70504e-20
|
||||
9.00000e-05 3.76012e-20
|
||||
1.00000e-04 3.81009e-20
|
||||
1.20000e-04 3.89814e-20
|
||||
1.40000e-04 3.97417e-20
|
||||
1.60000e-04 4.04123e-20
|
||||
1.80000e-04 4.10131e-20
|
||||
2.00000e-04 4.15582e-20
|
||||
2.50000e-04 4.27366e-20
|
||||
3.00000e-04 4.37242e-20
|
||||
3.50000e-04 4.45770e-20
|
||||
4.00000e-04 4.53291e-20
|
||||
5.00000e-04 4.66144e-20
|
||||
6.00000e-04 4.76916e-20
|
||||
7.00000e-04 4.86218e-20
|
||||
8.00000e-04 4.94422e-20
|
||||
9.00000e-04 5.01773e-20
|
||||
1.00000e-03 5.08442e-20
|
||||
1.20000e-03 5.20191e-20
|
||||
1.40000e-03 5.30337e-20
|
||||
1.60000e-03 5.39285e-20
|
||||
1.80000e-03 5.47303e-20
|
||||
2.00000e-03 5.54577e-20
|
||||
2.50000e-03 5.70302e-20
|
||||
3.00000e-03 5.83481e-20
|
||||
3.50000e-03 5.94861e-20
|
||||
4.00000e-03 6.04899e-20
|
||||
5.00000e-03 6.22051e-20
|
||||
6.00000e-03 6.36426e-20
|
||||
7.00000e-03 6.48838e-20
|
||||
8.00000e-03 6.59786e-20
|
||||
9.00000e-03 6.69596e-20
|
||||
1.00000e-02 6.78495e-20
|
||||
1.20000e-02 6.94174e-20
|
||||
1.40000e-02 7.07713e-20
|
||||
1.60000e-02 7.19654e-20
|
||||
1.80000e-02 7.30354e-20
|
||||
2.00000e-02 7.41000e-20
|
||||
3.00000e-02 7.71000e-20
|
||||
4.00000e-02 8.08000e-20
|
||||
5.00000e-02 8.32000e-20
|
||||
6.00000e-02 8.51000e-20
|
||||
7.00000e-02 8.69000e-20
|
||||
8.00000e-02 8.84000e-20
|
||||
9.00000e-02 8.99000e-20
|
||||
1.00000e-01 9.13000e-20
|
||||
1.20000e-01 9.33000e-20
|
||||
1.50000e-01 9.55000e-20
|
||||
2.00000e-01 9.83000e-20
|
||||
2.50000e-01 1.00400e-19
|
||||
3.00000e-01 1.02400e-19
|
||||
4.00000e-01 1.06100e-19
|
||||
5.00000e-01 1.09500e-19
|
||||
6.00000e-01 1.12800e-19
|
||||
7.00000e-01 1.15900e-19
|
||||
8.00000e-01 1.18800e-19
|
||||
9.00000e-01 1.21600e-19
|
||||
1.00000e+00 1.23600e-19
|
||||
1.25000e+00 1.30000e-19
|
||||
1.50000e+00 1.35500e-19
|
||||
2.00000e+00 1.41100e-19
|
||||
3.00000e+00 1.41200e-19
|
||||
4.00000e+00 1.32000e-19
|
||||
5.00000e+00 1.25100e-19
|
||||
6.00000e+00 1.14500e-19
|
||||
8.00000e+00 9.85000e-20
|
||||
1.00000e+01 8.58000e-20
|
||||
1.20000e+01 7.61000e-20
|
||||
1.40000e+01 6.92000e-20
|
||||
1.60000e+01 6.32000e-20
|
||||
1.80000e+01 5.78000e-20
|
||||
2.00000e+01 5.26000e-20
|
||||
2.50000e+01 4.23000e-20
|
||||
3.00000e+01 3.40000e-20
|
||||
3.50000e+01 2.81000e-20
|
||||
4.00000e+01 2.36000e-20
|
||||
5.00000e+01 1.73000e-20
|
||||
6.00000e+01 1.31000e-20
|
||||
7.00000e+01 1.06000e-20
|
||||
8.00000e+01 8.90000e-21
|
||||
9.00000e+01 8.10000e-21
|
||||
1.00000e+02 7.40000e-21
|
||||
1.20000e+02 6.61975e-21
|
||||
1.40000e+02 5.66489e-21
|
||||
1.60000e+02 4.94945e-21
|
||||
1.80000e+02 4.39369e-21
|
||||
2.00000e+02 3.94985e-21
|
||||
2.50000e+02 3.15371e-21
|
||||
3.00000e+02 2.62546e-21
|
||||
3.50000e+02 2.24920e-21
|
||||
4.00000e+02 1.96732e-21
|
||||
5.00000e+02 1.57294e-21
|
||||
6.00000e+02 1.31034e-21
|
||||
7.00000e+02 1.12305e-21
|
||||
8.00000e+02 9.82697e-22
|
||||
9.00000e+02 8.73558e-22
|
||||
1.00000e+03 7.86271e-22
|
||||
1.20000e+03 6.55425e-22
|
||||
1.40000e+03 5.62016e-22
|
||||
1.60000e+03 4.91973e-22
|
||||
1.80000e+03 4.37513e-22
|
||||
2.00000e+03 3.93956e-22
|
||||
2.50000e+03 3.15568e-22
|
||||
3.00000e+03 2.63326e-22
|
||||
3.50000e+03 2.26015e-22
|
||||
4.00000e+03 1.98036e-22
|
||||
5.00000e+03 1.58872e-22
|
||||
6.00000e+03 1.32766e-22
|
||||
7.00000e+03 1.14121e-22
|
||||
8.00000e+03 1.00139e-22
|
||||
9.00000e+03 8.92653e-23
|
||||
1.00000e+04 8.05667e-23
|
||||
1.20000e+04 6.75199e-23
|
||||
1.40000e+04 5.82019e-23
|
||||
1.60000e+04 5.12142e-23
|
||||
1.80000e+04 4.57799e-23
|
||||
2.00000e+04 4.14329e-23
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// 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 */
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// drift_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef drift_base_h
|
||||
#define drift_base_h
|
||||
|
||||
#include "mover_base.h"
|
||||
|
||||
|
||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||
class Drift_Base : public Mover_Base {
|
||||
public:
|
||||
Drift_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
||||
|
||||
void move(Particle *movePart, const double &distance_m);
|
||||
|
||||
protected:
|
||||
double get_zNew_m(Particle *movePart, const double &distance_m);
|
||||
virtual void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void Drift_Base::move(Particle *movePart, const double &distance_m) {
|
||||
vec3 oldLoc_m = movePart->get_Location_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
double znew_m = get_zNew_m(movePart, distance_m);
|
||||
doWallInteraction(movePart, &oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
movePart->set_Location_m(newLoc_m);
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
}
|
||||
|
||||
inline double Drift_Base::get_zNew_m(Particle *movePart, const double &distance_m) {
|
||||
double zold_m = movePart->get_Location_m()[2];
|
||||
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
double vTotAbs_ms = vec3Abs(v_ms);
|
||||
double vForwardAbs_ms = vec3Abs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] < 0 ? -1 : 1;
|
||||
|
||||
double znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
return (znew_m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* drift_base_h */
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// eT2_elastic.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef eT2_elastic_h
|
||||
#define eT2_elastic_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
#include "tcs_container.hpp"
|
||||
#include "dcs_container.hpp"
|
||||
#include "kinematics_base.h"
|
||||
|
||||
|
||||
class eT2_Elastic : public Sub_Interaction_Base {
|
||||
TCS_Container tcs_data;
|
||||
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"),
|
||||
kinematics(me_eV, mT2_eV) {}
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart);
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline double eT2_Elastic::get_macroSigma_m2(const Particle &interPart) {
|
||||
double Ekin_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = tcs_data.get_value(Ekin_eV);
|
||||
//std::cout<<"DEBUG:\t"<<microSigma_m2<<"\n";
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Population->get_density_m3(loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
inline InteractionOut eT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 vT2_ms = Population->roll_speed_ms(interPart->get_Location_m());
|
||||
vec3 vLab_ms = v_ms - vT2_ms;
|
||||
double T_eV = calc_Ekin_eV_from_speed(vLab_ms, me_eV);
|
||||
double theta_lab = dcs_data.roll_value(T_eV,rngUni);
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
kinematics.doKinematics(interPart, vT2_ms, theta_lab, phi_lab);
|
||||
return (InteractionOut());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Elastic Scattering:
|
||||
Using Rutherford Model with screening parameter following
|
||||
Cross-sections for water vapour for the Monte Carlo electron track structure code from 10eV to the MeV region
|
||||
S Uehara et al 1993 Phys. Med. Biol. 38 1841
|
||||
*/
|
||||
class eT2_Elastic_Analytic : public Sub_Interaction_Base {
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
public:
|
||||
eT2_Elastic_Analytic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {
|
||||
kinematics = Elastic_Kinematic_Base(me_eV, mT2_eV);
|
||||
};
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart);
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline double eT2_Elastic_Analytic::get_macroSigma_m2(const Particle &interPart) {
|
||||
double Ekin_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = Uehara_eT2_ElasticScattering::calc_TCS(Ekin_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Population->get_density_m3(loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
inline InteractionOut eT2_Elastic_Analytic::do_Interaction (Particle *interPart) {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 vT2_ms = Population->roll_speed_ms(interPart->get_Location_m());
|
||||
vec3 vLab_ms = v_ms - vT2_ms;
|
||||
double T_eV = calc_Ekin_eV_from_speed(vLab_ms, me_eV);
|
||||
double theta_lab = Uehara_eT2_ElasticScattering::roll_theta(T_eV, rngUni);
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
kinematics.doKinematics(interPart, vT2_ms, theta_lab, phi_lab);
|
||||
return (InteractionOut());
|
||||
}
|
||||
|
||||
#endif /* eT2_elastic_h */
|
||||
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// eT2_ionization.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef eT2_ionization_h
|
||||
#define eT2_ionization_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "average_container.h"
|
||||
#include "stacked_container.h"
|
||||
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
/*
|
||||
Ionization:
|
||||
Using BED-Model Kim and Rudd 1994
|
||||
*/
|
||||
class eT2_T2I_Ionization_Analytic : public Sub_Interaction_Base {
|
||||
public:
|
||||
eT2_T2I_Ionization_Analytic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
inline double eT2_T2I_Ionization_Analytic::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 nT2_m3 = Population->get_density_m3(loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
inline InteractionOut eT2_T2I_Ionization_Analytic::do_Interaction (Particle *interPart) {
|
||||
vec3 vLab_ms = roll_vLab_ms(*interPart);
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
|
||||
double T_eV = calc_Ekin_eV_from_speed(v_ms, me_eV);
|
||||
if (T_eV < EionT2_eV) {
|
||||
throw MyException("Electron::do_Ionization: Ekin_eV < EIonT2_eV.");
|
||||
}
|
||||
double W_eV = roll_ionW_eV(T_eV);
|
||||
|
||||
double E1_eV = T_eV-EionT2_eV - W_eV;
|
||||
|
||||
double phi1 = rngUni->random()*2*pi;
|
||||
double phi2 = phi1-pi;
|
||||
|
||||
double theta1 = roll_IonTheta1(T_eV, W_eV);
|
||||
double theta2 = roll_IonTheta2(T_eV, W_eV);
|
||||
|
||||
double v1Absnew_ms = calc_Speed_from_Ekin_eV(E1_eV, me_eV);
|
||||
double v2Absnew_ms = calc_Speed_from_Ekin_eV(W_eV, me_eV);
|
||||
|
||||
vec3 P1newDir, P2newDir, v1New_ms, v2New_ms ;
|
||||
P1newDir = calc_newDirection(v_ms, theta1, phi1);
|
||||
P2newDir = calc_newDirection(v_ms, theta2, phi2);
|
||||
|
||||
vec3 vOff_ms = vLab_ms - v_ms;
|
||||
v1New_ms = v1Absnew_ms*P1newDir + vOff_ms;
|
||||
v2New_ms = v2Absnew_ms*P2newDir + vOff_ms;
|
||||
|
||||
interPart->set_Speed_ms(v1New_ms);
|
||||
|
||||
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_Analytic::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);
|
||||
}
|
||||
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) {
|
||||
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_Analytic::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);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
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();
|
||||
|
||||
double T_eV = calc_Ekin_eV_from_speed(v_ms, me_eV);
|
||||
if (T_eV < EionT2_eV) {
|
||||
throw MyException("Electron::do_Ionization: Ekin_eV < EIonT2_eV.");
|
||||
}
|
||||
double W_eV = roll_ionW_eV(T_eV);
|
||||
|
||||
double E1_eV = T_eV-EionT2_eV - W_eV;
|
||||
|
||||
double phi1 = rngUni->random()*2*pi;
|
||||
double phi2 = phi1-pi;
|
||||
|
||||
double theta1 = roll_IonTheta1(T_eV, W_eV);
|
||||
double theta2 = roll_IonTheta2(T_eV, W_eV);
|
||||
|
||||
double v1Absnew_ms = calc_Speed_from_Ekin_eV(E1_eV, me_eV);
|
||||
double v2Absnew_ms = calc_Speed_from_Ekin_eV(W_eV, me_eV);
|
||||
|
||||
vec3 P1newDir, P2newDir, v1New_ms, v2New_ms ;
|
||||
P1newDir = calc_newDirection(v_ms, theta1, phi1);
|
||||
P2newDir = calc_newDirection(v_ms, theta2, phi2);
|
||||
|
||||
vec3 vOff_ms = vLab_ms - v_ms;
|
||||
v1New_ms = v1Absnew_ms*P1newDir + vOff_ms;
|
||||
v2New_ms = v2Absnew_ms*P2newDir + vOff_ms;
|
||||
|
||||
interPart->set_Speed_ms(v1New_ms);
|
||||
|
||||
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);
|
||||
}
|
||||
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 */
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// e_T2I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef e_T2I_recombination_h
|
||||
#define e_T2I_recombination_h
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "tcs_container.hpp"
|
||||
#include "janev_eT2I_recombination.h"
|
||||
|
||||
class eT2I_Recombination : public Sub_Interaction_Base {
|
||||
|
||||
|
||||
public:
|
||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : Sub_Interaction_Base(T2IPopulation, rngUni) {}
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart);
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline double eT2I_Recombination::get_macroSigma_m2(const Particle &interPart) {
|
||||
double Ekin_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = Janev_eT2_Recombination::get_TCS(Ekin_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2I_m3 = Population->get_density_m3(loc_m);
|
||||
return (microSigma_m2*nT2I_m3);
|
||||
}
|
||||
|
||||
inline InteractionOut eT2I_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
res.set_delete_location(interPart->get_Location_m());
|
||||
// Maybe add the 2 T atoms.
|
||||
return(res);
|
||||
}
|
||||
#endif /* e_T2I_recombination_h */
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// electron_boris.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_boris_h
|
||||
#define electron_boris_h
|
||||
|
||||
#include "mover_base.h"
|
||||
|
||||
|
||||
class E_Mover_Boris : public Mover_Base {
|
||||
double dt_s;
|
||||
public:
|
||||
E_Mover_Boris(double dt_s, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(electron, Logger, Population) {
|
||||
this->dt_s = dt_s;
|
||||
};
|
||||
|
||||
void move(Particle *movePart, const double &distance_m);
|
||||
|
||||
private:
|
||||
double doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T);
|
||||
void doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T);
|
||||
bool doBoris_WallInteraction(Particle *movePart);
|
||||
void doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m);
|
||||
};
|
||||
|
||||
void E_Mover_Boris::move(Particle *movePart, const double &distance_m) {
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_Location_m();
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_Location_m();
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(movePart, E_Vm, B_T);
|
||||
if (doBoris_WallInteraction(movePart) == true) {
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(movePart, &oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double E_Mover_Boris::doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T) {
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_Location_m();
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * vec3Abs(v_ms);
|
||||
doBoris_speedChange(movePart, E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * vec3Abs(v_ms);
|
||||
movePart->set_Location_m(x_m);
|
||||
return(distance_m);
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Charge_nat() * e_C;
|
||||
double m_kg = movePart->get_Mass_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_Speed_ms(v_ms);
|
||||
}
|
||||
|
||||
bool E_Mover_Boris::doBoris_WallInteraction(Particle *movePart) {
|
||||
vec3 loc_m = movePart->get_Location_m();
|
||||
double r_m = movePart->get_Radius_m();
|
||||
if (loc_m[2]<=Katrin_Geo::get_z_RW_m()) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_Location_m(newLoc_m);
|
||||
return (true);
|
||||
}
|
||||
if (r_m>=Katrin_Geo::get_radius_m()) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (Katrin_Geo::get_radius_m() * 1.01)/vec3Abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return (true);
|
||||
}
|
||||
if (loc_m[2]>=Katrin_Geo::get_z_WGTSend_m()) { // Spectrometer Reflection
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_Location_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif /* electron_boris_h */
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// electron_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_drift_h
|
||||
#define electron_drift_h
|
||||
|
||||
#include "drift_base.h"
|
||||
|
||||
|
||||
class E_Mover_Drift : public Drift_Base {
|
||||
public:
|
||||
E_Mover_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : Drift_Base(electron, Logger, Population) {};
|
||||
protected:
|
||||
void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m);
|
||||
};
|
||||
|
||||
void E_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= Katrin_Geo::get_z_WGTSend_m()) { // Moveing into Spectrometer and reversing Speed.
|
||||
vec3 reverseLoc_m = *oldLoc_m;
|
||||
|
||||
// Log Movement before Reflection
|
||||
reverseLoc_m[2] = Katrin_Geo::get_z_WGTSend_m();
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
|
||||
// Final Movement
|
||||
*oldLoc_m = reverseLoc_m;
|
||||
*znew_m = Katrin_Geo::get_z_WGTSend_m() - (*znew_m - Katrin_Geo::get_z_WGTSend_m());
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
if (*znew_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_RW_m();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* electron_drift_h */
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// electron_population.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 17.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_population_h
|
||||
#define electron_population_h
|
||||
|
||||
|
||||
#include "energeticPop_container.hpp"
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
#include "constants.h"
|
||||
|
||||
|
||||
class E_Population : public Population_Base, public RNG_Base {
|
||||
EnergeticPop_Container e_Container;
|
||||
Timer *Tim;
|
||||
|
||||
public:
|
||||
E_Population(Timer *Tim, UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(electron), RNG_Base(rngUni, rngNormal), e_Container(vec3(10,10,10), 2e4, 20) {
|
||||
this->Tim = Tim;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double get_density_m3 (const vec3 &loc_m);
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &oldLoc_m) {};
|
||||
|
||||
vec3 get_average_speed_ms (const vec3 &loc_m);
|
||||
vec3 roll_speed_ms (const vec3 &loc_m);
|
||||
};
|
||||
|
||||
|
||||
inline double E_Population::get_density_m3(const vec3 &loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
double physTime_s = Tim->get_physTime_s();
|
||||
double dens = e_Container.getDensity_m3(loc_m, physTime_s);
|
||||
return(dens);
|
||||
}
|
||||
|
||||
inline void E_Population::increase_density(const Particle &upPart, const vec3 &oldLoc_m) {
|
||||
e_Container.upDensity(upPart, oldLoc_m);
|
||||
}
|
||||
|
||||
|
||||
inline vec3 E_Population::get_average_speed_ms(const vec3 &loc_m) {
|
||||
return (vec3(0,0,0));
|
||||
}
|
||||
|
||||
inline vec3 E_Population::roll_speed_ms(const vec3 &loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
double E_eV = e_Container.roll_Energy_eV(loc_m, rngUni);
|
||||
double vAbs_ms = calc_Speed_from_Ekin_eV(E_eV, me_eV);
|
||||
vec3 v_ms = roll_uniform_direction(rngUni) * vAbs_ms;
|
||||
return(v_ms);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* electron_population_h */
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// E_Terminator.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef E_Terminator_h
|
||||
#define E_Terminator_h
|
||||
|
||||
#include "terminator_base.h"
|
||||
|
||||
|
||||
class E_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
||||
|
||||
public:
|
||||
E_Terminator(const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(electron), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
||||
|
||||
bool checkTermination (const Particle &movePart);
|
||||
private:
|
||||
bool check_Wall(const Particle &movePart);
|
||||
};
|
||||
|
||||
|
||||
inline bool E_Terminator::checkTermination (const Particle &movePart) {
|
||||
if (check_Wall(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_Energy(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_MaxInteractions(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
inline bool E_Terminator::check_Wall(const Particle &movePart) {
|
||||
vec3 loc_m = movePart.get_Location_m();
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (r_m >= Katrin_Geo::get_radius_m()) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
#endif /* E_Terminator_h */
|
||||
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// energeticPop_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "energeticPop_container.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void EnergeticPop_Container::set_Map() {
|
||||
vector<vec3> bins = get_bins();
|
||||
double Ex_min = floor(log10(1e-3));
|
||||
double Ex_max = ceil(log10(E_max_eV));
|
||||
double step = (Ex_max-Ex_min)/Epoints;
|
||||
double x, E_eV;
|
||||
for (vector<vec3>::iterator Itr = bins.begin(); Itr!=bins.end(); Itr++) {
|
||||
for (int i = 1; i<=Epoints; i++) {
|
||||
x = Ex_min + step*i;
|
||||
E_eV = pow(10,x);
|
||||
addPoint(deque<double>{(*Itr)[0], (*Itr)[1], (*Itr)[2], E_eV, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double EnergeticPop_Container::getDensity_m3(const vec3 &locXYZ_m, double physTime_s) {
|
||||
check_In_Container(locXYZ_m, xyz);
|
||||
vec3 zrphiCords = transformTo_zrphiCords(locXYZ_m, xyz);
|
||||
double V_m3 = get_V_m3(zrphiCords[1]);
|
||||
double cumTime_s = get_cumulativeTime_s(zrphiCords);
|
||||
return (cumTime_s/physTime_s/V_m3);
|
||||
}
|
||||
|
||||
double EnergeticPop_Container::get_cumulativeTime_s(vec3 zrphiCords) {
|
||||
dim1Map EMap = *getSubMap<dim1Map>(ddeque{zrphiCords[0], zrphiCords[1], zrphiCords[2]}, Lower_bound);
|
||||
double cumTime_s = 0;
|
||||
for (dim1Map::iterator Itr = EMap.begin(); Itr != EMap.end(); Itr++) {
|
||||
cumTime_s +=Itr->second;
|
||||
}
|
||||
return(cumTime_s);
|
||||
}
|
||||
|
||||
|
||||
void EnergeticPop_Container::upDensity (const Particle &upParticle, const vec3 &oldLocXYZ_m) {
|
||||
check_In_Container(oldLocXYZ_m, xyz);
|
||||
vec3 zrphiOld_m = transformTo_zrphiCords(oldLocXYZ_m, xyz);
|
||||
vec3 zrphiNew_m = upParticle.get_Location_m();
|
||||
check_In_Container(zrphiNew_m, zrphi);
|
||||
// Check r and phi not changing, only valid for drift approximation....
|
||||
|
||||
double z_min_m = zrphiOld_m[0];
|
||||
double z_max_m = zrphiNew_m[0];
|
||||
if (z_max_m<z_min_m) {
|
||||
swap (z_min_m, z_max_m);
|
||||
}
|
||||
double r_m = zrphiOld_m[1];
|
||||
double phi = zrphiOld_m[2];
|
||||
double l_m = get_l_m();
|
||||
double vAbs_ms = upParticle.get_SpeedAbs_ms();
|
||||
double E_eV = upParticle.get_EKin_eV();
|
||||
|
||||
dim4Map::iterator zItr_min = Map.lower_bound(z_min_m);
|
||||
dim4Map::iterator zItr_max = Map.lower_bound(z_max_m);
|
||||
|
||||
for (dim4Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||
Itr->second.lower_bound(r_m)->second.lower_bound(phi)->second.lower_bound(E_eV)->second += l_m/vAbs_ms;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double EnergeticPop_Container::roll_Energy_eV(const vec3 &locXYZ_m, UniRNG *rngUni) {
|
||||
check_In_Container(locXYZ_m, xyz);
|
||||
|
||||
vec3 zrphiCords = transformTo_zrphiCords(locXYZ_m, xyz);
|
||||
dim1Map EMap = *getSubMap<dim1Map>(ddeque{locXYZ_m[0], locXYZ_m[1], locXYZ_m[2]}, Lower_bound);
|
||||
|
||||
double targetTime_s = rngUni->random() * get_cumulativeTime_s(zrphiCords);
|
||||
double summedTime_s = 0;
|
||||
dim1Map::iterator Itr = EMap.begin();
|
||||
do {
|
||||
summedTime_s += Itr->second;
|
||||
Itr++;
|
||||
} while(summedTime_s < targetTime_s);
|
||||
Itr--;
|
||||
|
||||
if (Itr == EMap.begin() ) {
|
||||
return (Itr->first);
|
||||
} else {
|
||||
double E_eV = ( (Itr->first) + ((--Itr)->first) )/2;
|
||||
return (E_eV);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// energeticPop_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef energeticPop_container_hpp
|
||||
#define energeticPop_container_hpp
|
||||
|
||||
#include "zylindric_cords.h"
|
||||
#include "particle.hpp"
|
||||
#include "random_operations.h"
|
||||
|
||||
class EnergeticPop_Container : private Base_Container<dim4Map>, private Zylindric_Cords {
|
||||
double E_max_eV;
|
||||
double Epoints;
|
||||
|
||||
public:
|
||||
EnergeticPop_Container(vec3 zrphi_numBins, double E_max_eV, double Epoints) : Zylindric_Cords(zrphi_numBins) {
|
||||
this->E_max_eV = E_max_eV;
|
||||
this->Epoints = Epoints;
|
||||
set_Map();
|
||||
}
|
||||
private:
|
||||
void set_Map();
|
||||
|
||||
public:
|
||||
double getDensity_m3(const vec3 &locXYZ_m, double physTime_s) ;
|
||||
private:
|
||||
double get_cumulativeTime_s(vec3 zrphiCords);
|
||||
|
||||
public:
|
||||
void upDensity (const Particle &upParticle, const vec3 &oldLocXYZ_m) ;
|
||||
|
||||
public:
|
||||
double roll_Energy_eV(const vec3 &locXYZ_m, UniRNG *rngUni) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* energeticPop_container_hpp */
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// h5_file.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "h5_file.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
H5_File::H5_File() {
|
||||
create();
|
||||
h5p = H5_Particles(&h5_file);
|
||||
}
|
||||
|
||||
void H5_File::create() {
|
||||
const string constH5Name = getFileName();
|
||||
h5_file = H5Fcreate(constH5Name.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
|
||||
std::string H5_File::getFileName() {
|
||||
string parname = getparName();
|
||||
stringstream H5name;
|
||||
int i = 1;
|
||||
do {
|
||||
H5name.str(std::string());
|
||||
H5name << parname << "_" << getTimeString() << "_" << i++<<".h5";
|
||||
} while ( isFile(H5name.str()) );
|
||||
return (H5name.str());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// h5_file.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef h5_file_hpp
|
||||
#define h5_file_hpp
|
||||
|
||||
#include "h5_particles.h"
|
||||
|
||||
|
||||
class H5_File {
|
||||
hid_t h5_file;
|
||||
H5_Particles h5p;
|
||||
|
||||
public:
|
||||
H5_File();
|
||||
H5_Particles *get_h5p() {return(&h5p);}
|
||||
private:
|
||||
void create();
|
||||
std::string getFileName();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* h5_file_hpp */
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// h5_particles.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef h5_particles_h
|
||||
#define h5_particles_h
|
||||
|
||||
#include "read_system.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "hdf5_hl.h"
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
class H5_Particles {
|
||||
int numberZBins;
|
||||
bool logging;
|
||||
double *zValues;
|
||||
|
||||
|
||||
hid_t *h5_file;
|
||||
hid_t *h5g_particles;
|
||||
hid_t *h5g_z;
|
||||
|
||||
public:
|
||||
H5_Particles() {};
|
||||
H5_Particles(hid_t *h5_file);
|
||||
|
||||
int get_numberZBins() {return(numberZBins);}
|
||||
bool get_logging() {return(logging);}
|
||||
double *get_zValues() {return(zValues);}
|
||||
hid_t *get_h5g_z() {return(h5g_z);}
|
||||
|
||||
|
||||
private:
|
||||
void set_logging();
|
||||
void set_zValues();
|
||||
void print_logInfo();
|
||||
|
||||
void create_h5gs();
|
||||
};
|
||||
|
||||
inline H5_Particles::H5_Particles(hid_t *h5_file) {
|
||||
this->h5_file = h5_file;
|
||||
numberZBins = getParameter("numberZBins");
|
||||
set_logging();
|
||||
set_zValues();
|
||||
print_logInfo();
|
||||
|
||||
create_h5gs();
|
||||
}
|
||||
|
||||
|
||||
inline void H5_Particles::set_logging() {
|
||||
if (numberZBins == 0) {
|
||||
logging = false;
|
||||
} else if (numberZBins == -1 || numberZBins > 0){
|
||||
logging = true;
|
||||
} else {
|
||||
std::stringstream ss;
|
||||
ss<<"H5_Logger::Parameter numberZBins invalid value.\nnumberZBins:\t"<<numberZBins<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
inline void H5_Particles::set_zValues() {
|
||||
if (logging) {
|
||||
zValues = new double[numberZBins];
|
||||
double start_m = Katrin_Geo::get_z_RW_m();
|
||||
double length_m = Katrin_Geo::get_z_WGTSend_m() - start_m;
|
||||
double stepLength_m = length_m/(numberZBins-1);
|
||||
double z_m;
|
||||
for (int i = 0;i<numberZBins;i++) {
|
||||
z_m = start_m + stepLength_m*i;
|
||||
zValues[i] = z_m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void H5_Particles::print_logInfo() {
|
||||
std::stringstream ss;
|
||||
ss<<"Logger\t ";
|
||||
if (!logging) {
|
||||
ss<<"Logging disabled.\n";
|
||||
} else if (numberZBins == -1) {
|
||||
ss<<"Logging after every Interaction to one file.\n";
|
||||
} else if (numberZBins == 1) {
|
||||
ss<<"Only Logging Rearwall Output.\n";
|
||||
} else {
|
||||
ss<<"Logging at "<<numberZBins<<" z values.\n";
|
||||
}
|
||||
std::cout<<ss.str();
|
||||
}
|
||||
|
||||
inline void H5_Particles::create_h5gs() {
|
||||
h5g_particles = new hid_t;
|
||||
*h5g_particles = H5Gcreate(*h5_file, "/Particles", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
if (numberZBins == -1) {
|
||||
h5g_z = new hid_t[1];
|
||||
h5g_z[0] = H5Gcreate(*h5_file, "/Particles/z=all", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
} else {
|
||||
h5g_z = new hid_t [numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "/Particles/" << zValues[i];
|
||||
h5g_z[i] = H5Gcreate2(*h5_file, ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* h5_particles_h */
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// h5tb_interface.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include <sstream>
|
||||
#include "h5tb_interface.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
|
||||
const size_t H5TB_Interface::size = sizeof(logParticle);
|
||||
const char *H5TB_Interface::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
|
||||
const size_t H5TB_Interface::offset[8] = {
|
||||
HOFFSET(logParticle, Id),
|
||||
HOFFSET(logParticle, parentId),
|
||||
HOFFSET(logParticle, x_m),
|
||||
HOFFSET(logParticle, y_m),
|
||||
HOFFSET(logParticle, z_m),
|
||||
HOFFSET(logParticle, vx_ms),
|
||||
HOFFSET(logParticle, vy_ms),
|
||||
HOFFSET(logParticle, vz_ms)};
|
||||
const hid_t H5TB_Interface::fieldTypes[8] = {
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_INT,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE,
|
||||
H5T_NATIVE_DOUBLE};
|
||||
const hsize_t H5TB_Interface::chunkSize = 4096;
|
||||
const size_t H5TB_Interface::sizes[8] = {
|
||||
sizeof( samplelogParticle.Id),
|
||||
sizeof( samplelogParticle.parentId),
|
||||
sizeof( samplelogParticle.x_m),
|
||||
sizeof( samplelogParticle.y_m),
|
||||
sizeof( samplelogParticle.z_m),
|
||||
sizeof( samplelogParticle.vx_ms),
|
||||
sizeof( samplelogParticle.vy_ms),
|
||||
sizeof( samplelogParticle.vz_ms)};
|
||||
|
||||
|
||||
void H5TB_Interface::create() {
|
||||
herr_t state = H5TBmake_table(tableName.c_str(), *loc_id, tableName.c_str(), 8, 0,
|
||||
size, fieldNames, offset, fieldTypes,
|
||||
chunkSize, NULL, 0, NULL);
|
||||
if (state < 0) {
|
||||
stringstream ss;
|
||||
ss<<"H5TB_Interface::create: Error creating.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void H5TB_Interface::write(const Particle &logPart) {
|
||||
logParticle logParticle_buffer = transform(logPart);
|
||||
// Maybe add real buffer here....
|
||||
H5TBappend_records(*loc_id, tableName.c_str() , 1, size, offset, sizes, &logParticle_buffer );
|
||||
}
|
||||
|
||||
loggerParticle H5TB_Interface::transform(const Particle &logPart) {
|
||||
logParticle res;
|
||||
res.Id = logPart.get_Id();
|
||||
res.parentId = logPart.get_ParentId();
|
||||
res.x_m = logPart.get_Location_m()[0];
|
||||
res.y_m = logPart.get_Location_m()[1];
|
||||
res.z_m = logPart.get_Location_m()[2];
|
||||
res.vx_ms = logPart.get_Speed_ms()[0];
|
||||
res.vy_ms = logPart.get_Speed_ms()[1];
|
||||
res.vz_ms = logPart.get_Speed_ms()[2];
|
||||
return (res);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// h5tb_interface.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef h5tb_interface_hpp
|
||||
#define h5tb_interface_hpp
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "hdf5_hl.h"
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
typedef struct loggerParticle {
|
||||
unsigned int Id;
|
||||
unsigned int parentId;
|
||||
double x_m;
|
||||
double y_m;
|
||||
double z_m;
|
||||
double vx_ms;
|
||||
double vy_ms;
|
||||
double vz_ms;
|
||||
} logParticle;
|
||||
|
||||
|
||||
class H5TB_Interface {
|
||||
static const size_t size;
|
||||
static const char *fieldNames[8];
|
||||
static const size_t offset[8];
|
||||
static const hid_t fieldTypes[8];
|
||||
static const hsize_t chunkSize;
|
||||
static const size_t sizes[8];
|
||||
|
||||
std::string tableName;
|
||||
hid_t *loc_id;
|
||||
|
||||
public:
|
||||
H5TB_Interface() {};
|
||||
H5TB_Interface(const std::string &tableName, hid_t *loc_id) {
|
||||
this->tableName = tableName;
|
||||
this->loc_id = loc_id;
|
||||
create();
|
||||
}
|
||||
private:
|
||||
void create();
|
||||
|
||||
public:
|
||||
void write(const Particle &logPart);
|
||||
private:
|
||||
loggerParticle transform(const Particle &logPart);
|
||||
};
|
||||
|
||||
|
||||
#endif /* h5tb_interface_hpp */
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// hardsphere_elastic.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 08.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef hardsphere_elastic_h
|
||||
#define hardsphere_elastic_h
|
||||
|
||||
#include "random_operations.h"
|
||||
#include "constants.h"
|
||||
|
||||
|
||||
class Hardsphere_elasticScattering {
|
||||
double r_m;
|
||||
|
||||
public:
|
||||
Hardsphere_elasticScattering(double r_m) {this->r_m = r_m;}
|
||||
|
||||
double get_TCS() {return(4*pi*r_m*r_m);}
|
||||
double get_SDCS() {return(r_m*r_m);}
|
||||
|
||||
double roll_theta(UniRNG *rngUni) {return (pi*rngUni->random());}
|
||||
};
|
||||
|
||||
|
||||
#endif /* hardsphere_elastic_h */
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// janev_eT2I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef janev_eT2I_recombination_h
|
||||
#define janev_eT2I_recombination_h
|
||||
|
||||
#include <cmath>
|
||||
// Janev:2003aa "From Collision processes in low-temperature hydrogen plasmas" 7.1.3.A p.73 formular (185)
|
||||
|
||||
class Janev_eT2_Recombination {
|
||||
|
||||
public:
|
||||
Janev_eT2_Recombination() {}
|
||||
|
||||
static double get_TCS(const double &E_eV) {
|
||||
double const1 = pow( pow(E_eV,0.665) * ( 1 + 1.1*pow(E_eV,0.512) + 0.011*pow(E_eV,3.10) ) , - 1);
|
||||
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||
return (17.3e-20 * (const1+const2) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* janev_eT2I_recombination_h */
|
||||
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// kinematics_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 23.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef kinematics_base_h
|
||||
#define kinematics_base_h
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "error_types.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
// See http://www.lnl.infn.it/~pisolo/alberto/Kinematics.pdf
|
||||
|
||||
class Elastic_Kinematic_Base {
|
||||
double m1_eV, m2_eV;
|
||||
double sign;
|
||||
double const1, const2;
|
||||
|
||||
public:
|
||||
Elastic_Kinematic_Base() {};
|
||||
Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV);
|
||||
|
||||
void doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab);
|
||||
};
|
||||
|
||||
inline Elastic_Kinematic_Base::Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV) {
|
||||
this->m1_eV = m1_eV;
|
||||
this->m2_eV = m2_eV;
|
||||
sign = (m1_eV < m2_eV) ? 1 : -1;
|
||||
const1 = m1_eV*m1_eV/pow(m1_eV + m2_eV,2);
|
||||
const2 = pow(m2_eV/m1_eV,2);
|
||||
}
|
||||
|
||||
inline void Elastic_Kinematic_Base::doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab) {
|
||||
vec3 v1_ms = P1->get_Speed_ms() - v2_lab_ms;
|
||||
|
||||
double E0_eV = calc_Ekin_eV_from_speed(v1_ms, m1_eV);
|
||||
double inner_sqrt = pow( const2 - pow(sin(theta_lab),2) , 0.5 );
|
||||
double E1_eV = E0_eV * const1 * pow(cos(theta_lab) + sign*inner_sqrt , 2);
|
||||
|
||||
double v1Abs_new_ms = calc_Speed_from_Ekin_eV(E1_eV, m1_eV);
|
||||
vec3 n0 = calc_newDirection(v1_ms, theta_lab, phi_lab);
|
||||
vec3 v1_new_ms = n0 * v1Abs_new_ms + v2_lab_ms;
|
||||
P1->set_Speed_ms(v1_new_ms);
|
||||
}
|
||||
|
||||
|
||||
class Inelastic_Kinematic_Base {
|
||||
double Q_eV;
|
||||
double m1_eV, m2_eV;
|
||||
|
||||
double a, b, c, d;
|
||||
|
||||
public:
|
||||
Inelastic_Kinematic_Base();
|
||||
Inelastic_Kinematic_Base(const double &Q_eV, const double &m1_eV, const double &m2_eV);
|
||||
|
||||
void doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab);
|
||||
|
||||
private:
|
||||
double ET_eV(const double &E1_eV) {return (E1_eV + Q_eV);}
|
||||
double A (const double &E1_eV) {return (a*E1_eV/(E1_eV-Q_eV));}
|
||||
double B (const double &E1_eV) {return (b*E1_eV/(E1_eV-Q_eV));}
|
||||
double temp_cd(const double &E1_eV) {return (1 + m1_eV*Q_eV/m2_eV/(E1_eV-Q_eV));}
|
||||
double C (const double &E1_eV) {return (c*temp_cd(E1_eV));}
|
||||
double D (const double &E1_eV) {return (d*temp_cd(E1_eV));}
|
||||
};
|
||||
|
||||
inline Inelastic_Kinematic_Base::Inelastic_Kinematic_Base(const double &Q_eV, const double &m1_eV, const double &m2_eV) {
|
||||
this->Q_eV = Q_eV;
|
||||
if (Q_eV<=0) {
|
||||
std::stringstream ss;
|
||||
ss<<"Inelastic_Kinematics_Base: Q_eV<=0.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
this->m1_eV = m1_eV;
|
||||
this->m2_eV = m2_eV;
|
||||
if (m1_eV > m2_eV) {
|
||||
std::stringstream ss;
|
||||
ss<<"Inelastic_Kinematics_Base: m1_eV > m2_eV.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
double c1 = pow(m1_eV+m2_eV,2);
|
||||
a = m1_eV*m2_eV/c1;
|
||||
b = m1_eV*m1_eV/c1;
|
||||
c = a;
|
||||
d = m2_eV*m2_eV/c1;
|
||||
};
|
||||
|
||||
|
||||
inline void Inelastic_Kinematic_Base::doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab) {
|
||||
vec3 v1_ms = P1->get_Speed_ms() - v2_lab_ms;
|
||||
|
||||
double E1_eV = calc_Ekin_eV_from_speed(v1_ms, m1_eV);
|
||||
double ET_eV = this->ET_eV(E1_eV);
|
||||
double B = this->B(E1_eV);
|
||||
double D = this->D(E1_eV);
|
||||
double sign = B>D ? -1 : 1;
|
||||
double inner_sqrt = pow( (D/B - pow(sin(theta_lab),2) ) , 0.5 );
|
||||
double E1_new_eV = ET_eV * B * pow( cos(theta_lab) +sign * inner_sqrt, 2);
|
||||
double v1Abs_new_ms = calc_Speed_from_Ekin_eV(E1_new_eV, m1_eV);
|
||||
vec3 n0 = calc_newDirection(v1_ms, theta_lab, phi_lab);
|
||||
vec3 v1_new_ms = n0 * v1Abs_new_ms + v2_lab_ms;
|
||||
P1->set_Speed_ms(v1_new_ms);
|
||||
}
|
||||
|
||||
|
||||
#endif /* kinematics_base_h */
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// linScale.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef linScale_h
|
||||
#define linScale_h
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
// Returnes index on linear scale. [0] is underflow bin. [number_bins] is highest bin and also functions as overflow bin.
|
||||
class Lin_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) {
|
||||
this->min_x = min_x;
|
||||
this->max_x = max_x;
|
||||
this->number_bins = number_bins; // = max_index
|
||||
if (number_bins<3) {
|
||||
std::stringstream ss;
|
||||
ss<<"Lin_Scale::Lin_Scale: Less than 2 bins not possible.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
delta_x = (max_x - min_x)/number_bins;
|
||||
}
|
||||
|
||||
int get_max_index() {return(number_bins);}
|
||||
int get_dimension() {return(number_bins + 1);}
|
||||
|
||||
int calc_index(const double &xI) {
|
||||
if (xI < min_x) {
|
||||
return (0);
|
||||
}
|
||||
if (xI > max_x) {
|
||||
return (number_bins);
|
||||
}
|
||||
return (std::ceil((xI-min_x)/delta_x));
|
||||
}
|
||||
|
||||
bool valid_index (const int &index) {
|
||||
if (index < 0 || index > number_bins) {
|
||||
return (false);
|
||||
} else {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
double calc_upper_bound(int index) {
|
||||
return (min_x + double(index) * delta_x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* linScale_h */
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// logScale.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef logScale_h
|
||||
#define logScale_h
|
||||
|
||||
#include "linScale.h"
|
||||
|
||||
|
||||
class Log_Scale : private Lin_Scale {
|
||||
public:
|
||||
Log_Scale() {};
|
||||
Log_Scale(double min_x, double max_x, int number_bins) : Lin_Scale(std::log10(min_x), std::log10(max_x), number_bins) {};
|
||||
|
||||
int get_max_index() {return(Lin_Scale::get_max_index());}
|
||||
int get_dimension() {return(Lin_Scale::get_dimension());}
|
||||
|
||||
|
||||
int calc_index(double xI) {
|
||||
double pI = std::log10(xI);
|
||||
return (Lin_Scale::calc_index(pI));
|
||||
}
|
||||
|
||||
double calc_upper_bound(int index) {
|
||||
double pI = Lin_Scale::calc_upper_bound(index);
|
||||
return (pow(10,pI));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* logScale_h */
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// logger_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "logger_builder.hpp"
|
||||
|
||||
#include "multiz_particle_logger.h"
|
||||
#include "sf_particle_logger.h"
|
||||
#include "off_particle_logger.h"
|
||||
|
||||
|
||||
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
||||
Particle_Logger_Manager ParticleLogger;
|
||||
H5_Particles *h5p = h5f->get_h5p();
|
||||
|
||||
ParticleLogger.add(build_eLogger(h5p));
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
||||
return (ParticleLogger);
|
||||
}
|
||||
|
||||
Particle_Logger_Base *Particle_Logger_Builder::build_eLogger(H5_Particles *h5p) {
|
||||
Particle_Logger_Base *res;
|
||||
if (h5p->get_logging() == false) {
|
||||
res = new Off_Particle_Logger(electron);
|
||||
} else if(h5p->get_numberZBins() == -1){
|
||||
res = new SF_Particle_Logger(electron, h5p->get_h5g_z());
|
||||
} else {
|
||||
res = new MuliZ_Particle_Logger(electron, h5p->get_numberZBins(), h5p->get_zValues(), h5p->get_h5g_z());
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// logger_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef logger_builder_hpp
|
||||
#define logger_builder_hpp
|
||||
|
||||
#include "h5_file.hpp"
|
||||
|
||||
#include "manager_base.h"
|
||||
|
||||
#include "particle_logger_base.h"
|
||||
|
||||
|
||||
typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
||||
|
||||
class Particle_Logger_Builder {
|
||||
|
||||
public:
|
||||
Particle_Logger_Builder() {};
|
||||
|
||||
static Particle_Logger_Manager build(H5_File *h5f);
|
||||
private:
|
||||
static Particle_Logger_Base *build_eLogger(H5_Particles *h5p);
|
||||
};
|
||||
|
||||
#endif /* logger_builder_hpp */
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// manager_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 17.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef manager_base_h
|
||||
#define manager_base_h
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
template <class T>
|
||||
class Manager_Base {
|
||||
private:
|
||||
std::vector<T*> Processes;
|
||||
|
||||
public:
|
||||
Manager_Base() {};
|
||||
|
||||
void add(T* addProc);
|
||||
bool exists(species this_species);
|
||||
T* find(species this_species);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline void Manager_Base<T>::add(T* add) {
|
||||
if (exists(add->get_species())) {
|
||||
std::stringstream ss;
|
||||
ss<<"Manager_Base::add_Process: Dublicate Insert of Process for this Species.";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
Processes.push_back(add);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Manager_Base<T>::exists(species this_species) {
|
||||
for (typename std::vector<T*>::iterator Itr = Processes.begin(); Itr!=Processes.end(); Itr++) {
|
||||
if ((*Itr)->get_species() == this_species) {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* Manager_Base<T>::find(species this_species) {
|
||||
for (typename std::vector<T*>::iterator Itr = Processes.begin(); Itr!=Processes.end(); Itr++) {
|
||||
if ((*Itr)->get_species() == this_species) {
|
||||
return (*Itr);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Manager_Base::find(): No Process for this_species implemented.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
|
||||
#endif /* manager_base_h */
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// mover_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef mover_base_h
|
||||
#define mover_base_h
|
||||
|
||||
#include "process_base.h"
|
||||
#include "katrin_geo.hpp"
|
||||
#include "katrin_fields.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
#include "particle_logger_base.h"
|
||||
|
||||
|
||||
class Mover_Base : public Process_Base {
|
||||
protected:
|
||||
Particle_Logger_Base *Logger;
|
||||
Population_Base *Population;
|
||||
|
||||
public:
|
||||
Mover_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Process_Base(this_species) {
|
||||
this->Logger = Logger;
|
||||
this->Population = Population;
|
||||
}
|
||||
|
||||
virtual void move(Particle *movePart, const double &distance_m) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* mover_base_h */
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// mover_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "mover_builder.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
#include "electron_drift.h"
|
||||
#include "electron_boris.h"
|
||||
#include "tritiumI_drift.h"
|
||||
#include "tritium2I_drift.h"
|
||||
|
||||
|
||||
const int Mover_Builder::propagationMethod = getParameter("propagationMethod");
|
||||
const double Mover_Builder::dt_s = getParameter("dt_s");
|
||||
|
||||
Mover_Manager Mover_Builder::build(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Mover_Manager Movers;
|
||||
Movers.add(build_electron(Loggers, Populations));
|
||||
Movers.add(build_tritiumI(Loggers, Populations));
|
||||
Movers.add(build_tritium2I(Loggers, Populations));
|
||||
return (Movers);
|
||||
}
|
||||
|
||||
|
||||
Mover_Base *Mover_Builder::build_electron(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Mover_Base *electron_Mover;
|
||||
Particle_Logger_Base *Logger = Loggers->find(electron);
|
||||
Population_Base *Popultation = Populations->find(electron);
|
||||
if (propagationMethod == 0) {
|
||||
electron_Mover = new E_Mover_Drift(Logger, Popultation);
|
||||
} else {
|
||||
electron_Mover = new E_Mover_Boris(dt_s, Logger, Popultation);
|
||||
}
|
||||
return (electron_Mover);
|
||||
}
|
||||
|
||||
Mover_Base *Mover_Builder::build_tritiumI(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritiumI);
|
||||
Population_Base *Popultation = Populations->find(tritiumI);
|
||||
return (new TI_Mover_Drift(Logger, Popultation));
|
||||
}
|
||||
|
||||
Mover_Base *Mover_Builder::build_tritium2I(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritium2I);
|
||||
Population_Base *Popultation = Populations->find(tritium2I);
|
||||
return (new T2I_Mover_Drift(Logger, Popultation));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// mover_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef mover_builder_hpp
|
||||
#define mover_builder_hpp
|
||||
|
||||
#include "manager_base.h"
|
||||
#include "mover_base.h"
|
||||
#include "logger_builder.hpp"
|
||||
#include "population_builder.hpp"
|
||||
|
||||
typedef Manager_Base<Mover_Base> Mover_Manager;
|
||||
|
||||
|
||||
class Mover_Builder {
|
||||
static const int propagationMethod;
|
||||
static const double dt_s;
|
||||
public:
|
||||
Mover_Builder() {};
|
||||
|
||||
static Mover_Manager build(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
private:
|
||||
static Mover_Base *build_electron(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
static Mover_Base *build_tritiumI(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
static Mover_Base *build_tritium2I(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* mover_builder_hpp */
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// multiz_particle_logger.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef multiz_particle_logger_h
|
||||
#define multiz_particle_logger_h
|
||||
|
||||
#include "particle_logger_base.h"
|
||||
|
||||
|
||||
class MuliZ_Particle_Logger : public Particle_Logger_Base {
|
||||
H5TB_Interface *h5tb;
|
||||
|
||||
int numberZBins;
|
||||
double *zLogValues;
|
||||
hid_t *h5g_z;
|
||||
|
||||
public:
|
||||
MuliZ_Particle_Logger(species this_species, const int &numberZBins, double *zLogValues, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
||||
this->numberZBins = numberZBins;
|
||||
this->zLogValues = zLogValues;
|
||||
this->h5g_z = h5g_z;
|
||||
create();
|
||||
}
|
||||
private:
|
||||
void create();
|
||||
|
||||
public:
|
||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||
};
|
||||
|
||||
|
||||
inline void MuliZ_Particle_Logger::create() {
|
||||
std::string speciesName = get_species_string(get_species());
|
||||
if (numberZBins < 1) {
|
||||
std::stringstream ss;
|
||||
ss<<"MuliZ_Particle_Logger::create: numberZBins < 1.\n";
|
||||
}
|
||||
h5tb = new H5TB_Interface[numberZBins];
|
||||
for (int i = 0; i < numberZBins; i++) {
|
||||
h5tb[i] = H5TB_Interface(speciesName, &h5g_z[i]);
|
||||
}
|
||||
}
|
||||
|
||||
inline void MuliZ_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
||||
double zold = oldLoc_m[2];
|
||||
double znew = logPart.get_Location_m()[2];
|
||||
double zmin = std::min(zold,znew);
|
||||
double zmax = std::max(zold,znew);
|
||||
for (int i=0;i<numberZBins;i++) {
|
||||
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
|
||||
h5tb[i].write(logPart); // Location wrong, because set to new Location, instead of logging location.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* multiz_particle_logger_h */
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// off_particle_logger.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef off_particle_logger_h
|
||||
#define off_particle_logger_h
|
||||
|
||||
|
||||
class Off_Particle_Logger : public Particle_Logger_Base {
|
||||
public:
|
||||
Off_Particle_Logger(species this_species) : Particle_Logger_Base(this_species) {};
|
||||
void log(const Particle &logPart, const vec3 &oldLoc_m) {};
|
||||
};
|
||||
|
||||
|
||||
#endif /* off_particle_logger_h */
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// particle_logger_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef particle_logger_base_h
|
||||
#define particle_logger_base_h
|
||||
|
||||
#include "h5tb_interface.hpp"
|
||||
#include "process_base.h"
|
||||
|
||||
class Particle_Logger_Base : public Process_Base {
|
||||
public:
|
||||
Particle_Logger_Base(species this_species) : Process_Base(this_species) {};
|
||||
virtual void log(const Particle &logPart, const vec3 &oldLoc_m) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* particle_logger_base_h */
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// population3_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "population3_container.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Pop3_Container::~Pop3_Container() {
|
||||
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
data = new double **[num_z_bins+1];
|
||||
for (int i = 0; i <= num_z_bins; i++)
|
||||
{
|
||||
data[i] = new double *[num_r_bins+1];
|
||||
for(int j = 0; j<=num_r_bins; j++)
|
||||
data[i][j] = new double[num_phi_bins+1];
|
||||
}
|
||||
for (int i = 0; i<=num_z_bins; i++) {
|
||||
for (int j = 0; j<=num_r_bins; j++) {
|
||||
for (int k = 0; k<=num_phi_bins; k++) {
|
||||
data[i][j][k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void Pop3_Container::increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m) {
|
||||
double z_min_m = get_z_m(loc1_m);
|
||||
double z_max_m = get_z_m(loc2_m);
|
||||
if (z_max_m < z_min_m) {
|
||||
swap(z_min_m, z_max_m);
|
||||
}
|
||||
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));
|
||||
|
||||
for (int i = min_z_index; i<max_z_index; i++) {
|
||||
data[i][rbin][phibin] += value;
|
||||
}
|
||||
}
|
||||
|
||||
double Pop3_Container::get_value (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));
|
||||
return (data[zbin][rbin][phibin]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// population3_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef population3_container_hpp
|
||||
#define population3_container_hpp
|
||||
|
||||
#include "linScale.h"
|
||||
#include "katrin_geo.hpp"
|
||||
#include "timer.hpp"
|
||||
|
||||
class Pop3_Container {
|
||||
double ***data;
|
||||
Lin_Scale z_scale;
|
||||
Lin_Scale r_scale;
|
||||
Lin_Scale phi_scale;
|
||||
|
||||
public:
|
||||
~Pop3_Container();
|
||||
Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins);
|
||||
void increase_value(const double &value, const vec3 &loc_m);
|
||||
void increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m);
|
||||
double get_value (vec3 loc_m);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* population3_container_hpp */
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// population_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef population_base_h
|
||||
#define population_base_h
|
||||
|
||||
#include "timer.hpp"
|
||||
#include "random_operations.h"
|
||||
|
||||
#include "error_types.h"
|
||||
#include "read_system.h"
|
||||
#include "kinematics.h"
|
||||
#include "process_base.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
|
||||
|
||||
class Population_Base : public Process_Base {
|
||||
|
||||
public:
|
||||
Population_Base(species this_species) : Process_Base(this_species) {};
|
||||
|
||||
virtual double get_density_m3 (const vec3 &loc_m) = 0;
|
||||
virtual void increase_density (const Particle &upPart, const vec3 &oldLoc_m) = 0;
|
||||
virtual void decrease_denisty (const vec3 &oldLoc_m) = 0;
|
||||
|
||||
virtual vec3 get_average_speed_ms (const vec3 &loc_m) = 0;
|
||||
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* population_base_h */
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// process_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef process_base_h
|
||||
#define process_base_h
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
class Process_Base {
|
||||
species this_species;
|
||||
|
||||
public:
|
||||
Process_Base(species this_species) {
|
||||
this->this_species = this_species;
|
||||
}
|
||||
|
||||
species get_species() {return(this_species); }
|
||||
|
||||
void check (const species &check_species) {
|
||||
if (check_species != this_species) {
|
||||
std::stringstream ss;
|
||||
ss<<"Process_Base::check this_species missmatch.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* process_base_h */
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// sf_particle_logger.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef sf_particle_logger_h
|
||||
#define sf_particle_logger_h
|
||||
|
||||
#include "particle_logger_base.h"
|
||||
|
||||
|
||||
class SF_Particle_Logger : public Particle_Logger_Base {
|
||||
hid_t *h5g_z;
|
||||
|
||||
H5TB_Interface h5tb;
|
||||
|
||||
public:
|
||||
SF_Particle_Logger(species this_species, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
||||
this->h5g_z = h5g_z;
|
||||
create();
|
||||
}
|
||||
|
||||
private:
|
||||
void create();
|
||||
|
||||
public:
|
||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||
};
|
||||
|
||||
|
||||
inline void SF_Particle_Logger::create() {
|
||||
std::string speciesName = get_species_string(get_species());
|
||||
h5tb = H5TB_Interface(speciesName, h5g_z);
|
||||
}
|
||||
|
||||
inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
||||
h5tb.write(logPart);
|
||||
}
|
||||
|
||||
|
||||
#endif /* sf_particle_logger_h */
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// sub_interaction_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef sub_interaction_base_h
|
||||
#define sub_interaction_base_h
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "population_base.h"
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
class InteractionOut {
|
||||
bool delete_current;
|
||||
|
||||
Particle new_particles[3];
|
||||
int number_new_particles;
|
||||
bool decrease_density;
|
||||
vec3 delete_location;
|
||||
|
||||
public:
|
||||
InteractionOut() {reset();};
|
||||
|
||||
void reset() {
|
||||
delete_current = false;
|
||||
number_new_particles = 0;
|
||||
decrease_density = false;
|
||||
}
|
||||
|
||||
void set_delete_current(const bool &delete_current) {this->delete_current = 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);}
|
||||
};
|
||||
|
||||
|
||||
class Sub_Interaction_Base {
|
||||
protected:
|
||||
Population_Base *Population;
|
||||
UniRNG *rngUni;
|
||||
|
||||
public:
|
||||
Sub_Interaction_Base(Population_Base *Population, UniRNG *rngUni) {
|
||||
this->Population = Population;
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
|
||||
virtual double get_macroSigma_m2(const Particle &interPart) = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* sub_interaction_base_h */
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// tcs_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "tcs_container.hpp"
|
||||
|
||||
|
||||
|
||||
double TCS_Container::get_value(double E_eV) {
|
||||
int index = E_scale.calc_index(E_eV);
|
||||
return (data[index]);
|
||||
}
|
||||
|
||||
void TCS_Container::calc_data(const std::string &load_path) {
|
||||
int dimension = E_scale.get_dimension();
|
||||
data = new double[dimension];
|
||||
Edge_Container<dim1Map> E1D(load_path);
|
||||
for (int i=0; i<dimension; i++) {
|
||||
data[i] = calc_bin_value(i, &E1D);
|
||||
}
|
||||
}
|
||||
|
||||
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}) );
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// tcs_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tcs_container_hpp
|
||||
#define tcs_container_hpp
|
||||
|
||||
#include "logScale.h"
|
||||
#include "edge_container.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
class TCS_Container {
|
||||
double *data;
|
||||
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.
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// terminator_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef terminator_base_h
|
||||
#define terminator_base_h
|
||||
|
||||
#include "process_base.h"
|
||||
#include "particle.hpp"
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
class Terminator_Base : public Process_Base {
|
||||
public:
|
||||
Terminator_Base(species this_species) : Process_Base(this_species) {};
|
||||
virtual bool checkTermination (const Particle &movePart) = 0;
|
||||
};
|
||||
|
||||
|
||||
class MaxInteractions_Terminator_Base {
|
||||
int maxInteractions;
|
||||
|
||||
int interactionsCount = 0;
|
||||
int curId = 0;
|
||||
|
||||
public:
|
||||
MaxInteractions_Terminator_Base(const int &maxInteractions) {
|
||||
this->maxInteractions = maxInteractions;
|
||||
}
|
||||
protected:
|
||||
bool check_MaxInteractions(const Particle &movePart) {
|
||||
int Id = movePart.get_Id();
|
||||
if (Id != curId) {
|
||||
curId = Id;
|
||||
interactionsCount = 0;
|
||||
}
|
||||
interactionsCount +=1;
|
||||
if (interactionsCount >= maxInteractions) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Energy_Terminator_Base {
|
||||
double cutoffEnergy_eV;
|
||||
|
||||
public:
|
||||
Energy_Terminator_Base(const double &cutoffEnergy_eV) {
|
||||
this->cutoffEnergy_eV = cutoffEnergy_eV;
|
||||
}
|
||||
protected:
|
||||
bool check_Energy(const Particle &movePart) {
|
||||
double Ekin_eV = movePart.get_EKin_eV();
|
||||
if (Ekin_eV<=cutoffEnergy_eV) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* terminator_base_h */
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// terminator_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "terminator_builder.hpp"
|
||||
|
||||
#include "electron_terminator.h"
|
||||
#include "tritiumI_terminator.h"
|
||||
#include "tritium2I_terminator.h"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
const int Terminator_Builder::maxInteractions = getParameter("maxInteractions");
|
||||
const double Terminator_Builder::cutoffEnergy_eV = getParameter("cutoffEnergy_eV");
|
||||
|
||||
|
||||
Terminator_Manager Terminator_Builder::build() {
|
||||
Terminator_Manager Terminator;
|
||||
Terminator.add(new E_Terminator(maxInteractions, cutoffEnergy_eV));
|
||||
Terminator.add(new TI_Terminator(maxInteractions, cutoffEnergy_eV));
|
||||
Terminator.add(new T2I_Terminator(maxInteractions, cutoffEnergy_eV));
|
||||
return (Terminator);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// terminator_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef terminator_builder_hpp
|
||||
#define terminator_builder_hpp
|
||||
|
||||
#include "terminator_base.h"
|
||||
#include "manager_base.h"
|
||||
|
||||
typedef Manager_Base<Terminator_Base> Terminator_Manager;
|
||||
|
||||
|
||||
class Terminator_Builder {
|
||||
static const int maxInteractions;
|
||||
static const double cutoffEnergy_eV;
|
||||
|
||||
public:
|
||||
Terminator_Builder() {};
|
||||
|
||||
static Terminator_Manager build();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* terminator_builder_hpp */
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// thermalPop_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "thermalPop_container.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void ThermalPop_Container::set_Map() {
|
||||
vector<vec3> bins = get_bins();
|
||||
for (vector<vec3>::iterator Itr = bins.begin(); Itr!=bins.end(); Itr++) {
|
||||
addPoint(ddeque{(*Itr)[0], (*Itr)[1], (*Itr)[2], 0});
|
||||
}
|
||||
}
|
||||
|
||||
double ThermalPop_Container::getDensity_m3(const vec3 &locXYZ_m, double physTime_s) {
|
||||
check_In_Container(locXYZ_m, xyz);
|
||||
vec3 zrphiCords = transformTo_zrphiCords(locXYZ_m, xyz);
|
||||
double V_m3 = get_V_m3(zrphiCords[1]);
|
||||
double cumTime_s = get_value(ddeque{zrphiCords[0], zrphiCords[1], zrphiCords[2]}, Lower_bound) ;
|
||||
return (cumTime_s/physTime_s/V_m3);
|
||||
}
|
||||
|
||||
void ThermalPop_Container::upDensity (const Particle &upParticle, const vec3 &oldLocXYZ_m) {
|
||||
check_In_Container(oldLocXYZ_m, xyz);
|
||||
vec3 zrphiOld_m = transformTo_zrphiCords(oldLocXYZ_m, xyz);
|
||||
vec3 zrphiNew_m = upParticle.get_Location_m();
|
||||
check_In_Container(zrphiNew_m, zrphi);
|
||||
// Check r and phi not changing, only valid for drift approximation....
|
||||
|
||||
double z_min_m = zrphiOld_m[0];
|
||||
double z_max_m = zrphiNew_m[0];
|
||||
if (z_max_m<z_min_m) {
|
||||
swap (z_min_m, z_max_m);
|
||||
}
|
||||
double r_m = zrphiOld_m[1];
|
||||
double phi = zrphiOld_m[2];
|
||||
double l_m = get_l_m();
|
||||
double vAbs_ms = upParticle.get_SpeedAbs_ms();
|
||||
|
||||
dim3Map::iterator zItr_min = Map.lower_bound(z_min_m);
|
||||
dim3Map::iterator zItr_max = Map.lower_bound(z_max_m);
|
||||
|
||||
for (dim3Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||
Itr->second.lower_bound(r_m)->second.lower_bound(phi)->second += l_m/vAbs_ms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// thermalPop_container.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef thermalPop_container_hpp
|
||||
#define thermalPop_container_hpp
|
||||
|
||||
#include "zylindric_cords.h"
|
||||
#include "particle.hpp"
|
||||
|
||||
class ThermalPop_Container : private Base_Container<dim3Map>, private Zylindric_Cords {
|
||||
|
||||
public:
|
||||
ThermalPop_Container(vec3 zrphi_numBins) : Zylindric_Cords(zrphi_numBins) {
|
||||
set_Map();
|
||||
}
|
||||
private:
|
||||
void set_Map();
|
||||
|
||||
public:
|
||||
double getDensity_m3(const vec3 &locXYZ_m, double physTime_s) ;
|
||||
void upDensity (const Particle &upParticle, const vec3 &oldLocXYZ_m) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* thermalPop_container_hpp */
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// thermal_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 25.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef thermal_base_h
|
||||
#define thermal_base_h
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "population3_container.hpp"
|
||||
#include "size_container.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
|
||||
class Thermal_Base : public Population_Base, protected RNG_Base{
|
||||
Pop3_Container cumulated_times_s;
|
||||
Pop3_Container numbers_annhilated;
|
||||
Size_Container bin_sizes;
|
||||
|
||||
Timer *timer;
|
||||
|
||||
|
||||
public:
|
||||
Thermal_Base(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species),
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
cumulated_times_s(num_z_bins, num_r_bins, num_phi_bins),
|
||||
numbers_annhilated(num_z_bins, num_r_bins, num_phi_bins),
|
||||
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
|
||||
this->timer = timer;
|
||||
};
|
||||
|
||||
double get_density_m3 (const vec3 &loc_m);
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m);
|
||||
|
||||
|
||||
virtual vec3 get_average_speed_ms (const vec3 &loc_m) = 0;
|
||||
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
||||
};
|
||||
|
||||
inline double Thermal_Base::get_density_m3(const vec3 &loc_m) {
|
||||
//Katrin_Geo::check_inKatrin(loc_m);
|
||||
double physical_time_s = timer->get_physTime_s();
|
||||
double cumulative_time_s = cumulated_times_s.get_value(loc_m);
|
||||
double offset = numbers_annhilated.get_value(loc_m);
|
||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
||||
double dens_m3 = cumulative_time_s/physical_time_s/bin_size_m3 - offset;
|
||||
dens_m3 = (dens_m3 < 0) ? zero : dens_m3;
|
||||
return(dens_m3);
|
||||
}
|
||||
|
||||
inline void Thermal_Base::increase_density(const Particle &upPart, const vec3 &oldLoc_m) {
|
||||
double cell_time_s = bin_sizes.get_cell_length_m()/upPart.get_SpeedAbs_ms();
|
||||
cumulated_times_s.increase_value(cell_time_s, upPart.get_Location_m(), oldLoc_m);
|
||||
}
|
||||
|
||||
inline void Thermal_Base::decrease_denisty (const vec3 &loc_m) {
|
||||
numbers_annhilated.increase_value(1, loc_m);
|
||||
}
|
||||
|
||||
|
||||
#endif /* thermal_base_h */
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// tritium2I_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium2I_drift_h
|
||||
#define tritium2I_drift_h
|
||||
|
||||
#include "drift_base.h"
|
||||
|
||||
|
||||
class T2I_Mover_Drift : public Drift_Base {
|
||||
public:
|
||||
T2I_Mover_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : Drift_Base(tritium2I, Logger, Population) {};
|
||||
|
||||
protected:
|
||||
void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m);
|
||||
};
|
||||
|
||||
|
||||
void T2I_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= Katrin_Geo::get_z_WGTSend_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_WGTSend_m();
|
||||
}
|
||||
if (*znew_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_RW_m();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritium2I_drift_h */
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// tritium2I_terminator.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium2I_terminator_h
|
||||
#define tritium2I_terminator_h
|
||||
|
||||
|
||||
class T2I_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
||||
|
||||
public:
|
||||
T2I_Terminator(const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(tritium2I), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
||||
|
||||
bool checkTermination (const Particle &movePart);
|
||||
private:
|
||||
bool check_Wall(const Particle &movePart);
|
||||
};
|
||||
|
||||
|
||||
inline bool T2I_Terminator::checkTermination (const Particle &movePart) {
|
||||
if (check_Wall(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_Energy(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_MaxInteractions(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
inline bool T2I_Terminator::check_Wall(const Particle &movePart) {
|
||||
vec3 loc_m = movePart.get_Location_m();
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (z_m >= Katrin_Geo::get_z_WGTSend_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (r_m >= Katrin_Geo::get_radius_m()) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritium2I_terminator_h */
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// tritium2_population.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 17.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium2_population_h
|
||||
#define tritium2_population_h
|
||||
|
||||
|
||||
class T2_Population : public Population_Base, public RNG_Base {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
static const double wgtsTemp_K;
|
||||
static const double wgtsT2FlowSpeed_ms;
|
||||
|
||||
public:
|
||||
T2_Population(UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium2), RNG_Base(rngUni, rngNormal){};
|
||||
|
||||
double get_density_m3 (const vec3 &loc_m);
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {};
|
||||
void decrease_denisty (const vec3 &oldLoc_m) {};
|
||||
|
||||
vec3 get_average_speed_ms (const vec3 &loc_m);
|
||||
vec3 roll_speed_ms (const vec3 &loc_m);
|
||||
|
||||
|
||||
private:
|
||||
double calc_DensityTriangle(const double &z_m);
|
||||
|
||||
private:
|
||||
vec3 roll_thermSpeed_ms(const vec3 &loc_m);
|
||||
|
||||
};
|
||||
|
||||
|
||||
const double T2_Population::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
const double T2_Population::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double T2_Population::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
if (!Katrin_Geo::inWGTS(loc_m)) {
|
||||
return (zero);
|
||||
} else {
|
||||
return (calc_DensityTriangle(loc_m[2]));
|
||||
}
|
||||
}
|
||||
|
||||
inline double T2_Population::calc_DensityTriangle(const double &z_m) {
|
||||
double z_wgts_m = z_m - Katrin_Geo::get_z_WGTSstart_m(); // Cords with z=0 at beginning of WGTS
|
||||
double wgtsLength_m = Katrin_Geo::get_wgtsLength_m();
|
||||
double wgtsHalfLength_m = wgtsLength_m/2;
|
||||
double zProjection_m = (z_wgts_m < wgtsHalfLength_m) ? z_wgts_m : wgtsLength_m - z_wgts_m;
|
||||
double reduction_Factor = zProjection_m/wgtsHalfLength_m; //Correction since reflection
|
||||
return(reduction_Factor * wgtsT2MaxDensity_m3);
|
||||
}
|
||||
|
||||
inline vec3 T2_Population::roll_speed_ms(const vec3 &loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
return (get_average_speed_ms(loc_m) + roll_thermSpeed_ms(loc_m));
|
||||
}
|
||||
|
||||
inline vec3 T2_Population::get_average_speed_ms(const vec3 &loc_m) {
|
||||
if (Katrin_Geo::inWGTS(loc_m)) {
|
||||
double z_wgtsHalf_m = Katrin_Geo::get_z_WGTSstart_m() + (Katrin_Geo::get_z_WGTSend_m() - Katrin_Geo::get_z_WGTSstart_m())/2;
|
||||
double sign = (loc_m[2] < z_wgtsHalf_m) ? -1 : 1;
|
||||
double zSpeed_ms = sign*wgtsT2FlowSpeed_ms;
|
||||
return ( vec3(0,0,zSpeed_ms) );
|
||||
} else {
|
||||
return (vec3(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
inline vec3 T2_Population::roll_thermSpeed_ms(const vec3 &loc_m) {
|
||||
double Ekin_eV = roll_MBEnergy(wgtsTemp_K,mT2_eV,rngNormal);
|
||||
double Speed_ms = calc_Speed_from_Ekin_eV(Ekin_eV, mT2_eV);
|
||||
vec3 speed_ms = roll_uniform_direction(rngUni)*Speed_ms;
|
||||
return(speed_ms);
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritium2_population_h */
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// tritiumI_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritiumI_drift_h
|
||||
#define tritiumI_drift_h
|
||||
|
||||
#include "drift_base.h"
|
||||
|
||||
|
||||
class TI_Mover_Drift : public Drift_Base {
|
||||
public:
|
||||
TI_Mover_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : Drift_Base(tritiumI, Logger, Population) {};
|
||||
|
||||
protected:
|
||||
void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m);
|
||||
};
|
||||
|
||||
|
||||
void TI_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= Katrin_Geo::get_z_WGTSend_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_WGTSend_m();
|
||||
}
|
||||
if (*znew_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_RW_m();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritiumI_drift_h */
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// tritiumI_terminator.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritiumI_terminator_h
|
||||
#define tritiumI_terminator_h
|
||||
|
||||
|
||||
class TI_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
||||
|
||||
public:
|
||||
TI_Terminator(const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(tritiumI), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
||||
|
||||
bool checkTermination (const Particle &movePart);
|
||||
private:
|
||||
bool check_Wall(const Particle &movePart);
|
||||
};
|
||||
|
||||
|
||||
inline bool TI_Terminator::checkTermination (const Particle &movePart) {
|
||||
if (check_Wall(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_Energy(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
if (check_MaxInteractions(movePart)) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
inline bool TI_Terminator::check_Wall(const Particle &movePart) {
|
||||
vec3 loc_m = movePart.get_Location_m();
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (z_m >= Katrin_Geo::get_z_WGTSend_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (r_m >= Katrin_Geo::get_radius_m()) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritiumI_terminator_h */
|
||||
@@ -0,0 +1,179 @@
|
||||
//
|
||||
// zylindric_cords.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 15.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef zylindric_cords_h
|
||||
#define zylindric_cords_h
|
||||
|
||||
typedef enum cordStyle{xyz, zrphi} cordStyle;
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "kinematics.h"
|
||||
#include "base_container.h"
|
||||
|
||||
|
||||
class Zylindric_Cords {
|
||||
double z_min_m;
|
||||
double z_max_m;
|
||||
double r_max_m;
|
||||
vec3 zrphi_numBins;
|
||||
|
||||
double l_m;
|
||||
dim1Map V_m3;
|
||||
|
||||
public:
|
||||
Zylindric_Cords() {};
|
||||
Zylindric_Cords(vec3 zrphi_numBins);
|
||||
Zylindric_Cords(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
private:
|
||||
void set_fromKatrinGeo();
|
||||
void set_l_m();
|
||||
void set_V_m3();
|
||||
|
||||
public:
|
||||
std::vector<vec3> get_bins() ;
|
||||
|
||||
double get_l_m () {return(l_m);}
|
||||
double get_V_m3(double r_m) ;
|
||||
|
||||
public:
|
||||
void check_In_Container(vec3 Cords, cordStyle cordStyleIn = xyz);
|
||||
bool in_Container(vec3 Cords, cordStyle cordStyleIn = xyz);
|
||||
|
||||
private:
|
||||
bool in_zDimension (double z_m);
|
||||
bool in_rDimension (double r_m);
|
||||
|
||||
protected:
|
||||
vec3 transformTo_zrphiCords(vec3 Cords, cordStyle cordStyleIn);
|
||||
};
|
||||
|
||||
|
||||
inline Zylindric_Cords::Zylindric_Cords(vec3 zrphi_numBins) {
|
||||
set_fromKatrinGeo();
|
||||
this->zrphi_numBins = zrphi_numBins;
|
||||
set_l_m();
|
||||
set_V_m3();
|
||||
}
|
||||
|
||||
inline Zylindric_Cords::Zylindric_Cords(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) {
|
||||
this->z_min_m = z_min_m;
|
||||
this->z_max_m = z_max_m;
|
||||
this->r_max_m = r_max_m;
|
||||
this->zrphi_numBins = zrphi_numBins;
|
||||
set_l_m();
|
||||
set_V_m3();
|
||||
}
|
||||
|
||||
inline void Zylindric_Cords::set_fromKatrinGeo() {
|
||||
this->z_min_m = Katrin_Geo::get_z_RW_m();
|
||||
this->z_max_m = Katrin_Geo::get_z_WGTSend_m();
|
||||
this->r_max_m = Katrin_Geo::get_radius_m();
|
||||
}
|
||||
|
||||
inline void Zylindric_Cords::set_l_m() {
|
||||
l_m = (z_max_m-z_min_m)/zrphi_numBins[0];
|
||||
}
|
||||
|
||||
inline void Zylindric_Cords::set_V_m3() {
|
||||
int n_r = zrphi_numBins[1];
|
||||
int n_phi = zrphi_numBins[2];
|
||||
double r_step_m = r_max_m/n_r;
|
||||
double r_m, A_disc_m2, V_res_m3;
|
||||
for (int i = 1; i <= n_r; i++) {
|
||||
r_m = i * r_step_m;
|
||||
A_disc_m2 = pi*(pow(r_m,2)-pow(r_m-r_step_m,2));
|
||||
V_res_m3 = A_disc_m2/n_phi*l_m;
|
||||
V_m3.insert( std::pair<double,double>(r_m, V_res_m3) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline std::vector<vec3> Zylindric_Cords::get_bins() {
|
||||
std::vector<vec3> res;
|
||||
int n_z = zrphi_numBins[0];
|
||||
int n_r = zrphi_numBins[1];
|
||||
int n_phi = zrphi_numBins[2];
|
||||
double z_step_m = l_m;
|
||||
double r_step_m = r_max_m/n_r;
|
||||
double phi_step = 2*pi/n_phi;
|
||||
double z_m, r_m, phi;
|
||||
|
||||
for (int i_z = 1; i_z<=n_z; i_z++) {
|
||||
z_m = z_min_m + z_step_m * i_z;
|
||||
for (int i_r = 1; i_r<=n_r; i_r++) {
|
||||
r_m = r_step_m * i_r;
|
||||
for (int i_phi = 1; i_phi<=n_phi; i_phi++) {
|
||||
phi = phi_step * i_phi;
|
||||
res.push_back( vec3(z_m, r_m, phi) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
||||
inline double Zylindric_Cords::get_V_m3(double r_m) {
|
||||
if (!in_rDimension(r_m)) {
|
||||
std::stringstream ss;
|
||||
ss<<"Zylindric_Cords::get_V_m3: r_m not in Container.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
return(V_m3.lower_bound(r_m))->second;
|
||||
|
||||
}
|
||||
|
||||
inline void Zylindric_Cords::check_In_Container(vec3 Cords, cordStyle cordStyleIn) {
|
||||
if (!in_Container(Cords, cordStyleIn)) {
|
||||
std::stringstream ss;
|
||||
ss<<"Zylindric_Cords::check_In_Container: Cords not in Container.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Zylindric_Cords::in_Container(vec3 Cords, cordStyle cordStyleIn) {
|
||||
Cords = transformTo_zrphiCords(Cords, cordStyleIn);
|
||||
return (in_zDimension(Cords[0]) && in_rDimension(Cords[1]));
|
||||
}
|
||||
|
||||
inline bool Zylindric_Cords::in_zDimension (double z_m) {
|
||||
if (z_m<z_min_m) {
|
||||
return (false);
|
||||
}
|
||||
if (z_m>z_max_m) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
inline bool Zylindric_Cords::in_rDimension (double r_m) {
|
||||
if (r_m>r_max_m) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
inline vec3 Zylindric_Cords::transformTo_zrphiCords(vec3 Cords, cordStyle cordStyleIn) {
|
||||
if (cordStyleIn == zrphi) {
|
||||
return (Cords);
|
||||
}
|
||||
double z = Cords[2];
|
||||
double r = sqrt(Cords[0]*Cords[0] + Cords[1]*Cords[1]);
|
||||
double phi;
|
||||
if (Cords[0] >= 0) {
|
||||
phi = acos(Cords[1]/r);
|
||||
} else {
|
||||
phi = 2*pi - acos(Cords[1]/r);
|
||||
}
|
||||
return (vec3(z,r,phi));
|
||||
}
|
||||
|
||||
|
||||
#endif /* zylindric_cords_h */
|
||||
Reference in New Issue
Block a user