Major changes:

- Added individul operators for species and better selecting process.
- Switched to C arrays for main loop operations and calculating array indizes using knowledge of binning instead of doing sorted search
- Added Recombination
- Reworked elastic scattering kinematics
- Added inelastic scattering kinematics
This commit is contained in:
Christian
2019-05-27 13:51:32 +02:00
parent ac83bae061
commit 79bf420f8d
56 changed files with 82194 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
//
// dcs_container.cpp
// mc_electron
//
// Created by Christian Reiling on 22.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "dcs_container.hpp"
void DCS_Theta_Container::calc_data(std::string load_path) {
Edge_Container<dim2Map> E2D(load_path);
int number_theta_bins = theta_scale.get_dimension();
double *temp;
double sum;
for (int E_bin = 0; E_bin<=E_scale.get_max_index(); E_bin++) {
temp = new double[number_theta_bins];
sum = 0;
for (int theta_bin = 0; theta_bin < number_theta_bins; theta_bin++) {
sum += calc_bin_value(E_bin, theta_bin, &E2D);
temp[theta_bin] = sum;
}
for (int theta_bin = 0; theta_bin < number_theta_bins; theta_bin++) {
temp[theta_bin] /= sum;
}
data[E_bin] = temp;
}
}
double DCS_Theta_Container::calc_E_eV(const int &E_bin) {
double E_eV;
if (E_bin == 0) {
E_eV = E_scale.calc_upper_bound(0);
} else {
E_eV = E_scale.calc_upper_bound(E_bin-1);
E_eV +=(E_scale.calc_upper_bound(E_bin) - E_scale.calc_upper_bound(E_bin-1))/2;
}
return (E_eV);
}
double DCS_Theta_Container::calc_bin_value(const int &E_bin, const int &theta_bin, Edge_Container<dim2Map> *E2D) {
double E_eV = calc_E_eV(E_bin);
double theta = theta_scale.calc_upper_bound(theta_bin);
double val = E2D->interpolate(ddeque{E_eV, theta});
if (theta_bin == 0 || theta_bin == theta_scale.get_max_index()) {
val *= 0.5;
}
return (val);
}
double DCS_Theta_Container::roll_value(double E_eV, UniRNG *rngUni) {
int E_index = E_scale.calc_index(E_eV);
double target = rngUni->random();
for (int i=0; i<=theta_scale.get_max_index(); i++) {
if (target < data[E_index][i]) {
return (theta_scale.calc_upper_bound(i)); //upper bound represents corresponding value.
//return (roll_in_bin(i, rngUni)); // rolling in bin.
}
}
std::stringstream ss;
ss<<"DCS_Theta_Container::get_value: Overflow./n";
throw MyException (ss.str());
}
double DCS_Theta_Container::roll_in_bin(const int &theta_bin, UniRNG *rngUni) {
int lower_bin = theta_bin-1;
int upper_bin = theta_bin+1;
int max_bin = theta_scale.get_max_index();
lower_bin = (lower_bin<0) ? 0 : lower_bin;
upper_bin = (upper_bin>max_bin) ? max_bin : upper_bin;
double lower_value = theta_scale.calc_upper_bound(lower_bin);
double this_value = theta_scale.calc_upper_bound(theta_bin);
double upper_value = theta_scale.calc_upper_bound(upper_bin);
double lower_theta = lower_value + 0.5*(this_value - lower_value);
double upper_theta = this_value + 0.5*(upper_value - this_value);
double sample_value = lower_theta + rngUni->random() * (upper_theta-lower_theta);
return (sample_value);
}