Extracting random point in file.

No Integration for Reaction Rate Cross sections.
This commit is contained in:
Christian
2019-11-19 13:17:00 +01:00
parent cabafc7757
commit da60c6a574
12 changed files with 59 additions and 40 deletions
+3 -3
View File
@@ -12,11 +12,11 @@
#include "TI_thermal_binary_base.h"
class T3IT2_RadAsc : public TI_thermal_binary_Precomputed_Interaction_Base {
class T3IT2_RadAsc : public TI_thermal_Rate_Interaction_Base {
public:
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, 3*mT_eV) {
calc_values(); // need to call here, because, constructor can't call pure virtual function
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 1) {
//calc_values(); // need to call here, because, constructor can't call pure virtual function
};
double get_microSigma_m2(const double &E_eV) {
+4 -4
View File
@@ -12,14 +12,14 @@
#include "TI_thermal_tenary_base.h"
class T3IT2_TerAsc : public TI_thermal_tenary_Precomputed_Interaction_Base {
class T3IT2_TerAsc : public TI_thermal_Rate_Interaction_Base {
public:
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_tenary_Precomputed_Interaction_Base(T2Population, rngUni, 3*mT_eV) {
calc_values(); // need to call here, because, constructor can't call pure virtual function
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 2) {
//calc_values(); // need to call here, because, constructor can't call pure virtual function
};
double get_microSigma_divbyn_m2(const double &E_eV) {
double get_microSigma_m2(const double &E_eV) {
double v_ms = calc_v_ms_from_E_eV(E_eV, 3*mT_eV);
return 7e-41*v_ms; // CS from Gerlich:1990aa
}
+3 -3
View File
@@ -11,11 +11,11 @@
#include "TI_thermal_binary_base.h"
class TIT2_RadAsc : public TI_thermal_binary_Precomputed_Interaction_Base {
class TIT2_RadAsc : public TI_thermal_Rate_Interaction_Base {
public:
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_binary_Precomputed_Interaction_Base(T2Population, rngUni, mT_eV) {
calc_values(); // need to call here, because, constructor can't call pure virtual function
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 1) {
//calc_values(); // need to call here, because, constructor can't call pure virtual function
};
double get_microSigma_m2(const double &E_eV) {
+4 -4
View File
@@ -12,14 +12,14 @@
#include "TI_thermal_tenary_base.h"
class TIT2_TerAsc : public TI_thermal_tenary_Precomputed_Interaction_Base {
class TIT2_TerAsc : public TI_thermal_Rate_Interaction_Base {
public:
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_tenary_Precomputed_Interaction_Base(T2Population, rngUni, mT_eV) {
calc_values(); // need to call here, because, constructor can't call pure virtual function
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 2) {
//calc_values(); // need to call here, because, constructor can't call pure virtual function
};
double get_microSigma_divbyn_m2(const double &E_eV) {
double get_microSigma_m2(const double &E_eV) {
double v_ms = calc_v_ms_from_E_eV(E_eV, mT_eV);
return 2.6e-41/v_ms; // CS from Plasil:2012
}
+2 -2
View File
@@ -31,7 +31,7 @@ protected:
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
double calc_microSigma_divbyn_m2(const double &E_eV);
private:
virtual double get_microSigma_divbyn_m2(const double &E_eV) = 0;
virtual double get_microSigma_m2(const double &E_eV) = 0;
};
inline double TI_thermal_tenary_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
@@ -49,7 +49,7 @@ inline double TI_thermal_tenary_Interaction_Base::calc_microSigma_divbyn_m2(cons
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
auto integrand = [&](double theta) {
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v_therm,2) - 2*v1_ms*v_therm*cos(theta)) * pow(c_ms, -2);
return get_microSigma_divbyn_m2(E_eV);
return get_microSigma_m2(E_eV);
};
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson())/pi;
}
+2 -2
View File
@@ -70,9 +70,9 @@ void DCS_Ionization_Container::calc_data(std::string load_path) {
int num_W_bins = W_scale[0].get_number_bins();
double *temp;
double sum;
double E_eV;
//double E_eV;
for (int i = 0; i<num_T_bins; i++) {
E_eV = T_scale.get_bin_mid(i);
//E_eV = T_scale.get_bin_mid(i);
temp = new double[num_W_bins];
sum = 0;
+1 -1
View File
@@ -65,7 +65,7 @@ void DCS_Theta_Container::calc_data(std::string load_path) {
double sum;
double E_eV;
for (int i = 0; i<number_E_bins; i++) {
E_eV = E_scale.get_bin_mid(i);
//E_eV = E_scale.get_bin_mid(i);
temp = new double[number_theta_bins];
sum = 0;
+5 -5
View File
@@ -11,7 +11,7 @@
#include "population_base.h"
#include <queue>
#include <vector>
#include "random_operations.h"
@@ -32,14 +32,14 @@ public:
this->ions = ions;
};
int inject (std::queue<Particle> *particle_queue, const int &last_ID);
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
private:
double roll_FermiEnergy_eV();
double get_FermiDecaySpectrumDensity(const double &E_eV);
double get_FermiFunction(const double &Z, const double &E_eV);
};
inline int Injector::inject (std::queue<Particle> *particle_queue, const int &last_ID) {
inline int Injector::inject (std::vector<Particle> *particle_queue, const int &last_ID) {
vec3 loc_m = T2Population->roll_x_ms();
double E_eV;
@@ -58,13 +58,13 @@ inline int Injector::inject (std::queue<Particle> *particle_queue, const int &la
break;
}
vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
particle_queue->push(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
if (ions == 0) {
return 1;
} else {
vec3 vTI_ms = T2Population->roll_v_ms(loc_m);
particle_queue->push(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
return 2;
}
+17
View File
@@ -56,4 +56,21 @@ public:
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
};
class TI_thermal_Rate_Interaction_Base : public Interaction_Base { // Binary interactions of tritium ions with thermal Populations
int n;
protected:
double m1_eV; // energy of kinetic particle for CS measurement : tritium ion
public:
TI_thermal_Rate_Interaction_Base(Population_Base *Population, UniRNG *rngUni, int n) : Interaction_Base(Population, rngUni) {
this-> n = n;
}
double get_macro_sigma_m(const Particle &interPart) {
return get_microSigma_m2(interPart.get_E_eV()) * pow (Population->get_density_m3(interPart.get_x_m()), n);
}
private:
virtual double get_microSigma_m2(const double &E_eV) = 0;
};
#endif /* interaction_base_h */
+8 -6
View File
@@ -26,7 +26,7 @@ void Particle_Looper::init_managers() {
}
void Particle_Looper::do_loops(int target_decays) {
queue<Particle> particle_queue;
vector<Particle> particle_queue;
int number_decays = 0;
while ( (number_decays < target_decays) || (!particle_queue.empty()) ) {
if (particle_queue.empty()) {
@@ -35,13 +35,15 @@ void Particle_Looper::do_loops(int target_decays) {
local_decays = local_decays + 1;
ID_counter = ID_counter + num_new;
}
process_first(&particle_queue);
process_one(&particle_queue);
}
pop_loggers.log();
}
void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
Particle curPart = particle_queue->front();
void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
int i = floor(rngUni.random()*particle_queue->size());
Particle curPart = particle_queue->at(i);
//Particle curPart = particle_queue->front();
Mover_Base *moverPtr = movers.find(curPart.get_species());
Interaction_Channel_Base *interactionPtr = interactions.find(curPart.get_species());
Terminator_Base *terminatorPtr = terminators.find(curPart.get_species());
@@ -59,7 +61,7 @@ void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
} else {
IntOut = interactionPtr->do_Interaction(&curPart);
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
particle_queue->push(IntOut.get_new_particles()[i]);
particle_queue->push_back(IntOut.get_new_particles()[i]);
particle_queue->back().set_Id(get_new_id());
}
if (IntOut.get_delete_current()) {
@@ -68,7 +70,7 @@ void Particle_Looper::process_first(std::queue<Particle> *particle_queue) {
}
}
}
particle_queue->pop();
particle_queue->erase(particle_queue->begin() + i);
}
long int Particle_Looper::get_new_id() {
+2 -2
View File
@@ -9,7 +9,7 @@
#ifndef particle_looper_hpp
#define particle_looper_hpp
#include <queue>
#include <vector>
#include "h5_file.hpp"
#include "timer.hpp"
@@ -67,7 +67,7 @@ private:
public:
void do_loops(int target_decays);
private:
void process_first(std::queue<Particle> *particle_queue);
void process_one(std::vector<Particle> *particle_queue);
long int get_new_id();
long int get_last_id();
+8 -8
View File
@@ -8,17 +8,17 @@
#include <iostream>
#include "../mc_electron/integrater.h"
#include <vector>
using namespace std;
double f(double x, double y, double a) { return a*x*y; }
int main() {
double a = 3;
auto g = [&] (double x) {
return f(x,x, a);
};
double s = integrate(g, 0.0, 1.0, 10, simpson());
cout<<s<<endl;
std::vector<int> vec;
vec.push_back(6);
vec.push_back(-17);
vec.push_back(12);
//vec.erase();
cout<<vec.size();
}