More or less last working status, major changes comming now.
This commit is contained in:
@@ -156,7 +156,7 @@ namespace container_base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double interpolat_Value(const dim1Map &Map, deque<double> Cord) {
|
inline double interpolate_Value(const dim1Map &Map, deque<double> Cord) {
|
||||||
if (Cord.size()!=1) {
|
if (Cord.size()!=1) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"interpolat_Value: Length of Cord and &Map do not map.";
|
ss<<"interpolat_Value: Length of Cord and &Map do not map.";
|
||||||
@@ -181,27 +181,63 @@ namespace container_base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline double interpolat_Value(const T &Map, deque<double> Cord) {
|
inline double interpolate_Value(const T &Map, deque<double> Cord) {
|
||||||
double x = *Cord.begin();
|
double x = *Cord.begin();
|
||||||
Cord.pop_front();
|
Cord.pop_front();
|
||||||
|
|
||||||
if (x < Map.begin()->first) {
|
if (x < Map.begin()->first) {
|
||||||
return ( interpolat_Value(Map.begin()->second, Cord) );
|
return ( interpolate_Value(Map.begin()->second, Cord) );
|
||||||
} else if (x > Map.rbegin()->first){
|
} else if (x > Map.rbegin()->first){
|
||||||
return ( interpolat_Value( (Map.rbegin())->second, Cord) );
|
return ( interpolate_Value( (Map.rbegin())->second, Cord) );
|
||||||
}
|
}
|
||||||
|
|
||||||
typename T::const_iterator lowAnker_Itr = --Map.lower_bound(x);
|
typename T::const_iterator lowAnker_Itr = --Map.lower_bound(x);
|
||||||
typename T::const_iterator upAnker_Itr = Map.lower_bound(x);
|
typename T::const_iterator upAnker_Itr = Map.lower_bound(x);
|
||||||
double lowAnker_x = lowAnker_Itr->first;
|
double lowAnker_x = lowAnker_Itr->first;
|
||||||
double lowAnker_fxy = interpolat_Value(lowAnker_Itr->second, Cord);
|
double lowAnker_fxy = interpolate_Value(lowAnker_Itr->second, Cord);
|
||||||
double upAnker_x = upAnker_Itr->first;
|
double upAnker_x = upAnker_Itr->first;
|
||||||
double upAnker_fxy = interpolat_Value(upAnker_Itr->second, Cord);
|
double upAnker_fxy = interpolate_Value(upAnker_Itr->second, Cord);
|
||||||
|
|
||||||
double res = lowAnker_fxy + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fxy-lowAnker_fxy);
|
double res = lowAnker_fxy + (x-lowAnker_x)/(upAnker_x-lowAnker_x) * (upAnker_fxy-lowAnker_fxy);
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void set_Itr(dim1Map &Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||||
|
if (Cord.size()!=1) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"set_Itr: Length of Cord and &Map do not map.";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
double x = *Cord.begin();
|
||||||
|
|
||||||
|
if (x>Map.rbegin()->first) {
|
||||||
|
Itr = (--Map.end());
|
||||||
|
} else {
|
||||||
|
Itr = Map.lower_bound(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void set_Itr(T &Map, deque<double> Cord, dim1Map::iterator &Itr) {
|
||||||
|
double x = *Cord.begin();
|
||||||
|
Cord.pop_front();
|
||||||
|
if (x>Map.rbegin()->first) {
|
||||||
|
set_Itr(Map.rbegin()->second,Cord,Itr);
|
||||||
|
} else {
|
||||||
|
set_Itr(Map.lower_bound(x)->second,Cord,Itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline dim1Map::iterator get_Itr(T &Map, deque<double> Cord) {
|
||||||
|
dim1Map::iterator res;
|
||||||
|
set_Itr(Map, Cord, res);
|
||||||
|
return(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write some iterator over all bins in maps.
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,152 @@
|
|||||||
#include "density_container.hpp"
|
#include "density_container.hpp"
|
||||||
|
|
||||||
|
|
||||||
//void fillFromFunction(double (*f)(double), double minX, double maxX, int numpointsPerOrder);
|
WGTS_Geo::WGTS_Geo(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) {
|
||||||
void Skalar_DenContainer::fillFromCSV(std::string loadFilePath) {
|
this->z_min_m = z_min_m;
|
||||||
|
this->z_max_m = z_max_m;
|
||||||
|
this->r_max_m = r_max_m;
|
||||||
|
this->zrphi_numBins = zrphi_numBins;
|
||||||
|
dim1Map bin_l_m;
|
||||||
|
dim1Map bin_V_m3;
|
||||||
|
init_bin_maps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WGTS_Geo::init_bin_maps() {
|
||||||
|
int n_z = zrphi_numBins[0];
|
||||||
|
int n_r = zrphi_numBins[1];
|
||||||
|
int n_phi = zrphi_numBins[2];
|
||||||
|
double len_m = (z_max_m-z_min_m)/n_z;
|
||||||
|
double rad_step_m = r_max_m/n_r;
|
||||||
|
|
||||||
void Skalar_DenContainer::add_ankerpoint(double x, double y, double z, double fxyz) {
|
double z_m,r_m;
|
||||||
|
for (int i_z=1;i_z<=n_z;i_z++) {
|
||||||
|
z_m = z_min_m + i_z * len_m;
|
||||||
|
bin_l_m.insert(dim1Pair(z_m,len_m));
|
||||||
|
}
|
||||||
|
double V_m3;
|
||||||
|
for (int i_r=1;i_r<=n_r;i_r++) {
|
||||||
|
r_m = i_r * rad_step_m;
|
||||||
|
V_m3 = (pi*pow(r_m,2)-pi*pow(r_m-rad_step_m,2))/n_phi;
|
||||||
|
bin_V_m3.insert(dim1Pair(r_m,V_m3));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skalar_DenContainer::exportToFile(std::string exportFilePath) {
|
double WGTS_Geo::get_Bin_l_m (double z_m) {
|
||||||
|
if (check_z_outside(z_m)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"WGTS_Geo_Container::get_Bin_l_m: z_m not in Container.";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
return (bin_l_m.lower_bound(z_m)->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double WGTS_Geo::get_Bin_V_m3(double r_m) {
|
||||||
|
if (check_r_outside(r_m)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"WGTS_Geo_Container::get_Bin_V_m3: r_m not in Container.";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
return (bin_V_m3.lower_bound(r_m)->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WGTS_Geo::outside_Container(vec3 Cords, cordStyle cordStyleIn) {
|
||||||
|
Cords = zrphiCords(Cords, cordStyleIn);
|
||||||
|
return (check_z_outside (Cords[0]) || check_r_outside(Cords[1]));
|
||||||
|
}
|
||||||
|
bool WGTS_Geo::check_z_outside (double z_m) {
|
||||||
|
if (z_m<z_min_m) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
if (z_m>z_max_m) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
bool WGTS_Geo::check_r_outside (double r_m) {
|
||||||
|
if (r_m>r_max_m) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
vec3 WGTS_Geo::zrphiCords(vec3 Cords, cordStyle cordStyleIn) {
|
||||||
|
if (cordStyleIn == zrphi) {
|
||||||
|
return (Cords);
|
||||||
|
}
|
||||||
|
double z = Cords[0];
|
||||||
|
double r = sqrt(Cords[1]*Cords[1] + Cords[2]*Cords[2]);
|
||||||
|
double phi;
|
||||||
|
if (Cords[1] >= 0) {
|
||||||
|
phi = acos(Cords[2]/r);
|
||||||
|
} else {
|
||||||
|
phi = 2*pi - acos(Cords[2]/r);
|
||||||
|
}
|
||||||
|
return (vec3(z,r,phi));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WGTS3D_ParticleTime_s_Container::WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) : WGTS_Geo(z_min_m, z_max_m, r_max_m, zrphi_numBins) {
|
||||||
|
init_Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WGTS3D_ParticleTime_s_Container::init_Map() {
|
||||||
|
// Give posibility for non linear Bins....
|
||||||
|
int n_z = zrphi_numBins[0];
|
||||||
|
int n_r = zrphi_numBins[1];
|
||||||
|
int n_phi = zrphi_numBins[2];
|
||||||
|
double step_z_m = (z_max_m-z_min_m)/n_z;
|
||||||
|
double step_r_m = r_max_m/n_r;
|
||||||
|
double step_phi = 2*pi/n_phi;
|
||||||
|
|
||||||
|
double z_m,r_m,phi;
|
||||||
|
for (int i_z=1;i_z<=n_z;i_z++) {
|
||||||
|
z_m = z_min_m + i_z * step_z_m;
|
||||||
|
for (int i_r=1;i_r<=n_r;i_r++) {
|
||||||
|
r_m = i_r * step_r_m;
|
||||||
|
for (int i_phi=1;i_phi<=n_phi;i_phi++) {
|
||||||
|
phi = step_phi * i_phi;
|
||||||
|
add_ankerpoint(z_m, r_m, phi, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double WGTS3D_ParticleTime_s_Container::getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn) {
|
||||||
|
if (outside_Container(loc_m, cordStyleIn)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"WGTS3D_ParticleTime_s_Container::getDensity: loc_old or loc_new not in Container.";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
loc_m = zrphiCords(loc_m);
|
||||||
|
return (findBin(loc_m)->second/simTime_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn) {
|
||||||
|
if (outside_Container(loc_old, cordStyleIn) || outside_Container(loc_new, cordStyleIn)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"WGTS3D_ParticleTime_s_Container::up_DriftApprox_Density: loc_old or loc_new not in Container.";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
vec3 loc_min = zrphiCords(loc_old, cordStyleIn);
|
||||||
|
vec3 loc_max = zrphiCords(loc_new, cordStyleIn);
|
||||||
|
double zmin_m = loc_min[0];
|
||||||
|
double zmax_m = loc_min[0];
|
||||||
|
if (zmax_m<zmin_m) {
|
||||||
|
swap (zmin_m, zmax_m);
|
||||||
|
swap (loc_min, loc_max);
|
||||||
|
}
|
||||||
|
// Check start and end in same r and phi bin
|
||||||
|
|
||||||
|
dim3Map::iterator zItr_min = Map.lower_bound(zmin_m);
|
||||||
|
dim3Map::iterator zItr_max = Map.lower_bound(zmax_m);
|
||||||
|
double r_m = loc_min[1];
|
||||||
|
double phi = loc_min[2];
|
||||||
|
double l_m;
|
||||||
|
for (dim3Map::iterator Itr = zItr_min;Itr != zItr_max;Itr++) {
|
||||||
|
l_m = get_Bin_l_m(Itr->first);
|
||||||
|
container_base::get_Itr(Itr->second, deque<double> {r_m,phi})->second += l_m/vAbs_ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
#ifndef density_container_hpp
|
#ifndef density_container_hpp
|
||||||
#define density_container_hpp
|
#define density_container_hpp
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "container_base_functions.h"
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
typedef std::map<double,double> dim1Map;
|
typedef std::map<double,double> dim1Map;
|
||||||
typedef std::pair<double,double> dim1Pair;
|
typedef std::pair<double,double> dim1Pair;
|
||||||
@@ -19,30 +17,110 @@ typedef std::pair<double,double> dim1Pair;
|
|||||||
typedef std::map<double,dim1Map> dim2Map;
|
typedef std::map<double,dim1Map> dim2Map;
|
||||||
typedef std::pair<double,dim1Map> dim2Pair;
|
typedef std::pair<double,dim1Map> dim2Pair;
|
||||||
|
|
||||||
typedef std::map<double,dim2Map> skalar3Map;
|
typedef std::map<double,dim2Map> dim3Map;
|
||||||
typedef std::pair<double,dim2Map> skalar3Pair;
|
typedef std::pair<double,dim2Map> dim3Pair;
|
||||||
|
|
||||||
|
typedef enum cordStyle{xyz, zrphi} cordStyle;
|
||||||
|
|
||||||
|
|
||||||
class Skalar_DenContainer {
|
class Base3D_FuncContainer {
|
||||||
public:
|
public:
|
||||||
Skalar_DenContainer() {};
|
Base3D_FuncContainer() {};
|
||||||
Skalar_DenContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
Base3D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||||
|
|
||||||
void fillFromCSV(std::string 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);
|
void add_ankerpoint(double x, double y, double z, double fxyz){container_base::add_To_Map(&Map, deque<double> {x,y,z,fxyz});};
|
||||||
|
|
||||||
void exportToFile(std::string exportFilePath);
|
void exportToFile(std::string exportFilePath){container_base::export_To_Csv(Map, exportFilePath);};
|
||||||
|
|
||||||
skalar3Map get_Map() {return (Map);}
|
dim3Map get_Map() {return (Map);}
|
||||||
protected:
|
protected:
|
||||||
double lower_z;
|
dim3Map Map;
|
||||||
double lower_r;
|
|
||||||
double lower_phi;
|
|
||||||
|
|
||||||
skalar3Map 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);
|
||||||
|
double get_Bin_V_m3(double r_m);
|
||||||
|
|
||||||
|
bool outside_Container(vec3 Cords, cordStyle cordStyleIn = xyz);
|
||||||
|
bool check_z_outside (double z_m);
|
||||||
|
bool check_r_outside (double r_m);
|
||||||
|
vec3 zrphiCords(vec3 Cords, cordStyle cordStyleIn = xyz);
|
||||||
|
|
||||||
|
double z_min_m;
|
||||||
|
double z_max_m;
|
||||||
|
double r_max_m;
|
||||||
|
vec3 zrphi_numBins;
|
||||||
|
dim1Map bin_l_m;
|
||||||
|
dim1Map bin_V_m3;
|
||||||
|
};
|
||||||
|
|
||||||
|
// WGTS3D_ParticleTime_s_Container Contains cumulative duration of stay in bin.
|
||||||
|
class WGTS3D_ParticleTime_s_Container : public Base3D_FuncContainer , public WGTS_Geo {
|
||||||
|
public:
|
||||||
|
WGTS3D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init_Map();
|
||||||
|
using Base3D_FuncContainer::add_ankerpoint;
|
||||||
|
using Base3D_FuncContainer::fillFromCSV;
|
||||||
|
|
||||||
|
public:
|
||||||
|
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz);
|
||||||
|
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||||
|
dim1Map::iterator findBin(vec3 zrPhiCords) {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||||
|
};
|
||||||
|
// Add option to load default from file...
|
||||||
|
//Part3D_WGTS_Container(std::string loadFilePath, double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||||
|
//void check_Bins()
|
||||||
|
|
||||||
|
/*
|
||||||
|
typedef std::map<double,dim3Map> dim4Map;
|
||||||
|
typedef std::pair<double,dim3Map> dim4Pair;
|
||||||
|
|
||||||
|
class Base4D_FuncContainer {
|
||||||
|
public:
|
||||||
|
Base4D_FuncContainer() {};
|
||||||
|
Base4D_FuncContainer(std::string loadFilePath) {fillFromCSV(loadFilePath);};
|
||||||
|
|
||||||
|
void fillFromCSV(std::string loadFilePath){container_base::add_From_Csv(&Map, 4, loadFilePath);};
|
||||||
|
void add_ankerpoint(double x, double y, double z, double E, double fxyzE){container_base::add_To_Map(&Map, deque<double> {x,y,z,E,fxyzE});};
|
||||||
|
|
||||||
|
void exportToFile(std::string exportFilePath){container_base::export_To_Csv(Map, exportFilePath);};
|
||||||
|
|
||||||
|
dim4Map get_Map() {return (Map);}
|
||||||
|
protected:
|
||||||
|
dim4Map Map;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WGTS4D_ParticleTime_s_Container : public Base4D_FuncContainer , public WGTS_Geo {
|
||||||
|
public:
|
||||||
|
WGTS4D_ParticleTime_s_Container(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init_Map();
|
||||||
|
using Base4D_FuncContainer::add_ankerpoint;
|
||||||
|
using Base4D_FuncContainer::fillFromCSV;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
double getDensity(vec3 loc_m, double simTime_s, cordStyle cordStyleIn = xyz);
|
||||||
|
void upDensity(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz) {up_DriftApprox_Density(vAbs_ms, loc_old, loc_new, cordStyleIn);};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void up_DriftApprox_Density(double vAbs_ms, vec3 loc_old, vec3 loc_new, cordStyle cordStyleIn = xyz);
|
||||||
|
dim1Map::iterator findBin(vec3 zrPhiCords) {return (container_base::get_Itr(Map,deque<double> {zrPhiCords[0],zrPhiCords[1],zrPhiCords[2]}));};
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
#endif /* density_container_hpp */
|
#endif /* density_container_hpp */
|
||||||
|
|||||||
@@ -12,12 +12,11 @@
|
|||||||
#include "particle.hpp"
|
#include "particle.hpp"
|
||||||
#include "bedionization.hpp"
|
#include "bedionization.hpp"
|
||||||
#include "function_container.hpp"
|
#include "function_container.hpp"
|
||||||
|
#include "katrin.hpp"
|
||||||
|
|
||||||
class Electron : public Particle {
|
class Electron : public Particle {
|
||||||
public:
|
public:
|
||||||
virtual ~Electron() {}
|
Electron(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) : Particle(me_eV, -1 , loc_m, speed_ms, idnum, parentIdnum, electron) {};
|
||||||
Electron(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) : Particle::Particle(me_eV, 1 , loc_m, speed_ms, idnum, parentIdnum, electron) {};
|
|
||||||
|
|
||||||
// Interactions
|
// Interactions
|
||||||
public:
|
public:
|
||||||
@@ -56,6 +55,29 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum e_InterKind{e_T2_elastcis, e_T2_ion} e_InterKind;
|
||||||
|
|
||||||
|
class Inter_Output {
|
||||||
|
public:
|
||||||
|
Inter_Output();
|
||||||
|
private:
|
||||||
|
bool deleteCur;
|
||||||
|
Electron *NewElectrons;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class Electron_Interactions {
|
||||||
|
public:
|
||||||
|
Electron_Interactions();
|
||||||
|
e_InterKind roll_Interaction();
|
||||||
|
Inter_Output do_Interaction(e_InterKind InterKind);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Katrin *Kat;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* electron_hpp */
|
#endif /* electron_hpp */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
Edge1D_FuncContainer() : Base1D_FuncContainer() {};
|
Edge1D_FuncContainer() : Base1D_FuncContainer() {};
|
||||||
Edge1D_FuncContainer(std::string loadFilePath) : Base1D_FuncContainer(loadFilePath){};
|
Edge1D_FuncContainer(std::string loadFilePath) : Base1D_FuncContainer(loadFilePath){};
|
||||||
|
|
||||||
double interpolate(double x) {return (container_base::interpolat_Value(Map,deque<double>{x}));};
|
double interpolate(double x) {return (container_base::interpolate_Value(Map,deque<double>{x}));};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Average1D_Container: Calculates new edges, so values from edge bin correspond to mean value.
|
// Average1D_Container: Calculates new edges, so values from edge bin correspond to mean value.
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
Edge2D_FuncContainer() : Base2D_FuncContainer() {};
|
Edge2D_FuncContainer() : Base2D_FuncContainer() {};
|
||||||
Edge2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath) {};
|
Edge2D_FuncContainer(std::string loadFilePath) : Base2D_FuncContainer(loadFilePath) {};
|
||||||
|
|
||||||
double interpolate(double x, double y) {return (container_base::interpolat_Value(Map,deque<double>{x,y}));};
|
double interpolate(double x, double y) {return (container_base::interpolate_Value(Map,deque<double>{x,y}));};
|
||||||
|
|
||||||
void get_Ionization_fromFunction(double (*f)(double,double), double minX, double maxX, int numpointsPerXOrder, int numpointsPerYOrder);
|
void get_Ionization_fromFunction(double (*f)(double,double), double minX, double maxX, int numpointsPerXOrder, int numpointsPerYOrder);
|
||||||
void get_Elastic_fromFunction(double (*f)(double,double), double minX, double maxX, int numpointsPerXOrder, int numpointsOverY);
|
void get_Elastic_fromFunction(double (*f)(double,double), double minX, double maxX, int numpointsPerXOrder, int numpointsOverY);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "electron.hpp"
|
#include "electron.hpp"
|
||||||
|
#include "density_container.hpp"
|
||||||
|
|
||||||
#include "blitz/tinyvec2.h"
|
#include "blitz/tinyvec2.h"
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
@@ -75,6 +76,12 @@ private:
|
|||||||
bool check_WallTermination(Electron checkElectron);
|
bool check_WallTermination(Electron checkElectron);
|
||||||
|
|
||||||
static const double cutoffEnergy_eV;
|
static const double cutoffEnergy_eV;
|
||||||
|
|
||||||
|
|
||||||
|
// Ions
|
||||||
|
public:
|
||||||
|
private:
|
||||||
|
//Skalar_WGTS_Container Ion_Container = Skalar_WGTS_Container(0, wgtsLength_m, wgtsRadius_m, vec3(10,10,12));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* katrin_hpp */
|
#endif /* katrin_hpp */
|
||||||
|
|||||||
+11
-57
@@ -22,7 +22,6 @@ void createBED_TCS_Func_container() {
|
|||||||
Average1D_FuncContainer BED_average_TCS;
|
Average1D_FuncContainer BED_average_TCS;
|
||||||
BED_average_TCS.set_Map(BED_edge_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");
|
BED_average_TCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_average_TCS.dat");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createBED_SDCS_Func2D_container() {
|
void createBED_SDCS_Func2D_container() {
|
||||||
@@ -43,71 +42,26 @@ void createBED_SDCS_Func2D_container() {
|
|||||||
BED_stacked_SDCS.set_Map(BED_average_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");
|
BED_stacked_SDCS.exportToFile("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_stacked_SDCS.dat");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void testSpeed() {
|
|
||||||
double dummy;
|
|
||||||
Edge1D_FuncContainer TCS = Edge1D_FuncContainer("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_TCS.dat");
|
|
||||||
Edge2D_FuncContainer SDCS = Edge2D_FuncContainer("/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/src/mc_electron/data/BED_SDCS.dat");
|
|
||||||
clock_t start = clock();
|
|
||||||
int imax = 1000;
|
|
||||||
double T_eV = 20;
|
|
||||||
double W_eV = 1;
|
|
||||||
cout<<"TCS function call:\n";
|
|
||||||
for (int i = 0;i<imax;i++) {
|
|
||||||
dummy = BED_Ionization::get_TCS(T_eV);
|
|
||||||
}
|
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
|
||||||
|
|
||||||
start = clock();
|
|
||||||
cout<<"TCS container call:\n";
|
|
||||||
for (int i = 0;i<imax;i++) {
|
|
||||||
dummy = TCS.interpolate(T_eV);
|
|
||||||
}
|
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
|
||||||
|
|
||||||
start = clock();
|
|
||||||
cout<<"SDCS function call:\n";
|
|
||||||
for (int i = 0;i<imax;i++) {
|
|
||||||
dummy = BED_Ionization::get_SDCS(T_eV,W_eV);
|
|
||||||
}
|
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
|
||||||
|
|
||||||
start = clock();
|
|
||||||
cout<<"SDCS container call:\n";
|
|
||||||
for (int i = 0;i<imax;i++) {
|
|
||||||
dummy = SDCS.interpolate(T_eV,W_eV);
|
|
||||||
}
|
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Katrin Kat;
|
||||||
|
double tritiumDens(vec3 cordszrphi) {
|
||||||
|
double x = cordszrphi[1] * cos(cordszrphi[2]);
|
||||||
|
double y = cordszrphi[1] * sin(cordszrphi[2]);
|
||||||
|
double z = cordszrphi[0];
|
||||||
|
return (Kat.getTritiumDensity_m3(vec3(x,y,z)));
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[]) {
|
||||||
/*
|
|
||||||
try {
|
|
||||||
Simulation Sim;
|
|
||||||
Sim.doit();
|
|
||||||
} catch (MyException& caught) {
|
|
||||||
cout<<caught.what()<<endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//testSpeed();
|
|
||||||
|
|
||||||
clock_t start = clock();
|
clock_t start = clock();
|
||||||
Simulation Sim;
|
Simulation Sim;
|
||||||
Sim.doit();
|
Sim.doit();
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
||||||
|
|
||||||
//createBED_TCS_Func_container();
|
//createBED_TCS_Func_container();
|
||||||
//createBED_SDCS_Func2D_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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,32 +23,42 @@ const int Simulation::propagationMethod = getParameter("propagationMethod");
|
|||||||
const int Simulation::maxInteractions = getParameter("maxInteractions");
|
const int Simulation::maxInteractions = getParameter("maxInteractions");
|
||||||
|
|
||||||
Simulation::Simulation() {
|
Simulation::Simulation() {
|
||||||
numberTotalElectrons = 0;
|
|
||||||
numberDecays = 0;
|
|
||||||
rngUni.seed(seed);
|
rngUni.seed(seed);
|
||||||
updater_fraction = numberTotalDecays/100;
|
updater_fraction = numberTotalDecays/100;
|
||||||
updater_numberOfPrevious = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::doit() {
|
void Simulation::doit() {
|
||||||
int numberInteractionsThisElectron = 0;
|
while ( (numberDecays < numberTotalDecays) || (!electronQue.empty()) || (!tritiumIonQue.empty()) ) {
|
||||||
while ( (numberDecays < numberTotalDecays) || (electronQue.size() > 0) ) {
|
if (electronQue.empty() && tritiumIonQue.empty()) {
|
||||||
if (electronQue.empty()) {
|
|
||||||
electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal));
|
electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal));
|
||||||
numberDecays++;
|
numberDecays++;
|
||||||
}
|
}
|
||||||
actionElectronPtr = &electronQue.front();
|
|
||||||
do_statusUpdate();
|
do_statusUpdate();
|
||||||
|
if (!electronQue.empty()) {
|
||||||
|
process_firstElectron();
|
||||||
|
} else {
|
||||||
|
process_firstTIon();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void Simulation::process_firstElectron() {
|
||||||
|
int numberInteractionsThisElectron = 0;
|
||||||
|
actionElectronPtr = &electronQue.front();
|
||||||
|
while (!Kat.check_Termination (*actionElectronPtr) && !check_NumberInteractions(numberInteractionsThisElectron)) {
|
||||||
move_electron(actionElectronPtr, &Log);
|
move_electron(actionElectronPtr, &Log);
|
||||||
if (!Kat.check_Termination (*actionElectronPtr) ) {
|
if (!Kat.check_Termination (*actionElectronPtr) ) {
|
||||||
do_interaction(actionElectronPtr);
|
do_interaction(actionElectronPtr);
|
||||||
}
|
}
|
||||||
if (Kat.check_Termination (*actionElectronPtr) || check_NumberInteractions(numberInteractionsThisElectron)) {
|
|
||||||
electronQue.pop_front();
|
|
||||||
numberInteractionsThisElectron = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
electronQue.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Simulation::process_firstTIon() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Simulation::check_NumberInteractions(int &numberInteractionsThisElectron) {
|
bool Simulation::check_NumberInteractions(int &numberInteractionsThisElectron) {
|
||||||
if (maxInteractions == 0) {
|
if (maxInteractions == 0) {
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
|
|
||||||
#include "katrin.hpp"
|
#include "katrin.hpp"
|
||||||
#include "electron.hpp"
|
#include "electron.hpp"
|
||||||
#include "logger.hpp"
|
#include "tritiumion.hpp"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +22,10 @@ public:
|
|||||||
|
|
||||||
void doit();
|
void doit();
|
||||||
private:
|
private:
|
||||||
|
void process_firstElectron();
|
||||||
|
void process_firstTIon();
|
||||||
|
|
||||||
|
|
||||||
void do_statusUpdate();
|
void do_statusUpdate();
|
||||||
void move_electron(Electron *moveElectron, H5_Logger *Log);
|
void move_electron(Electron *moveElectron, H5_Logger *Log);
|
||||||
void do_interaction(Electron *interactElectron);
|
void do_interaction(Electron *interactElectron);
|
||||||
@@ -34,16 +37,21 @@ private:
|
|||||||
ranlib::Uniform<double> rngUni;
|
ranlib::Uniform<double> rngUni;
|
||||||
ranlib::NormalUnit<double> rngNormal;
|
ranlib::NormalUnit<double> rngNormal;
|
||||||
|
|
||||||
int numberTotalElectrons;
|
// Electrons
|
||||||
int numberDecays;
|
int numberTotalElectrons = 0;
|
||||||
|
int numberDecays = 0;
|
||||||
std::deque<Electron> electronQue;
|
std::deque<Electron> electronQue;
|
||||||
Electron *actionElectronPtr;
|
Electron *actionElectronPtr;
|
||||||
|
|
||||||
//Updater
|
// Ions
|
||||||
int updater_numberOfPrevious;
|
int numberTotalIons = 0;
|
||||||
|
std::deque<TritiumIon> tritiumIonQue;
|
||||||
|
|
||||||
|
// Updater
|
||||||
|
int updater_numberOfPrevious = 0;
|
||||||
int updater_fraction;
|
int updater_fraction;
|
||||||
|
|
||||||
|
// Parameters
|
||||||
static const long int seed;
|
static const long int seed;
|
||||||
static const long int numberTotalDecays;
|
static const long int numberTotalDecays;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
//
|
||||||
|
// tritiumion.cpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 11.04.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "tritiumion.hpp"
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// tritiumion.hpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 11.04.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef tritiumion_hpp
|
||||||
|
#define tritiumion_hpp
|
||||||
|
|
||||||
|
#include "particle.hpp"
|
||||||
|
#include "function_container.hpp"
|
||||||
|
|
||||||
|
class TritiumIon : public Particle {
|
||||||
|
public:
|
||||||
|
TritiumIon(vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum) : Particle(mT2_eV, 1 , loc_m, speed_ms, idnum, parentIdnum, electron) {};
|
||||||
|
|
||||||
|
// Interactions
|
||||||
|
public:
|
||||||
|
double get_SigmaTotal_m2(vec3 speedT2_ms);
|
||||||
|
std::vector<double> get_SigmaVector_m2(vec3 speedT2_ms);
|
||||||
|
int roll_Interaction(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||||
|
private:
|
||||||
|
static const int ionOn;
|
||||||
|
static const int elaOn;
|
||||||
|
|
||||||
|
// Elastic Scattering
|
||||||
|
public:
|
||||||
|
void do_elaScattering (vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||||
|
double get_elaSigma_m2(vec3 speedT2_ms);
|
||||||
|
protected:
|
||||||
|
double get_elaEta(vec3 speedLab_ms);
|
||||||
|
double roll_elaTheta(vec3 speedT2_ms, ranlib::Uniform<double> *rngUni);
|
||||||
|
void do_elaKinetics(vec3 speedT2_ms, double theta, double phi);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* tritiumion_hpp */
|
||||||
Reference in New Issue
Block a user