Working Version with Population update and T+ interactions.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// BED_SDCS_calculator.cpp
|
||||
// cross_section_calculator
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "BED_SDCS_calculator.hpp"
|
||||
|
||||
|
||||
|
||||
double BED_SDCS_calculator::minE_eV = 15;
|
||||
double BED_SDCS_calculator::maxE_eV = 2e4;
|
||||
double BED_SDCS_calculator::pointsPer_initE_Order = 50;
|
||||
double BED_SDCS_calculator::pointsPer_secE_Order = 10;
|
||||
|
||||
std::string BED_SDCS_calculator::defaultExportPath = "/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/";
|
||||
|
||||
void BED_SDCS_calculator::set_Parameters (double new_minE_eV, double new_maxE_eV, double new_pointsPer_initE_Order, double new_pointsPer_secE_Order) {
|
||||
set_minE_eV(new_minE_eV);
|
||||
set_maxE_eV (new_maxE_eV);
|
||||
set_pointsPer_initE_Order (new_pointsPer_initE_Order);
|
||||
set_pointsPer_secE_Order (new_pointsPer_secE_Order);
|
||||
}
|
||||
|
||||
void BED_SDCS_calculator::set_defaultExportPath(std::string new_defaultExportPath) {
|
||||
if (new_defaultExportPath.back() != '/') {
|
||||
new_defaultExportPath = new_defaultExportPath + '/';
|
||||
}
|
||||
defaultExportPath = new_defaultExportPath;
|
||||
}
|
||||
|
||||
|
||||
Edge2D_FuncContainer calc_SDCS_Edge() {
|
||||
Edge2D_FuncContainer BED_edge_SDCS;
|
||||
BED_edge_SDCS.get_Ionization_fromFunction(BED_eT2_Ionization::calc_SDCS, 15, 20000, 50, 10);
|
||||
BED_edge_SDCS.add_ankerpoint(EionT2_eV, 0,0);
|
||||
double xmin =EionT2_eV+1e-4;
|
||||
double ymin = (xmin-EionT2_eV)/2;
|
||||
BED_edge_SDCS.add_ankerpoint(xmin, ymin,BED_eT2_Ionization::calc_SDCS(xmin,ymin));
|
||||
return(BED_edge_SDCS);
|
||||
}
|
||||
|
||||
Average2D_FuncContainer calc_SDCS_Average() {
|
||||
Edge2D_FuncContainer BED_edge_SDCS = calc_SDCS_Edge();
|
||||
Average2D_FuncContainer BED_average_SDCS = Average2D_FuncContainer(BED_edge_SDCS);
|
||||
return(BED_average_SDCS);
|
||||
}
|
||||
|
||||
Stacked2D_FuncContainer calc_SDCS_Stacked() {
|
||||
Average2D_FuncContainer BED_average_SDCS = calc_SDCS_Average();
|
||||
Stacked2D_FuncContainer BED_stacked_SDCS = Stacked2D_FuncContainer(BED_average_SDCS);
|
||||
return(BED_stacked_SDCS);
|
||||
}
|
||||
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Edge (std::string exportPath) {
|
||||
Edge2D_FuncContainer BED_edge_SDCS = calc_SDCS_Edge();
|
||||
BED_edge_SDCS.exportToFile(exportPath);
|
||||
}
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Average (std::string exportPath) {
|
||||
Average2D_FuncContainer BED_average_SDCS = calc_SDCS_Average();
|
||||
BED_average_SDCS.exportToFile(exportPath);
|
||||
}
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Stacked (std::string exportPath) {
|
||||
Stacked2D_FuncContainer BED_stacked_SDCS = calc_SDCS_Stacked();
|
||||
BED_stacked_SDCS.exportToFile(exportPath);
|
||||
}
|
||||
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Edge () {
|
||||
stringstream ss;
|
||||
ss<<defaultExportPath<<"BED_edge_SDCS.dat";
|
||||
export_SDCS_Edge(ss.str());
|
||||
}
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Average () {
|
||||
stringstream ss;
|
||||
ss<<defaultExportPath<<"BED_average_SDCS.dat";
|
||||
export_SDCS_Average(ss.str());
|
||||
}
|
||||
|
||||
void BED_SDCS_calculator::export_SDCS_Stacked () {
|
||||
stringstream ss;
|
||||
ss<<defaultExportPath<<"BED_stacked_SDCS.dat";
|
||||
export_SDCS_Stacked(ss.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// BED_SDCS_calculator.hpp
|
||||
// cross_section_calculator
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BED_SDCS_calculator_hpp
|
||||
#define BED_SDCS_calculator_hpp
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
|
||||
class BED_SDCS_calculator {
|
||||
static double minE_eV;
|
||||
static double maxE_eV;
|
||||
static double pointsPer_initE_Order;
|
||||
static double pointsPer_secE_Order;
|
||||
static std::string defaultExportPath;
|
||||
public:
|
||||
BED_SDCS_calculator();
|
||||
|
||||
static void set_Parameters (double new_minE_eV, double new_maxE_eV, double new_pointsPer_initE_Order, double new_pointsPer_secE_Order);
|
||||
static void set_minE_eV (double new_minE_eV) {minE_eV = new_minE_eV;}
|
||||
static void set_maxE_eV (double new_maxE_eV) {maxE_eV = new_maxE_eV;}
|
||||
static void set_pointsPer_initE_Order (double new_pointsPer_initE_Order) {pointsPer_initE_Order = new_pointsPer_initE_Order;}
|
||||
static void set_pointsPer_secE_Order (double new_pointsPer_secE_Order) {pointsPer_secE_Order = new_pointsPer_secE_Order;}
|
||||
|
||||
static void set_defaultExportPath(std::string new_defaultExportPath);
|
||||
|
||||
|
||||
static void export_SDCS_Edge (std::string exportPath);
|
||||
static void export_SDCS_Average (std::string exportPath);
|
||||
static void export_SDCS_Stacked (std::string exportPath);
|
||||
|
||||
static void export_SDCS_Edge ();
|
||||
static void export_SDCS_Average ();
|
||||
static void export_SDCS_Stacked ();
|
||||
|
||||
private:
|
||||
static Edge2D_FuncContainer calc_SDCS_Edge();
|
||||
static Average2D_FuncContainer calc_SDCS_Average();
|
||||
static Stacked2D_FuncContainer calc_SDCS_Stacked();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* BED_SDCS_calculator_hpp */
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// BED_TCS_calculator.cpp
|
||||
// cross_section_calculator
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "BED_TCS_calculator.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
double BED_TCS_calculator::minE_eV = 15;
|
||||
double BED_TCS_calculator::maxE_eV = 2e4;
|
||||
double BED_TCS_calculator::pointsPerOrder = 100;
|
||||
std::string BED_TCS_calculator::defaultExportPath = "/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/";
|
||||
|
||||
void BED_TCS_calculator::set_Parameters (double new_minE_eV, double new_maxE_eV, double new_pointsPerOrder) {
|
||||
set_minE_eV(new_minE_eV);
|
||||
set_maxE_eV (new_maxE_eV);
|
||||
set_pointsPerOrder (new_pointsPerOrder);
|
||||
}
|
||||
|
||||
void BED_TCS_calculator::set_defaultExportPath(std::string new_defaultExportPath) {
|
||||
if (new_defaultExportPath.back() != '/') {
|
||||
new_defaultExportPath = new_defaultExportPath + '/';
|
||||
}
|
||||
defaultExportPath = new_defaultExportPath;
|
||||
}
|
||||
|
||||
|
||||
Edge1D_FuncContainer BED_TCS_calculator::calc_TCS_Edge() {
|
||||
Edge1D_FuncContainer BED_edge_TCS;
|
||||
BED_edge_TCS.fillFromFunction(BED_eT2_Ionization::calc_TCS, minE_eV, maxE_eV, pointsPerOrder);
|
||||
// Manually add points near threshold
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV, BED_eT2_Ionization::calc_TCS(EionT2_eV));
|
||||
double offset = 1e-4;
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV+offset, BED_eT2_Ionization::calc_TCS(EionT2_eV+offset));
|
||||
return (BED_edge_TCS);
|
||||
}
|
||||
|
||||
Average1D_FuncContainer BED_TCS_calculator::calc_TCS_Average() {
|
||||
Edge1D_FuncContainer BED_edge_TCS = calc_TCS_Edge();
|
||||
Average1D_FuncContainer BED_average_TCS = Average1D_FuncContainer(BED_edge_TCS);
|
||||
return (BED_average_TCS);
|
||||
}
|
||||
|
||||
void BED_TCS_calculator::export_TCS_Edge (std::string exportPath) {
|
||||
Edge1D_FuncContainer BED_edge_TCS = calc_TCS_Edge();
|
||||
BED_edge_TCS.exportToFile(exportPath);
|
||||
}
|
||||
void BED_TCS_calculator::export_TCS_Average (std::string exportPath) {
|
||||
Average1D_FuncContainer BED_average_TCS = calc_TCS_Average();
|
||||
BED_average_TCS.exportToFile(exportPath);
|
||||
}
|
||||
|
||||
void BED_TCS_calculator::export_TCS_Edge () {
|
||||
stringstream ss;
|
||||
ss<<defaultExportPath<<"BED_edge_TCS.dat";
|
||||
export_TCS_Edge(ss.str());
|
||||
}
|
||||
|
||||
void BED_TCS_calculator::export_TCS_Average () {
|
||||
stringstream ss;
|
||||
ss<<defaultExportPath<<"BED_average_TCS.dat";
|
||||
export_TCS_Average(ss.str());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// BED_TCS_calculator.hpp
|
||||
// cross_section_calculator
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BED_TCS_calculator_hpp
|
||||
#define BED_TCS_calculator_hpp
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
class BED_TCS_calculator {
|
||||
static double minE_eV;
|
||||
static double maxE_eV;
|
||||
static double pointsPerOrder;
|
||||
static std::string defaultExportPath;
|
||||
|
||||
public:
|
||||
BED_TCS_calculator();
|
||||
|
||||
static void set_Parameters (double new_minE_eV, double new_maxE_eV, double new_pointsPerOrder);
|
||||
static void set_minE_eV (double new_minE_eV) {minE_eV = new_minE_eV;}
|
||||
static void set_maxE_eV (double new_maxE_eV) {maxE_eV = new_maxE_eV;}
|
||||
static void set_pointsPerOrder (double new_pointsPerOrder) {minE_eV = new_pointsPerOrder;}
|
||||
|
||||
static void set_defaultExportPath(std::string new_defaultExportPath);
|
||||
|
||||
static void export_TCS_Edge (std::string exportPath);
|
||||
static void export_TCS_Average (std::string exportPath);
|
||||
|
||||
static void export_TCS_Edge ();
|
||||
static void export_TCS_Average ();
|
||||
|
||||
private:
|
||||
static Edge1D_FuncContainer calc_TCS_Edge();
|
||||
static Average1D_FuncContainer calc_TCS_Average();
|
||||
};
|
||||
#endif /* BED_TCS_calculator_hpp */
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// main.cpp
|
||||
// cross_section_calculator
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
//createBED_TCS_Func_container();
|
||||
//createBED_SDCS_Func2D_container();
|
||||
//Katrin Kat;
|
||||
//Skalar_WGTS_Container Ion_Container(0, 10, 0.045, vec3(10,10,10));
|
||||
//Ion_Container.set_Bins_from_Function(tritiumDens);
|
||||
}
|
||||
@@ -8,15 +8,15 @@
|
||||
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const double BED_eT2_Ionization::S_m2 = 5.4721e-20;
|
||||
const double BED_eT2_Ionization::B_eV = EionT2_eV;
|
||||
const double BED_eT2_Ionization::u = 1.664;
|
||||
@@ -24,7 +24,6 @@ const double BED_eT2_Ionization::N = 2;
|
||||
const double BED_eT2_Ionization::Ni = 1.173;
|
||||
const double BED_eT2_Ionization::c[4] = {1.1262 , 6.3982 , -7.8055, 2.1449} ;
|
||||
|
||||
|
||||
double BED_eT2_Ionization::calc_TCS(const double &T_eV) {
|
||||
if (T_eV<=0) {
|
||||
stringstream ss;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define BED_eT2_ionization_hpp
|
||||
|
||||
|
||||
|
||||
// BED Ionization model from Kim, Y.-K. and Rudd, M. E. 1994
|
||||
class BED_eT2_Ionization {
|
||||
static const double S_m2;
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
#ifndef constants_h
|
||||
#define constants_h
|
||||
|
||||
|
||||
typedef const double constant;
|
||||
|
||||
|
||||
constant zero = 1e-15;
|
||||
|
||||
// Natural Constants
|
||||
constant pi = 3.1415;
|
||||
constant c_ms = 299792458;
|
||||
@@ -23,9 +25,12 @@ constant ERyd_eV = 13.605693009;
|
||||
// Particle Properties
|
||||
constant me_eV = 0.511e6;
|
||||
constant re_m = 2.817940322719e-15;
|
||||
|
||||
constant ZT2 = 2.;
|
||||
constant mT2_eV = 5.61886404234e9;
|
||||
constant mT_eV = 2.8094320212e9;
|
||||
constant mT2_eV = mT_eV*2;
|
||||
constant EionT2_eV = 15.43;
|
||||
constant decayConstT2_s = 1.78405e-09;
|
||||
|
||||
// Beta Decay
|
||||
constant BetaDecayConst = 1.2072343416696292e-47;
|
||||
|
||||
@@ -9,51 +9,50 @@
|
||||
#ifndef container_base_functions_h
|
||||
#define container_base_functions_h
|
||||
|
||||
#include "error_types.h"
|
||||
#include "read_system.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <deque>
|
||||
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include "blitz/array.h"
|
||||
|
||||
#include "error_types.h"
|
||||
#include "read_system.h"
|
||||
#include "constants.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
typedef std::map<double,double> dim1Map;
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace container_base {
|
||||
inline void add_To_Map(map<double,double> *Map, const deque<double> &queIn) { //Iteration End
|
||||
inline void add_To_Map(std::map<double,double> *Map, const std::deque<double> &queIn) { //Iteration End
|
||||
if (queIn.size()!=2) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss<<"addTo_Map: vecIn not big enough.";
|
||||
cout<<ss.str()<<endl;
|
||||
std::cout<<ss.str()<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x1 = *queIn.begin();
|
||||
double f = *queIn.rbegin();
|
||||
if ( Map->find(x1)!=Map->end() ) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss<<"HIT: Key x="<<x1<<" already exists.";
|
||||
cout<<ss.str()<<endl;
|
||||
std::cout<<ss.str()<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
Map->insert(pair<double,double>(x1, f));
|
||||
Map->insert(std::pair<double,double>(x1, f));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void add_To_Map (map<double,T> *Map, deque<double> queIn) {
|
||||
inline void add_To_Map (std::map<double,T> *Map, std::deque<double> queIn) {
|
||||
double xN = *queIn.begin();
|
||||
queIn.pop_front();
|
||||
T tempMap;
|
||||
if ( Map->find(xN)==Map->end() ) { // No such element -> generate new Map and insert
|
||||
T tempMap;
|
||||
add_To_Map(&tempMap, queIn);
|
||||
Map->insert(pair<double,T>(xN,tempMap));
|
||||
Map->insert(std::pair<double,T>(xN,tempMap));
|
||||
} else { // Found such element -> Insert to existing map using iteration
|
||||
add_To_Map(&Map->find(xN)->second, queIn);
|
||||
}
|
||||
@@ -61,19 +60,19 @@ namespace container_base {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline void add_From_Csv (T *Map, const int &dim, const string &loadFilePath) {
|
||||
ifstream fileStream(loadFilePath);
|
||||
inline void add_From_Csv (T *Map, const int &dim, const std::string &loadFilePath) {
|
||||
std::ifstream fileStream(loadFilePath);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func_Container::readFromCSV: Could not open file. \n loadFilePath= "<<loadFilePath<<endl;
|
||||
std::stringstream ss;
|
||||
ss<<"Func_Container::readFromCSV: Could not open file. \n loadFilePath= "<<loadFilePath<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
string lineFromFile;
|
||||
stringstream ss;
|
||||
std::string lineFromFile;
|
||||
std::stringstream ss;
|
||||
double temp;
|
||||
deque<double> dequeTemp;
|
||||
std::deque<double> dequeTemp;
|
||||
bool lineReadError = false;
|
||||
|
||||
while (getline(fileStream, lineFromFile)) {
|
||||
@@ -90,7 +89,7 @@ namespace container_base {
|
||||
if (ss>>temp) {
|
||||
dequeTemp.push_back(temp);
|
||||
} else if (!lineReadError) {
|
||||
cout<<"Func_Container::readFromCSV: Warning could not read line in inputFile. \nloadFilePath = "<<loadFilePath<<endl;
|
||||
std::cout<<"Func_Container::readFromCSV: Warning could not read line in inputFile. \nloadFilePath = "<<loadFilePath<<"\n";
|
||||
lineReadError = true;
|
||||
|
||||
}
|
||||
@@ -102,15 +101,15 @@ namespace container_base {
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
inline void write_To_Csv(const dim1Map &Map, ofstream *outFile, string preset = "") { //Iteration End
|
||||
inline void write_To_Csv(const dim1Map &Map, std::ofstream *outFile, std::string preset = "") { //Iteration End
|
||||
for (dim1Map::const_iterator Itr = Map.begin();Itr!=Map.end();Itr++) {
|
||||
(*outFile)<<preset<<Itr->first<<"\t"<<Itr->second<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void write_To_Csv(const T &Map, ofstream *outFile, string preset = "") {
|
||||
stringstream ss;
|
||||
inline void write_To_Csv(const T &Map, std::ofstream *outFile, std::string preset = "") {
|
||||
std::stringstream ss;
|
||||
for (typename T::const_iterator Itr = Map.begin();Itr!=Map.end();Itr++) {
|
||||
ss.clear();
|
||||
ss.str("");
|
||||
@@ -120,12 +119,12 @@ namespace container_base {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void export_To_Csv(const T &Map, string exportFilePath) {
|
||||
ofstream outFile;
|
||||
inline void export_To_Csv(const T &Map, std::string exportFilePath) {
|
||||
std::ofstream outFile;
|
||||
outFile.open(exportFilePath);
|
||||
if (!outFile.good()) {
|
||||
stringstream ss;
|
||||
ss<<"Func2D_Container::exportToFile: Could not open file. \n exportFilePath= "<<exportFilePath<<endl;
|
||||
std::stringstream ss;
|
||||
ss<<"Func2D_Container::exportToFile: Could not open file. \n exportFilePath= "<<exportFilePath<<"\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
outFile<<"# Automatically generated Data of Function2D_Container class by exportToFile().\n";
|
||||
@@ -136,9 +135,9 @@ namespace container_base {
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
inline double get_Value(const dim1Map &Map, deque<double> Cord) {
|
||||
inline double get_Value(const dim1Map &Map, std::deque<double> Cord) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss<<"getValue: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
@@ -151,7 +150,7 @@ namespace container_base {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline double get_Value(const T &Map, deque<double> Cord) {
|
||||
inline double get_Value(const T &Map, std::deque<double> Cord) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
if (Map.rbegin()->first < x) {
|
||||
@@ -161,9 +160,9 @@ namespace container_base {
|
||||
}
|
||||
}
|
||||
|
||||
inline double interpolate_Value(const dim1Map &Map, deque<double> Cord) {
|
||||
inline double interpolate_Value(const dim1Map &Map, std::deque<double> Cord) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss<<"interpolat_Value: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
@@ -186,7 +185,7 @@ namespace container_base {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline double interpolate_Value(const T &Map, deque<double> Cord) {
|
||||
inline double interpolate_Value(const T &Map, std::deque<double> Cord) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
|
||||
@@ -207,40 +206,71 @@ namespace container_base {
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
inline void set_Itr(dim1Map Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
inline void set_Itr(dim1Map *Map, std::deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
if (Cord.size()!=1) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss<<"set_Itr: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x = *Cord.begin();
|
||||
|
||||
if (x>Map.rbegin()->first) {
|
||||
Itr = (--Map.end());
|
||||
if (x>Map->rbegin()->first) {
|
||||
Itr = (--Map->end());
|
||||
} else {
|
||||
Itr = Map.lower_bound(x);
|
||||
Itr = Map->lower_bound(x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void set_Itr(T Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
inline void set_Itr(T *Map, std::deque<double> Cord, dim1Map::iterator &Itr) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
if (x>Map.rbegin()->first) {
|
||||
set_Itr(Map.rbegin()->second,Cord,Itr);
|
||||
if (x > Map->rbegin()->first) {
|
||||
set_Itr( &(Map->rbegin()->second), Cord, Itr );
|
||||
} else {
|
||||
set_Itr(Map.lower_bound(x)->second,Cord,Itr);
|
||||
set_Itr( &((Map->lower_bound(x))->second), Cord, Itr );
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline dim1Map::iterator get_Itr(T &Map, deque<double> Cord) {
|
||||
inline dim1Map::iterator get_Itr(T *Map, std::deque<double> Cord) {
|
||||
dim1Map::iterator res;
|
||||
set_Itr(Map, Cord, res);
|
||||
return(res);
|
||||
}
|
||||
|
||||
inline void set_constItr(const dim1Map *Map, std::deque<double> Cord, dim1Map::const_iterator &Itr) {
|
||||
if (Cord.size()!=1) {
|
||||
std::stringstream ss;
|
||||
ss<<"set_Itr: Length of Cord and &Map do not map.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double x = *Cord.begin();
|
||||
|
||||
if (x>(--Map->cend())->first) {
|
||||
Itr = (--Map->cend());
|
||||
} else {
|
||||
Itr = Map->lower_bound(x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void set_constItr(const T *Map, std::deque<double> Cord, dim1Map::const_iterator &Itr) {
|
||||
double x = *Cord.begin();
|
||||
Cord.pop_front();
|
||||
if (x > (--Map->cend())->first) {
|
||||
set_constItr( &((--Map->cend())->second), Cord, Itr );
|
||||
} else {
|
||||
set_constItr( &((Map->lower_bound(x))->second), Cord, Itr );
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline dim1Map::const_iterator get_constItr(const T *Map, std::deque<double> Cord) {
|
||||
dim1Map::const_iterator res;
|
||||
set_constItr(Map, Cord, res);
|
||||
return(res);
|
||||
}
|
||||
|
||||
// Write some iterator over all bins in maps.
|
||||
} // namespace
|
||||
|
||||
@@ -7,15 +7,28 @@
|
||||
//
|
||||
|
||||
#include "density_container.hpp"
|
||||
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
WGTS_Geo::WGTS_Geo(vec3 zrphi_numBins) {
|
||||
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();
|
||||
this->zrphi_numBins = zrphi_numBins;
|
||||
init_bin_maps();
|
||||
}
|
||||
|
||||
WGTS_Geo::WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) {
|
||||
this->z_min_m = z_min_m;
|
||||
this->z_max_m = z_max_m;
|
||||
this->r_max_m = r_max_m;
|
||||
this->zrphi_numBins = zrphi_numBins;
|
||||
dim1Map bin_l_m;
|
||||
dim1Map bin_V_m3;
|
||||
init_bin_maps();
|
||||
}
|
||||
|
||||
@@ -37,10 +50,9 @@ void WGTS_Geo::init_bin_maps() {
|
||||
V_m3 = (pi*pow(r_m,2)-pi*pow(r_m-rad_step_m,2))/n_phi;
|
||||
bin_V_m3.insert(dim1Pair(r_m,V_m3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double WGTS_Geo::get_Bin_l_m (double z_m) const {
|
||||
double WGTS_Geo::get_Bin_l_m(double z_m) const {
|
||||
if (check_z_outside(z_m)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS_Geo_Container::get_Bin_l_m: z_m not in Container.";
|
||||
@@ -49,7 +61,7 @@ double WGTS_Geo::get_Bin_l_m (double z_m) const {
|
||||
return (bin_l_m.lower_bound(z_m)->second);
|
||||
}
|
||||
|
||||
double WGTS_Geo::get_Bin_V_m3(double r_m) const {
|
||||
double WGTS_Geo::get_Bin_V_m3(double z_m, double r_m) const {
|
||||
if (check_r_outside(r_m)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS_Geo_Container::get_Bin_V_m3: r_m not in Container.";
|
||||
@@ -81,13 +93,13 @@ vec3 WGTS_Geo::zrphiCords(vec3 Cords, cordStyle cordStyleIn) const {
|
||||
if (cordStyleIn == zrphi) {
|
||||
return (Cords);
|
||||
}
|
||||
double z = Cords[0];
|
||||
double r = sqrt(Cords[1]*Cords[1] + Cords[2]*Cords[2]);
|
||||
double z = Cords[2];
|
||||
double r = sqrt(Cords[0]*Cords[0] + Cords[1]*Cords[1]);
|
||||
double phi;
|
||||
if (Cords[1] >= 0) {
|
||||
phi = acos(Cords[2]/r);
|
||||
if (Cords[0] >= 0) {
|
||||
phi = acos(Cords[1]/r);
|
||||
} else {
|
||||
phi = 2*pi - acos(Cords[2]/r);
|
||||
phi = 2*pi - acos(Cords[1]/r);
|
||||
}
|
||||
return (vec3(z,r,phi));
|
||||
}
|
||||
@@ -96,7 +108,9 @@ vec3 WGTS_Geo::zrphiCords(vec3 Cords, cordStyle cordStyleIn) const {
|
||||
WGTS3D_ParticleTime_s_Container::WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) : WGTS_Geo(z_min_m, z_max_m, r_max_m, zrphi_numBins) {
|
||||
init_Map();
|
||||
}
|
||||
|
||||
WGTS3D_ParticleTime_s_Container::WGTS3D_ParticleTime_s_Container(vec3 zrphi_numBins) : WGTS_Geo(zrphi_numBins) {
|
||||
init_Map();
|
||||
}
|
||||
|
||||
void WGTS3D_ParticleTime_s_Container::init_Map() {
|
||||
// Give posibility for non linear Bins....
|
||||
@@ -120,14 +134,16 @@ void WGTS3D_ParticleTime_s_Container::init_Map() {
|
||||
}
|
||||
}
|
||||
|
||||
double WGTS3D_ParticleTime_s_Container::getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn) const {
|
||||
double WGTS3D_ParticleTime_s_Container::getDensity_m3(vec3 loc_m, double physTime_s, cordStyle cordStyleIn) const {
|
||||
if (outside_Container(loc_m, cordStyleIn)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS3D_ParticleTime_s_Container::getDensity: loc_old or loc_new not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
loc_m = zrphiCords(loc_m);
|
||||
return (findBin(loc_m)->second/simTime_s);
|
||||
loc_m = zrphiCords(loc_m, cordStyleIn);
|
||||
double V_m3 = get_Bin_V_m3(loc_m[0], loc_m[1]);
|
||||
double cumTime_s = findBin(loc_m)->second;
|
||||
return (cumTime_s/physTime_s/V_m3);
|
||||
}
|
||||
|
||||
void WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn) {
|
||||
@@ -144,17 +160,195 @@ void WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density(double vAbs_ms, vec
|
||||
swap (zmin_m, zmax_m);
|
||||
swap (loc_min, loc_max);
|
||||
}
|
||||
// Check start and end in same r and phi bin
|
||||
// Todo: Check start and end in same r and phi bin here
|
||||
|
||||
dim3Map::iterator zItr_min = Map.lower_bound(zmin_m);
|
||||
dim3Map::iterator zItr_max = Map.lower_bound(zmax_m);
|
||||
double r_m = loc_min[1];
|
||||
double phi = loc_min[2];
|
||||
double l_m;
|
||||
vec3 zrPhiCords = vec3 (0,r_m,phi);
|
||||
double z_m, l_m;
|
||||
for (dim3Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||
l_m = get_Bin_l_m(Itr->first);
|
||||
container_base::get_Itr(Itr->second, deque<double> {r_m,phi})->second += l_m/vAbs_ms;
|
||||
z_m = Itr->first;
|
||||
l_m = get_Bin_l_m(z_m);
|
||||
zrPhiCords[0] = z_m;
|
||||
findBin(zrPhiCords)->second += l_m/vAbs_ms;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WGTS4D_ParticleTime_s_Container::WGTS4D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins, double mass_eV, double Emin_eV, double Emax_eV, double pointsPerEorder) : WGTS_Geo(z_min_m, z_max_m, r_max_m, zrphi_numBins) {
|
||||
this->Emin_eV = Emin_eV;
|
||||
this->Emax_eV = Emax_eV;
|
||||
this->pointsPerEorder = pointsPerEorder;
|
||||
this->mass_eV = mass_eV;
|
||||
init_Map();
|
||||
}
|
||||
|
||||
WGTS4D_ParticleTime_s_Container::WGTS4D_ParticleTime_s_Container(vec3 zrphi_numBins, double mass_eV, double Emin_eV, double Emax_eV, double pointsPerEorder) : WGTS_Geo(zrphi_numBins) {
|
||||
this->Emin_eV = Emin_eV;
|
||||
this->Emax_eV = Emax_eV;
|
||||
this->pointsPerEorder = pointsPerEorder;
|
||||
this->mass_eV = mass_eV;
|
||||
init_Map();
|
||||
}
|
||||
|
||||
void WGTS4D_ParticleTime_s_Container::init_Map() {
|
||||
// Give posibility for non linear Bins....
|
||||
int n_z = zrphi_numBins[0];
|
||||
int n_r = zrphi_numBins[1];
|
||||
int n_phi = zrphi_numBins[2];
|
||||
double step_z_m = (z_max_m-z_min_m)/n_z;
|
||||
double step_r_m = r_max_m/n_r;
|
||||
double step_phi = 2*pi/n_phi;
|
||||
|
||||
int E_interval = pointsPerEorder -1;
|
||||
int E_minI = floor(log10(Emin_eV)*E_interval);
|
||||
int E_maxI = ceil(log10(Emax_eV)*E_interval);
|
||||
|
||||
double z_m,r_m,phi, E_eV;
|
||||
for (int i_z=1;i_z<=n_z;i_z++) {
|
||||
z_m = z_min_m + i_z * step_z_m;
|
||||
for (int i_r=1;i_r<=n_r;i_r++) {
|
||||
r_m = i_r * step_r_m;
|
||||
for (int i_phi=1;i_phi<=n_phi;i_phi++) {
|
||||
phi = step_phi * i_phi;
|
||||
for (int i_E = E_minI;i_E<=E_maxI;i_E++) {
|
||||
E_eV = pow(10,double (i_E)/double(E_interval));
|
||||
add_ankerpoint(z_m, r_m, phi, E_eV, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double WGTS4D_ParticleTime_s_Container::getDensity_m3(vec3 loc_m, double physTime_s, cordStyle cordStyleIn) const {
|
||||
if (outside_Container(loc_m, cordStyleIn)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS4D_ParticleTime_s_Container::getDensity: loc_old or loc_new not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
loc_m = zrphiCords(loc_m, cordStyleIn);
|
||||
double V_m3 = get_Bin_V_m3(loc_m[0], loc_m[1]);
|
||||
return (get_CumTime_s(loc_m)/physTime_s/V_m3);
|
||||
}
|
||||
|
||||
void WGTS4D_ParticleTime_s_Container::up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn) {
|
||||
if (outside_Container(loc_old, cordStyleIn) || outside_Container(loc_new, cordStyleIn)) {
|
||||
stringstream ss;
|
||||
ss<<"WGTS4D_ParticleTime_s_Container::up_DriftApprox_Density: loc_old or loc_new not in Container.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
vec3 loc_min = zrphiCords(loc_old, cordStyleIn);
|
||||
vec3 loc_max = zrphiCords(loc_new, cordStyleIn);
|
||||
double zmin_m = loc_min[0];
|
||||
double zmax_m = loc_max[0];
|
||||
if (zmax_m < zmin_m) {
|
||||
swap (zmin_m, zmax_m);
|
||||
swap (loc_min, loc_max);
|
||||
}
|
||||
// Todo: Check start and end in same r and phi bin here
|
||||
|
||||
dim4Map::iterator zItr_min = Map.lower_bound(zmin_m);
|
||||
dim4Map::iterator zItr_max = Map.lower_bound(zmax_m);
|
||||
double r_m = loc_min[1];
|
||||
double phi = loc_min[2];
|
||||
double E_eV = calc_Ekin_eV_from_speed(vAbs_ms, mass_eV);
|
||||
vec3 zrPhiCords = vec3 (0,r_m,phi);
|
||||
double z_m, l_m;
|
||||
for (dim4Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||
z_m = Itr->first;
|
||||
l_m = get_Bin_l_m(z_m);
|
||||
zrPhiCords[0] = z_m;
|
||||
findBin(zrPhiCords, E_eV)->second += l_m/vAbs_ms;
|
||||
}
|
||||
}
|
||||
|
||||
double WGTS4D_ParticleTime_s_Container::get_CumTime_s(vec3 zrPhiCords) const {
|
||||
dim1Map EMap = findBin(zrPhiCords)->second;
|
||||
double num = 0;
|
||||
for (dim1Map::iterator Itr=EMap.begin();Itr!=EMap.end();Itr++) {
|
||||
num +=Itr->second;
|
||||
}
|
||||
return(num);
|
||||
}
|
||||
|
||||
double WGTS4D_ParticleTime_s_Container::roll_Energy_eV(vec3 loc_m, UniRNG *rngUni, cordStyle cordStyleIn) const {
|
||||
loc_m = zrphiCords(loc_m, cordStyleIn);
|
||||
dim1Map EMap = findBin(loc_m)->second;
|
||||
double maxValue = get_CumTime_s(loc_m);
|
||||
|
||||
|
||||
double sum = 0;
|
||||
double target = rngUni->random() * maxValue;
|
||||
dim1Map::iterator Itr = EMap.begin();
|
||||
do {
|
||||
sum += Itr->second;
|
||||
Itr++;
|
||||
} while(sum < target);
|
||||
Itr--;
|
||||
|
||||
if (Itr == EMap.begin() ) {
|
||||
return (Itr->first);
|
||||
} else {
|
||||
double E_eV = ( (Itr->first) + ((--Itr)->first) )/2;
|
||||
return (E_eV);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dim2Map::const_iterator WGTS4D_ParticleTime_s_Container::findBin(vec3 zrPhiCords) const { // improve -> template
|
||||
double z_m = zrPhiCords[0];
|
||||
dim3Map Map3;
|
||||
if (z_m > Map.rbegin()->first) {
|
||||
Map3 = (--Map.end())->second;
|
||||
} else {
|
||||
Map3 = Map.lower_bound(z_m)->second;
|
||||
}
|
||||
|
||||
double r_m = zrPhiCords[1];
|
||||
dim2Map Map2;
|
||||
if (r_m > Map3.rbegin()->first) {
|
||||
Map2 = (--Map3.end())->second;
|
||||
} else {
|
||||
Map2 = Map3.lower_bound(r_m)->second;
|
||||
}
|
||||
|
||||
double phi = zrPhiCords[2];
|
||||
dim2Map::const_iterator Itr;
|
||||
if (phi > Map3.rbegin()->first) {
|
||||
Itr = (--Map2.end());
|
||||
} else {
|
||||
Itr = Map2.lower_bound(phi);
|
||||
}
|
||||
|
||||
return (Itr);
|
||||
}
|
||||
|
||||
dim2Map::iterator WGTS4D_ParticleTime_s_Container::findBin(vec3 zrPhiCords) { // improve -> template
|
||||
double z_m = zrPhiCords[0];
|
||||
dim3Map Map3;
|
||||
if (z_m > Map.rbegin()->first) {
|
||||
Map3 = (--Map.end())->second;
|
||||
} else {
|
||||
Map3 = Map.lower_bound(z_m)->second;
|
||||
}
|
||||
|
||||
double r_m = zrPhiCords[1];
|
||||
dim2Map Map2;
|
||||
if (r_m > Map3.rbegin()->first) {
|
||||
Map2 = (--Map3.end())->second;
|
||||
} else {
|
||||
Map2 = Map3.lower_bound(r_m)->second;
|
||||
}
|
||||
|
||||
double phi = zrPhiCords[2];
|
||||
dim2Map::iterator Itr;
|
||||
if (phi > Map3.rbegin()->first) {
|
||||
Itr = (--Map2.end());
|
||||
} else {
|
||||
Itr = Map2.lower_bound(phi);
|
||||
}
|
||||
|
||||
return (Itr);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "container_base_functions.h"
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
typedef std::map<double,double> dim1Map;
|
||||
typedef std::pair<double,double> dim1Pair;
|
||||
|
||||
@@ -20,107 +22,128 @@ typedef std::pair<double,dim1Map> dim2Pair;
|
||||
typedef std::map<double,dim2Map> dim3Map;
|
||||
typedef std::pair<double,dim2Map> dim3Pair;
|
||||
|
||||
typedef std::map<double,dim3Map> dim4Map;
|
||||
typedef std::pair<double,dim3Map> dim4Pair;
|
||||
|
||||
typedef enum cordStyle{xyz, zrphi} cordStyle;
|
||||
|
||||
|
||||
class Base3D_FuncContainer {
|
||||
protected:
|
||||
dim3Map Map;
|
||||
public:
|
||||
Base3D_FuncContainer() {};
|
||||
Base3D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv(&Map, 3, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double z, double fxyz){container_base::add_To_Map(&Map, deque<double> {x,y,z,fxyz});};
|
||||
void add_ankerpoint(double x, double y, double z, double fxyz){container_base::add_To_Map(&Map, std::deque<double> {x,y,z,fxyz});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) const {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim3Map get_Map() const {return (Map);}
|
||||
protected:
|
||||
dim3Map Map;
|
||||
};
|
||||
|
||||
|
||||
class WGTS_Geo {
|
||||
public:
|
||||
WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
protected:
|
||||
void init_bin_maps();
|
||||
|
||||
double get_Bin_l_m (double z_m) const ;
|
||||
double get_Bin_V_m3(double r_m) const;
|
||||
|
||||
bool outside_Container(vec3 Cords, cordStyle cordStyleIn = xyz) const;
|
||||
bool check_z_outside (double z_m) const;
|
||||
bool check_r_outside (double r_m) const;
|
||||
vec3 zrphiCords(vec3 Cords, cordStyle cordStyleIn = xyz) const;
|
||||
|
||||
double z_min_m;
|
||||
double z_max_m;
|
||||
double r_max_m;
|
||||
vec3 zrphi_numBins;
|
||||
dim1Map bin_l_m;
|
||||
dim1Map bin_V_m3;
|
||||
|
||||
public:
|
||||
WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
WGTS_Geo(vec3 zrphi_numBins);
|
||||
|
||||
private:
|
||||
void init_bin_maps();
|
||||
|
||||
public:
|
||||
double get_Bin_l_m (double z_m) const ;
|
||||
double get_Bin_V_m3(double z_m, double r_m) const;
|
||||
|
||||
bool outside_Container(vec3 Cords, cordStyle cordStyleIn = xyz) const;
|
||||
bool check_z_outside (double z_m) const;
|
||||
bool check_r_outside (double r_m) const;
|
||||
|
||||
vec3 zrphiCords(vec3 Cords, cordStyle cordStyleIn) const;
|
||||
};
|
||||
|
||||
// WGTS3D_ParticleTime_s_Container Contains cumulative duration of stay in bin.
|
||||
class WGTS3D_ParticleTime_s_Container : public Base3D_FuncContainer , public WGTS_Geo {
|
||||
class WGTS3D_ParticleTime_s_Container : private Base3D_FuncContainer , private WGTS_Geo {
|
||||
public:
|
||||
WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
protected:
|
||||
WGTS3D_ParticleTime_s_Container(vec3 zrphi_numBins);
|
||||
private:
|
||||
void init_Map();
|
||||
using Base3D_FuncContainer::add_ankerpoint;
|
||||
using Base3D_FuncContainer::fillFromCSV;
|
||||
|
||||
|
||||
public:
|
||||
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz) const;
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
double getDensity_m3(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz) const;
|
||||
|
||||
protected:
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
private:
|
||||
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords) const {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords) {return (container_base::get_Itr(&Map, std::deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
dim1Map::const_iterator findBin(vec3 zrPhiCords) const {return (container_base::get_constItr(&Map, std::deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
};
|
||||
// Add option to load default from file...
|
||||
//Part3D_WGTS_Container(std::string loadFilePath, double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
//void check_Bins()
|
||||
|
||||
/*
|
||||
typedef std::map<double,dim3Map> dim4Map;
|
||||
typedef std::pair<double,dim3Map> dim4Pair;
|
||||
|
||||
class Base4D_FuncContainer {
|
||||
protected:
|
||||
dim4Map Map;
|
||||
|
||||
public:
|
||||
Base4D_FuncContainer() {};
|
||||
Base4D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv(&Map, 4, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double z, double E, double fxyzE){container_base::add_To_Map(&Map, deque<double> {x,y,z,E,fxyzE});};
|
||||
void add_ankerpoint(double x, double y, double z, double E, double fxyzE){container_base::add_To_Map(&Map, std::deque<double> {x,y,z,E,fxyzE});};
|
||||
|
||||
void exportToFile(std::string exportFilePath){container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
dim4Map get_Map() {return (Map);}
|
||||
protected:
|
||||
dim4Map Map;
|
||||
};
|
||||
|
||||
class WGTS4D_ParticleTime_s_Container : public Base4D_FuncContainer , public WGTS_Geo {
|
||||
public:
|
||||
WGTS4D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||
|
||||
class WGTS4D_ParticleTime_s_Container : private Base4D_FuncContainer , private WGTS_Geo {
|
||||
double mass_eV;
|
||||
double Emin_eV;
|
||||
double Emax_eV;
|
||||
double pointsPerEorder;
|
||||
|
||||
protected:
|
||||
public:
|
||||
WGTS4D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins, double mass_eV, double Emin_eV, double Emax_eV, double pointsPerEorder);
|
||||
WGTS4D_ParticleTime_s_Container(vec3 zrphi_numBins, double mass_eV, double Emin_eV, double Emax_eV, double pointsPerEorder);
|
||||
|
||||
private:
|
||||
void init_Map();
|
||||
using Base4D_FuncContainer::add_ankerpoint;
|
||||
using Base4D_FuncContainer::fillFromCSV;
|
||||
|
||||
|
||||
public:
|
||||
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz);
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
double getDensity_m3(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz) const ;
|
||||
private:
|
||||
double get_CumTime_s(vec3 zrPhiCords) const ;
|
||||
|
||||
protected:
|
||||
public:
|
||||
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||
private:
|
||||
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords) {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||
|
||||
public:
|
||||
double roll_Energy_eV(vec3 loc_m, UniRNG *rngUni, cordStyle cordStyleIn = xyz) const ;
|
||||
|
||||
dim2Map::iterator findBin(vec3 zrPhiCords);
|
||||
dim1Map::iterator findBin(vec3 zrPhiCords, double E_eV) {return (container_base::get_Itr(&Map, std::deque<double> {zrPhiCords[0], zrPhiCords[1], zrPhiCords[2], E_eV}));
|
||||
}
|
||||
dim2Map::const_iterator findBin(vec3 zrPhiCords) const;
|
||||
dim1Map::const_iterator findBin(vec3 zrPhiCords, double E_eV) const {return (container_base::get_constItr(&Map, std::deque<double> {zrPhiCords[0], zrPhiCords[1], zrPhiCords[2], E_eV}));
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
#endif /* density_container_hpp */
|
||||
|
||||
@@ -8,23 +8,23 @@
|
||||
|
||||
#include "electron_interactions.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
double e_T2_elasticScattering::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double Ekin_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = Uehara_eT2_ElasticScattering::calc_TCS(Ekin_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Kat->getTritiumDensity_m3(loc_m);
|
||||
double nT2_m3 = Pop->get_Density_m3(tritium2, loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
InteractionOut e_T2_elasticScattering::do_Interaction (Particle *interPart) const {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 vT2_ms = Kat->roll_totEqSpeed_ms(interPart->get_Location_m());
|
||||
vec3 vT2_ms = Pop->roll_Speed_ms(tritium2, interPart->get_Location_m());
|
||||
vec3 vLab_ms = v_ms - vT2_ms;
|
||||
double T_eV = calc_Ekin_eV_from_speed(vLab_ms, me_eV);
|
||||
double thetaLab = Uehara_eT2_ElasticScattering::roll_theta(T_eV, rngUni);
|
||||
@@ -52,12 +52,11 @@ double e_T2_ionization::get_macroSigma_m2(const Particle &interPart) const {
|
||||
double T_eV = interPart.get_EKin_eV();
|
||||
double microSigma_m2 = BED_TCS_average_container.get_Value(T_eV);
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double nT2_m3 = Kat->getTritiumDensity_m3(loc_m);
|
||||
double nT2_m3 = Pop->get_Density_m3(tritium2, loc_m);
|
||||
return (microSigma_m2*nT2_m3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
InteractionOut e_T2_ionization::do_Interaction (Particle *interPart) const {
|
||||
vec3 vLab_ms = roll_vLab_ms(*interPart);
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
@@ -88,16 +87,22 @@ InteractionOut e_T2_ionization::do_Interaction (Particle *interPart) const {
|
||||
v2New_ms = v2Absnew_ms*P2newDir + vOff_ms;
|
||||
|
||||
interPart->set_Speed_ms(v1New_ms);
|
||||
Particle eNew = PartBuilder.createElectron(interPart->get_Location_m(), v2New_ms, -1, interPart->get_Id());
|
||||
|
||||
vec3 loc_m = interPart->get_Location_m();
|
||||
Particle eNew = PartBuilder.createElectron(loc_m, v2New_ms, -1, interPart->get_Id());
|
||||
InteractionOut InterOut;
|
||||
InterOut.add_newParticle(eNew);
|
||||
|
||||
vec3 vT_ms = Pop->roll_Speed_ms(tritium, loc_m);
|
||||
Particle TNew = PartBuilder.createTritium(loc_m, vT_ms, -1, interPart->get_Id());
|
||||
InterOut.add_newParticle(TNew);
|
||||
|
||||
return(InterOut);
|
||||
}
|
||||
|
||||
vec3 e_T2_ionization::roll_vLab_ms(const Particle &interPart) const {
|
||||
vec3 v_ms = interPart.get_Speed_ms();
|
||||
vec3 vT2_ms = Kat->roll_totEqSpeed_ms(interPart.get_Location_m());
|
||||
vec3 vT2_ms = Pop->roll_Speed_ms(tritium2, 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);
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
*/
|
||||
class e_T2_elasticScattering : public Interaction {
|
||||
public:
|
||||
e_T2_elasticScattering(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(Kat, rngUni, rngNormal) {};
|
||||
|
||||
species get_Species() const {return(electron);}
|
||||
e_T2_elasticScattering(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(electron, Pop, rngUni, rngNormal) {};
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
InteractionOut do_Interaction (Particle *interPart) const;
|
||||
@@ -42,9 +40,7 @@ class e_T2_ionization : public Interaction {
|
||||
ParticleBuilder PartBuilder;
|
||||
|
||||
public:
|
||||
e_T2_ionization(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(Kat, rngUni, rngNormal) {};
|
||||
|
||||
species get_Species() const {return(electron);}
|
||||
e_T2_ionization(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(electron, Pop, rngUni, rngNormal) {};
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
InteractionOut do_Interaction (Particle *interPart) const;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// electron_population.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "electron_population.hpp"
|
||||
|
||||
double e_Density::get_Density_m3(vec3 loc_m) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
double physTime_s = Tim->get_physTime_s();
|
||||
double dens = e_Container.getDensity_m3(loc_m, physTime_s, xyz);
|
||||
return(dens);
|
||||
}
|
||||
|
||||
vec3 e_Density::roll_Speed_ms(vec3 loc_m) const {
|
||||
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);
|
||||
}
|
||||
|
||||
void e_Density::up_Denisty(vec3 oldLoc_m, vec3 newLoc_m, double Ekin_eV) {
|
||||
double vAbs_ms = calc_Speed_from_Ekin_eV(Ekin_eV, me_eV);
|
||||
e_Container.upDensity(vAbs_ms, oldLoc_m, newLoc_m);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// electron_population.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_population_hpp
|
||||
#define electron_population_hpp
|
||||
|
||||
#include "timer.hpp"
|
||||
#include "density_container.hpp"
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
#include "constants.h"
|
||||
|
||||
|
||||
class e_Density : public Population_Base, public RNG_Base {
|
||||
WGTS4D_ParticleTime_s_Container e_Container;
|
||||
Timer *Tim;
|
||||
|
||||
public:
|
||||
e_Density(Timer *Tim, UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(electron), RNG_Base(rngUni, rngNormal), e_Container(vec3(10,10,10), me_eV, zero, 2e4, 20) {
|
||||
this->Tim = Tim;
|
||||
};
|
||||
|
||||
double get_Density_m3(vec3 loc_m) const ;
|
||||
|
||||
vec3 roll_Speed_ms(vec3 loc_m) const;
|
||||
|
||||
void up_Denisty(vec3 oldLoc_m, vec3 newLoc_m, double Ekin_eV);
|
||||
};
|
||||
|
||||
|
||||
#endif /* electron_population_hpp */
|
||||
@@ -9,22 +9,9 @@
|
||||
#ifndef error_types_h
|
||||
#define error_types_h
|
||||
|
||||
/*
|
||||
#include "constants.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
#include <blitz/array.h>
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
*/
|
||||
#include <iostream>
|
||||
|
||||
|
||||
struct MyException : public std::exception
|
||||
{
|
||||
std::string s;
|
||||
@@ -32,4 +19,6 @@ struct MyException : public std::exception
|
||||
~MyException() throw () {}
|
||||
const char* what() const throw() { return s.c_str(); }
|
||||
};
|
||||
|
||||
|
||||
#endif /* error_types_h */
|
||||
|
||||
@@ -10,17 +10,18 @@
|
||||
#define find_species_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline typename std::vector<T*>::iterator find_SpeciesItr(std::vector<T*> Vec, species Species) {
|
||||
inline typename std::vector<T*>::iterator find_SpeciesItr(std::vector<T*> *Vec, species Species) {
|
||||
typename std::vector<T*>::iterator Itr;
|
||||
if (Vec.size() == 0) {
|
||||
Itr = Vec.end();
|
||||
if (Vec->size() == 0) {
|
||||
Itr = Vec->end();
|
||||
} else {
|
||||
Itr = Vec.begin();
|
||||
while (Itr != Vec.end() ) {
|
||||
Itr = Vec->begin();
|
||||
while (Itr != Vec->end() ) {
|
||||
if ((*Itr)->get_Species() == Species) {
|
||||
break;
|
||||
}
|
||||
@@ -31,13 +32,13 @@ inline typename std::vector<T*>::iterator find_SpeciesItr(std::vector<T*> Vec, s
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename std::vector<T*>::const_iterator find_SpeciesConstItr(const std::vector<T*> Vec, species Species) {
|
||||
inline typename std::vector<T*>::const_iterator find_SpeciesConstItr(const std::vector<T*> *Vec, species Species) {
|
||||
typename std::vector<T*>::const_iterator Itr;
|
||||
if (Vec.size() == 0) {
|
||||
Itr = Vec.end();
|
||||
if (Vec->size() == 0) {
|
||||
Itr = Vec->cend();
|
||||
} else {
|
||||
Itr = Vec.cbegin();
|
||||
while (Itr != Vec.cend() ) {
|
||||
Itr = Vec->cbegin();
|
||||
while (Itr != Vec->cend() ) {
|
||||
if ( (*Itr)->get_Species() == Species) {
|
||||
break;
|
||||
}
|
||||
@@ -47,4 +48,5 @@ inline typename std::vector<T*>::const_iterator find_SpeciesConstItr(const std::
|
||||
return (Itr);
|
||||
}
|
||||
|
||||
|
||||
#endif /* find_species_h */
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
#include "function_container.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
inline void Base_FuncContainer::averageMap_from_edgeMap (dim1Map *averageMap, dim1Map &edgeMap) {
|
||||
averageMap->clear();
|
||||
dim1Map::iterator curItr, afterItr;
|
||||
@@ -54,8 +57,7 @@ inline double Base_FuncContainer::sampleValue_from_stackedMap (const dim1Map &st
|
||||
return (stackedMap.lower_bound(rngUni->random())->second);
|
||||
}
|
||||
|
||||
// Base1D_Container
|
||||
// AddData
|
||||
|
||||
void Base1D_FuncContainer::fillFromFunction(double (*f)(const double &), double minKey, double maxKey, int numpointsPerOrder) {
|
||||
int interval = numpointsPerOrder -1;
|
||||
int minI = floor(log10(minKey)*interval);
|
||||
@@ -82,7 +84,7 @@ void Base1D_FuncContainer::fillFromFunction(double (*f)(const double &), double
|
||||
}
|
||||
}
|
||||
|
||||
// average1D_Container
|
||||
|
||||
void Average1D_FuncContainer::set_Map(dim1Map &edgeMap) {
|
||||
averageMap_from_edgeMap (&Map, edgeMap);
|
||||
}
|
||||
@@ -93,9 +95,6 @@ void Average1D_FuncContainer::set_Map(Edge1D_FuncContainer &edgeContainer) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// edge2D_Container
|
||||
|
||||
void Edge2D_FuncContainer::get_Ionization_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numYpoints) {
|
||||
int Xinterval = numpointsPerXOrder -1;
|
||||
int minXI = floor(log10(minX)*Xinterval);
|
||||
@@ -141,7 +140,7 @@ void Edge2D_FuncContainer::get_Elastic_fromFunction(double (*f)(const double &,
|
||||
}
|
||||
}
|
||||
|
||||
// Average2D_Container
|
||||
|
||||
void Average2D_FuncContainer::set_Map(dim2Map &edgeMap) {
|
||||
// should template averageMap_from_edgeMap function and reuse it for first iteration...
|
||||
Map.clear();
|
||||
@@ -165,7 +164,7 @@ void Average2D_FuncContainer::set_Map(Edge2D_FuncContainer &edgeContainer) {
|
||||
set_Map(edgeMap);
|
||||
}
|
||||
|
||||
// Stacked2D_Container:
|
||||
|
||||
void Stacked2D_FuncContainer::set_Map(dim2Map &averageMap) {
|
||||
Map.clear();
|
||||
dim1Map tempMap;
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
#ifndef function_container_hpp
|
||||
#define function_container_hpp
|
||||
|
||||
#include "container_base_functions.h"
|
||||
|
||||
#include <random/uniform.h>
|
||||
|
||||
#include "container_base_functions.h"
|
||||
|
||||
typedef std::map<double,double> dim1Map;
|
||||
typedef std::pair<double,double> dim1Pair;
|
||||
|
||||
|
||||
// Base_FuncContainer: Provide Operation on dim1Maps.
|
||||
class Base_FuncContainer {
|
||||
protected:
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
void fillFromFunction(double (*f)(const double &), double minX, double maxX, int numpointsPerOrder);
|
||||
void fillFromCSV(std::string loadFilePath) {container_base::add_From_Csv (&Map, 1, loadFilePath);};
|
||||
void add_ankerpoint(double x, double fx) {container_base::add_To_Map(&Map, deque<double> {x,fx});};
|
||||
void add_ankerpoint(double x, double fx) {container_base::add_To_Map(&Map, std::deque<double> {x,fx});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) const {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
Edge1D_FuncContainer() : Base1D_FuncContainer() {};
|
||||
Edge1D_FuncContainer(std::string loadFilePath) : Base1D_FuncContainer(loadFilePath){};
|
||||
|
||||
double interpolate(double x) const {return (container_base::interpolate_Value(Map,deque<double>{x}));};
|
||||
double interpolate(double x) const {return (container_base::interpolate_Value(Map,std::deque<double>{x}));};
|
||||
};
|
||||
|
||||
// Average1D_Container: Calculates new edges, so values from edge bin correspond to mean value.
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
void set_Map(dim1Map &edgeMap);
|
||||
void set_Map(Edge1D_FuncContainer &edgeContainer);
|
||||
|
||||
double get_Value(double x) const {return ( container_base::get_Value(Map, deque<double> {x}) );};
|
||||
double get_Value(double x) const {return ( container_base::get_Value(Map, std::deque<double> {x}) );};
|
||||
};
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
Base2D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||
|
||||
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv (&Map, 2, loadFilePath);};
|
||||
void add_ankerpoint(double x, double y, double fxy) {container_base::add_To_Map(&Map, deque<double> {x,y,fxy});};
|
||||
void add_ankerpoint(double x, double y, double fxy) {container_base::add_To_Map(&Map, std::deque<double> {x,y,fxy});};
|
||||
|
||||
void exportToFile(std::string exportFilePath) {container_base::export_To_Csv(Map, exportFilePath);};
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
Edge2D_FuncContainer() : Base2D_FuncContainer() {};
|
||||
Edge2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath) {};
|
||||
|
||||
double interpolate(double x, double y) const {return (container_base::interpolate_Value(Map,deque<double>{x,y}));};
|
||||
double interpolate(double x, double y) const {return (container_base::interpolate_Value(Map,std::deque<double>{x,y}));};
|
||||
|
||||
void get_Ionization_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numpointsPerYOrder);
|
||||
void get_Elastic_fromFunction(double (*f)(const double &, const double &), double minX, double maxX, int numpointsPerXOrder, int numpointsOverY);
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
void set_Map(dim2Map &edgeMap);
|
||||
void set_Map(Edge2D_FuncContainer &edgeContainer);
|
||||
double get_Value(double x, double y) const {return ( container_base::get_Value(Map, deque<double> {x,y}) );};
|
||||
double get_Value(double x, double y) const {return ( container_base::get_Value(Map, std::deque<double> {x,y}) );};
|
||||
};
|
||||
|
||||
// Stacked2D_Container:
|
||||
|
||||
@@ -6,18 +6,20 @@
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
#include "injector.hpp"
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
const int Injector::injectionMethod = getParameter("injectionMethod");
|
||||
const double Injector::injectionEnergy_eV = getParameter("injectionEnergy_eV");
|
||||
|
||||
Particle Injector::injectElectron (const int &newId) {
|
||||
double r_m = Kat->get_radius_m()*sqrt(rngUni->random());
|
||||
double r_m = Katrin_Geo::get_radius_m()*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double z_WGTSstart_m = Kat->get_z_WGTSstart_m();
|
||||
double z_WGTSend_m = Kat->get_z_WGTSend_m();
|
||||
double wgtsLength_m = z_WGTSend_m - z_WGTSstart_m;
|
||||
double z_WGTSstart_m = Katrin_Geo::get_z_WGTSstart_m();
|
||||
double wgtsLength_m = Katrin_Geo::get_wgtsLength_m();
|
||||
|
||||
double z_WGTS_start_to_half_pos_m = sqrt(rngUni->random())*wgtsLength_m/2;
|
||||
double z_m = (rngUni->random()<0.5) ? z_WGTS_start_to_half_pos_m : wgtsLength_m - z_WGTS_start_to_half_pos_m;
|
||||
@@ -44,10 +46,9 @@ Particle Injector::injectElectron (const int &newId) {
|
||||
}
|
||||
|
||||
double Injector::roll_FermiEnergy_eV() {
|
||||
// get Energy distribution using Rejection Method
|
||||
double pmax,Emin_eV, Emax_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
Emin_eV = 1e-15;
|
||||
Emin_eV = zero;
|
||||
Emax_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
|
||||
@@ -9,28 +9,27 @@
|
||||
#ifndef injector_hpp
|
||||
#define injector_hpp
|
||||
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
|
||||
class Injector : RNG_Base {
|
||||
static const int injectionMethod;
|
||||
static const double injectionEnergy_eV;
|
||||
|
||||
ParticleBuilder PartFac;
|
||||
|
||||
public:
|
||||
Injector(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){
|
||||
this->Kat = Kat;
|
||||
};
|
||||
Injector() : RNG_Base(NULL, NULL) {};
|
||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){};
|
||||
|
||||
Particle injectElectron (const int &newId);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &Ekin_eV);
|
||||
double get_FermiFunction(const double &Z, const double &Ekin_eV);
|
||||
|
||||
Katrin *Kat;
|
||||
ParticleBuilder PartFac;
|
||||
|
||||
static const int injectionMethod;
|
||||
static const double injectionEnergy_eV;
|
||||
};
|
||||
|
||||
|
||||
#endif /* injector_hpp */
|
||||
|
||||
@@ -9,16 +9,18 @@
|
||||
#ifndef interaction_base_hpp
|
||||
#define interaction_base_hpp
|
||||
|
||||
#include "error_types.h"
|
||||
#include "particle.hpp"
|
||||
#include "katrin.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "population.hpp"
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
class InteractionOut {
|
||||
bool deleteCur;
|
||||
deque <Particle> newParticles;
|
||||
std::deque <Particle> newParticles;
|
||||
|
||||
public:
|
||||
InteractionOut() {reset();};
|
||||
@@ -29,24 +31,36 @@ public:
|
||||
}
|
||||
|
||||
void set_deleteCur(const bool &deleteCur) {this->deleteCur = deleteCur;}
|
||||
void set_newParticles(const deque<Particle> &newParticles) {this->newParticles = newParticles;}
|
||||
void set_newParticles(const std::deque<Particle> &newParticles) {this->newParticles = newParticles;}
|
||||
void add_newParticle(const Particle &newParticle) {newParticles.push_back(newParticle);}
|
||||
|
||||
bool get_deleteCur() const {return(deleteCur);};
|
||||
deque<Particle> get_newParticles() const {return(newParticles);};
|
||||
void appendDeque(std::deque<Particle> *Que, int *currentNewID) {
|
||||
Particle curPart;
|
||||
for (std::deque<Particle>::iterator Itr = newParticles.begin();Itr!=newParticles.end();Itr++) {
|
||||
curPart = (*Itr);
|
||||
curPart.set_Id(*currentNewID);
|
||||
currentNewID++;
|
||||
Que->push_back(curPart);
|
||||
}
|
||||
}
|
||||
|
||||
bool terminateCurrent() const {return(deleteCur);};
|
||||
//std::deque<Particle> get_newParticles() const {return(newParticles);};
|
||||
};
|
||||
|
||||
|
||||
class Interaction : public RNG_Base {
|
||||
protected:
|
||||
Katrin *Kat;
|
||||
Population *Pop;
|
||||
species Species;
|
||||
|
||||
public:
|
||||
Interaction(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
Interaction(species Species, Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Species = Species;
|
||||
this->Pop = Pop;
|
||||
};
|
||||
|
||||
virtual species get_Species() const = 0;
|
||||
species get_Species() const {return(Species);}
|
||||
|
||||
virtual double get_macroSigma_m2(const Particle &interPart) const = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) const = 0;
|
||||
|
||||
@@ -12,23 +12,32 @@
|
||||
const int InteractionBuilder::eT2elastic = getParameter("eT2elastic");
|
||||
const int InteractionBuilder::eT2ionization = getParameter("eT2ionization");
|
||||
|
||||
InteractionProcessor InteractionBuilder::build_InteractionProcessor() {
|
||||
InteractionProcessor InterProcessor(Kat,rngUni,rngNormal);
|
||||
InterProcessor.add_ParticleInteraction(build_eInteractions());
|
||||
InteractionProcessor InteractionBuilder::build_InteractionProcessor(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
InteractionProcessor InterProcessor;
|
||||
InterProcessor.add_ParticleInteraction(build_eInteractions(Pop, rngUni, rngNormal));
|
||||
InterProcessor.add_ParticleInteraction(build_TInteractions(Pop, rngUni, rngNormal));
|
||||
return(InterProcessor);
|
||||
}
|
||||
|
||||
ParticleInteractions* InteractionBuilder::build_eInteractions() {
|
||||
ParticleInteractions* eInteractions = new ParticleInteractions(Kat, rngUni, rngNormal, electron);
|
||||
ParticleInteractions* InteractionBuilder::build_eInteractions(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
ParticleInteractions* eInteractions = new ParticleInteractions(electron, Pop, rngUni, rngNormal);
|
||||
if (eT2elastic == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_elasticScattering(Kat, rngUni, rngNormal));
|
||||
eInteractions->add_Interaction(new e_T2_elasticScattering(Pop, rngUni, rngNormal));
|
||||
}
|
||||
if (eT2ionization == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_ionization(Kat, rngUni, rngNormal));
|
||||
eInteractions->add_Interaction(new e_T2_ionization(Pop, rngUni, rngNormal));
|
||||
}
|
||||
return(eInteractions);
|
||||
}
|
||||
|
||||
ParticleInteractions* InteractionBuilder::build_TInteractions(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
ParticleInteractions* TInteractions = new ParticleInteractions(tritium, Pop, rngUni, rngNormal);
|
||||
|
||||
TInteractions->add_Interaction(new T_T2_elasticScattering(Pop, rngUni, rngNormal));
|
||||
|
||||
return(TInteractions);
|
||||
}
|
||||
|
||||
/*
|
||||
ParticleInteractions InteractionBuilder::build_T2Interactions() {
|
||||
|
||||
|
||||
@@ -9,30 +9,24 @@
|
||||
#ifndef interaction_builder_hpp
|
||||
#define interaction_builder_hpp
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
|
||||
|
||||
#include "population.hpp"
|
||||
#include "interaction_processor.hpp"
|
||||
#include "interaction_species.hpp"
|
||||
#include "electron_interactions.hpp"
|
||||
#include "tritium_interactions.hpp"
|
||||
|
||||
class InteractionBuilder : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
|
||||
|
||||
class InteractionBuilder {
|
||||
static const int eT2ionization;
|
||||
static const int eT2elastic;
|
||||
|
||||
public:
|
||||
InteractionBuilder(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
}
|
||||
InteractionProcessor build_InteractionProcessor();
|
||||
|
||||
InteractionBuilder() {};
|
||||
|
||||
static InteractionProcessor build_InteractionProcessor(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal);
|
||||
private:
|
||||
ParticleInteractions* build_eInteractions();
|
||||
//ParticleInteractions* build_T2Interactions();
|
||||
static ParticleInteractions* build_eInteractions(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal);
|
||||
static ParticleInteractions* build_TInteractions(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#include "interaction_processor.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
InteractionOut InteractionProcessor::do_Interaction(Particle *interPart) const {
|
||||
species Species = interPart->get_Species();
|
||||
@@ -30,7 +34,6 @@ double InteractionProcessor::get_macroSigma_m2(const Particle &interPart) const
|
||||
} else {
|
||||
cout<<"Warning: No Interaction for Particle of Species"<<Species<<"\n";
|
||||
}
|
||||
macroSigma_m2 = macroSigma_m2==0 ? 1e-15 : macroSigma_m2; // Small Value will lead to huge mfp and particle will get out of WGTS
|
||||
return (macroSigma_m2);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,17 @@
|
||||
#define interaction_processor_hpp
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
#include "find_species.h"
|
||||
|
||||
#include "find_species.h"
|
||||
|
||||
typedef std::vector <ParticleInteractions*> ParticleInteractionsVec;
|
||||
|
||||
class InteractionProcessor : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
|
||||
class InteractionProcessor {
|
||||
ParticleInteractionsVec ParticleInteractions;
|
||||
|
||||
public:
|
||||
InteractionProcessor(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){
|
||||
this->Kat = Kat;
|
||||
};
|
||||
InteractionProcessor() {};
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart) const;
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
@@ -32,12 +30,11 @@ public:
|
||||
|
||||
bool empty() const {return (ParticleInteractions.size()==0 ? true : false);}
|
||||
private:
|
||||
ParticleInteractionsVec::const_iterator find_ParticleInteraction (species findSpec) const {
|
||||
return (find_SpeciesConstItr(ParticleInteractions, findSpec));
|
||||
};
|
||||
ParticleInteractionsVec::iterator find_ParticleInteraction (species findSpec) {
|
||||
return (find_SpeciesItr(ParticleInteractions, findSpec));
|
||||
};
|
||||
ParticleInteractionsVec::const_iterator find_ParticleInteraction (species findSpec) const {return (find_SpeciesConstItr(&ParticleInteractions, findSpec));}
|
||||
ParticleInteractionsVec::iterator find_ParticleInteraction (species findSpec) {return (find_SpeciesItr(&ParticleInteractions, findSpec));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* interaction_processor_hpp */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
InteractionOut ParticleInteractions::do_Interaction(Particle *interPart) const {
|
||||
double macroSigma_m2 = get_macroSigma_m2(*interPart);
|
||||
if (macroSigma_m2 == 0) {
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
#ifndef interaction_species_hpp
|
||||
#define interaction_species_hpp
|
||||
|
||||
#include "population.hpp"
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
typedef std::vector<Interaction*> InteractionsVec;
|
||||
|
||||
|
||||
class ParticleInteractions : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
Population *Pop;
|
||||
species Species;
|
||||
InteractionsVec Interactions;
|
||||
|
||||
public:
|
||||
ParticleInteractions(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal, species Species) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
ParticleInteractions(species Species, Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Pop = Pop;
|
||||
this->Species = Species;
|
||||
};
|
||||
|
||||
@@ -33,4 +36,5 @@ public:
|
||||
bool empty() const {return (Interactions.size()==0 ? true : false);}
|
||||
};
|
||||
|
||||
|
||||
#endif /* interaction_species_hpp */
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// katrin.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.09.18.
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
|
||||
#include "sstream"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const double Katrin::wgtsMagField_T = getParameter("wgtsMagField_T");
|
||||
|
||||
const double Katrin::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
const double Katrin::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double Katrin::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
void Katrin::check_Properties() {
|
||||
// Geometrics
|
||||
stringstream ss;
|
||||
ss<<"Katrin::check_Properties: ";
|
||||
if (rearwallZ_m>wgtsStartZ_m) {
|
||||
ss<<"rearwallZ_m>wgtsStartZ_m"<<endl;
|
||||
MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
double Katrin::getTritiumDensity_m3(vec3 loc_m) {
|
||||
double z_wgtsCords_m = loc_m[2] - wgtsStartZ_m; // New Cords, where wgtsStart equals z=0
|
||||
double reductget_ionFactor;
|
||||
if (z_wgtsCords_m<0) { //outside of tank
|
||||
reductget_ionFactor = 1e-9;
|
||||
} else {
|
||||
double zProjection_m = (z_wgtsCords_m < wgtsLength_m()/2) ? z_wgtsCords_m : wgtsLength_m() - z_wgtsCords_m;
|
||||
reductget_ionFactor = zProjection_m/wgtsLength_m()*2; //Correction since reflection
|
||||
}
|
||||
return(reductget_ionFactor * wgtsT2MaxDensity_m3);
|
||||
}
|
||||
|
||||
vec3 Katrin::roll_totEqSpeed_ms(vec3 loc_m) {
|
||||
return ( get_flowEqSpeed_ms(loc_m) + roll_thermEqSpeed_ms(loc_m) );
|
||||
}
|
||||
|
||||
vec3 Katrin::get_flowEqSpeed_ms(vec3 loc_m) {
|
||||
vec3 speed_ms;
|
||||
double sign = (loc_m[2] < wgtsStartZ_m + wgtsLength_m()/2.) ? -1 : 1;
|
||||
double flow_ms = sign*wgtsT2FlowSpeed_ms;
|
||||
speed_ms = 0,0,flow_ms;
|
||||
return (speed_ms);
|
||||
}
|
||||
|
||||
vec3 Katrin::roll_thermEqSpeed_ms(vec3 loc_m) {
|
||||
double tempOffsetABS_ms = calc_Speed_from_Ekin_eV(roll_MBEnergy(wgtsTemp_K,mT2_eV,rngNormal), mT2_eV);
|
||||
vec3 speed_ms = roll_uniform_direction(rngUni)*tempOffsetABS_ms;
|
||||
return(speed_ms);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// katrin.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 20.09.18.
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef katrin_hpp
|
||||
#define katrin_hpp
|
||||
|
||||
#include "constants.h"
|
||||
#include "random_operations.h"
|
||||
|
||||
#include "density_container.hpp"
|
||||
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include "blitz/array.h"
|
||||
|
||||
|
||||
|
||||
class Katrin : public RNG_Base{
|
||||
public:
|
||||
Katrin(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
check_Properties ();
|
||||
};
|
||||
|
||||
private:
|
||||
void check_Properties();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* katrin_hpp */
|
||||
@@ -7,3 +7,8 @@
|
||||
//
|
||||
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
const double Katrin_Fields::wgtsMagField_T = getParameter("wgtsMagField_T");
|
||||
|
||||
@@ -14,21 +14,20 @@
|
||||
|
||||
class Katrin_Fields {
|
||||
static const double wgtsMagField_T;
|
||||
|
||||
Katrin_Geo *Kat_Geo;
|
||||
|
||||
public:
|
||||
Katrin_Fields() {};
|
||||
Katrin_Fields(){};
|
||||
|
||||
vec3 getMagField_T(vec3 loc_m) const {
|
||||
Kat_Geo->check_inKatrin(loc_m);
|
||||
static vec3 getMagField_T(vec3 loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
return (vec3(0,0,wgtsMagField_T));
|
||||
}
|
||||
vec3 getElField_Vm(vec3 loc_m) const {
|
||||
Kat_Geo->check_inKatrin(loc_m);
|
||||
static vec3 getElField_Vm(vec3 loc_m) {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
return (vec3(0,0,0));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* katrin_fields_hpp */
|
||||
|
||||
@@ -8,29 +8,31 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "error_types.h"
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "error_types.h"
|
||||
#include "read_system.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const double Katrin_Geo::rearwallZ_m = getParameter("rearwallZ_m");
|
||||
const double Katrin_Geo::wgtsStartZ_m = getParameter("wgtsStartZ_m");
|
||||
const double Katrin_Geo::wgtsEndZ_m = getParameter("wgtsEndZ_m");
|
||||
const double Katrin_Geo::wgtsRadius_m = getParameter("wgtsRadius_m");
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Katrin_Geo::check_inWGTS(vec3 loc_m) {
|
||||
if (inWGTS(loc_m)) {
|
||||
if (!inWGTS(loc_m)) {
|
||||
stringstream ss;
|
||||
ss<<"Katrin_Geo::check_inWGTS: Location not within WGTS\nLocation:\t"<<loc_m<<"\n";
|
||||
ss<<"Katrin_Geo::check_inWGTS: Location not within WGTS\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void Katrin_Geo::check_inKatrin(vec3 loc_m) {
|
||||
if (inKatrin(loc_m)) {
|
||||
if (!inKatrin(loc_m)) {
|
||||
stringstream ss;
|
||||
ss<<"Katrin_Geo::check_inKatrin: Location not within Katrin\nLocation:\t"<<loc_m<<"\n";
|
||||
ss<<"Katrin_Geo::check_inKatrin: Location not within Katrin\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
#ifndef katrin_geo_hpp
|
||||
#define katrin_geo_hpp
|
||||
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include "kinematics.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
|
||||
class Katrin_Geo {
|
||||
static const double rearwallZ_m;
|
||||
@@ -32,9 +31,8 @@ public:
|
||||
|
||||
static bool inWGTS(vec3 loc_m);
|
||||
static bool inKatrin(vec3 loc_m);
|
||||
|
||||
private:
|
||||
static double wgtsLength_m() {return (get_z_WGTSend_m() - get_z_WGTSstart_m());};
|
||||
|
||||
static double get_wgtsLength_m() {return (get_z_WGTSend_m() - get_z_WGTSstart_m());};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// katrin_population_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "katrin_population_builder.hpp"
|
||||
|
||||
|
||||
const int InteractionBuilder::eT2elastic = getParameter("eT2elastic");
|
||||
const int InteractionBuilder::eT2ionization = getParameter("eT2ionization");
|
||||
|
||||
InteractionProcessor InteractionBuilder::build_InteractionProcessor() {
|
||||
InteractionProcessor InterProcessor(Kat,rngUni,rngNormal);
|
||||
InterProcessor.add_ParticleInteraction(build_eInteractions());
|
||||
return(InterProcessor);
|
||||
}
|
||||
|
||||
ParticleInteractions* InteractionBuilder::build_eInteractions() {
|
||||
ParticleInteractions* eInteractions = new ParticleInteractions(Kat, rngUni, rngNormal, electron);
|
||||
if (eT2elastic == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_elasticScattering(Kat, rngUni, rngNormal));
|
||||
}
|
||||
if (eT2ionization == 1) {
|
||||
eInteractions->add_Interaction(new e_T2_ionization(Kat, rngUni, rngNormal));
|
||||
}
|
||||
return(eInteractions);
|
||||
}
|
||||
|
||||
/*
|
||||
ParticleInteractions InteractionBuilder::build_T2Interactions() {
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -1,40 +0,0 @@
|
||||
//
|
||||
// katrin_population_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef katrin_population_builder_hpp
|
||||
#define katrin_population_builder_hpp
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
class Katrin_Populations_Builder {
|
||||
|
||||
};
|
||||
|
||||
|
||||
class InteractionBuilder : public RNG_Base {
|
||||
Katrin *Kat;
|
||||
|
||||
static const int eT2ionization;
|
||||
static const int eT2elastic;
|
||||
|
||||
public:
|
||||
InteractionBuilder(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Kat = Kat;
|
||||
}
|
||||
InteractionProcessor build_InteractionProcessor();
|
||||
|
||||
|
||||
private:
|
||||
ParticleInteractions* build_eInteractions();
|
||||
//ParticleInteractions* build_T2Interactions();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* katrin_population_builder_hpp */
|
||||
@@ -9,16 +9,15 @@
|
||||
#ifndef kinematics_h
|
||||
#define kinematics_h
|
||||
|
||||
#include <sstream>
|
||||
#include <blitz/tinyvec2.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
|
||||
#include <blitz/tinyvec2.h>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
|
||||
|
||||
inline double vec3Abs(const vec3 &vec) {
|
||||
return( sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2)) );
|
||||
}
|
||||
@@ -125,4 +124,5 @@ inline vec3 calc_newDirection(const vec3 &direction_old, const double &theta_cha
|
||||
return(vec3(sin(theta_new)*cos(phi_new) , sin(theta_new)*sin(phi_new) , cos(theta_new)));
|
||||
}
|
||||
|
||||
|
||||
#endif /* kinematics_h */
|
||||
|
||||
@@ -7,54 +7,13 @@
|
||||
//
|
||||
|
||||
#include "simulation.hpp"
|
||||
#include "BED_eT2_ionization.hpp"
|
||||
#include "function_container.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void createBED_TCS_Func_container() {
|
||||
Edge1D_FuncContainer BED_edge_TCS;
|
||||
BED_edge_TCS.fillFromFunction(BED_eT2_Ionization::calc_TCS, 15, 20000, 100);
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV, BED_eT2_Ionization::calc_TCS(EionT2_eV));
|
||||
BED_edge_TCS.add_ankerpoint(EionT2_eV+1e-4, BED_eT2_Ionization::calc_TCS(EionT2_eV+1e-4));
|
||||
BED_edge_TCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_edge_TCS.dat");
|
||||
|
||||
Average1D_FuncContainer BED_average_TCS;
|
||||
BED_average_TCS.set_Map(BED_edge_TCS);
|
||||
BED_average_TCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_average_TCS.dat");
|
||||
}
|
||||
|
||||
void createBED_SDCS_Func2D_container() {
|
||||
Edge2D_FuncContainer BED_edge_SDCS;
|
||||
BED_edge_SDCS.get_Ionization_fromFunction(BED_eT2_Ionization::calc_SDCS, 15, 20000, 50, 10);
|
||||
BED_edge_SDCS.add_ankerpoint(EionT2_eV, 0,0);
|
||||
double xmin =EionT2_eV+1e-4;
|
||||
double ymin = (xmin-EionT2_eV)/2;
|
||||
BED_edge_SDCS.add_ankerpoint(xmin, ymin,BED_eT2_Ionization::calc_SDCS(xmin,ymin));
|
||||
BED_edge_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_edge_SDCS.dat");
|
||||
|
||||
Average2D_FuncContainer BED_average_SDCS;
|
||||
BED_average_SDCS.set_Map(BED_edge_SDCS);
|
||||
BED_average_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_average_SDCS.dat");
|
||||
|
||||
|
||||
Stacked2D_FuncContainer BED_stacked_SDCS;
|
||||
BED_stacked_SDCS.set_Map(BED_average_SDCS);
|
||||
BED_stacked_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_stacked_SDCS.dat");
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
clock_t start = clock();
|
||||
Simulation Sim;
|
||||
Sim.doit();
|
||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
||||
|
||||
//createBED_TCS_Func_container();
|
||||
//createBED_SDCS_Func2D_container();
|
||||
//Katrin Kat;
|
||||
//Skalar_WGTS_Container Ion_Container(0, 10, 0.045, vec3(10,10,10));
|
||||
//Ion_Container.set_Bins_from_Function(tritiumDens);
|
||||
}
|
||||
|
||||
+21
-11
@@ -8,6 +8,15 @@
|
||||
|
||||
#include "mover.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const int Mover::propagationMethod = getParameter("propagationMethod");
|
||||
const double Mover::dt_s = getParameter("dt_s");
|
||||
|
||||
@@ -22,6 +31,7 @@ void Mover::moveParticle(Particle *movePart, const double &distance_m) {
|
||||
ss<<"Simulation::move_electron: propagationMethod="<<propagationMethod<<" not valid.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
this->movePart = NULL;
|
||||
}
|
||||
|
||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||
@@ -49,21 +59,21 @@ double Mover::getDrift_znew_m(const double &distance_m) {
|
||||
}
|
||||
|
||||
void Mover::doDrift_WallInteraction(vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= Kat->get_z_WGTSend_m()) { // Moveing into Spectrometer and reversing Speed.
|
||||
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] = Kat->get_z_WGTSend_m();
|
||||
reverseLoc_m[2] = Katrin_Geo::get_z_WGTSend_m();
|
||||
movePart->set_Location_m(reverseLoc_m);
|
||||
Log->log_Particle(*movePart,*oldLoc_m);
|
||||
|
||||
// Final Movement
|
||||
*oldLoc_m = reverseLoc_m;
|
||||
*znew_m = Kat->get_z_WGTSend_m() - (*znew_m - Kat->get_z_WGTSend_m());
|
||||
*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 <= Kat->get_z_RW_m()) {
|
||||
*znew_m = Kat->get_z_RW_m();
|
||||
if (*znew_m <= Katrin_Geo::get_z_RW_m()) {
|
||||
*znew_m = Katrin_Geo::get_z_RW_m();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +86,8 @@ void Mover::do_BorisPushMovement(const double &distance_m) {
|
||||
double traveledDistance_m = 0;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_Location_m();
|
||||
E_Vm = Kat->getElField_Vm(loc_m);
|
||||
B_T = Kat->getMagField_T(loc_m);
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(E_Vm, B_T);
|
||||
if (doBoris_WallInteraction() == true) {
|
||||
@@ -120,21 +130,21 @@ void Mover::doBoris_speedChange(const vec3 &E_Vm, const vec3 &B_T) {
|
||||
bool Mover::doBoris_WallInteraction() {
|
||||
vec3 loc_m = movePart->get_Location_m();
|
||||
double r_m = movePart->get_Radius_m();
|
||||
if (loc_m[2]<=Kat->get_z_RW_m()) { // Rear Wall Termination
|
||||
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>=Kat->get_radius_m()) { // WGTS Wall Termination
|
||||
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 = (Kat->get_radius_m() * 1.01)/vec3Abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
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]>=Kat->get_z_WGTSend_m()) { // Spectrometer Reflection
|
||||
if (loc_m[2]>=Katrin_Geo::get_z_WGTSend_m()) { // Spectrometer Reflection
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
return (false);
|
||||
|
||||
+15
-13
@@ -9,17 +9,25 @@
|
||||
#ifndef mover_hpp
|
||||
#define mover_hpp
|
||||
|
||||
#include "kinematics.h"
|
||||
#include "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "h5_logger.hpp"
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
|
||||
// Mover: Moves Particles within WGTS using parameter propagationMethod to determine Method.
|
||||
// Also Logging during movement
|
||||
class Mover {
|
||||
static const int propagationMethod;
|
||||
static const double dt_s;
|
||||
|
||||
H5_Logger *Log;
|
||||
|
||||
Particle *movePart;
|
||||
|
||||
public:
|
||||
Mover(Katrin *Kat, H5_Logger *Log) {
|
||||
this->Kat = Kat;
|
||||
Mover() {this->Log = NULL;}
|
||||
Mover(H5_Logger *Log) {
|
||||
this->Log = Log;
|
||||
};
|
||||
|
||||
@@ -35,13 +43,7 @@ private:
|
||||
void doBoris_speedChange(const vec3 &E_Vm, const vec3 &B_T);
|
||||
bool doBoris_WallInteraction();
|
||||
void doBoris_LogzDirChange(double *oldzDir, vec3 *oldLoc_m);
|
||||
|
||||
static const int propagationMethod;
|
||||
static const double dt_s;
|
||||
|
||||
Particle *movePart;
|
||||
|
||||
Katrin *Kat;
|
||||
H5_Logger *Log;
|
||||
};
|
||||
|
||||
|
||||
#endif /* mover_hpp */
|
||||
|
||||
@@ -6,42 +6,22 @@
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include "particle.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// Overload <<
|
||||
ostream& operator<<(ostream& os, const species& SpecOut) {
|
||||
switch (SpecOut) {
|
||||
case undef:
|
||||
os<<"undef";
|
||||
break;
|
||||
case electron:
|
||||
os<<"e-";
|
||||
break;
|
||||
case positron:
|
||||
os<<"e+";
|
||||
break;
|
||||
case proton:
|
||||
os<<"p";
|
||||
break;
|
||||
case tritium:
|
||||
os<<"T3";
|
||||
break;
|
||||
case tritium2:
|
||||
os<<"T_2";
|
||||
break;
|
||||
case helium:
|
||||
os<<"He3";
|
||||
break;
|
||||
case deuterium:
|
||||
os<<"D2";
|
||||
break;
|
||||
case DT:
|
||||
os<<"DT";
|
||||
break;
|
||||
default:
|
||||
os<<"";
|
||||
}
|
||||
|
||||
@@ -9,17 +9,18 @@
|
||||
#ifndef particle_hpp
|
||||
#define particle_hpp
|
||||
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
#include "iostream"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include "blitz/array.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
typedef enum species{undef, electron, tritium, tritium2, helium, deuterium, DT}species;
|
||||
std::ostream& operator<<(std::ostream& os, const species& SpecOut);
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
typedef blitz::TinyVector<double,3> vec3;
|
||||
typedef enum species{electron, tritium, tritium2}species;
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const species& SpecOut);
|
||||
|
||||
class Particle {
|
||||
public:
|
||||
@@ -36,28 +37,22 @@ protected:
|
||||
unsigned int parentId;
|
||||
|
||||
public:
|
||||
// Get Properties Methods
|
||||
double get_Mass_eV() { return(m_eV); };
|
||||
double get_Charge_nat() { return(Z); };
|
||||
vec3 get_Location_m() const { return(x_m); };
|
||||
vec3 get_Speed_ms() const { return(v_ms); };
|
||||
species get_Species() const {return(s); };
|
||||
double get_Id() const { return(Id); };
|
||||
double get_ParentId() const { return(parentId); };
|
||||
double get_Mass_eV() { return(m_eV);}
|
||||
double get_Charge_nat() { return(Z);}
|
||||
vec3 get_Location_m() const { return(x_m);}
|
||||
vec3 get_Speed_ms() const { return(v_ms);}
|
||||
species get_Species() const {return(s);}
|
||||
double get_Id() const { return(Id);}
|
||||
double get_ParentId() const { return(parentId);}
|
||||
|
||||
// Get Properties
|
||||
double get_Radius_m() { return ( sqrt( pow(x_m[0],2) + pow(x_m[1],2) ) ); } ;
|
||||
double get_Radius_m() { return ( sqrt( pow(x_m[0],2) + pow(x_m[1],2) ) );}
|
||||
double get_SpeedAbs_ms() const { return ( vec3Abs(v_ms) ); } ;
|
||||
double get_EKin_eV() const { return ( calc_Ekin_eV_from_speed(v_ms, m_eV) ); } ;
|
||||
double get_EKin_eV() const { return ( calc_Ekin_eV_from_speed(v_ms, m_eV) );}
|
||||
|
||||
// Set Properties Methods
|
||||
void set_Location_m(blitz::TinyVector<double, 3> xnew_m) {x_m = xnew_m; };
|
||||
void set_Speed_ms(blitz::TinyVector<double, 3> vnew_ms) {v_ms = vnew_ms; };
|
||||
void set_Location_m(blitz::TinyVector<double, 3> xnew_m) {x_m = xnew_m;}
|
||||
void set_Speed_ms(blitz::TinyVector<double, 3> vnew_ms) {v_ms = vnew_ms;}
|
||||
void set_Id(double newId) {Id = newId;}
|
||||
|
||||
//Boris Push: Propagate Flight for one timestep dt_s in E_Vm and B_T and returns distance.
|
||||
|
||||
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const Particle& partOut);
|
||||
};
|
||||
|
||||
@@ -68,6 +63,11 @@ public:
|
||||
Particle createElectron(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) const {
|
||||
return ( Particle(me_eV, -1 , loc_m, speed_ms, idnum, parentIdnum, electron));
|
||||
}
|
||||
|
||||
Particle createTritium(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) const {
|
||||
return ( Particle(mT_eV, 1 , loc_m, speed_ms, idnum, parentIdnum, tritium));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* particle_hpp */
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// population_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "population_builder.hpp"
|
||||
|
||||
#include "electron_population.hpp"
|
||||
#include "tritium_population.hpp"
|
||||
#include "tritium2_population.hpp"
|
||||
|
||||
|
||||
Population Population_Builder::build_Population(Timer *Tim,UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
Population Kat_Population;
|
||||
Kat_Population.add_Population(new e_Density(Tim, rngUni, rngNormal));
|
||||
Kat_Population.add_Population(new T_Density(Tim, rngUni, rngNormal));
|
||||
Kat_Population.add_Population(new T2_Density(rngUni, rngNormal));
|
||||
|
||||
return (Kat_Population);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// population_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef population_builder_hpp
|
||||
#define population_builder_hpp
|
||||
|
||||
#include "population.hpp"
|
||||
#include "timer.hpp"
|
||||
|
||||
|
||||
class Population_Builder {
|
||||
public:
|
||||
Population_Builder() {};
|
||||
|
||||
static Population build_Population(Timer *Tim, UniRNG *rngUni, NormalRNG *rngNormal);
|
||||
};
|
||||
|
||||
|
||||
#endif /* population_builder_hpp */
|
||||
@@ -9,11 +9,12 @@
|
||||
#ifndef random_operations_h
|
||||
#define random_operations_h
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
|
||||
typedef ranlib::Uniform<double> UniRNG;
|
||||
typedef ranlib::NormalUnit<double> NormalRNG;
|
||||
|
||||
@@ -29,7 +30,6 @@ protected:
|
||||
NormalRNG *rngNormal;
|
||||
};
|
||||
|
||||
|
||||
inline vec3 roll_uniform_direction(ranlib::Uniform<double> *rngUni) {
|
||||
vec3 dir;
|
||||
double phi = 2*pi*rngUni->random();
|
||||
@@ -62,4 +62,5 @@ inline double roll_Rejectionmethod(double (*pdf)(double), double xmin, double xm
|
||||
return(xcan);
|
||||
}
|
||||
|
||||
|
||||
#endif /* random_operations_h */
|
||||
|
||||
@@ -9,11 +9,14 @@
|
||||
#ifndef read_system_h
|
||||
#define read_system_h
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
inline double getParameterValue(std::string lineFromFile) {
|
||||
@@ -177,8 +180,8 @@ inline std::string remove_catEnding (std::string inString) {
|
||||
}
|
||||
|
||||
inline std::string getparName() {
|
||||
string parpath = getenv("parpath");
|
||||
string parfile = remove_catEnding(getenv("parfile"));
|
||||
std::string parpath = getenv("parpath");
|
||||
std::string parfile = remove_catEnding(getenv("parfile"));
|
||||
return (parpath + "/" + parfile);
|
||||
}
|
||||
|
||||
@@ -198,12 +201,4 @@ inline bool isDir(std::string dirPath) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* read_system_h */
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// rutherford_elastic.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 08.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "rutherford_elastic.hpp"
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// rutherford_elastic.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 08.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef rutherford_elastic_hpp
|
||||
#define rutherford_elastic_hpp
|
||||
/*
|
||||
class Rutherford_ElasticScattering {
|
||||
<#instance variables#>
|
||||
|
||||
public:
|
||||
static double calc_TCS(const double &T_eV);
|
||||
static double calc_SDCS(const double &T_eV, const double &theta);
|
||||
|
||||
static double roll_theta(const double &T_eV, UniRNG *rngUni);
|
||||
private:
|
||||
static double calc_eta(const double &T_eV);
|
||||
};
|
||||
*/
|
||||
#endif /* rutherford_elastic_hpp */
|
||||
@@ -6,7 +6,6 @@
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include "simulation.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -16,25 +15,54 @@ const long int Simulation::seed = getParameter("seed");
|
||||
const long int Simulation::numberTotalDecays = getParameter("numberTotalDecays");
|
||||
const int Simulation::maxInteractions = getParameter("maxInteractions");
|
||||
|
||||
void Simulation::init_Simulation() {
|
||||
set_RNGs();
|
||||
Tim = Timer(&numberDecays);
|
||||
Pop = Population_Builder::build_Population(&Tim, &rngUni, &rngNormal);
|
||||
Inj = Injector(&rngUni, &rngNormal);
|
||||
Mov = Mover(&Log);
|
||||
Inter = InteractionBuilder::build_InteractionProcessor(&Pop, &rngUni, &rngNormal);
|
||||
set_statusUpdater();
|
||||
}
|
||||
|
||||
void Simulation::set_RNGs() {
|
||||
rngUni.seed(seed);
|
||||
rngNormal.seed(seed);
|
||||
}
|
||||
|
||||
void Simulation::set_statusUpdater() {
|
||||
updater_fraction = numberTotalDecays/100;
|
||||
updater_fraction = updater_fraction==0 ? 1 : updater_fraction;
|
||||
}
|
||||
|
||||
void Simulation::doit() {
|
||||
InteractionOut IntOut;
|
||||
double mfp;
|
||||
std::deque<Particle> partQue;
|
||||
Particle curPart;
|
||||
vec3 oldLoc_m;
|
||||
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
||||
if (partQue.empty()) {
|
||||
curPart = Inj.injectElectron(numberTotalElectrons);
|
||||
curPart = Inj.injectElectron(numberTotalParticles);
|
||||
numberDecays++;
|
||||
numberTotalElectrons++;
|
||||
numberTotalParticles++;
|
||||
do_statusUpdate();
|
||||
} else {
|
||||
curPart = partQue.front();
|
||||
partQue.pop_front();
|
||||
}
|
||||
|
||||
while (!Term.check_Termination(curPart)) {
|
||||
oldLoc_m = curPart.get_Location_m();
|
||||
mfp = 1/Inter.get_macroSigma_m2(curPart);
|
||||
Mov.moveParticle(&curPart, mfp);
|
||||
Pop.up_Denisty(oldLoc_m, curPart);
|
||||
if (!Term.check_Termination(curPart)) {
|
||||
IntOut = Inter.do_Interaction(&curPart);
|
||||
//appy_Inter_Output(IntOut);
|
||||
IntOut.appendDeque(&partQue, &numberTotalParticles);
|
||||
if (IntOut.terminateCurrent()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +77,7 @@ void Simulation::do_statusUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void Simulation::doTC6() {
|
||||
cout<<endl<<"Simulation::doTC6: Doing Testcase 6."<<endl<<endl;
|
||||
|
||||
@@ -9,68 +9,55 @@
|
||||
#ifndef simulation_hpp
|
||||
#define simulation_hpp
|
||||
|
||||
|
||||
#include "katrin.hpp"
|
||||
#include "timer.hpp"
|
||||
#include "population_builder.hpp"
|
||||
#include "injector.hpp"
|
||||
#include "mover.hpp"
|
||||
#include "terminator.hpp"
|
||||
#include "interaction_processor.hpp"
|
||||
#include "interaction_builder.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
|
||||
class Simulation {
|
||||
public:
|
||||
Simulation() : Kat(&rngUni, &rngNormal),
|
||||
Inj(&Kat, &rngUni, &rngNormal),
|
||||
Log(&Kat),
|
||||
Mov(&Kat, &Log),
|
||||
Inter(&Kat, &rngUni, &rngNormal),
|
||||
Term(&Kat) {
|
||||
rngUni.seed(seed);
|
||||
rngNormal.seed(seed);
|
||||
updater_fraction = numberTotalDecays/100;
|
||||
updater_fraction = updater_fraction==0 ? 1 : updater_fraction;
|
||||
InteractionBuilder InterBuilder(&Kat, &rngUni, &rngNormal);
|
||||
Inter = InterBuilder.build_InteractionProcessor();
|
||||
}
|
||||
void doit();
|
||||
private:
|
||||
void do_statusUpdate();
|
||||
static const long int seed;
|
||||
static const long int numberTotalDecays;
|
||||
static const int maxInteractions;
|
||||
|
||||
UniRNG rngUni;
|
||||
NormalRNG rngNormal;
|
||||
|
||||
Katrin Kat;
|
||||
Injector Inj;
|
||||
H5_Logger Log;
|
||||
Timer Tim;
|
||||
Population Pop;
|
||||
|
||||
Injector Inj;
|
||||
Mover Mov;
|
||||
InteractionProcessor Inter;
|
||||
Terminator Term;
|
||||
|
||||
ranlib::Uniform<double> rngUni;
|
||||
ranlib::NormalUnit<double> rngNormal;
|
||||
|
||||
double mfp;
|
||||
std::deque<Particle> partQue;
|
||||
Particle curPart;
|
||||
//InterOutput IntOut;
|
||||
|
||||
int numberTotalElectrons = 0;
|
||||
int numberTotalParticles = 0;
|
||||
int numberDecays = 0;
|
||||
|
||||
int numberTotalIons = 0;
|
||||
|
||||
int updater_numberOfPrevious = 0;
|
||||
int updater_fraction;
|
||||
|
||||
// Parameters
|
||||
static const long int seed;
|
||||
static const long int numberTotalDecays;
|
||||
public:
|
||||
Simulation() {init_Simulation();}
|
||||
private:
|
||||
void init_Simulation();
|
||||
void set_RNGs();
|
||||
void set_statusUpdater();
|
||||
|
||||
static const int maxInteractions;
|
||||
public:
|
||||
void doit();
|
||||
private:
|
||||
void do_statusUpdate();
|
||||
|
||||
public:
|
||||
void doTC6();
|
||||
private:
|
||||
void parameterCheck_TC6();
|
||||
};
|
||||
|
||||
|
||||
#endif /* simulation_hpp */
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
#include "terminator.hpp"
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
const double Terminator::cutoffEnergy_eV = getParameter("cutoffEnergy_eV");
|
||||
|
||||
bool Terminator::check_Termination(const Particle &checkPart) {
|
||||
@@ -15,7 +20,11 @@ bool Terminator::check_Termination(const Particle &checkPart) {
|
||||
vec3 loc_m = checkPart.get_Location_m();
|
||||
bool E_check = check_EnergyTermination(Ekin_eV);
|
||||
bool loc_check = check_WallTermination(loc_m);
|
||||
return(E_check || loc_check);
|
||||
if (checkPart.get_Species() == electron) {
|
||||
return(E_check || loc_check);
|
||||
} else {
|
||||
return (loc_check);
|
||||
}
|
||||
}
|
||||
|
||||
bool Terminator::check_EnergyTermination(const double &Ekin_eV) {
|
||||
@@ -28,10 +37,10 @@ bool Terminator::check_EnergyTermination(const double &Ekin_eV) {
|
||||
bool Terminator::check_WallTermination(const vec3 &loc_m) {
|
||||
double z_m = loc_m[2];
|
||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
||||
if (z_m <=Kat->get_z_RW_m()) {
|
||||
if (z_m <=Katrin_Geo::get_z_RW_m()) {
|
||||
return (true);
|
||||
}
|
||||
if (r_m >= Kat->get_radius_m()) {
|
||||
if (r_m >= Katrin_Geo::get_radius_m()) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
||||
@@ -9,25 +9,21 @@
|
||||
#ifndef terminator_hpp
|
||||
#define terminator_hpp
|
||||
|
||||
#include "katrin.hpp"
|
||||
#include "particle.hpp"
|
||||
|
||||
// Terminate Electrons
|
||||
class Terminator {
|
||||
public:
|
||||
Terminator(Katrin *Kat) {
|
||||
this->Kat = Kat;
|
||||
}
|
||||
|
||||
bool check_Termination(const Particle &checkPart);
|
||||
private:
|
||||
bool check_EnergyTermination(const double &Ekin_eV);
|
||||
bool check_WallTermination(const vec3 &loc_m);
|
||||
|
||||
|
||||
class Terminator {
|
||||
static const double cutoffEnergy_eV;
|
||||
|
||||
Katrin *Kat;
|
||||
public:
|
||||
Terminator() {};
|
||||
|
||||
static bool check_Termination(const Particle &checkPart);
|
||||
private:
|
||||
static bool check_EnergyTermination(const double &Ekin_eV);
|
||||
static bool check_WallTermination(const vec3 &loc_m);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* terminator_hpp */
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// timer.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "timer.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
|
||||
const double Timer::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
|
||||
double Timer::get_physTime_s() {
|
||||
return ( double(*numTotDecays)/T2_activity_s );
|
||||
}
|
||||
|
||||
void Timer::set_T2_activity_s() {
|
||||
double r_m = Katrin_Geo::get_radius_m();
|
||||
double l_m = Katrin_Geo::get_wgtsLength_m();
|
||||
double V_m3 = pi*r_m*r_m*l_m;
|
||||
double NT2 = (wgtsT2MaxDensity_m3/2)*V_m3;
|
||||
T2_activity_s = NT2*decayConstT2_s;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// timer.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef timer_hpp
|
||||
#define timer_hpp
|
||||
|
||||
#include "katrin_geo.hpp"
|
||||
class Timer {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
|
||||
double T2_activity_s;
|
||||
|
||||
int *numTotDecays;
|
||||
|
||||
public:
|
||||
Timer() {numTotDecays = NULL;}
|
||||
|
||||
Timer(int *numTotDecays) {
|
||||
this->numTotDecays = numTotDecays;
|
||||
}
|
||||
|
||||
double get_physTime_s();
|
||||
|
||||
private:
|
||||
void set_T2_activity_s();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* timer_hpp */
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// tritium2_population.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "tritium2_population.hpp"
|
||||
|
||||
|
||||
const double T2_Density::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
const double T2_Density::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double T2_Density::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
double T2_Density::get_Density_m3(vec3 loc_m) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
if (!Katrin_Geo::inWGTS(loc_m)) {
|
||||
return (zero);
|
||||
} else {
|
||||
return (calc_DensityTriangle(loc_m[2]));
|
||||
}
|
||||
}
|
||||
|
||||
double T2_Density::calc_DensityTriangle(double z_m) const {
|
||||
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);
|
||||
}
|
||||
|
||||
vec3 T2_Density::roll_Speed_ms(vec3 loc_m) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
return (calc_flowSpeed_ms(loc_m) + roll_thermSpeed_ms(loc_m));
|
||||
}
|
||||
|
||||
vec3 T2_Density::calc_flowSpeed_ms(vec3 loc_m) const {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
vec3 T2_Density::roll_thermSpeed_ms(vec3 loc_m) const {
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// tritium2_population.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 07.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium2_population_hpp
|
||||
#define tritium2_population_hpp
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
|
||||
class T2_Density : public Population_Base, public RNG_Base {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
static const double wgtsTemp_K;
|
||||
static const double wgtsT2FlowSpeed_ms;
|
||||
|
||||
public:
|
||||
T2_Density(UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium2), RNG_Base(rngUni, rngNormal){};
|
||||
|
||||
double get_Density_m3(vec3 loc_m) const ;
|
||||
private:
|
||||
double calc_DensityTriangle(double z_m) const;
|
||||
|
||||
public:
|
||||
vec3 roll_Speed_ms(vec3 loc_m) const;
|
||||
private:
|
||||
vec3 calc_flowSpeed_ms(vec3 loc_m) const;
|
||||
vec3 roll_thermSpeed_ms(vec3 loc_m) const;
|
||||
|
||||
public:
|
||||
void up_Denisty(vec3 oldLoc_m, vec3 newLoc_m, double Ekin_eV) {};
|
||||
};
|
||||
|
||||
|
||||
#endif /* tritium2_population_hpp */
|
||||
@@ -7,3 +7,27 @@
|
||||
//
|
||||
|
||||
#include "tritium_interactions.hpp"
|
||||
|
||||
double T_T2_elasticScattering::get_macroSigma_m2(const Particle &interPart) const {
|
||||
vec3 loc_m = interPart.get_Location_m();
|
||||
double n_m3 = Pop->get_Density_m3(tritium2, loc_m);
|
||||
return (HardSphere.get_TCS() * n_m3);
|
||||
}
|
||||
|
||||
InteractionOut T_T2_elasticScattering::do_Interaction (Particle *interPart) const {
|
||||
vec3 v_ms = interPart->get_Speed_ms();
|
||||
vec3 vT2_ms = Pop->roll_Speed_ms(tritium2, interPart->get_Location_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());
|
||||
}
|
||||
|
||||
vec3 T_T2_elasticScattering::calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab) const {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,21 @@
|
||||
|
||||
#include "interaction_species.hpp"
|
||||
|
||||
/*
|
||||
class TIon_InteractionProcessor : public Base_ParticleInteractionsProcessors {
|
||||
#include "hardsphere_elastic.h"
|
||||
|
||||
class T_T2_elasticScattering : public Interaction {
|
||||
const Hardsphere_elasticScattering HardSphere = Hardsphere_elasticScattering(3.4614e-15);
|
||||
public:
|
||||
TIon_InteractionProcessor(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : Base_ParticleInteractionsProcessors(Kat, rngUni, rngNormal) {};
|
||||
T_T2_elasticScattering(Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : Interaction(tritium, Pop, rngUni, rngNormal) {};
|
||||
|
||||
double get_macroSigma_m2(const Particle &interPart) const;
|
||||
InteractionOut do_Interaction (Particle *interPart) const;
|
||||
|
||||
InterOutput do_Interaction(Particle *interPart);
|
||||
private:
|
||||
vec3 calc_vNew_ms(vec3 vOld_ms, vec3 vT2_ms, double thetaLab, double phiLab) const;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* tritium_interactions_hpp */
|
||||
|
||||
@@ -9,20 +9,41 @@
|
||||
#include "tritium_population.hpp"
|
||||
|
||||
|
||||
const double T_Density::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double T_Density::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
const double T2_Density::wgtsTemp_K = getParameter("wgtsTemp_K");
|
||||
const double T2_Density::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
|
||||
const double T2_Density::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
|
||||
|
||||
double T2_Density::get_Density(vec3 loc_m) const {
|
||||
double T_Density::get_Density_m3(vec3 loc_m) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
if (!Katrin_Geo::inWGTS(loc_m)) {
|
||||
return (0);
|
||||
double physTime_s = Tim->get_physTime_s();
|
||||
double dens = T_Container.getDensity_m3(loc_m, physTime_s, xyz);
|
||||
return(dens);
|
||||
}
|
||||
|
||||
vec3 T_Density::roll_Speed_ms(vec3 loc_m) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
return (calc_flowSpeed_ms(loc_m) + roll_thermSpeed_ms(loc_m));
|
||||
}
|
||||
|
||||
vec3 T_Density::calc_flowSpeed_ms(vec3 loc_m) const {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
double T2_Density::roll_Energy(vec3 loc_m, UniRNG *rngUni) const {
|
||||
Katrin_Geo::check_inKatrin(loc_m);
|
||||
vec3 T_Density::roll_thermSpeed_ms(vec3 loc_m) const {
|
||||
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);
|
||||
}
|
||||
|
||||
void T_Density::up_Denisty(vec3 oldLoc_m, vec3 newLoc_m, double Ekin_eV) {
|
||||
double vAbs_ms = calc_Speed_from_Ekin_eV(Ekin_eV, me_eV);
|
||||
T_Container.upDensity(vAbs_ms, oldLoc_m, newLoc_m);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,27 +9,33 @@
|
||||
#ifndef tritium_population_hpp
|
||||
#define tritium_population_hpp
|
||||
|
||||
#include "density_container.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
|
||||
class T2_Density : public Population_Base {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
class T_Density : public Population_Base, public RNG_Base {
|
||||
static const double wgtsTemp_K;
|
||||
static const double wgtsT2FlowSpeed_ms;
|
||||
|
||||
WGTS3D_ParticleTime_s_Container T_Container;
|
||||
Timer *Tim;
|
||||
|
||||
public:
|
||||
T2_Density() : Population_Base(tritium2) {};
|
||||
T_Density(Timer *Tim, UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium), RNG_Base(rngUni, rngNormal), T_Container(vec3(10,10,10)) {
|
||||
this->Tim = Tim;
|
||||
};
|
||||
|
||||
double get_Density(vec3 loc_m) const ;
|
||||
double roll_Energy(vec3 loc_m, UniRNG *rngUni) const ;
|
||||
void up_Denisty(vec3 loc_m, double Ekin_eV) {Katrin_Geo::check_inKatrin(loc_m);};
|
||||
double get_Density_m3(vec3 loc_m) const ;
|
||||
|
||||
public:
|
||||
vec3 roll_Speed_ms(vec3 loc_m) const;
|
||||
private:
|
||||
vec3 calc_flowSpeed_ms(vec3 loc_m) const;
|
||||
vec3 roll_thermSpeed_ms(vec3 loc_m) const;
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
void up_Denisty(vec3 oldLoc_m, vec3 newLoc_m, double Ekin_eV);
|
||||
};
|
||||
|
||||
|
||||
//Skalar_WGTS_Container Ion_Container = Skalar_WGTS_Container(0, wgtsLength_m, wgtsRadius_m, vec3(10,10,12));
|
||||
#endif /* tritium_population_hpp */
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
#include "uehara_eT2_elastic.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
#include "constants.h"
|
||||
#include "error_types.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
double Uehara_eT2_ElasticScattering::calc_TCS(const double &T_eV) {
|
||||
double beta = calc_beta_from_Ekin_eV(T_eV,me_eV);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "random_operations.h"
|
||||
|
||||
|
||||
// Cross secton by Uehara 1993: Rutherford CS with screening parameter. Originally for water vapor.
|
||||
class Uehara_eT2_ElasticScattering {
|
||||
|
||||
@@ -25,4 +26,5 @@ private:
|
||||
static double calc_eta(const double &T_eV);
|
||||
};
|
||||
|
||||
|
||||
#endif /* uehara_eT2_elastic_hpp */
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
int *test;
|
||||
|
||||
Reference in New Issue
Block a user