Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
561131906b |
@@ -1,122 +0,0 @@
|
||||
#include "CurrentHistogram.h"
|
||||
|
||||
#include <exception>
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
double binWidth(int num_bins, double min, double max)
|
||||
{
|
||||
return (max-min)/num_bins;
|
||||
}
|
||||
|
||||
std::vector<double> createEnergyBins(int decade_min, int decade_max)
|
||||
{
|
||||
std::vector<double> bins;
|
||||
for(int power = decade_min; power < decade_max; ++power){
|
||||
for(int num = 1; num < 10; ++num){
|
||||
bins.push_back(num*std::pow(10,power));
|
||||
}
|
||||
}
|
||||
bins.push_back(std::pow(10,decade_max));
|
||||
return bins;
|
||||
}
|
||||
|
||||
int numEnergyBins(int energy_decade_min, int energy_decade_max){
|
||||
return (energy_decade_max-energy_decade_min)*9 + 1;
|
||||
}
|
||||
|
||||
CurrentHistogram::CurrentHistogram(
|
||||
int num_bin_z, double z_min, double z_max,
|
||||
int num_bin_r, double r_max,
|
||||
int energy_decade_min, int energy_decade_max):
|
||||
dr_(binWidth(num_bin_r, 0., r_max)),
|
||||
dz_(binWidth(num_bin_z, z_min, z_max)),
|
||||
z_min_(z_min),
|
||||
r_min_(0.),
|
||||
num_bin_z_(num_bin_z),
|
||||
num_bin_r_(num_bin_r),
|
||||
energy_bins_(createEnergyBins(energy_decade_min, energy_decade_max)),
|
||||
hist_data_(
|
||||
blitz::Range(0, num_bin_r),
|
||||
blitz::Range(-1, num_bin_z),
|
||||
blitz::Range(-1, numEnergyBins(energy_decade_min, energy_decade_max)-1))
|
||||
{
|
||||
hist_data_=0;
|
||||
}
|
||||
|
||||
int CurrentHistogram::findRadialBin (
|
||||
const blitz::TinyVector<double,3>& position_cart) const
|
||||
{
|
||||
const double r = std::sqrt(position_cart(0)*position_cart(0) + position_cart(1)*position_cart(1));
|
||||
const int bin_r = std::floor(r/dr_);
|
||||
return std::min(bin_r, num_bin_r_);
|
||||
}
|
||||
|
||||
int CurrentHistogram::findLongitudinalBin (
|
||||
const blitz::TinyVector<double,3>& position_cart) const
|
||||
{
|
||||
const int bin_z = std::floor((position_cart(2)-z_min_)/dz_);
|
||||
return std::min(std::max(-1,bin_z),num_bin_z_);
|
||||
}
|
||||
|
||||
int CurrentHistogram::findEnergyBin(double energy) const
|
||||
{
|
||||
auto const it = std::lower_bound(energy_bins_.begin(), energy_bins_.end(), energy);
|
||||
//if (it == energy_bins_.end()) { return energy_bins_.size(); }
|
||||
//if (it == energy_bins_.begin()){ return -1;};
|
||||
return (it-energy_bins_.begin())-1;
|
||||
}
|
||||
|
||||
void CurrentHistogram::fill(
|
||||
const blitz::TinyVector<double,3>& position_cart,
|
||||
double energy)
|
||||
{
|
||||
const int bin_z = findLongitudinalBin(position_cart);
|
||||
const int bin_r = findRadialBin(position_cart);
|
||||
const int bin_E = findEnergyBin(energy);
|
||||
hist_data_(bin_r, bin_z, bin_E) += static_cast<long int>(1);
|
||||
}
|
||||
|
||||
void CurrentHistogram::fill(int bin_r, int bin_z, double energy)
|
||||
{
|
||||
const int bin_E = findEnergyBin(energy);
|
||||
if(hist_data_.isInRange(bin_r, bin_z, bin_E)){
|
||||
hist_data_(bin_r, bin_z, bin_E) += static_cast<long int>(1);
|
||||
}
|
||||
}
|
||||
|
||||
blitz::TinyVector<int,2> CurrentHistogram::binDifference(
|
||||
const blitz::TinyVector<double,3>& new_position_cart,
|
||||
const blitz::TinyVector<double,3>& old_position_cart)
|
||||
{
|
||||
const int bin_z_old = findLongitudinalBin(old_position_cart);
|
||||
const int bin_r_old = findRadialBin(old_position_cart);
|
||||
|
||||
const int bin_z_new = findLongitudinalBin(new_position_cart);
|
||||
const int bin_r_new = findRadialBin(new_position_cart);
|
||||
|
||||
return blitz::TinyVector<int,2>(bin_r_new-bin_r_old, bin_z_new-bin_z_old);
|
||||
}
|
||||
|
||||
std::vector<double> CurrentHistogram::binBordersR() const
|
||||
{
|
||||
std::vector<double> bin_border_r;
|
||||
for(int i = 0; i <= num_bin_r_; ++i){
|
||||
const double border = r_min_ + i*dr_;
|
||||
bin_border_r.push_back(border);
|
||||
}
|
||||
return bin_border_r;
|
||||
}
|
||||
std::vector<double> CurrentHistogram::binBordersZ() const
|
||||
{
|
||||
std::vector<double> bin_border_z;
|
||||
for(int i = 0; i <= num_bin_z_; ++i){
|
||||
const double border = z_min_ + i*dz_;
|
||||
bin_border_z.push_back(border);
|
||||
}
|
||||
return bin_border_z;
|
||||
}
|
||||
std::vector<double> CurrentHistogram::binBordersE() const
|
||||
{
|
||||
return energy_bins_;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifndef CURRENTHISTOGRAM_H
|
||||
#define CURRENTHISTOGRAM_H
|
||||
|
||||
#include "blitz/array.h"
|
||||
#include <vector>
|
||||
|
||||
class CurrentHistogram {
|
||||
public:
|
||||
CurrentHistogram(
|
||||
int num_bin_z, double z_min, double z_max,
|
||||
int num_bin_r, double r_max,
|
||||
int energy_decade_min, int energy_decade_max);
|
||||
|
||||
void fill(
|
||||
const blitz::TinyVector<double,3>& position_cart,
|
||||
double energy);
|
||||
|
||||
void fill(int bin_r, int bin_z, double energy);
|
||||
|
||||
int findRadialBin(
|
||||
const blitz::TinyVector<double,3>& position_cart) const;
|
||||
|
||||
int findLongitudinalBin(
|
||||
const blitz::TinyVector<double,3>& position_cart) const;
|
||||
|
||||
int findEnergyBin(
|
||||
double energy) const;
|
||||
|
||||
blitz::TinyVector<int,2> binDifference(
|
||||
const blitz::TinyVector<double,3>& new_position_cart,
|
||||
const blitz::TinyVector<double,3>& old_position_cart);
|
||||
|
||||
blitz::Array<unsigned long,3> hist_data_;
|
||||
|
||||
std::vector<double> binBordersR() const;
|
||||
std::vector<double> binBordersZ() const;
|
||||
std::vector<double> binBordersE() const;
|
||||
private:
|
||||
|
||||
const std::vector<double> energy_bins_;
|
||||
|
||||
const double dz_;
|
||||
const double dr_;
|
||||
|
||||
const double z_min_;
|
||||
const double r_min_;
|
||||
|
||||
const int num_bin_z_;
|
||||
const int num_bin_r_;
|
||||
};
|
||||
|
||||
#endif /* CURRENTHISTOGRAM_H */
|
||||
@@ -1,191 +0,0 @@
|
||||
#include "CurrentLogger.h"
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "highfive/H5File.hpp"
|
||||
#include "highfive/H5DataSet.hpp"
|
||||
|
||||
#include <hdf5_hl.h>
|
||||
|
||||
CurrentLogger::CurrentLogger(
|
||||
species this_species,
|
||||
int num_planes_z, double z_min, double z_max,
|
||||
int num_planes_r, double r_max,
|
||||
int energy_decade_min, int energy_decade_max,
|
||||
std::string output_filename):
|
||||
Particle_Logger_Base(this_species),
|
||||
N_pos_r(
|
||||
num_planes_z-1, z_min, z_max, // -1 through |[0,n]| = n+1
|
||||
num_planes_r, r_max,
|
||||
energy_decade_min, energy_decade_max ),
|
||||
N_neg_r(
|
||||
num_planes_z-1, z_min, z_max, // -1 through |[0,n]| = n+1
|
||||
num_planes_r, r_max,
|
||||
energy_decade_min, energy_decade_max ),
|
||||
N_pos_z(
|
||||
num_planes_z-1, z_min, z_max, // -1 through |[0,n]| = n+1
|
||||
num_planes_r, r_max,
|
||||
energy_decade_min, energy_decade_max ),
|
||||
N_neg_z(
|
||||
num_planes_z-1, z_min, z_max, // -1 through |[0,n]| = n+1
|
||||
num_planes_r, r_max,
|
||||
energy_decade_min, energy_decade_max ),
|
||||
output_filename_(output_filename)
|
||||
{
|
||||
writeBinBorderData();
|
||||
}
|
||||
|
||||
void CurrentLogger::log(const Particle& logPart, const vec3& old_loc_m)
|
||||
{
|
||||
if (!logging) {
|
||||
return;
|
||||
}
|
||||
|
||||
const vec3 new_loc_m = logPart.get_x_m();
|
||||
|
||||
const int bin_r_new = N_pos_r.findRadialBin(new_loc_m);
|
||||
const int bin_z_new = N_pos_r.findLongitudinalBin(new_loc_m);
|
||||
|
||||
const int bin_r_old = N_pos_r.findRadialBin(old_loc_m);
|
||||
const int bin_z_old = N_pos_r.findLongitudinalBin(old_loc_m);
|
||||
|
||||
const int delta_bin_r = bin_r_new - bin_r_old;
|
||||
const int delta_bin_z = bin_z_new - bin_z_old;
|
||||
|
||||
//std::cout << "bin_z_new " << bin_z_new << std::endl;
|
||||
//std::cout << "bin_z_old " << bin_z_old << std::endl;
|
||||
|
||||
//if(std::abs(delta_bin_z) > 1){
|
||||
// std::cout << "Moved bins: " << delta_bin_z << std::endl;
|
||||
//}
|
||||
|
||||
if((delta_bin_r ==0) && (delta_bin_z == 0)){
|
||||
// do nothing
|
||||
}
|
||||
else{
|
||||
const double energy = logPart.get_E_eV();
|
||||
|
||||
if(delta_bin_z >= 1){
|
||||
for(int i = 0; i < delta_bin_z; ++i){
|
||||
N_pos_z.fill(bin_r_old, bin_z_old+i, energy);
|
||||
}
|
||||
//N_pos_z.fill(bin_r_old, bin_z_old, energy);
|
||||
}
|
||||
else if(delta_bin_z <= -1) {
|
||||
for(int i = 0; i < std::abs(delta_bin_z); ++i){
|
||||
N_neg_z.fill(bin_r_old, bin_z_old-i, energy);
|
||||
}
|
||||
//N_neg_z.fill(bin_r_old, bin_z_old, energy);
|
||||
}
|
||||
|
||||
if(delta_bin_r == 1){
|
||||
N_pos_r.fill(bin_r_old, bin_z_old, energy);
|
||||
}
|
||||
else if(delta_bin_r == -1) {
|
||||
N_neg_r.fill(bin_r_old, bin_z_old, energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CurrentLogger::flush()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void CurrentLogger::writeBinBorderData()
|
||||
{
|
||||
std::string filename = output_filename_+"_currents.h5";
|
||||
std::string group = "/" + get_species_string(this->get_species()) + "/current_bin_borders";
|
||||
|
||||
HighFive::File file(
|
||||
filename,
|
||||
HighFive::File::ReadWrite | HighFive::File::Create);
|
||||
|
||||
if(!file.exist(group)){
|
||||
file.createGroup(group);
|
||||
}
|
||||
|
||||
auto bin_borders_E = N_pos_z.binBordersE();
|
||||
std::string path_E = group + "/bin_borders_E";
|
||||
|
||||
if(file.exist(path_E)){
|
||||
HighFive::DataSet dataset = file.getDataSet(path_E);
|
||||
dataset.write(bin_borders_E);
|
||||
} else{
|
||||
HighFive::DataSet dataset =
|
||||
file.createDataSet<double>(path_E, HighFive::DataSpace::From(bin_borders_E));
|
||||
dataset.write(bin_borders_E);
|
||||
}
|
||||
|
||||
|
||||
auto bin_borders_r = N_pos_z.binBordersR();
|
||||
std::string path_r = group + "/bin_borders_r";
|
||||
if(file.exist(path_r)){
|
||||
HighFive::DataSet dataset = file.getDataSet(path_r);
|
||||
dataset.write(bin_borders_r);
|
||||
} else{
|
||||
HighFive::DataSet dataset =
|
||||
file.createDataSet<double>(path_r, HighFive::DataSpace::From(bin_borders_r));
|
||||
dataset.write(bin_borders_r);
|
||||
}
|
||||
|
||||
auto bin_borders_z = N_pos_z.binBordersZ();
|
||||
std::string path_z = group + "/bin_borders_z";
|
||||
if(file.exist(path_z)){
|
||||
HighFive::DataSet dataset = file.getDataSet(path_z);
|
||||
dataset.write(bin_borders_z);
|
||||
} else{
|
||||
HighFive::DataSet dataset =
|
||||
file.createDataSet<double>(path_z, HighFive::DataSpace::From(bin_borders_z));
|
||||
dataset.write(bin_borders_z);
|
||||
}
|
||||
}
|
||||
|
||||
void CurrentLogger::output()
|
||||
{
|
||||
output("N_pos_z", N_pos_z.hist_data_);
|
||||
output("N_neg_z", N_neg_z.hist_data_);
|
||||
output("N_pos_r", N_pos_r.hist_data_);
|
||||
output("N_neg_r", N_neg_r.hist_data_);
|
||||
}
|
||||
|
||||
void CurrentLogger::output(
|
||||
std::string dataname, const blitz::Array<unsigned long,3>& data)
|
||||
{
|
||||
std::string filename = output_filename_+"_currents.h5";
|
||||
std::string group = "/" + get_species_string(this->get_species());
|
||||
std::string path = group+"/"+dataname;
|
||||
|
||||
HighFive::File file(
|
||||
filename,
|
||||
HighFive::File::ReadWrite | HighFive::File::Create);
|
||||
|
||||
if(!file.exist(group)){
|
||||
file.createGroup(group);
|
||||
}
|
||||
|
||||
blitz::TinyVector<int,3> start = data.lbound();
|
||||
blitz::TinyVector<int,3> end = data.ubound();
|
||||
|
||||
std::vector<std::vector<std::vector<unsigned long>>> data_v;
|
||||
for(int i = start(0); i<=end(0); ++i){
|
||||
std::vector<std::vector<unsigned long>> zs;
|
||||
for(int j = start(1); j<=end(1); ++j){
|
||||
std::vector<unsigned long> energies;
|
||||
for(int k = start(2); k<=end(2); ++k){
|
||||
energies.push_back(data(i,j,k));
|
||||
}
|
||||
zs.push_back(energies);
|
||||
}
|
||||
data_v.push_back(zs);
|
||||
}
|
||||
|
||||
if(file.exist(path)){
|
||||
HighFive::DataSet dataset = file.getDataSet(path);
|
||||
dataset.write(data_v);
|
||||
} else{
|
||||
HighFive::DataSet dataset =
|
||||
file.createDataSet<unsigned long>(path, HighFive::DataSpace::From(data_v));
|
||||
dataset.write(data_v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef CURRENTLOGGER_H
|
||||
#define CURRENTLOGGER_H
|
||||
|
||||
#include "particle_logger_base.h"
|
||||
#include "CurrentHistogram.h"
|
||||
|
||||
class CurrentLogger : public Particle_Logger_Base {
|
||||
public:
|
||||
CurrentLogger(
|
||||
species this_species,
|
||||
int num_planes_z, double z_min, double z_max,
|
||||
int num_planes_r, double r_max,
|
||||
int energy_decade_min, int energy_decade_max,
|
||||
std::string output_filename);
|
||||
|
||||
void log(const Particle& logPart, const vec3& old_loc_m);
|
||||
void flush();
|
||||
void output();
|
||||
|
||||
private:
|
||||
CurrentHistogram N_pos_r;
|
||||
CurrentHistogram N_neg_r;
|
||||
|
||||
CurrentHistogram N_pos_z;
|
||||
CurrentHistogram N_neg_z;
|
||||
|
||||
const std::string output_filename_;
|
||||
|
||||
void output(
|
||||
std::string dataname,
|
||||
const blitz::Array<unsigned long,3>& data);
|
||||
|
||||
void writeBinBorderData();
|
||||
};
|
||||
|
||||
#endif /* CURRENTLOGGER_H */
|
||||
@@ -1,115 +0,0 @@
|
||||
#include "Ion_Mover_Boris.h"
|
||||
|
||||
Ion_Mover_Boris::Ion_Mover_Boris(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population,
|
||||
double B_max):
|
||||
Mover_Base(this_species, Logger, Population)
|
||||
{
|
||||
if(B_max == 0.){
|
||||
dt_s = 1.;
|
||||
} else{
|
||||
dt_s = Population->get_m_eV()/(B_max*c_ms*c_ms);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Ion_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m)
|
||||
{
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
|
||||
if (macro_sigma_m == 0) { // If infinite movement distance let electron leave at only exit... Prob extremly faulty, but also impossible.
|
||||
movePart->set_x_m(z_RW_m);
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_x_m();
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(movePart, E_Vm, B_T);
|
||||
if (doBoris_WallInteraction(movePart) == true) {
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(movePart, &oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double Ion_Mover_Boris::doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T)
|
||||
{
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_x_m();
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * calc_vec3_abs(v_ms);
|
||||
doBoris_speedChange(movePart, E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * calc_vec3_abs(v_ms);
|
||||
movePart->set_x_m(x_m);
|
||||
return distance_m;
|
||||
}
|
||||
|
||||
void Ion_Mover_Boris::doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Z() * e_C;
|
||||
double m_kg = movePart->get_m_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_v_ms(v_ms);
|
||||
}
|
||||
|
||||
bool Ion_Mover_Boris::doBoris_WallInteraction(Particle *movePart) {
|
||||
vec3 loc_m = movePart->get_x_m();
|
||||
double r_m = movePart->get_r_m();
|
||||
if (loc_m[2]<=z_RW_m) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_x_m(newLoc_m);
|
||||
return true;
|
||||
}
|
||||
if (r_m>=r_WGTS_m) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (r_WGTS_m * 1.01)/calc_vec3_abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return true;
|
||||
}
|
||||
if (loc_m[2]>=z_DPS_m) { // DPS Absorption
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
newLoc_m[2] = z_DPS_m;
|
||||
movePart->set_x_m(newLoc_m);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ion_Mover_Boris::doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_x_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef ION_MOVER_BORIS_H
|
||||
#define ION_MOVER_BORIS_H
|
||||
|
||||
#include "mover_base.h"
|
||||
#include "constants.h"
|
||||
|
||||
class Ion_Mover_Boris : public Mover_Base {
|
||||
double dt_s;
|
||||
public:
|
||||
Ion_Mover_Boris(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population,
|
||||
double B_max);
|
||||
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
|
||||
private:
|
||||
double doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T);
|
||||
void doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T);
|
||||
bool doBoris_WallInteraction(Particle *movePart);
|
||||
void doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m);
|
||||
};
|
||||
|
||||
|
||||
#endif /* ION_MOVER_BORIS_H */
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "LongitudinalBins.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
namespace Discrete {
|
||||
|
||||
std::vector<double> createBins(
|
||||
double z_min, double z_max,
|
||||
int num_bins)
|
||||
{
|
||||
std::vector<double> bins;
|
||||
const double dz = (z_max - z_min)/num_bins;
|
||||
for(int bin = 0; bin <= num_bins; ++bin){
|
||||
bins.push_back(z_min + bin*dz);
|
||||
}
|
||||
return bins;
|
||||
}
|
||||
|
||||
|
||||
Longitudinal::Longitudinal(
|
||||
double z_min,
|
||||
double z_max,
|
||||
int num_bins):
|
||||
bins_(createBins(z_min, z_max, num_bins))
|
||||
{
|
||||
}
|
||||
|
||||
Longitudinal::Longitudinal(const Longitudinal& l):
|
||||
bins_(l.bins_)
|
||||
{}
|
||||
|
||||
bool Longitudinal::changedBin(double z_start, double z_end) const
|
||||
{
|
||||
return !(findBin(z_start) == findBin(z_end));
|
||||
}
|
||||
|
||||
int Longitudinal::findBin(double z) const
|
||||
{
|
||||
auto const it = std::lower_bound(bins_.begin(), bins_.end(), z);
|
||||
return (it-bins_.begin())-1;
|
||||
}
|
||||
|
||||
std::vector<double> Longitudinal::bins() const
|
||||
{
|
||||
return bins_;
|
||||
}
|
||||
|
||||
double Longitudinal::minimalBinDistance() const
|
||||
{
|
||||
return std::abs(bins_[1]-bins_[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef LONGITUDINALBINS_H
|
||||
#define LONGITUDINALBINS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Discrete {
|
||||
class Longitudinal {
|
||||
public:
|
||||
Longitudinal(
|
||||
double z_min,
|
||||
double z_max,
|
||||
int num_bins);
|
||||
|
||||
Longitudinal(const Longitudinal& l);
|
||||
|
||||
bool changedBin(double z_start, double z_end) const;
|
||||
int findBin(double z) const;
|
||||
std::vector<double> bins() const;
|
||||
double minimalBinDistance() const;
|
||||
|
||||
private:
|
||||
const std::vector<double> bins_;
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* LONGITUDINALBINS_H */
|
||||
@@ -1,82 +0,0 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "LongitudinalBins.h"
|
||||
#include <vector>
|
||||
|
||||
TEST_CASE("Longitudinal Bins", "[LongitudinalBins]"){
|
||||
SECTION("Bins are filled correctly"){
|
||||
int num_bins = 14;
|
||||
const double z_min = 0.;
|
||||
const double z_max = 14.;
|
||||
|
||||
Discrete::Longitudinal longitudinal(z_min, z_max, num_bins);
|
||||
|
||||
std::vector<double> bins = longitudinal.bins();
|
||||
|
||||
REQUIRE(bins.front() == 0.);
|
||||
REQUIRE(bins.back() == 14.);
|
||||
REQUIRE(bins[1] == 1.);
|
||||
}
|
||||
|
||||
SECTION("Bin is calculated correctly"){
|
||||
int num_bins = 14;
|
||||
const double z_min = 0.;
|
||||
const double z_max = 14.;
|
||||
|
||||
Discrete::Longitudinal longitudinal(z_min, z_max, num_bins);
|
||||
|
||||
|
||||
SECTION("in bin"){
|
||||
REQUIRE(longitudinal.findBin(0.5) == 0);
|
||||
REQUIRE(longitudinal.findBin(1.2) == 1);
|
||||
REQUIRE(longitudinal.findBin(13.5) == 13);
|
||||
}
|
||||
SECTION("at bin borders"){
|
||||
REQUIRE(longitudinal.findBin(0.0) == -1);
|
||||
REQUIRE(longitudinal.findBin(1.0) == 0);
|
||||
REQUIRE(longitudinal.findBin(2.0) == 1);
|
||||
REQUIRE(longitudinal.findBin(14.0) == 13);
|
||||
}
|
||||
SECTION("Outside of bins"){
|
||||
REQUIRE(longitudinal.findBin(-0.5) == -1);
|
||||
REQUIRE(longitudinal.findBin(-14.5) == -1);
|
||||
REQUIRE(longitudinal.findBin(14.5) == 14);
|
||||
REQUIRE(longitudinal.findBin(20.3) == 14);
|
||||
}
|
||||
}
|
||||
SECTION("Bin changes are found"){
|
||||
int num_bins = 14;
|
||||
const double z_min = 0.;
|
||||
const double z_max = 14.;
|
||||
|
||||
Discrete::Longitudinal longitudinal(z_min, z_max, num_bins);
|
||||
|
||||
SECTION("Same bin"){
|
||||
REQUIRE(!longitudinal.changedBin(0.5, 0.5));
|
||||
REQUIRE(!longitudinal.changedBin(0.7, 0.5));
|
||||
REQUIRE(!longitudinal.changedBin(0.5, 0.7));
|
||||
REQUIRE(!longitudinal.changedBin(1.5, 1.7));
|
||||
REQUIRE(!longitudinal.changedBin(0.5, 1.0));
|
||||
}
|
||||
|
||||
SECTION("Bin change"){
|
||||
REQUIRE(longitudinal.changedBin(0.5, 1.5));
|
||||
REQUIRE(longitudinal.changedBin(1.5, 0.5));
|
||||
|
||||
REQUIRE(longitudinal.changedBin(0.5, -0.5));
|
||||
REQUIRE(longitudinal.changedBin(13.5, 14.5));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Constructor"){
|
||||
int num_bins = 14;
|
||||
const double z_min = 0.;
|
||||
const double z_max = 14.;
|
||||
|
||||
Discrete::Longitudinal longitudinal(z_min, z_max, num_bins);
|
||||
|
||||
Discrete::Longitudinal copy_longitudinal(longitudinal);
|
||||
REQUIRE(copy_longitudinal.bins()[0] == longitudinal.bins()[0]);
|
||||
REQUIRE(copy_longitudinal.bins()[3] == longitudinal.bins()[3]);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "T2IT2_cx.h"
|
||||
#include "janev_T2IT2_cx.h"
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
T2IT2_CX::T2IT2_CX(
|
||||
Population_Base *T2Population, UniRNG *rngUni) :
|
||||
TI_thermal_binary_Precomputed_Interaction_Base(
|
||||
T2Population, rngUni, 2*mT_eV),
|
||||
kinematics(2*mT_eV, 2*mT_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double T2IT2_CX::get_microSigma_m2(const double &E_eV)
|
||||
{
|
||||
return Janev_T2IT2_CX::get_TCS(E_eV);
|
||||
}
|
||||
|
||||
|
||||
InteractionOut T2IT2_CX::do_Interaction (Particle *interPart)
|
||||
{
|
||||
const vec3 v1_ms = interPart->get_v_ms();
|
||||
const vec3 loc_m = interPart->get_x_m();
|
||||
const vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
const double theta_lab = rngUni->random() * pi;
|
||||
const double phi_lab = rngUni->random() * 2 * pi;
|
||||
const vec3 v_new = kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab);
|
||||
interPart->set_v_ms(v_new);
|
||||
|
||||
// gyro center move
|
||||
const double v_perp_new_squared = v_new(0)*v_new(0) + v_new(1)*v_new(1);
|
||||
const double v_perp_old_squared = v1_ms(0)*v1_ms(0) + v1_ms(1)*v1_ms(1);
|
||||
|
||||
const double v_perp_new = std::sqrt(v_perp_new_squared);
|
||||
|
||||
const double scalar_product_squared =
|
||||
std::pow(v1_ms(0)*v_new(0) + v1_ms(1)*v_new(1),2)
|
||||
/(v_perp_new_squared*v_perp_old_squared);
|
||||
const double sin_theta_half = scalar_product_squared >= 1 ?
|
||||
0 : std::sqrt((1-std::sqrt(scalar_product_squared))/2);
|
||||
|
||||
const double rG_m = v_perp_new*interPart->get_m_eV()/(Katrin_Fields::getMagField_T(loc_m)(2)*c_ms*c_ms);
|
||||
const double gyro_centrum_move_m = 2*rG_m * sin_theta_half;
|
||||
const double phi = rngUni->random() * 2 * pi;
|
||||
const double x_new = loc_m(0) + std::sin(phi)*gyro_centrum_move_m;
|
||||
const double y_new = loc_m(1) + std::cos(phi)*gyro_centrum_move_m;
|
||||
interPart->set_x_m(vec3(x_new, y_new, loc_m(2)));
|
||||
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
+30
-9
@@ -1,17 +1,38 @@
|
||||
//
|
||||
// T2IT2_cx.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 12.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef T2IT2_CX_H
|
||||
#define T2IT2_CX_H
|
||||
#ifndef T2IT2_cx_h
|
||||
#define T2IT2_cx_h
|
||||
|
||||
#include "TI_thermal_binary_base.h"
|
||||
#include "kinematics_base.h"
|
||||
#include "janev_T2IT2_cx.h"
|
||||
|
||||
class T2IT2_CX : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T2IT2_CX(Population_Base *T2Population, UniRNG *rngUni);
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
private:
|
||||
|
||||
class T2IT2_CX : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
public:
|
||||
T2IT2_CX(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 2*mT_eV), kinematics(2*mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_T2IT2_CX::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
#endif /* T2IT2_CX_H */
|
||||
|
||||
inline InteractionOut T2IT2_CX::do_Interaction (Particle *interPart) {
|
||||
vec3 v1_ms = interPart->get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m());
|
||||
double theta_lab = rngUni->random() * pi;
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
interPart->set_v_ms(kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab));
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
|
||||
#endif /* T2IT2_cx_h */
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#include "T2Ie_recombination.h"
|
||||
#include "janev_eT2I_recombination.h"
|
||||
#include "kinematics.h"
|
||||
#include "recombination_counter.h"
|
||||
|
||||
T2Ie_Recombination::T2Ie_Recombination(
|
||||
Population_Base *ePopulation,
|
||||
UniRNG *rngUni) :
|
||||
TI_e_Precomputed_Interaction_Base(
|
||||
ePopulation, rngUni, 2*mT_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double T2Ie_Recombination::get_microSigma_m2(
|
||||
const double &E_eV)
|
||||
{
|
||||
// ion at rest
|
||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
|
||||
InteractionOut T2Ie_Recombination::do_Interaction (
|
||||
Particle *interPart)
|
||||
{
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
const vec3 pos_m = interPart->get_x_m();
|
||||
const double E_eV = calc_E_eV_from_v_ms(
|
||||
Population->roll_v_ms(pos_m), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(pos_m, E_eV);
|
||||
GlobalCounter::num_T2I_recombinations += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,77 @@
|
||||
#ifndef T2IE_RECOMBINATION_H
|
||||
#define T2IE_RECOMBINATION_H
|
||||
//
|
||||
// T2Ie_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef T2Ie_recombination_h
|
||||
#define T2Ie_recombination_h
|
||||
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT2I_recombination.h"
|
||||
|
||||
|
||||
class T2Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T2Ie_Recombination(
|
||||
Population_Base *ePopulation,
|
||||
UniRNG *rngUni);
|
||||
public:
|
||||
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
double twoEam2 = (E_eV + m2_eV) * 2 * m1_eV;
|
||||
double E_kin_incident = twoEam2 / (2 * m2_eV) - m1_eV;
|
||||
if(E_kin_incident == 0.0){
|
||||
std::cout << "ACHTUNG Energie ist 0" << "\n";
|
||||
}
|
||||
//std::cout << "E_kin_incident " << E_kin_incident << "\n";
|
||||
return Janev_eT2I_Recombination::get_TCS(E_kin_incident);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* T2IE_RECOMBINATION_H */
|
||||
inline InteractionOut T2Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
|
||||
std::cout <<interPart->get_species() << " RECO mit " <<Population->get_species()<<"\n";
|
||||
//std::cout << "Energie von teilchen " << interPart->get_E_eV() <<"\n";
|
||||
//std::cout << "sigma von interaction T2+ mit e- " << get_microSigma_m2(interPart->get_E_eV())<<"\n";
|
||||
|
||||
|
||||
//std::cout << "v_ms von pop e- = " << Population->roll_v_ms(interPart->get_x_m())[0]<<"\n";
|
||||
//std::cout << "v_ms von pop e- = " << Population->roll_v_ms(interPart->get_x_m())[0]<<"\n";
|
||||
//double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
//double E_eV = calc_E_eV_from_v_ms_richtig(Population->roll_v_ms(interPart->get_x_m()));
|
||||
double E_eV = Population->roll_v_ms(interPart->get_x_m())(0);
|
||||
//fehler? roll_v_ms gibt eine energie
|
||||
std::cout << "Energie aus e- pop " << E_eV <<"\n";
|
||||
//std::cout << "Ort des interpart = " << interPart->get_x_m()<<"\n";
|
||||
|
||||
//E_eV = 1.0; //damit es mal geht, komischer Fehler
|
||||
|
||||
double E_min_eV = 1e-7;
|
||||
double E_max_eV = 2e4;
|
||||
int number_E_bins = 50;
|
||||
Log_Scale E_scale;
|
||||
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
|
||||
int Ee_bin = E_scale.calc_index(E_eV);
|
||||
std::cout<<"Ee_bin = " << Ee_bin<<"\n";
|
||||
//std::cout << "E_eV = " << E_eV<<"\n";
|
||||
Bins loc_bin = Population->get_loc_bin(interPart->get_x_m());
|
||||
|
||||
//std::cout<<"E aus roll v = "<<E_eV<<"\n";
|
||||
double n1 = Population->get_density_m3(Ee_bin, loc_bin); //nur zum schauen
|
||||
//std::cout<<"Population vor Recombination = "<<n1<<"\n";
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
double n2 = Population->get_density_m3(Ee_bin, loc_bin); //nur zum schauen
|
||||
//std::cout<<"Population nach Recombination = "<<n2<<"\n";
|
||||
//std::cout<<"T2+ wurde gelöscht"<<"\n";
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif /* T2Ie_recombination_h */
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "T3IT2_elastic.h"
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
|
||||
T3IT2_Elastic::T3IT2_Elastic(
|
||||
Population_Base *T2Population,
|
||||
UniRNG *rngUni)
|
||||
: TI_thermal_binary_Precomputed_Interaction_Base(
|
||||
T2Population, rngUni, 3*mT_eV),
|
||||
kinematics(3*mT_eV, 2*mT_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double T3IT2_Elastic::get_microSigma_m2(const double &E_eV)
|
||||
{
|
||||
return tcs_gen.get_TCS(E_eV);
|
||||
}
|
||||
|
||||
InteractionOut T3IT2_Elastic::do_Interaction (Particle *interPart)
|
||||
{
|
||||
const vec3 v1_ms = interPart->get_v_ms();
|
||||
const vec3 loc_m = interPart->get_x_m();
|
||||
const vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
const double theta_lab = rngUni->random() * pi;
|
||||
const double phi_lab = rngUni->random() * 2 * pi;
|
||||
const vec3 v_new = kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab);
|
||||
interPart->set_v_ms(v_new);
|
||||
|
||||
// gyro center move
|
||||
|
||||
const double v_perp_new_squared = v_new(0)*v_new(0) + v_new(1)*v_new(1);
|
||||
const double v_perp_old_squared = v1_ms(0)*v1_ms(0) + v1_ms(1)*v1_ms(1);
|
||||
|
||||
const double v_perp_new = std::sqrt(v_perp_new_squared);
|
||||
|
||||
const double scalar_product_squared =
|
||||
std::pow(v1_ms(0)*v_new(0) + v1_ms(1)*v_new(1),2)
|
||||
/(v_perp_new_squared*v_perp_old_squared); // = cos(x)^2
|
||||
const double sin_theta_half = scalar_product_squared >= 1 ?
|
||||
0 : std::sqrt((1-std::sqrt(scalar_product_squared))/2);
|
||||
|
||||
const double rG_m = v_perp_new*interPart->get_m_eV()/(Katrin_Fields::getMagField_T(loc_m)(2)*c_ms*c_ms);
|
||||
const double gyro_centrum_move_m = 2*rG_m * sin_theta_half;
|
||||
const double phi = rngUni->random() * 2 * pi;
|
||||
const double x_new = loc_m(0) + std::sin(phi)*gyro_centrum_move_m;
|
||||
const double y_new = loc_m(1) + std::cos(phi)*gyro_centrum_move_m;
|
||||
interPart->set_x_m(vec3(x_new, y_new, loc_m(2)));
|
||||
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
//
|
||||
// T3IT2_elastic.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef T3IT2_elastic_h
|
||||
#define T3IT2_elastic_h
|
||||
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "tabata_T3IT2_elastic.h"
|
||||
#include "kinematics_base.h"
|
||||
|
||||
|
||||
class T3IT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_T3IT2_Elastic tcs_gen;
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
T3IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni);
|
||||
public:
|
||||
T3IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 3*mT_eV), kinematics(3*mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_gen.get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut T3IT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
vec3 v1_ms = interPart->get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m());
|
||||
double theta_lab = rngUni->random() * pi;
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
interPart->set_v_ms(kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab));
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
#endif /* T3IT2_elastic_h */
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "T3Ie_recombination.h"
|
||||
#include "janev_eT3I_recombination.h"
|
||||
#include "kinematics.h"
|
||||
#include "recombination_counter.h"
|
||||
|
||||
T3Ie_Recombination::T3Ie_Recombination(
|
||||
Population_Base *ePopulation,
|
||||
UniRNG *rngUni) :
|
||||
TI_e_Precomputed_Interaction_Base(
|
||||
ePopulation, rngUni, 3*mT_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double T3Ie_Recombination::get_microSigma_m2(
|
||||
const double &E_eV)
|
||||
{
|
||||
// ion at rest
|
||||
return Janev_eT3I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
|
||||
InteractionOut T3Ie_Recombination::do_Interaction (
|
||||
Particle *interPart)
|
||||
{
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
const vec3 pos_m = interPart->get_x_m();
|
||||
double E_eV = calc_E_eV_from_v_ms(
|
||||
Population->roll_v_ms(pos_m), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(pos_m, E_eV);
|
||||
GlobalCounter::num_T3I_recombinations += 1;
|
||||
return res;
|
||||
}
|
||||
@@ -1,17 +1,39 @@
|
||||
//
|
||||
// T3Ie_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 29.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef T3Ie_recombination_h
|
||||
#define T3Ie_recombination_h
|
||||
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
|
||||
|
||||
class T3Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||
public:
|
||||
T3Ie_Recombination(
|
||||
Population_Base *ePopulation,
|
||||
UniRNG *rngUni);
|
||||
public:
|
||||
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 3*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
protected:
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT3I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
};
|
||||
|
||||
inline InteractionOut T3Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
double E_eV = calc_E_eV_from_v_ms(Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif /* T3Ie_recombination_h */
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "TIT2_elastic.h"
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
|
||||
TIT2_Elastic::TIT2_Elastic(
|
||||
Population_Base *T2Population,
|
||||
UniRNG *rngUni)
|
||||
: TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, mT_eV),
|
||||
kinematics(mT_eV, 2*mT_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double TIT2_Elastic::get_microSigma_m2(const double &E_eV)
|
||||
{
|
||||
return tcs_gen.get_TCS(E_eV);
|
||||
}
|
||||
|
||||
InteractionOut TIT2_Elastic::do_Interaction (Particle *interPart)
|
||||
{
|
||||
const vec3 v1_ms = interPart->get_v_ms();
|
||||
const vec3 loc_m = interPart->get_x_m();
|
||||
const vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
const double theta_lab = rngUni->random() * pi;
|
||||
const double phi_lab = rngUni->random() * 2 * pi;
|
||||
const vec3 v_new = kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab);
|
||||
interPart->set_v_ms(v_new);
|
||||
|
||||
// gyro center move
|
||||
const double v_perp_new_squared = v_new(0)*v_new(0) + v_new(1)*v_new(1);
|
||||
const double v_perp_old_squared = v1_ms(0)*v1_ms(0) + v1_ms(1)*v1_ms(1);
|
||||
|
||||
const double v_perp_new = std::sqrt(v_perp_new_squared);
|
||||
|
||||
const double scalar_product_squared =
|
||||
std::pow(v1_ms(0)*v_new(0) + v1_ms(1)*v_new(1),2)
|
||||
/(v_perp_new_squared*v_perp_old_squared);
|
||||
const double sin_theta = scalar_product_squared >= 1 ?
|
||||
0 : std::sqrt(1-scalar_product_squared); // sin(arcos(x)) = sqrt(1-x^2)
|
||||
|
||||
const double rG_m = v_perp_new*interPart->get_m_eV()/(Katrin_Fields::getMagField_T(loc_m)(2)*c_ms*c_ms);
|
||||
const double gyro_centrum_move_m = 2*rG_m * sin_theta;
|
||||
const double phi = rngUni->random() * 2 * pi;
|
||||
const double x_new = loc_m(0) + std::sin(phi)*gyro_centrum_move_m;
|
||||
const double y_new = loc_m(1) + std::cos(phi)*gyro_centrum_move_m;
|
||||
interPart->set_x_m(vec3(x_new, y_new, loc_m(2)));
|
||||
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
+22
-3
@@ -1,20 +1,39 @@
|
||||
//
|
||||
// TIT2_elastic.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TIT2_elastic_h
|
||||
#define TIT2_elastic_h
|
||||
|
||||
#include "TI_thermal_binary_base.h"
|
||||
|
||||
#include "tabata_TIT2_elastic.h"
|
||||
#include "kinematics_base.h"
|
||||
|
||||
|
||||
class TIT2_Elastic : public TI_thermal_binary_Precomputed_Interaction_Base {
|
||||
Tabata_TIT2_Elastic tcs_gen;
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
TIT2_Elastic(Population_Base *T2Population, UniRNG *rngUni);
|
||||
TIT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, mT_eV), kinematics(mT_eV, 2*mT_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
};
|
||||
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_gen.get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut TIT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
vec3 v1_ms = interPart->get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m());
|
||||
double theta_lab = rngUni->random() * pi;
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
interPart->set_v_ms(kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab));
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
#endif /* TIT2_elastic_h */
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#include "TI_kinetic_base.h"
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
TI_e_Interaction_Base::TI_e_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni, double m_eV) :
|
||||
Interaction_Base(Population, rngUni)
|
||||
{
|
||||
m1_eV = Population->get_m_eV();
|
||||
m2_eV = m_eV;
|
||||
|
||||
num_Ee_bins = Population->get_number_E_bins();
|
||||
if (num_Ee_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when expected kinetic.");
|
||||
}
|
||||
ve_mids = new double[num_Ee_bins];
|
||||
Ee_mids = new double[num_Ee_bins];
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
Ee_mids[Ee_bin] = Population->get_E_bin_mid_eV(Ee_bin);
|
||||
ve_mids[Ee_bin] = calc_v_ms_from_E_eV(Ee_mids[Ee_bin], m1_eV);
|
||||
}
|
||||
}
|
||||
|
||||
double TI_e_Interaction_Base::get_macro_sigma_m(
|
||||
const Particle &interPart)
|
||||
{
|
||||
return calc_macro_sigma_m(
|
||||
interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
|
||||
double TI_e_Interaction_Base::calc_macro_sigma_m(
|
||||
const double &E_eV, const vec3 &loc_m)
|
||||
{
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin)
|
||||
* Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
double TI_e_Interaction_Base::calc_microSigma_m2(
|
||||
const double &E2_eV, const int &Ee_bin)
|
||||
{
|
||||
//return get_microSigma_m2(Ee_mids[Ee_bin]); // No Integration... Only e- energy
|
||||
double v1_ms = ve_mids[Ee_bin]; // electron velocity
|
||||
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV); // ion velocity
|
||||
|
||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||
} else {
|
||||
auto integrand = [&](double theta) {
|
||||
const double E_kin_incident =
|
||||
kineticEnergyIncidentRelativistic(v1_ms, v2_ms, m1_eV, m2_eV, theta);
|
||||
// frame where ion (m2_eV) is at rest
|
||||
return get_microSigma_m2(E_kin_incident);
|
||||
};
|
||||
return integrate(integrand, pi/8., 7*pi/8., INT_N, simpson())/(6./8.*pi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TI_e_Precomputed_Interaction_Base::TI_e_Precomputed_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni,
|
||||
double m_eV) :
|
||||
TI_e_Interaction_Base(Population, rngUni, m_eV),
|
||||
E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N)
|
||||
{
|
||||
precomputed_values = new double *[E_scale.get_number_bins()];
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
precomputed_values[EI_bin] = new double[num_Ee_bins];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TI_e_Precomputed_Interaction_Base::calc_values()
|
||||
{
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
precomputed_values[EI_bin][Ee_bin] = calc_microSigma_m2(E_scale.get_bin_mid(EI_bin), Ee_bin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(
|
||||
const Particle &interPart)
|
||||
{
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double E_eV = interPart.get_E_eV();
|
||||
|
||||
if (E_scale.in_scale(E_eV)) {
|
||||
return lookup_macro_sigma_m(E_eV, loc_m);
|
||||
} else {
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
}
|
||||
|
||||
double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(
|
||||
const double &E_eV, const vec3 &loc_m)
|
||||
{
|
||||
int EI_bin = E_scale.calc_index(E_eV);
|
||||
double *microSigmas = precomputed_values[EI_bin];
|
||||
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
macro_sigma_m += microSigmas[Ee_bin]
|
||||
* Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
+261
-25
@@ -1,48 +1,284 @@
|
||||
//
|
||||
// TI_kinetic_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TI_kinetic_base_h
|
||||
#define TI_kinetic_base_h
|
||||
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
// Interactions of ions with kinetic e Populations
|
||||
class TI_e_Interaction_Base : public Interaction_Base {
|
||||
public:
|
||||
TI_e_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni,
|
||||
double m_eV);
|
||||
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
|
||||
protected:
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
double calc_microSigma_m2(const double &E1_eV, const int &Ee_bin);
|
||||
|
||||
class TI_e_Interaction_Base : public Interaction_Base { // Interactions of ions with kinetic e Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle for CS measurement : e-
|
||||
double m2_eV; // energy of massic initial particle : TI
|
||||
int num_Ee_bins; // number of Ee_bins in Populations
|
||||
double *Ee_mids; // values for energy mids of Ee_bins in Populations
|
||||
double *ve_mids; // corresponding v_values
|
||||
|
||||
public:
|
||||
TI_e_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
m1_eV = Population->get_m_eV();
|
||||
m2_eV = m_eV;
|
||||
|
||||
num_Ee_bins = Population->get_number_E_bins();
|
||||
if (num_Ee_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when expected kinetic.");
|
||||
}
|
||||
ve_mids = new double[num_Ee_bins];
|
||||
Ee_mids = new double[num_Ee_bins];
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
Ee_mids[Ee_bin] = Population->get_E_bin_mid_eV(Ee_bin);
|
||||
ve_mids[Ee_bin] = calc_v_ms_from_E_eV(Ee_mids[Ee_bin], m1_eV);
|
||||
}
|
||||
}
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
|
||||
private:
|
||||
protected:
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
double calc_microSigma_m2(const double &E1_eV, const int &Ee_bin);
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
// Precompute Interactions of ions with kinetic e Populations
|
||||
class TI_e_Precomputed_Interaction_Base : public TI_e_Interaction_Base {
|
||||
public:
|
||||
TI_e_Precomputed_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni,
|
||||
double m_eV);
|
||||
inline double TI_e_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||
}
|
||||
|
||||
double gammafaktor(double v) {
|
||||
return 1/sqrt(1-pow(v/c_ms, 2));
|
||||
}
|
||||
|
||||
|
||||
inline double TI_e_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
|
||||
std::cout << "Energie von T2+ in calc macro sigma also in mirco sigma: " << E_eV << "\n";
|
||||
|
||||
//get_microSigma_m2(0.0); gucken
|
||||
|
||||
double macro_sigma_m = 0;
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
if(Population->get_density_m3(Ee_bin, loc_bins) > 0 ){
|
||||
|
||||
double v1_ms = ve_mids[Ee_bin]; //ist nährungsweise die richitge geschwindigkeit für elektorn
|
||||
double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV); //ist die richtige geschwindigkeit für ion
|
||||
std::cout << "Energie von elektron hier: " << Ee_mids[Ee_bin] << "\n";
|
||||
std::cout << "v von elektron hier: " << v1_ms << "\n";
|
||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||
//std::cout << "machen wir das?" << "\n";
|
||||
//std::cout << Ee_mids[Ee_bin] << "\n";
|
||||
//std::cout << get_microSigma_m2(Ee_mids[Ee_bin]) << "\n";
|
||||
//std::cout << "wird das gemacht? " << "\n";
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
//neu
|
||||
|
||||
double v1_ms = ve_mids[Ee_bin];
|
||||
double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||
//std::cout << "v1 " << v1_ms <<"\n";
|
||||
//std::cout << "v2 " << v2_ms <<"\n";
|
||||
auto integrand = [&](double theta) {
|
||||
|
||||
|
||||
double p1 = gammafaktor(v2_ms) * m2_eV * v2_ms / c_ms;
|
||||
double p2 = gammafaktor(v1_ms) * m1_eV * v1_ms / c_ms;
|
||||
|
||||
double E1 = sqrt(pow(m2_eV, 2) + pow(p1, 2)); // so ist es wie im python skyript
|
||||
double E2 = sqrt(pow(m1_eV, 2) + pow(p2, 2)); // wie im skrpt
|
||||
|
||||
|
||||
//std::cout << "E1 " << E1 << "\n"; // ion
|
||||
//std::cout << "E2 " << E2 << "\n"; // elektron
|
||||
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||
//std::cout << "p1 " << p1 << "\n"; // p von ion
|
||||
//std::cout << "p2 " << p2 << "\n"; // p von elektorn
|
||||
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||
|
||||
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||
//std::cout << "s " << s << "\n";
|
||||
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||
//std::cout << "theta " << theta << "\n";
|
||||
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||
double E_incident = twoEam2/(2*m1_eV);
|
||||
double E_kin_incident = E_incident - m2_eV;
|
||||
|
||||
|
||||
//double E_eV = m2_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||
|
||||
//std::cout << "Energie für microsigma berechnung " << E_eV <<"\n";
|
||||
return get_microSigma_m2(E_kin_incident);
|
||||
};
|
||||
|
||||
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||
|
||||
|
||||
/*
|
||||
//alt
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV);
|
||||
};
|
||||
|
||||
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||
*/
|
||||
}
|
||||
|
||||
std::cout << "sigma einfach eingeseitzt " << get_microSigma_m2(E_eV) << "\n";
|
||||
std::cout << "monte carlo micro sigma " << calc_microSigma_m2(E_eV, Ee_bin) << "\n";
|
||||
std::cout << "Monte carlo macro sigma " << macro_sigma_m << "\n";
|
||||
|
||||
|
||||
//std::cout << "micro sigma in calcmacrosigma in ohne precomputed" << calc_microSigma_m2(E_eV, Ee_bin) <<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline double TI_e_Interaction_Base::calc_microSigma_m2(const double &E2_eV, const int &Ee_bin) {
|
||||
//return get_microSigma_m2(Ee_mids[Ee_bin]); // No Integration... Only e- energy
|
||||
double v1_ms = ve_mids[Ee_bin]; //ist nährungsweise die richitge geschwindigkeit für elektorn
|
||||
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV); //ist die richtige geschwindigkeit für ion
|
||||
|
||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||
//std::cout << "machen wir das?" << "\n";
|
||||
//std::cout << Ee_mids[Ee_bin] << "\n";
|
||||
//std::cout << get_microSigma_m2(Ee_mids[Ee_bin]) << "\n";
|
||||
//std::cout << "wird das gemacht? " << "\n";
|
||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
//neu
|
||||
|
||||
double v1_ms = ve_mids[Ee_bin];
|
||||
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV);
|
||||
//std::cout << "v1 " << v1_ms <<"\n";
|
||||
//std::cout << "v2 " << v2_ms <<"\n";
|
||||
auto integrand = [&](double theta) {
|
||||
|
||||
|
||||
double p1 = gammafaktor(v2_ms) * m2_eV * v2_ms / c_ms;
|
||||
double p2 = gammafaktor(v1_ms) * m1_eV * v1_ms / c_ms;
|
||||
|
||||
double E1 = sqrt(pow(m2_eV, 2) + pow(p1, 2)); // so ist es wie im python skyript
|
||||
double E2 = sqrt(pow(m1_eV, 2) + pow(p2, 2)); // wie im skrpt
|
||||
|
||||
|
||||
//std::cout << "E1 " << E1 << "\n"; // ion
|
||||
//std::cout << "E2 " << E2 << "\n"; // elektron
|
||||
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||
//std::cout << "p1 " << p1 << "\n"; // p von ion
|
||||
//std::cout << "p2 " << p2 << "\n"; // p von elektorn
|
||||
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||
|
||||
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||
//std::cout << "s " << s << "\n";
|
||||
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||
//std::cout << "theta " << theta << "\n";
|
||||
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||
double E_incident = twoEam2/(2*m1_eV);
|
||||
double E_kin_incident = E_incident - m2_eV;
|
||||
|
||||
|
||||
//double E_eV = m2_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||
|
||||
//std::cout << "Energie für microsigma berechnung " << E_eV <<"\n";
|
||||
return get_microSigma_m2(E_kin_incident);
|
||||
};
|
||||
|
||||
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
return integralergebnis;
|
||||
//std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//alt
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class TI_e_Precomputed_Interaction_Base : public TI_e_Interaction_Base { // Precompute Interactions of ions with kinetic e Populations
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double **precomputed_values;
|
||||
|
||||
public:
|
||||
TI_e_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_e_Interaction_Base(Population, rngUni, m_eV), E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N) {
|
||||
precomputed_values = new double *[E_scale.get_number_bins()];
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
precomputed_values[EI_bin] = new double[num_Ee_bins];
|
||||
}
|
||||
}
|
||||
void calc_values();
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
|
||||
private:
|
||||
private:
|
||||
double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double **precomputed_values;
|
||||
};
|
||||
|
||||
inline void TI_e_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
precomputed_values[EI_bin][Ee_bin] = calc_microSigma_m2(E_scale.get_bin_mid(EI_bin), Ee_bin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double E_eV = interPart.get_E_eV();
|
||||
|
||||
if (E_scale.in_scale(E_eV)) {
|
||||
return lookup_macro_sigma_m(E_eV, loc_m);
|
||||
} else {
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
}
|
||||
|
||||
inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
int EI_bin = E_scale.calc_index(E_eV);
|
||||
double *microSigmas = precomputed_values[EI_bin];
|
||||
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
|
||||
#endif /* TI_kinetic_base_h */
|
||||
|
||||
@@ -52,7 +52,7 @@ inline double TI_thermal_binary_Interaction_Base::calc_microSigma_m2(const doubl
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||
};
|
||||
return double_simpson_integrate(integrand, 0., 3*v_therm, pi/8., 7.*pi/8., INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||
/* // Integration over theta
|
||||
auto integrand = [&](double theta) {
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2);
|
||||
|
||||
@@ -51,7 +51,7 @@ inline double TI_thermal_tenary_Interaction_Base::calc_microSigma_divbyn_m2(cons
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2);
|
||||
return get_microSigma_m2(E_eV);
|
||||
};
|
||||
return integrate(integrand, pi/8., 7.*pi/8., INT_N, simpson())/pi;
|
||||
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
}
|
||||
|
||||
class TI_thermal_tenary_Precomputed_Interaction_Base : public TI_thermal_tenary_Interaction_Base { // Precomputed Interactions of electrons with thermal Populations
|
||||
|
||||
@@ -41,7 +41,7 @@ void ASCI_Logger::set_zLogValues() {
|
||||
zLogValues.clear();
|
||||
if (logging) {
|
||||
double start_m = z_RW_m;
|
||||
double length_m = z_DPS_m - start_m;
|
||||
double length_m = z_WGTS_end_m - start_m;
|
||||
double stepLength_m = length_m/(numberZBins-1);
|
||||
double z_m;
|
||||
for (int i = 0;i<numberZBins;i++) {
|
||||
|
||||
+10
-20
@@ -39,27 +39,19 @@ constant BetaDecayConst = 1.2072343416696292e-47;
|
||||
constant TritiumDecayEndpoint_eV = 18.574e3;
|
||||
|
||||
// WGTS
|
||||
constant z_RW_m = -3;
|
||||
constant z_WGTS_start_m = 0;
|
||||
constant z_WGTS_end_m = 10;
|
||||
constant z_DPS_end_m = 13;
|
||||
constant r_WGTS_m = 0.045;
|
||||
constant z_RW_m = 0;
|
||||
constant z_rear_pp1 = 1.43;
|
||||
constant z_rear_pp2 = 3;
|
||||
constant z_front_pp1 = 13;
|
||||
constant z_front_pp2 = 14.57;
|
||||
constant z_DPS_m = 16;
|
||||
constant z_inlet_m = 8;
|
||||
constant l_WGTS_m = z_DPS_m - z_RW_m;
|
||||
|
||||
constant l_WGTS_m = z_WGTS_end_m - z_WGTS_start_m;
|
||||
constant z_WGTS_mid_m = (z_WGTS_end_m+z_WGTS_start_m)/2;
|
||||
|
||||
// from Kuckert:2018aa
|
||||
constant reduction_RW = 5e-4;
|
||||
constant reduction_rear_pp1 = 0.002;
|
||||
constant reduction_rear_pp2 = 0.02;
|
||||
constant reduction_inlet = 1.0;
|
||||
constant reduction_front_pp1 = 0.02;
|
||||
constant reduction_front_pp2 = 0.002;
|
||||
constant reduction_DPS = 5e-4;
|
||||
|
||||
|
||||
constant reduction_WGTS_front = 0.034;
|
||||
constant reduction_WGTS_rear = 0.033;
|
||||
constant reduction_tot_front = 5e-4;
|
||||
constant reduction_tot_rear = 5e-4;
|
||||
|
||||
// For interaction integration
|
||||
const int INT_N = load_parameter("INT_N"); // Number of points for theta integration
|
||||
@@ -67,6 +59,4 @@ const double INT_PRE_START = load_parameter("INT_PRE_START"); // Start energy fo
|
||||
const double INT_PRE_END = load_parameter("INT_PRE_END"); // End energy for precomputed cross sections
|
||||
const int INT_PRE_N = load_parameter("INT_PRE_N"); //Number of points for precomputed cross sections
|
||||
|
||||
const int long_move_num_bins = load_parameter("LONG_MOVE_NUM_BINS");
|
||||
|
||||
#endif /* constants_h */
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "CurrentHistogram.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
TEST_CASE("Current Histogram", "[CurrentHistogram]"){
|
||||
|
||||
|
||||
SECTION("Bins are calculated correctly"){
|
||||
int decade_min = -1;
|
||||
int decade_max = 0;
|
||||
int num_bin_z = 2;
|
||||
int num_bin_r = 2;
|
||||
double z_min = -3;
|
||||
double z_max = 10;
|
||||
double r_max = 0.045;
|
||||
CurrentHistogram hist(
|
||||
num_bin_z, z_min, z_max,
|
||||
num_bin_r, r_max,
|
||||
decade_min, decade_max);
|
||||
SECTION("Radial bins outside"){
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(1., 0., 0.))
|
||||
== 2);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(-1., 0., 0.))
|
||||
== 2);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0., 1., 0.))
|
||||
== 2);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(-0., -1., 0.))
|
||||
== 2);
|
||||
}
|
||||
|
||||
SECTION("Radial bins inside"){
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0.04, 0., 0.))
|
||||
== 1);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(-0.04, 0., 0.))
|
||||
== 1);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0., 0.04, 0.))
|
||||
== 1);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0., -0.04, 0.))
|
||||
== 1);
|
||||
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0.02, 0., 0.))
|
||||
== 0);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(-0.02, 0., 0.))
|
||||
== 0);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0., 0.02, 0.))
|
||||
== 0);
|
||||
REQUIRE(hist.findRadialBin(
|
||||
blitz::TinyVector<double,3>(0., -0.02, 0.))
|
||||
== 0);
|
||||
}
|
||||
|
||||
SECTION("Longitudinal bins outside"){
|
||||
REQUIRE(hist.findLongitudinalBin(
|
||||
blitz::TinyVector<double,3>(0., 0., 13.))
|
||||
== 2);
|
||||
REQUIRE(hist.findLongitudinalBin(
|
||||
blitz::TinyVector<double,3>(0., 0., -4.))
|
||||
== -1);
|
||||
}
|
||||
|
||||
SECTION("Longitudinal bins inside"){
|
||||
REQUIRE(hist.findLongitudinalBin(
|
||||
blitz::TinyVector<double,3>(0.04, 0., -2.9))
|
||||
== 0);
|
||||
REQUIRE(hist.findLongitudinalBin(
|
||||
blitz::TinyVector<double,3>(-0.04, 0., 9.5))
|
||||
== 1);
|
||||
}
|
||||
|
||||
SECTION("Energy bins outside"){
|
||||
REQUIRE(hist.findEnergyBin(1E-2) == -1);
|
||||
REQUIRE(hist.findEnergyBin(1E1) == 9);
|
||||
}
|
||||
|
||||
SECTION("Energy bins at boundary"){
|
||||
REQUIRE(hist.findEnergyBin(1E-1) == 0);
|
||||
REQUIRE(hist.findEnergyBin(0.99999999999) == 8);
|
||||
}
|
||||
|
||||
SECTION("Energy bins inside"){
|
||||
REQUIRE(hist.findEnergyBin(1.1E-1) == 0);
|
||||
REQUIRE(hist.findEnergyBin(2.2E-1) == 1);
|
||||
REQUIRE(hist.findEnergyBin(3.9E-1) == 2);
|
||||
REQUIRE(hist.findEnergyBin(8.5E-1) == 7);
|
||||
REQUIRE(hist.findEnergyBin(9.5E-1) == 8);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Correct value in array is filled"){
|
||||
int decade_min = -5;
|
||||
int decade_max = -4;
|
||||
int num_bin_z = 2;
|
||||
int num_bin_r = 2;
|
||||
double z_min = -3;
|
||||
double z_max = 10;
|
||||
double r_max = 0.045;
|
||||
|
||||
CurrentHistogram hist(
|
||||
num_bin_z, z_min, z_max,
|
||||
num_bin_r, r_max,
|
||||
decade_min, decade_max);
|
||||
|
||||
hist.fill(blitz::TinyVector<double,3>(0.04, 0., 0.5), 3.1E-5);
|
||||
hist.fill(blitz::TinyVector<double,3>(0.02, 0., 9.5), 4.1E-5);
|
||||
REQUIRE(hist.hist_data_(1,0,2) == 1);
|
||||
REQUIRE(hist.hist_data_(0,1,3) == 1);
|
||||
}
|
||||
SECTION("Bin Borders"){
|
||||
int decade_min = -5;
|
||||
int decade_max = -3;
|
||||
int num_bin_z = 2;
|
||||
int num_bin_r = 2;
|
||||
double z_min = -3;
|
||||
double z_max = 10;
|
||||
double r_max = 0.045;
|
||||
|
||||
CurrentHistogram hist(
|
||||
num_bin_z, z_min, z_max,
|
||||
num_bin_r, r_max,
|
||||
decade_min, decade_max);
|
||||
|
||||
auto e_bins = hist.binBordersE();
|
||||
REQUIRE(e_bins[0] == Approx(std::pow(10,decade_min)));
|
||||
REQUIRE(e_bins.back() == Approx(std::pow(10,decade_max)));
|
||||
|
||||
auto r_bins = hist.binBordersR();
|
||||
REQUIRE(r_bins[0] == 0);
|
||||
REQUIRE(r_bins[1] == r_max/num_bin_r);
|
||||
REQUIRE(r_bins.back() == r_max);
|
||||
|
||||
auto z_bins = hist.binBordersZ();
|
||||
REQUIRE(z_bins[0] == z_min);
|
||||
REQUIRE(z_bins[1] == z_min + (z_max-z_min)/num_bin_z);
|
||||
REQUIRE(z_bins.back() == z_max);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "CurrentHistogram.h"
|
||||
#include "CurrentLogger.h"
|
||||
#include "particle.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
TEST_CASE("Current Logger", "[CurrentLogger]"){
|
||||
|
||||
|
||||
SECTION("Radial bins are filled"){
|
||||
int numberZBins = 14;
|
||||
int numberRBins = 5;
|
||||
int energy_decade_min = -5;
|
||||
int energy_decade_max = 4;
|
||||
|
||||
|
||||
CurrentLogger logger(
|
||||
electron,
|
||||
numberZBins, z_RW_m, z_DPS_m,
|
||||
numberRBins, r_WGTS_m,
|
||||
energy_decade_min, energy_decade_max,
|
||||
"/home/jonas/new_workspace/Coding/Output/KARL/test/output");
|
||||
|
||||
SECTION("Radial bins outside"){
|
||||
double m_eV = 511E3;
|
||||
double charge_e = -1*e_C;
|
||||
vec3 v_ms(0., 0., 1.);
|
||||
double Id = 1.;
|
||||
double Pid = 1.;
|
||||
|
||||
vec3 old_loc_m(0.04, 0., -3.);
|
||||
vec3 loc_m(0.04,0.0,-2.5);
|
||||
Particle particle(m_eV, charge_e, loc_m, v_ms, Id, Pid, electron);
|
||||
|
||||
logger.log(particle, old_loc_m);
|
||||
|
||||
logger.output();
|
||||
|
||||
REQUIRE(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Code", "[Code]"){
|
||||
|
||||
}
|
||||
Binary file not shown.
+1000001
File diff suppressed because it is too large
Load Diff
@@ -1,70 +0,0 @@
|
||||
# Parametertemplate for mcelectro
|
||||
#
|
||||
# File ignores Lines starting with '#' or empty
|
||||
# '=' ';' ',' and whitespaces are delimiters
|
||||
# First value is Parameter Name
|
||||
# Second value is Parameter Value
|
||||
# Further Symbols are ignored
|
||||
|
||||
|
||||
### Simulation Parameters
|
||||
SEED = 1337 Seed for PRNG
|
||||
POP_DECAYS = 0 Number of decays for initial density calculation
|
||||
POP_STEP = 1 Step width for initial density calculation
|
||||
DECAYS = 1E6 Target number of beta decays
|
||||
STEP = 2 Step width of beta decays before density synchronisation
|
||||
LOG_BARS = 33 Number of logging barriers for Logging
|
||||
PROPAGATION = 0 0 = Drift approximation, 1 = Boris Push
|
||||
BORIS_T = 1e-10 Resolution for BorisPush
|
||||
E_FIELD = 1 0 = off, 1 = load data
|
||||
|
||||
### Katrin
|
||||
# Properties
|
||||
BFIELD = 2.5 B_z in T
|
||||
T2_MAXDENS = 6.337599e20 Peak Density at z=5m in m^-3
|
||||
TEMP = 80 Temperatur of WGTS in K
|
||||
T2_VELO = -1 -1 = data from Kuckert, else = v_z in m/s speed
|
||||
|
||||
### Injection
|
||||
INJECTION = 0 0 = Fermi, 1 = Delta, 2 = MB
|
||||
INJ_E = 1 Injection energy in eV. Ignored for Fermi, for MB using E=kb*T
|
||||
INJ_TI = 2 0 = No Ion, 1 = Delta, 2 = MB
|
||||
INJ_E_TI = 0.0068973904 Injection energy in eV. Ignored for Fermi, for MB using E=kb*T
|
||||
|
||||
|
||||
### Termination
|
||||
TERM_E = 1e-8 Threshold energy for termination
|
||||
TERM_DI_E = 1e-8 Threshold energy for termination of electrons at z = 10
|
||||
TERM_MAX = 1e8 Maximum Inteaction before termination
|
||||
|
||||
### Interactions: 0 = Omitted, >1 = Activated
|
||||
eT2_ELA = 1
|
||||
INT_ELA_DIR = 0 0 = elastic data, 1=4pi, 2=0pi
|
||||
|
||||
eT2_ION = 1 1 = Janev (3channels), 2 = BED-Theory
|
||||
eT2_ROT 2 0 = off, 1 = not implemented, 2 = YOON
|
||||
eT2_VIB 2 0 = off, 1 = Janev, 2 = YOON
|
||||
eT2_EL = 1 0 = off, 1 = Janev, 2 = YOON
|
||||
e_REC = 1
|
||||
|
||||
INT_N = 100 Number of points for theta integration
|
||||
INT_PRE_START = 1e-7 Start energy for precomputed cross sections
|
||||
INT_PRE_END = 1e0 End energy for precomputed cross sections
|
||||
INT_PRE_N 9e3 Number of points for precomputed cross sections
|
||||
|
||||
### Properties of runtime density containers
|
||||
POP_N_R = 15 Number of bins in r
|
||||
POP_N_PHI = 1 Number of bins in phi
|
||||
POP_N_Z = 32 Number of bins in z
|
||||
POP_N_E = 100 Number of bins in E for kinetic bins
|
||||
POP_E_START = 1e-7 Minimum energy bin for kinetic bins
|
||||
POP_E_END = 2e4 Maximum energy bin for kinetic bins
|
||||
|
||||
### Properties of new Current Logging
|
||||
LOG_BARS_ENERGY_DECADE_MIN = -5
|
||||
LOG_BARS_ENERGY_DECADE_MAX = 4
|
||||
LOG_BARS_R = 15
|
||||
|
||||
|
||||
### Properties of longitudinal step size of movement
|
||||
LONG_MOVE_NUM_BINS = 32
|
||||
@@ -10,7 +10,7 @@
|
||||
<ElectricField>
|
||||
<Filename>/home/jonas/new_workspace/Coding/Output/KARL/ElectricField/E_field.h5</Filename>
|
||||
<Radius>0.045</Radius>
|
||||
<Height>16.</Height>
|
||||
<Height>13.</Height>
|
||||
|
||||
</ElectricField>
|
||||
</KatrinFields>
|
||||
@@ -1,105 +0,0 @@
|
||||
#include "drift_base.h"
|
||||
#include "katrin_fields.hpp"
|
||||
#include <cmath>
|
||||
#include "constants.h"
|
||||
|
||||
const double minimalZMovementDistance = 0.005;
|
||||
|
||||
Drift_Base::Drift_Base(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population) :
|
||||
Mover_Base(this_species, Logger, Population),
|
||||
longitudinal_bins(Discrete::Longitudinal(z_RW_m, z_DPS_m, long_move_num_bins))
|
||||
{};
|
||||
|
||||
|
||||
bool leftSimulation(const vec3& position)
|
||||
{
|
||||
return (position(2) <= z_RW_m)
|
||||
|| (position(2) >= z_DPS_m)
|
||||
|| (position(0)*position(0)+position(1)*position(1) >= r_WGTS_m*r_WGTS_m);
|
||||
}
|
||||
|
||||
void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
const double dz = std::min(std::min(
|
||||
Katrin_Fields::E_field_ptr->stepSize(2),
|
||||
longitudinal_bins.minimalBinDistance()),
|
||||
minimalZMovementDistance);
|
||||
|
||||
const double distance = 1./macro_sigma_m;
|
||||
|
||||
const double n = std::floor(distance/dz);
|
||||
|
||||
bool left_simulation = false;
|
||||
bool changed_longitudinal_bin = false;
|
||||
|
||||
const double part_macro_sigma_m = 1./dz;
|
||||
for(double step = 0; step < n; ++step){
|
||||
// move particle to new position
|
||||
double znew_m = get_zNew_m(movePart, part_macro_sigma_m);
|
||||
doWallInteraction(movePart, &oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
movePart->set_x_m(newLoc_m);
|
||||
|
||||
// calculate additional movement through E/B field
|
||||
do_E_calculus(movePart, oldLoc_m, part_macro_sigma_m);
|
||||
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
|
||||
newLoc_m = movePart->get_x_m();
|
||||
|
||||
|
||||
// stop movement conditions
|
||||
changed_longitudinal_bin = longitudinal_bins.changedBin(
|
||||
calc_z_m(oldLoc_m), calc_z_m(newLoc_m));
|
||||
left_simulation = leftSimulation(newLoc_m);
|
||||
|
||||
if(left_simulation || changed_longitudinal_bin){
|
||||
break;
|
||||
}
|
||||
// prepare new loop iteration
|
||||
oldLoc_m = newLoc_m;
|
||||
}
|
||||
if((!left_simulation) && (!changed_longitudinal_bin)){
|
||||
const double rest = std::fmod(distance,dz);
|
||||
const double rest_macro_sigma = 1./rest;
|
||||
|
||||
double znew_m = get_zNew_m(movePart, rest_macro_sigma);
|
||||
doWallInteraction(movePart, &oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
movePart->set_x_m(newLoc_m);
|
||||
do_E_calculus(movePart, oldLoc_m, rest_macro_sigma);
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sigma_m) {
|
||||
double zold_m = movePart->get_x_m()[2];
|
||||
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
double vTotAbs_ms = calc_vec3_abs(v_ms);
|
||||
double vForwardAbs_ms = calc_vec3_abs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] <= 0 ? -1 : 1;
|
||||
double znew_m;
|
||||
if (macro_sigma_m == 0) {
|
||||
if (zDir == -1) {
|
||||
znew_m = z_RW_m;
|
||||
} else {
|
||||
znew_m = z_DPS_m;
|
||||
}
|
||||
} else {
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
}
|
||||
return znew_m;
|
||||
}
|
||||
+167
-7
@@ -1,17 +1,21 @@
|
||||
//
|
||||
// drift_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef drift_base_h
|
||||
#define drift_base_h
|
||||
|
||||
#include "mover_base.h"
|
||||
#include "LongitudinalBins.h"
|
||||
|
||||
|
||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||
class Drift_Base : public Mover_Base {
|
||||
public:
|
||||
Drift_Base(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population);
|
||||
Drift_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
||||
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
|
||||
@@ -19,8 +23,164 @@ protected:
|
||||
double get_zNew_m(Particle *movePart, const double ¯o_sigma_m);
|
||||
virtual void doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) = 0;
|
||||
virtual void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) = 0;
|
||||
|
||||
Discrete::Longitudinal longitudinal_bins;
|
||||
|
||||
};
|
||||
|
||||
inline void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
vec3 newLoc_m = oldLoc_m;
|
||||
|
||||
double znew_m = get_zNew_m(movePart, macro_sigma_m);
|
||||
doWallInteraction(movePart, &oldLoc_m, &znew_m);
|
||||
newLoc_m[2] = znew_m;
|
||||
|
||||
movePart->set_x_m(newLoc_m);
|
||||
do_E_calculus(movePart, oldLoc_m, macro_sigma_m);
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
|
||||
double E_min_eV = 1e-7;
|
||||
double E_max_eV = 2e4;
|
||||
int number_E_bins = 50;
|
||||
|
||||
Log_Scale E_scale;
|
||||
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
|
||||
double E_eV = movePart->get_E_eV();
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
double n = Population->get_density_m3(oldLoc_m);
|
||||
//std::cout << "Pop vor Erhöhung: " << Population->get_species() << " "<< n <<"\n";
|
||||
|
||||
}
|
||||
catch(const MyException& e)
|
||||
{
|
||||
double E_eV = movePart->get_E_eV();
|
||||
int Ee_bin = E_scale.calc_index(E_eV);
|
||||
Bins loc_bin = Population->get_loc_bin(oldLoc_m);
|
||||
double n = Population->get_density_m3(Ee_bin, loc_bin);
|
||||
//std::cout << "Pop vor Erhöhung: " << Population->get_species() << " " << n << "\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Bins dummyloc0 = Population->get_loc_bin(vec3(0,0,0));
|
||||
Bins dummyloc1 = Population->get_loc_bin(vec3(0,0,1));
|
||||
Bins dummyloc2 = Population->get_loc_bin(vec3(0,0,2));
|
||||
Bins dummyloc3 = Population->get_loc_bin(vec3(0,0,3));
|
||||
Bins dummyloc4 = Population->get_loc_bin(vec3(0,0,4));
|
||||
Bins dummyloc5 = Population->get_loc_bin(vec3(0,0,5));
|
||||
Bins dummyloc6 = Population->get_loc_bin(vec3(0,0,6));
|
||||
Bins dummyloc7 = Population->get_loc_bin(vec3(0,0,7));
|
||||
Bins dummyloc8 = Population->get_loc_bin(vec3(0,0,8));
|
||||
Bins dummyloc9 = Population->get_loc_bin(vec3(0,0,9));
|
||||
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc0) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc1) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc2) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc3) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc4) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc5) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc6) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc7) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc8) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc9) << "\n";
|
||||
*/
|
||||
//std::cerr << e.what() << '\n';
|
||||
/*
|
||||
for (int Ee_bin = 0; Ee_bin<number_E_bins; Ee_bin++) {
|
||||
if(Population->get_density_m3(Ee_bin, loc_bin) > 0){
|
||||
std::cout << "Dichte die einen Beitrag liefert: " << Population->get_density_m3(Ee_bin, loc_bin) <<"\n";
|
||||
//std::cout << macro_sigma_m<<"\n";
|
||||
//std::cout << Ee_bin <<"\n";
|
||||
}
|
||||
|
||||
//std::cout << "hier gehts rein?" << "\n";
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Population->get_density_m3()
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
//Population->get_density_m3()
|
||||
try
|
||||
{
|
||||
double n = Population->get_density_m3(oldLoc_m);
|
||||
//std::cout << "Pop nach Erhöhung: " << Population->get_species() << " " << n <<"\n";
|
||||
|
||||
}
|
||||
catch(const MyException& e)
|
||||
{
|
||||
double E_eV = movePart->get_E_eV();
|
||||
int Ee_bin = E_scale.calc_index(E_eV);
|
||||
Bins loc_bin = Population->get_loc_bin(oldLoc_m);
|
||||
double n = Population->get_density_m3(Ee_bin, loc_bin);
|
||||
//std::cout << "Pop nach Erhöhung: " << Population->get_species() << " " << n << "\n";
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Bins dummyloc0 = Population->get_loc_bin(vec3(0,0,0));
|
||||
Bins dummyloc1 = Population->get_loc_bin(vec3(0,0,1));
|
||||
Bins dummyloc2 = Population->get_loc_bin(vec3(0,0,2));
|
||||
Bins dummyloc3 = Population->get_loc_bin(vec3(0,0,3));
|
||||
Bins dummyloc4 = Population->get_loc_bin(vec3(0,0,4));
|
||||
Bins dummyloc5 = Population->get_loc_bin(vec3(0,0,5));
|
||||
Bins dummyloc6 = Population->get_loc_bin(vec3(0,0,6));
|
||||
Bins dummyloc7 = Population->get_loc_bin(vec3(0,0,7));
|
||||
Bins dummyloc8 = Population->get_loc_bin(vec3(0,0,8));
|
||||
Bins dummyloc9 = Population->get_loc_bin(vec3(0,0,9));
|
||||
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc0) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc1) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc2) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc3) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc4) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc5) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc6) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc7) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc8) << "\n";
|
||||
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc9) << "\n";
|
||||
*/
|
||||
//std::cerr << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sigma_m) {
|
||||
double zold_m = movePart->get_x_m()[2];
|
||||
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
double vTotAbs_ms = calc_vec3_abs(v_ms);
|
||||
double vForwardAbs_ms = calc_vec3_abs(vec3(0,0,v_ms[2]));
|
||||
double zDir = v_ms[2] <= 0 ? -1 : 1;
|
||||
double znew_m;
|
||||
if (macro_sigma_m == 0) {
|
||||
if (zDir == -1) {
|
||||
znew_m = z_RW_m - 2*l_WGTS_m;
|
||||
} else {
|
||||
znew_m = z_WGTS_end_m + 2*l_WGTS_m;
|
||||
}
|
||||
} else {
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
//distance * e^x mit mu=1
|
||||
//std::cout<<"Distanz ohne random = " << distance_m<<"\n";
|
||||
UniRNG rngUni;
|
||||
double number = rngUni.random();
|
||||
//double number = distribution(generator);
|
||||
//std::cout << "rngUni " << x <<"\n";
|
||||
distance_m = - distance_m * log(number);
|
||||
//std::cout<<"Distanz mit random = " << distance_m<<"\n";
|
||||
znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||
}
|
||||
return znew_m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* drift_base_h */
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "eT2I_recombination.h"
|
||||
#include "recombination_counter.h"
|
||||
|
||||
|
||||
eT2I_Recombination::eT2I_Recombination(
|
||||
Population_Base *T2IPopulation,
|
||||
UniRNG *rngUni) :
|
||||
e_thermal_Precomputed_Interaction_Base(
|
||||
T2IPopulation, rngUni, me_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double eT2I_Recombination::get_microSigma_m2(
|
||||
const double &E_eV)
|
||||
{
|
||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
|
||||
|
||||
InteractionOut eT2I_Recombination::do_Interaction(
|
||||
Particle *interPart)
|
||||
{
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
GlobalCounter::num_electron_recombinations += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// eT2I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.06.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef eT2I_recombination_h
|
||||
#define eT2I_recombination_h
|
||||
|
||||
@@ -7,12 +15,32 @@
|
||||
|
||||
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
public:
|
||||
eT2I_Recombination(
|
||||
Population_Base *T2IPopulation,
|
||||
UniRNG *rngUni);
|
||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
double get_microSigma_m2(const double &E_eV) {
|
||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline InteractionOut eT2I_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
//std::cout<<"eT2I:\t"<<*interPart<<"\n";
|
||||
std::cout<<interPart->get_species()<<" RECO mit " << Population->get_species() << "\n";
|
||||
//std::cout << "Energie von teilchen " << interPart->get_E_eV() <<"\n";
|
||||
//std::cout << "sigma von interaction e- mit T2+ " << get_microSigma_m2(interPart->get_E_eV())<< "\n";
|
||||
//Bins loc_bin = Population->get_loc_bin(interPart->get_x_m());
|
||||
double n1 = Population->get_density_m3(interPart->get_x_m()); //nur zum schauen
|
||||
//std::cout<<"Population vor Recombination = "<< n1<<"\n";
|
||||
Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
double n2 = Population->get_density_m3(interPart->get_x_m());
|
||||
//std::cout<<"Population nach Recombination = " <<n2<<"\n";
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif /* eT2I_recombination_h */
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "eT2_elastic.h"
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
eT2_Elastic::eT2_Elastic(
|
||||
Population_Base *T2Population,
|
||||
UniRNG *rngUni,
|
||||
DCS_Base *dcs_gen)
|
||||
: e_thermal_Precomputed_Interaction_Base(T2Population, rngUni, me_eV),
|
||||
tcs_data(scale_start, scale_end, 1e3, get_data_path() + "eT2_ela_TCS.dat"),
|
||||
kinematics(me_eV, 2*mT_eV)
|
||||
{
|
||||
this->dcs_gen = dcs_gen;
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double eT2_Elastic::get_macro_sigma_m(const Particle &interPart)
|
||||
{
|
||||
return e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
|
||||
double eT2_Elastic::get_microSigma_m2(const double &E_eV)
|
||||
{
|
||||
return tcs_data.get_value(E_eV);
|
||||
}
|
||||
|
||||
InteractionOut eT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
const vec3 v1_ms = interPart->get_v_ms();
|
||||
const vec3 loc_m = interPart->get_x_m();
|
||||
const vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||
const vec3 vLab_ms = v1_ms - v2_ms; // P2 fixed
|
||||
const double T_eV = calc_E_eV_from_v_ms(vLab_ms, me_eV);
|
||||
const double theta_lab = dcs_gen->get_theta(T_eV);
|
||||
const double phi_lab = rngUni->random() * 2 * pi;
|
||||
const vec3 v_new = kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab);
|
||||
interPart->set_v_ms(v_new);
|
||||
|
||||
|
||||
// gyro center move
|
||||
|
||||
const double v_perp_new_squared = v_new(0)*v_new(0) + v_new(1)*v_new(1);
|
||||
const double v_perp_old_squared = v1_ms(0)*v1_ms(0) + v1_ms(1)*v1_ms(1);
|
||||
|
||||
const double v_perp_new = std::sqrt(v_perp_new_squared);
|
||||
|
||||
const double scalar_product_squared =
|
||||
std::pow(v1_ms(0)*v_new(0) + v1_ms(1)*v_new(1),2)
|
||||
/(v_perp_new_squared*v_perp_old_squared);
|
||||
const double sin_theta_half = scalar_product_squared >= 1 ?
|
||||
0 : std::sqrt((1-std::sqrt(scalar_product_squared))/2);
|
||||
|
||||
const double rG_m = v_perp_new*interPart->get_m_eV()/(Katrin_Fields::getMagField_T(loc_m)(2)*c_ms*c_ms);
|
||||
const double gyro_centrum_move_m = 2*rG_m * sin_theta_half;
|
||||
const double phi = rngUni->random() * 2 * pi;
|
||||
const double x_new = loc_m(0) + std::sin(phi)*gyro_centrum_move_m;
|
||||
const double y_new = loc_m(1) + std::cos(phi)*gyro_centrum_move_m;
|
||||
interPart->set_x_m(vec3(x_new, y_new, loc_m(2)));
|
||||
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
+22
-3
@@ -25,10 +25,29 @@ class eT2_Elastic : public e_thermal_Precomputed_Interaction_Base {
|
||||
Elastic_Kinematic_Base kinematics;
|
||||
|
||||
public:
|
||||
eT2_Elastic(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen);
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
eT2_Elastic(Population_Base *T2Population, UniRNG *rngUni, DCS_Base *dcs_gen) : e_thermal_Precomputed_Interaction_Base(T2Population, rngUni, me_eV),
|
||||
tcs_data(scale_start, scale_end, 1e3, get_data_path() + "eT2_ela_TCS.dat"),
|
||||
kinematics(me_eV, 2*mT_eV) {
|
||||
this->dcs_gen = dcs_gen;
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
double get_macro_sigma_m(const Particle &interPart) {
|
||||
return e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(interPart);
|
||||
}
|
||||
double get_microSigma_m2(const double &E_eV) {return tcs_data.get_value(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut eT2_Elastic::do_Interaction (Particle *interPart) {
|
||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||
vec3 v1_ms = interPart->get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m());
|
||||
vec3 vLab_ms = v1_ms - v2_ms; // P2 fixed
|
||||
double T_eV = calc_E_eV_from_v_ms(vLab_ms, me_eV);
|
||||
double theta_lab = dcs_gen->get_theta(T_eV);
|
||||
double phi_lab = rngUni->random() * 2 * pi;
|
||||
interPart->set_v_ms(kinematics.get_v1_new(v1_ms, v2_ms, theta_lab, phi_lab));
|
||||
return InteractionOut();
|
||||
}
|
||||
|
||||
#endif /* eT2_elastic_h */
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include "eT3I_recombination.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
#include "recombination_counter.h"
|
||||
|
||||
eT3I_Recombination::eT3I_Recombination(
|
||||
Population_Base *T3IPopulation,
|
||||
UniRNG *rngUni) :
|
||||
e_thermal_Precomputed_Interaction_Base(
|
||||
T3IPopulation, rngUni, me_eV)
|
||||
{
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double eT3I_Recombination::get_microSigma_m2(
|
||||
const double &E_eV)
|
||||
{
|
||||
return Janev_eT3I_Recombination::get_TCS(E_eV);
|
||||
}
|
||||
|
||||
|
||||
InteractionOut eT3I_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
GlobalCounter::num_electron_recombinations +=1;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,36 @@
|
||||
//
|
||||
// eT3I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 12.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef eT3I_recombination_h
|
||||
#define eT3I_recombination_h
|
||||
|
||||
#include "e_thermal_base.h"
|
||||
|
||||
#include "janev_eT3I_recombination.h"
|
||||
|
||||
class eT3I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||
public:
|
||||
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni);
|
||||
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T3IPopulation, rngUni, me_eV) {
|
||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||
}
|
||||
|
||||
double get_microSigma_m2(const double &E_eV);
|
||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT3I_Recombination::get_TCS(E_eV);}
|
||||
InteractionOut do_Interaction (Particle *interPart);
|
||||
};
|
||||
|
||||
|
||||
inline InteractionOut eT3I_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
//std::cout<<"eT3I:\t"<<*interPart<<"\n";
|
||||
//Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif /* eT3I_recombination_h */
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// eT5I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef eT5I_recombination_h
|
||||
#define eT5I_recombination_h
|
||||
|
||||
@@ -22,7 +30,7 @@ inline InteractionOut eT5I_Recombination::do_Interaction (Particle *interPart) {
|
||||
InteractionOut res;
|
||||
//std::cout<<"eT5I:\t"<<*interPart<<"\n";
|
||||
res.set_delete_current(true);
|
||||
Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
//Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
#include "e_thermal_base.h"
|
||||
#include "interaction_base.h"
|
||||
|
||||
#include "blitz/array.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
e_thermal_Interaction_Base::e_thermal_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni,
|
||||
double m_eV) :
|
||||
Interaction_Base(Population, rngUni)
|
||||
{
|
||||
if (Population->get_number_E_bins() > 1) {
|
||||
throw MyException("Population is not thermal, when expected thermal.");
|
||||
}
|
||||
m1_eV = m_eV;
|
||||
v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||
E_limit = calc_E_eV_from_v_ms(v_therm * 2000, m1_eV); // 2000 represents 1% variation in energy
|
||||
}
|
||||
|
||||
double e_thermal_Interaction_Base::get_macro_sigma_m(const Particle &interPart)
|
||||
{
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double v_ms = calc_vec3_abs(
|
||||
interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
|
||||
double e_thermal_Interaction_Base::calc_macro_sigma_m(
|
||||
const double &E_eV, const vec3 &loc_m)
|
||||
{
|
||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV)
|
||||
{
|
||||
//return get_microSigma_m2(E_eV); //No Integration... Only e- energy
|
||||
if (E_eV > E_limit) {
|
||||
return get_microSigma_m2(E_eV);
|
||||
} else {
|
||||
const double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||
const double m2_eV = Population->get_m_eV();
|
||||
|
||||
// Integration over theta and v
|
||||
auto integrand = [&](double v2_ms, double theta) {
|
||||
// v2_ms: drift already taken care of in get macro sigma
|
||||
const double E_incident = kineticEnergyIncidentRelativistic(
|
||||
v1_ms, v2_ms, m1_eV, m2_eV, theta);
|
||||
// frame where ion is at rest
|
||||
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_incident)/(6./8.*pi);
|
||||
};
|
||||
return double_simpson_integrate(integrand, 0., 3*v_therm, pi/8., 7./8.*pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||
}
|
||||
}
|
||||
|
||||
vec3 e_thermal_Interaction_Base::get_vOff_ms(
|
||||
const Particle &interPart, const double &minE_eV)
|
||||
{
|
||||
vec3 v1_ms = interPart.get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart.get_x_m());
|
||||
vec3 v1Lab_ms = v1_ms - v2_ms;
|
||||
double T_eV = calc_E_eV_from_v_ms(v1Lab_ms, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
T_eV = calc_E_eV_from_v_ms(v1_ms, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Base::get_vOff_ms: T_eV < minE_eV.\nT_eV= "<< T_eV<<"\t minE_eV= "<<minE_eV<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
return v2_ms;
|
||||
}
|
||||
|
||||
|
||||
e_thermal_Precomputed_Interaction_Base::e_thermal_Precomputed_Interaction_Base(
|
||||
Population_Base *Population, UniRNG *rngUni, double m_eV):
|
||||
e_thermal_Interaction_Base(Population, rngUni, m_eV),
|
||||
E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N)
|
||||
{
|
||||
precomputed_values = new double [E_scale.get_number_bins()];
|
||||
}
|
||||
|
||||
void e_thermal_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
||||
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
||||
}
|
||||
}
|
||||
|
||||
double e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(
|
||||
const Particle &interPart)
|
||||
{
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double v_ms = calc_vec3_abs(
|
||||
interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
||||
if (E_scale.in_scale(E_eV)) {
|
||||
return lookup_macro_sigma_m(E_eV, loc_m);
|
||||
} else {
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
}
|
||||
|
||||
double e_thermal_Precomputed_Interaction_Base::lookup_macro_sigma_m(
|
||||
const double &E_eV, const vec3 &loc_m)
|
||||
{
|
||||
int i = E_scale.calc_index(E_eV);
|
||||
return precomputed_values[i] * Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
+285
-23
@@ -1,46 +1,308 @@
|
||||
//
|
||||
// e_thermal_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef e_thermal_base_h
|
||||
#define e_thermal_base_h
|
||||
|
||||
#include "interaction_base.h"
|
||||
|
||||
// Interactions of electrons with thermal Populations
|
||||
class e_thermal_Interaction_Base : public Interaction_Base {
|
||||
|
||||
public:
|
||||
e_thermal_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni, double m_eV);
|
||||
|
||||
protected:
|
||||
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||
protected:
|
||||
double m1_eV; // energy of kinetic particle in CS measurement : e-
|
||||
|
||||
double E_limit; // limit for integration calculation
|
||||
double v_therm; // typical spped for thermal population
|
||||
|
||||
public:
|
||||
e_thermal_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
if (Population->get_number_E_bins() > 1) {
|
||||
throw MyException("Population is not thermal, when expected thermal.");
|
||||
}
|
||||
m1_eV = m_eV;
|
||||
//v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||
//v_therm = calc_v_ms_from_E_eV(0.1, 2*mT_eV); //gleiche energie
|
||||
v_therm = calc_v_ms_from_E_eV(0.0018, me_eV); // gleiche geschwidingkeit
|
||||
E_limit = calc_E_eV_from_v_ms(v_therm * 2000, m1_eV); // 2000 represents 1% variation in energy
|
||||
}
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
|
||||
protected:
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
double calc_microSigma_m2(const double &E_eV);
|
||||
vec3 get_vOff_ms(const Particle &interPart, const double &minE_eV); // For derived class -> Roll energy loss
|
||||
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
|
||||
private:
|
||||
private:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
};
|
||||
|
||||
// Using precomputed values
|
||||
class e_thermal_Precomputed_Interaction_Base : public e_thermal_Interaction_Base {
|
||||
public:
|
||||
e_thermal_Precomputed_Interaction_Base(
|
||||
Population_Base *Population,
|
||||
UniRNG *rngUni,
|
||||
double m_eV);
|
||||
void calc_values(); // must be called by derived class, can't call in this constructor, due to virtual pure
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
inline double e_thermal_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
|
||||
private:
|
||||
double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
double gammafaktor2(double v) {
|
||||
return 1/sqrt(1-pow(v/c_ms, 2));
|
||||
}
|
||||
|
||||
inline double e_thermal_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
//std::cout <<"calc"<<"\n";
|
||||
//std::cout << "Dichte für get sigma: " << Population->get_density_m3(loc_m)<<"\n";
|
||||
//std::cout << "calc macro_sigma in e_thermal interaction base macht was "<< "\n";
|
||||
//std::cout << "Dichte die verwednet wird: "<<Population->get_density_m3(loc_m)<<"\n"; //die dichte ist falsch?, also sollte sich halt verkleinern
|
||||
//std::cout << "macro sigma von calc macro sigma in e_thermal interaction base " << 1e15 * calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m)<<"\n";
|
||||
//std::cout << "microsigma = " << get_microSigma_m2(E_eV) << "\n";
|
||||
std::cout << "Energie = " << E_eV << "\n";
|
||||
|
||||
if (E_eV > E_limit) {
|
||||
//std::cout << " microsigma = " << get_microSigma_m2(E_eV) << "\n";
|
||||
std::cout << "wird das gemacht? " << "\n";
|
||||
return get_microSigma_m2(E_eV);
|
||||
} else {
|
||||
|
||||
|
||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||
|
||||
double m2_eV = Population->get_m_eV();
|
||||
//std::cout << "m2 " << m2_eV << "\n";
|
||||
|
||||
|
||||
double v2_ms = v_therm;
|
||||
//double v2_ms = v_therm + Population->get_drift_v_ms();
|
||||
//std::cout << "v2 " << v2_ms << "\n";
|
||||
|
||||
//double E1 = E_eV; //unnötig
|
||||
//double E2 = calc_E_eV_from_v_ms(v2_ms, m2_eV);
|
||||
|
||||
//auto integrand = [&](double v2_ms, double theta)
|
||||
auto integrand = [&](double theta) {
|
||||
//double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||
|
||||
//std::cout << "v1 " << v1_ms <<"\n";
|
||||
//std::cout << "v2 " << v2_ms <<"\n";
|
||||
|
||||
double p1 = gammafaktor2(v1_ms) * m1_eV * v1_ms / c_ms; // e-
|
||||
double p2 = gammafaktor2(v2_ms) * m2_eV * v2_ms / c_ms; // ion
|
||||
double E1 = sqrt(pow(m1_eV, 2) + pow(p1, 2)); // e-
|
||||
double E2 = sqrt(pow(m2_eV, 2) + pow(p2, 2)); // ion
|
||||
|
||||
//std::cout << "E1 " << E1 << "\n"; //elektron
|
||||
//std::cout << "E2 " << E2 << "\n"; // ion
|
||||
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||
//std::cout << "p1 " << p1 << "\n"; // p von elektron
|
||||
//std::cout << "p2 " << p2 << "\n"; // p von ion
|
||||
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||
|
||||
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||
//std::cout << "s " << s << "\n";
|
||||
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||
//std::cout << "theta " << theta << "\n";
|
||||
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||
double E_incident = twoEam2/(2*m2_eV);
|
||||
double E_kin_incident = E_incident - m1_eV;
|
||||
|
||||
|
||||
//double E_eV_kin = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||
//std::cout << "geschwindigkeit pop " << v2_ms << "\n";
|
||||
//std::cout << "Energie " << E_eV <<"\n";
|
||||
//return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||
return get_microSigma_m2(E_kin_incident);
|
||||
};
|
||||
//std::cout << "Masse m1 " << m1_eV << "\n";
|
||||
//std::cout << "Masse m2 " << m2_eV << "\n";
|
||||
//std::cout << "thermal v " << v_therm << "\n";
|
||||
//std::cout << "integral für e- ergebnis: " << double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N) << "\n";
|
||||
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||
}
|
||||
//std::cout << "integral für e- ergebnis: " << double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N) << "\n";
|
||||
|
||||
|
||||
|
||||
std::cout << "Energie? " << E_eV << "\n";
|
||||
//std::cout << "E_limit? " << E_limit << "\n";
|
||||
std::cout << "get microsigma ohne integral (wird nicht verwendet) " << get_microSigma_m2(E_eV) << "\n";
|
||||
std::cout << "Monte Carlo micro sigma = " << calc_microSigma_m2(E_eV) << "\n";
|
||||
|
||||
|
||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||
//return get_microSigma_m2(E_eV); //No Integration... Only e- energy
|
||||
if (E_eV > E_limit) {
|
||||
return get_microSigma_m2(E_eV);
|
||||
} else {
|
||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||
|
||||
double m2_eV = Population->get_m_eV();
|
||||
//std::cout << "m2 " << m2_eV << "\n";
|
||||
|
||||
|
||||
double v2_ms = v_therm;
|
||||
//double v2_ms = v_therm + Population->get_drift_v_ms();
|
||||
//std::cout << "v2 " << v2_ms << "\n";
|
||||
|
||||
//double E1 = E_eV; //unnötig
|
||||
//double E2 = calc_E_eV_from_v_ms(v2_ms, m2_eV);
|
||||
|
||||
//auto integrand = [&](double v2_ms, double theta)
|
||||
auto integrand = [&](double theta) {
|
||||
//double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||
|
||||
//std::cout << "v1 " << v1_ms <<"\n";
|
||||
//std::cout << "v2 " << v2_ms <<"\n";
|
||||
|
||||
double p1 = gammafaktor2(v1_ms) * m1_eV * v1_ms / c_ms; // e-
|
||||
double p2 = gammafaktor2(v2_ms) * m2_eV * v2_ms / c_ms; // ion
|
||||
double E1 = sqrt(pow(m1_eV, 2) + pow(p1, 2)); // e-
|
||||
double E2 = sqrt(pow(m2_eV, 2) + pow(p2, 2)); // ion
|
||||
|
||||
//std::cout << "E1 " << E1 << "\n"; //elektron
|
||||
//std::cout << "E2 " << E2 << "\n"; // ion
|
||||
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||
//std::cout << "p1 " << p1 << "\n"; // p von elektron
|
||||
//std::cout << "p2 " << p2 << "\n"; // p von ion
|
||||
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||
|
||||
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||
//std::cout << "s " << s << "\n";
|
||||
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||
//std::cout << "theta " << theta << "\n";
|
||||
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||
double E_incident = twoEam2/(2*m2_eV);
|
||||
double E_kin_incident = E_incident - m1_eV;
|
||||
|
||||
|
||||
//double E_eV_kin = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||
//std::cout << "geschwindigkeit pop " << v2_ms << "\n";
|
||||
//std::cout << "Energie " << E_eV <<"\n";
|
||||
//return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||
return get_microSigma_m2(E_kin_incident);
|
||||
};
|
||||
//std::cout << "Masse m1 " << m1_eV << "\n";
|
||||
//std::cout << "Masse m2 " << m2_eV << "\n";
|
||||
//std::cout << "thermal v " << v_therm << "\n";
|
||||
//std::cout << "integral für e- ergebnis: " << double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N) << "\n";
|
||||
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||
return integralergebnis;
|
||||
|
||||
|
||||
|
||||
/* //alt
|
||||
// Integration over theta and v
|
||||
auto integrand = [&](double v2_ms, double theta) {
|
||||
v2_ms = v2_ms + Population->get_drift()
|
||||
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||
};
|
||||
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
inline vec3 e_thermal_Interaction_Base::get_vOff_ms(const Particle &interPart, const double &minE_eV) {
|
||||
vec3 v1_ms = interPart.get_v_ms();
|
||||
vec3 v2_ms = Population->roll_v_ms(interPart.get_x_m());
|
||||
vec3 v1Lab_ms = v1_ms - v2_ms;
|
||||
double T_eV = calc_E_eV_from_v_ms(v1Lab_ms, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
T_eV = calc_E_eV_from_v_ms(v1_ms, m1_eV);
|
||||
if (T_eV < minE_eV) {
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Base::get_vOff_ms: T_eV < minE_eV.\nT_eV= "<< T_eV<<"\t minE_eV= "<<minE_eV<<"\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
return v2_ms;
|
||||
}
|
||||
|
||||
|
||||
class e_thermal_Precomputed_Interaction_Base : public e_thermal_Interaction_Base { // + Using precomputed values
|
||||
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||
double *precomputed_values;
|
||||
|
||||
public:
|
||||
e_thermal_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : e_thermal_Interaction_Base(Population, rngUni, m_eV), E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N) {
|
||||
precomputed_values = new double [E_scale.get_number_bins()];
|
||||
}
|
||||
void calc_values(); // must be called by derived class, can't call in this constructor, due to virtual pure
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
private:
|
||||
double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||
};
|
||||
|
||||
inline void e_thermal_Precomputed_Interaction_Base::calc_values() {
|
||||
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
||||
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
||||
}
|
||||
}
|
||||
|
||||
inline double e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
//std::cout << "wird das verwendet e_termal_precomputed_interaciton_base::get_macro_sigma_m "<<"\n"; //wird verwendet, ok gut -> hier suchen!
|
||||
|
||||
vec3 loc_m = interPart.get_x_m();
|
||||
//std::cout << "Pop in e_thermal_precomputed_interaction_base: " << Population->get_species() << "\n";
|
||||
//std::cout << "verwendete Dichte für get_macro_sigma_m in e_thermal_precomputed_interaction_base: " << Population->get_species() << " "<<Population->get_density_m3(loc_m)<<"\n";
|
||||
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||
//std::cout << Population->get_species() << "\n";
|
||||
//double v_ms = calc_vec3_abs(interPart.get_v_ms()); //test ohne shift
|
||||
//std::cout << "verwendete geschwindigkeit: " << v_ms << "\n";
|
||||
//std::cout << "thermal dirft v = " << Population->get_drift_v_ms(loc_m) << "\n";
|
||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal
|
||||
//E_eV = interPart.get_E_eV(); // warum nicht so?
|
||||
//double microsigma_montecarlo = calc_microSigma_m2(E_eV);
|
||||
//std::cout << "Monte Carlo Micro Sigma = " << microsigma_montecarlo << "\n";
|
||||
//std::cout << "pop in get_macro_sigma_m in e_thermal_precomputed_interaction_base: " << Population->get_species()<<"\n";
|
||||
|
||||
|
||||
//return calc_macro_sigma_m(E_eV, loc_m);
|
||||
|
||||
std::cout << "Energie die in calc_macro_sigma oder lookup_macro_sigma reinkommt: " << E_eV << "\n";
|
||||
|
||||
if (E_scale.in_scale(E_eV)) {
|
||||
//double a;
|
||||
//a = lookup_macro_sigma_m(E_eV, loc_m);
|
||||
//std::cout << " lookup_macro_sigma in get_macro_sigma in e_thermal_precomputed_base gibt: " << a <<"\n";
|
||||
//std::cout << "look_up" << "\n";
|
||||
//return lookup_macro_sigma_m(E_eV, loc_m);
|
||||
return calc_macro_sigma_m(E_eV, loc_m); // zum testen
|
||||
} else {
|
||||
//double a;
|
||||
//a = calc_macro_sigma_m(E_eV, loc_m);
|
||||
//std::cout << "calc_macro_sigma in get_macro_sigma in e_thermal_precomputed_base: " << a << "\n";
|
||||
//std::cout<< "calc" <<"\n";
|
||||
return calc_macro_sigma_m(E_eV, loc_m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline double e_thermal_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
int i = E_scale.calc_index(E_eV);
|
||||
|
||||
std::cout << "Energie? " << E_scale.get_bin_mid(i) << "\n";
|
||||
//std::cout <<"E index = "<<i<<"\n";
|
||||
//std::cout <<"precomputed_values[i] = " << precomputed_values[i]<< "\n";
|
||||
//std::cout << "pop denisity = " << Population->get_density_m3(loc_m)<<"\n";
|
||||
//std::cout << "pop denisity species = " << Population->get_species()<<"\n";
|
||||
//std::cout <<"look up"<<"\n";
|
||||
//std::cout << "Dichte für get sigma in e_thermal_precomuputed_interaction_base: " << Population->get_density_m3(loc_m)<<"\n";
|
||||
std::cout << "precomputaed value der verwendet wird (Monte Carlo Sigma): " << precomputed_values[i] <<"\n";
|
||||
return precomputed_values[i] * Population->get_density_m3(loc_m);
|
||||
}
|
||||
|
||||
|
||||
#endif /* e_thermal_base_h */
|
||||
|
||||
@@ -9,8 +9,7 @@ namespace ElectricFieldFactory {
|
||||
std::unique_ptr<ElectricField> build(
|
||||
std::string filename,
|
||||
double cylinder_radius,
|
||||
double cylinder_height,
|
||||
double scale_factor);
|
||||
double cylinder_height);
|
||||
|
||||
blitz::Array<double,3> read(std::string filename, std::string dataset_path);
|
||||
|
||||
@@ -31,14 +31,4 @@ blitz::TinyVector<double,3> ElectricField::value(
|
||||
return blitz::TinyVector<double,3>(0., 0., 0.);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double ElectricField::stepSize(int cyl_axis) const
|
||||
{
|
||||
return dx_(cyl_axis);
|
||||
}
|
||||
|
||||
blitz::TinyVector<double,3> ElectricField::stepSize() const
|
||||
{
|
||||
return dx_;
|
||||
}
|
||||
@@ -17,9 +17,6 @@ class ElectricField {
|
||||
|
||||
blitz::TinyVector<double,3> value(const blitz::TinyVector<int,3>& bin) const;
|
||||
|
||||
double stepSize(int cyl_axis) const;
|
||||
blitz::TinyVector<double,3> stepSize() const;
|
||||
|
||||
private:
|
||||
// todo: make sure we use fast axis on z to reduce acess time
|
||||
const blitz::Array<double,3> Er_;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "electricFieldFactory.h"
|
||||
#include "elecrticFieldFactory.h"
|
||||
|
||||
#include "highfive/H5File.hpp"
|
||||
#include "highfive/H5DataSet.hpp"
|
||||
@@ -10,22 +10,19 @@
|
||||
std::unique_ptr<ElectricField> ElectricFieldFactory::build(
|
||||
std::string filename,
|
||||
double cylinder_radius,
|
||||
double cylinder_height,
|
||||
double scale_factor)
|
||||
double cylinder_height)
|
||||
{
|
||||
std::string dataset_path_Er("/Efield/efield_r");
|
||||
std::string dataset_path_Ez("/Efield/efield_z");
|
||||
std::string dataset_path_Er("/Er");
|
||||
std::string dataset_path_Ez("/Ez");
|
||||
|
||||
blitz::Array<double,3> Er = read(filename, dataset_path_Er);
|
||||
blitz::Array<double,3> Ez = read(filename, dataset_path_Ez);
|
||||
blitz::Array<double,3> Ephi(Er.shape());
|
||||
Ephi = 0.;
|
||||
|
||||
Er *= scale_factor;
|
||||
Ez *= scale_factor;
|
||||
|
||||
blitz::TinyVector<int,3> nx( Er.shape()(0), 1, Er.shape()(2));
|
||||
|
||||
|
||||
blitz::TinyVector<double,3> dx = discretize(
|
||||
nx, cylinder_radius, cylinder_height);
|
||||
|
||||
@@ -43,22 +40,21 @@ blitz::Array<double,3> ElectricFieldFactory::read(
|
||||
std::vector<std::vector<double>> data;
|
||||
dataset.read(data);
|
||||
|
||||
const int nz = data[0].size();
|
||||
const int nr = data.size();
|
||||
const int nr = data[0].size();
|
||||
const int nz = data.size();
|
||||
const int nphi = 1;
|
||||
|
||||
blitz::Array<double,3> data_3d(nr, nphi, nz);
|
||||
data_3d = 0.;
|
||||
|
||||
const double E_cgs_to_si = 29979.19999934;
|
||||
|
||||
for(int ri = 0; ri<data_3d.shape()(0); ++ri){
|
||||
for(int phii = 0; phii < data_3d.shape()(1); ++phii){
|
||||
for(int zi = 0; zi< data_3d.shape()(2); ++zi){
|
||||
data_3d(ri, phii, zi) = data[ri][zi] * E_cgs_to_si;
|
||||
data_3d(ri, phii, zi) = data[zi][ri];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data_3d.copy();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "electricField.h"
|
||||
#include "electricFieldFactory.h"
|
||||
#include "elecrticFieldFactory.h"
|
||||
#include "CoordinateConversion.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "highfive/H5File.hpp"
|
||||
#include "highfive/H5DataSet.hpp"
|
||||
#include "highfive/H5DataSpace.hpp"
|
||||
#include "HighFive/include/highfive/H5File.hpp"
|
||||
#include "HighFive/include/highfive/H5DataSet.hpp"
|
||||
#include "HighFive/include/highfive/H5DataSpace.hpp"
|
||||
|
||||
TEST_CASE("ElectricField", "[ElectricField]"){
|
||||
const blitz::TinyVector<double,3> cyl_origin(0., 0., 1.);
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "electron_E_drift.h"
|
||||
#include <cmath>
|
||||
|
||||
void E_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
const double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
const vec3 newLoc_m = movePart->get_x_m();
|
||||
const vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
const vec3 B_T = 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m));
|
||||
const double B_squared = static_cast<double>(blitz::dot(B_T, B_T));
|
||||
vec3 v_drift;
|
||||
if(B_squared == 0){
|
||||
v_drift = vec3(0,0,0);
|
||||
}
|
||||
else{
|
||||
v_drift = blitz::cross(E_Vm, B_T)/(B_squared);
|
||||
}
|
||||
movePart->set_x_m(newLoc_m + v_drift*t_s);
|
||||
|
||||
const double v_boost_z_ms = movePart->get_Z()/movePart->get_m_eV() * E_Vm(2) * t_s * c_ms * c_ms;
|
||||
const vec3 v_boost_ms = vec3(0,0, v_boost_z_ms);
|
||||
movePart->set_v_ms(movePart->get_v_ms() + v_boost_ms);
|
||||
}
|
||||
|
||||
@@ -15,13 +15,34 @@
|
||||
|
||||
class E_Mover_E_Drift : public E_Mover_Drift {
|
||||
public:
|
||||
E_Mover_E_Drift(
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population)
|
||||
: E_Mover_Drift(Logger, Population)
|
||||
{};
|
||||
E_Mover_E_Drift(Particle_Logger_Base *Logger, Population_Base *Population) : E_Mover_Drift(Logger, Population) {};
|
||||
protected:
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
inline void E_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
|
||||
double B_T = calc_vec3_abs( 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m)) );
|
||||
double E_rad_Vm = calc_r_m(E_Vm);
|
||||
|
||||
double v_rad_ms = E_rad_Vm/B_T;
|
||||
vec3 loc_offset_m = E_Vm;
|
||||
if((loc_offset_m(0) == 0.) && (loc_offset_m(1) == 0.)){
|
||||
loc_offset_m = 0.;
|
||||
} else{
|
||||
loc_offset_m(2) = 0.;
|
||||
loc_offset_m = loc_offset_m/calc_vec3_abs(loc_offset_m) * v_rad_ms * t_s;
|
||||
}
|
||||
movePart->set_x_m(newLoc_m + loc_offset_m);
|
||||
|
||||
vec3 v_boost_ms = vec3(0,0, movePart->get_Z()*e_C/movePart->get_m_eV()*E_Vm[2] * t_s/c_ms/c_ms);
|
||||
movePart->set_v_ms(movePart->get_v_ms() + v_boost_ms);
|
||||
}
|
||||
|
||||
#endif /* electron_E_drift_h */
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
#include "electron_boris.h"
|
||||
|
||||
|
||||
E_Mover_Boris::E_Mover_Boris(
|
||||
double dt_s,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population)
|
||||
: Mover_Base(electron, Logger, Population)
|
||||
{
|
||||
this->dt_s = dt_s;
|
||||
};
|
||||
|
||||
E_Mover_Boris::E_Mover_Boris(
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population,
|
||||
double B_max):
|
||||
Mover_Base(electron, Logger, Population)
|
||||
{
|
||||
if(B_max == 0.){
|
||||
dt_s = 1.;
|
||||
} else{
|
||||
dt_s = Population->get_m_eV()/(B_max*c_ms*c_ms);
|
||||
}
|
||||
};
|
||||
|
||||
void E_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
|
||||
if (macro_sigma_m == 0) { // If infinite movement distance let electron leave at only exit... Prob extremly faulty, but also impossible.
|
||||
movePart->set_x_m(z_RW_m);
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
|
||||
loc_m = movePart->get_x_m();
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(movePart, E_Vm, B_T);
|
||||
if (doBoris_WallInteraction(movePart) == true) {
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(movePart, &oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double E_Mover_Boris::doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T) {
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_x_m();
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * calc_vec3_abs(v_ms);
|
||||
doBoris_speedChange(movePart, E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * calc_vec3_abs(v_ms);
|
||||
movePart->set_x_m(x_m);
|
||||
return distance_m;
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Z() * e_C;
|
||||
double m_kg = movePart->get_m_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_v_ms(v_ms);
|
||||
}
|
||||
|
||||
bool E_Mover_Boris::doBoris_WallInteraction(Particle *movePart) {
|
||||
vec3 loc_m = movePart->get_x_m();
|
||||
double r_m = movePart->get_r_m();
|
||||
if (loc_m[2]<=z_RW_m) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_x_m(newLoc_m);
|
||||
return true;
|
||||
}
|
||||
if (r_m>=r_WGTS_m) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (r_WGTS_m * 1.01)/calc_vec3_abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return true;
|
||||
}
|
||||
if (loc_m[2]>=z_DPS_m) { // Spectrometer Reflection
|
||||
movePart->set_v_ms( -1*(movePart->get_v_ms()) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_x_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
+104
-10
@@ -1,22 +1,24 @@
|
||||
//
|
||||
// electron_boris.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_boris_h
|
||||
#define electron_boris_h
|
||||
|
||||
#include "mover_base.h"
|
||||
#include "constants.h"
|
||||
|
||||
|
||||
class E_Mover_Boris : public Mover_Base {
|
||||
double dt_s;
|
||||
public:
|
||||
E_Mover_Boris(
|
||||
double dt_s,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population);
|
||||
E_Mover_Boris(double dt_s, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(electron, Logger, Population) {
|
||||
this->dt_s = dt_s;
|
||||
};
|
||||
|
||||
E_Mover_Boris(
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population,
|
||||
double B_max);
|
||||
|
||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||
|
||||
private:
|
||||
@@ -26,7 +28,99 @@ private:
|
||||
void doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m);
|
||||
};
|
||||
|
||||
void E_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_x_m();
|
||||
|
||||
if (macro_sigma_m == 0) { // If infinite movement distance let electron leave at only exit... Prob extremly faulty, but also impossible.
|
||||
movePart->set_x_m(z_RW_m);
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double distance_m = 1/macro_sigma_m;
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_x_m();
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(movePart, E_Vm, B_T);
|
||||
if (doBoris_WallInteraction(movePart) == true) {
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(movePart, &oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double E_Mover_Boris::doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T) {
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_x_m();
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * calc_vec3_abs(v_ms);
|
||||
doBoris_speedChange(movePart, E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * calc_vec3_abs(v_ms);
|
||||
movePart->set_x_m(x_m);
|
||||
return distance_m;
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Z() * e_C;
|
||||
double m_kg = movePart->get_m_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_v_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_v_ms(v_ms);
|
||||
}
|
||||
|
||||
bool E_Mover_Boris::doBoris_WallInteraction(Particle *movePart) {
|
||||
vec3 loc_m = movePart->get_x_m();
|
||||
double r_m = movePart->get_r_m();
|
||||
if (loc_m[2]<=z_RW_m) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_x_m(newLoc_m);
|
||||
return true;
|
||||
}
|
||||
if (r_m>=r_WGTS_m) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (r_WGTS_m * 1.01)/calc_vec3_abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return true;
|
||||
}
|
||||
if (loc_m[2]>=z_WGTS_end_m) { // Spectrometer Reflection
|
||||
movePart->set_v_ms( -1*(movePart->get_v_ms()) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_x_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif /* electron_boris_h */
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef ELECTRON_DRIFT_H
|
||||
#define ELECTRON_DRIFT_H
|
||||
//
|
||||
// electron_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_drift_h
|
||||
#define electron_drift_h
|
||||
|
||||
#include "drift_base.h"
|
||||
|
||||
@@ -14,22 +22,22 @@ protected:
|
||||
|
||||
inline void E_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
|
||||
if (*znew_m >= z_DPS_m) { // Moveing into Spectrometer and reversing Speed.
|
||||
if (*znew_m >= z_WGTS_end_m) { // Moveing into Spectrometer and reversing Speed.
|
||||
vec3 reverseLoc_m = *oldLoc_m;
|
||||
|
||||
// Log Movement before Reflection
|
||||
reverseLoc_m[2] = z_DPS_m ;
|
||||
reverseLoc_m[2] = z_WGTS_end_m ;
|
||||
movePart->set_x_m(reverseLoc_m);
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
|
||||
// Final Movement
|
||||
*oldLoc_m = reverseLoc_m;
|
||||
*znew_m = z_DPS_m - (*znew_m - z_DPS_m);
|
||||
*znew_m = z_WGTS_end_m - (*znew_m - z_WGTS_end_m);
|
||||
movePart->set_v_ms( -1*(movePart->get_v_ms()) );
|
||||
}
|
||||
if (*znew_m <= z_RW_m) {
|
||||
*znew_m = z_RW_m-0.0001;
|
||||
*znew_m = z_RW_m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +45,4 @@ inline void E_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* ELECTRON_DRIFT_H */
|
||||
#endif /* electron_drift_h */
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef ELECTRON_TERMINATOR_H
|
||||
#define ELECTRON_TERMINATOR_H
|
||||
//
|
||||
// E_Terminator.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 19.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef E_Terminator_h
|
||||
#define E_Terminator_h
|
||||
|
||||
#include "terminator_base.h"
|
||||
|
||||
@@ -25,7 +33,7 @@ inline bool Negative_Terminator::check_walls(const Particle &movePart) {
|
||||
stats.n_rw += 1;
|
||||
return true;
|
||||
}
|
||||
if (z_m >= z_DPS_m && E_eV <= dipole_cutoffE_eV) {
|
||||
if (z_m >= z_WGTS_end_m && E_eV <= dipole_cutoffE_eV) {
|
||||
stats.n_dipole += 1;
|
||||
return true;
|
||||
}
|
||||
@@ -37,4 +45,4 @@ inline bool Negative_Terminator::check_walls(const Particle &movePart) {
|
||||
}
|
||||
|
||||
|
||||
#endif /* ELECTRON_TERMINATOR_H */
|
||||
#endif /* E_Terminator_h */
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
#include "injector.h"
|
||||
#include <random/uniform.h>
|
||||
#include "injector_builder.hpp"
|
||||
|
||||
|
||||
|
||||
Injector::Injector() :
|
||||
RNG_Base(nullptr, nullptr),
|
||||
use_injection_position(false),
|
||||
injection_position(blitz::TinyVector<double,3>(0, 0, 0)),
|
||||
velocity_direction(0)
|
||||
{};
|
||||
|
||||
Injector::Injector(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Base *T2Population,
|
||||
int method,
|
||||
double energy_eV,
|
||||
int ions,
|
||||
bool use_injection_position,
|
||||
const blitz::TinyVector<double,3>& injection_position,
|
||||
int velocity_direction) :
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
use_injection_position(use_injection_position),
|
||||
injection_position(injection_position),
|
||||
velocity_direction(velocity_direction)
|
||||
{
|
||||
this->T2Population = T2Population;
|
||||
this->method = method;
|
||||
this->energy_eV = energy_eV;
|
||||
this->ions = ions;
|
||||
};
|
||||
|
||||
|
||||
int Injector::inject (
|
||||
std::vector<Particle> *particle_queue,
|
||||
const int &last_ID)
|
||||
{
|
||||
|
||||
int num_particles_added = 0;
|
||||
|
||||
vec3 loc_m(0., 0., 0.);
|
||||
|
||||
if(use_injection_position){
|
||||
loc_m = injection_position;
|
||||
}
|
||||
else{
|
||||
loc_m = T2Population->roll_x_ms();
|
||||
}
|
||||
|
||||
double E_eV;
|
||||
switch(method) {
|
||||
case 0: // Fermi
|
||||
E_eV = roll_FermiEnergy_eV();
|
||||
break;
|
||||
case 1: //Delta
|
||||
E_eV = energy_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
E_eV = roll_MBEnergy(energy_eV/kb_eVK, me_eV, rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
|
||||
const double v_abs = calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
vec3 v_dir(0., 0., 0.);
|
||||
|
||||
if(velocity_direction == 0){
|
||||
v_dir = roll_uniform_direction(rngUni);
|
||||
}
|
||||
else if(velocity_direction == 1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, 1);
|
||||
}
|
||||
else if(velocity_direction == -1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, -1);
|
||||
}
|
||||
else{
|
||||
throw MyException("Katrin::inject:electron Invalid Injection Velocity Direction.");
|
||||
}
|
||||
|
||||
vec3 v_ms = v_abs * v_dir;
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
num_particles_added += 1;
|
||||
|
||||
if(ions != 0){
|
||||
double ETI_eV;
|
||||
switch(ions) {
|
||||
case 1: //Delta
|
||||
ETI_eV = Injector_Builder::energyTI_eV;
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
ETI_eV = roll_MBEnergy(
|
||||
Injector_Builder::energyTI_eV/kb_eVK,
|
||||
2*mT_eV,
|
||||
rngNormal);
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectIon: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
|
||||
const double v_abs = calc_v_ms_from_E_eV(ETI_eV,2*mT_eV);
|
||||
|
||||
vec3 v_dir(0., 0., 0.);
|
||||
|
||||
if(velocity_direction == 0){
|
||||
v_dir = roll_uniform_direction(rngUni);
|
||||
}
|
||||
else if(velocity_direction == 1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, 1);
|
||||
}
|
||||
else if(velocity_direction == -1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, -1);
|
||||
}
|
||||
else{
|
||||
throw MyException("Katrin::inject:ion Invalid Injection Velocity Direction.");
|
||||
}
|
||||
|
||||
vec3 vTI_ms = v_dir * v_abs;
|
||||
vec3 locTI = loc_m;
|
||||
particle_queue->push_back(PartFac.create_T2I(locTI, vTI_ms, last_ID+2, last_ID+2));
|
||||
num_particles_added += 1;
|
||||
}
|
||||
|
||||
return num_particles_added;
|
||||
}
|
||||
|
||||
double Injector::roll_FermiEnergy_eV()
|
||||
{
|
||||
double pmax,E_min_eV, E_max_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
E_min_eV = scale_start;
|
||||
E_max_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = E_min_eV + eta1*(E_max_eV - E_min_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return Ecan_eV;
|
||||
}
|
||||
|
||||
double Injector::get_FermiDecaySpectrumDensity(
|
||||
const double &E_eV)
|
||||
{
|
||||
if (E_eV>TritiumDecayEndpoint_eV) {
|
||||
return 0;
|
||||
} else{
|
||||
double p_eV = sqrt(E_eV*E_eV + 2 * E_eV * me_eV);
|
||||
return BetaDecayConst*get_FermiFunction(2, E_eV)*p_eV*(E_eV+me_eV)*pow(TritiumDecayEndpoint_eV-E_eV,2);
|
||||
}
|
||||
}
|
||||
|
||||
double Injector::get_FermiFunction(
|
||||
const double &Z, const double &E_eV)
|
||||
{
|
||||
double gamma = 1+ E_eV/me_eV;
|
||||
double beta = sqrt(1 - pow(gamma,-2));
|
||||
double eta =Z/beta/137.;
|
||||
return 2*pi*eta/(1-exp(-2*pi*eta));
|
||||
}
|
||||
+113
-26
@@ -1,5 +1,13 @@
|
||||
#ifndef INJECTOR_H
|
||||
#define INJECTOR_H
|
||||
//
|
||||
// injector.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef injector_h
|
||||
#define injector_h
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
@@ -8,34 +16,113 @@
|
||||
|
||||
|
||||
class Injector : RNG_Base {
|
||||
public:
|
||||
Injector();
|
||||
|
||||
Injector(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Base *T2Population,
|
||||
int method,
|
||||
double energy_eV,
|
||||
int ions,
|
||||
bool use_injection_position,
|
||||
const blitz::TinyVector<double,3>& injection_position,
|
||||
int velocity_direction);
|
||||
|
||||
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &E_eV);
|
||||
double get_FermiFunction(const double &Z, const double &E_eV);
|
||||
|
||||
int method;
|
||||
double energy_eV;
|
||||
int ions;
|
||||
Population_Base *T2Population;
|
||||
|
||||
Particle_Builder PartFac;
|
||||
bool use_injection_position;
|
||||
blitz::TinyVector<double,3> injection_position;
|
||||
int velocity_direction;
|
||||
|
||||
public:
|
||||
Injector() : RNG_Base(nullptr, nullptr) {};
|
||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal, Population_Base *T2Population, int method, double energy_eV, int ions) : RNG_Base(rngUni, rngNormal){
|
||||
this->T2Population = T2Population;
|
||||
this->method = method;
|
||||
this->energy_eV = energy_eV;
|
||||
this->ions = ions;
|
||||
};
|
||||
|
||||
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
||||
private:
|
||||
double roll_FermiEnergy_eV();
|
||||
double get_FermiDecaySpectrumDensity(const double &E_eV);
|
||||
double get_FermiFunction(const double &Z, const double &E_eV);
|
||||
};
|
||||
|
||||
#endif /* INJECTOR_H */
|
||||
inline int Injector::inject (std::vector<Particle> *particle_queue, const int &last_ID) {
|
||||
vec3 loc_m = T2Population->roll_x_ms();
|
||||
vec3 v_ms;
|
||||
vec3 vTI_ms;
|
||||
|
||||
double E_eV;
|
||||
switch(method) {
|
||||
case 0: // Fermi
|
||||
E_eV = roll_FermiEnergy_eV();
|
||||
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
break;
|
||||
case 1: //Delta
|
||||
E_eV = energy_eV;
|
||||
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
break;
|
||||
case 2: //Maxwell Boltzman
|
||||
E_eV = roll_MBEnergy(energy_eV/kb_eVK, me_eV, rngNormal);
|
||||
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
break;
|
||||
case 3: // Delta Injection for Recombination Testing
|
||||
std::cout << "injecte e-" <<"\n";
|
||||
loc_m = vec3(0.,0.,9.99);
|
||||
E_eV = energy_eV;
|
||||
//std::cout<<"E = "<< E_eV<<"\n";
|
||||
//direction = vec3(0,0,-1);
|
||||
v_ms = vec3(0.,0.,-1.) * calc_v_ms_from_E_eV(E_eV, me_eV);
|
||||
std::cout << "Geschwindigkeit e-: " << v_ms << "\n";
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
break;
|
||||
default:
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
//vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
//particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
|
||||
if (ions == 0) {
|
||||
return 1;
|
||||
if (ions == 2) { // 2: Delta Injection for Testing Recombination
|
||||
vec3 direction = vec3(0.,0.,-1.);
|
||||
vec3 loc_m = vec3(0.,0.,9.99);
|
||||
vec3 vTI_ms = direction * calc_v_ms_from_E_eV(E_eV, me_eV); //gleiche geschwindigkeit
|
||||
//vec3 vTI_ms = direction * calc_v_ms_from_E_eV(E_eV, 2*mT_eV); // gleiche energie
|
||||
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
|
||||
return 2;
|
||||
} else {
|
||||
vec3 vTI_ms = T2Population->roll_v_ms(loc_m);
|
||||
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline double Injector::roll_FermiEnergy_eV() {
|
||||
double pmax,E_min_eV, E_max_eV, Ecan_eV,eta1,eta2;
|
||||
pmax = 1.5e-28; // From Plotting EnergyDistributionBetaDecay
|
||||
E_min_eV = scale_start;
|
||||
E_max_eV = TritiumDecayEndpoint_eV;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
Ecan_eV = E_min_eV + eta1*(E_max_eV - E_min_eV);
|
||||
} while(eta2*pmax > get_FermiDecaySpectrumDensity(Ecan_eV));
|
||||
return Ecan_eV;
|
||||
}
|
||||
|
||||
inline double Injector::get_FermiDecaySpectrumDensity(const double &E_eV) {
|
||||
if (E_eV>TritiumDecayEndpoint_eV) {
|
||||
return 0;
|
||||
} else{
|
||||
double p_eV = sqrt(E_eV*E_eV + 2 * E_eV * me_eV);
|
||||
return BetaDecayConst*get_FermiFunction(2, E_eV)*p_eV*(E_eV+me_eV)*pow(TritiumDecayEndpoint_eV-E_eV,2);
|
||||
}
|
||||
}
|
||||
|
||||
inline double Injector::get_FermiFunction(const double &Z, const double &E_eV) {
|
||||
double gamma = 1+ E_eV/me_eV;
|
||||
double beta = sqrt(1 - pow(gamma,-2));
|
||||
double eta =Z/beta/137.;
|
||||
return 2*pi*eta/(1-exp(-2*pi*eta));
|
||||
}
|
||||
|
||||
|
||||
#endif /* injector_h */
|
||||
|
||||
@@ -11,29 +11,8 @@
|
||||
const int Injector_Builder::method = load_parameter("INJECTION");
|
||||
const double Injector_Builder::energy_eV = load_parameter("INJ_E");
|
||||
const int Injector_Builder::ions = load_parameter("INJ_TI");
|
||||
const double Injector_Builder::energyTI_eV = load_parameter("INJ_E_TI");
|
||||
|
||||
const bool Injector_Builder::use_injection_position = load_parameter("USE_INJECTION_POSITION");
|
||||
const double Injector_Builder::z_pos_injection = load_parameter("INJECTION_Z_POS");
|
||||
const double Injector_Builder::r_pos_injection = load_parameter("INJECTION_R_POS");
|
||||
|
||||
const int Injector_Builder::velocity_direction = load_parameter("INJECTION_VELOCITY_DIRECTION");
|
||||
|
||||
Injector Injector_Builder::build(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Manager *populations)
|
||||
{
|
||||
Injector Injector_Builder::build(UniRNG *rngUni, NormalRNG *rngNormal, Population_Manager *populations) {
|
||||
Population_Base *T2Population = populations->find(tritium2);
|
||||
|
||||
return Injector(
|
||||
rngUni,
|
||||
rngNormal,
|
||||
T2Population,
|
||||
method,
|
||||
energy_eV,
|
||||
ions,
|
||||
use_injection_position,
|
||||
blitz::TinyVector<double,3>(r_pos_injection, 0, z_pos_injection),
|
||||
velocity_direction);
|
||||
return Injector(rngUni, rngNormal, T2Population, method, energy_eV, ions);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// injector_builder.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 14.11.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef injector_builder_hpp
|
||||
#define injector_builder_hpp
|
||||
|
||||
@@ -6,21 +14,13 @@
|
||||
|
||||
|
||||
class Injector_Builder {
|
||||
public:
|
||||
Injector_Builder() {};
|
||||
|
||||
static Injector build(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Manager *populations);
|
||||
|
||||
static const int method;
|
||||
static const double energy_eV;
|
||||
static const int ions;
|
||||
static const double energyTI_eV;
|
||||
static const bool use_injection_position;
|
||||
static const double z_pos_injection;
|
||||
static const double r_pos_injection;
|
||||
static const int velocity_direction;
|
||||
|
||||
public:
|
||||
Injector_Builder() {};
|
||||
|
||||
static Injector build(UniRNG *rngUni, NormalRNG *rngNormal, Population_Manager *populations);
|
||||
};
|
||||
#endif /* injector_builder_hpp */
|
||||
|
||||
@@ -55,7 +55,7 @@ Interaction_Manager Interaction_Builder::build(Population_Manager *Populations,
|
||||
Interactions.add(build_tritiumI(Populations, rngUni));
|
||||
Interactions.add(build_tritium2I(Populations, rngUni));
|
||||
Interactions.add(build_tritium3I(Populations, rngUni));
|
||||
//Interactions.add(build_tritium5I(Populations, rngUni));
|
||||
Interactions.add(build_tritium5I(Populations, rngUni));
|
||||
return Interactions;
|
||||
}
|
||||
Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
@@ -63,7 +63,7 @@ Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *T2IPopulation = Populations->find(tritium2I);
|
||||
Population_Base *T3IPopulation = Populations->find(tritium3I);
|
||||
//Population_Base *T5IPopulation = Populations->find(tritium5I);
|
||||
Population_Base *T5IPopulation = Populations->find(tritium5I);
|
||||
DCS_Base *exc_dcs = new ZeroPi_DCS(rngUni);
|
||||
|
||||
if (load_parameter("eT2_ELA") == 1) {
|
||||
@@ -119,7 +119,7 @@ Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager
|
||||
if (load_parameter("e_REC") == 1) {
|
||||
eInteraction->add(new eT2I_Recombination(T2IPopulation, rngUni));
|
||||
eInteraction->add(new eT3I_Recombination(T3IPopulation, rngUni));
|
||||
//eInteraction->add(new eT5I_Recombination(T5IPopulation, rngUni));
|
||||
eInteraction->add(new eT5I_Recombination(T5IPopulation, rngUni));
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
@@ -170,17 +170,9 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium(Population_Manager
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *TI_Interaction = new Interaction_Channel_Base(tritiumI, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
|
||||
if(load_parameter("TI_ELASTIC") == 1){
|
||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||
}
|
||||
if(load_parameter("TI_RADIAL_ASSOCIATION") == 1){
|
||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||
}
|
||||
if(load_parameter("TI_TERNARY_ASSOCIATION") == 1){
|
||||
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
||||
}
|
||||
|
||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
||||
return TI_Interaction;
|
||||
}
|
||||
|
||||
@@ -194,15 +186,9 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium2I(Population_Manage
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
if(load_parameter("T2I_CLUSTER") == 1){
|
||||
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
||||
}
|
||||
|
||||
if(load_parameter("T2I_CHARGETRANSFER") == 1){
|
||||
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
||||
}
|
||||
|
||||
//T2I_Interaction->add(new T2Ie_DissExc(ePopulation, rngUni));
|
||||
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
||||
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
||||
return T2I_Interaction ;
|
||||
}
|
||||
|
||||
@@ -210,14 +196,9 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manage
|
||||
Interaction_Channel_Base *T3I_Interaction = new Interaction_Channel_Base(tritium3I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
|
||||
if(load_parameter("T3I_ELASTIC") == 1){
|
||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||
}
|
||||
|
||||
//
|
||||
//T3I_Interaction->add(new T3IT2_RadAsc(T2Population, rngUni));
|
||||
//T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||
T3I_Interaction->add(new T3IT2_RadAsc(T2Population, rngUni));
|
||||
T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
||||
|
||||
if (load_parameter("e_REC") == 1) {
|
||||
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
||||
@@ -228,7 +209,7 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manage
|
||||
//T3I_Interaction->add(new T3Ie_DissExc(ePopulation, rngUni));
|
||||
return T3I_Interaction ;
|
||||
}
|
||||
/*
|
||||
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritium5I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *T5I_Interaction = new Interaction_Channel_Base(tritium5I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
@@ -243,5 +224,3 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium5I(Population_Manage
|
||||
|
||||
return T5I_Interaction;
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
static Interaction_Channel_Base* build_tritiumI(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium2I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium3I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
//static Interaction_Channel_Base* build_tritium5I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
static Interaction_Channel_Base* build_tritium5I(Population_Manager *Populations, UniRNG *rngUni);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef INTERACTION_CHANNEL_BASE_H
|
||||
#define INTERACTION_CHANNEL_BASE_H
|
||||
#ifndef interaction_channel_base_h
|
||||
#define interaction_channel_base_h
|
||||
|
||||
#include "process_base.h"
|
||||
#include "interaction_base.h"
|
||||
@@ -41,8 +41,9 @@ inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPa
|
||||
return SubInteractions[i]->do_Interaction(interPart);
|
||||
}
|
||||
}
|
||||
InteractionOut do_nothing;
|
||||
return do_nothing;
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,4 +73,4 @@ inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||
numSubInteractions += 1;
|
||||
}
|
||||
|
||||
#endif /* INTERACTION_CHANNEL_BASE_H */
|
||||
#endif /* interaction_channel_base_h */
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "janev_eT2I_recombination.h"
|
||||
#include <cmath>
|
||||
// Janev:2003aa "From Collision processes in low-temperature hydrogen plasmas" 7.1.3.A p.73 formular (185)
|
||||
|
||||
double Janev_eT2I_Recombination::get_TCS(const double &E_eV)
|
||||
{
|
||||
double const1 = pow( pow(E_eV,0.665) * (1 + 1.1*pow(E_eV,0.512) + 0.011*pow(E_eV,3.10)) , -1);
|
||||
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||
return 17.3e-20 * (const1+const2);
|
||||
}
|
||||
@@ -1,11 +1,27 @@
|
||||
//
|
||||
// janev_eT2I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef janev_eT2I_recombination_h
|
||||
#define janev_eT2I_recombination_h
|
||||
|
||||
#include <cmath>
|
||||
// Janev:2003aa "From Collision processes in low-temperature hydrogen plasmas" 7.1.3.A p.73 formular (185)
|
||||
|
||||
class Janev_eT2I_Recombination {
|
||||
|
||||
public:
|
||||
static double get_TCS(const double &E_eV);
|
||||
public:
|
||||
Janev_eT2I_Recombination() {}
|
||||
|
||||
static double get_TCS(const double &E_eV) {
|
||||
double const1 = pow( pow(E_eV,0.665) * (1 + 1.1*pow(E_eV,0.512) + 0.011*pow(E_eV,3.10)) , -1);
|
||||
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||
return 17.3e-20 * (const1+const2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// janev_eT3I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 12.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef janev_eT3I_recombination_h
|
||||
#define janev_eT3I_recombination_h
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "read_system.h"
|
||||
#include "CoordinateConversion.h"
|
||||
#include "electricFieldFactory.h"
|
||||
#include "elecrticFieldFactory.h"
|
||||
|
||||
double Katrin_Fields::wgtsMagField_T = 0.;
|
||||
std::shared_ptr<ElectricField> Katrin_Fields::E_field_ptr = nullptr;
|
||||
@@ -23,7 +23,6 @@ blitz::TinyVector<double,3> Katrin_Fields::getElField_Vm(
|
||||
CoordinateConversion::cylinderCoordinate(cartesian_m);
|
||||
const blitz::TinyVector<double,3> E_cyl =
|
||||
E_field_ptr->value(cylinder);
|
||||
|
||||
const blitz::TinyVector<double,3> E_cart =
|
||||
CoordinateConversion::cartesianBase(
|
||||
E_cyl,
|
||||
|
||||
+16
-30
@@ -1,5 +1,13 @@
|
||||
#ifndef KINEMATICS_H
|
||||
#define KINEMATICS_H
|
||||
//
|
||||
// kinematics.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef kinematics_h
|
||||
#define kinematics_h
|
||||
|
||||
#include <sstream>
|
||||
#include <blitz/array.h>
|
||||
@@ -56,34 +64,12 @@ inline double calc_r_m(const vec3 &loc_m) {
|
||||
}
|
||||
|
||||
inline double calc_phi(const vec3 &loc_m) {
|
||||
return std::atan2(loc_m(1),loc_m(1));
|
||||
if (loc_m[1] >= 0) {
|
||||
return acos(loc_m[0]/calc_r_m(loc_m));
|
||||
} else {
|
||||
return 2*pi - acos(loc_m[0]/calc_r_m(loc_m));
|
||||
}
|
||||
}
|
||||
|
||||
inline double rel_gamma(double v)
|
||||
{
|
||||
return 1./std::sqrt(1-std::pow(v/c_ms, 2));
|
||||
}
|
||||
|
||||
inline double kineticEnergyIncidentRelativistic(double v1, double v2, double m1, double m2, double theta)
|
||||
{
|
||||
// relativistic transformation to a system where m2 is at rest
|
||||
const double p1 = rel_gamma(v1)*m1*v1/c_ms;
|
||||
const double p2 = rel_gamma(v2)*m2*v2/c_ms;
|
||||
const double E1 = std::sqrt(std::pow(m1,2)+std::pow(p1,2));
|
||||
const double E2 = std::sqrt(std::pow(m2,2)+std::pow(p2,2));
|
||||
const double s =
|
||||
std::pow(m1, 2) + std::pow(m2,2) + 2*E1*E2 - 2*p1*p2*std::cos(theta);
|
||||
const double twoEam2 = s - std::pow(m1, 2) - std::pow(m2, 2);
|
||||
const double E_incident = twoEam2/(2*m2);
|
||||
const double E_kin_incident = E_incident - m1;
|
||||
return E_kin_incident;
|
||||
}
|
||||
|
||||
inline double kineticIncidentEnergySwitch(double E1, double m1, double m2)
|
||||
{
|
||||
// relativistic transformation to a system where m1 is at rest
|
||||
const double E_kin_incident = (E1 + m1)*m2/m1 - m2;
|
||||
return E_kin_incident;
|
||||
}
|
||||
|
||||
#endif /* KINEMATICS_H */
|
||||
#endif /* kinematics_h */
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
#include "kinetic_population.h"
|
||||
#include <fstream>
|
||||
|
||||
|
||||
Kinetic_Population::Kinetic_Population(
|
||||
species this_species,
|
||||
Timer *timer,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
int num_z_bins,
|
||||
int num_r_bins,
|
||||
int num_phi_bins,
|
||||
int num_E_bins,
|
||||
double E_min_eV,
|
||||
double E_max_eV):
|
||||
Population_Base(this_species),
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV, E_max_eV)
|
||||
{
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
}
|
||||
|
||||
|
||||
double Kinetic_Population::get_density_m3(const vec3 &loc_m)
|
||||
{
|
||||
throw MyException("Method for non kinetic populations.\n");
|
||||
}
|
||||
|
||||
double Kinetic_Population::get_density_m3(
|
||||
const int &E_bin, const Bins &loc_bins)
|
||||
{
|
||||
return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::roll_x_ms()
|
||||
{
|
||||
throw MyException ("Not yet implemented as not needed at this point.");
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::get_drift_v_ms(const vec3 &loc_m)
|
||||
{
|
||||
return vec3(0,0,0);
|
||||
} // Dummy as integration is made over energy mids
|
||||
|
||||
double Kinetic_Population::get_thermal_v_ms()
|
||||
{
|
||||
return 0;
|
||||
} // Dummy as integration is made over energy mids
|
||||
|
||||
double Kinetic_Population::get_v_pdf(const double &v_ms)
|
||||
{
|
||||
throw MyException ("Not yet implemented as not needed at this point.");
|
||||
}
|
||||
|
||||
|
||||
void Kinetic_Population::increase_density (
|
||||
const Particle &upPart,
|
||||
const vec3 &oldLoc_m)
|
||||
{
|
||||
container.increase_cum_time_s(
|
||||
oldLoc_m,
|
||||
upPart.get_x_m(),
|
||||
calc_vec3_abs(upPart.get_v_ms()),
|
||||
upPart.get_E_eV());
|
||||
}
|
||||
|
||||
void Kinetic_Population::decrease_denisty (
|
||||
const vec3 &loc_m,
|
||||
const double &E_eV)
|
||||
{
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Kinetic_Population::get_number_E_bins()
|
||||
{
|
||||
return container.get_number_E_bins();
|
||||
}
|
||||
|
||||
Bins Kinetic_Population::get_loc_bin(const vec3 & loc_m)
|
||||
{
|
||||
return container.calc_loc_bin(loc_m);
|
||||
}
|
||||
|
||||
double Kinetic_Population::get_E_bin_mid_eV(const int &E_bin)
|
||||
{
|
||||
return container.get_E_bin_mid_eV(E_bin);
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m)
|
||||
{
|
||||
Bins loc_bins = get_loc_bin(loc_m);
|
||||
double target = 0;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
target += get_density_m3(E_bin, loc_bins);
|
||||
}
|
||||
target *= rngUni->random();
|
||||
double current = 0;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
current += get_density_m3(E_bin, loc_bins);
|
||||
if (current >= target) {
|
||||
return calc_v_ms_from_E_eV(container.roll_E_eV_in_bin(E_bin, rngUni),m_eV);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
Population_Container *Kinetic_Population::access_container()
|
||||
{
|
||||
return &container;
|
||||
}
|
||||
|
||||
@@ -1,47 +1,97 @@
|
||||
#ifndef KINETIC_POPULATION_H
|
||||
#define KINETIC_POPULATION_H
|
||||
//
|
||||
// energetic_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 11.06.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef energetic_base_h
|
||||
#define energetic_base_h
|
||||
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "population_container.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
class Kinetic_Population : public Population_Base, private RNG_Base {
|
||||
|
||||
public:
|
||||
Kinetic_Population(
|
||||
species this_species,
|
||||
Timer *timer,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
int num_z_bins,
|
||||
int num_r_bins,
|
||||
int num_phi_bins,
|
||||
int num_E_bins,
|
||||
double E_min_eV,
|
||||
double E_max_eV);
|
||||
Population_Container container;
|
||||
Timer *timer;
|
||||
|
||||
double m_eV;
|
||||
|
||||
public:
|
||||
Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV, double E_max_eV);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
double get_density_m3(const vec3 &loc_m){throw MyException("Method for non kinetic populations.\n");}
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
int get_number_E_bins();
|
||||
Bins get_loc_bin(const vec3 & loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m);
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m);
|
||||
double get_thermal_v_ms();
|
||||
double get_v_pdf(const double &v_ms);
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return vec3(0,0,0);} // Dummy as integration is made over energy mids
|
||||
double get_thermal_v_ms() {return 0;} // Dummy as integration is made over energy mids
|
||||
double get_v_pdf(const double &v_ms) {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
Population_Container *access_container();
|
||||
|
||||
private:
|
||||
Population_Container container;
|
||||
Timer *timer;
|
||||
|
||||
double m_eV;
|
||||
};
|
||||
|
||||
|
||||
inline Kinetic_Population::Kinetic_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV, double E_max_eV) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV, E_max_eV) {
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
};
|
||||
|
||||
#endif /* KINETIC_POPULATION_H */
|
||||
inline void Kinetic_Population::increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||
container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());
|
||||
}
|
||||
|
||||
inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
inline double Kinetic_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||
}
|
||||
|
||||
int Kinetic_Population::get_number_E_bins() {
|
||||
return container.get_number_E_bins();
|
||||
}
|
||||
Bins Kinetic_Population::get_loc_bin(const vec3 & loc_m) {
|
||||
return container.calc_loc_bin(loc_m);
|
||||
}
|
||||
|
||||
double Kinetic_Population::get_E_bin_mid_eV(const int &E_bin) {
|
||||
return container.get_E_bin_mid_eV(E_bin);
|
||||
}
|
||||
|
||||
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
||||
Bins loc_bins = get_loc_bin(loc_m);
|
||||
double target = 0;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
target += get_density_m3(E_bin, loc_bins);
|
||||
}
|
||||
target *= rngUni->random();
|
||||
double current = 0;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
current += get_density_m3(E_bin, loc_bins);
|
||||
if (current >= target) {
|
||||
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Population_Container *Kinetic_Population::access_container() {
|
||||
return &container;
|
||||
}
|
||||
|
||||
#endif /* energetic_base_h */
|
||||
|
||||
+13
-56
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// logger_builder.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 18.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "logger_builder.hpp"
|
||||
|
||||
#include "multiz_particle_logger.h"
|
||||
@@ -5,10 +13,8 @@
|
||||
#include "off_particle_logger.h"
|
||||
|
||||
#include "population_logger_base.h"
|
||||
#include "CurrentLogger.h"
|
||||
|
||||
const int Particle_Logger_Builder::numberZBins = load_parameter("LOG_BARS");
|
||||
const int Particle_Logger_Builder::numberRBins = load_parameter("LOG_BARS_R");
|
||||
|
||||
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
||||
Particle_Logger_Manager ParticleLogger;
|
||||
@@ -19,70 +25,22 @@ Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritium3I));
|
||||
//ParticleLogger.add(new Off_Particle_Logger(tritium5I));
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritium5I));
|
||||
} else if(numberZBins == -1){
|
||||
ParticleLogger.add(new SF_Particle_Logger(electron, h5f));
|
||||
ParticleLogger.add(new SF_Particle_Logger(tritiumI, h5f));
|
||||
ParticleLogger.add(new SF_Particle_Logger(tritium2I, h5f));
|
||||
ParticleLogger.add(new SF_Particle_Logger(tritium3I, h5f));
|
||||
//ParticleLogger.add(new SF_Particle_Logger(tritium5I, h5f));
|
||||
ParticleLogger.add(new SF_Particle_Logger(tritium5I, h5f));
|
||||
} else {
|
||||
build_MultiZ(&ParticleLogger, h5f);
|
||||
}
|
||||
return ParticleLogger;
|
||||
}
|
||||
|
||||
Particle_Logger_Manager Particle_Logger_Builder::build(std::string filename)
|
||||
{
|
||||
Particle_Logger_Manager ParticleLogger;
|
||||
ParticleLogger.add(new Off_Particle_Logger(tritium));
|
||||
|
||||
build_histogram(&ParticleLogger, filename);
|
||||
|
||||
return ParticleLogger;
|
||||
}
|
||||
|
||||
void Particle_Logger_Builder::build_histogram(
|
||||
Particle_Logger_Manager *ParticleLogger,
|
||||
std::string filename)
|
||||
{
|
||||
const int energy_decade_min = load_parameter("LOG_BARS_ENERGY_DECADE_MIN");
|
||||
const int energy_decade_max = load_parameter("LOG_BARS_ENERGY_DECADE_MAX");
|
||||
|
||||
const double zmin = z_RW_m;
|
||||
const double zmax = z_DPS_m;
|
||||
|
||||
ParticleLogger->add(new CurrentLogger(
|
||||
electron,
|
||||
numberZBins, zmin, zmax,
|
||||
numberRBins, r_WGTS_m,
|
||||
energy_decade_min, energy_decade_max,
|
||||
filename));
|
||||
ParticleLogger->add(new CurrentLogger(
|
||||
tritiumI,
|
||||
numberZBins, zmin, zmax,
|
||||
numberRBins, r_WGTS_m,
|
||||
energy_decade_min, energy_decade_max,
|
||||
filename));
|
||||
ParticleLogger->add(new CurrentLogger(
|
||||
tritium2I,
|
||||
numberZBins, zmin, zmax,
|
||||
numberRBins, r_WGTS_m,
|
||||
energy_decade_min, energy_decade_max,
|
||||
filename));
|
||||
ParticleLogger->add(new CurrentLogger(
|
||||
tritium3I,
|
||||
numberZBins, zmin, zmax,
|
||||
numberRBins, r_WGTS_m,
|
||||
energy_decade_min, energy_decade_max,
|
||||
filename));
|
||||
}
|
||||
|
||||
|
||||
void Particle_Logger_Builder::build_MultiZ(Particle_Logger_Manager *ParticleLogger, H5_File *h5f) {
|
||||
double *zValues = new double[numberZBins];
|
||||
double start_m = z_RW_m;
|
||||
double length_m = z_DPS_m - start_m;
|
||||
double length_m = z_WGTS_end_m - start_m;
|
||||
double stepLength_m = length_m/(numberZBins-1);
|
||||
|
||||
double z_m;
|
||||
@@ -90,12 +48,11 @@ void Particle_Logger_Builder::build_MultiZ(Particle_Logger_Manager *ParticleLogg
|
||||
z_m = start_m + stepLength_m*i;
|
||||
zValues[i] = z_m;
|
||||
}
|
||||
|
||||
ParticleLogger->add(new MultiZ_Particle_Logger(electron, h5f, numberZBins, zValues));
|
||||
ParticleLogger->add(new MultiZ_Particle_Logger(tritiumI, h5f, numberZBins, zValues));
|
||||
ParticleLogger->add(new MultiZ_Particle_Logger(tritium2I, h5f, numberZBins, zValues));
|
||||
ParticleLogger->add(new MultiZ_Particle_Logger(tritium3I, h5f, numberZBins, zValues));
|
||||
//ParticleLogger->add(new MultiZ_Particle_Logger(tritium5I, h5f, numberZBins, zValues));
|
||||
ParticleLogger->add(new MultiZ_Particle_Logger(tritium5I, h5f, numberZBins, zValues));
|
||||
|
||||
delete[] zValues;
|
||||
}
|
||||
@@ -106,6 +63,6 @@ Population_Logger_Manager Population_Logger_Builder::build(H5_File *h5f, Populat
|
||||
Population_Loggers.add (new Population_Logger(populations->find(tritiumI), timer, h5f));
|
||||
Population_Loggers.add (new Population_Logger(populations->find(tritium2I), timer, h5f));
|
||||
Population_Loggers.add (new Population_Logger(populations->find(tritium3I), timer, h5f));
|
||||
//Population_Loggers.add (new Population_Logger(populations->find(tritium5I), timer, h5f));
|
||||
Population_Loggers.add (new Population_Logger(populations->find(tritium5I), timer, h5f));
|
||||
return Population_Loggers;
|
||||
}
|
||||
|
||||
@@ -22,19 +22,11 @@ typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
||||
|
||||
class Particle_Logger_Builder {
|
||||
static const int numberZBins;
|
||||
static const int numberRBins;
|
||||
|
||||
public:
|
||||
Particle_Logger_Builder() {};
|
||||
static Particle_Logger_Manager build(H5_File *h5f);
|
||||
static Particle_Logger_Manager build(std::string filename);
|
||||
|
||||
static void build_MultiZ(
|
||||
Particle_Logger_Manager *ParticleLogger,
|
||||
H5_File *h5f);
|
||||
static void build_histogram(
|
||||
Particle_Logger_Manager *ParticleLogger,
|
||||
std::string filename);
|
||||
static void build_MultiZ(Particle_Logger_Manager *ParticleLogger, H5_File *h5f);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+2
-34
@@ -15,30 +15,6 @@ OBJS := particle_looper.o \
|
||||
electricFieldFactory.o \
|
||||
CoordinateConversion.o \
|
||||
simulation_init.o \
|
||||
Ion_Mover_Boris.o \
|
||||
electron_boris.o \
|
||||
drift_base.o \
|
||||
electron_E_drift.o \
|
||||
eT2_elastic.o \
|
||||
T3IT2_elastic.o \
|
||||
TIT2_elastic.o \
|
||||
CurrentHistogram.o \
|
||||
CurrentLogger.o \
|
||||
e_thermal_base.o \
|
||||
TI_kinetic_base.o \
|
||||
eT2I_recombination.o \
|
||||
eT3I_recombination.o \
|
||||
T2Ie_recombination.o \
|
||||
T3Ie_recombination.o \
|
||||
postive_E_drift.o \
|
||||
recombination_counter.o \
|
||||
T2IT2_cx.o \
|
||||
tritium2_population.o \
|
||||
LongitudinalBins.o \
|
||||
injector.o \
|
||||
thermal_population.o \
|
||||
janev_eT2I_recombination.o \
|
||||
kinetic_population.o \
|
||||
|
||||
|
||||
CXXFLAGS = $(X_OFLAGS) -I.. $(X_INC) -std=c++11
|
||||
@@ -49,8 +25,7 @@ MPXFLAGS = $(X_OFLAGS) -I.. $(X_INC) $(X_HDF5P_INC) -std=c++11
|
||||
LDFLAGS = $(X_LIB) $(X_HDF5P_LIBS)
|
||||
|
||||
#LOADLIBES = -lblitz -lm -lhdf5 -lhdf5_hl
|
||||
#LOADLIBES = -lblitz -lm -g -DBZ_DEBUG
|
||||
LOADLIBES = -lblitz -lm
|
||||
LOADLIBES = -lblitz -lm -g -DBZ_DEBUG
|
||||
|
||||
TARGETS = mcelectron
|
||||
|
||||
@@ -72,14 +47,7 @@ ctest: $(TARGETS_TEST)
|
||||
OBJECTS_TEST = electric_field_test.o \
|
||||
electricField.o \
|
||||
electricFieldFactory.o \
|
||||
CoordinateConversion.o \
|
||||
CurrentHistogram.o \
|
||||
current_histogram_test.o\
|
||||
CurrentLogger.o\
|
||||
current_logger_test.o\
|
||||
particle.o\
|
||||
LongitudinalBins.o \
|
||||
LongitudinalBins_test.o \
|
||||
CoordinateConversion.o
|
||||
|
||||
catch: test_main.o $(OBJECTS_TEST)
|
||||
$(MPICXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||
|
||||
+20
-33
@@ -16,7 +16,6 @@
|
||||
#include "postive_drift.h"
|
||||
#include "postive_E_drift.h"
|
||||
#include "neutral_mover.h"
|
||||
#include "Ion_Mover_Boris.h"
|
||||
|
||||
|
||||
const int Mover_Builder::propagationMethod = load_parameter("PROPAGATION");
|
||||
@@ -29,7 +28,7 @@ Mover_Manager Mover_Builder::build(Particle_Logger_Manager *Loggers, Population_
|
||||
Movers.add(build_tritiumI(Loggers, Populations));
|
||||
Movers.add(build_tritium2I(Loggers, Populations));
|
||||
Movers.add(build_tritium3I(Loggers, Populations));
|
||||
//Movers.add(build_tritium5I(Loggers, Populations));
|
||||
Movers.add(build_tritium5I(Loggers, Populations));
|
||||
return Movers;
|
||||
}
|
||||
|
||||
@@ -49,8 +48,7 @@ Mover_Base *Mover_Builder::build_electron(Particle_Logger_Manager *Loggers, Popu
|
||||
|
||||
|
||||
} else {
|
||||
//electron_Mover = new E_Mover_Boris(dt_s, Logger, Popultation);
|
||||
electron_Mover = new E_Mover_Boris(Logger, Popultation, load_parameter("BFIELD"));
|
||||
electron_Mover = new E_Mover_Boris(dt_s, Logger, Popultation);
|
||||
}
|
||||
return electron_Mover;
|
||||
}
|
||||
@@ -64,53 +62,43 @@ Mover_Base *Mover_Builder::build_tritium(Particle_Logger_Manager *Loggers, Popul
|
||||
Mover_Base *Mover_Builder::build_tritiumI(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritiumI);
|
||||
Population_Base *Popultation = Populations->find(tritiumI);
|
||||
if (propagationMethod == 0) {
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritiumI, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritiumI, Logger, Popultation);
|
||||
} else {
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritiumI, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritiumI, Logger, Popultation);
|
||||
} else {
|
||||
return new Ion_Mover_Boris(tritiumI, Logger, Popultation, load_parameter("BFIELD"));
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
}
|
||||
|
||||
Mover_Base *Mover_Builder::build_tritium2I(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritium2I);
|
||||
Population_Base *Popultation = Populations->find(tritium2I);
|
||||
if (propagationMethod == 0) {
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritium2I, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritium2I, Logger, Popultation);
|
||||
} else {
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritium2I, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritium2I, Logger, Popultation);
|
||||
} else {
|
||||
return new Ion_Mover_Boris(tritium2I, Logger, Popultation, load_parameter("BFIELD"));
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Mover_Base *Mover_Builder::build_tritium3I(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritium3I);
|
||||
Population_Base *Popultation = Populations->find(tritium3I);
|
||||
if (propagationMethod == 0) {
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritium3I, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritium3I, Logger, Popultation);
|
||||
} else {
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
if (load_parameter("E_FIELD") == 0) {
|
||||
return new Positive_Mover_Drift(tritium3I, Logger, Popultation);
|
||||
} else if (load_parameter("E_FIELD") == 1) {
|
||||
return new Positive_Mover_E_Drift(tritium3I, Logger, Popultation);
|
||||
} else {
|
||||
return new Ion_Mover_Boris(tritium3I, Logger, Popultation, load_parameter("BFIELD"));
|
||||
throw MyException("E_FIELD invalid");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
Mover_Base *Mover_Builder::build_tritium5I(Particle_Logger_Manager *Loggers, Population_Manager *Populations) {
|
||||
Particle_Logger_Base *Logger = Loggers->find(tritium5I);
|
||||
Population_Base *Popultation = Populations->find(tritium5I);
|
||||
@@ -124,4 +112,3 @@ Mover_Base *Mover_Builder::build_tritium5I(Particle_Logger_Manager *Loggers, Pop
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
static Mover_Base *build_tritiumI(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
static Mover_Base *build_tritium2I(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
static Mover_Base *build_tritium3I(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
//static Mover_Base *build_tritium5I(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
static Mover_Base *build_tritium5I(Particle_Logger_Manager *Loggers, Population_Manager *Populations);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// neutral_mover.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 04.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef neutral_mover_h
|
||||
#define neutral_mover_h
|
||||
|
||||
@@ -30,8 +38,8 @@ inline void Neutral_Mover::wall_correction(vec3 *newLoc_m, const vec3 &oldLoc_m)
|
||||
if (*newLoc_m[2] < z_RW_m) {
|
||||
newLoc_m[2] = z_RW_m;
|
||||
}
|
||||
if (*newLoc_m[2] > z_DPS_m) {
|
||||
newLoc_m[2] = z_DPS_m;
|
||||
if (*newLoc_m[2] > z_WGTS_end_m) {
|
||||
newLoc_m[2] = z_WGTS_end_m;
|
||||
}
|
||||
if (calc_r_m(*newLoc_m) > r_WGTS_m) {
|
||||
double phi = calc_phi(*newLoc_m);
|
||||
|
||||
@@ -51,7 +51,7 @@ std::vector<species> get_all_species_vector() {
|
||||
all.push_back(tritium2I);
|
||||
all.push_back(tritium2);
|
||||
all.push_back(tritium3I);
|
||||
//all.push_back(tritium5I);
|
||||
all.push_back(tritium5I);
|
||||
return all;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
void set_logging(const bool &logging) {
|
||||
this->logging = logging;
|
||||
}
|
||||
virtual void output(){};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +1,19 @@
|
||||
//
|
||||
// particle_looper.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "particle_looper.hpp"
|
||||
#include "recombination_counter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Particle_Looper::Particle_Looper():
|
||||
longitudinal_bins(
|
||||
Discrete::Longitudinal(z_RW_m, z_DPS_m, long_move_num_bins))
|
||||
{}
|
||||
|
||||
|
||||
void Particle_Looper::init(
|
||||
long int seed, long int ID_offset, std::string output_path)
|
||||
{
|
||||
rngUni.seed(seed);
|
||||
rngNormal.seed(seed);
|
||||
this->ID_offset = ID_offset;
|
||||
h5f = H5_File(output_path);
|
||||
output_filename_without_type_ending=output_path.erase(output_path.length()-3);
|
||||
init_managers();
|
||||
//pop_load_saver.load();
|
||||
}
|
||||
|
||||
|
||||
void Particle_Looper::init_managers() {
|
||||
timer = Timer(&local_decays, &global_decays);
|
||||
//part_loggers = Particle_Logger_Builder::build(&h5f);
|
||||
part_loggers = Particle_Logger_Builder::build(output_filename_without_type_ending);
|
||||
part_loggers = Particle_Logger_Builder::build(&h5f);
|
||||
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
||||
|
||||
injector = Injector_Builder::build(&rngUni, &rngNormal, &populations);
|
||||
@@ -50,53 +37,49 @@ void Particle_Looper::do_loops(int target_decays) {
|
||||
}
|
||||
process_one(&particle_queue);
|
||||
}
|
||||
Particle_Logger_Base *log_output = part_loggers.find(species::electron);
|
||||
log_output->output();
|
||||
|
||||
log_output = part_loggers.find(species::tritium3I);
|
||||
log_output->output();
|
||||
|
||||
log_output = part_loggers.find(species::tritiumI);
|
||||
log_output->output();
|
||||
|
||||
log_output = part_loggers.find(species::tritium2I);
|
||||
log_output->output();
|
||||
|
||||
pop_loggers.log();
|
||||
}
|
||||
|
||||
void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
||||
int i = floor(rngUni.random()*particle_queue->size());
|
||||
//int i = particle_queue->size();
|
||||
//i = 0;
|
||||
//std::cout << i << "\n";
|
||||
Particle curPart = particle_queue->at(i);
|
||||
; std::cout<<"################################################"<<"\n";
|
||||
std::cout<<"Current Particle: "<< curPart.get_species() <<"\n";
|
||||
std::cout<<"current particle energy "<< curPart.get_E_eV()<<"\n";
|
||||
//Particle curPart = particle_queue->front();
|
||||
Mover_Base *moverPtr = movers.find(curPart.get_species());
|
||||
Interaction_Channel_Base *interactionPtr = interactions.find(curPart.get_species());
|
||||
Terminator_Base *terminatorPtr = terminators.find(curPart.get_species());
|
||||
Particle_Logger_Base *logger = part_loggers.find(curPart.get_species());
|
||||
|
||||
|
||||
InteractionOut IntOut;
|
||||
double macro_sigma_m;
|
||||
double macro_sigma_m;
|
||||
vec3 oldLoc_m;
|
||||
while (!terminatorPtr->check_terminlization(curPart)) {
|
||||
oldLoc_m = curPart.get_x_m();
|
||||
|
||||
std::cout << "Wo sind wir gerade? " << oldLoc_m << "\n";
|
||||
//std::cout << "noch nichts passiert, richtig?"<< "\n";
|
||||
macro_sigma_m = interactionPtr->get_macro_sigma_m(curPart);
|
||||
double rnd_number = rngUni.random();
|
||||
rnd_number = (rnd_number == 0.) ? 1E-15 : rnd_number;
|
||||
double rolled_macro_sigma_m = - macro_sigma_m/log(rnd_number);
|
||||
rolled_macro_sigma_m = (rolled_macro_sigma_m <= 0.)? 1E-15 : rolled_macro_sigma_m;
|
||||
|
||||
moverPtr->move(&curPart, rolled_macro_sigma_m);
|
||||
//macro_sigma_m = macro_sigma_m * 1e21;
|
||||
//std::cout<<"MacroSigma in particle_looper wird für move verwendet: "<< macro_sigma_m<<"\n";
|
||||
|
||||
//macro_sigma_m = 1; //nur test
|
||||
//std::cout<<"Test macro_sigma auf 1 gesetzt -> also Interaktion "<<"\n";
|
||||
std::cout << "Move: " << "\n";
|
||||
moverPtr->move(&curPart, macro_sigma_m);
|
||||
|
||||
std::cout << "Wo sind wir nach move? " << curPart.get_x_m() << "\n";
|
||||
|
||||
if (terminatorPtr->check_terminlization(curPart)) {
|
||||
break; // Don't double check terminlization, else n_double.
|
||||
}
|
||||
std::cout<<"Keine Interaktion."<<"\n";
|
||||
|
||||
const double z_new = calc_z_m(curPart.get_x_m());
|
||||
if(!longitudinal_bins.changedBin(calc_z_m(oldLoc_m), z_new)){
|
||||
oldLoc_m = curPart.get_x_m();
|
||||
break; // Don't double check terminlization, else n_double.
|
||||
} else {
|
||||
std::cout<<"Interaktion: "<<"\n";
|
||||
//curPart.set_x_m(oldLoc_m);
|
||||
IntOut = interactionPtr->do_Interaction(&curPart);
|
||||
logger->log(curPart, oldLoc_m);
|
||||
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
||||
particle_queue->push_back(IntOut.get_new_particles()[i]);
|
||||
particle_queue->back().set_Id(get_new_id());
|
||||
@@ -107,10 +90,7 @@ void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
||||
}
|
||||
}
|
||||
}
|
||||
particle_queue->erase(particle_queue->begin() + i);
|
||||
|
||||
}
|
||||
|
||||
particle_queue->erase(particle_queue->begin() + i );}
|
||||
|
||||
long int Particle_Looper::get_new_id() {
|
||||
ID_counter++;
|
||||
@@ -153,24 +133,3 @@ void Particle_Looper::flush() {
|
||||
pop_loggers.flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long int Particle_Looper::get_number_total_particles()
|
||||
{
|
||||
return ID_counter;
|
||||
}
|
||||
|
||||
void Particle_Looper::set_global_decays(long int global_decays)
|
||||
{
|
||||
this->global_decays = global_decays;
|
||||
}
|
||||
|
||||
Population_Manager *Particle_Looper::get_populations()
|
||||
{
|
||||
return &populations;
|
||||
}
|
||||
|
||||
Terminator_Manager *Particle_Looper::get_terminators()
|
||||
{
|
||||
return &terminators;
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef PARTICLE_LOOPER_H
|
||||
#define PARTICLE_LOOPER_H
|
||||
//
|
||||
// particle_looper.hpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef particle_looper_hpp
|
||||
#define particle_looper_hpp
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -15,33 +23,9 @@
|
||||
#include "terminator_builder.hpp"
|
||||
|
||||
#include "population_load_saver.hpp"
|
||||
#include "LongitudinalBins.h"
|
||||
|
||||
|
||||
class Particle_Looper {
|
||||
|
||||
public:
|
||||
Particle_Looper();
|
||||
void init(long int seed, long int ID_offset, std::string output_path);
|
||||
|
||||
void do_loops(int target_decays);
|
||||
void do_logging_off_loops(int target_decays);
|
||||
long int get_number_total_particles();
|
||||
void set_global_decays(long int global_decays);
|
||||
Population_Manager *get_populations();
|
||||
Terminator_Manager *get_terminators();
|
||||
|
||||
void flush();
|
||||
|
||||
private:
|
||||
void init_managers();
|
||||
|
||||
void process_one(std::vector<Particle> *particle_queue);
|
||||
long int get_new_id();
|
||||
long int get_last_id();
|
||||
|
||||
void set_logging(bool logging);
|
||||
|
||||
UniRNG rngUni;
|
||||
NormalRNG rngNormal;
|
||||
|
||||
@@ -63,11 +47,55 @@ class Particle_Looper {
|
||||
long int ID_counter = 0;
|
||||
long int local_decays = 0;
|
||||
long int global_decays = 0;
|
||||
std::string output_filename_without_type_ending;
|
||||
|
||||
Discrete::Longitudinal longitudinal_bins;
|
||||
|
||||
public:
|
||||
Particle_Looper() {};
|
||||
void init(long int seed, long int ID_offset, std::string output_path) {
|
||||
rngUni.seed(seed);
|
||||
rngNormal.seed(seed);
|
||||
this->ID_offset = ID_offset;
|
||||
h5f = H5_File(output_path);
|
||||
init_managers();
|
||||
//pop_load_saver.load();
|
||||
}
|
||||
~Particle_Looper() {
|
||||
//pop_load_saver.save();
|
||||
}
|
||||
private:
|
||||
void init_managers();
|
||||
|
||||
public:
|
||||
void do_loops(int target_decays);
|
||||
private:
|
||||
void process_one(std::vector<Particle> *particle_queue);
|
||||
long int get_new_id();
|
||||
long int get_last_id();
|
||||
|
||||
public:
|
||||
void do_logging_off_loops(int target_decays);
|
||||
private:
|
||||
void set_logging(bool logging);
|
||||
|
||||
public:
|
||||
long int get_number_total_particles() {
|
||||
return ID_counter;
|
||||
}
|
||||
|
||||
void set_global_decays(long int global_decays) {
|
||||
this->global_decays = global_decays;
|
||||
}
|
||||
|
||||
Population_Manager *get_populations() {
|
||||
return &populations;
|
||||
}
|
||||
|
||||
Terminator_Manager *get_terminators() {
|
||||
return &terminators;
|
||||
}
|
||||
|
||||
void flush();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* PARTICLE_LOOPER_H */
|
||||
#endif /* particle_looper_hpp */
|
||||
|
||||
@@ -36,14 +36,14 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
||||
Populations.add(new Thermal_Population(tritiumI, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium2I, new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium3I, new WGTS_Kinematics(3*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
//Populations.add(new Thermal_Population(tritium5I, new WGTS_Kinematics(5*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium5I, new WGTS_Kinematics(5*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new T2_Population(new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), rngUni, rngNormal));
|
||||
} else {
|
||||
Populations.add(new Thermal_Population(tritium, new Lin_Kinematics(mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritiumI, new Lin_Kinematics(mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium2I, new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium3I, new Lin_Kinematics(3*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
//Populations.add(new Thermal_Population(tritium5I, new Lin_Kinematics(5*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new Thermal_Population(tritium5I, new Lin_Kinematics(5*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// population_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 02.08.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "population_container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -45,7 +53,7 @@ Population_Container &Population_Container::operator=(const Population_Container
|
||||
}
|
||||
|
||||
void Population_Container::init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins, double E_min_eV, double E_max_eV) {
|
||||
scales.z = Lin_Scale(z_RW_m, z_DPS_m, num_z_bins);
|
||||
scales.z = Lin_Scale(z_RW_m, z_WGTS_end_m, num_z_bins);
|
||||
scales.r = Lin_Scale(0,r_WGTS_m, num_r_bins);
|
||||
scales.phi = Lin_Scale(0, 2*pi, num_phi_bins);
|
||||
E_scale = Log_Scale(E_min_eV, E_max_eV, num_E_bins);
|
||||
@@ -76,18 +84,12 @@ void Population_Container::init_size_array() {
|
||||
}
|
||||
}
|
||||
|
||||
void Population_Container::increase_cum_time_s(
|
||||
const vec3 &loc1_m,
|
||||
const vec3 &loc2_m,
|
||||
const double &v_ms,
|
||||
const double &E_eV)
|
||||
{
|
||||
void Population_Container::increase_cum_time_s(const vec3 &loc1_m, const vec3 &loc2_m, const double &v_ms, const double &E_eV) {
|
||||
int E_bin = E_scale.calc_index(E_eV);
|
||||
Bins bins_1 = calc_loc_bin(loc1_m);
|
||||
Bins bins_2 = calc_loc_bin(loc2_m);
|
||||
|
||||
if ((!(bins_1.r == bins_2.r && bins_1.phi == bins_2.phi)) && (bins_1.z == bins_2.z)) { // Movement not in z... just ignore it for now...
|
||||
//cout<<"Population_Container: Movement in r-phi-direction. \n.";
|
||||
cout<<"Population_Container: Movement in r-phi-direction. \n.";
|
||||
} else if (bins_1.z == bins_2.z) { // Movement in same bin, most of the times!
|
||||
double d_m = calc_vec3_abs(loc2_m - loc1_m);
|
||||
double cum_time_s = d_m/v_ms;
|
||||
@@ -132,16 +134,30 @@ double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_e
|
||||
}
|
||||
|
||||
double Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s) {
|
||||
const int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||
const double cum_time_s = cum_times_s[data_bin];
|
||||
const double offset = offsets[data_bin];
|
||||
const double V_m3 = size_data_m3[loc_bins.r];
|
||||
int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||
double cum_time_s = cum_times_s[data_bin];
|
||||
int offset = offsets[data_bin];
|
||||
//std::cout<< "Offset = " << offset<<"\n";
|
||||
double V_m3 = size_data_m3[loc_bins.r];
|
||||
|
||||
//std::cout<<"cum_time/time = "<<cum_time_s/time_s<<"\n";
|
||||
//std::cout<<"offset = " <<offset<<"\n";
|
||||
|
||||
double n_m3 = cum_time_s/time_s/V_m3 - offset/V_m3;
|
||||
//double n_m3 = cum_time_s/time_s/V_m3 ;
|
||||
|
||||
|
||||
if (n_m3<0) {
|
||||
std::cout<<"Offset größer als n"<<"\n";
|
||||
n_m3 = 0;
|
||||
//cum_times_s[data_bin] = 0;
|
||||
//offsets[data_bin] = 0;
|
||||
cum_times_s[data_bin] = 0;
|
||||
offsets[data_bin] = 0;
|
||||
//std::cout << "cumtime in data bin " << cum_times_s[data_bin] << "\n";
|
||||
//std::cout << "cumtime in data bin+1 " << cum_times_s[data_bin+1] << "\n";
|
||||
//std::cout << "offset in data bin " << offsets[data_bin] << "\n";
|
||||
//std::cout << "offset in data bin+1 " << offsets[data_bin+1] << "\n";
|
||||
//cumtime = 0
|
||||
//offset = 0
|
||||
}
|
||||
return n_m3;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// population_load_saver.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 11.06.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "population_load_saver.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -41,8 +49,8 @@ void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
||||
*save_stream<<timer->get_time_s()<<"\t # Offset Time in seconds \n";
|
||||
|
||||
*save_stream<<z_RW_m<<"\t";
|
||||
*save_stream<<z_rear_pp2<<"\t";
|
||||
*save_stream<<z_DPS_m<<"\t";
|
||||
*save_stream<<z_WGTS_start_m<<"\t";
|
||||
*save_stream<<z_WGTS_end_m<<"\t";
|
||||
*save_stream<<r_WGTS_m<<"\t";
|
||||
*save_stream<<" # 1. rear wall pos 2. WGTS start pos 3. WGTS end pos 4. WGTS radius all pos in m \n";
|
||||
|
||||
@@ -162,13 +170,13 @@ void Population_Load_Saver::check_katrin_geo_line(ifstream *load_stream) {
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
*load_stream>>z_WGTSstart_m;
|
||||
if ( z_WGTSstart_m != z_rear_pp2) {
|
||||
if ( z_WGTSstart_m != z_WGTS_start_m) {
|
||||
stringstream ss;
|
||||
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSstart missmatch.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
*load_stream>>z_WGTSend_m;
|
||||
if ( z_WGTSend_m != z_DPS_m) {
|
||||
if ( z_WGTSend_m != z_WGTS_end_m) {
|
||||
stringstream ss;
|
||||
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSend missmatch.\n";
|
||||
throw MyException(ss.str());
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// positive_terminator.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 04.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef positive_terminator_h
|
||||
#define positive_terminator_h
|
||||
|
||||
@@ -20,7 +28,7 @@ inline bool PosNeu_Terminator::check_walls(const Particle &movePart) {
|
||||
stats.n_rw += 1;
|
||||
return true;
|
||||
}
|
||||
if (z_m >= z_DPS_m) {
|
||||
if (z_m >= z_WGTS_end_m) {
|
||||
stats.n_dipole += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#include "postive_E_drift.h"
|
||||
#include <cmath>
|
||||
|
||||
Positive_Mover_E_Drift::Positive_Mover_E_Drift(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population) :
|
||||
Positive_Mover_Drift(this_species, Logger, Population)
|
||||
{};
|
||||
|
||||
void Positive_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
const double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
const vec3 newLoc_m = movePart->get_x_m();
|
||||
const vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
const vec3 B_T = 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m));
|
||||
const double B_squared = static_cast<double>(blitz::dot(B_T, B_T));
|
||||
vec3 v_drift;
|
||||
if(B_squared == 0){
|
||||
v_drift = vec3(0,0,0);
|
||||
}
|
||||
else{
|
||||
v_drift = blitz::cross(E_Vm, B_T)/(B_squared);
|
||||
}
|
||||
|
||||
movePart->set_x_m(newLoc_m + v_drift*t_s);
|
||||
|
||||
const double v_boost_z_ms = movePart->get_Z()/movePart->get_m_eV() * E_Vm(2) * t_s * c_ms * c_ms;
|
||||
const vec3 v_boost_ms = vec3(0,0, v_boost_z_ms);
|
||||
movePart->set_v_ms(movePart->get_v_ms() + v_boost_ms);
|
||||
}
|
||||
|
||||
+43
-13
@@ -1,20 +1,50 @@
|
||||
#ifndef POSTIVE_E_DRIFT_H
|
||||
#define POSTIVE_E_DRIFT_H
|
||||
//
|
||||
// postive_E_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 05.10.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef postive_E_drift_h
|
||||
#define postive_E_drift_h
|
||||
|
||||
#include "postive_drift.h"
|
||||
|
||||
class Positive_Mover_E_Drift : public Positive_Mover_Drift {
|
||||
public:
|
||||
Positive_Mover_E_Drift(
|
||||
species this_species,
|
||||
Particle_Logger_Base *Logger,
|
||||
Population_Base *Population);
|
||||
public:
|
||||
Positive_Mover_E_Drift(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Positive_Mover_Drift(this_species, Logger, Population) {};
|
||||
|
||||
protected:
|
||||
void do_E_calculus(
|
||||
Particle *movePart,
|
||||
const vec3 &oldLoc_m,
|
||||
const double ¯o_sigma_m);
|
||||
protected:
|
||||
void do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m);
|
||||
};
|
||||
|
||||
#endif /* POSTIVE_E_DRIFT_H */
|
||||
|
||||
inline void Positive_Mover_E_Drift::do_E_calculus(Particle *movePart, const vec3 &oldLoc_m, const double ¯o_sigma_m) {
|
||||
if (macro_sigma_m <= 0) {
|
||||
return;
|
||||
}
|
||||
double t_s = 1/macro_sigma_m/calc_vec3_abs(movePart->get_v_ms());
|
||||
vec3 newLoc_m = movePart->get_x_m();
|
||||
vec3 E_Vm = 0.5 * (Katrin_Fields::getElField_Vm(oldLoc_m) + Katrin_Fields::getElField_Vm(newLoc_m));
|
||||
double B_T = calc_vec3_abs( 0.5 * (Katrin_Fields::getMagField_T(oldLoc_m) + Katrin_Fields::getMagField_T(newLoc_m)) );
|
||||
|
||||
double E_rad_Vm = calc_r_m(E_Vm);
|
||||
double v_rad_ms = E_rad_Vm/B_T;
|
||||
|
||||
vec3 loc_offset_m = E_Vm;
|
||||
if((loc_offset_m(0) == 0.) && (loc_offset_m(1) == 0.)){
|
||||
loc_offset_m = 0.;
|
||||
} else{
|
||||
loc_offset_m(2) = 0.;
|
||||
loc_offset_m = loc_offset_m/calc_vec3_abs(loc_offset_m) * v_rad_ms * t_s;
|
||||
}
|
||||
|
||||
movePart->set_x_m(newLoc_m + loc_offset_m);
|
||||
|
||||
vec3 v_boost_ms = vec3(0,0, movePart->get_Z()*e_C/movePart->get_m_eV()*E_Vm[2] * t_s/c_ms/c_ms);
|
||||
movePart->set_v_ms(movePart->get_v_ms() + v_boost_ms);
|
||||
}
|
||||
|
||||
|
||||
#endif /* postive_E_drift_h */
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef POSTIVE_DRIFT_H
|
||||
#define POSTIVE_DRIFT_H
|
||||
//
|
||||
// postive_drift.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 04.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef postive_drift_h
|
||||
#define postive_drift_h
|
||||
|
||||
#include "drift_base.h"
|
||||
|
||||
@@ -15,11 +23,11 @@ protected:
|
||||
|
||||
|
||||
inline void Positive_Mover_Drift::doWallInteraction(Particle *movePart, vec3 *oldLoc_m, double *znew_m) {
|
||||
if (*znew_m >= z_DPS_m) {
|
||||
*znew_m = z_DPS_m+0.001;
|
||||
if (*znew_m >= z_WGTS_end_m) {
|
||||
*znew_m = z_WGTS_end_m;
|
||||
}
|
||||
if (*znew_m <= z_RW_m) {
|
||||
*znew_m = z_RW_m-0.001;
|
||||
*znew_m = z_RW_m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +35,4 @@ inline void Positive_Mover_Drift::do_E_calculus(Particle *movePart, const vec3 &
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* POSTIVE_DRIFT_H */
|
||||
#endif /* postive_drift_h */
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef RANDOM_OPERATIONS_H
|
||||
#define RANDOM_OPERATIONS_H
|
||||
//
|
||||
// random_operations.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef random_operations_h
|
||||
#define random_operations_h
|
||||
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
@@ -59,4 +67,4 @@ inline double roll_Rejectionmethod(double (*pdf)(double), double xmin, double xm
|
||||
}
|
||||
|
||||
|
||||
#endif /* RANDOM_OPERATIONS_H */
|
||||
#endif /* random_operations_h */
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "recombination_counter.h"
|
||||
|
||||
long int GlobalCounter::num_electron_recombinations{0};
|
||||
long int GlobalCounter::num_T3I_recombinations{0};
|
||||
long int GlobalCounter::num_T2I_recombinations{0};
|
||||
long int GlobalCounter::num_TI_recombinations{0};
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef RECOMBINATION_COUNTER_H
|
||||
#define RECOMBINATION_COUNTER_H
|
||||
|
||||
struct GlobalCounter {
|
||||
static long int num_electron_recombinations;
|
||||
static long int num_T3I_recombinations;
|
||||
static long int num_T2I_recombinations;
|
||||
static long int num_TI_recombinations;
|
||||
};
|
||||
|
||||
|
||||
#endif /* RECOMBINATION_COUNTER_H */
|
||||
+6
-27
@@ -9,7 +9,6 @@
|
||||
#include "simulation.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
#include "recombination_counter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -258,34 +257,14 @@ void Simulation::print_term_stats() {
|
||||
global_stats.from_array(global_array);
|
||||
if (mpi_rank == 0) {
|
||||
std::cout<<"# "<<*itr<<"\n";
|
||||
std::cout<<"n_total \t"<<global_stats.n_total<<"\n";
|
||||
std::cout<<"n_rw \t"<<global_stats.n_rw<<"\n";
|
||||
std::cout<<"n_dipole \t"<<global_stats.n_dipole<<"\n";
|
||||
std::cout<<"n_radial \t"<<global_stats.n_radial<<"\n";
|
||||
std::cout<<"n_max \t"<<global_stats.n_max<<"\n";
|
||||
std::cout<<"n_energy \t"<<global_stats.n_energy<<"\n";
|
||||
std::cout<<"n_total\t"<<global_stats.n_total<<"\n";
|
||||
std::cout<<"n_rw\t"<<global_stats.n_rw<<"\n";
|
||||
std::cout<<"n_dipole\t"<<global_stats.n_dipole<<"\n";
|
||||
std::cout<<"n_radial\t"<<global_stats.n_radial<<"\n";
|
||||
std::cout<<"n_max\t"<<global_stats.n_max<<"\n";
|
||||
std::cout<<"n_energy\t"<<global_stats.n_energy<<"\n";
|
||||
std::cout<<"n_reaction\t"<<global_stats.n_reaction<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long int num_e_recombinations = 0;
|
||||
MPI_Allreduce(&(GlobalCounter::num_electron_recombinations), &num_e_recombinations, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
long int num_TI2_recombinations = 0;
|
||||
MPI_Allreduce(&(GlobalCounter::num_T2I_recombinations), &num_TI2_recombinations, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
long int num_TI3_recombinations = 0;
|
||||
MPI_Allreduce(&(GlobalCounter::num_T3I_recombinations), &num_TI3_recombinations, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
long int num_TI_recombinations = 0;
|
||||
MPI_Allreduce(&(GlobalCounter::num_TI_recombinations), &num_TI_recombinations, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
if(mpi_rank == 0){
|
||||
std::cout << "# Recombinations\n";
|
||||
std::cout << "n_rec_e- \t"<<num_e_recombinations<<"\n";
|
||||
std::cout << "n_rec_T+ \t"<<num_TI_recombinations<<"\n";
|
||||
std::cout << "n_rec_T2+ \t"<<num_TI2_recombinations<<"\n";
|
||||
std::cout << "n_rec_T3+ \t"<<num_TI3_recombinations<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "simulation.hpp"
|
||||
#include "katrin_fields.hpp"
|
||||
|
||||
#include "electricFieldFactory.h"
|
||||
#include "elecrticFieldFactory.h"
|
||||
#include "CoordinateConversion.h"
|
||||
|
||||
#include "pugixml.hpp"
|
||||
@@ -10,7 +10,7 @@
|
||||
void initCoordinateConversion()
|
||||
{
|
||||
CoordinateConversion::setCylinderOrigin(
|
||||
blitz::TinyVector<double,3>(0., 0., 0.));
|
||||
blitz::TinyVector<double,3>(0., 0., -3.));
|
||||
}
|
||||
|
||||
void initBField(const pugi::xml_node& B_params) {
|
||||
@@ -23,16 +23,10 @@ void initEField(const pugi::xml_node& E_params) {
|
||||
double radius = atof(E_params.child_value("Radius"));
|
||||
double height = atof(E_params.child_value("Height"));
|
||||
|
||||
double scale_factor = 1.;
|
||||
if(!E_params.child("ScaleFactor").empty()) {
|
||||
scale_factor = atof(E_params.child_value("ScaleFactor"));
|
||||
}
|
||||
|
||||
Katrin_Fields::E_field_ptr = ElectricFieldFactory::build(
|
||||
filename,
|
||||
radius,
|
||||
height,
|
||||
scale_factor);
|
||||
height);
|
||||
}
|
||||
|
||||
void initKatrinFields(const pugi::xml_node& field_params) {
|
||||
|
||||
@@ -25,6 +25,6 @@ Terminator_Manager Terminator_Builder::build() {
|
||||
Terminator.add(new PosNeu_Terminator(tritiumI, maxInteractions, cutoffEnergy_eV));
|
||||
Terminator.add(new PosNeu_Terminator(tritium2I, maxInteractions, cutoffEnergy_eV));
|
||||
Terminator.add(new PosNeu_Terminator(tritium3I, maxInteractions, cutoffEnergy_eV));
|
||||
//Terminator.add(new PosNeu_Terminator(tritium5I, maxInteractions, cutoffEnergy_eV));
|
||||
Terminator.add(new PosNeu_Terminator(tritium5I, maxInteractions, cutoffEnergy_eV));
|
||||
return Terminator;
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
#include "thermal_population.h"
|
||||
|
||||
|
||||
Thermal_Population::Thermal_Population(
|
||||
species this_species,
|
||||
Base_Kinematics *kinematics,
|
||||
Timer *timer,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
int num_z_bins, int num_r_bins, int num_phi_bins) :
|
||||
Population_Base(this_species),
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
container(num_z_bins, num_r_bins, num_phi_bins, 1)
|
||||
{
|
||||
this->timer = timer;
|
||||
this->kinematics = kinematics;
|
||||
}
|
||||
|
||||
void Thermal_Population::increase_density (
|
||||
const Particle &upPart, const vec3 &oldLoc_m)
|
||||
{
|
||||
container.increase_cum_time_s(
|
||||
oldLoc_m,
|
||||
upPart.get_x_m(),
|
||||
calc_vec3_abs(upPart.get_v_ms()),
|
||||
upPart.get_E_eV());
|
||||
}
|
||||
void Thermal_Population::decrease_denisty (
|
||||
const vec3 &loc_m, const double &E_eV)
|
||||
{
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
double Thermal_Population::get_density_m3(
|
||||
const vec3 &loc_m)
|
||||
{
|
||||
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||
}
|
||||
|
||||
double Thermal_Population::get_density_m3(
|
||||
const int &E_bin, const Bins &loc_bins)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
|
||||
int Thermal_Population::get_number_E_bins()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bins Thermal_Population::get_loc_bin(
|
||||
const vec3 & loc_m)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
double Thermal_Population::get_E_bin_mid_eV(
|
||||
const int &E_bin)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
|
||||
|
||||
vec3 Thermal_Population::roll_x_ms()
|
||||
{
|
||||
throw MyException ("Not yet implemented as not needed at this point.");
|
||||
}
|
||||
vec3 Thermal_Population::roll_v_ms (
|
||||
const vec3 &loc_m)
|
||||
{
|
||||
return kinematics->get_v_ms(loc_m);
|
||||
}
|
||||
vec3 Thermal_Population::get_drift_v_ms(
|
||||
const vec3 &loc_m)
|
||||
{
|
||||
return kinematics->get_v_offset_ms(loc_m);
|
||||
}
|
||||
double Thermal_Population::get_thermal_v_ms()
|
||||
{
|
||||
return kinematics->get_thermal_v_ms();
|
||||
}
|
||||
double Thermal_Population::get_v_pdf(
|
||||
const double &v_ms)
|
||||
{
|
||||
return kinematics->get_v_pdf(v_ms);
|
||||
}
|
||||
|
||||
Population_Container *Thermal_Population::access_container()
|
||||
{
|
||||
return &container;
|
||||
}
|
||||
@@ -1,44 +1,49 @@
|
||||
#ifndef THERMAL_POPULATION_H
|
||||
#define THERMAL_POPULATION_H
|
||||
//
|
||||
// Thermal_Population.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 25.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Thermal_Population_h
|
||||
#define Thermal_Population_h
|
||||
|
||||
#include "population_base.h"
|
||||
#include "wgts_kinematics.h"
|
||||
|
||||
class Thermal_Population : public Population_Base, private RNG_Base {
|
||||
public:
|
||||
Thermal_Population(
|
||||
species this_species,
|
||||
Base_Kinematics *kinematics,
|
||||
Timer *timer,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
int num_z_bins,
|
||||
int num_r_bins,
|
||||
int num_phi_bins);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
int get_number_E_bins();
|
||||
Bins get_loc_bin(const vec3 & loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_v_ms (const vec3 &loc_m);
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m);
|
||||
double get_thermal_v_ms();
|
||||
double get_v_pdf(const double &v_ms);
|
||||
|
||||
Population_Container *access_container();
|
||||
private:
|
||||
|
||||
class Thermal_Population : public Population_Base, private RNG_Base {
|
||||
Population_Container container;
|
||||
Timer *timer;
|
||||
Base_Kinematics *kinematics;
|
||||
|
||||
public:
|
||||
Thermal_Population(species this_species, Base_Kinematics *kinematics, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, 1) {
|
||||
this->timer = timer;
|
||||
this->kinematics = kinematics;
|
||||
}
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {container.increase_offset(loc_m, E_eV);}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m) {return container.get_density_m3(loc_m, 0, timer->get_time_s());}
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||
|
||||
Population_Container *access_container() {return &container;}
|
||||
};
|
||||
|
||||
|
||||
#endif /* THERMAL_POPULATION_H */
|
||||
#endif /* Thermal_Population_h */
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
#include "tritium2_population.h"
|
||||
|
||||
T2_Population::T2_Population(
|
||||
Base_Kinematics *kinematics,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal) :
|
||||
Population_Base(tritium2),
|
||||
RNG_Base(rngUni, rngNormal)
|
||||
{
|
||||
set_regimes();
|
||||
this->kinematics = kinematics;
|
||||
}
|
||||
|
||||
const double T2_Population::wgtsT2MaxDensity_m3 = load_parameter("T2_MAXDENS");
|
||||
|
||||
void T2_Population::increase_density (
|
||||
const Particle &upPart, const vec3 &oldLoc_m)
|
||||
{}
|
||||
|
||||
void T2_Population::decrease_denisty (
|
||||
const vec3 &loc_m, const double &E_eV)
|
||||
{}
|
||||
|
||||
|
||||
double T2_Population::get_density_m3(
|
||||
const int &E_bin, const Bins &loc_bins)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
|
||||
int T2_Population::get_number_E_bins()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bins T2_Population::get_loc_bin(
|
||||
const vec3 & loc_m)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
|
||||
double T2_Population::get_E_bin_mid_eV(
|
||||
const int &E_bin)
|
||||
{
|
||||
throw MyException("Should not be called.\n.");
|
||||
}
|
||||
|
||||
vec3 T2_Population::roll_v_ms (
|
||||
const vec3 &loc_m)
|
||||
{
|
||||
return kinematics->get_v_ms(loc_m);
|
||||
}
|
||||
|
||||
vec3 T2_Population::get_drift_v_ms(
|
||||
const vec3 &loc_m)
|
||||
{
|
||||
return kinematics->get_v_offset_ms(loc_m);
|
||||
}
|
||||
|
||||
double T2_Population::get_thermal_v_ms()
|
||||
{
|
||||
return kinematics->get_thermal_v_ms();
|
||||
}
|
||||
|
||||
double T2_Population::get_v_pdf(
|
||||
const double &v_ms)
|
||||
{
|
||||
return kinematics->get_v_pdf(v_ms);
|
||||
}
|
||||
|
||||
Population_Container *T2_Population::access_container()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void T2_Population::set_regimes() {
|
||||
|
||||
std::vector<double> reductions = {
|
||||
reduction_RW,
|
||||
reduction_rear_pp1,
|
||||
reduction_rear_pp2,
|
||||
reduction_inlet,
|
||||
reduction_front_pp1,
|
||||
reduction_front_pp2,
|
||||
reduction_DPS
|
||||
};
|
||||
|
||||
std::vector<double> zs = {
|
||||
z_RW_m,
|
||||
z_rear_pp1,
|
||||
z_rear_pp2,
|
||||
z_inlet_m,
|
||||
z_front_pp1,
|
||||
z_front_pp2,
|
||||
z_DPS_m
|
||||
};
|
||||
|
||||
n_regimes = reductions.size()-1;
|
||||
|
||||
for (int i = 0; i<n_regimes; i++) {
|
||||
reduction_min.push_back(reductions[i]);
|
||||
z_min_m.push_back(zs[i]);
|
||||
|
||||
const double reduction_max = reductions[i+1];
|
||||
const double reduction_min_loc = reductions[i];
|
||||
const double z_max_m = zs[i+1];
|
||||
const double z_min_loc_m = zs[i];
|
||||
|
||||
slopes.push_back((reduction_max-reduction_min_loc)/(z_max_m-z_min_loc_m));
|
||||
}
|
||||
}
|
||||
|
||||
double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||
double z_m = calc_z_m(loc_m);
|
||||
for (int i = (n_regimes-1); i>=0; i--) {
|
||||
if (z_m>z_min_m[i]) {
|
||||
double reduction_factor = reduction_min[i] + (z_m-z_min_m[i])*slopes[i];
|
||||
return reduction_factor * wgtsT2MaxDensity_m3;
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"T2_Population::calc_DensityTriangle: z_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 T2_Population::roll_x_ms() {
|
||||
double r_m = r_WGTS_m*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double eta1, eta2, z_can_m;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
z_can_m = z_RW_m + eta1*(z_DPS_m - z_RW_m);
|
||||
} while(eta2*wgtsT2MaxDensity_m3 > get_density_m3(vec3(0,0, z_can_m)));
|
||||
return vec3 (r_m*cos(phi) ,r_m*sin(phi) ,z_can_m);
|
||||
}
|
||||
|
||||
@@ -1,48 +1,106 @@
|
||||
#ifndef TRITIUM2_POPULATION_H
|
||||
#define TRITIUM2_POPULATION_H
|
||||
//
|
||||
// tritium2_population.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 17.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef tritium2_population_h
|
||||
#define tritium2_population_h
|
||||
|
||||
#include "wgts_kinematics.h"
|
||||
#include "population_base.h"
|
||||
#include "random_operations.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class T2_Population : public Population_Base, private RNG_Base {
|
||||
public:
|
||||
T2_Population(
|
||||
Base_Kinematics *kinematics,
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
int get_number_E_bins();
|
||||
Bins get_loc_bin(const vec3 & loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_v_ms (const vec3 &loc_m);
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m);
|
||||
double get_thermal_v_ms();
|
||||
double get_v_pdf(const double &v_ms);
|
||||
|
||||
Population_Container *access_container();
|
||||
|
||||
private:
|
||||
void set_regimes();
|
||||
|
||||
class T2_Population : public Population_Base, private RNG_Base {
|
||||
static const double wgtsT2MaxDensity_m3;
|
||||
|
||||
Base_Kinematics *kinematics;
|
||||
int n_regimes;
|
||||
double *reduction_min;
|
||||
double *z_min_m;
|
||||
double *slopes;
|
||||
|
||||
public:
|
||||
T2_Population(Base_Kinematics *kinematics, UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium2), RNG_Base(rngUni, rngNormal) {
|
||||
set_regimes();
|
||||
this->kinematics = kinematics;
|
||||
};
|
||||
~T2_Population() {
|
||||
delete[] reduction_min;
|
||||
delete[] z_min_m;
|
||||
delete[] slopes;
|
||||
};
|
||||
private:
|
||||
void set_regimes();
|
||||
|
||||
public:
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||
|
||||
Population_Container *access_container() {return nullptr;};
|
||||
|
||||
std::vector<double> slopes;
|
||||
std::vector<double> z_min_m;
|
||||
std::vector<double> reduction_min;
|
||||
};
|
||||
|
||||
#endif /* TRITIUM2_POPULATION_H */
|
||||
const double T2_Population::wgtsT2MaxDensity_m3 = load_parameter("T2_MAXDENS");
|
||||
|
||||
inline void T2_Population::set_regimes() {
|
||||
n_regimes = 4;
|
||||
double reds[5] = {reduction_tot_rear, reduction_WGTS_rear, 1, reduction_WGTS_front, reduction_tot_front};
|
||||
double zs[5] = {z_RW_m, z_WGTS_start_m, z_WGTS_mid_m, z_WGTS_end_m, z_DPS_end_m};
|
||||
reduction_min = new double[n_regimes];
|
||||
double reduction_max;
|
||||
z_min_m = new double[n_regimes];
|
||||
double z_max_m;
|
||||
slopes = new double[n_regimes];
|
||||
for (int i = 0; i<n_regimes; i++) {
|
||||
reduction_min[i] = reds[i];
|
||||
reduction_max = reds[i+1];
|
||||
z_min_m[i] = zs[i];
|
||||
z_max_m = zs[i+1];
|
||||
slopes[i] = (reduction_max-reduction_min[i])/(z_max_m-z_min_m[i]);
|
||||
}
|
||||
}
|
||||
|
||||
inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||
double z_m = calc_z_m(loc_m);
|
||||
for (int i = (n_regimes-1); i>=0; i--) {
|
||||
if (z_m>z_min_m[i]) {
|
||||
double reduction_factor = reduction_min[i] + (z_m-z_min_m[i])*slopes[i];
|
||||
return reduction_factor * wgtsT2MaxDensity_m3;
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"T2_Population::calc_DensityTriangle: z_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline vec3 T2_Population::roll_x_ms() {
|
||||
double r_m = r_WGTS_m*sqrt(rngUni->random());
|
||||
double phi = rngUni->random()*2*pi;
|
||||
|
||||
double eta1, eta2, z_can_m;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
z_can_m = z_RW_m + eta1*(z_WGTS_end_m - z_RW_m);
|
||||
} while(eta2*wgtsT2MaxDensity_m3 > get_density_m3(vec3(0,0, z_can_m)));
|
||||
return vec3 (r_m*cos(phi) ,r_m*sin(phi) ,z_can_m);
|
||||
}
|
||||
|
||||
|
||||
#endif /* tritium2_population_h */
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
//
|
||||
// vec3_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 02.09.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "vec3_container.hpp"
|
||||
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, std::string load_path) {
|
||||
z_scale = Lin_Scale(z_RW_m, z_DPS_m, num_z_bins);
|
||||
z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins);
|
||||
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
||||
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
||||
int num_tot_bins = num_z_bins * num_r_bins * num_phi_bins;
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
//
|
||||
// velocity_container.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "velocity_container.hpp"
|
||||
|
||||
#include "read_system.h"
|
||||
|
||||
Velocity_Container::Velocity_Container(std::string load_path) {
|
||||
z_scale = Lin_Scale(z_rear_pp2, z_front_pp1, num_z_bins);
|
||||
z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins);
|
||||
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
||||
int num_tot_bins = num_z_bins * num_r_bins;
|
||||
vz_data = new double[num_tot_bins];
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef WGTS_KINEMATICS_H
|
||||
#define WGTS_KINEMATICS_H
|
||||
#ifndef wgts_kinematics_h
|
||||
#define wgts_kinematics_h
|
||||
|
||||
#include "velocity_container.hpp"
|
||||
#include "random_operations.h"
|
||||
|
||||
|
||||
class Base_Kinematics {
|
||||
UniRNG *rngUni;
|
||||
@@ -48,14 +48,9 @@ public:
|
||||
WGTS_Kinematics(double m_eV, double wgtsTemp_K, UniRNG *rngUni, NormalRNG *rngNormal) : Base_Kinematics(m_eV, wgtsTemp_K, rngUni, rngNormal), v_data(get_data_path() + "velocity.dat") {}
|
||||
|
||||
vec3 get_v_offset_ms(const vec3 &loc_m) {
|
||||
const double z = calc_z_m(loc_m);
|
||||
if (z < z_rear_pp2) {
|
||||
if (calc_z_m(loc_m)<z_WGTS_start_m) {
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
else if(z >= z_front_pp1){
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return v_data.get_v_ms (loc_m);
|
||||
}
|
||||
}
|
||||
@@ -73,4 +68,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif /* WGTS_KINEMATICS_H */
|
||||
#endif /* wgts_kinematics_h */
|
||||
|
||||
@@ -73,7 +73,7 @@ inline Zylindric_Cords::Zylindric_Cords(double z_min_m, double z_max_m, double r
|
||||
|
||||
inline void Zylindric_Cords::set_fromKatrinGeo() {
|
||||
this->z_min_m = z_RW_m;
|
||||
this->z_max_m = z_DPS_m;
|
||||
this->z_max_m = z_WGTS_end_m;
|
||||
this->r_max_m = r_WGTS_m;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import numpy as np
|
||||
|
||||
from functions.calculate_currents_from_karl import *
|
||||
from functions.calculate_density_from_karl import *
|
||||
import functions.plot_standards as pst
|
||||
|
||||
|
||||
def crossVelocityToCsv(
|
||||
filename_densities,
|
||||
filename_currents,
|
||||
filename_output,
|
||||
key_density,
|
||||
key_current):
|
||||
|
||||
jz = np.sum(particleCurrentZ(filename_currents, filename_densities, key_current),2)
|
||||
|
||||
total_density = getDensities(filename_densities, key_density)
|
||||
density = np.transpose(np.sum(total_density,3)[:,:,0])
|
||||
|
||||
velocity = np.zeros_like(jz)
|
||||
nr = velocity.shape[0]
|
||||
nz = velocity.shape[1]
|
||||
|
||||
velocity[:,0] = jz[:,0]/density[:,0]
|
||||
velocity[:,nz-1] = jz[:,nz-1]/density[:,nz-2]
|
||||
|
||||
velocity[:,1:nz-1] = 2*jz[:,1:nz-1]/(density[:,0:nz-2] + density[:,1:nz-1])
|
||||
si_to_cgs = 1E2
|
||||
|
||||
np.savetxt(
|
||||
filename_output,
|
||||
np.transpose(velocity*si_to_cgs),
|
||||
delimiter=",",
|
||||
header="velocity (cm/s), r to left, z to bottom")
|
||||
@@ -1,38 +0,0 @@
|
||||
import numpy as np
|
||||
import h5py as h5py
|
||||
import os
|
||||
import sys
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
import functions.calculate_currents_from_karl as cc
|
||||
import functions.plot_standards as pst
|
||||
|
||||
def longitudinalCurrentInDeltaE(
|
||||
filename_density,
|
||||
filename_current,
|
||||
Emin, Emax,
|
||||
z_indexs):
|
||||
|
||||
e_dict = {"key" : "/e-", "charge": -1.602E-19}
|
||||
#T3_dict = {"key" : "/T3+", "linestyle": '--', "label": "T$_3^+$", "charge": 1.602E-19}
|
||||
#T2_dict = {"key" : "/T2+", "linestyle": '--', "label": "T$_2^+$", "charge": 1.602E-19}
|
||||
#T_dict = {"key" : "/T+", "linestyle": '--', "label": "T$^+$", "charge": 1.602E-19}
|
||||
dicts = [e_dict]
|
||||
|
||||
pst.setRcParams()
|
||||
prop_cycle = plt.rcParams['axes.prop_cycle']
|
||||
colors = prop_cycle.by_key()['color']
|
||||
|
||||
for d in dicts:
|
||||
E_bins = cc.binBordersE(filename_current, d["key"])
|
||||
z_bins = cc.binBordersZ(filename_current, d["key"])
|
||||
|
||||
E_bin_min = np.abs((E_bins-Emin)).argmin()
|
||||
E_bin_max = np.abs((E_bins-Emax)).argmin()
|
||||
|
||||
I_z = cc.absoluteCurrentZ(filename_current, filename_density, d["key"])
|
||||
A = (4.5E-2)**2*np.pi
|
||||
for zi in z_indexs:
|
||||
j_E = np.sum(np.sum(I_z,axis=0)[zi,E_bin_min:E_bin_max])/A
|
||||
print("j_E: {:e} 1/(m^2*s)".format(j_E))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user