Bug fix for recombination
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "LongitudinalBins.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <iostream>
|
||||
namespace Discrete {
|
||||
|
||||
std::vector<double> createBins(
|
||||
@@ -25,6 +25,10 @@ Longitudinal::Longitudinal(
|
||||
{
|
||||
}
|
||||
|
||||
Longitudinal::Longitudinal(const Longitudinal& l):
|
||||
bins_(l.bins_)
|
||||
{}
|
||||
|
||||
bool Longitudinal::changedBin(double z_start, double z_end) const
|
||||
{
|
||||
return !(findBin(z_start) == findBin(z_end));
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Discrete {
|
||||
double z_max,
|
||||
int num_bins);
|
||||
|
||||
Longitudinal(const Longitudinal& l);
|
||||
|
||||
bool changedBin(double z_start, double z_end) const;
|
||||
int findBin(double z) const;
|
||||
std::vector<double> bins() const;
|
||||
|
||||
@@ -24,9 +24,10 @@ InteractionOut T2Ie_Recombination::do_Interaction (
|
||||
{
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
double E_eV = calc_E_eV_from_v_ms(
|
||||
Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
const vec3 pos_m = interPart->get_x_m();
|
||||
const double E_eV = calc_E_eV_from_v_ms(
|
||||
Population->roll_v_ms(pos_m), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(pos_m, E_eV);
|
||||
GlobalCounter::num_T2I_recombinations += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ InteractionOut T3Ie_Recombination::do_Interaction (
|
||||
{
|
||||
InteractionOut res;
|
||||
res.set_delete_current(true);
|
||||
const vec3 pos_m = interPart->get_x_m();
|
||||
double E_eV = calc_E_eV_from_v_ms(
|
||||
Population->roll_v_ms(interPart->get_x_m()), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||
Population->roll_v_ms(pos_m), me_eV); // should be computed properly using chances.
|
||||
Population->decrease_denisty(pos_m, E_eV);
|
||||
GlobalCounter::num_T3I_recombinations += 1;
|
||||
return res;
|
||||
}
|
||||
+55
-13
@@ -2,19 +2,29 @@
|
||||
#include <random/uniform.h>
|
||||
#include "injector_builder.hpp"
|
||||
|
||||
Injector::Injector() :
|
||||
RNG_Base(nullptr, nullptr)
|
||||
{};
|
||||
|
||||
|
||||
Injector::Injector() :
|
||||
RNG_Base(nullptr, nullptr),
|
||||
use_injection_position(false),
|
||||
injection_position(blitz::TinyVector<double,3>(0, 0, 0)),
|
||||
velocity_direction(0)
|
||||
{};
|
||||
|
||||
Injector::Injector(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Base *T2Population,
|
||||
int method,
|
||||
double energy_eV,
|
||||
int ions) :
|
||||
RNG_Base(rngUni, rngNormal)
|
||||
int ions,
|
||||
bool use_injection_position,
|
||||
const blitz::TinyVector<double,3>& injection_position,
|
||||
int velocity_direction) :
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
use_injection_position(use_injection_position),
|
||||
injection_position(injection_position),
|
||||
velocity_direction(velocity_direction)
|
||||
{
|
||||
this->T2Population = T2Population;
|
||||
this->method = method;
|
||||
@@ -27,9 +37,18 @@ int Injector::inject (
|
||||
std::vector<Particle> *particle_queue,
|
||||
const int &last_ID)
|
||||
{
|
||||
|
||||
int num_particles_added = 0;
|
||||
|
||||
vec3 loc_m = T2Population->roll_x_ms();
|
||||
vec3 loc_m(0., 0., 0.);
|
||||
|
||||
if(use_injection_position){
|
||||
loc_m = injection_position;
|
||||
}
|
||||
else{
|
||||
loc_m = T2Population->roll_x_ms();
|
||||
}
|
||||
|
||||
double E_eV;
|
||||
switch(method) {
|
||||
case 0: // Fermi
|
||||
@@ -45,7 +64,24 @@ int Injector::inject (
|
||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||
break;
|
||||
}
|
||||
vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
|
||||
const double v_abs = calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||
vec3 v_dir(0., 0., 0.);
|
||||
|
||||
if(velocity_direction == 0){
|
||||
v_dir = roll_uniform_direction(rngUni);
|
||||
}
|
||||
else if(velocity_direction == 1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, 1);
|
||||
}
|
||||
else if(velocity_direction == -1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, -1);
|
||||
}
|
||||
else{
|
||||
throw MyException("Katrin::inject:electron Invalid Injection Velocity Direction.");
|
||||
}
|
||||
|
||||
vec3 v_ms = v_abs * v_dir;
|
||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||
num_particles_added += 1;
|
||||
|
||||
@@ -68,16 +104,22 @@ int Injector::inject (
|
||||
|
||||
const double v_abs = calc_v_ms_from_E_eV(ETI_eV,2*mT_eV);
|
||||
|
||||
vec3 direction(0., 0., 0.);
|
||||
if(ions == 1){
|
||||
direction = vec3(0., 0., -1.0);
|
||||
vec3 v_dir(0., 0., 0.);
|
||||
|
||||
if(velocity_direction == 0){
|
||||
v_dir = roll_uniform_direction(rngUni);
|
||||
}
|
||||
else if(velocity_direction == 1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, 1);
|
||||
}
|
||||
else if(velocity_direction == -1){
|
||||
v_dir = blitz::TinyVector<double,3>(0, 0, -1);
|
||||
}
|
||||
else{
|
||||
direction = roll_uniform_direction(rngUni);
|
||||
throw MyException("Katrin::inject:ion Invalid Injection Velocity Direction.");
|
||||
}
|
||||
|
||||
vec3 vTI_ms = direction * v_abs;
|
||||
//vec3 locTI(0., 0.0, 10);
|
||||
vec3 vTI_ms = v_dir * v_abs;
|
||||
vec3 locTI = loc_m;
|
||||
particle_queue->push_back(PartFac.create_T2I(locTI, vTI_ms, last_ID+2, last_ID+2));
|
||||
num_particles_added += 1;
|
||||
|
||||
+8
-1
@@ -10,13 +10,17 @@
|
||||
class Injector : RNG_Base {
|
||||
public:
|
||||
Injector();
|
||||
|
||||
Injector(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Base *T2Population,
|
||||
int method,
|
||||
double energy_eV,
|
||||
int ions);
|
||||
int ions,
|
||||
bool use_injection_position,
|
||||
const blitz::TinyVector<double,3>& injection_position,
|
||||
int velocity_direction);
|
||||
|
||||
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
||||
private:
|
||||
@@ -29,6 +33,9 @@ class Injector : RNG_Base {
|
||||
int ions;
|
||||
Population_Base *T2Population;
|
||||
Particle_Builder PartFac;
|
||||
bool use_injection_position;
|
||||
blitz::TinyVector<double,3> injection_position;
|
||||
int velocity_direction;
|
||||
};
|
||||
|
||||
#endif /* INJECTOR_H */
|
||||
|
||||
@@ -13,11 +13,27 @@ const double Injector_Builder::energy_eV = load_parameter("INJ_E");
|
||||
const int Injector_Builder::ions = load_parameter("INJ_TI");
|
||||
const double Injector_Builder::energyTI_eV = load_parameter("INJ_E_TI");
|
||||
|
||||
const bool Injector_Builder::use_injection_position = load_parameter("USE_INJECTION_POSITION");
|
||||
const double Injector_Builder::z_pos_injection = load_parameter("INJECTION_Z_POS");
|
||||
const double Injector_Builder::r_pos_injection = load_parameter("INJECTION_R_POS");
|
||||
|
||||
const int Injector_Builder::velocity_direction = load_parameter("INJECTION_VELOCITY_DIRECTION");
|
||||
|
||||
Injector Injector_Builder::build(
|
||||
UniRNG *rngUni,
|
||||
NormalRNG *rngNormal,
|
||||
Population_Manager *populations)
|
||||
{
|
||||
Population_Base *T2Population = populations->find(tritium2);
|
||||
return Injector(rngUni, rngNormal, T2Population, method, energy_eV, ions);
|
||||
|
||||
return Injector(
|
||||
rngUni,
|
||||
rngNormal,
|
||||
T2Population,
|
||||
method,
|
||||
energy_eV,
|
||||
ions,
|
||||
use_injection_position,
|
||||
blitz::TinyVector<double,3>(r_pos_injection, 0, z_pos_injection),
|
||||
velocity_direction);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,9 @@ class Injector_Builder {
|
||||
static const double energy_eV;
|
||||
static const int ions;
|
||||
static const double energyTI_eV;
|
||||
static const bool use_injection_position;
|
||||
static const double z_pos_injection;
|
||||
static const double r_pos_injection;
|
||||
static const int velocity_direction;
|
||||
};
|
||||
#endif /* injector_builder_hpp */
|
||||
|
||||
@@ -170,9 +170,17 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium(Population_Manager
|
||||
Interaction_Channel_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||
Interaction_Channel_Base *TI_Interaction = new Interaction_Channel_Base(tritiumI, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
||||
|
||||
if(load_parameter("TI_ELASTIC") == 1){
|
||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||
}
|
||||
if(load_parameter("TI_RADIAL_ASSOCIATION") == 1){
|
||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||
}
|
||||
if(load_parameter("TI_TERNARY_ASSOCIATION") == 1){
|
||||
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
||||
}
|
||||
|
||||
return TI_Interaction;
|
||||
}
|
||||
|
||||
@@ -186,9 +194,15 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium2I(Population_Manage
|
||||
} else if (load_parameter("e_REC") != 0) {
|
||||
throw MyException ("e_REC invalid.");
|
||||
}
|
||||
if(load_parameter("T2I_CLUSTER") == 1){
|
||||
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
||||
}
|
||||
|
||||
if(load_parameter("T2I_CHARGETRANSFER") == 1){
|
||||
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
||||
}
|
||||
|
||||
//T2I_Interaction->add(new T2Ie_DissExc(ePopulation, rngUni));
|
||||
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
||||
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
||||
return T2I_Interaction ;
|
||||
}
|
||||
|
||||
@@ -196,7 +210,12 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manage
|
||||
Interaction_Channel_Base *T3I_Interaction = new Interaction_Channel_Base(tritium3I, rngUni);
|
||||
Population_Base *T2Population = Populations->find(tritium2);
|
||||
Population_Base *ePopulation = Populations->find(electron);
|
||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||
|
||||
if(load_parameter("T3I_ELASTIC") == 1){
|
||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||
}
|
||||
|
||||
//
|
||||
//T3I_Interaction->add(new T3IT2_RadAsc(T2Population, rngUni));
|
||||
//T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "janev_eT2I_recombination.h"
|
||||
#include <cmath>
|
||||
// Janev:2003aa "From Collision processes in low-temperature hydrogen plasmas" 7.1.3.A p.73 formular (185)
|
||||
|
||||
double Janev_eT2I_Recombination::get_TCS(const double &E_eV)
|
||||
{
|
||||
double const1 = pow( pow(E_eV,0.665) * (1 + 1.1*pow(E_eV,0.512) + 0.011*pow(E_eV,3.10)) , -1);
|
||||
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||
return 17.3e-20 * (const1+const2);
|
||||
}
|
||||
@@ -1,27 +1,11 @@
|
||||
//
|
||||
// janev_eT2I_recombination.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 24.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef janev_eT2I_recombination_h
|
||||
#define janev_eT2I_recombination_h
|
||||
|
||||
#include <cmath>
|
||||
// Janev:2003aa "From Collision processes in low-temperature hydrogen plasmas" 7.1.3.A p.73 formular (185)
|
||||
|
||||
class Janev_eT2I_Recombination {
|
||||
|
||||
public:
|
||||
Janev_eT2I_Recombination() {}
|
||||
|
||||
static double get_TCS(const double &E_eV) {
|
||||
double const1 = pow( pow(E_eV,0.665) * (1 + 1.1*pow(E_eV,0.512) + 0.011*pow(E_eV,3.10)) , -1);
|
||||
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||
return 17.3e-20 * (const1+const2);
|
||||
}
|
||||
public:
|
||||
static double get_TCS(const double &E_eV);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "kinetic_population.h"
|
||||
#include <fstream>
|
||||
|
||||
|
||||
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,
|
||||
double E_min_eV,
|
||||
double E_max_eV):
|
||||
Population_Base(this_species),
|
||||
RNG_Base(rngUni, rngNormal),
|
||||
container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV, E_max_eV)
|
||||
{
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
}
|
||||
|
||||
|
||||
double Kinetic_Population::get_density_m3(const vec3 &loc_m)
|
||||
{
|
||||
throw MyException("Method for non kinetic populations.\n");
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::roll_x_ms()
|
||||
{
|
||||
throw MyException ("Not yet implemented as not needed at this point.");
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::get_drift_v_ms(const vec3 &loc_m)
|
||||
{
|
||||
return vec3(0,0,0);
|
||||
} // Dummy as integration is made over energy mids
|
||||
|
||||
double Kinetic_Population::get_thermal_v_ms()
|
||||
{
|
||||
return 0;
|
||||
} // Dummy as integration is made over energy mids
|
||||
|
||||
double Kinetic_Population::get_v_pdf(const double &v_ms)
|
||||
{
|
||||
throw MyException ("Not yet implemented as not needed at this point.");
|
||||
}
|
||||
|
||||
|
||||
void Kinetic_Population::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 Kinetic_Population::decrease_denisty (
|
||||
const vec3 &loc_m,
|
||||
const double &E_eV)
|
||||
{
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m)
|
||||
{
|
||||
Bins loc_bins = get_loc_bin(loc_m);
|
||||
double target = 0;
|
||||
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<get_number_E_bins(); E_bin++) {
|
||||
current += get_density_m3(E_bin, loc_bins);
|
||||
if (current >= target) {
|
||||
return calc_v_ms_from_E_eV(container.roll_E_eV_in_bin(E_bin, rngUni),m_eV);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
Population_Container *Kinetic_Population::access_container()
|
||||
{
|
||||
return &container;
|
||||
}
|
||||
|
||||
@@ -1,97 +1,47 @@
|
||||
//
|
||||
// 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 <fstream>
|
||||
#ifndef KINETIC_POPULATION_H
|
||||
#define KINETIC_POPULATION_H
|
||||
|
||||
#include "population_container.hpp"
|
||||
|
||||
#include "population_base.h"
|
||||
|
||||
class Kinetic_Population : public Population_Base, private RNG_Base {
|
||||
Population_Container container;
|
||||
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, double E_min_eV, double E_max_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,
|
||||
double E_min_eV,
|
||||
double E_max_eV);
|
||||
|
||||
void increase_density (const Particle &upPart, const vec3 &oldLoc_m);
|
||||
void decrease_denisty (const vec3 &loc_m, const double &E_eV);
|
||||
|
||||
double get_density_m3(const vec3 &loc_m){throw MyException("Method for non kinetic populations.\n");}
|
||||
double get_density_m3(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_x_ms();
|
||||
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
|
||||
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.");}
|
||||
vec3 get_drift_v_ms(const vec3 &loc_m);
|
||||
double get_thermal_v_ms();
|
||||
double get_v_pdf(const double &v_ms);
|
||||
Population_Container *access_container();
|
||||
|
||||
private:
|
||||
Population_Container container;
|
||||
Timer *timer;
|
||||
|
||||
double m_eV;
|
||||
};
|
||||
|
||||
|
||||
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, double E_min_eV, double E_max_eV) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, num_E_bins, E_min_eV, E_max_eV) {
|
||||
this->timer = timer;
|
||||
m_eV = get_species_mass(this_species);
|
||||
};
|
||||
|
||||
inline void Kinetic_Population::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());
|
||||
}
|
||||
|
||||
inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||
container.increase_offset(loc_m, E_eV);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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) {
|
||||
Bins loc_bins = get_loc_bin(loc_m);
|
||||
double target = 0;
|
||||
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<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);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Kinetic_Population::roll_v_ms: Overflow.\n";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
inline Population_Container *Kinetic_Population::access_container() {
|
||||
return &container;
|
||||
}
|
||||
|
||||
#endif /* energetic_base_h */
|
||||
#endif /* KINETIC_POPULATION_H */
|
||||
|
||||
@@ -37,6 +37,8 @@ OBJS := particle_looper.o \
|
||||
LongitudinalBins.o \
|
||||
injector.o \
|
||||
thermal_population.o \
|
||||
janev_eT2I_recombination.o \
|
||||
kinetic_population.o \
|
||||
|
||||
|
||||
CXXFLAGS = $(X_OFLAGS) -I.. $(X_INC) -std=c++11
|
||||
|
||||
@@ -132,16 +132,16 @@ double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_e
|
||||
}
|
||||
|
||||
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];
|
||||
double V_m3 = size_data_m3[loc_bins.r];
|
||||
const int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||
const double cum_time_s = cum_times_s[data_bin];
|
||||
const double offset = offsets[data_bin];
|
||||
const double V_m3 = size_data_m3[loc_bins.r];
|
||||
|
||||
double n_m3 = cum_time_s/time_s/V_m3 - offset/V_m3;
|
||||
if (n_m3<0) {
|
||||
n_m3 = 0;
|
||||
cum_times_s[data_bin] = 0;
|
||||
offsets[data_bin] = 0;
|
||||
//cum_times_s[data_bin] = 0;
|
||||
//offsets[data_bin] = 0;
|
||||
}
|
||||
return n_m3;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ def plotCurrentRVsR(filename_current, filename_density, output_folder, z_pos):
|
||||
prop_cycle = plt.rcParams['axes.prop_cycle']
|
||||
colors = prop_cycle.by_key()['color']
|
||||
|
||||
e_dict = {"key" : "/e-", "linestyle": '+-', "label": "e"}
|
||||
T3_dict = {"key" : "/T3+", "linestyle": '.-', "label": "T3+"}
|
||||
e_dict = {"key" : "/e-", "linestyle": '-', "marker":"+", "label": "e"}
|
||||
T3_dict = {"key" : "/T3+", "linestyle": '-', "marker":".", "label": "T3+"}
|
||||
dicts = [e_dict, T3_dict]
|
||||
|
||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
||||
@@ -29,7 +29,7 @@ def plotCurrentRVsR(filename_current, filename_density, output_folder, z_pos):
|
||||
plot_data = np.sum(j_total_r,2)[:,z_bin]
|
||||
plot_x = r_bins[1:]
|
||||
|
||||
ax.plot(plot_x*100, plot_data*1E-4, linestyle=d["linestyle"], label=d["label"])
|
||||
ax.plot(plot_x*100, plot_data*1E-4, linestyle=d["linestyle"], marker=d["marker"], label=d["label"])
|
||||
|
||||
ax.set_xlabel(r"Radius $r$ [cm]")
|
||||
ax.set_ylabel(r"Particle Current $j_r$ [$cm^{-2}s^{-1}$]")
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
<Parameters>
|
||||
<Geometry>
|
||||
<Length>1300</Length>
|
||||
<Length>1600</Length>
|
||||
<Radius>4.5</Radius>
|
||||
</Geometry>
|
||||
|
||||
<DensityGrid>
|
||||
<Bins>
|
||||
<R>10</R>
|
||||
<Z>16</Z>
|
||||
<R>15</R>
|
||||
<Z>2800</Z>
|
||||
</Bins>
|
||||
</DensityGrid>
|
||||
<Input>
|
||||
<Density>
|
||||
<Filename>./config/density.h5</Filename>
|
||||
<Filename>./config/zero_density.h5</Filename>
|
||||
<H5Path>/Density/total</H5Path>
|
||||
</Density>
|
||||
</Input>
|
||||
@@ -24,7 +24,7 @@
|
||||
<Boundary>
|
||||
<Rear>
|
||||
<Type>1</Type>
|
||||
<Potential>0.0</Potential>
|
||||
<Potential>0.0001</Potential>
|
||||
</Rear>
|
||||
<Tube>
|
||||
<Type>1</Type>
|
||||
@@ -42,21 +42,21 @@
|
||||
<Output>
|
||||
<Potential>
|
||||
<H5File>
|
||||
<Filename>./output/output.h5</Filename>
|
||||
<Filename>./output/rearwall.h5</Filename>
|
||||
<H5Group>/Potential</H5Group>
|
||||
<H5DatasetName>potential</H5DatasetName>
|
||||
</H5File>
|
||||
</Potential>
|
||||
<Density>
|
||||
<H5File>
|
||||
<Filename>./output/output.h5</Filename>
|
||||
<Filename>./output/rearwall.h5</Filename>
|
||||
<H5Group>/Density</H5Group>
|
||||
<H5DatasetName>density</H5DatasetName>
|
||||
</H5File>
|
||||
</Density>
|
||||
<Efield>
|
||||
<H5File>
|
||||
<Filename>./output/output.h5</Filename>
|
||||
<Filename>./output/rearwall.h5</Filename>
|
||||
<H5Group>/Efield</H5Group>
|
||||
<H5DatasetName>efield</H5DatasetName>
|
||||
</H5File>
|
||||
|
||||
Reference in New Issue
Block a user