Major changes:

- Moved to array operations for main loops.
- Changed to setting pointers to operator only once before loop.
- Changed Population Containers
- Added Recombination
- Added Inelastic Scattering Kinematics
- Reworked Elastic Scattering Cross Section
- Reworked Elastic Scattering Kinematics
- Reworked organisation of different particle species and corresponding operators
This commit is contained in:
Christian
2019-05-27 13:46:59 +02:00
parent 0f2a5625a2
commit ac83bae061
50 changed files with 1057 additions and 2374 deletions
+131
View File
@@ -0,0 +1,131 @@
//
// stacked_container.h
// mc_electron
//
// Created by Christian Reiling on 10.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef stacked_container_h
#define stacked_container_h
#include "average_container.h"
#include "random_operations.h"
template <class T_Map>
class Stacked_Container : public Base_Container<T_Map> {
double lowerEdge = 0;
public:
Stacked_Container() : Base_Container<T_Map>() {} ;
Stacked_Container(const double &lowerEdge, std::string load_path) : Base_Container<T_Map>(load_path) {
this->lowerEdge = lowerEdge;
}
Stacked_Container(const double &lowerEdge, const Average_Container<T_Map> &averageContainer) {
this->lowerEdge = lowerEdge;
calcMap(averageContainer);
}
public:
void calcMap(const Average_Container<T_Map> &averageContainer, const double &lowerEdge);
private:
void rec_calcMap(const dim1Map &subMap, std::deque<double> Points);
template <typename T> void rec_calcMap(const T &subMapm, std::deque<double> Points);
double calc_tot(const dim1Map &subMap);
public:
double sample(const std::deque<double> &Points, UniRNG *rngUni);
};
template <class T_Map>
void Stacked_Container<T_Map>::calcMap(const Average_Container<T_Map> &averageContainer, const double &lowerEdge) {
this->lowerEdge = lowerEdge;
T_Map averageMap = averageContainer.getMap();
if (averageMap.empty()) {
std::stringstream ss;
ss<<"Stacked_Container::calcMap: Input Average_Container empty.\n";
throw MyException(ss.str());
}
Base_Container<T_Map>::Map.clear();
std::deque<double> Points;
rec_calcMap(averageMap, Points);
}
template <class T_Map>
void Stacked_Container<T_Map>::rec_calcMap(const dim1Map &subMap, std::deque<double> Points) {
double tot = calc_tot(subMap);
double curVal, width, heigth;
// first value manually, because of lowerEdge
width = subMap.cbegin()->first - lowerEdge;
heigth = subMap.cbegin()->second/tot;
curVal = width * heigth;
Points.push_back(curVal);
Points.push_back(subMap.cbegin()->first);
Base_Container<T_Map>::addPoint(Points);
Points.pop_back();
Points.pop_back();
dim1Map::const_iterator preItr;
for (dim1Map::const_iterator curItr = (++subMap.cbegin()); curItr!=subMap.cend(); curItr++) {
preItr = curItr;
--preItr;
width = curItr->first - preItr->first;
heigth = curItr->second/tot;
curVal += width*heigth;
Points.push_back(curVal);
Points.push_back(curItr->first);
Base_Container<T_Map>::addPoint(Points);
Points.pop_back();
Points.pop_back();
}
}
template <class T_Map>
template <typename T>
void Stacked_Container<T_Map>::rec_calcMap(const T &subMap, std::deque<double> Points) {
for (typename T::const_iterator Itr = subMap.cbegin(); Itr!= subMap.cend(); Itr++) {
Points.push_back(Itr->first);
rec_calcMap(Itr->second, Points);
Points.pop_back();
}
}
template <class T_Map>
double Stacked_Container<T_Map>::calc_tot(const dim1Map &subMap) {
double tot = 0;
// insert first value manually
double width, heigth;
width = subMap.begin()->first - lowerEdge;
heigth = subMap.begin()->second;
tot += width*heigth;
dim1Map::const_iterator preItr;
for (dim1Map::const_iterator curItr = (++subMap.cbegin()); curItr!=subMap.cend(); curItr++) {
preItr = curItr;
--preItr;
width = curItr->first - preItr->first;
heigth = curItr->second;
tot += width*heigth;
}
return (tot);
}
template <class T_Map>
double Stacked_Container<T_Map>::sample(const std::deque<double> &Points, UniRNG *rngUni) {
Base_Container<T_Map>::checkEmpty();
if (Points.size() != Base_Container<T_Map>::Dim - 1) {
std::stringstream ss;
ss<<"Stacked_Container::sample: deque Point dimension missmatch.\n";
throw MyException(ss.str());
}
dim1Map *endMap = Base_Container<T_Map>::template getSubMap<dim1Map>(Points, Lower_bound_Over);
return (endMap->lower_bound(rngUni->random())->second);
}
#endif /* stacked_container_h */