eT2_T2I_Ionization_Janev_(label) 1. non dissoziative labeled as ndiss 2. dissoziative via X2 Sigma^+_g labeled as diss_g 3. dissoziative via B2 Sigma^+_u labeled as diss_u Added more Excitation Channels e + T2 from Janev
255 lines
8.4 KiB
C++
255 lines
8.4 KiB
C++
//
|
|
// energetic_base.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 11.06.19.
|
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef energetic_base_h
|
|
#define energetic_base_h
|
|
|
|
|
|
#include "katrin_geo.hpp"
|
|
|
|
#include <fstream>
|
|
|
|
#include "population4_container.hpp"
|
|
#include "size_container.hpp"
|
|
#include "lin_scale.h"
|
|
|
|
#include "population_base.h"
|
|
|
|
|
|
class Kinetic_Population : public Population_Base, protected RNG_Base{
|
|
Pop4_Container cumulated_times_s;
|
|
Pop4_Container number_annhilated;
|
|
|
|
Size_Container bin_sizes;
|
|
|
|
Timer *timer;
|
|
|
|
double m_eV;
|
|
|
|
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);
|
|
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 decrease_denisty (const vec3 &loc_m, const double &energy_eV);
|
|
|
|
public:
|
|
vec3 get_average_speed_ms (const vec3 &loc_m);
|
|
vec3 roll_speed_ms (const vec3 &loc_m);
|
|
private:
|
|
vec3 roll_thermSpeed_ms(const vec3 &loc_m);
|
|
|
|
public:
|
|
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 get_phi_scale();
|
|
Log_Scale get_E_scale();
|
|
};
|
|
|
|
|
|
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),
|
|
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;
|
|
//init_containers(num_z_bins, num_r_bins, num_phi_bins, num_E_bins);
|
|
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) {
|
|
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);
|
|
}
|
|
*/
|
|
inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
|
//Katrin_Geo::check_inKatrin(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;
|
|
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_SpeedAbs_ms();
|
|
double energy_eV = upPart.get_EKin_eV();
|
|
cumulated_times_s.increase_value(cell_time_s, upPart.get_Location_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_speed_ms(const vec3 &loc_m) {
|
|
return vec3(0,0,0);
|
|
}
|
|
|
|
inline vec3 Kinetic_Population::roll_speed_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);
|
|
|
|
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 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];
|
|
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);
|
|
return lower + rngUni->random() * (upper-lower);
|
|
}
|
|
}
|
|
std::stringstream ss;
|
|
ss<<"Kinetic_Population::roll_speed_ms: Overflow.\n";
|
|
throw MyException (ss.str());
|
|
}
|
|
|
|
|
|
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 = get_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 = get_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] = get_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::get_phi_scale() {
|
|
return cumulated_times_s.get_phi_scale();
|
|
|
|
}
|
|
|
|
inline Log_Scale Kinetic_Population::get_E_scale() {
|
|
return cumulated_times_s.get_E_scale();
|
|
|
|
}
|
|
|
|
#endif /* energetic_base_h */
|