Cleaned up Populations class.
Renamed some functions, so no dummy parameters need to be used.
This commit is contained in:
@@ -29,8 +29,10 @@ public:
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
int get_number_E_bins();
|
||||
Bins get_loc_bin(const vec3 & loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m);
|
||||
@@ -61,24 +63,31 @@ inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
||||
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) {
|
||||
inline double Kinetic_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||
}
|
||||
|
||||
inline Sum_bounds Kinetic_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||
return container.get_sumation_bounds(loc_m);
|
||||
int Kinetic_Population::get_number_E_bins() {
|
||||
return container.get_number_E_bins();
|
||||
}
|
||||
Bins Kinetic_Population::get_loc_bin(const vec3 & loc_m) {
|
||||
return container.calc_loc_bin(loc_m);
|
||||
}
|
||||
|
||||
double Kinetic_Population::get_E_bin_mid_eV(const int &E_bin) {
|
||||
return container.get_E_bin_mid_eV(E_bin);
|
||||
}
|
||||
|
||||
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
||||
Sum_bounds bounds = container.get_sumation_bounds(loc_m);
|
||||
Bins loc_bins = get_loc_bin(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;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
target += get_density_m3(E_bin, loc_bins);
|
||||
}
|
||||
target *= rngUni->random();
|
||||
double current = 0;
|
||||
for (int E_bin = 0; E_bin<bounds.num_E_bins; E_bin++) {
|
||||
current += get_density_m3(E_bin, bounds.loc_bins).n_m3;
|
||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||
current += get_density_m3(E_bin, loc_bins);
|
||||
if (current >= target) {
|
||||
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,11 @@ public:
|
||||
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 double get_density_m3(const int &E_bin, const Bins &loc_bins) = 0;
|
||||
virtual int get_number_E_bins() = 0;
|
||||
virtual Bins get_loc_bin(const vec3 & loc_m) = 0;
|
||||
virtual double get_E_bin_mid_eV(const int &E_bin) = 0;
|
||||
|
||||
double get_m_eV() {return m_eV;}
|
||||
|
||||
virtual vec3 roll_x_ms() = 0;
|
||||
|
||||
@@ -128,10 +128,10 @@ void Population_Container::increase_offset(const vec3 &loc_m, const double &E_eV
|
||||
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;
|
||||
return get_density_m3(E_bin, loc_bins, time_s);
|
||||
}
|
||||
|
||||
Content Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s) {
|
||||
double 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];
|
||||
@@ -141,19 +141,11 @@ Content Population_Container::get_density_m3(const int &E_bin, const Bins &loc_b
|
||||
if (n_m3<0) {
|
||||
n_m3 = 0;
|
||||
}
|
||||
double E_eV = E_scale.get_bin_mid(E_bin);
|
||||
return Content({E_eV, n_m3});
|
||||
return 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);
|
||||
int Population_Container::get_number_E_bins() {
|
||||
return E_scale.get_number_bins();
|
||||
}
|
||||
|
||||
Bins Population_Container::calc_loc_bin(const vec3 &loc_m) {
|
||||
@@ -164,6 +156,16 @@ Bins Population_Container::calc_loc_bin(const vec3 &loc_m) {
|
||||
return res;
|
||||
}
|
||||
|
||||
double Population_Container::get_E_bin_mid_eV(const int &E_bin) {
|
||||
return E_scale.get_bin_mid(E_bin);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -70,14 +70,15 @@ public:
|
||||
|
||||
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_density_m3(const int &E_bin, const Bins &loc_bins, const double &time_s);
|
||||
int get_number_E_bins();
|
||||
Bins calc_loc_bin(const vec3 &loc_m);
|
||||
double get_E_bin_mid_eV(const int &E_bin);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@@ -169,13 +169,11 @@ inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const doub
|
||||
int EI_bin = E_scale.calc_index(E_eV);
|
||||
double *microSigmas = precomputed_values[EI_bin];
|
||||
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(loc_m);
|
||||
Content cont;
|
||||
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
cont = Population->get_density_m3(Ee_bin, bounds.loc_bins);
|
||||
macro_sigma_m += microSigmas[Ee_bin] * cont.n_m3;
|
||||
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ protected:
|
||||
|
||||
public:
|
||||
e_thermal_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(vec3(0,0,0));
|
||||
if (bounds.num_E_bins > 1) {
|
||||
if (Population->get_number_E_bins() > 1) {
|
||||
throw MyException("Population is not thermal, when expected thermal.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
@@ -130,8 +129,7 @@ protected:
|
||||
|
||||
public:
|
||||
TI_thermal_binary_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(vec3(0,0,0));
|
||||
if (bounds.num_E_bins > 1) {
|
||||
if (Population->get_number_E_bins() > 1) {
|
||||
throw MyException("Population is not thermal, when expected thermal.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
@@ -172,8 +170,7 @@ protected:
|
||||
|
||||
public:
|
||||
TI_thermal_tenary_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(vec3(0,0,0));
|
||||
if (bounds.num_E_bins > 1) {
|
||||
if (Population->get_number_E_bins() > 1) {
|
||||
throw MyException("Population is not thermal, when expected thermal.");
|
||||
}
|
||||
this->m_eV = m_eV;
|
||||
@@ -219,19 +216,16 @@ public:
|
||||
m_eV = Population->get_m_eV();
|
||||
this->mI_eV = mI_eV;
|
||||
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(vec3(0,0,0));
|
||||
num_Ee_bins = bounds.num_E_bins;
|
||||
num_Ee_bins = Population->get_number_E_bins();
|
||||
if (num_Ee_bins <= 1) {
|
||||
throw MyException("Population is not kinetic, when kinetic thermal.");
|
||||
}
|
||||
ve_mids = new double[num_Ee_bins];
|
||||
Ee_mids = new double[num_Ee_bins];
|
||||
|
||||
Content cont;
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
cont = Population->get_density_m3(Ee_bin, Bins{0,0,0});
|
||||
Ee_mids[Ee_bin] = cont.E_eV;
|
||||
ve_mids[Ee_bin] = sqrt(2*cont.E_eV/m_eV)*c_ms;
|
||||
Ee_mids[Ee_bin] = Population->get_E_bin_mid_eV(Ee_bin);
|
||||
ve_mids[Ee_bin] = sqrt(2*Ee_mids[Ee_bin]/m_eV)*c_ms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,12 +236,10 @@ protected:
|
||||
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||
|
||||
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||
Sum_bounds bounds = Population->get_sumation_bounds(loc_m);
|
||||
Content cont;
|
||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||
double macro_sigma_m = 0;
|
||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||
cont = Population->get_density_m3(Ee_bin, bounds.loc_bins);
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * cont.n_m3;
|
||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * Population->get_density_m3(Ee_bin, loc_bins);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
@@ -25,27 +25,16 @@ public:
|
||||
this->kinematics = kinematics;
|
||||
}
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||
container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());
|
||||
}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m) {container.increase_cum_time_s(oldLoc_m, upPart.get_x_m(), calc_vec3_abs(upPart.get_v_ms()), upPart.get_E_eV());}
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {container.increase_offset(loc_m, E_eV);}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m) {return container.get_density_m3(loc_m, 0, timer->get_time_s());}
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m) {
|
||||
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
||||
}
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
std::stringstream ss;
|
||||
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());
|
||||
}
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m) {
|
||||
Sum_bounds res;
|
||||
res.num_E_bins = 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
vec3 roll_x_ms() {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
|
||||
@@ -38,8 +38,11 @@ public:
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {}
|
||||
|
||||
double get_density_m3(const vec3 &loc_m);
|
||||
Content get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||
Sum_bounds get_sumation_bounds(const vec3 &loc_m);
|
||||
|
||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||
int get_number_E_bins() {return 1;}
|
||||
Bins get_loc_bin(const vec3 & loc_m) {throw MyException("Should not be called.\n.");}
|
||||
double get_E_bin_mid_eV(const int &E_bin) {throw MyException("Should not be called.\n.");}
|
||||
|
||||
vec3 roll_x_ms();
|
||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||
@@ -83,17 +86,7 @@ inline double T2_Population::get_density_m3(const vec3 &loc_m) {
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Content T2_Population::get_density_m3(const int &E_bin, const Bins &loc_bins) {
|
||||
std::stringstream ss;
|
||||
ss<<"T2_Population::get_density_m3: method for non thermal populations.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Sum_bounds T2_Population::get_sumation_bounds(const vec3 &loc_m) {
|
||||
Sum_bounds res;
|
||||
res.num_E_bins = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
inline vec3 T2_Population::roll_x_ms() {
|
||||
double r_m = r_WGTS_m*sqrt(rngUni->random());
|
||||
|
||||
Reference in New Issue
Block a user