Added statistics method for terminization channels of particles
and elastic scattering for T3+. In this version benchmark old run.
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// 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 "sub_interaction_base.h"
|
||||||
|
#include "tabata_T3IT2_elastic.h"
|
||||||
|
|
||||||
|
|
||||||
|
class T3IT2_Elastic : public Sub_Interaction_Base {
|
||||||
|
Tabata_T3IT2_Elastic tcs_gen;
|
||||||
|
|
||||||
|
public:
|
||||||
|
T3IT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||||
|
|
||||||
|
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 loc_m = interPart->get_x_m();
|
||||||
|
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||||
|
|
||||||
|
vec3 vLab_ms = interPart->get_v_ms() - v2_ms;
|
||||||
|
vec3 v1_ms = roll_uniform_direction(rngUni) * calc_vec3_abs(vLab_ms) + v2_ms;
|
||||||
|
interPart->set_v_ms(v1_ms);
|
||||||
|
return InteractionOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* T3IT2_elastic_h */
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// 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 "sub_interaction_base.h"
|
||||||
|
#include "tabata_TIT2_elastic.h"
|
||||||
|
|
||||||
|
|
||||||
|
class TIT2_Elastic : public Sub_Interaction_Base {
|
||||||
|
Tabata_TIT2_Elastic tcs_gen;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TIT2_Elastic(Population_Base *T2Population, UniRNG *rngUni) : Sub_Interaction_Base(T2Population, rngUni) {};
|
||||||
|
|
||||||
|
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 loc_m = interPart->get_x_m();
|
||||||
|
vec3 v2_ms = Population->roll_v_ms(loc_m);
|
||||||
|
|
||||||
|
vec3 vLab_ms = interPart->get_v_ms() - v2_ms;
|
||||||
|
vec3 v1_ms = roll_uniform_direction(rngUni) * calc_vec3_abs(vLab_ms) + v2_ms;
|
||||||
|
interPart->set_v_ms(v1_ms);
|
||||||
|
return InteractionOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TIT2_elastic_h */
|
||||||
@@ -12,39 +12,24 @@
|
|||||||
#include "terminator_base.h"
|
#include "terminator_base.h"
|
||||||
|
|
||||||
|
|
||||||
class E_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
class Negative_Terminator : public Terminator_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
E_Terminator(const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(electron), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
Negative_Terminator(species this_species, long int max_interactions, double cut_off_energy_eV) : Terminator_Base(this_species, max_interactions, cut_off_energy_eV) {};
|
||||||
|
|
||||||
bool checkTermination (const Particle &movePart);
|
|
||||||
private:
|
private:
|
||||||
bool check_Wall(const Particle &movePart);
|
bool check_walls(const vec3 &loc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline bool E_Terminator::checkTermination (const Particle &movePart) {
|
inline bool Negative_Terminator::check_walls(const vec3 &loc_m) {
|
||||||
if (check_Wall(movePart)) {
|
double z_m = calc_z_m(loc_m);
|
||||||
return true;
|
double r_m = calc_r_m(loc_m);
|
||||||
}
|
|
||||||
if (check_Energy(movePart)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (check_MaxInteractions(movePart)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool E_Terminator::check_Wall(const Particle &movePart) {
|
|
||||||
vec3 loc_m = movePart.get_x_m();
|
|
||||||
double z_m = loc_m[2];
|
|
||||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
|
||||||
if (z_m <= z_RW_m) {
|
if (z_m <= z_RW_m) {
|
||||||
|
stats.n_rw += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (r_m >= r_WGTS_m) {
|
if (r_m >= r_WGTS_m) {
|
||||||
|
stats.n_radial += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include "eT3I_recombination.h"
|
#include "eT3I_recombination.h"
|
||||||
#include "eT3I_disexc.h"
|
#include "eT3I_disexc.h"
|
||||||
|
|
||||||
|
// TI impact
|
||||||
|
#include "TIT2_elastic.h"
|
||||||
|
|
||||||
// T2I impact
|
// T2I impact
|
||||||
#include "T2Ie_disexc.h"
|
#include "T2Ie_disexc.h"
|
||||||
#include "T2Ie_recombination.h"
|
#include "T2Ie_recombination.h"
|
||||||
@@ -29,6 +32,7 @@
|
|||||||
#include "T2IT2_cx.h"
|
#include "T2IT2_cx.h"
|
||||||
|
|
||||||
// T3I impact
|
// T3I impact
|
||||||
|
#include "T3IT2_elastic.h"
|
||||||
#include "T3Ie_recombination.h"
|
#include "T3Ie_recombination.h"
|
||||||
#include "T3Ie_disexc.h"
|
#include "T3Ie_disexc.h"
|
||||||
|
|
||||||
@@ -61,7 +65,7 @@ Interaction_Base* Interaction_Builder::build_electron(Population_Manager *Popula
|
|||||||
DCS_Base *exc_dcs;
|
DCS_Base *exc_dcs;
|
||||||
if (e_direction == 0) {
|
if (e_direction == 0) {
|
||||||
elastic_dcs = new Elastic_DCS(rngUni);
|
elastic_dcs = new Elastic_DCS(rngUni);
|
||||||
exc_dcs = new FourPi_DCS(rngUni);
|
exc_dcs = new ZeroPi_DCS(rngUni);
|
||||||
} else if (e_direction == 1) {
|
} else if (e_direction == 1) {
|
||||||
elastic_dcs = new FourPi_DCS(rngUni);
|
elastic_dcs = new FourPi_DCS(rngUni);
|
||||||
exc_dcs = new FourPi_DCS(rngUni);
|
exc_dcs = new FourPi_DCS(rngUni);
|
||||||
@@ -156,6 +160,8 @@ Interaction_Base* Interaction_Builder::build_tritium(Population_Manager *Populat
|
|||||||
|
|
||||||
Interaction_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
Interaction_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||||
Interaction_Base *TI_Interaction = new Interaction_Base(tritiumI, rngUni);
|
Interaction_Base *TI_Interaction = new Interaction_Base(tritiumI, rngUni);
|
||||||
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
|
//TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||||
return TI_Interaction;
|
return TI_Interaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +178,9 @@ Interaction_Base* Interaction_Builder::build_tritium2I(Population_Manager *Popul
|
|||||||
|
|
||||||
Interaction_Base* Interaction_Builder::build_tritium3I(Population_Manager *Populations, UniRNG *rngUni) {
|
Interaction_Base* Interaction_Builder::build_tritium3I(Population_Manager *Populations, UniRNG *rngUni) {
|
||||||
Interaction_Base *T3I_Interaction = new Interaction_Base(tritium3I, rngUni);
|
Interaction_Base *T3I_Interaction = new Interaction_Base(tritium3I, rngUni);
|
||||||
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
Population_Base *ePopulation = Populations->find(electron);
|
Population_Base *ePopulation = Populations->find(electron);
|
||||||
|
//T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||||
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
||||||
T3I_Interaction->add(new T3Ie_DissExc(ePopulation, rngUni));
|
T3I_Interaction->add(new T3Ie_DissExc(ePopulation, rngUni));
|
||||||
return T3I_Interaction ;
|
return T3I_Interaction ;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "particle.hpp"
|
#include "particle.hpp"
|
||||||
#include "error_types.h"
|
#include "error_types.h"
|
||||||
#include "kinematics.h"
|
#include "kinematics.h"
|
||||||
|
#include "error_types.h"
|
||||||
|
|
||||||
// See http://www.lnl.infn.it/~pisolo/alberto/Kinematics.pdf
|
// See http://www.lnl.infn.it/~pisolo/alberto/Kinematics.pdf
|
||||||
|
|
||||||
@@ -28,6 +29,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline Elastic_Kinematic_Base::Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV) {
|
inline Elastic_Kinematic_Base::Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV) {
|
||||||
|
if (m2_eV<m1_eV) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"Elastic_Kinematic_Base: m2_eV<m1_eV. \n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
this->m1_eV = m1_eV;
|
this->m1_eV = m1_eV;
|
||||||
this->m2_eV = m2_eV;
|
this->m2_eV = m2_eV;
|
||||||
sign = (m1_eV < m2_eV) ? 1 : -1;
|
sign = (m1_eV < m2_eV) ? 1 : -1;
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// neutral_terminator.h
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 04.07.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef neutral_terminator_h
|
|
||||||
#define neutral_terminator_h
|
|
||||||
|
|
||||||
#include "terminator_base.h"
|
|
||||||
#include "katrin_geo.h"
|
|
||||||
|
|
||||||
class Neutral_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
|
||||||
|
|
||||||
public:
|
|
||||||
Neutral_Terminator(species this_species, const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(this_species), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
|
||||||
|
|
||||||
bool checkTermination (const Particle &movePart);
|
|
||||||
private:
|
|
||||||
bool check_Wall(const Particle &movePart);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Neutral_Terminator::checkTermination (const Particle &movePart) {
|
|
||||||
if (check_Wall(movePart)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (check_Energy(movePart)) {
|
|
||||||
//return true;
|
|
||||||
}
|
|
||||||
if (check_MaxInteractions(movePart)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Neutral_Terminator::check_Wall(const Particle &movePart) {
|
|
||||||
return in_Katrin(movePart.get_x_m());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* neutral_terminator_h */
|
|
||||||
@@ -49,17 +49,20 @@ void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
|
|||||||
InteractionOut IntOut;
|
InteractionOut IntOut;
|
||||||
double macroSigma_m2;
|
double macroSigma_m2;
|
||||||
vec3 oldLoc_m;
|
vec3 oldLoc_m;
|
||||||
while (!terminatorPtr->checkTermination(curPart)) {
|
while (!terminatorPtr->check_terminlization(curPart)) {
|
||||||
oldLoc_m = curPart.get_x_m();
|
oldLoc_m = curPart.get_x_m();
|
||||||
macroSigma_m2 = interactionPtr->get_macroSigma_m2(curPart);
|
macroSigma_m2 = interactionPtr->get_macroSigma_m2(curPart);
|
||||||
moverPtr->move(&curPart, macroSigma_m2);
|
moverPtr->move(&curPart, macroSigma_m2);
|
||||||
if (!terminatorPtr->checkTermination(curPart)) {
|
if (terminatorPtr->check_terminlization(curPart)) {
|
||||||
|
break; // Don't double check terminlization, else n_double.
|
||||||
|
} else {
|
||||||
IntOut = interactionPtr->do_Interaction(&curPart);
|
IntOut = interactionPtr->do_Interaction(&curPart);
|
||||||
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
||||||
particle_queue->push(IntOut.get_new_particles()[i]);
|
particle_queue->push(IntOut.get_new_particles()[i]);
|
||||||
particle_queue->back().set_Id(get_new_id());
|
particle_queue->back().set_Id(get_new_id());
|
||||||
}
|
}
|
||||||
if (IntOut.get_delete_current()) {
|
if (IntOut.get_delete_current()) {
|
||||||
|
terminatorPtr->increase_n_reaction();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ public:
|
|||||||
Population_Manager *get_populations() {
|
Population_Manager *get_populations() {
|
||||||
return &populations;
|
return &populations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Terminator_Manager *get_terminators() {
|
||||||
|
return &terminators;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,45 +12,32 @@
|
|||||||
#include "terminator_base.h"
|
#include "terminator_base.h"
|
||||||
#include "katrin_geo.h"
|
#include "katrin_geo.h"
|
||||||
|
|
||||||
class Positive_Terminator : public Terminator_Base, private Energy_Terminator_Base, private MaxInteractions_Terminator_Base {
|
class PosNeu_Terminator : public Terminator_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Positive_Terminator(species this_species, const int &maxInteractions, const double &cutoffEnergy_eV) : Terminator_Base(this_species), Energy_Terminator_Base(cutoffEnergy_eV), MaxInteractions_Terminator_Base(maxInteractions) {};
|
PosNeu_Terminator(species this_species, long int max_interactions, double cut_off_energy_eV) : Terminator_Base(this_species, max_interactions, cut_off_energy_eV) {};
|
||||||
|
|
||||||
bool checkTermination (const Particle &movePart);
|
|
||||||
private:
|
private:
|
||||||
bool check_Wall(const Particle &movePart);
|
bool check_walls(const vec3 &loc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline bool Positive_Terminator::checkTermination (const Particle &movePart) {
|
inline bool PosNeu_Terminator::check_walls(const vec3 &loc_m) {
|
||||||
if (check_Wall(movePart)) {
|
double z_m = calc_z_m(loc_m);
|
||||||
return true;
|
double r_m = calc_r_m(loc_m);
|
||||||
}
|
|
||||||
if (check_Energy(movePart)) {
|
|
||||||
//return true;
|
|
||||||
}
|
|
||||||
if (check_MaxInteractions(movePart)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Positive_Terminator::check_Wall(const Particle &movePart) {
|
|
||||||
vec3 loc_m = movePart.get_x_m();
|
|
||||||
double z_m = loc_m[2];
|
|
||||||
double r_m = sqrt( pow(loc_m[0],2) + pow(loc_m[1],2) );
|
|
||||||
if (z_m <= z_RW_m) {
|
if (z_m <= z_RW_m) {
|
||||||
|
stats.n_rw += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (z_m >= z_WGTS_end_m) {
|
if (z_m >= z_WGTS_end_m) {
|
||||||
|
stats.n_dipole += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (r_m >= r_WGTS_m) {
|
if (r_m >= r_WGTS_m) {
|
||||||
|
stats.n_radial += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* positive_terminator_h */
|
#endif /* positive_terminator_h */
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ Simulation::Simulation() {
|
|||||||
looper.init(calc_seed(), calc_ID_offset(), calc_outfile_path());
|
looper.init(calc_seed(), calc_ID_offset(), calc_outfile_path());
|
||||||
init_pop_arrays();
|
init_pop_arrays();
|
||||||
}
|
}
|
||||||
Simulation::~Simulation() {
|
|
||||||
deconstruct_pop_arrays();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Simulation::init_pop_arrays() {
|
void Simulation::init_pop_arrays() { // Init C-arrays used for MPI-Allgather commands depending on Populations sizes
|
||||||
Population_Manager *populations = looper.get_populations();
|
Population_Manager *populations = looper.get_populations();
|
||||||
|
|
||||||
int number_pop_species = 0;
|
int number_pop_species = 0;
|
||||||
@@ -64,26 +61,15 @@ void Simulation::init_pop_arrays() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::deconstruct_pop_arrays() {
|
long int Simulation::calc_ID_offset() { // Calc ID_offset for individual MPI process
|
||||||
delete[] pop_species;
|
|
||||||
delete[] pop_array_lengths;
|
|
||||||
for (int i = 0; i<number_pop_species; i++) {
|
|
||||||
delete[] global_cum_time_s[i];
|
|
||||||
delete[] global_offset[i];
|
|
||||||
}
|
|
||||||
delete[] global_cum_time_s;
|
|
||||||
delete[] global_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
long int Simulation::calc_ID_offset() {
|
|
||||||
return numberTotalDecays * 1000 * mpi_rank;
|
return numberTotalDecays * 1000 * mpi_rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
long int Simulation::calc_seed() {
|
long int Simulation::calc_seed() { // Calc seed for individual MPI process
|
||||||
return seed + mpi_rank;
|
return seed + mpi_rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Simulation::calc_outfile_path() {
|
std::string Simulation::calc_outfile_path() { // Create .h5 file for individual MPI process
|
||||||
int dir_number;
|
int dir_number;
|
||||||
std::string dirname;
|
std::string dirname;
|
||||||
if (mpi_rank == 0) {
|
if (mpi_rank == 0) {
|
||||||
@@ -102,7 +88,7 @@ std::string Simulation::calc_outfile_path() {
|
|||||||
return filename.str();
|
return filename.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::calc_dir_number() {
|
int Simulation::calc_dir_number() { // Calc directory _num for MPI World
|
||||||
string parname = get_parameter_filenamepath();
|
string parname = get_parameter_filenamepath();
|
||||||
stringstream dirname;
|
stringstream dirname;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -113,7 +99,7 @@ int Simulation::calc_dir_number() {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Simulation::build_dirname(int dir_number) {
|
std::string Simulation::build_dirname(int dir_number) { // Concatanate directory name for MPI World
|
||||||
string parname = get_parameter_filenamepath();
|
string parname = get_parameter_filenamepath();
|
||||||
stringstream dirname;
|
stringstream dirname;
|
||||||
dirname.str(std::string());
|
dirname.str(std::string());
|
||||||
@@ -121,7 +107,7 @@ std::string Simulation::build_dirname(int dir_number) {
|
|||||||
return dirname.str();
|
return dirname.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::create_out_dir(std::string dirname) {
|
void Simulation::create_out_dir(std::string dirname) { // Create directory
|
||||||
if (mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
if (mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Simulation::create_out_dir: Could not create output directiory.\n outdirName = "<<dirname<<endl;
|
ss<<"Simulation::create_out_dir: Could not create output directiory.\n outdirName = "<<dirname<<endl;
|
||||||
@@ -129,21 +115,40 @@ void Simulation::create_out_dir(std::string dirname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Simulation::create_number_extension() {
|
std::string Simulation::create_number_extension() { // Calc h5 subindex for individual MPI process
|
||||||
int digits = to_string(mpi_size).length();
|
int digits = to_string(mpi_size).length();
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::setw(digits) << std::setfill('0') << mpi_rank;
|
ss << std::setw(digits) << std::setfill('0') << mpi_rank;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::doit() {
|
|
||||||
|
Simulation::~Simulation() {
|
||||||
|
deconstruct_pop_arrays();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Simulation::deconstruct_pop_arrays() { // Deallocate memory properly
|
||||||
|
delete[] pop_species;
|
||||||
|
delete[] pop_array_lengths;
|
||||||
|
for (int i = 0; i<number_pop_species; i++) {
|
||||||
|
delete[] global_cum_time_s[i];
|
||||||
|
delete[] global_offset[i];
|
||||||
|
}
|
||||||
|
delete[] global_cum_time_s;
|
||||||
|
delete[] global_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Simulation::doit() { // 2 Phase: 1. calc average densities, 2. actual simulate
|
||||||
do_cycle(popCalcDecays, popCalcStep, false);
|
do_cycle(popCalcDecays, popCalcStep, false);
|
||||||
if (mpi_rank == 0) {
|
if (mpi_rank == 0) {
|
||||||
cout<<"Population calculation done.\n";
|
cout<<"Population calculation done.\n";
|
||||||
}
|
}
|
||||||
do_cycle(numberTotalDecays, simulationStepWidth, true);
|
do_cycle(numberTotalDecays, simulationStepWidth, true);
|
||||||
|
print_term_stats();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Split up total number_total to different processes, average densities after step_size, set particle logging on off
|
||||||
void Simulation::do_cycle(long int number_total, long int step_size, bool logging) {
|
void Simulation::do_cycle(long int number_total, long int step_size, bool logging) {
|
||||||
if (number_total == 0) {
|
if (number_total == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -172,6 +177,7 @@ void Simulation::do_cycle(long int number_total, long int step_size, bool loggin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run a number of decays and sync populations afterwards
|
||||||
void Simulation::do_decays(const long int &number_decays, const bool &logging) {
|
void Simulation::do_decays(const long int &number_decays, const bool &logging) {
|
||||||
if (logging) {
|
if (logging) {
|
||||||
looper.do_loops(number_decays);
|
looper.do_loops(number_decays);
|
||||||
@@ -184,13 +190,13 @@ void Simulation::do_decays(const long int &number_decays, const bool &logging) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::sync_cpus() {
|
void Simulation::sync_cpus() { // Sync populations among MPI World
|
||||||
MPI_Allreduce(&number_local_decays, &number_global_decays, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
MPI_Allreduce(&number_local_decays, &number_global_decays, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
||||||
looper.set_global_decays(number_global_decays - number_local_decays);
|
looper.set_global_decays(number_global_decays - number_local_decays);
|
||||||
sync_populations();
|
sync_populations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::sync_populations() {
|
void Simulation::sync_populations() { // Sync new densities for each species and calculate new densities properly
|
||||||
Population_Manager *populations = looper.get_populations();
|
Population_Manager *populations = looper.get_populations();
|
||||||
Population_Container *container;
|
Population_Container *container;
|
||||||
double *global_delta_cumulated_time_s;
|
double *global_delta_cumulated_time_s;
|
||||||
@@ -230,9 +236,33 @@ void Simulation::sync_populations() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::do_statusUpdate() {
|
void Simulation::do_statusUpdate() { // Push current number of decays to std::cout
|
||||||
if (mpi_rank == 0) {
|
if (mpi_rank == 0) {
|
||||||
cout<<"Status: "<<number_global_decays<<"/"<<(numberTotalDecays+popCalcDecays)<<endl;
|
cout<<"Status: "<<number_global_decays<<"/"<<(numberTotalDecays+popCalcDecays)<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Simulation::print_term_stats() {
|
||||||
|
Terminator_Manager *terminators = looper.get_terminators();
|
||||||
|
vector<species> all_species = get_all_species_vector();
|
||||||
|
Termination_Stats local_stats, global_stats;
|
||||||
|
int local_array[7], global_array[7];
|
||||||
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
|
if (terminators->exists(*itr)) {
|
||||||
|
local_stats = terminators->find(*itr)->get_stats();
|
||||||
|
local_stats.to_array(local_array);
|
||||||
|
MPI_Allreduce(local_array, global_array, 7, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
||||||
|
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_reaction\t"<<global_stats.n_reaction<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ private:
|
|||||||
void sync_cpus();
|
void sync_cpus();
|
||||||
void sync_populations();
|
void sync_populations();
|
||||||
void do_statusUpdate();
|
void do_statusUpdate();
|
||||||
|
|
||||||
|
void print_term_stats();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// tabata_T3IT2_elastic.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 13.09.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef tabata_T3IT2_elastic_h
|
||||||
|
#define tabata_T3IT2_elastic_h
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
#include <cmath>
|
||||||
|
// TABATA:2000aa "Process 25
|
||||||
|
|
||||||
|
class Tabata_T3IT2_Elastic {
|
||||||
|
double sig0c1 = 1.16e-20;
|
||||||
|
double c2 = -8.12e-1;
|
||||||
|
double c3 = 4.29e-4;
|
||||||
|
double c4c2 = (-1.38e-1) - (-8.12e-1);
|
||||||
|
double c5 = 1.28e-2;
|
||||||
|
double c4c6 = (-1.38e-1) + 1.33;
|
||||||
|
double c7 = 8.67e-2;
|
||||||
|
double c4c8 = (-1.38e-1) + 2.18;
|
||||||
|
public:
|
||||||
|
Tabata_T3IT2_Elastic() {}
|
||||||
|
double get_TCS(const double &E_eV) {
|
||||||
|
double x_keV = E_eV*1e-3;
|
||||||
|
double fac1 = sig0c1*pow(E_eV/ERyd_eV, c2);
|
||||||
|
double fac2 = 1 + pow(x_keV/c3, c4c2);
|
||||||
|
double div = 1 + pow(x_keV/c5, c4c6) + pow(x_keV/c7, c4c8);
|
||||||
|
return fac1*fac2/div;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* tabata_T3IT2_elastic_h */
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// tabata_TIT2_elastic.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 13.09.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef tabata_TIT2_elastic_h
|
||||||
|
#define tabata_TIT2_elastic_h
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
#include <cmath>
|
||||||
|
// TABATA:2000aa "Process 10
|
||||||
|
|
||||||
|
class Tabata_TIT2_Elastic {
|
||||||
|
double sig0c1 = 5.74e-20;
|
||||||
|
double c2 = -5.765e-1;
|
||||||
|
double c3 = 2.79e-2;
|
||||||
|
double c2c4 = -5.765e-1 + 1.737;
|
||||||
|
public:
|
||||||
|
Tabata_TIT2_Elastic() {}
|
||||||
|
double get_TCS(const double &E_eV) {
|
||||||
|
double x_keV = E_eV*1e-3;
|
||||||
|
double fac = sig0c1*pow(E_eV/ERyd_eV, c2);
|
||||||
|
double div = 1 + pow(x_keV/c3, c2c4);
|
||||||
|
return fac/div;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* tabata_TIT2_elastic_h */
|
||||||
@@ -13,55 +13,112 @@
|
|||||||
#include "particle.hpp"
|
#include "particle.hpp"
|
||||||
#include "katrin_geo.h"
|
#include "katrin_geo.h"
|
||||||
|
|
||||||
|
struct Termination_Stats {
|
||||||
|
int n_total = 0;
|
||||||
|
int n_rw = 0;
|
||||||
|
int n_dipole = 0;
|
||||||
|
int n_radial = 0;
|
||||||
|
int n_max = 0;
|
||||||
|
int n_energy = 0;
|
||||||
|
int n_reaction = 0;
|
||||||
|
|
||||||
|
void to_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
||||||
|
array [0] = n_total;
|
||||||
|
array [1] = n_rw;
|
||||||
|
array [2] = n_dipole;
|
||||||
|
array [3] = n_radial;
|
||||||
|
array [4] = n_max;
|
||||||
|
array [5] = n_energy;
|
||||||
|
array [6] = n_reaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
||||||
|
n_total = array [0];
|
||||||
|
n_rw = array [1];
|
||||||
|
n_dipole = array [2];
|
||||||
|
n_radial = array [3];
|
||||||
|
n_max = array [4];
|
||||||
|
n_energy = array [5];
|
||||||
|
n_reaction = array [6];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Terminator_Base : public Process_Base {
|
class Terminator_Base : public Process_Base {
|
||||||
|
protected:
|
||||||
|
Termination_Stats stats;
|
||||||
|
|
||||||
|
private:
|
||||||
|
long int cur_Id_total = -1; // For counting num_tot
|
||||||
|
|
||||||
|
long int cur_Id_max = -1; // For max interactions
|
||||||
|
int max_interactions;
|
||||||
|
int interaction_counter = 0;
|
||||||
|
double cut_off_energy_eV;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Terminator_Base(species this_species) : Process_Base(this_species) {};
|
Terminator_Base(species this_species, int max_interactions, double cut_off_energy_eV) : Process_Base(this_species) {
|
||||||
virtual bool checkTermination (const Particle &movePart) = 0;
|
this->max_interactions = max_interactions;
|
||||||
|
this->cut_off_energy_eV = cut_off_energy_eV;
|
||||||
|
};
|
||||||
|
bool check_terminlization(const Particle &movePart);
|
||||||
|
Termination_Stats get_stats() {
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
void increase_n_reaction() {
|
||||||
|
stats.n_reaction += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void count_total(const long int &Id);
|
||||||
|
|
||||||
|
bool check_min_energy(const double &E_eV);
|
||||||
|
bool check_max_interactions(const long int &Id);
|
||||||
|
virtual bool check_walls(const vec3 &loc_m) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MaxInteractions_Terminator_Base {
|
inline bool Terminator_Base::check_terminlization(const Particle &movePart) {
|
||||||
int maxInteractions;
|
long int Id = movePart.get_Id();
|
||||||
|
count_total(Id);
|
||||||
int interactionsCount = 0;
|
return check_walls(movePart.get_x_m()) ||
|
||||||
int curId = 0;
|
check_min_energy(movePart.get_E_eV()) ||
|
||||||
|
check_max_interactions(Id);
|
||||||
public:
|
|
||||||
MaxInteractions_Terminator_Base(const int &maxInteractions) {
|
|
||||||
this->maxInteractions = maxInteractions;
|
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
bool check_MaxInteractions(const Particle &movePart) {
|
inline void Terminator_Base::count_total(const long int &Id) {
|
||||||
int Id = movePart.get_Id();
|
if (Id != cur_Id_total) {
|
||||||
if (Id != curId) {
|
cur_Id_total = Id;
|
||||||
curId = Id;
|
stats.n_total += 1;
|
||||||
interactionsCount = 0;
|
|
||||||
}
|
}
|
||||||
interactionsCount +=1;
|
}
|
||||||
if (interactionsCount >= maxInteractions) {
|
|
||||||
|
inline bool Terminator_Base::check_min_energy(const double &E_eV) {
|
||||||
|
if (E_eV<=cut_off_energy_eV) {
|
||||||
|
stats.n_energy += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Energy_Terminator_Base {
|
|
||||||
double cutoffEnergy_eV;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Energy_Terminator_Base(const double &cutoffEnergy_eV) {
|
|
||||||
this->cutoffEnergy_eV = cutoffEnergy_eV;
|
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
bool check_Energy(const Particle &movePart) {
|
inline bool Terminator_Base::check_max_interactions(const long int &Id) {
|
||||||
double E_eV = movePart.get_E_eV();
|
if (Id != cur_Id_max) {
|
||||||
if (E_eV<=cutoffEnergy_eV) {
|
cur_Id_max = Id;
|
||||||
|
interaction_counter = 0;
|
||||||
|
}
|
||||||
|
interaction_counter +=1;
|
||||||
|
if (interaction_counter >= max_interactions) {
|
||||||
|
stats.n_max += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* terminator_base_h */
|
#endif /* terminator_base_h */
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "terminator_builder.hpp"
|
#include "terminator_builder.hpp"
|
||||||
|
|
||||||
#include "electron_terminator.h"
|
#include "electron_terminator.h"
|
||||||
#include "neutral_terminator.h"
|
|
||||||
#include "positive_terminator.h"
|
#include "positive_terminator.h"
|
||||||
|
|
||||||
#include "read_system.h"
|
#include "read_system.h"
|
||||||
@@ -20,10 +19,10 @@ const double Terminator_Builder::cutoffEnergy_eV = load_parameter("cutoffEnergy_
|
|||||||
|
|
||||||
Terminator_Manager Terminator_Builder::build() {
|
Terminator_Manager Terminator_Builder::build() {
|
||||||
Terminator_Manager Terminator;
|
Terminator_Manager Terminator;
|
||||||
Terminator.add(new E_Terminator(maxInteractions, cutoffEnergy_eV));
|
Terminator.add(new Negative_Terminator(electron, maxInteractions, cutoffEnergy_eV));
|
||||||
//Terminator.add(new Neutral_Terminator(tritium, maxInteractions, cutoffEnergy_eV));
|
//Terminator.add(new Neutral_Terminator(tritium, maxInteractions, cutoffEnergy_eV));
|
||||||
Terminator.add(new Positive_Terminator(tritiumI, maxInteractions, cutoffEnergy_eV));
|
Terminator.add(new PosNeu_Terminator(tritiumI, maxInteractions, cutoffEnergy_eV));
|
||||||
Terminator.add(new Positive_Terminator(tritium2I, maxInteractions, cutoffEnergy_eV));
|
Terminator.add(new PosNeu_Terminator(tritium2I, maxInteractions, cutoffEnergy_eV));
|
||||||
Terminator.add(new Positive_Terminator(tritium3I, maxInteractions, cutoffEnergy_eV));
|
Terminator.add(new PosNeu_Terminator(tritium3I, maxInteractions, cutoffEnergy_eV));
|
||||||
return Terminator;
|
return Terminator;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user