Added statistics method for terminization channels of particles
and elastic scattering for T3+. In this version benchmark old run.
This commit is contained in:
@@ -13,55 +13,112 @@
|
||||
#include "particle.hpp"
|
||||
#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 {
|
||||
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:
|
||||
Terminator_Base(species this_species) : Process_Base(this_species) {};
|
||||
virtual bool checkTermination (const Particle &movePart) = 0;
|
||||
Terminator_Base(species this_species, int max_interactions, double cut_off_energy_eV) : Process_Base(this_species) {
|
||||
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 {
|
||||
int maxInteractions;
|
||||
|
||||
int interactionsCount = 0;
|
||||
int curId = 0;
|
||||
|
||||
public:
|
||||
MaxInteractions_Terminator_Base(const int &maxInteractions) {
|
||||
this->maxInteractions = maxInteractions;
|
||||
inline bool Terminator_Base::check_terminlization(const Particle &movePart) {
|
||||
long int Id = movePart.get_Id();
|
||||
count_total(Id);
|
||||
return check_walls(movePart.get_x_m()) ||
|
||||
check_min_energy(movePart.get_E_eV()) ||
|
||||
check_max_interactions(Id);
|
||||
}
|
||||
|
||||
inline void Terminator_Base::count_total(const long int &Id) {
|
||||
if (Id != cur_Id_total) {
|
||||
cur_Id_total = Id;
|
||||
stats.n_total += 1;
|
||||
}
|
||||
protected:
|
||||
bool check_MaxInteractions(const Particle &movePart) {
|
||||
int Id = movePart.get_Id();
|
||||
if (Id != curId) {
|
||||
curId = Id;
|
||||
interactionsCount = 0;
|
||||
}
|
||||
interactionsCount +=1;
|
||||
if (interactionsCount >= maxInteractions) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Terminator_Base::check_min_energy(const double &E_eV) {
|
||||
if (E_eV<=cut_off_energy_eV) {
|
||||
stats.n_energy += 1;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
class Energy_Terminator_Base {
|
||||
double cutoffEnergy_eV;
|
||||
|
||||
public:
|
||||
Energy_Terminator_Base(const double &cutoffEnergy_eV) {
|
||||
this->cutoffEnergy_eV = cutoffEnergy_eV;
|
||||
inline bool Terminator_Base::check_max_interactions(const long int &Id) {
|
||||
if (Id != cur_Id_max) {
|
||||
cur_Id_max = Id;
|
||||
interaction_counter = 0;
|
||||
}
|
||||
protected:
|
||||
bool check_Energy(const Particle &movePart) {
|
||||
double E_eV = movePart.get_E_eV();
|
||||
if (E_eV<=cutoffEnergy_eV) {
|
||||
return true;
|
||||
}
|
||||
interaction_counter +=1;
|
||||
if (interaction_counter >= max_interactions) {
|
||||
stats.n_max += 1;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* terminator_base_h */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user