Changed Population Container -> more precice calculation of time in cells.
This commit is contained in:
@@ -15,7 +15,8 @@ class T3Ie_Recombination : public Sub_Interaction_Base {
|
|||||||
public:
|
public:
|
||||||
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
T3Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : Sub_Interaction_Base(ePopulation, rngUni) {}
|
||||||
|
|
||||||
double get_microSigma_m2(const double &E_eV) {return Janev_eT3I_Recombination::get_TCS(E_eV);}
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
|
return Janev_eT3I_Recombination::get_TCS(E_eV);}
|
||||||
InteractionOut do_Interaction (Particle *interPart);
|
InteractionOut do_Interaction (Particle *interPart);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const size_t H5TB_Particle_Interface::sizes[8] = {
|
|||||||
void H5TB_Particle_Interface::create() {
|
void H5TB_Particle_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 8, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 8, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, NULL, 0, NULL);
|
chunkSize, nullptr, 0, nullptr);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Particle_Interface::create: Error creating.\n";
|
ss<<"H5TB_Particle_Interface::create: Error creating.\n";
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
pop_log_bin sample_log_cell = {0,0,0,0,0,0,0};
|
pop_bin sample_log_cell = {0,0,0,0,0,0,0};
|
||||||
const size_t H5TB_Population_Interface::size = sizeof(pop_log_bin);
|
const size_t H5TB_Population_Interface::size = sizeof(pop_bin);
|
||||||
const char *H5TB_Population_Interface::fieldNames[7] = {
|
const char *H5TB_Population_Interface::fieldNames[7] = {
|
||||||
"phys_time_s",
|
"phys_time_s",
|
||||||
"z_bin",
|
"z_bin",
|
||||||
@@ -24,13 +24,13 @@ const char *H5TB_Population_Interface::fieldNames[7] = {
|
|||||||
"cum_time",
|
"cum_time",
|
||||||
"offset"};
|
"offset"};
|
||||||
const size_t H5TB_Population_Interface::offset[7] = {
|
const size_t H5TB_Population_Interface::offset[7] = {
|
||||||
HOFFSET(pop_log_bin, phys_time_s),
|
HOFFSET(pop_bin, phys_time_s),
|
||||||
HOFFSET(pop_log_bin, z_bin),
|
HOFFSET(pop_bin, z_bin),
|
||||||
HOFFSET(pop_log_bin, r_bin),
|
HOFFSET(pop_bin, r_bin),
|
||||||
HOFFSET(pop_log_bin, phi_bin),
|
HOFFSET(pop_bin, phi_bin),
|
||||||
HOFFSET(pop_log_bin, E_bin),
|
HOFFSET(pop_bin, E_bin),
|
||||||
HOFFSET(pop_log_bin, cumulated_time_s),
|
HOFFSET(pop_bin, cumulated_time_s),
|
||||||
HOFFSET(pop_log_bin, offset)};
|
HOFFSET(pop_bin, offset)};
|
||||||
const hid_t H5TB_Population_Interface::fieldTypes[7] = {
|
const hid_t H5TB_Population_Interface::fieldTypes[7] = {
|
||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
@@ -53,7 +53,7 @@ const size_t H5TB_Population_Interface::sizes[7] = {
|
|||||||
void H5TB_Population_Interface::create() {
|
void H5TB_Population_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, NULL, 0, NULL);
|
chunkSize, nullptr, 0, nullptr);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Population_Interface::create: Error creating.\n";
|
ss<<"H5TB_Population_Interface::create: Error creating.\n";
|
||||||
@@ -61,7 +61,7 @@ void H5TB_Population_Interface::create() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void H5TB_Population_Interface::write(const pop_log_bin &log_bin) {
|
void H5TB_Population_Interface::write(const pop_bin &log_bin) {
|
||||||
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_bin);
|
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "hdf5.h"
|
#include "hdf5.h"
|
||||||
#include "hdf5_hl.h"
|
#include "hdf5_hl.h"
|
||||||
|
|
||||||
typedef struct pop_log_bin {
|
struct pop_bin {
|
||||||
double phys_time_s;
|
double phys_time_s;
|
||||||
int z_bin;
|
int z_bin;
|
||||||
int r_bin;
|
int r_bin;
|
||||||
@@ -24,7 +24,7 @@ typedef struct pop_log_bin {
|
|||||||
int E_bin;
|
int E_bin;
|
||||||
double cumulated_time_s;
|
double cumulated_time_s;
|
||||||
int offset;
|
int offset;
|
||||||
} pop_log_bin;
|
};
|
||||||
|
|
||||||
|
|
||||||
class H5TB_Population_Interface {
|
class H5TB_Population_Interface {
|
||||||
@@ -49,7 +49,7 @@ private:
|
|||||||
void create();
|
void create();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void write(const pop_log_bin &log_bin);
|
void write(const pop_bin &log_bin);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const size_t H5TB_Population_Meta_Interface::sizes[12] = {
|
|||||||
void H5TB_Population_Meta_Interface::create() {
|
void H5TB_Population_Meta_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, NULL, 0, NULL);
|
chunkSize, nullptr, 0, nullptr);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
|
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
|
||||||
|
|||||||
@@ -17,6 +17,23 @@
|
|||||||
#include "hdf5_hl.h"
|
#include "hdf5_hl.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct pop_bin_meta_info {
|
||||||
|
int z_bin;
|
||||||
|
int r_bin;
|
||||||
|
int phi_bin;
|
||||||
|
int E_bin;
|
||||||
|
double z_min_m;
|
||||||
|
double z_max_m;
|
||||||
|
double r_min_m;
|
||||||
|
double r_max_m;
|
||||||
|
double phi_min;
|
||||||
|
double phi_max;
|
||||||
|
double E_min_eV;
|
||||||
|
double E_max_eV;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class H5TB_Population_Meta_Interface {
|
class H5TB_Population_Meta_Interface {
|
||||||
static const size_t size;
|
static const size_t size;
|
||||||
static const char *fieldNames[12];
|
static const char *fieldNames[12];
|
||||||
@@ -40,7 +57,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void write(const pop_bin_meta_info &log_meta_bin);
|
void write(const pop_bin_meta_info &log_meta_bin);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* h5tb_population_meta_interface_hpp */
|
#endif /* h5tb_population_meta_interface_hpp */
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Injector : RNG_Base {
|
|||||||
Particle_Builder PartFac;
|
Particle_Builder PartFac;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Injector() : RNG_Base(NULL, NULL) {};
|
Injector() : RNG_Base(nullptr, nullptr) {};
|
||||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){};
|
Injector(UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal){};
|
||||||
|
|
||||||
Particle injectElectron (const int &newId);
|
Particle injectElectron (const int &newId);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#define interaction_base_hpp
|
#define interaction_base_hpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "sub_interaction_base.h"
|
#include "sub_interaction_base.h"
|
||||||
|
|
||||||
#include "process_base.h"
|
#include "process_base.h"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
typedef blitz::TinyVector<double,3> vec3;
|
typedef blitz::TinyVector<double,3> vec3;
|
||||||
|
|
||||||
|
|
||||||
inline double calc_vec3_abs(const vec3 &vec) {
|
inline double calc_vec3_abs(const vec3 &vec) {
|
||||||
return sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
return sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,293 +14,81 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "population4_container.hpp"
|
#include "population_container.hpp"
|
||||||
#include "size_container.hpp"
|
|
||||||
#include "lin_scale.h"
|
|
||||||
|
|
||||||
#include "population_base.h"
|
#include "population_base.h"
|
||||||
|
|
||||||
|
class Kinetic_Population : public Population_Base, private RNG_Base {
|
||||||
class Kinetic_Population : public Population_Base, protected RNG_Base{
|
Population_Container container;
|
||||||
Pop4_Container cumulated_times_s;
|
|
||||||
Pop4_Container number_annhilated;
|
|
||||||
|
|
||||||
Size_Container bin_sizes;
|
|
||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
double m_eV;
|
double m_eV;
|
||||||
|
|
||||||
public:
|
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);
|
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);
|
||||||
private:
|
|
||||||
//void init_containers(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
|
||||||
|
|
||||||
public:
|
|
||||||
double get_density_m3 (const vec3 &loc_m);
|
|
||||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||||
void decrease_denisty (const vec3 &loc_m, const double &energy_eV);
|
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||||
|
|
||||||
public:
|
double get_density_m3(const vec3 &loc_m);
|
||||||
vec3 roll_v_ms (const vec3 &loc_m);
|
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||||
private:
|
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||||
vec3 get_average_v_ms (const vec3 &loc_m);
|
|
||||||
vec3 roll_thermSpeed_ms(const vec3 &loc_m);
|
|
||||||
|
|
||||||
public:
|
virtual vec3 roll_v_ms (const vec3 &loc_m);
|
||||||
int get_number_E_bins();
|
|
||||||
double get_E_eV (const int &E_bin);
|
|
||||||
double get_density_m3(const vec3 &loc_m, const int &E_bin);
|
|
||||||
|
|
||||||
public:
|
virtual Population_Container *access_container();
|
||||||
meta_vec get_bins_meta_info();
|
|
||||||
bin_content_vec get_bins_content();
|
|
||||||
bin_count4 get_bin_count4();
|
|
||||||
void set_bins(bin_count4 bin_counts, bin_content_vec bin_contents);
|
|
||||||
private:
|
|
||||||
Lin_Scale get_z_scale();
|
|
||||||
Lin_Scale get_r_scale();
|
|
||||||
Lin_Scale calc_phi_scale();
|
|
||||||
Log_Scale get_E_scale();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_array_length();
|
|
||||||
double *get_cumulated_time_s_array();
|
|
||||||
double *get_offset_array();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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) : Population_Base(this_species), RNG_Base(rngUni, rngNormal),
|
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) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins) {
|
||||||
cumulated_times_s(num_z_bins, num_r_bins, num_phi_bins, num_E_bins),
|
|
||||||
number_annhilated(num_z_bins, num_r_bins, num_phi_bins, num_E_bins),
|
|
||||||
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
|
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
//init_containers(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
||||||
m_eV = get_species_mass(this_species);
|
m_eV = get_species_mass(this_species);
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
void Kinetic_Population::init_containers(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) {
|
inline void Kinetic_Population::increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||||
cumulated_times_s = Pop4_Container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());
|
||||||
number_annhilated = Pop4_Container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
||||||
bin_sizes = Size_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
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 vec3 &loc_m) {
|
inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
||||||
if (!in_Katrin(loc_m)) {
|
std::stringstream ss;
|
||||||
std::stringstream ss;
|
ss<<"Kinetic_Population::get_density_m3: method for non kinetic populations.\n";
|
||||||
ss<<"Kinetic_Population::get_density_m3: loc_m outside of Katrin.\n";
|
throw MyException(ss.str());
|
||||||
throw MyException(ss.str());
|
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Content 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Sum_bounds Kinetic_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||||
|
return container.get_sumation_bounds(loc_m);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
||||||
|
Sum_bounds bounds = container.get_sumation_bounds(loc_m);
|
||||||
|
double target = 0;
|
||||||
|
for (int E_bin = 0; E_bin<bounds.num_E_bins; E_bin++) {
|
||||||
|
target += get_density_m3(E_bin, bounds.loc_bins).n_m3;
|
||||||
}
|
}
|
||||||
double total_cumulated_time_s = cumulated_times_s.get_value_sum(loc_m);
|
target *= rngUni->random();
|
||||||
double total_annhilated = number_annhilated.get_value_sum(loc_m);
|
double current = 0;
|
||||||
|
for (int E_bin = 0; E_bin<bounds.num_E_bins; E_bin++) {
|
||||||
double physical_time_s = timer->get_physTime_s();
|
current += get_density_m3(E_bin, bounds.loc_bins).n_m3;
|
||||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
if (current >= target) {
|
||||||
double dens_m3 = total_cumulated_time_s/physical_time_s/bin_size_m3 - total_annhilated;
|
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
||||||
dens_m3 = (dens_m3 < 0) ? 0 : dens_m3;
|
|
||||||
return dens_m3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Kinetic_Population::increase_density(const Particle &upPart, const vec3 &oldLoc_m) {
|
|
||||||
double cell_time_s = bin_sizes.get_cell_length_m()/upPart.get_vAbs_ms();
|
|
||||||
double energy_eV = upPart.get_E_eV();
|
|
||||||
cumulated_times_s.increase_value(cell_time_s, upPart.get_x_m(), oldLoc_m, energy_eV);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const double &energy_eV) {
|
|
||||||
number_annhilated.increase_value(1, loc_m, energy_eV);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline vec3 Kinetic_Population::get_average_v_ms(const vec3 &loc_m) {
|
|
||||||
return vec3(0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec3 Kinetic_Population::roll_v_ms(const vec3 &loc_m) {
|
|
||||||
double total = get_density_m3(loc_m);
|
|
||||||
double target = rngUni->random() * total;
|
|
||||||
|
|
||||||
double physical_time_s = timer->get_physTime_s();
|
|
||||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
|
||||||
|
|
||||||
loc_bins loc_bin = cumulated_times_s.get_loc_bins(loc_m);
|
|
||||||
int z_bin = loc_bin.z_bin;
|
|
||||||
int r_bin = loc_bin.r_bin;
|
|
||||||
int phi_bin = loc_bin.phi_bin;
|
|
||||||
int num_E_bins = cumulated_times_s.get_num_E_bins();
|
|
||||||
|
|
||||||
double cumulated_time_s;
|
|
||||||
double offset;
|
|
||||||
double delta_density_m3;
|
|
||||||
double cum_density_m3 = 0;
|
|
||||||
for (int E_bin=0; E_bin<num_E_bins; E_bin++) {
|
|
||||||
cumulated_time_s = cumulated_times_s.get_value_by_bin(z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
offset = number_annhilated.get_value_by_bin(z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
delta_density_m3 = cumulated_time_s/physical_time_s/bin_size_m3 - offset;
|
|
||||||
delta_density_m3 = (delta_density_m3<0) ? 0 : delta_density_m3;
|
|
||||||
cum_density_m3 += delta_density_m3;
|
|
||||||
if (cum_density_m3>target) {
|
|
||||||
double lower = cumulated_times_s.get_lower_E_boarder_eV(E_bin);
|
|
||||||
double upper = cumulated_times_s.get_upper_E_boarder_eV(E_bin);
|
|
||||||
return lower + rngUni->random() * (upper-lower);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
||||||
throw MyException (ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Population_Container *Kinetic_Population::access_container() {
|
||||||
inline int Kinetic_Population::get_number_E_bins() {
|
return &container;
|
||||||
return cumulated_times_s.get_num_E_bins();
|
|
||||||
}
|
|
||||||
inline double Kinetic_Population::get_E_eV (const int &E_bin) {
|
|
||||||
return cumulated_times_s.get_E_scale().get_bin_mid(E_bin);
|
|
||||||
}
|
|
||||||
inline double Kinetic_Population::get_density_m3(const vec3 &loc_m, const int &E_bin) {
|
|
||||||
double physical_time_s = timer->get_physTime_s();
|
|
||||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
|
||||||
|
|
||||||
loc_bins loc_bin = cumulated_times_s.get_loc_bins(loc_m);
|
|
||||||
int z_bin = loc_bin.z_bin;
|
|
||||||
int r_bin = loc_bin.r_bin;
|
|
||||||
int phi_bin = loc_bin.phi_bin;
|
|
||||||
double cumulated_time_s = cumulated_times_s.get_value_by_bin(z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
double offset = number_annhilated.get_value_by_bin(z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
double density_m3 = cumulated_time_s/physical_time_s/bin_size_m3 - offset;
|
|
||||||
density_m3 = (density_m3<0) ? 0 : density_m3;
|
|
||||||
return density_m3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline meta_vec Kinetic_Population::get_bins_meta_info() {
|
|
||||||
Lin_Scale z_scale = get_z_scale();
|
|
||||||
Lin_Scale r_scale = get_r_scale();
|
|
||||||
Lin_Scale phi_scale = calc_phi_scale();
|
|
||||||
Log_Scale E_scale = get_E_scale();
|
|
||||||
|
|
||||||
meta_vec res;
|
|
||||||
pop_bin_meta_info temp_bin = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
temp_bin.z_min_m = z_scale.get_lower_scale_end();
|
|
||||||
for (int i_z=0; i_z<z_scale.get_number_bins(); i_z++) {
|
|
||||||
temp_bin.z_bin = i_z;
|
|
||||||
temp_bin.z_max_m = z_scale.get_upper_bin_bound(i_z);
|
|
||||||
temp_bin.r_min_m = r_scale.get_lower_scale_end();
|
|
||||||
for (int i_r=0; i_r<r_scale.get_number_bins(); i_r++) {
|
|
||||||
temp_bin.r_bin = i_r;
|
|
||||||
temp_bin.r_max_m = r_scale.get_upper_bin_bound(i_r);
|
|
||||||
temp_bin.phi_min = phi_scale.get_lower_scale_end();
|
|
||||||
for (int i_phi=0; i_phi<phi_scale.get_number_bins(); i_phi++) {
|
|
||||||
temp_bin.phi_bin = i_phi;
|
|
||||||
temp_bin.phi_max = phi_scale.get_upper_bin_bound(i_phi);
|
|
||||||
temp_bin.E_min_eV = E_scale.get_lower_scale_end();
|
|
||||||
for (int i_E=0; i_E<E_scale.get_number_bins(); i_E++) {
|
|
||||||
temp_bin.E_bin = i_E;
|
|
||||||
temp_bin.E_max_eV = E_scale.get_upper_bin_bound(i_E);
|
|
||||||
res.push_back(temp_bin);
|
|
||||||
temp_bin.E_min_eV = temp_bin.E_max_eV;
|
|
||||||
}
|
|
||||||
temp_bin.phi_min = temp_bin.phi_max;
|
|
||||||
}
|
|
||||||
temp_bin.r_min_m = temp_bin.r_max_m;
|
|
||||||
}
|
|
||||||
temp_bin.z_min_m = temp_bin.z_max_m;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bin_content_vec Kinetic_Population::get_bins_content() {
|
|
||||||
Lin_Scale z_scale = get_z_scale();
|
|
||||||
Lin_Scale r_scale = get_r_scale();
|
|
||||||
Lin_Scale phi_scale = calc_phi_scale();
|
|
||||||
Log_Scale E_scale = get_E_scale();
|
|
||||||
|
|
||||||
bin_content_vec res;
|
|
||||||
pop_bin_content temp_bin = {0, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
for (int i_z=0; i_z < z_scale.get_number_bins(); i_z++) {
|
|
||||||
temp_bin.z_bin = i_z;
|
|
||||||
for (int i_r=0; i_r < r_scale.get_number_bins(); i_r++) {
|
|
||||||
temp_bin.r_bin = i_r;
|
|
||||||
for (int i_phi=0; i_phi < phi_scale.get_number_bins(); i_phi++) {
|
|
||||||
temp_bin.phi_bin = i_phi;
|
|
||||||
for (int i_E=0; i_E < E_scale.get_number_bins(); i_E++) {
|
|
||||||
temp_bin.E_bin = i_E;
|
|
||||||
temp_bin.cumulated_time_s = cumulated_times_s.get_value_by_bin(i_z, i_r, i_phi, i_E);
|
|
||||||
temp_bin.offset = number_annhilated.get_value_by_bin(i_z, i_r, i_phi, i_E);
|
|
||||||
res.push_back(temp_bin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bin_count4 Kinetic_Population::get_bin_count4() {
|
|
||||||
bin_count4 res;
|
|
||||||
res[0] = get_z_scale().get_number_bins();
|
|
||||||
res[1] = get_r_scale().get_number_bins();
|
|
||||||
res[2] = calc_phi_scale().get_number_bins();
|
|
||||||
res[3] = get_E_scale().get_number_bins();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Kinetic_Population::set_bins(bin_count4 bin_counts, bin_content_vec bin_contents) {
|
|
||||||
int num_z_bins = bin_counts[0];
|
|
||||||
int num_r_bins = bin_counts[1];
|
|
||||||
int num_phi_bins = bin_counts[2];
|
|
||||||
int num_E_bins = bin_counts[3];
|
|
||||||
|
|
||||||
cumulated_times_s = Pop4_Container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
||||||
number_annhilated = Pop4_Container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
||||||
bin_sizes = Size_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
//init_containers(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
||||||
|
|
||||||
int z_bin, r_bin, phi_bin, E_bin;
|
|
||||||
double cumulated_time_s, offset;
|
|
||||||
for(bin_content_vec::iterator itr = bin_contents.begin(); itr != bin_contents.end(); itr++) {
|
|
||||||
z_bin = (*itr).z_bin;
|
|
||||||
r_bin = (*itr).r_bin;
|
|
||||||
phi_bin = (*itr).phi_bin;
|
|
||||||
E_bin = (*itr).E_bin;
|
|
||||||
cumulated_time_s = (*itr).cumulated_time_s;
|
|
||||||
offset = (*itr).offset;
|
|
||||||
cumulated_times_s.set_value_by_bin(cumulated_time_s, z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
number_annhilated.set_value_by_bin(offset, z_bin, r_bin, phi_bin, E_bin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Kinetic_Population::get_z_scale() {
|
|
||||||
return cumulated_times_s.get_z_scale();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Kinetic_Population::get_r_scale() {
|
|
||||||
return cumulated_times_s.get_r_scale();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Kinetic_Population::calc_phi_scale() {
|
|
||||||
return cumulated_times_s.calc_phi_scale();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Log_Scale Kinetic_Population::get_E_scale() {
|
|
||||||
return cumulated_times_s.get_E_scale();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int Kinetic_Population::get_array_length() {
|
|
||||||
return cumulated_times_s.get_total_data_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double *Kinetic_Population::get_cumulated_time_s_array() {
|
|
||||||
return cumulated_times_s.get_array();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double *Kinetic_Population::get_offset_array() {
|
|
||||||
return number_annhilated.get_array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* energetic_base_h */
|
#endif /* energetic_base_h */
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public:
|
|||||||
Lin_Scale() {number_bins=0;};
|
Lin_Scale() {number_bins=0;};
|
||||||
Lin_Scale(const double &min_x, const double &max_x, const int &number_bins);
|
Lin_Scale(const double &min_x, const double &max_x, const int &number_bins);
|
||||||
~Lin_Scale() {};
|
~Lin_Scale() {};
|
||||||
Scale *clone() {return new Lin_Scale(*this);}
|
|
||||||
|
|
||||||
double get_lower_scale_end();
|
double get_lower_scale_end();
|
||||||
double get_upper_scale_end();
|
double get_upper_scale_end();
|
||||||
|
double get_delta();
|
||||||
int get_number_bins();
|
int get_number_bins();
|
||||||
|
|
||||||
int calc_index(const double &x);
|
int calc_index(const double &x);
|
||||||
@@ -58,7 +58,9 @@ inline double Lin_Scale::get_lower_scale_end() {
|
|||||||
inline double Lin_Scale::get_upper_scale_end() {
|
inline double Lin_Scale::get_upper_scale_end() {
|
||||||
return max_x;
|
return max_x;
|
||||||
}
|
}
|
||||||
|
inline double Lin_Scale::get_delta() {
|
||||||
|
return delta_x;
|
||||||
|
}
|
||||||
inline int Lin_Scale::get_number_bins() {
|
inline int Lin_Scale::get_number_bins() {
|
||||||
return number_bins;
|
return number_bins;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public:
|
|||||||
lin_scale = Lin_Scale(std::log10(min_x), std::log10(max_x), number_bins);
|
lin_scale = Lin_Scale(std::log10(min_x), std::log10(max_x), number_bins);
|
||||||
};
|
};
|
||||||
~Log_Scale() {};
|
~Log_Scale() {};
|
||||||
Scale *clone() {return new Log_Scale(*this);}
|
|
||||||
|
|
||||||
double get_lower_scale_end();
|
double get_lower_scale_end();
|
||||||
double get_upper_scale_end();
|
double get_upper_scale_end();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ include $(HOMEBASE)/src/makeinclude/include.mak
|
|||||||
|
|
||||||
OBJS := particle_looper.o \
|
OBJS := particle_looper.o \
|
||||||
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
tcs_container.o dcs_theta_container.o dcs_ionization_container.o \
|
||||||
population3_container.o population4_container.o velocity_container.o size_container.o \
|
population_container.o velocity_container.o size_container.o \
|
||||||
thermalPop_container.o energeticPop_container.o \
|
thermalPop_container.o energeticPop_container.o \
|
||||||
particle.o injector.o timer.o katrin_fields.o \
|
particle.o injector.o timer.o katrin_fields.o \
|
||||||
h5_file.o logger_builder.o population_load_saver.o \
|
h5_file.o logger_builder.o population_load_saver.o \
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
//
|
|
||||||
// population3_container.cpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 24.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "population3_container.hpp"
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
|
|
||||||
z_scale = Lin_Scale(z_RW_m, z_WGTS_end_m, num_z_bins);
|
|
||||||
r_scale = Lin_Scale(0,r_WGTS_m, num_r_bins);
|
|
||||||
phi_scale = Lin_Scale(0, 2*pi, num_phi_bins);
|
|
||||||
|
|
||||||
r_offset = num_phi_bins;
|
|
||||||
z_offset = r_offset*num_r_bins;
|
|
||||||
total_data_size = num_z_bins*z_offset;
|
|
||||||
data = new double[total_data_size];
|
|
||||||
}
|
|
||||||
|
|
||||||
Pop3_Container::~Pop3_Container() {
|
|
||||||
delete[] data;
|
|
||||||
};
|
|
||||||
|
|
||||||
Pop3_Container::Pop3_Container(const Pop3_Container& other) {
|
|
||||||
z_scale = other.z_scale;
|
|
||||||
r_scale = other.r_scale;
|
|
||||||
phi_scale = other.phi_scale;
|
|
||||||
z_offset = other.z_offset;
|
|
||||||
r_offset = other.r_offset;
|
|
||||||
total_data_size = other.total_data_size;
|
|
||||||
|
|
||||||
for (int i=0; i<total_data_size; i++) {
|
|
||||||
data[i] = other.data[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pop3_Container& Pop3_Container::operator=(const Pop3_Container& other) {
|
|
||||||
Pop3_Container tmp(other);
|
|
||||||
swap(z_scale, tmp.z_scale);
|
|
||||||
swap(r_scale, tmp.r_scale);
|
|
||||||
swap(phi_scale, tmp.phi_scale);
|
|
||||||
swap(z_offset, tmp.z_offset);
|
|
||||||
swap(r_offset, tmp.r_offset);
|
|
||||||
swap(total_data_size, tmp.total_data_size);
|
|
||||||
swap(data, tmp.data);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Pop3_Container::increase_value(const double &value, const vec3 &loc_m) {
|
|
||||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
int data_bin = calc_data_bin(z_bin, r_bin, phi_bin);
|
|
||||||
data[data_bin] += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pop3_Container::increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m) {
|
|
||||||
double z_min_m = calc_z_m(loc1_m);
|
|
||||||
double z_max_m = calc_z_m(loc2_m);
|
|
||||||
if (z_max_m < z_min_m) {
|
|
||||||
swap(z_min_m, z_max_m);
|
|
||||||
}
|
|
||||||
int min_z_bin = z_scale.calc_index(z_min_m);
|
|
||||||
int max_z_bin = z_scale.calc_index(z_max_m);
|
|
||||||
// No r/phi movement, else need to calculate more exactly
|
|
||||||
double r = calc_r_m(loc1_m);
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(r));
|
|
||||||
double phi = calc_phi(loc1_m);
|
|
||||||
int phi_bin = phi_scale.calc_index(phi);
|
|
||||||
int data_bin;
|
|
||||||
for (int z_bin = min_z_bin; z_bin<=max_z_bin; z_bin++) {
|
|
||||||
data_bin = calc_data_bin(z_bin, r_bin, phi_bin);
|
|
||||||
data[data_bin] += value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Pop3_Container::get_value (vec3 loc_m) {
|
|
||||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
int data_bin = calc_data_bin(z_bin, r_bin, phi_bin);
|
|
||||||
return data[data_bin];
|
|
||||||
}
|
|
||||||
|
|
||||||
int Pop3_Container::calc_data_bin(int z_bin, int r_bin, int phi_bin) {
|
|
||||||
return z_offset*z_bin + r_offset*r_bin + phi_bin;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
//
|
|
||||||
// population3_container.hpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 24.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef population3_container_hpp
|
|
||||||
#define population3_container_hpp
|
|
||||||
|
|
||||||
#include "lin_scale.h"
|
|
||||||
#include "kinematics.h"
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Pop3_Container {
|
|
||||||
double *data;
|
|
||||||
Lin_Scale z_scale, r_scale, phi_scale;
|
|
||||||
int z_offset, r_offset, total_data_size;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
//Pop3_Container() {};
|
|
||||||
Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins);
|
|
||||||
|
|
||||||
~Pop3_Container();
|
|
||||||
Pop3_Container(const Pop3_Container& other);
|
|
||||||
Pop3_Container& operator=(const Pop3_Container& other);
|
|
||||||
|
|
||||||
void increase_value(const double &value, const vec3 &loc_m);
|
|
||||||
void increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m);
|
|
||||||
double get_value (vec3 loc_m);
|
|
||||||
|
|
||||||
void set_value_by_bin(double value, int z_bin, int r_bin, int phi_bin) {data[calc_data_bin(z_bin, r_bin, phi_bin)] = value;}
|
|
||||||
double get_value_by_bin(int z_bin, int r_bin, int phi_bin) {
|
|
||||||
return data[calc_data_bin(z_bin, r_bin, phi_bin)];
|
|
||||||
}
|
|
||||||
|
|
||||||
Lin_Scale get_z_scale(){return z_scale;}
|
|
||||||
Lin_Scale get_r_scale(){return r_scale;}
|
|
||||||
Lin_Scale calc_phi_scale(){return phi_scale;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int calc_data_bin(int z_bin, int r_bin, int phi_bin);
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_total_data_size() {return total_data_size;}
|
|
||||||
double *get_array() {return data;}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* population3_container_hpp */
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
//
|
|
||||||
// population4_container.cpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 11.06.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "population4_container.hpp"
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
Pop4_Container::Pop4_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) {
|
|
||||||
z_scale = Lin_Scale(z_RW_m, z_WGTS_end_m, num_z_bins);
|
|
||||||
r_scale = Lin_Scale(0,r_WGTS_m, num_r_bins);
|
|
||||||
phi_scale = Lin_Scale(0, 2*pi, num_phi_bins);
|
|
||||||
E_scale = Log_Scale(scale_start, scale_end, num_E_bins);
|
|
||||||
|
|
||||||
phi_offset = num_E_bins;
|
|
||||||
r_offset = phi_offset * num_phi_bins;
|
|
||||||
z_offset = r_offset*num_r_bins;
|
|
||||||
total_data_size = num_z_bins*z_offset;
|
|
||||||
|
|
||||||
data = new double[total_data_size];
|
|
||||||
}
|
|
||||||
|
|
||||||
Pop4_Container::~Pop4_Container() {
|
|
||||||
delete[] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pop4_Container::Pop4_Container(const Pop4_Container& other) {
|
|
||||||
z_scale = other.z_scale;
|
|
||||||
r_scale = other.r_scale;
|
|
||||||
phi_scale = other.phi_scale;
|
|
||||||
E_scale = other.E_scale;
|
|
||||||
|
|
||||||
z_offset = other.z_offset;
|
|
||||||
r_offset = other.r_offset;
|
|
||||||
phi_offset = other.phi_offset;
|
|
||||||
total_data_size = other.total_data_size;
|
|
||||||
|
|
||||||
for (int i=0; i<total_data_size; i++) {
|
|
||||||
data[i] = other.data[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pop4_Container& Pop4_Container::operator=(const Pop4_Container& other) {
|
|
||||||
Pop4_Container tmp(other);
|
|
||||||
swap(z_scale, tmp.z_scale);
|
|
||||||
swap(r_scale, tmp.r_scale);
|
|
||||||
swap(phi_scale, tmp.phi_scale);
|
|
||||||
swap(E_scale, tmp.E_scale);
|
|
||||||
swap(z_offset, tmp.z_offset);
|
|
||||||
swap(r_offset, tmp.r_offset);
|
|
||||||
swap(phi_offset, tmp.phi_offset);
|
|
||||||
swap(total_data_size, tmp.total_data_size);
|
|
||||||
swap(data, tmp.data);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pop4_Container::increase_value(const double &value, const vec3 &loc_m, const double &E_eV) {
|
|
||||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
int E_bin = E_scale.calc_index(E_eV);
|
|
||||||
|
|
||||||
data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)] += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pop4_Container::increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m, const double &E_eV) {
|
|
||||||
double z_min_m = calc_z_m(loc1_m);
|
|
||||||
double z_max_m = calc_z_m(loc2_m);
|
|
||||||
if (z_max_m < z_min_m) {
|
|
||||||
swap(z_min_m, z_max_m);
|
|
||||||
}
|
|
||||||
int min_z_index = z_scale.calc_index(z_min_m);
|
|
||||||
int max_z_index = z_scale.calc_index(z_max_m);
|
|
||||||
// No r/phi movement, else need to calculate more exactly
|
|
||||||
double r = calc_r_m(loc1_m);
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(r));
|
|
||||||
double phi = calc_phi(loc1_m);
|
|
||||||
int phi_bin = phi_scale.calc_index(phi);
|
|
||||||
int E_bin = E_scale.calc_index(E_eV);
|
|
||||||
|
|
||||||
for (int z_bin = min_z_index; z_bin<=max_z_index; z_bin++) {
|
|
||||||
data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)] += value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Pop4_Container::get_value(const vec3 &loc_m, const double &E_eV) {
|
|
||||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
int E_bin = E_scale.calc_index(E_eV);
|
|
||||||
return data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)];
|
|
||||||
}
|
|
||||||
|
|
||||||
double Pop4_Container::get_value_sum(const vec3 &loc_m) {
|
|
||||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
int data_bin_start = calc_data_bin(z_bin, r_bin, phi_bin, 0);
|
|
||||||
int data_bin_end = calc_data_bin(z_bin, r_bin, phi_bin, E_scale.get_number_bins());
|
|
||||||
double sum = 0;
|
|
||||||
for (int data_bin=data_bin_start; data_bin<data_bin_end; data_bin++) {
|
|
||||||
sum += data[data_bin];
|
|
||||||
}
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
loc_bins Pop4_Container::get_loc_bins(const vec3 &loc_m) {
|
|
||||||
loc_bins res;
|
|
||||||
res.z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
|
||||||
res.r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
|
||||||
res.phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Pop4_Container::calc_data_bin(int z_bin, int r_bin, int phi_bin, int E_bin) {
|
|
||||||
return z_offset*z_bin + r_offset*r_bin + phi_offset*phi_bin + E_bin;
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
//
|
|
||||||
// population4_container.hpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 11.06.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef population4_container_hpp
|
|
||||||
#define population4_container_hpp
|
|
||||||
|
|
||||||
#include "log_scale.h"
|
|
||||||
#include "katrin_geo.h"
|
|
||||||
#include "timer.hpp"
|
|
||||||
|
|
||||||
struct loc_bins {
|
|
||||||
int z_bin;
|
|
||||||
int r_bin;
|
|
||||||
int phi_bin;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Pop4_Container {
|
|
||||||
double *data;
|
|
||||||
Lin_Scale z_scale, r_scale, phi_scale;
|
|
||||||
Log_Scale E_scale;
|
|
||||||
int z_offset, r_offset, phi_offset, total_data_size;
|
|
||||||
public:
|
|
||||||
//Pop4_Container() {};
|
|
||||||
Pop4_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
|
||||||
|
|
||||||
~Pop4_Container();
|
|
||||||
Pop4_Container(const Pop4_Container& other);
|
|
||||||
Pop4_Container& operator=(const Pop4_Container& other);
|
|
||||||
|
|
||||||
void increase_value(const double &value, const vec3 &loc_m, const double &E_eV);
|
|
||||||
void increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m, const double &E_eV);
|
|
||||||
double get_value(const vec3 &loc_m, const double &E_eV);
|
|
||||||
double get_value_sum(const vec3 &loc_m);
|
|
||||||
|
|
||||||
void set_value_by_bin(double value, int z_bin, int r_bin, int phi_bin, int E_bin) {data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)] = value;}
|
|
||||||
double get_value_by_bin(int z_bin, int r_bin, int phi_bin, int E_bin) {return data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)];}
|
|
||||||
|
|
||||||
loc_bins get_loc_bins(const vec3 &loc_m);
|
|
||||||
int get_num_E_bins() {return E_scale.get_number_bins();}
|
|
||||||
|
|
||||||
double get_lower_E_boarder_eV(int E_bin) {return E_scale.get_lower_bin_bound(E_bin);}
|
|
||||||
double get_upper_E_boarder_eV(int E_bin) {return E_scale.get_upper_bin_bound(E_bin);}
|
|
||||||
|
|
||||||
Lin_Scale get_z_scale(){return z_scale;}
|
|
||||||
Lin_Scale get_r_scale(){return r_scale;}
|
|
||||||
Lin_Scale calc_phi_scale(){return phi_scale;}
|
|
||||||
Log_Scale get_E_scale(){return E_scale;}
|
|
||||||
|
|
||||||
int calc_data_bin(int z_bin, int r_bin, int phi_bin, int E_bin);
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_total_data_size() {return total_data_size;}
|
|
||||||
double *get_array() {return data;}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* population4_container_hpp */
|
|
||||||
@@ -17,36 +17,7 @@
|
|||||||
#include "kinematics.h"
|
#include "kinematics.h"
|
||||||
#include "process_base.h"
|
#include "process_base.h"
|
||||||
|
|
||||||
typedef blitz::TinyVector<double,3> vec3;
|
#include "population_container.hpp"
|
||||||
typedef blitz::TinyVector<int,3> bin_count3;
|
|
||||||
typedef blitz::TinyVector<int,4> bin_count4;
|
|
||||||
|
|
||||||
typedef struct pop_bin_meta_info {
|
|
||||||
int z_bin;
|
|
||||||
int r_bin;
|
|
||||||
int phi_bin;
|
|
||||||
int E_bin;
|
|
||||||
double z_min_m;
|
|
||||||
double z_max_m;
|
|
||||||
double r_min_m;
|
|
||||||
double r_max_m;
|
|
||||||
double phi_min;
|
|
||||||
double phi_max;
|
|
||||||
double E_min_eV;
|
|
||||||
double E_max_eV;
|
|
||||||
} pop_bin_meta;
|
|
||||||
|
|
||||||
typedef struct pop_bin_content {
|
|
||||||
int z_bin;
|
|
||||||
int r_bin;
|
|
||||||
int phi_bin;
|
|
||||||
int E_bin;
|
|
||||||
double cumulated_time_s;
|
|
||||||
int offset;
|
|
||||||
} pop_log_bins;
|
|
||||||
|
|
||||||
typedef std::vector<pop_bin_meta_info> meta_vec;
|
|
||||||
typedef std::vector<pop_bin_content> bin_content_vec;
|
|
||||||
|
|
||||||
|
|
||||||
class Population_Base : public Process_Base {
|
class Population_Base : public Process_Base {
|
||||||
@@ -54,28 +25,16 @@ class Population_Base : public Process_Base {
|
|||||||
public:
|
public:
|
||||||
Population_Base(species this_species) : Process_Base(this_species) {};
|
Population_Base(species this_species) : Process_Base(this_species) {};
|
||||||
|
|
||||||
virtual double get_density_m3 (const vec3 &loc_m) = 0;
|
|
||||||
virtual void increase_density (const Particle &upPart, const vec3 &oldLoc_m) = 0;
|
virtual void increase_density (const Particle &upPart, const vec3 &oldLoc_m) = 0;
|
||||||
virtual void decrease_denisty (const vec3 &oldLoc_m, const double &energy_eV) = 0;
|
virtual void decrease_denisty (const vec3 &loc_m, const double &E_eV) = 0;
|
||||||
|
|
||||||
|
virtual double get_density_m3(const vec3 &loc_m) = 0;
|
||||||
|
virtual Content get_density_m3(const int &E_bin, const Bins &loc_bins) = 0;
|
||||||
|
virtual Sum_bounds get_sumation_bounds(const vec3 &loc_m) = 0;
|
||||||
|
|
||||||
virtual vec3 get_average_v_ms (const vec3 &loc_m) = 0;
|
|
||||||
virtual vec3 roll_v_ms (const vec3 &loc_m) = 0;
|
virtual vec3 roll_v_ms (const vec3 &loc_m) = 0;
|
||||||
|
|
||||||
// For integrating over energy
|
virtual Population_Container *access_container() = 0;
|
||||||
virtual int get_number_E_bins() = 0;
|
|
||||||
virtual double get_E_eV (const int &E_bin) = 0;
|
|
||||||
virtual double get_density_m3(const vec3 &loc_m, const int &E_bin) = 0;
|
|
||||||
|
|
||||||
// For logging
|
|
||||||
virtual meta_vec get_bins_meta_info() = 0;
|
|
||||||
virtual bin_content_vec get_bins_content() = 0;
|
|
||||||
virtual bin_count4 get_bin_count4() = 0;
|
|
||||||
virtual void set_bins(bin_count4 bin_counts, bin_content_vec bin_contents) = 0;
|
|
||||||
|
|
||||||
// For synchronizing with other cpus
|
|
||||||
virtual int get_array_length() = 0;
|
|
||||||
virtual double *get_cumulated_time_s_array() = 0;
|
|
||||||
virtual double *get_offset_array() = 0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
//
|
||||||
|
// 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>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
Population_Container::Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins) {
|
||||||
|
init_scales(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
||||||
|
init_bin_offsets();
|
||||||
|
init_content_arrays();
|
||||||
|
init_size_array();
|
||||||
|
}
|
||||||
|
|
||||||
|
Population_Container::~Population_Container() {
|
||||||
|
delete[] cum_times_s;
|
||||||
|
delete[] offsets;
|
||||||
|
delete[] size_data_m3;
|
||||||
|
}
|
||||||
|
Population_Container::Population_Container(const Population_Container& other) : cum_times_s(nullptr), offsets(nullptr), size_data_m3(nullptr) {
|
||||||
|
*this = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
Population_Container &Population_Container::operator=(const Population_Container& other) {
|
||||||
|
scales = other.scales;
|
||||||
|
E_scale = other.E_scale;
|
||||||
|
bin_offsets = other.bin_offsets;
|
||||||
|
data_size = other.data_size;
|
||||||
|
|
||||||
|
delete[] cum_times_s;
|
||||||
|
delete[] offsets;
|
||||||
|
cum_times_s = new double[data_size];
|
||||||
|
offsets = new double[data_size];
|
||||||
|
for (int i = 0; i<data_size; i++) {
|
||||||
|
cum_times_s[i] = other.cum_times_s[i];
|
||||||
|
offsets[i] = other.offsets[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] size_data_m3;
|
||||||
|
init_size_array();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Population_Container::init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_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(scale_start, scale_end, num_E_bins);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Population_Container::init_bin_offsets() {
|
||||||
|
bin_offsets.phi = E_scale.get_number_bins();
|
||||||
|
bin_offsets.r = bin_offsets.phi * scales.phi.get_number_bins();
|
||||||
|
bin_offsets.z = bin_offsets.r * scales.r.get_number_bins();
|
||||||
|
data_size = bin_offsets.z * scales.z.get_number_bins();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Population_Container::init_content_arrays() {
|
||||||
|
cum_times_s = new double[data_size];
|
||||||
|
offsets = new double[data_size];
|
||||||
|
for (int i = 0; i<data_size; i++) {
|
||||||
|
cum_times_s[i] = 0;
|
||||||
|
offsets[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Population_Container::init_size_array() {
|
||||||
|
double bin_length_m = scales.z.get_delta();
|
||||||
|
size_data_m3 = new double[scales.r.get_number_bins()];
|
||||||
|
for (int r_bin = 0; r_bin<scales.r.get_number_bins(); r_bin++) {
|
||||||
|
double A_m2 = pi * (pow(scales.r.get_upper_bin_bound(r_bin), 2) - pow(scales.r.get_lower_bin_bound(r_bin), 2));
|
||||||
|
size_data_m3[r_bin] = A_m2 * bin_length_m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)) { // Movement not in z... just ignore it for now...
|
||||||
|
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;
|
||||||
|
int bin = calc_data_bin(bins_1, E_bin);
|
||||||
|
cum_times_s[bin] += cum_time_s;
|
||||||
|
} else { // Movement in z-direction, r and phi bin constant... Bit lengthy, might find a more beautiful solution....
|
||||||
|
double z_1 = calc_z_m(loc1_m);
|
||||||
|
double z_2 = calc_z_m(loc2_m);
|
||||||
|
if (bins_1.z > bins_2.z) { // sort for pos1 be smaller.
|
||||||
|
swap(bins_1, bins_2);
|
||||||
|
swap(z_1, z_2);
|
||||||
|
}
|
||||||
|
double d_m = scales.z.get_upper_bin_bound(bins_1.z) - z_1; // lower bin
|
||||||
|
double cum_time_s = d_m/v_ms;
|
||||||
|
int bin = calc_data_bin(bins_1, E_bin);
|
||||||
|
cum_times_s[bin] += cum_time_s;
|
||||||
|
d_m = z_2 - scales.z.get_lower_bin_bound(bins_2.z); // upper bin
|
||||||
|
cum_time_s = d_m/v_ms;
|
||||||
|
bin = calc_data_bin(bins_2, E_bin);
|
||||||
|
cum_times_s[bin] += cum_time_s;
|
||||||
|
for (int z_bin = bins_1.z + 1; z_bin < bins_2.z; z_bin ++) {
|
||||||
|
d_m = scales.z.get_upper_bin_bound(z_bin) - scales.z.get_lower_bin_bound(z_bin); // upper bin
|
||||||
|
bins_1.z = z_bin; // use bins_1 as dynamic bin here.
|
||||||
|
cum_time_s = d_m/v_ms;
|
||||||
|
bin = calc_data_bin(bins_1, E_bin);
|
||||||
|
cum_times_s[bin] += cum_time_s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Population_Container::increase_offset(const vec3 &loc_m, const double &E_eV) {
|
||||||
|
int E_bin = E_scale.calc_index(E_eV);
|
||||||
|
Bins loc_bins = calc_loc_bin(loc_m);
|
||||||
|
int bin = calc_data_bin(loc_bins, E_bin);
|
||||||
|
offsets[bin] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s) {
|
||||||
|
Bins loc_bins = calc_loc_bin(loc_m);
|
||||||
|
int E_bin = E_scale.calc_index(E_eV);
|
||||||
|
return get_density_m3(E_bin, loc_bins, time_s).n_m3;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Content Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s) {
|
||||||
|
int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||||
|
double cum_time_s = cum_times_s[data_bin];
|
||||||
|
int offset = offsets[data_bin];
|
||||||
|
double V_m3 = size_data_m3[loc_bins.r];
|
||||||
|
|
||||||
|
double n_m3 = cum_time_s/time_s/V_m3 - offset;
|
||||||
|
if (n_m3<0) {
|
||||||
|
n_m3 = 0;
|
||||||
|
}
|
||||||
|
double E_eV = E_scale.get_bin_mid(E_bin);
|
||||||
|
return Content({E_eV, n_m3});
|
||||||
|
}
|
||||||
|
|
||||||
|
Sum_bounds Population_Container::get_sumation_bounds(const vec3 &loc_m) {
|
||||||
|
Bins loc_bins = calc_loc_bin(loc_m);
|
||||||
|
return Sum_bounds{loc_bins, E_scale.get_number_bins()};
|
||||||
|
}
|
||||||
|
|
||||||
|
double Population_Container::roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni) {
|
||||||
|
double low = E_scale.get_lower_bin_bound(E_bin);
|
||||||
|
double up = E_scale.get_upper_bin_bound(E_bin);
|
||||||
|
return low + rngUni->random()*(up-low);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bins Population_Container::calc_loc_bin(const vec3 &loc_m) {
|
||||||
|
Bins res;
|
||||||
|
res.z = scales.z.calc_index(calc_z_m(loc_m));
|
||||||
|
res.r = scales.r.calc_index(calc_r_m(loc_m));
|
||||||
|
res.phi = scales.phi.calc_index(calc_phi(loc_m));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Population_Container::calc_data_bin(const Bins &loc_bin, const double &E_bin) {
|
||||||
|
return bin_offsets.z * loc_bin.z + bin_offsets.r*loc_bin.r + bin_offsets.phi*loc_bin.phi + E_bin;
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
//
|
||||||
|
// population_container.hpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 02.08.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef population_container_hpp
|
||||||
|
#define population_container_hpp
|
||||||
|
|
||||||
|
#include "log_scale.h"
|
||||||
|
#include "random_operations.h"
|
||||||
|
#include "katrin_geo.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct Bins {
|
||||||
|
int z;
|
||||||
|
int r;
|
||||||
|
int phi;
|
||||||
|
inline bool operator==(Bins other) {
|
||||||
|
if (z == other.z && r == other.r && phi == other.phi) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Scales {
|
||||||
|
Lin_Scale z;
|
||||||
|
Lin_Scale r;
|
||||||
|
Lin_Scale phi;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Sum_bounds {
|
||||||
|
Bins loc_bins;
|
||||||
|
int num_E_bins;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Content {
|
||||||
|
double E_eV;
|
||||||
|
double n_m3;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Population_Container {
|
||||||
|
friend class Simulation;
|
||||||
|
friend class Population_Logger;
|
||||||
|
friend class Population_Load_Saver;
|
||||||
|
|
||||||
|
Scales scales;
|
||||||
|
Log_Scale E_scale;
|
||||||
|
|
||||||
|
double *cum_times_s;
|
||||||
|
double *offsets;
|
||||||
|
Bins bin_offsets;
|
||||||
|
int data_size;
|
||||||
|
|
||||||
|
double *size_data_m3;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Population_Container(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
||||||
|
~Population_Container();
|
||||||
|
Population_Container(const Population_Container& other);
|
||||||
|
Population_Container& operator=(const Population_Container& other);
|
||||||
|
private:
|
||||||
|
void init_scales(int num_z_bins, int num_r_bins, int num_phi_bins, int num_E_bins);
|
||||||
|
void init_bin_offsets();
|
||||||
|
void init_content_arrays();
|
||||||
|
void init_size_array();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void increase_cum_time_s(const vec3 &loc1_m, const vec3 &loc2_m, const double &v_ms, const double &E_eV);
|
||||||
|
void increase_offset(const vec3 &loc_m, const double &E_eV);
|
||||||
|
|
||||||
|
public:
|
||||||
|
double get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s);
|
||||||
|
Content get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s);
|
||||||
|
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||||
|
|
||||||
|
double get_E_eV (const int &E_bin);
|
||||||
|
double roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Bins calc_loc_bin(const vec3 &loc_m);
|
||||||
|
int calc_data_bin(const Bins &loc_bin, const double &E_bin);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* population_container_hpp */
|
||||||
@@ -12,13 +12,22 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
void Population_Load_Saver::save() {
|
void Population_Load_Saver::save() {
|
||||||
|
ofstream save_stream(get_save_path());
|
||||||
|
write_overhead(&save_stream);
|
||||||
|
|
||||||
|
vector<species> all_species = get_all_species_vector();
|
||||||
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
|
if (populations->find(*itr)->access_container() != nullptr) {
|
||||||
|
write_species(&save_stream, *itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (all_species.size()<1) {
|
if (all_species.size()<1) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::save: No Populations to save. \n";
|
ss<<"Population_Load_Saver::save: No Populations to save. \n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
ofstream save_stream(get_save_path());
|
|
||||||
write_overhead(&save_stream);
|
|
||||||
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
write_species(&save_stream, *itr);
|
write_species(&save_stream, *itr);
|
||||||
}
|
}
|
||||||
@@ -34,9 +43,9 @@ string Population_Load_Saver::get_save_path() {
|
|||||||
|
|
||||||
void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
||||||
*save_stream<<"# File is automatically created. File contains Populations Density. To be loaded as start offset.\n";
|
*save_stream<<"# File is automatically created. File contains Populations Density. To be loaded as start offset.\n";
|
||||||
*save_stream<<all_species.size()<<"\t # Number of Populations \n";
|
*save_stream<<calc_number()<<"\t # Number of Populations \n";
|
||||||
|
|
||||||
*save_stream<<timer->get_physTime_s()<<"\t # Offset Time in seconds \n";
|
*save_stream<<timer->get_time_s()<<"\t # Offset Time in seconds \n";
|
||||||
|
|
||||||
*save_stream<<z_RW_m<<"\t";
|
*save_stream<<z_RW_m<<"\t";
|
||||||
*save_stream<<z_WGTS_start_m<<"\t";
|
*save_stream<<z_WGTS_start_m<<"\t";
|
||||||
@@ -54,41 +63,64 @@ void Population_Load_Saver::write_overhead(ofstream *save_stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::write_species(ofstream *save_stream, species this_species) {
|
void Population_Load_Saver::write_species(ofstream *save_stream, species this_species) {
|
||||||
Population_Base *pop = populations->find(this_species);
|
Population_Container *cont = populations->find(this_species)->access_container();
|
||||||
bin_count4 number_bins = pop->get_bin_count4();
|
|
||||||
bin_content_vec bins = pop->get_bins_content();
|
|
||||||
|
|
||||||
*save_stream<<get_species_string(this_species)<<"\t #species name \n";
|
*save_stream<<get_species_string(this_species)<<"\t #species name \n";
|
||||||
|
|
||||||
for (int i = 0; i<4; i++) {
|
*save_stream<<cont->scales.z.get_number_bins()<<"\t";
|
||||||
*save_stream<<number_bins[i]<<"\t";
|
*save_stream<<cont->scales.r.get_number_bins()<<"\t";
|
||||||
}
|
*save_stream<<cont->scales.phi.get_number_bins()<<"\t";
|
||||||
|
*save_stream<<cont->E_scale.get_number_bins()<<"\t";
|
||||||
*save_stream<<"#number_bins of 1. z_scale 2. r_scale 3. phi_scale 4. E_scale \n";
|
*save_stream<<"#number_bins of 1. z_scale 2. r_scale 3. phi_scale 4. E_scale \n";
|
||||||
for (bin_content_vec::iterator itr = bins.begin(); itr != bins.end(); itr++) {
|
|
||||||
*save_stream<<itr->z_bin<<"\t";
|
for (int i_z = 0; i_z<cont->scales.z.get_number_bins(); i_z++) {
|
||||||
*save_stream<<itr->r_bin<<"\t";
|
for (int i_r = 0; i_z<cont->scales.r.get_number_bins(); i_z++) {
|
||||||
*save_stream<<itr->phi_bin<<"\t";
|
for (int i_phi = 0; i_z<cont->scales.phi.get_number_bins(); i_z++) {
|
||||||
*save_stream<<itr->E_bin<<"\t";
|
for (int i_E = 0; i_z<cont->E_scale.get_number_bins(); i_z++) {
|
||||||
*save_stream<<itr->cumulated_time_s<<"\t";
|
int bin = cont->calc_data_bin(Bins{i_z, i_r, i_phi}, i_E);
|
||||||
*save_stream<<itr->offset<<"\n";
|
*save_stream<<i_z<<"\t"<<i_r<<"\t"<<i_phi<<"\t"<<i_E<<"\t";
|
||||||
|
*save_stream<<cont->cum_times_s[bin]<<"\t";
|
||||||
|
*save_stream<<cont->offsets[bin]<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*save_stream<<"end_of_species \n";
|
*save_stream<<"end_of_species \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Population_Load_Saver::calc_number() {
|
||||||
|
int num = 0;
|
||||||
|
vector<species> all_species = get_all_species_vector();
|
||||||
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
|
if (populations->find(*itr)->access_container() != nullptr) {
|
||||||
|
num += 1 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Population_Load_Saver::load() {
|
void Population_Load_Saver::load() {
|
||||||
|
// Maybe change whole system to h5, therefore allowing sloppy style
|
||||||
string load_path = get_enviroment_variable("pop_load_path");
|
string load_path = get_enviroment_variable("pop_load_path");
|
||||||
if (load_path.empty()) {
|
if (load_path.empty()) {
|
||||||
cout<<"No File specified for Population default loading.\n";
|
cout<<"No File specified for loading Population start values.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ifstream load_stream(load_path);
|
ifstream load_stream(load_path);
|
||||||
if (!load_stream.good()) {
|
if (!load_stream.good()) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::load: Could not open file.\n";
|
ss<<"Population_Load_Saver::load: Could not open file.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
goto_nextline(&load_stream); //ignore first line
|
goto_nextline(&load_stream); //ignore first line
|
||||||
int number_populations = get_num_populations_line(&load_stream);
|
int number_populations = get_num_populations_line(&load_stream);
|
||||||
|
if (number_populations != calc_number()) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"Population_Load_Saver::load: Number Population missmatch.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
|
||||||
double offset_time_s = get_offset_time_line(&load_stream);
|
double offset_time_s = get_offset_time_line(&load_stream);
|
||||||
timer->set_offset_time_s(offset_time_s);
|
timer->set_offset_time_s(offset_time_s);
|
||||||
check_katrin_geo_line(&load_stream);
|
check_katrin_geo_line(&load_stream);
|
||||||
@@ -108,7 +140,7 @@ void Population_Load_Saver::load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::goto_nextline(ifstream *load_stream) {
|
void Population_Load_Saver::goto_nextline(ifstream *load_stream) {
|
||||||
load_stream->ignore(std::numeric_limits<streamsize>::max(), '\n');
|
load_stream->ignore(numeric_limits<streamsize>::max(), '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
int Population_Load_Saver::get_num_populations_line(ifstream *load_stream) {
|
int Population_Load_Saver::get_num_populations_line(ifstream *load_stream) {
|
||||||
@@ -116,50 +148,50 @@ int Population_Load_Saver::get_num_populations_line(ifstream *load_stream) {
|
|||||||
*load_stream>>num_populations;
|
*load_stream>>num_populations;
|
||||||
goto_nextline(load_stream);
|
goto_nextline(load_stream);
|
||||||
if (num_populations < 1) {
|
if (num_populations < 1) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::get_num_populations_line: num_populations < 1.\n";
|
ss<<"Population_Load_Saver::get_num_populations_line: num_populations < 1.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
return num_populations;
|
return num_populations;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Population_Load_Saver::get_offset_time_line(std::ifstream *load_stream) {
|
double Population_Load_Saver::get_offset_time_line(ifstream *load_stream) {
|
||||||
double offset_time_s;
|
double offset_time_s;
|
||||||
*load_stream>>offset_time_s;
|
*load_stream>>offset_time_s;
|
||||||
goto_nextline(load_stream);
|
goto_nextline(load_stream);
|
||||||
return offset_time_s;
|
return offset_time_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::check_katrin_geo_line(std::ifstream *load_stream) {
|
void Population_Load_Saver::check_katrin_geo_line(ifstream *load_stream) {
|
||||||
double z_RW_m, z_WGTSstart_m, z_WGTSend_m, radius_m;
|
double z_RW_m, z_WGTSstart_m, z_WGTSend_m, radius_m;
|
||||||
*load_stream>>z_RW_m;
|
*load_stream>>z_RW_m;
|
||||||
if ( z_RW_m != z_RW_m) {
|
if ( z_RW_m != z_RW_m) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::check_katrin_geo_line: z_RW missmatch.\n";
|
ss<<"Population_Load_Saver::check_katrin_geo_line: z_RW missmatch.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
*load_stream>>z_WGTSstart_m;
|
*load_stream>>z_WGTSstart_m;
|
||||||
if ( z_WGTSstart_m != z_WGTS_start_m) {
|
if ( z_WGTSstart_m != z_WGTS_start_m) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSstart missmatch.\n";
|
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSstart missmatch.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
*load_stream>>z_WGTSend_m;
|
*load_stream>>z_WGTSend_m;
|
||||||
if ( z_WGTSend_m != z_WGTS_end_m) {
|
if ( z_WGTSend_m != z_WGTS_end_m) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSend missmatch.\n";
|
ss<<"Population_Load_Saver::check_katrin_geo_line: z_WGTSend missmatch.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
*load_stream>>radius_m;
|
*load_stream>>radius_m;
|
||||||
if ( radius_m != r_WGTS_m) {
|
if ( radius_m != r_WGTS_m) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::check_katrin_geo_line: radius missmatch.\n";
|
ss<<"Population_Load_Saver::check_katrin_geo_line: radius missmatch.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
goto_nextline(load_stream);
|
goto_nextline(load_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::check_katrin_T2_line(std::ifstream *load_stream) {
|
void Population_Load_Saver::check_katrin_T2_line(ifstream *load_stream) {
|
||||||
double wgtsT2MaxDensity_m3, wgtsTemp_K, wgtsT2FlowSpeed_ms;
|
double wgtsT2MaxDensity_m3, wgtsTemp_K, wgtsT2FlowSpeed_ms;
|
||||||
*load_stream>>wgtsT2MaxDensity_m3;
|
*load_stream>>wgtsT2MaxDensity_m3;
|
||||||
if ( wgtsT2MaxDensity_m3 != load_parameter("wgtsT2MaxDensity_m3")) {
|
if ( wgtsT2MaxDensity_m3 != load_parameter("wgtsT2MaxDensity_m3")) {
|
||||||
@@ -176,17 +208,17 @@ void Population_Load_Saver::check_katrin_T2_line(std::ifstream *load_stream) {
|
|||||||
goto_nextline(load_stream);
|
goto_nextline(load_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
species Population_Load_Saver::get_species_line(std::ifstream *load_stream) {
|
species Population_Load_Saver::get_species_line(ifstream *load_stream) {
|
||||||
string species_string;
|
string species_string;
|
||||||
*load_stream>>species_string;
|
*load_stream>>species_string;
|
||||||
goto_nextline(load_stream);
|
goto_nextline(load_stream);
|
||||||
return get_species_from_string(species_string);
|
return get_species_from_string(species_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::append_check_vector(std::vector<species> *check_vector, species add_species) {
|
void Population_Load_Saver::append_check_vector(vector<species> *check_vector, species add_species) {
|
||||||
for (std::vector<species>::iterator itr=check_vector->begin(); itr!=check_vector->end(); itr++) {
|
for (vector<species>::iterator itr=check_vector->begin(); itr!=check_vector->end(); itr++) {
|
||||||
if (*itr == add_species) {
|
if (*itr == add_species) {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::append_check_vector: species already loaded.\n";
|
ss<<"Population_Load_Saver::append_check_vector: species already loaded.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
@@ -194,35 +226,35 @@ void Population_Load_Saver::append_check_vector(std::vector<species> *check_vect
|
|||||||
check_vector->push_back(add_species);
|
check_vector->push_back(add_species);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Population_Load_Saver::load_species(std::ifstream *load_stream, species add_species) {
|
void Population_Load_Saver::load_species(ifstream *load_stream, species add_species) {
|
||||||
bin_count4 bin_counts;
|
Population_Container *cont = populations->find(add_species)->access_container();
|
||||||
*load_stream>>bin_counts[0];
|
|
||||||
*load_stream>>bin_counts[1];
|
|
||||||
*load_stream>>bin_counts[2];
|
|
||||||
*load_stream>>bin_counts[3];
|
|
||||||
|
|
||||||
int number_content_lines = 1;
|
int num_z_bins, num_r_bins, num_phi_bins, num_E_bins;
|
||||||
for (int i = 0; i<4;i++) {
|
*load_stream>>num_z_bins>>num_r_bins>>num_phi_bins>>num_E_bins;
|
||||||
number_content_lines *= (bin_counts[i]+1);
|
if ( (num_z_bins != cont->scales.z.get_number_bins())
|
||||||
}
|
|| (num_r_bins != cont->scales.r.get_number_bins())
|
||||||
bin_content_vec bin_contents;
|
|| (num_phi_bins != cont->scales.phi.get_number_bins())
|
||||||
pop_bin_content temp;
|
|| (num_E_bins != cont->E_scale.get_number_bins()) ) {
|
||||||
for (int i = 0; i<number_content_lines; i++) {
|
stringstream ss;
|
||||||
*load_stream>>temp.z_bin;
|
ss<<"Population_Load_Saver::load_species: Number bins in scales missmatch.\n";
|
||||||
*load_stream>>temp.r_bin;
|
throw MyException(ss.str());
|
||||||
*load_stream>>temp.phi_bin;
|
}
|
||||||
*load_stream>>temp.E_bin;
|
|
||||||
*load_stream>>temp.cumulated_time_s;
|
int z_bin, r_bin, phi_bin, E_bin;
|
||||||
*load_stream>>temp.offset;
|
for (int i = 0; i< cont->data_size; i++) {
|
||||||
goto_nextline(load_stream);
|
*load_stream>>z_bin>>r_bin>>phi_bin>>E_bin;
|
||||||
bin_contents.push_back(temp);
|
if (i != cont->calc_data_bin(Bins{}, E_bin)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"Population_Load_Saver::load_species: Input Data bin missmatch.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
*load_stream>>cont->cum_times_s[i]>>cont->offsets[i];
|
||||||
}
|
}
|
||||||
string end_of_species;
|
string end_of_species;
|
||||||
*load_stream>>end_of_species;
|
*load_stream>>end_of_species;
|
||||||
if (end_of_species!="end_of_species") {
|
if (end_of_species!="end_of_species") {
|
||||||
std::stringstream ss;
|
stringstream ss;
|
||||||
ss<<"Population_Load_Saver::load_species: Missmatch in number of lines..\n";
|
ss<<"Population_Load_Saver::load_species: Missmatch in number of lines..\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
populations->find(add_species)->set_bins(bin_counts, bin_contents);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "population_builder.hpp"
|
#include "population_builder.hpp"
|
||||||
|
|
||||||
class Population_Load_Saver {
|
class Population_Load_Saver {
|
||||||
std::vector <species> all_species;
|
|
||||||
Population_Manager *populations;
|
Population_Manager *populations;
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
@@ -21,12 +20,6 @@ public:
|
|||||||
Population_Load_Saver(Population_Manager *populations, Timer *timer) {
|
Population_Load_Saver(Population_Manager *populations, Timer *timer) {
|
||||||
this->populations = populations;
|
this->populations = populations;
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
|
|
||||||
all_species.push_back(electron);
|
|
||||||
all_species.push_back(tritium);
|
|
||||||
all_species.push_back(tritiumI);
|
|
||||||
all_species.push_back(tritium2I);
|
|
||||||
all_species.push_back(tritium3I);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
@@ -34,7 +27,7 @@ private:
|
|||||||
std::string get_save_path();
|
std::string get_save_path();
|
||||||
void write_overhead(std::ofstream *save_stream);
|
void write_overhead(std::ofstream *save_stream);
|
||||||
void write_species(std::ofstream *save_stream, species this_species);
|
void write_species(std::ofstream *save_stream, species this_species);
|
||||||
|
int calc_number();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void load();
|
void load();
|
||||||
@@ -50,10 +43,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* population_load_saver_hpp */
|
#endif /* population_load_saver_hpp */
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
class Population_Logger {
|
class Population_Logger {
|
||||||
Population_Base *pop;
|
Population_Base *pop;
|
||||||
|
Population_Container *container;
|
||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
H5TB_Population_Interface h5tb;
|
H5TB_Population_Interface h5tb;
|
||||||
H5TB_Population_Meta_Interface h5tb_meta;
|
H5TB_Population_Meta_Interface h5tb_meta;
|
||||||
@@ -33,13 +35,12 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void log();
|
void log();
|
||||||
private:
|
|
||||||
pop_log_bin transform(pop_bin_content pop_bin);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Population_Logger::Population_Logger(Population_Base *pop, Timer *timer, H5_File *h5_file) {
|
inline Population_Logger::Population_Logger(Population_Base *pop, Timer *timer, H5_File *h5_file) {
|
||||||
this->pop = pop;
|
this->pop = pop;
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
|
this->container = pop->access_container();
|
||||||
create_h5g_species(h5_file);
|
create_h5g_species(h5_file);
|
||||||
create_h5tb_meta();
|
create_h5tb_meta();
|
||||||
create_h5tb();
|
create_h5tb();
|
||||||
@@ -55,9 +56,33 @@ inline void Population_Logger::create_h5tb_meta() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<get_species_string(pop->get_species())<<"_meta_data";
|
ss<<get_species_string(pop->get_species())<<"_meta_data";
|
||||||
h5tb_meta = H5TB_Population_Meta_Interface(ss.str(), &h5g_species);
|
h5tb_meta = H5TB_Population_Meta_Interface(ss.str(), &h5g_species);
|
||||||
meta_vec bins_meta_info = pop->get_bins_meta_info();
|
|
||||||
for (meta_vec::iterator itr = bins_meta_info.begin(); itr != bins_meta_info.end(); itr++) {
|
pop_bin_meta_info temp_bin = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
h5tb_meta.write(*itr);
|
|
||||||
|
temp_bin.z_min_m = container->scales.z.get_lower_scale_end();
|
||||||
|
for (int i_z=0; i_z<container->scales.z.get_number_bins(); i_z++) {
|
||||||
|
temp_bin.z_bin = i_z;
|
||||||
|
temp_bin.z_max_m = container->scales.z.get_upper_bin_bound(i_z);
|
||||||
|
temp_bin.r_min_m = container->scales.r.get_lower_scale_end();
|
||||||
|
for (int i_r=0; i_r<container->scales.r.get_number_bins(); i_r++) {
|
||||||
|
temp_bin.r_bin = i_r;
|
||||||
|
temp_bin.r_max_m = container->scales.r.get_upper_bin_bound(i_r);
|
||||||
|
temp_bin.phi_min = container->scales.phi.get_lower_scale_end();
|
||||||
|
for (int i_phi=0; i_phi<container->scales.phi.get_number_bins(); i_phi++) {
|
||||||
|
temp_bin.phi_bin = i_phi;
|
||||||
|
temp_bin.phi_max = container->scales.phi.get_upper_bin_bound(i_phi);
|
||||||
|
temp_bin.E_min_eV = container->E_scale.get_lower_scale_end();
|
||||||
|
for (int i_E=0; i_E<container->E_scale.get_number_bins(); i_E++) {
|
||||||
|
temp_bin.E_bin = i_E;
|
||||||
|
temp_bin.E_max_eV = container->E_scale.get_upper_bin_bound(i_E);
|
||||||
|
h5tb_meta.write(temp_bin);
|
||||||
|
temp_bin.E_min_eV = temp_bin.E_max_eV;
|
||||||
|
}
|
||||||
|
temp_bin.phi_min = temp_bin.phi_max;
|
||||||
|
}
|
||||||
|
temp_bin.r_min_m = temp_bin.r_max_m;
|
||||||
|
}
|
||||||
|
temp_bin.z_min_m = temp_bin.z_max_m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,25 +92,27 @@ inline void Population_Logger::create_h5tb() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void Population_Logger::log() {
|
inline void Population_Logger::log() {
|
||||||
bin_content_vec bins_content = pop->get_bins_content();
|
pop_bin temp_bin;
|
||||||
pop_log_bin temp;
|
temp_bin.phys_time_s = timer->get_time_s();
|
||||||
for (bin_content_vec::iterator itr = bins_content.begin(); itr != bins_content.end(); itr++) {
|
int bin;
|
||||||
temp = transform(*itr);
|
for (int i_z=0; i_z < container->scales.z.get_number_bins(); i_z++) {
|
||||||
h5tb.write(temp);
|
temp_bin.z_bin = i_z;
|
||||||
|
for (int i_r=0; i_r < container->scales.r.get_number_bins(); i_r++) {
|
||||||
|
temp_bin.r_bin = i_r;
|
||||||
|
for (int i_phi=0; i_phi < container->scales.phi.get_number_bins(); i_phi++) {
|
||||||
|
temp_bin.phi_bin = i_phi;
|
||||||
|
for (int i_E=0; i_E < container->E_scale.get_number_bins(); i_E++) {
|
||||||
|
temp_bin.E_bin = i_E;
|
||||||
|
bin = container->calc_data_bin(Bins{i_z, i_r, i_phi}, i_E);
|
||||||
|
temp_bin.cumulated_time_s = container->cum_times_s[bin];
|
||||||
|
temp_bin.offset = container->offsets[bin];
|
||||||
|
h5tb.write(temp_bin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline pop_log_bin Population_Logger::transform(pop_bin_content pop_bin) {
|
|
||||||
pop_log_bin res;
|
|
||||||
res.phys_time_s = timer->get_physTime_s();
|
|
||||||
res.z_bin = pop_bin.z_bin;
|
|
||||||
res.r_bin = pop_bin.r_bin;
|
|
||||||
res.phi_bin = pop_bin.phi_bin;
|
|
||||||
res.E_bin = pop_bin.E_bin;
|
|
||||||
res.cumulated_time_s = pop_bin.cumulated_time_s;
|
|
||||||
res.offset = pop_bin.offset;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Population_Logger_Manager {
|
class Population_Logger_Manager {
|
||||||
Population_Logger **population_loggers;
|
Population_Logger **population_loggers;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ inline std::string make_path (const std::string &path) { // append '/' if necess
|
|||||||
|
|
||||||
inline std::string get_enviroment_variable (const std::string &envName) { // string version of C function getenv.
|
inline std::string get_enviroment_variable (const std::string &envName) { // string version of C function getenv.
|
||||||
char * val = getenv( envName.c_str() );
|
char * val = getenv( envName.c_str() );
|
||||||
return val == NULL ? std::string("") : std::string(val);
|
return val == nullptr ? std::string("") : std::string(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string get_parameter_file_path() {
|
inline std::string get_parameter_file_path() {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Scale {
|
|||||||
public:
|
public:
|
||||||
Scale() {};
|
Scale() {};
|
||||||
virtual ~Scale() {};
|
virtual ~Scale() {};
|
||||||
virtual Scale *clone() = 0;
|
|
||||||
|
|
||||||
virtual double get_lower_scale_end() = 0;
|
virtual double get_lower_scale_end() = 0;
|
||||||
virtual double get_upper_scale_end() = 0;
|
virtual double get_upper_scale_end() = 0;
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ void Simulation::init_pop_arrays() {
|
|||||||
for (int i = 0; i<number_pop_species; i++) {
|
for (int i = 0; i<number_pop_species; i++) {
|
||||||
pop_species[i] = all_species[i];
|
pop_species[i] = all_species[i];
|
||||||
population = populations->find(pop_species[i]);
|
population = populations->find(pop_species[i]);
|
||||||
pop_array_lengths[i] = population->get_array_length();
|
|
||||||
|
pop_array_lengths[i] = population->access_container()->data_size;
|
||||||
global_cum_time_s[i] = new double[pop_array_lengths[i]];
|
global_cum_time_s[i] = new double[pop_array_lengths[i]];
|
||||||
global_offset[i] = new double[pop_array_lengths[i]];
|
global_offset[i] = new double[pop_array_lengths[i]];
|
||||||
for (int j = 0; j<pop_array_lengths[i]; j++) {
|
for (int j = 0; j<pop_array_lengths[i]; j++) {
|
||||||
@@ -180,14 +181,14 @@ void Simulation::sync_cpus() {
|
|||||||
|
|
||||||
void Simulation::sync_populations() {
|
void Simulation::sync_populations() {
|
||||||
Population_Manager *populations = looper.get_populations();
|
Population_Manager *populations = looper.get_populations();
|
||||||
Population_Base *population;
|
Population_Container *container;
|
||||||
double *global_delta_cumulated_time_s;
|
double *global_delta_cumulated_time_s;
|
||||||
double *global_delta_offset;
|
double *global_delta_offset;
|
||||||
double *local_delta_cumulated_time_s;
|
double *local_delta_cumulated_time_s;
|
||||||
double *local_delta_offset;
|
double *local_delta_offset;
|
||||||
int array_length;
|
int array_length;
|
||||||
for (int i = 0; i<number_pop_species; i++) {
|
for (int i = 0; i<number_pop_species; i++) {
|
||||||
population = populations->find(pop_species[i]);
|
container = populations->find(pop_species[i])->access_container();
|
||||||
array_length = pop_array_lengths[i];
|
array_length = pop_array_lengths[i];
|
||||||
if (array_length == 0) {
|
if (array_length == 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -198,8 +199,8 @@ void Simulation::sync_populations() {
|
|||||||
local_delta_offset = new double[array_length];
|
local_delta_offset = new double[array_length];
|
||||||
|
|
||||||
for (int j = 0; j<array_length; j++) {
|
for (int j = 0; j<array_length; j++) {
|
||||||
local_delta_cumulated_time_s[j] = population->get_cumulated_time_s_array()[j] - global_cum_time_s[i][j];
|
local_delta_cumulated_time_s[j] = container->cum_times_s[j] - global_cum_time_s[i][j];
|
||||||
local_delta_offset[j] = population->get_offset_array()[j] - global_offset[i][j];
|
local_delta_offset[j] = container->offsets[j] - global_offset[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(local_delta_cumulated_time_s, global_delta_cumulated_time_s, array_length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
MPI_Allreduce(local_delta_cumulated_time_s, global_delta_cumulated_time_s, array_length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
||||||
@@ -208,8 +209,8 @@ void Simulation::sync_populations() {
|
|||||||
for (int j = 0; j<pop_array_lengths[i]; j++) {
|
for (int j = 0; j<pop_array_lengths[i]; j++) {
|
||||||
global_cum_time_s[i][j] += global_delta_cumulated_time_s[j];
|
global_cum_time_s[i][j] += global_delta_cumulated_time_s[j];
|
||||||
global_offset[i][j] += global_delta_offset[j];
|
global_offset[i][j] += global_delta_offset[j];
|
||||||
population->get_cumulated_time_s_array()[j] = global_cum_time_s[i][j];
|
container->cum_times_s[j] = global_cum_time_s[i][j];
|
||||||
population->get_offset_array()[j] = global_offset[i][j];
|
container->offsets[j] = global_offset[i][j];
|
||||||
}
|
}
|
||||||
delete[] global_delta_cumulated_time_s;
|
delete[] global_delta_cumulated_time_s;
|
||||||
delete[] global_delta_offset;
|
delete[] global_delta_offset;
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
//
|
|
||||||
// size_container.cpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 27.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "size_container.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
Size_Container::Size_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
|
|
||||||
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
|
||||||
cell_length_m = (z_WGTS_end_m-z_RW_m) / (num_z_bins);
|
|
||||||
|
|
||||||
data = new double[num_r_bins];
|
|
||||||
for (int i = 0; i<num_r_bins; i++) {
|
|
||||||
data[i] = cell_length_m * calc_disc_surface_m2(i)/num_phi_bins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Size_Container::~Size_Container() {
|
|
||||||
delete[] data;
|
|
||||||
};
|
|
||||||
|
|
||||||
Size_Container::Size_Container(const Size_Container& other) {
|
|
||||||
r_scale = other.r_scale;
|
|
||||||
cell_length_m = other.cell_length_m;
|
|
||||||
int number_bins = r_scale.get_number_bins();
|
|
||||||
data = new double [number_bins];
|
|
||||||
for (int i = 0; i < number_bins; i++) {
|
|
||||||
data[i] = other.data[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Size_Container& Size_Container::operator=(const Size_Container& other) {
|
|
||||||
Size_Container tmp(other);
|
|
||||||
swap(r_scale, tmp.r_scale);
|
|
||||||
swap(cell_length_m, tmp.cell_length_m);
|
|
||||||
swap(data, tmp.data);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double Size_Container::calc_disc_surface_m2 (const int &r_bin) {
|
|
||||||
double previous_r_m = r_scale.get_lower_bin_bound(r_bin);
|
|
||||||
double this_r_m = r_scale.get_upper_bin_bound(r_bin);
|
|
||||||
double A_m2 = pi * (this_r_m * this_r_m - previous_r_m * previous_r_m);
|
|
||||||
return A_m2;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Size_Container::get_cell_volume_m3(const double &r_m) {
|
|
||||||
int r_bin = r_scale.calc_index(r_m);
|
|
||||||
return data[r_bin];
|
|
||||||
}
|
|
||||||
|
|
||||||
double Size_Container::get_cell_volume_m3(const vec3 &loc_m) {
|
|
||||||
double r_m = calc_r_m(loc_m);
|
|
||||||
return get_cell_volume_m3(r_m);
|
|
||||||
}
|
|
||||||
|
|
||||||
double Size_Container::get_cell_length_m() {
|
|
||||||
return cell_length_m;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
//
|
|
||||||
// size_container.hpp
|
|
||||||
// mc_electron
|
|
||||||
//
|
|
||||||
// Created by Christian Reiling on 27.05.19.
|
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef size_container_hpp
|
|
||||||
#define size_container_hpp
|
|
||||||
|
|
||||||
#include "lin_scale.h"
|
|
||||||
#include "katrin_geo.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Size_Container {
|
|
||||||
double *data;
|
|
||||||
Lin_Scale r_scale;
|
|
||||||
double cell_length_m;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
//Size_Container() {};
|
|
||||||
Size_Container(int num_z_bins, int num_r_bins, int num_phi_bins);
|
|
||||||
~Size_Container();
|
|
||||||
Size_Container(const Size_Container& other);
|
|
||||||
Size_Container& operator=(const Size_Container& other);
|
|
||||||
|
|
||||||
double calc_disc_surface_m2 (const int &r_bin);
|
|
||||||
double get_cell_volume_m3(const double &r_m);
|
|
||||||
double get_cell_volume_m3(const vec3 &loc_m);
|
|
||||||
double get_cell_length_m();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* size_container_hpp */
|
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||||
double get_macroSigma_m2_thermal(const Particle &interPart);
|
double get_macroSigma_m2_thermal(const Particle &interPart);
|
||||||
double get_macroSigma_m2_kinetic(const Particle &interPart);
|
double get_macroSigma_m2_kinetic(const Particle &interPart, const Sum_bounds &bounds);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||||
@@ -69,11 +69,11 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline double Sub_Interaction_Base::get_macroSigma_m2(const Particle &interPart) {
|
inline double Sub_Interaction_Base::get_macroSigma_m2(const Particle &interPart) {
|
||||||
int number_E_bins = Population->get_number_E_bins();
|
Sum_bounds bounds = Population->get_sumation_bounds(interPart.get_x_m());
|
||||||
if (number_E_bins == 0) {
|
if (bounds.num_E_bins <= 1) { //thermal
|
||||||
return get_macroSigma_m2_thermal(interPart);
|
return get_macroSigma_m2_thermal(interPart);
|
||||||
} else {
|
} else { //kinetic
|
||||||
return get_macroSigma_m2_kinetic(interPart);
|
return get_macroSigma_m2_kinetic(interPart, bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,17 +85,13 @@ inline double Sub_Interaction_Base::get_macroSigma_m2_thermal(const Particle &in
|
|||||||
return microSigma_m2*nT2_m3;
|
return microSigma_m2*nT2_m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double Sub_Interaction_Base::get_macroSigma_m2_kinetic(const Particle &interPart) {
|
inline double Sub_Interaction_Base::get_macroSigma_m2_kinetic(const Particle &interPart, const Sum_bounds &bounds) {
|
||||||
// integrate over all energy bins, consider T3+ fixed and e- energetic.
|
// integrate over all energy bins, consider interPart.E_eV << E_eV.
|
||||||
int num_E_bins = Population->get_number_E_bins();
|
Content cont;
|
||||||
vec3 loc_m = interPart.get_x_m();
|
|
||||||
double macro_Sigma_m2 = 0;
|
double macro_Sigma_m2 = 0;
|
||||||
double E_eV, micro_Sigma_m2, ne_m3;
|
for (int E_bin = 0; E_bin< bounds.num_E_bins; E_bin++) {
|
||||||
for (int E_bin = 0; E_bin< num_E_bins; E_bin++) {
|
cont = Population->get_density_m3(E_bin, bounds.loc_bins);
|
||||||
E_eV = Population->get_E_eV(E_bin);
|
macro_Sigma_m2 += get_microSigma_m2(cont.E_eV) * cont.n_m3;
|
||||||
micro_Sigma_m2 = get_microSigma_m2(E_eV);
|
|
||||||
ne_m3 = Population->get_density_m3(loc_m, E_bin);
|
|
||||||
macro_Sigma_m2 += micro_Sigma_m2*ne_m3;
|
|
||||||
}
|
}
|
||||||
return macro_Sigma_m2;
|
return macro_Sigma_m2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,21 +11,13 @@
|
|||||||
|
|
||||||
#include "katrin_geo.h"
|
#include "katrin_geo.h"
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "population3_container.hpp"
|
|
||||||
#include "size_container.hpp"
|
|
||||||
#include "lin_scale.h"
|
|
||||||
|
|
||||||
#include "population_base.h"
|
#include "population_base.h"
|
||||||
|
#include "wgts_kinematics.h"
|
||||||
|
|
||||||
|
|
||||||
class Thermal_Population : public Population_Base, protected RNG_Base{
|
|
||||||
Pop3_Container cumulated_times_s;
|
|
||||||
Pop3_Container number_annhilated;
|
|
||||||
|
|
||||||
Size_Container bin_sizes;
|
|
||||||
|
|
||||||
|
class Thermal_Population : public Population_Base, private RNG_Base, public WGTS_Kinematics {
|
||||||
|
Population_Container container;
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
static const double wgtsTemp_K;
|
static const double wgtsTemp_K;
|
||||||
@@ -35,242 +27,60 @@ class Thermal_Population : public Population_Base, protected RNG_Base{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Thermal_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins);
|
Thermal_Population(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins);
|
||||||
private:
|
|
||||||
//void init_containers(int num_z_bins, int num_r_bins, int num_phi_bins);
|
|
||||||
|
|
||||||
public:
|
|
||||||
double get_density_m3 (const vec3 &loc_m);
|
|
||||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||||
void decrease_denisty (const vec3 &loc_m, const double &energy_eV);
|
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||||
|
|
||||||
public:
|
double get_density_m3(const vec3 &loc_m);
|
||||||
vec3 roll_v_ms (const vec3 &loc_m);
|
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||||
private:
|
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||||
vec3 get_average_v_ms (const vec3 &loc_m);
|
|
||||||
vec3 roll_thermSpeed_ms(const vec3 &loc_m);
|
|
||||||
|
|
||||||
public:
|
virtual vec3 roll_v_ms (const vec3 &loc_m);
|
||||||
int get_number_E_bins() {return 0;}
|
|
||||||
double get_E_eV (const int &E_bin) {throw MyException("Not implemented \n");}
|
|
||||||
double get_density_m3(const vec3 &loc_m, const int &E_bin) {throw MyException("Not implemented \n");};
|
|
||||||
|
|
||||||
public:
|
virtual Population_Container *access_container();
|
||||||
meta_vec get_bins_meta_info();
|
|
||||||
bin_content_vec get_bins_content();
|
|
||||||
bin_count4 get_bin_count4();
|
|
||||||
void set_bins(bin_count4 bin_counts, bin_content_vec bin_contents);
|
|
||||||
private:
|
|
||||||
Lin_Scale get_z_scale();
|
|
||||||
Lin_Scale get_r_scale();
|
|
||||||
Lin_Scale calc_phi_scale();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_array_length();
|
|
||||||
double *get_cumulated_time_s_array();
|
|
||||||
double *get_offset_array();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const double Thermal_Population::wgtsTemp_K = load_parameter("wgtsTemp_K");
|
const double Thermal_Population::wgtsTemp_K = load_parameter("wgtsTemp_K");
|
||||||
const double Thermal_Population::wgtsT2FlowSpeed_ms = load_parameter("wgtsT2FlowSpeed_ms");
|
const double Thermal_Population::wgtsT2FlowSpeed_ms = load_parameter("wgtsT2FlowSpeed_ms");
|
||||||
|
|
||||||
inline Thermal_Population::Thermal_Population(species this_species, 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),
|
|
||||||
cumulated_times_s(num_z_bins, num_r_bins, num_phi_bins),
|
inline Thermal_Population::Thermal_Population(species this_species, 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), WGTS_Kinematics(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, 1) {
|
||||||
number_annhilated(num_z_bins, num_r_bins, num_phi_bins),
|
|
||||||
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
|
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
//init_containers(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
m_eV = get_species_mass(this_species);
|
m_eV = get_species_mass(this_species);
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
void Thermal_Population::init_containers(int num_z_bins, int num_r_bins, int num_phi_bins) {
|
inline void Thermal_Population::increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||||
cumulated_times_s = Pop3_Container(num_z_bins, num_r_bins, num_phi_bins);
|
container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());
|
||||||
number_annhilated = Pop3_Container(num_z_bins, num_r_bins, num_phi_bins);
|
}
|
||||||
bin_sizes = Size_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
}*/
|
inline void Thermal_Population::decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||||
|
container.increase_offset(loc_m, E_eV);
|
||||||
|
}
|
||||||
|
|
||||||
inline double Thermal_Population::get_density_m3(const vec3 &loc_m) {
|
inline double Thermal_Population::get_density_m3(const vec3 &loc_m) {
|
||||||
if (!in_Katrin(loc_m)) {
|
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::get_density_m3: loc_m outside of Katrin.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
double physical_time_s = timer->get_physTime_s();
|
|
||||||
double cumulated_time_s_s = cumulated_times_s.get_value(loc_m);
|
|
||||||
double offset = number_annhilated.get_value(loc_m);
|
|
||||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
|
||||||
double dens_m3 = cumulated_time_s_s/physical_time_s/bin_size_m3 - offset;
|
|
||||||
dens_m3 = (dens_m3 < 0) ? 0 : dens_m3;
|
|
||||||
return dens_m3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Thermal_Population::increase_density(const Particle &upPart, const vec3 &oldLoc_m) {
|
inline Content Thermal_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||||
double cell_time_s = bin_sizes.get_cell_length_m()/upPart.get_vAbs_ms();
|
std::stringstream ss;
|
||||||
cumulated_times_s.increase_value(cell_time_s, upPart.get_x_m(), oldLoc_m);
|
ss<<"Thermal_Population::get_density_m3: method for non thermal populations.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
//return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Thermal_Population::decrease_denisty (const vec3 &loc_m, const double &energy_eV) {
|
inline Sum_bounds Thermal_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||||
number_annhilated.increase_value(1, loc_m);
|
Sum_bounds res;
|
||||||
}
|
res.num_E_bins = 1;
|
||||||
|
|
||||||
|
|
||||||
inline vec3 Thermal_Population::get_average_v_ms(const vec3 &loc_m) {
|
|
||||||
if (in_WGTS(loc_m)) {
|
|
||||||
double z_wgtsHalf_m = z_WGTS_start_m + (z_WGTS_end_m - z_WGTS_start_m)/2;
|
|
||||||
double sign = (loc_m[2] < z_wgtsHalf_m) ? -1 : 1;
|
|
||||||
double zSpeed_ms = sign*wgtsT2FlowSpeed_ms;
|
|
||||||
return vec3(0,0,zSpeed_ms);
|
|
||||||
} else {
|
|
||||||
return vec3(0,0,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec3 Thermal_Population::roll_v_ms(const vec3 &loc_m) {
|
|
||||||
if (!in_Katrin(loc_m)) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::roll_v_ms: loc_m outside of Katrin.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
return get_average_v_ms(loc_m) + roll_thermSpeed_ms(loc_m);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec3 Thermal_Population::roll_thermSpeed_ms(const vec3 &loc_m) {
|
|
||||||
double E_eV = roll_MBEnergy(wgtsTemp_K, m_eV, rngNormal);
|
|
||||||
double abs_v_ms = calc_v_ms_from_E_eV(E_eV, m_eV);
|
|
||||||
vec3 v_ms = roll_uniform_direction(rngUni)*abs_v_ms;
|
|
||||||
return v_ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline meta_vec Thermal_Population::get_bins_meta_info() {
|
|
||||||
Lin_Scale z_scale = get_z_scale();
|
|
||||||
Lin_Scale r_scale = get_r_scale();
|
|
||||||
Lin_Scale phi_scale = calc_phi_scale();
|
|
||||||
|
|
||||||
meta_vec res;
|
|
||||||
pop_bin_meta_info temp_bin = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
temp_bin.E_bin = 0;
|
|
||||||
temp_bin.E_min_eV = NAN;
|
|
||||||
temp_bin.E_max_eV = NAN;
|
|
||||||
temp_bin.z_min_m = z_scale.get_lower_scale_end();
|
|
||||||
for (int i_z=0; i_z<z_scale.get_number_bins(); i_z++) {
|
|
||||||
temp_bin.z_bin = i_z;
|
|
||||||
temp_bin.z_max_m = z_scale.get_upper_bin_bound(i_z);
|
|
||||||
temp_bin.r_min_m = r_scale.get_lower_scale_end();
|
|
||||||
for (int i_r=0; i_r<r_scale.get_number_bins(); i_r++) {
|
|
||||||
temp_bin.r_bin = i_r;
|
|
||||||
temp_bin.r_max_m = r_scale.get_upper_bin_bound(i_r);
|
|
||||||
temp_bin.phi_min = phi_scale.get_lower_scale_end();
|
|
||||||
for (int i_phi=0; i_phi<phi_scale.get_number_bins(); i_phi++) {
|
|
||||||
temp_bin.phi_bin = i_phi;
|
|
||||||
temp_bin.phi_max = phi_scale.get_upper_bin_bound(i_phi);
|
|
||||||
res.push_back(temp_bin);
|
|
||||||
temp_bin.phi_min = temp_bin.phi_max;
|
|
||||||
}
|
|
||||||
temp_bin.r_min_m = temp_bin.r_max_m;
|
|
||||||
}
|
|
||||||
temp_bin.z_min_m = temp_bin.z_max_m;
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bin_content_vec Thermal_Population::get_bins_content() {
|
inline vec3 Thermal_Population::roll_v_ms (const vec3 &loc_m) {
|
||||||
Lin_Scale z_scale = get_z_scale();
|
return WGTS_Kinematics::roll_v_ms(loc_m);
|
||||||
Lin_Scale r_scale = get_r_scale();
|
|
||||||
Lin_Scale phi_scale = calc_phi_scale();
|
|
||||||
|
|
||||||
bin_content_vec res;
|
|
||||||
pop_bin_content temp_bin = {0, 0, 0, 0, 0, 0};
|
|
||||||
temp_bin.E_bin = -1;
|
|
||||||
for (int i_z=0; i_z < z_scale.get_number_bins(); i_z++) {
|
|
||||||
temp_bin.z_bin = i_z;
|
|
||||||
for (int i_r=0; i_r < r_scale.get_number_bins(); i_r++) {
|
|
||||||
temp_bin.r_bin = i_r;
|
|
||||||
for (int i_phi=0; i_phi < phi_scale.get_number_bins(); i_phi++) {
|
|
||||||
temp_bin.phi_bin = i_phi;
|
|
||||||
temp_bin.cumulated_time_s = cumulated_times_s.get_value_by_bin(i_z, i_r, i_phi);
|
|
||||||
temp_bin.offset = number_annhilated.get_value_by_bin(i_z, i_r, i_phi);
|
|
||||||
res.push_back(temp_bin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bin_count4 Thermal_Population::get_bin_count4() {
|
inline Population_Container *Thermal_Population::access_container() {
|
||||||
bin_count4 res;
|
return &container;
|
||||||
res[0] = get_z_scale().get_number_bins();
|
|
||||||
res[1] = get_r_scale().get_number_bins();
|
|
||||||
res[2] = calc_phi_scale().get_number_bins();
|
|
||||||
res[3] = 0;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Thermal_Population::set_bins(bin_count4 bin_counts, bin_content_vec bin_contents) {
|
|
||||||
int num_z_bins = bin_counts[0];
|
|
||||||
int num_r_bins = bin_counts[1];
|
|
||||||
int num_phi_bins = bin_counts[2];
|
|
||||||
cumulated_times_s = Pop3_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
number_annhilated = Pop3_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
bin_sizes = Size_Container(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
//init_containers(num_z_bins, num_r_bins, num_phi_bins);
|
|
||||||
if (bin_counts[3]!=0) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::set_bins: E_bins != 0.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
int z_bin, r_bin, phi_bin;
|
|
||||||
double cumulated_time_s, offset;
|
|
||||||
for(bin_content_vec::iterator itr = bin_contents.begin(); itr != bin_contents.end(); itr++) {
|
|
||||||
z_bin = (*itr).z_bin;
|
|
||||||
r_bin = (*itr).r_bin;
|
|
||||||
phi_bin = (*itr).phi_bin;
|
|
||||||
cumulated_time_s = (*itr).cumulated_time_s;
|
|
||||||
offset = (*itr).offset;
|
|
||||||
cumulated_times_s.set_value_by_bin(cumulated_time_s, z_bin, r_bin, phi_bin);
|
|
||||||
number_annhilated.set_value_by_bin(offset, z_bin, r_bin, phi_bin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Thermal_Population::get_z_scale() {
|
|
||||||
if (cumulated_times_s.get_z_scale() == number_annhilated.get_z_scale()) {
|
|
||||||
return cumulated_times_s.get_z_scale();
|
|
||||||
} else {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::get_z_scale: Missmatch in scales.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Thermal_Population::get_r_scale() {
|
|
||||||
if (cumulated_times_s.get_r_scale() == number_annhilated.get_r_scale()) {
|
|
||||||
return cumulated_times_s.get_r_scale();
|
|
||||||
} else {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::get_r_scale: Missmatch in scales.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Lin_Scale Thermal_Population::calc_phi_scale() {
|
|
||||||
if (cumulated_times_s.calc_phi_scale() == number_annhilated.calc_phi_scale()) {
|
|
||||||
return cumulated_times_s.calc_phi_scale();
|
|
||||||
} else {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Thermal_Population::calc_phi_scale: Missmatch in scales.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int Thermal_Population::get_array_length() {
|
|
||||||
return cumulated_times_s.get_total_data_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double *Thermal_Population::get_cumulated_time_s_array() {
|
|
||||||
return cumulated_times_s.get_array();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double *Thermal_Population::get_offset_array() {
|
|
||||||
return number_annhilated.get_array();
|
|
||||||
}
|
|
||||||
#endif /* Thermal_Population_h */
|
#endif /* Thermal_Population_h */
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void Timer::set_T2_activity_s() {
|
|||||||
T2_activity_s = NT2*decayConstT2_s;
|
T2_activity_s = NT2*decayConstT2_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Timer::get_physTime_s() {
|
double Timer::get_time_s() {
|
||||||
return double(calc_total_decays())/T2_activity_s + offset_time_s;
|
return double(calc_total_decays())/T2_activity_s + offset_time_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ private:
|
|||||||
void set_T2_activity_s();
|
void set_T2_activity_s();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double get_physTime_s();
|
double get_time_s();
|
||||||
private:
|
private:
|
||||||
long int calc_total_decays();
|
long int calc_total_decays();
|
||||||
|
|
||||||
|
|||||||
@@ -9,21 +9,18 @@
|
|||||||
#ifndef tritium2_population_h
|
#ifndef tritium2_population_h
|
||||||
#define tritium2_population_h
|
#define tritium2_population_h
|
||||||
|
|
||||||
#include "velocity_container.hpp"
|
#include "wgts_kinematics.h"
|
||||||
|
|
||||||
|
class T2_Population : public Population_Base, private RNG_Base, public WGTS_Kinematics {
|
||||||
class T2_Population : public Population_Base, public RNG_Base {
|
|
||||||
static const double wgtsT2MaxDensity_m3;
|
static const double wgtsT2MaxDensity_m3;
|
||||||
static const double wgtsTemp_K;
|
|
||||||
static const double wgtsT2FlowSpeed_ms;
|
|
||||||
Velocity_Container v_data;
|
|
||||||
int n_regimes;
|
int n_regimes;
|
||||||
double *reduction_min;
|
double *reduction_min;
|
||||||
double *z_min_m;
|
double *z_min_m;
|
||||||
double *slopes;
|
double *slopes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T2_Population(UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium2), RNG_Base(rngUni, rngNormal) , v_data(get_data_path() + "velocity.dat") {
|
T2_Population(UniRNG *rngUni, NormalRNG *rngNormal) : Population_Base(tritium2), RNG_Base(rngUni, rngNormal), WGTS_Kinematics(rngUni, rngNormal) {
|
||||||
set_regimes();
|
set_regimes();
|
||||||
};
|
};
|
||||||
~T2_Population() {
|
~T2_Population() {
|
||||||
@@ -33,41 +30,22 @@ public:
|
|||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
void set_regimes();
|
void set_regimes();
|
||||||
public:
|
|
||||||
double get_density_m3 (const vec3 &loc_m);
|
|
||||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {};
|
|
||||||
void decrease_denisty (const vec3 &oldLoc_m, const double &energy_eV) {};
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
vec3 roll_v_ms (const vec3 &loc_m);
|
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {}
|
||||||
private:
|
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {}
|
||||||
vec3 get_average_v_ms (const vec3 &loc_m);
|
|
||||||
vec3 roll_thermSpeed_ms(const vec3 &loc_m);
|
|
||||||
|
|
||||||
public:
|
double get_density_m3(const vec3 &loc_m);
|
||||||
int get_number_E_bins() {return 0;}
|
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||||
double get_E_eV (const int &E_bin) {throw MyException("Not implemented \n");}
|
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||||
double get_density_m3(const vec3 &loc_m, const int &E_bin) {throw MyException("Not implemented \n");};
|
|
||||||
|
|
||||||
public:
|
vec3 roll_v_ms (const vec3 &loc_m) {return WGTS_Kinematics::roll_v_ms(loc_m);}
|
||||||
meta_vec get_bins_meta_info();
|
|
||||||
bin_content_vec get_bins_content();
|
Population_Container *access_container() {return nullptr;};
|
||||||
bin_count4 get_bin_count4();
|
|
||||||
void set_bins(bin_count4 bin_counts, bin_content_vec bin_contents) {};
|
|
||||||
private:
|
|
||||||
double calc_DensityTriangle(const double &z_m);
|
|
||||||
double interpolate_red(const double &z_m, const double &z_min_m, const double &z_max_m, const double &red_min, const double &red_max);
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_array_length() {return 0;}
|
|
||||||
double *get_cumulated_time_s_array() {return NULL;}
|
|
||||||
double *get_offset_array() {return NULL;}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const double T2_Population::wgtsT2MaxDensity_m3 = load_parameter("wgtsT2MaxDensity_m3");
|
const double T2_Population::wgtsT2MaxDensity_m3 = load_parameter("wgtsT2MaxDensity_m3");
|
||||||
const double T2_Population::wgtsTemp_K = load_parameter("wgtsTemp_K");
|
|
||||||
const double T2_Population::wgtsT2FlowSpeed_ms = load_parameter("wgtsT2FlowSpeed_ms");
|
|
||||||
|
|
||||||
inline void T2_Population::set_regimes() {
|
inline void T2_Population::set_regimes() {
|
||||||
n_regimes = 4;
|
n_regimes = 4;
|
||||||
@@ -88,16 +66,7 @@ inline void T2_Population::set_regimes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||||
if (!in_Katrin(loc_m)) {
|
double z_m = calc_z_m(loc_m);
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"T2_Population::get_density_m3: loc_m outside of Katrin.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
return calc_DensityTriangle(loc_m[2]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double T2_Population::calc_DensityTriangle(const double &z_m) {
|
|
||||||
for (int i = (n_regimes-1); i>=0; i--) {
|
for (int i = (n_regimes-1); i>=0; i--) {
|
||||||
if (z_m>z_min_m[i]) {
|
if (z_m>z_min_m[i]) {
|
||||||
double reduction_factor = reduction_min[i] + (z_m-z_min_m[i])*slopes[i];
|
double reduction_factor = reduction_min[i] + (z_m-z_min_m[i])*slopes[i];
|
||||||
@@ -109,51 +78,16 @@ inline double T2_Population::calc_DensityTriangle(const double &z_m) {
|
|||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Content T2_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||||
inline vec3 T2_Population::roll_v_ms(const vec3 &loc_m) {
|
|
||||||
if (!in_Katrin(loc_m)) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"T2_Population::roll_v_ms: loc_m outside of Katrin.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
}
|
|
||||||
return get_average_v_ms(loc_m) + roll_thermSpeed_ms(loc_m);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline meta_vec T2_Population::get_bins_meta_info() {
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"T2_Population::get_bins_meta_info: Not implemented \n";
|
ss<<"T2_Population::get_density_m3: method for non thermal populations.\n";
|
||||||
throw MyException (ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bin_content_vec T2_Population::get_bins_content() {
|
inline Sum_bounds T2_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||||
std::stringstream ss;
|
Sum_bounds res;
|
||||||
ss<<"T2_Population::get_bins_content: Not implemented \n";
|
res.num_E_bins = 0;
|
||||||
throw MyException (ss.str());
|
return res;
|
||||||
}
|
|
||||||
|
|
||||||
inline bin_count4 T2_Population::get_bin_count4() {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"T2_Population::get_bin_count4: Not implemented \n";
|
|
||||||
throw MyException (ss.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec3 T2_Population::get_average_v_ms(const vec3 &loc_m) {
|
|
||||||
return v_data.get_v_ms(loc_m);
|
|
||||||
/*if (in_WGTS(loc_m)) {
|
|
||||||
double z_wgtsHalf_m = z_WGTS_start_m + (z_WGTS_end_m - z_WGTS_start_m)/2;
|
|
||||||
double sign = (loc_m[2] < z_wgtsHalf_m) ? -1 : 1;
|
|
||||||
double zSpeed_ms = sign*wgtsT2FlowSpeed_ms;
|
|
||||||
return vec3(0,0,zSpeed_ms);
|
|
||||||
} else {
|
|
||||||
return vec3(0,0,0);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vec3 T2_Population::roll_thermSpeed_ms(const vec3 &loc_m) {
|
|
||||||
double E_eV = roll_MBEnergy(wgtsTemp_K, 2*mT_eV, rngNormal);
|
|
||||||
double Speed_ms = calc_v_ms_from_E_eV(E_eV, 2*mT_eV);
|
|
||||||
vec3 v_ms = roll_uniform_direction(rngUni)*Speed_ms;
|
|
||||||
return v_ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// wgts_kinematics.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 02.08.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef wgts_kinematics_h
|
||||||
|
#define wgts_kinematics_h
|
||||||
|
|
||||||
|
#include "velocity_container.hpp"
|
||||||
|
|
||||||
|
class WGTS_Kinematics {
|
||||||
|
static const double wgtsTemp_K;
|
||||||
|
static const double wgtsT2FlowSpeed_ms;
|
||||||
|
|
||||||
|
Velocity_Container v_data;
|
||||||
|
|
||||||
|
UniRNG *rngUni;
|
||||||
|
NormalRNG *rngNormal;
|
||||||
|
public:
|
||||||
|
WGTS_Kinematics(UniRNG *rngUni, NormalRNG *rngNormal) : v_data(get_data_path() + "velocity.dat"){
|
||||||
|
this->rngUni = rngUni;
|
||||||
|
this->rngNormal = rngNormal;
|
||||||
|
}
|
||||||
|
vec3 roll_v_ms(const vec3 &loc_m) {
|
||||||
|
return roll_v_thermal_ms() + get_v_offset_ms(loc_m);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
vec3 roll_v_thermal_ms() {
|
||||||
|
double E_eV = roll_MBEnergy(wgtsTemp_K, 2*mT_eV, rngNormal);
|
||||||
|
double Speed_ms = calc_v_ms_from_E_eV(E_eV, 2*mT_eV);
|
||||||
|
vec3 v_ms = roll_uniform_direction(rngUni)*Speed_ms;
|
||||||
|
return v_ms;
|
||||||
|
}
|
||||||
|
vec3 get_v_offset_ms(const vec3 &loc_m) {
|
||||||
|
return v_data.get_v_ms (loc_m);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const double WGTS_Kinematics::wgtsTemp_K = load_parameter("wgtsTemp_K");
|
||||||
|
const double WGTS_Kinematics::wgtsT2FlowSpeed_ms = load_parameter("wgtsT2FlowSpeed_ms");
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* wgts_kinematics_h */
|
||||||
@@ -6,18 +6,47 @@
|
|||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "tcs_container.hpp"
|
|
||||||
#include "dcs_container.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main() {
|
class data_holder {
|
||||||
clock_t start;
|
int data;
|
||||||
UniRNG rngUni;
|
friend class data_setter;
|
||||||
TCS_Container tcs_data = TCS_Container(1e-5, 2e4, 1e3, get_data_path() + "eT2_TCS_ela_concat.dat");
|
public:
|
||||||
DCS_Theta_Container dcs_data = DCS_Theta_Container(1e-5, 2e4, 1e3, 200, get_data_path() + "eT2_DCS_ela_concat.dat");
|
data_holder() {
|
||||||
|
data = 3;
|
||||||
|
}
|
||||||
|
int get_data() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//tcs_data.debug();
|
class data_interface {
|
||||||
std::cout<<tcs_data.get_value(0)<<"\n";
|
data_holder data;
|
||||||
|
friend class data_setter;
|
||||||
|
public:
|
||||||
|
data_interface() {};
|
||||||
|
void show_data() {
|
||||||
|
cout<<"data = \t"<<data.get_data()<<"\n";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class data_setter {
|
||||||
|
data_interface *data;
|
||||||
|
public:
|
||||||
|
data_setter(data_interface *data) {
|
||||||
|
this->data = data;
|
||||||
|
}
|
||||||
|
void set_data(int input) {
|
||||||
|
data->data.data = input;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
data_interface data;
|
||||||
|
data_setter data_s(&data);
|
||||||
|
data_s.set_data(5);
|
||||||
|
data.show_data();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user