Moved serial mode to target mcelecron_serial.
Implemented parallelization with mpi.
This commit is contained in:
@@ -57,6 +57,11 @@ private:
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
@@ -81,18 +86,12 @@ inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
||||
ss<<"Kinetic_Population::get_density_m3: loc_m outside of Katrin.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double total_cumulated_time_s = cumulated_times_s.get_value_sum(loc_m);
|
||||
double total_annhilated = number_annhilated.get_value_sum(loc_m);
|
||||
|
||||
double physical_time_s = timer->get_physTime_s();
|
||||
int num_E_bins = cumulated_times_s.get_num_E_bins();
|
||||
double *cumulated_time_s = cumulated_times_s.get_E_bins(loc_m);
|
||||
double *offset = number_annhilated.get_E_bins(loc_m);
|
||||
double total_cumulated_time_s = 0;
|
||||
double total_offset = 0;
|
||||
for (int i=0; i<num_E_bins; i++) {
|
||||
total_cumulated_time_s += cumulated_time_s[i];
|
||||
total_offset += offset[i];
|
||||
}
|
||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
||||
double dens_m3 = total_cumulated_time_s/physical_time_s/bin_size_m3 - total_offset;
|
||||
double dens_m3 = total_cumulated_time_s/physical_time_s/bin_size_m3 - total_annhilated;
|
||||
dens_m3 = (dens_m3 < 0) ? 0 : dens_m3;
|
||||
return dens_m3;
|
||||
}
|
||||
@@ -119,15 +118,25 @@ inline vec3 Kinetic_Population::roll_v_ms(const vec3 &loc_m) {
|
||||
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 = cumulated_times_s.get_E_bins(loc_m);
|
||||
double *offset = number_annhilated.get_E_bins(loc_m);
|
||||
|
||||
double cumulated_time_s;
|
||||
double offset;
|
||||
double delta_density_m3;
|
||||
double cum_density_m3 = 0;
|
||||
for (int i=0; i<num_E_bins; i++) {
|
||||
cum_density_m3 += cumulated_time_s[i]/physical_time_s/bin_size_m3 - offset[i];
|
||||
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_corresponding_E_lower_eV(i);
|
||||
double upper = cumulated_times_s.get_corresponding_E_upper_eV(i);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -223,13 +232,13 @@ inline void Kinetic_Population::set_bins(bin_count4 bin_counts, bin_content_vec
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
@@ -255,4 +264,16 @@ inline Log_Scale Kinetic_Population::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 */
|
||||
|
||||
Reference in New Issue
Block a user