Included integration over v distribution of thermal population
Included integration over v distribution of thermal population
This commit is contained in:
@@ -9,14 +9,14 @@
|
|||||||
#ifndef T3IT2_radasc_h
|
#ifndef T3IT2_radasc_h
|
||||||
#define T3IT2_radasc_h
|
#define T3IT2_radasc_h
|
||||||
|
|
||||||
#include "TI_thermal_binary_base.h"
|
#include "TI_rate_base.h"
|
||||||
|
|
||||||
|
|
||||||
class T3IT2_RadAsc : public TI_thermal_Rate_Interaction_Base {
|
class T3IT2_RadAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 1) {
|
T3IT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 1) {
|
||||||
//calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
};
|
};
|
||||||
|
|
||||||
double get_microSigma_m2(const double &E_eV) {
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
#ifndef T3IT2_terasc_h
|
#ifndef T3IT2_terasc_h
|
||||||
#define T3IT2_terasc_h
|
#define T3IT2_terasc_h
|
||||||
|
|
||||||
#include "TI_thermal_tenary_base.h"
|
#include "TI_rate_base.h"
|
||||||
|
|
||||||
|
|
||||||
class T3IT2_TerAsc : public TI_thermal_Rate_Interaction_Base {
|
class T3IT2_TerAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 2) {
|
T3IT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 2) {
|
||||||
//calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
};
|
};
|
||||||
|
|
||||||
double get_microSigma_m2(const double &E_eV) {
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#ifndef TIT2_radasc_h
|
#ifndef TIT2_radasc_h
|
||||||
#define TIT2_radasc_h
|
#define TIT2_radasc_h
|
||||||
|
|
||||||
#include "TI_thermal_binary_base.h"
|
#include "TI_rate_base.h"
|
||||||
|
|
||||||
class TIT2_RadAsc : public TI_thermal_Rate_Interaction_Base {
|
class TIT2_RadAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 1) {
|
TIT2_RadAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 1) {
|
||||||
//calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
};
|
};
|
||||||
|
|
||||||
double get_microSigma_m2(const double &E_eV) {
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
#ifndef TIT2_terasc_h
|
#ifndef TIT2_terasc_h
|
||||||
#define TIT2_terasc_h
|
#define TIT2_terasc_h
|
||||||
|
|
||||||
#include "TI_thermal_tenary_base.h"
|
#include "TI_rate_base.h"
|
||||||
|
|
||||||
|
|
||||||
class TIT2_TerAsc : public TI_thermal_Rate_Interaction_Base {
|
class TIT2_TerAsc : public TI_thermal_Rate_Precomputed_Interaction_Base {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Interaction_Base(T2Population, rngUni, 2) {
|
TIT2_TerAsc(Population_Base *T2Population, UniRNG *rngUni) : TI_thermal_Rate_Precomputed_Interaction_Base(T2Population, rngUni, 2) {
|
||||||
//calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
};
|
};
|
||||||
|
|
||||||
double get_microSigma_m2(const double &E_eV) {
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
//
|
||||||
|
// TI_rate_base.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 20.11.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TI_rate_base_h
|
||||||
|
#define TI_rate_base_h
|
||||||
|
|
||||||
|
#include "interaction_base.h"
|
||||||
|
|
||||||
|
|
||||||
|
class TI_thermal_Rate_Interaction_Base : public Interaction_Base { // Binary interactions of tritium ions with thermal Populations
|
||||||
|
protected:
|
||||||
|
int n;
|
||||||
|
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);
|
||||||
|
protected:
|
||||||
|
double calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||||
|
double calc_microSigma_m2(const double &E_eV);
|
||||||
|
private:
|
||||||
|
virtual double get_microSigma_m2(const double &E_eV) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline double TI_thermal_Rate_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
|
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||||
|
}
|
||||||
|
|
||||||
|
double TI_thermal_Rate_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
|
return calc_microSigma_m2(E_eV) * pow (Population->get_density_m3(loc_m), n);
|
||||||
|
}
|
||||||
|
double TI_thermal_Rate_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||||
|
return get_microSigma_m2(E_eV);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TI_thermal_Rate_Precomputed_Interaction_Base : public TI_thermal_Rate_Interaction_Base { // + Using precomputed values
|
||||||
|
Log_Scale E_scale; // E_scale for Interpolation calculation
|
||||||
|
double *precomputed_values;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TI_thermal_Rate_Precomputed_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : TI_thermal_Rate_Interaction_Base(Population, rngUni, m_eV), E_scale(INT_PRE_START, INT_PRE_END, INT_PRE_N) {
|
||||||
|
precomputed_values = new double [E_scale.get_number_bins()];
|
||||||
|
}
|
||||||
|
void calc_values(); // must be called by derived class, can't call in this constructor, due to virtual pure
|
||||||
|
double get_macro_sigma_m(const Particle &interPart);
|
||||||
|
private:
|
||||||
|
double lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void TI_thermal_Rate_Precomputed_Interaction_Base::calc_values() {
|
||||||
|
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
||||||
|
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double TI_thermal_Rate_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
|
vec3 loc_m = interPart.get_x_m();
|
||||||
|
double E_eV = interPart.get_E_eV();
|
||||||
|
|
||||||
|
if (E_scale.in_scale(E_eV)) {
|
||||||
|
return lookup_macro_sigma_m(E_eV, loc_m);
|
||||||
|
} else {
|
||||||
|
return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double TI_thermal_Rate_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
|
int i = E_scale.calc_index(E_eV);
|
||||||
|
return precomputed_values[i] * pow(Population->get_density_m3(loc_m), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TI_rate_base_h */
|
||||||
@@ -47,11 +47,19 @@ inline double TI_thermal_binary_Interaction_Base::calc_macro_sigma_m(const doubl
|
|||||||
|
|
||||||
inline double TI_thermal_binary_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
inline double TI_thermal_binary_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||||
|
// Integration over theta and v
|
||||||
|
auto integrand = [&](double v2_ms, double theta) {
|
||||||
|
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||||
|
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||||
|
};
|
||||||
|
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, 50, 50); // 3*v_therm equals 99% of the integral
|
||||||
|
/* // Integration over theta
|
||||||
auto integrand = [&](double theta) {
|
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);
|
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_m2(E_eV);
|
return get_microSigma_m2(E_eV);
|
||||||
};
|
};
|
||||||
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson())/pi;
|
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson())/pi;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#ifndef eT2I_recombination_h
|
#ifndef eT2I_recombination_h
|
||||||
#define eT2I_recombination_h
|
#define eT2I_recombination_h
|
||||||
|
|
||||||
#include "e_kinetic_base.h"
|
#include "e_thermal_base.h"
|
||||||
|
|
||||||
#include "janev_eT2I_recombination.h"
|
#include "janev_eT2I_recombination.h"
|
||||||
|
|
||||||
class eT2I_Recombination : public e_kinetic_Precomputed_Interaction_Base {
|
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||||
public:
|
public:
|
||||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_kinetic_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
||||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#ifndef eT3I_recombination_h
|
#ifndef eT3I_recombination_h
|
||||||
#define eT3I_recombination_h
|
#define eT3I_recombination_h
|
||||||
|
|
||||||
#include "e_kinetic_base.h"
|
#include "e_thermal_base.h"
|
||||||
|
|
||||||
#include "janev_eT3I_recombination.h"
|
#include "janev_eT3I_recombination.h"
|
||||||
|
|
||||||
class eT3I_Recombination : public e_kinetic_Precomputed_Interaction_Base {
|
class eT3I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||||
public:
|
public:
|
||||||
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni) : e_kinetic_Precomputed_Interaction_Base(T3IPopulation, rngUni, me_eV) {
|
eT3I_Recombination(Population_Base *T3IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T3IPopulation, rngUni, me_eV) {
|
||||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#ifndef eT5I_recombination_h
|
#ifndef eT5I_recombination_h
|
||||||
#define eT5I_recombination_h
|
#define eT5I_recombination_h
|
||||||
|
|
||||||
#include "e_kinetic_base.h"
|
#include "e_thermal_base.h"
|
||||||
|
|
||||||
#include "petterson_eT5I_recombination.h"
|
#include "petterson_eT5I_recombination.h"
|
||||||
|
|
||||||
class eT5I_Recombination : public e_kinetic_Precomputed_Interaction_Base {
|
class eT5I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||||
public:
|
public:
|
||||||
eT5I_Recombination(Population_Base *T5IPopulation, UniRNG *rngUni) : e_kinetic_Precomputed_Interaction_Base(T5IPopulation, rngUni, me_eV) {
|
eT5I_Recombination(Population_Base *T5IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T5IPopulation, rngUni, me_eV) {
|
||||||
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
calc_values(); // need to call here, because, constructor can't call pure virtual function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,18 @@ inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV)
|
|||||||
return get_microSigma_m2(E_eV);
|
return get_microSigma_m2(E_eV);
|
||||||
} else {
|
} else {
|
||||||
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||||
|
// Integration over theta and v
|
||||||
|
auto integrand = [&](double v2_ms, double theta) {
|
||||||
|
double E_eV = m1_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2);
|
||||||
|
return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||||
|
};
|
||||||
|
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, 50, 50); // 3*v_therm equals 99% of the integral
|
||||||
|
/* // Integration over theta
|
||||||
auto integrand = [&](double theta) {
|
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);
|
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_m2(E_eV);
|
return get_microSigma_m2(E_eV)/pi;
|
||||||
};
|
};
|
||||||
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson())/pi;
|
return integrate(integrand, 0., pi, INT_N_INTPOINTS, simpson());*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,5 +65,54 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename F, typename Double>
|
||||||
|
double double_simpson_integrate(F f, Double xmin, Double xmax, Double ymin, Double ymax, int nx, int ny) {
|
||||||
|
// Adapted from https://www.geeksforgeeks.org/program-to-calculate-double-integration/
|
||||||
|
// and http://www.physics.usyd.edu.au/teach_res/mp/doc/math_integration_2D.pdf
|
||||||
|
// and http://mathfaculty.fullerton.edu/mathews/n2003/SimpsonsRule2DMod.html
|
||||||
|
|
||||||
|
// Make number of steps even
|
||||||
|
if (nx % 2 != 0) {
|
||||||
|
nx += 1;
|
||||||
|
}
|
||||||
|
if (ny % 2 != 0) {
|
||||||
|
ny += 1;
|
||||||
|
}
|
||||||
|
// Calculating the step sizes
|
||||||
|
Double xsteps = (xmax - xmin)/(nx-1);
|
||||||
|
Double ysteps = (ymax - ymin)/(ny-1);
|
||||||
|
|
||||||
|
// Lambda for calculating function value in respect to x and y bins
|
||||||
|
auto f_bin = [&](int ix, int iy) {
|
||||||
|
return f(xmin + ix * xsteps, ymin + iy * ysteps);
|
||||||
|
};
|
||||||
|
// Lambda for calculating the integral over y for a ix bin
|
||||||
|
auto x_integral = [&](int ix) {
|
||||||
|
Double res = 0;
|
||||||
|
for (int iy = 0; iy < ny; iy++) {
|
||||||
|
if (iy == 0 || iy == ny - 1)
|
||||||
|
res += f_bin(ix, iy);
|
||||||
|
else if (iy % 2 == 0)
|
||||||
|
res += 2 * f_bin(ix, iy);
|
||||||
|
else
|
||||||
|
res += 4 * f_bin(ix, iy);
|
||||||
|
}
|
||||||
|
res *= (ysteps / 3);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculating the final integral value over x
|
||||||
|
Double res = 0;
|
||||||
|
for (int ix = 0; ix < nx; ix++) {
|
||||||
|
if (ix == 0 || ix == nx - 1)
|
||||||
|
res += x_integral(ix);
|
||||||
|
else if (ix % 2 == 0)
|
||||||
|
res += 2 * x_integral(ix);
|
||||||
|
else
|
||||||
|
res += 4 * x_integral(ix);
|
||||||
|
}
|
||||||
|
res *= (xsteps / 3);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* integrater_h */
|
#endif /* integrater_h */
|
||||||
|
|||||||
@@ -57,20 +57,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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 */
|
#endif /* interaction_base_h */
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
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 &E_eV);
|
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||||
|
|
||||||
double get_density_m3(const vec3 &loc_m);
|
double get_density_m3(const vec3 &loc_m){throw MyException("Method for non kinetic populations.\n");}
|
||||||
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
double get_density_m3(const int &E_bin, const Bins &loc_bins);
|
||||||
int get_number_E_bins();
|
int get_number_E_bins();
|
||||||
Bins get_loc_bin(const vec3 & loc_m);
|
Bins get_loc_bin(const vec3 & loc_m);
|
||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
vec3 roll_v_ms (const vec3 &loc_m);
|
vec3 roll_v_ms (const vec3 &loc_m);
|
||||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return vec3(0,0,0);} // Dummy as integration is made over energy mids
|
vec3 get_drift_v_ms(const vec3 &loc_m) {return vec3(0,0,0);} // Dummy as integration is made over energy mids
|
||||||
double get_thermal_v_ms() {return 0;} // Dummy as integration is made over energy mids
|
double get_thermal_v_ms() {return 0;} // Dummy as integration is made over energy mids
|
||||||
|
double get_v_pdf(const double &v_ms) {throw MyException ("Not yet implemented as not needed at this point.");}
|
||||||
Population_Container *access_container();
|
Population_Container *access_container();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,13 +56,6 @@ inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const doubl
|
|||||||
container.increase_offset(loc_m, E_eV);
|
container.increase_offset(loc_m, E_eV);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double Kinetic_Population::get_density_m3(const vec3 &loc_m) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Kinetic_Population::get_density_m3: method for non kinetic populations.\n";
|
|
||||||
throw MyException(ss.str());
|
|
||||||
return container.get_density_m3(loc_m, 0, timer->get_time_s());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double 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());
|
return container.get_density_m3(E_bin, loc_bins, timer->get_time_s());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual vec3 roll_v_ms (const vec3 &loc_m) = 0;
|
virtual vec3 roll_v_ms (const vec3 &loc_m) = 0;
|
||||||
virtual vec3 get_drift_v_ms(const vec3 &loc_m) = 0;
|
virtual vec3 get_drift_v_ms(const vec3 &loc_m) = 0;
|
||||||
virtual double get_thermal_v_ms() = 0;
|
virtual double get_thermal_v_ms() = 0;
|
||||||
|
virtual double get_v_pdf(const double &v_ms) = 0;
|
||||||
|
|
||||||
virtual Population_Container *access_container() = 0;
|
virtual Population_Container *access_container() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
|||||||
int num_phi_bins = POP_N_PHI;
|
int num_phi_bins = POP_N_PHI;
|
||||||
int num_E_bins = POP_N_E;
|
int num_E_bins = POP_N_E;
|
||||||
Populations.add(new Kinetic_Population(electron, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
Populations.add(new Kinetic_Population(electron, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||||
/*
|
|
||||||
if (v_flow == -1) {
|
if (v_flow == -1) {
|
||||||
Populations.add(new Thermal_Population(tritium, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
Populations.add(new Thermal_Population(tritium, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
Populations.add(new Thermal_Population(tritiumI, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
Populations.add(new Thermal_Population(tritiumI, new WGTS_Kinematics(mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
@@ -45,7 +45,7 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
|||||||
Populations.add(new Thermal_Population(tritium5I, new Lin_Kinematics(5*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
Populations.add(new Thermal_Population(tritium5I, new Lin_Kinematics(5*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
||||||
}
|
}
|
||||||
*/
|
/*
|
||||||
if (v_flow == -1) {
|
if (v_flow == -1) {
|
||||||
Populations.add(new Kinetic_Population(tritium, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
Populations.add(new Kinetic_Population(tritium, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||||
Populations.add(new Kinetic_Population(tritiumI, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
Populations.add(new Kinetic_Population(tritiumI, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||||
@@ -60,7 +60,7 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
|||||||
Populations.add(new Kinetic_Population(tritium3I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
Populations.add(new Kinetic_Population(tritium3I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||||
Populations.add(new Kinetic_Population(tritium5I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
Populations.add(new Kinetic_Population(tritium5I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START));
|
||||||
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
Populations.add(new T2_Population(new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), rngUni, rngNormal));
|
||||||
}
|
}*/
|
||||||
return Populations;
|
return Populations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||||
|
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||||
|
|
||||||
Population_Container *access_container() {return &container;}
|
Population_Container *access_container() {return &container;}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
vec3 roll_v_ms (const vec3 &loc_m) {return kinematics->get_v_ms(loc_m);}
|
||||||
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
vec3 get_drift_v_ms(const vec3 &loc_m) {return kinematics->get_v_offset_ms(loc_m);}
|
||||||
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
double get_thermal_v_ms() {return kinematics->get_thermal_v_ms();}
|
||||||
|
double get_v_pdf(const double &v_ms) {return kinematics->get_v_pdf(v_ms);}
|
||||||
|
|
||||||
Population_Container *access_container() {return nullptr;};
|
Population_Container *access_container() {return nullptr;};
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,13 @@ public:
|
|||||||
this->rngNormal = rngNormal;
|
this->rngNormal = rngNormal;
|
||||||
v_thermal = sqrt(2*kb_eVK*30/m_eV)*c_ms; // most probable speed sqrt(2*kb*T/m)
|
v_thermal = sqrt(2*kb_eVK*30/m_eV)*c_ms; // most probable speed sqrt(2*kb*T/m)
|
||||||
};
|
};
|
||||||
vec3 get_v_ms(const vec3&loc_m) {
|
|
||||||
return roll_v_thermal_ms() + get_v_offset_ms(loc_m);
|
|
||||||
}
|
|
||||||
|
|
||||||
double get_thermal_v_ms() {
|
|
||||||
return v_thermal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
vec3 get_v_ms(const vec3&loc_m) {return roll_v_thermal_ms() + get_v_offset_ms(loc_m);}
|
||||||
|
double get_thermal_v_ms() {return v_thermal;}
|
||||||
virtual vec3 get_v_offset_ms(const vec3 &loc_m) = 0;
|
virtual vec3 get_v_offset_ms(const vec3 &loc_m) = 0;
|
||||||
|
double get_v_pdf(const double &v_ms) {
|
||||||
|
return pow(2/pi, 0.5) * pow(m_eV*pow(c_ms, -2)/kb_eVK/wgtsTemp_K, 1.5) * pow(v_ms, 2) * exp(-m_eV * pow(v_ms/c_ms, 2)/2/kb_eVK/wgtsTemp_K);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
vec3 roll_v_thermal_ms() {
|
vec3 roll_v_thermal_ms() {
|
||||||
double E_eV = roll_MBEnergy(wgtsTemp_K, m_eV, rngNormal);
|
double E_eV = roll_MBEnergy(wgtsTemp_K, m_eV, rngNormal);
|
||||||
|
|||||||
@@ -9,16 +9,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../mc_electron/integrater.h"
|
#include "../mc_electron/integrater.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <gsl/gsl_integration.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
double f(double x, double y, double a) { return a*x*y; }
|
double f(double x, double y, double a) { return a*x*y; }
|
||||||
|
|
||||||
|
// Change the function according to your need
|
||||||
|
float givenFunction(float x, float y)
|
||||||
|
{
|
||||||
|
return pow(pow(x, 4) + pow(y, 5), 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::vector<int> vec;
|
printf("%f \n", double_simpson_integrate(givenFunction, 2.3, 2.5, 3.7, 4.3, 100, 100));
|
||||||
|
//printf("%f", doubleIntegral(h, k, lx, ux, ly, uy));
|
||||||
vec.push_back(6);
|
return 0;
|
||||||
vec.push_back(-17);
|
|
||||||
vec.push_back(12);
|
|
||||||
//vec.erase();
|
|
||||||
cout<<vec.size();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user