Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d73f372f3 | ||
|
|
a1ef34ea94 | ||
|
|
4de43e842d | ||
|
|
2687152d81 | ||
|
|
d96aaf5f44 | ||
|
|
cdfa57839c | ||
|
|
805f650044 | ||
|
|
0f20a5ba30 | ||
|
|
200459f267 | ||
|
|
95b21f9709 | ||
|
|
5d93e33fca | ||
|
|
10c76c7c96 | ||
|
|
e7c40a1031 | ||
|
|
70c23ed59a |
Executable
BIN
Binary file not shown.
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
include $(HOMEBASE)/src/makeinclude/first.mak
|
||||||
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
include $(HOMEBASE)/src/makeinclude/include.mak
|
||||||
|
|
||||||
|
OFLAGS = $(X_OFLAGS)
|
||||||
|
CXXFLAGS = $(OFLAGS) $(X_INC)
|
||||||
|
|
||||||
|
ZIP = tar -zxvf
|
||||||
|
|
||||||
|
NAME = gsl-2.6
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(ZIP) ../$(NAME).tar.gz
|
||||||
|
cd $(NAME)
|
||||||
|
$(NAME)/configure --prefix=$(HOMEBASE)/src/gsl/$(X_OSTYPE)/gsl/ --includedir=$(HOMEBASE)/include/ --libdir=$(HOMEBASE)/lib/$(X_OSTYPE)
|
||||||
|
make
|
||||||
|
|
||||||
|
install:
|
||||||
|
make install
|
||||||
|
rm -rf $(HOMEBASE)/lib/$(X_OSTYPE)/pkconfig
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -rf $(HOMEBASE)/include/gsl
|
||||||
|
-rm -rf $(HOMEBASE)/lib/$(X_OSTYPE)/libgsl*
|
||||||
|
-rm -rf $(HOMEBASE)/src/gsl/$(X_OSTYPE)
|
||||||
|
$(X_CLEAN)
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#include "Bessel.h"
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef BESSEL_H
|
||||||
|
#define BESSEL_H
|
||||||
|
|
||||||
|
//#include "kinematics.h"
|
||||||
|
#include "ElectricField.h"
|
||||||
|
#include "lin_scale.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include "RearwallPotential.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Bessel : public ElectricField, public RearwallPotential{
|
||||||
|
|
||||||
|
private:
|
||||||
|
vec3 efeld_value;
|
||||||
|
vec3 efeld_loc;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Bessel(vec3 efeld_value);
|
||||||
|
~Bessel(){};
|
||||||
|
//int getValue();
|
||||||
|
vec3 getLoc(const vec3 &loc_m);
|
||||||
|
vec3 getLoc(const double &z, const double &r, const double &phi);
|
||||||
|
vec3 getValue(const vec3 &loc_m);
|
||||||
|
vec3 getValue(const double &z, const double &r, const double &phi);
|
||||||
|
vec3 getValue();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif /* BESSEL_H */
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#include "ElectricField.h"
|
||||||
|
#include <iostream> //cout
|
||||||
|
#include <Homogene.h>
|
||||||
|
|
||||||
|
ElectricField::ElectricField(int i){
|
||||||
|
if (i==1)
|
||||||
|
{
|
||||||
|
|
||||||
|
double radius = load_parameter("RADIUS");
|
||||||
|
double height = load_parameter("HEIGHT");
|
||||||
|
double rearwall_potential = load_parameter("POTENTIAL");
|
||||||
|
vec3 center(0.0, 0.0, 0.0);
|
||||||
|
double minimal_z_for_bessel_calculation = 0.001;
|
||||||
|
int max_bessel_zero_order_ = 1000;
|
||||||
|
double precision = 1e-15;
|
||||||
|
bool potential_in_si = true;
|
||||||
|
|
||||||
|
f = new RearwallPotential(radius, height, rearwall_potential, center, minimal_z_for_bessel_calculation, max_bessel_zero_order_, precision, potential_in_si);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (i==2)
|
||||||
|
{
|
||||||
|
vec3 efeld_value = vec3(load_parameter("E_r"), load_parameter("E_phi"), load_parameter("E_z"));
|
||||||
|
f = new Homogene(efeld_value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ElectricField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec3 ElectricField::getValue(){
|
||||||
|
return vec3(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 ElectricField::getValue(const vec3 &loc_m){
|
||||||
|
return vec3(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 ElectricField::getValue(double z, double r, double phi){
|
||||||
|
return f->getValue(z, r, phi);
|
||||||
|
//return vec3(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricField::print() const {
|
||||||
|
f->print();
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef ELECTRICFIELD_H
|
||||||
|
#define ELECTRICFIELD_H
|
||||||
|
|
||||||
|
#include "kinematics.h"
|
||||||
|
#include "Function3d.h"
|
||||||
|
#include "RearwallPotential.h"
|
||||||
|
|
||||||
|
class ElectricField{
|
||||||
|
public:
|
||||||
|
ElectricField(int i);
|
||||||
|
ElectricField(){};
|
||||||
|
virtual vec3 getValue();
|
||||||
|
virtual vec3 getValue(const vec3 &loc_m);
|
||||||
|
virtual vec3 getValue(double z, double r, double phi);
|
||||||
|
virtual void print() const;
|
||||||
|
private:
|
||||||
|
Function3d *f;
|
||||||
|
};
|
||||||
|
#endif /* ELECTRICFIELD_H */
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#include "Function3d.h"
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> Function3d::getValue(const blitz::TinyVector<double, 3>& x) const {
|
||||||
|
return getValue(x(0), x(1), x(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
double Function3d::getValue(const blitz::TinyVector<double, 3>& x, int cart_axis) const {
|
||||||
|
return getValue(x(0), x(1), x(2), cart_axis);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::ostream & operator << (std::ostream &out, const Function3d& function) {
|
||||||
|
function.print(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Function3d::print(std::ostream &out) const{
|
||||||
|
out << "Function3d Base:\n";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
void Function3d::print() const{
|
||||||
|
std::cout << "Function3d Base:\n";
|
||||||
|
}
|
||||||
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef FUNCTION3D_H
|
||||||
|
#define FUNCTION3D_H
|
||||||
|
|
||||||
|
#include "blitz/array.h"
|
||||||
|
#include <iostream> // ostream
|
||||||
|
|
||||||
|
// Abstract base class for a 3d function
|
||||||
|
// - can provide an element of the return vector (direction: x, y, z)
|
||||||
|
// - can prodvie whole vector
|
||||||
|
class Function3d {
|
||||||
|
public:
|
||||||
|
virtual ~Function3d() {};
|
||||||
|
|
||||||
|
//virtual double getValue(double x, double y, double z, int cart_axis) const = 0;
|
||||||
|
virtual blitz::TinyVector<double ,3> getValue(double z, double r, double phi) const = 0;
|
||||||
|
|
||||||
|
//double getValue(const blitz::TinyVector<double, 3>& x, int cart_axis) const;
|
||||||
|
blitz::TinyVector<double, 3> getValue(const blitz::TinyVector<double, 3>& x) const;
|
||||||
|
|
||||||
|
//friend std::ostream & operator << (std::ostream &out, const Function3d& function);
|
||||||
|
//virtual void print(std::ostream &out) const;
|
||||||
|
virtual void print() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FUNCTION3D_H */
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include "Homogene.h"
|
||||||
|
|
||||||
|
|
||||||
|
Homogene::Homogene(vec3 efeld_value){
|
||||||
|
efeld_value_ = efeld_value;
|
||||||
|
E_r_ = efeld_value[0];
|
||||||
|
E_phi_ = efeld_value[1];
|
||||||
|
E_z_ = efeld_value[2];
|
||||||
|
std::cout << "wurde aufgegrufen" << std::endl;
|
||||||
|
std::cout << efeld_value_ << std::endl;
|
||||||
|
std::cout << E_r_ << std::endl;
|
||||||
|
std::cout << E_phi_ << std::endl;
|
||||||
|
std::cout << E_z_ << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Homogene::Homogene(double E_r, double E_phi, double E_z){
|
||||||
|
E_r_ = E_r;
|
||||||
|
E_phi_ = E_phi;
|
||||||
|
E_z_ = E_z;
|
||||||
|
efeld_value_ = vec3(E_r, E_phi, E_z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 Homogene::getValue(const vec3 &loc_m){
|
||||||
|
return efeld_value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 Homogene::getValue(double z, double r, double phi) const{
|
||||||
|
return efeld_value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Homogene::print()const {
|
||||||
|
std::cout << "efeld_value: " << efeld_value_ << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef HOMOGENE_H
|
||||||
|
#define HOMOGENE_H
|
||||||
|
|
||||||
|
#include "kinematics.h"
|
||||||
|
#include "lin_scale.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include "Function3d.h"
|
||||||
|
class Homogene : public Function3d{
|
||||||
|
|
||||||
|
private:
|
||||||
|
vec3 efeld_value_;
|
||||||
|
double E_r_;
|
||||||
|
double E_phi_;
|
||||||
|
double E_z_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Homogene(){};
|
||||||
|
Homogene(double E_r, double E_phi, double E_z);
|
||||||
|
Homogene(vec3 efeld_value);
|
||||||
|
~Homogene(){};
|
||||||
|
vec3 getValue(const vec3 &loc_m);
|
||||||
|
vec3 getValue(double z, double r, double phi) const;
|
||||||
|
void print() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif /* HOMOGENE_H */
|
||||||
Executable
+292
@@ -0,0 +1,292 @@
|
|||||||
|
#include "RearwallPotential.h"
|
||||||
|
#include "physconst.H"
|
||||||
|
#include "constants.h"
|
||||||
|
#include "enumerations.h"
|
||||||
|
|
||||||
|
#include <gsl/gsl_sf_trig.h> // sin/cos/sinh/cosh
|
||||||
|
#include <gsl/gsl_sf_bessel.h> // bessel function, and zeros
|
||||||
|
//#include "tools/my_errors.h"
|
||||||
|
#include "error_types.h"
|
||||||
|
#include <math.h> // isnan
|
||||||
|
|
||||||
|
RearwallPotential::RearwallPotential(double radius, double height,
|
||||||
|
double rearwall_potential,
|
||||||
|
const blitz::TinyVector<double, 3>& center,
|
||||||
|
double minimal_z_for_bessel_calculation,
|
||||||
|
int max_bessel_zero_order_,
|
||||||
|
double precision, bool potential_in_si
|
||||||
|
)
|
||||||
|
: radius_(radius),
|
||||||
|
height_(height),
|
||||||
|
max_bessel_zero_order_(max_bessel_zero_order_),
|
||||||
|
minimal_z_for_bessel_calculation_(minimal_z_for_bessel_calculation),
|
||||||
|
maximal_z_for_bessel_calculation_(height),
|
||||||
|
center_(center) {
|
||||||
|
if (potential_in_si) {
|
||||||
|
//rearwall_potential_ = rearwall_potential * 1E8 / PhysicalConstantsSI::c;
|
||||||
|
rearwall_potential_ = rearwall_potential * 1E8 / c_ms;
|
||||||
|
} else {
|
||||||
|
rearwall_potential_ = rearwall_potential;
|
||||||
|
}
|
||||||
|
maximal_z_for_bessel_calculation_ = getMaximalZ(radius, precision);
|
||||||
|
if (maximal_z_for_bessel_calculation_ < height_) {
|
||||||
|
height_ = maximal_z_for_bessel_calculation_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RearwallPotential::~RearwallPotential() {};
|
||||||
|
|
||||||
|
|
||||||
|
void RearwallPotential::print(std::ostream &out) const {
|
||||||
|
out << "Function3d: RearwallPotential\n";
|
||||||
|
out << "radius: " << radius_ << "\n";
|
||||||
|
out << "height: " << height_ << "\n";
|
||||||
|
out << "minimal z for bessel calculation: " << minimal_z_for_bessel_calculation_ << "\n";
|
||||||
|
out << "maximal z for bessel calculation: " << maximal_z_for_bessel_calculation_ << "\n";
|
||||||
|
out << "center: " << center_ << "\n";
|
||||||
|
out << "potential (cgs): " << rearwall_potential_ << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void RearwallPotential::print() const{
|
||||||
|
std::cout << "Function3d: RearwallPotential\n";
|
||||||
|
std::cout << "radius: " << radius_ << "\n";
|
||||||
|
std::cout << "height: " << height_ << "\n";
|
||||||
|
std::cout << "minimal z for bessel calculation: " << minimal_z_for_bessel_calculation_ << "\n";
|
||||||
|
std::cout << "maximal z for bessel calculation: " << maximal_z_for_bessel_calculation_ << "\n";
|
||||||
|
std::cout << "center: " << center_ << "\n";
|
||||||
|
std::cout << "potential (cgs): " << rearwall_potential_ << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getValue(double x, double y, double z,
|
||||||
|
int cart_axis) const {
|
||||||
|
// convert to local coordinates
|
||||||
|
x += -center_(0);
|
||||||
|
y += -center_(1);
|
||||||
|
z += -center_(2);
|
||||||
|
|
||||||
|
// get cylinder coordinates
|
||||||
|
gsl_sf_result r = {0.0, 0.0};
|
||||||
|
gsl_sf_result phi = {0.0, 0.0};
|
||||||
|
if(x == 0.0 && y == 0.0){ // guard for gsl error: 0,0 not defined
|
||||||
|
r.val = 0.0;
|
||||||
|
phi.val = 0.0;
|
||||||
|
} else {
|
||||||
|
gsl_sf_rect_to_polar(x, y, &r, &phi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cart_axis == Cart::Axis::x) {
|
||||||
|
return getRadialElectricField(r.val, z) * gsl_sf_cos(phi.val);
|
||||||
|
} else if (cart_axis == Cart::Axis::y) {
|
||||||
|
return getRadialElectricField(r.val, z) * gsl_sf_sin(phi.val);
|
||||||
|
} else if (cart_axis == Cart::Axis::z) {
|
||||||
|
return getLongitudinalElectricField(r.val, z);
|
||||||
|
} else {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"This axis " << cart_axis << " was not implemented. Use x, y or z for getValue." << std::endl;
|
||||||
|
throw MyException(ss.str());
|
||||||
|
//PANIC_NORANK(
|
||||||
|
// "This axis %d was not implemented. Use x, y or z for getValue.\n",
|
||||||
|
// cart_axis);
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> RearwallPotential::getValue(double z, double r,
|
||||||
|
double phi) const {
|
||||||
|
// convert to local coordinates
|
||||||
|
//x += -center_(0);
|
||||||
|
//y += -center_(1);
|
||||||
|
z += -center_(2);
|
||||||
|
/*
|
||||||
|
// get cylinder coordinates
|
||||||
|
gsl_sf_result r = {0.0, 0.0};
|
||||||
|
gsl_sf_result phi = {0.0, 0.0};
|
||||||
|
|
||||||
|
if(x == 0.0 && y == 0.0){ // guard for gsl error: 0,0 not defined
|
||||||
|
r.val = 0.0;
|
||||||
|
phi.val = 0.0;
|
||||||
|
} else {
|
||||||
|
gsl_sf_rect_to_polar(x, y, &r, &phi);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//std::cout << "ich wurde aufgerufen " << height_ << std::endl;
|
||||||
|
|
||||||
|
return blitz::TinyVector<double, 3>(
|
||||||
|
getRadialElectricField(r, z) * gsl_sf_cos(phi),
|
||||||
|
getRadialElectricField(r, z) * gsl_sf_sin(phi),
|
||||||
|
getLongitudinalElectricField(r, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double RearwallPotential::getElectricField(double radius, double z,
|
||||||
|
int clynder_axis) const {
|
||||||
|
if (clynder_axis == Cyl::Axis::rho) {
|
||||||
|
return getRadialElectricField(radius, z);
|
||||||
|
} else if (clynder_axis == Cyl::Axis::z) {
|
||||||
|
return getLongitudinalElectricField(radius, z);
|
||||||
|
} else if(clynder_axis == Cyl::Axis::phi) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"This axis " << clynder_axis << " was not implemented. Use x, y or z for getElectricField. " << std::endl;
|
||||||
|
throw MyException(ss.str());
|
||||||
|
//PANIC_NORANK(
|
||||||
|
// "This axis %d was not implemented. Use x, y or z for "
|
||||||
|
// "getElectricField.\n",
|
||||||
|
// clynder_axis);
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getRadialElectricField(double radius,
|
||||||
|
double z) const {
|
||||||
|
// boundary checks
|
||||||
|
if (isCoordinateOutsideCylinder(radius, z)) {
|
||||||
|
//std::cout << "out of cylinder" << std::endl;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scales linearly from 0 to E(minimal_z_for_bessel_calculation_)
|
||||||
|
if (z <= minimal_z_for_bessel_calculation_) {
|
||||||
|
double Er_zmin = 0.0;
|
||||||
|
for (int order = 1; order <= max_bessel_zero_order_; ++order) {
|
||||||
|
Er_zmin += getRadialFieldComponent(
|
||||||
|
radius, minimal_z_for_bessel_calculation_, order);
|
||||||
|
}
|
||||||
|
Er_zmin = Er_zmin * z / minimal_z_for_bessel_calculation_;
|
||||||
|
return Er_zmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard calculation
|
||||||
|
double Er = 0.0;
|
||||||
|
for (int order = 1; order <= max_bessel_zero_order_; ++order) {
|
||||||
|
Er += getRadialFieldComponent(radius, z, order);
|
||||||
|
}
|
||||||
|
return Er;
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getLongitudinalElectricField(double radius,
|
||||||
|
double z) const {
|
||||||
|
// boundary checks
|
||||||
|
if (isCoordinateOutsideCylinder(radius, z)) {
|
||||||
|
// in contrast to radial component the long. field is not zero
|
||||||
|
if (z != 0.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// uses value of E(minimal_z_for_bessel_calculation_) for smaller z
|
||||||
|
if (z <= minimal_z_for_bessel_calculation_) {
|
||||||
|
double Ez_zmin = 0.0;
|
||||||
|
for (int order = 1; order <= max_bessel_zero_order_; ++order) {
|
||||||
|
Ez_zmin += getLongitudinalFieldComponent(
|
||||||
|
radius, minimal_z_for_bessel_calculation_, order);
|
||||||
|
}
|
||||||
|
return Ez_zmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard calculation
|
||||||
|
double Ez = 0.0;
|
||||||
|
for (int order = 1; order <= max_bessel_zero_order_; ++order) {
|
||||||
|
Ez += getLongitudinalFieldComponent(radius, z, order);
|
||||||
|
}
|
||||||
|
return Ez;
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getPotential(double r, double z) const {
|
||||||
|
// check for boundaries
|
||||||
|
if(z <= 0.0) {
|
||||||
|
return rearwall_potential_;
|
||||||
|
} else if(isCoordinateOutsideCylinder(r, z)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard calculation
|
||||||
|
double potential = 0.0;
|
||||||
|
for(int order = 1; order <= max_bessel_zero_order_; ++order) {
|
||||||
|
potential += getRadialPotentialComponent(r, order) * getLongitudinalPotentialComponent(z, order);
|
||||||
|
}
|
||||||
|
potential *= rearwall_potential_;
|
||||||
|
if(potential > rearwall_potential_) {
|
||||||
|
potential = rearwall_potential_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return potential;
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getRadialPotentialComponent(
|
||||||
|
double r, int bessel_zero_order) const {
|
||||||
|
long double k0i = gsl_sf_bessel_zero_J0(bessel_zero_order);
|
||||||
|
return gsl_sf_bessel_J0(k0i*r/radius_)/(k0i * gsl_sf_bessel_J1(k0i));
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getLongitudinalPotentialComponent(
|
||||||
|
double z, int bessel_zero_order) const {
|
||||||
|
|
||||||
|
double k0i = gsl_sf_bessel_zero_J0(bessel_zero_order);
|
||||||
|
double b = k0i * height_/radius_;
|
||||||
|
double b_z = k0i/radius_*(height_ - z);
|
||||||
|
|
||||||
|
double V_long = 2.0*exp(gsl_sf_lnsinh(b_z) - gsl_sf_lnsinh(b));
|
||||||
|
if(isnan(V_long) || isinf(V_long)) {
|
||||||
|
return 0.0;
|
||||||
|
} else {
|
||||||
|
return V_long;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getLongitudinalFieldComponent(
|
||||||
|
double r, double z, int bessel_zero_order) const {
|
||||||
|
double k0i = gsl_sf_bessel_zero_J0(bessel_zero_order);
|
||||||
|
double b = k0i * height_ / radius_;
|
||||||
|
double b_z = k0i / radius_ * (height_ - z);
|
||||||
|
// cosh(b_z)/sinh(b):
|
||||||
|
double cosh_sinh = exp(gsl_sf_lncosh(b_z) - gsl_sf_lnsinh(b));
|
||||||
|
if (isnan(cosh_sinh) || isinf(cosh_sinh)) {
|
||||||
|
cosh_sinh = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double potential_z_derivative = 0.0;
|
||||||
|
if (z <= 0.0) {
|
||||||
|
potential_z_derivative = 2.0 * k0i / radius_;
|
||||||
|
} else {
|
||||||
|
potential_z_derivative = 2.0 * k0i / radius_ * cosh_sinh;
|
||||||
|
}
|
||||||
|
return rearwall_potential_ * potential_z_derivative *
|
||||||
|
getRadialPotentialComponent(r, bessel_zero_order);
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getRadialFieldComponent(double r, double z,
|
||||||
|
int bessel_zero_order) const {
|
||||||
|
double k0i = gsl_sf_bessel_zero_J0(bessel_zero_order);
|
||||||
|
double Er_i = rearwall_potential_ *
|
||||||
|
getLongitudinalPotentialComponent(z, bessel_zero_order) *
|
||||||
|
gsl_sf_bessel_J1(k0i * r / radius_) /
|
||||||
|
(radius_ * gsl_sf_bessel_J1(k0i));
|
||||||
|
return Er_i;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RearwallPotential::isCoordinateOutsideCylinder(double radius, double z) const {
|
||||||
|
if (z<=0)
|
||||||
|
{
|
||||||
|
std::cout << "z kleiner null" << std::endl;
|
||||||
|
}
|
||||||
|
else if (z>=maximal_z_for_bessel_calculation_)
|
||||||
|
{
|
||||||
|
//std::cout << z << " größer als "<< maximal_z_for_bessel_calculation_ << std::endl;
|
||||||
|
}
|
||||||
|
else if (radius > radius_)
|
||||||
|
{
|
||||||
|
std::cout << "radius auserhalb" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return z<=0.0 || z>= maximal_z_for_bessel_calculation_ || radius > radius_;
|
||||||
|
}
|
||||||
|
|
||||||
|
double RearwallPotential::getMaximalZ(double radius, double precision) const {
|
||||||
|
return (-1.0) * log(precision) * radius / gsl_sf_bessel_zero_J0(1);
|
||||||
|
}
|
||||||
|
|
||||||
Executable
+51
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef REARWALLPOTENTIAL_H
|
||||||
|
#define REARWALLPOTENTIAL_H
|
||||||
|
|
||||||
|
#include "Function3d.h"
|
||||||
|
#include "ElectricField.h"
|
||||||
|
|
||||||
|
class RearwallPotential : public Function3d {
|
||||||
|
public:
|
||||||
|
RearwallPotential(double radius, double height, double rearwall_potential, const blitz::TinyVector<double, 3>& center,
|
||||||
|
double minimal_z_for_bessel_calculation = 0.05, int max_bessel_zero_order_ = 1000,
|
||||||
|
double precision = 1E-15, bool potential_in_si = false);
|
||||||
|
|
||||||
|
~RearwallPotential();
|
||||||
|
|
||||||
|
void print(std::ostream &out) const;
|
||||||
|
void print() const;
|
||||||
|
|
||||||
|
double getValue(double x, double y, double z, int cart_axis) const;
|
||||||
|
blitz::TinyVector<double, 3> getValue(double z, double r, double phi) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double getElectricField(double radius, double z, int clinder_axis) const; // only used for debugging
|
||||||
|
double getPotential(double r, double z) const; // only used for debugging
|
||||||
|
|
||||||
|
double height_;
|
||||||
|
private:
|
||||||
|
double radius_;
|
||||||
|
double max_bessel_zero_order_;
|
||||||
|
double rearwall_potential_;
|
||||||
|
double minimal_z_for_bessel_calculation_;
|
||||||
|
double maximal_z_for_bessel_calculation_;
|
||||||
|
const blitz::TinyVector<double, 3> center_;
|
||||||
|
|
||||||
|
|
||||||
|
// use that for large values of z the result of the potential/field is smaller than double precision
|
||||||
|
// the bessel calculation is only done up to this z value
|
||||||
|
double getMaximalZ(double radius, double precision) const;
|
||||||
|
|
||||||
|
double getRadialElectricField(double radius, double z) const;
|
||||||
|
double getLongitudinalElectricField(double radius, double z) const;
|
||||||
|
|
||||||
|
double getRadialPotentialComponent(double r, int bessel_zero_order) const;
|
||||||
|
double getLongitudinalPotentialComponent(double z, int bessel_zero_order) const;
|
||||||
|
|
||||||
|
double getLongitudinalFieldComponent(double r, double z, int bessel_zero_order) const;
|
||||||
|
double getRadialFieldComponent(double r, double z, int bessel_zero_order) const;
|
||||||
|
|
||||||
|
bool isCoordinateOutsideCylinder(double radius, double z) const;
|
||||||
|
};
|
||||||
|
#endif /* REARWALLPOTENTIAL_H */
|
||||||
@@ -13,25 +13,70 @@
|
|||||||
|
|
||||||
#include "janev_eT2I_recombination.h"
|
#include "janev_eT2I_recombination.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class T2Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
class T2Ie_Recombination : public TI_e_Precomputed_Interaction_Base {
|
||||||
public:
|
public:
|
||||||
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 2*mT_eV) {
|
T2Ie_Recombination(Population_Base *ePopulation, UniRNG *rngUni) : TI_e_Precomputed_Interaction_Base(ePopulation, rngUni, 2*mT_eV) {
|
||||||
|
std::cout << "Konstruktor T2Ie_Recombinaton" << "\n";
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionOut do_Interaction (Particle *interPart);
|
InteractionOut do_Interaction (Particle *interPart);
|
||||||
protected:
|
protected:
|
||||||
double get_microSigma_m2(const double &E_eV) {
|
double get_microSigma_m2(const double &E_eV) {
|
||||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
|
||||||
|
//std::cout << "kommen wir hier rein? --------------------------" << "\n";
|
||||||
|
//std::cout << " Energie in microsigma T2+ mit e-" << E_eV << "\n";
|
||||||
|
//std::cout<<" Reco Crosssection T2 mit e-: "<< Janev_eT2I_Recombination::get_TCS(E_eV)<<"\n";
|
||||||
|
//double a = Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||||
|
//return a*100;
|
||||||
|
|
||||||
|
|
||||||
|
double twoEam2 = (E_eV + m2_eV) * 2 * m1_eV;
|
||||||
|
double E_kin_incident = twoEam2 / (2 * m2_eV) - m1_eV;
|
||||||
|
|
||||||
|
return Janev_eT2I_Recombination::get_TCS(E_kin_incident);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline InteractionOut T2Ie_Recombination::do_Interaction (Particle *interPart) {
|
inline InteractionOut T2Ie_Recombination::do_Interaction (Particle *interPart) {
|
||||||
InteractionOut res;
|
InteractionOut res;
|
||||||
res.set_delete_current(true);
|
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.
|
|
||||||
|
std::cout <<interPart->get_species() << " RECO mit " <<Population->get_species()<<"\n";
|
||||||
|
//std::cout << "Energie von teilchen " << interPart->get_E_eV() <<"\n";
|
||||||
|
//std::cout << "sigma von interaction T2+ mit e- " << get_microSigma_m2(interPart->get_E_eV())<<"\n";
|
||||||
|
|
||||||
|
|
||||||
|
//std::cout << "v_ms von pop e- = " << Population->roll_v_ms(interPart->get_x_m())[0]<<"\n";
|
||||||
|
//std::cout << "v_ms von pop e- = " << Population->roll_v_ms(interPart->get_x_m())[0]<<"\n";
|
||||||
|
//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.
|
||||||
|
//double E_eV = calc_E_eV_from_v_ms_richtig(Population->roll_v_ms(interPart->get_x_m()));
|
||||||
|
double E_eV = Population->roll_v_ms(interPart->get_x_m())(0);
|
||||||
|
//fehler? roll_v_ms gibt eine energie
|
||||||
|
std::cout << "Energie aus e- pop " << E_eV <<"\n";
|
||||||
|
//std::cout << "Ort des interpart = " << interPart->get_x_m()<<"\n";
|
||||||
|
|
||||||
|
//E_eV = 1.0; //damit es mal geht, komischer Fehler
|
||||||
|
|
||||||
|
double E_min_eV = 1e-7;
|
||||||
|
double E_max_eV = 2e4;
|
||||||
|
int number_E_bins = 50;
|
||||||
|
Log_Scale E_scale;
|
||||||
|
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
|
||||||
|
int Ee_bin = E_scale.calc_index(E_eV);
|
||||||
|
std::cout<<"Ee_bin = " << Ee_bin<<"\n";
|
||||||
|
//std::cout << "E_eV = " << E_eV<<"\n";
|
||||||
|
Bins loc_bin = Population->get_loc_bin(interPart->get_x_m());
|
||||||
|
|
||||||
|
//std::cout<<"E aus roll v = "<<E_eV<<"\n";
|
||||||
|
double n1 = Population->get_density_m3(Ee_bin, loc_bin); //nur zum schauen
|
||||||
|
//std::cout<<"Population vor Recombination = "<<n1<<"\n";
|
||||||
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
Population->decrease_denisty(interPart->get_x_m(), E_eV);
|
||||||
|
double n2 = Population->get_density_m3(Ee_bin, loc_bin); //nur zum schauen
|
||||||
|
//std::cout<<"Population nach Recombination = "<<n2<<"\n";
|
||||||
|
//std::cout<<"T2+ wurde gelöscht"<<"\n";
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,31 +47,176 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline double TI_e_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
inline double TI_e_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
|
//std::cout<< "wird das gemacht? nich precomputed" << "\n";
|
||||||
|
|
||||||
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
return calc_macro_sigma_m(interPart.get_E_eV(), interPart.get_x_m());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double gammafaktor(double v) {
|
||||||
|
return 1/sqrt(1-pow(v/c_ms, 2));
|
||||||
|
}
|
||||||
|
|
||||||
inline double TI_e_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
inline double TI_e_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||||
|
|
||||||
|
std::cout << "Energie von T2+ in calc macro sigma also in mirco sigma: " << E_eV << "\n";
|
||||||
|
|
||||||
double macro_sigma_m = 0;
|
double macro_sigma_m = 0;
|
||||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||||
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * Population->get_density_m3(Ee_bin, loc_bins);
|
|
||||||
}
|
|
||||||
return macro_sigma_m;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double TI_e_Interaction_Base::calc_microSigma_m2(const double &E2_eV, const int &Ee_bin) {
|
macro_sigma_m += calc_microSigma_m2(E_eV, Ee_bin) * Population->get_density_m3(Ee_bin, loc_bins);
|
||||||
//return get_microSigma_m2(Ee_mids[Ee_bin]); // No Integration... Only e- energy
|
if(Population->get_density_m3(Ee_bin, loc_bins) > 0 ){
|
||||||
double v1_ms = ve_mids[Ee_bin];
|
|
||||||
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV);
|
double v1_ms = ve_mids[Ee_bin]; //ist nährungsweise die richitge geschwindigkeit für elektorn
|
||||||
|
double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV); //ist die richtige geschwindigkeit für ion
|
||||||
|
|
||||||
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||||
|
//std::cout << "machen wir das?" << "\n";
|
||||||
|
//std::cout << Ee_mids[Ee_bin] << "\n";
|
||||||
|
//std::cout << get_microSigma_m2(Ee_mids[Ee_bin]) << "\n";
|
||||||
|
//std::cout << "wird nicht gemacht oder? " << "\n";
|
||||||
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
//neu
|
||||||
|
|
||||||
|
double v1_ms = ve_mids[Ee_bin];
|
||||||
|
double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||||
|
//std::cout << "v1 " << v1_ms <<"\n";
|
||||||
|
//std::cout << "v2 " << v2_ms <<"\n";
|
||||||
|
auto integrand = [&](double theta) {
|
||||||
|
|
||||||
|
|
||||||
|
double p1 = gammafaktor(v2_ms) * m2_eV * v2_ms / c_ms;
|
||||||
|
double p2 = gammafaktor(v1_ms) * m1_eV * v1_ms / c_ms;
|
||||||
|
|
||||||
|
double E1 = sqrt(pow(m2_eV, 2) + pow(p1, 2)); // so ist es wie im python skyript
|
||||||
|
double E2 = sqrt(pow(m1_eV, 2) + pow(p2, 2)); // wie im skrpt
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "E1 " << E1 << "\n"; // ion
|
||||||
|
std::cout << "E2 " << E2 << "\n"; // elektron
|
||||||
|
std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||||
|
std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||||
|
std::cout << "p1 " << p1 << "\n"; // p von ion
|
||||||
|
std::cout << "p2 " << p2 << "\n"; // p von elektorn
|
||||||
|
std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||||
|
std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||||
|
*/
|
||||||
|
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||||
|
//std::cout << "s " << s << "\n";
|
||||||
|
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||||
|
//std::cout << "theta " << theta << "\n";
|
||||||
|
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||||
|
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||||
|
double E_incident = twoEam2/(2*m1_eV);
|
||||||
|
double E_kin_incident = E_incident - m2_eV;
|
||||||
|
double E_eV = E_kin_incident;
|
||||||
|
|
||||||
|
//E_eV = m2_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||||
|
|
||||||
|
//std::cout << "Energie für microsigma berechnung " << E_eV <<"\n";
|
||||||
|
return get_microSigma_m2(E_eV);
|
||||||
|
};
|
||||||
|
|
||||||
|
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
//std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||||
|
|
||||||
|
/* //alt
|
||||||
auto integrand = [&](double theta) {
|
auto integrand = [&](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);
|
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 get_microSigma_m2(E_eV);
|
return get_microSigma_m2(E_eV);
|
||||||
};
|
};
|
||||||
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "monte carlo micro sigma " << calc_microSigma_m2(E_eV, Ee_bin) << "\n";
|
||||||
|
std::cout << "Monte carlo macro sigma " << macro_sigma_m << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
//std::cout << "micro sigma in calcmacrosigma in ohne precomputed" << calc_microSigma_m2(E_eV, Ee_bin) <<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return macro_sigma_m;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double TI_e_Interaction_Base::calc_microSigma_m2(const double &E2_eV, const int &Ee_bin) {
|
||||||
|
//return get_microSigma_m2(Ee_mids[Ee_bin]); // No Integration... Only e- energy
|
||||||
|
double v1_ms = ve_mids[Ee_bin]; //ist nährungsweise die richitge geschwindigkeit für elektorn
|
||||||
|
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV); //ist die richtige geschwindigkeit für ion
|
||||||
|
|
||||||
|
if (v1_ms > v2_ms*2000 ) { // 2000 represents 1% variation in energy
|
||||||
|
//std::cout << "machen wir das?" << "\n";
|
||||||
|
//std::cout << Ee_mids[Ee_bin] << "\n";
|
||||||
|
//std::cout << get_microSigma_m2(Ee_mids[Ee_bin]) << "\n";
|
||||||
|
return get_microSigma_m2(Ee_mids[Ee_bin]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//neu
|
||||||
|
|
||||||
|
double v1_ms = ve_mids[Ee_bin];
|
||||||
|
double v2_ms = calc_v_ms_from_E_eV(E2_eV, m2_eV);
|
||||||
|
//std::cout << "v1 " << v1_ms <<"\n";
|
||||||
|
//std::cout << "v2 " << v2_ms <<"\n";
|
||||||
|
auto integrand = [&](double theta) {
|
||||||
|
|
||||||
|
|
||||||
|
double p1 = gammafaktor(v2_ms) * m2_eV * v2_ms / c_ms;
|
||||||
|
double p2 = gammafaktor(v1_ms) * m1_eV * v1_ms / c_ms;
|
||||||
|
|
||||||
|
double E1 = sqrt(pow(m2_eV, 2) + pow(p1, 2)); // so ist es wie im python skyript
|
||||||
|
double E2 = sqrt(pow(m1_eV, 2) + pow(p2, 2)); // wie im skrpt
|
||||||
|
|
||||||
|
|
||||||
|
//std::cout << "E1 " << E1 << "\n"; // ion
|
||||||
|
//std::cout << "E2 " << E2 << "\n"; // elektron
|
||||||
|
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||||
|
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||||
|
//std::cout << "p1 " << p1 << "\n"; // p von ion
|
||||||
|
//std::cout << "p2 " << p2 << "\n"; // p von elektorn
|
||||||
|
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||||
|
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||||
|
|
||||||
|
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||||
|
//std::cout << "s " << s << "\n";
|
||||||
|
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||||
|
//std::cout << "theta " << theta << "\n";
|
||||||
|
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||||
|
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||||
|
double E_incident = twoEam2/(2*m1_eV);
|
||||||
|
double E_kin_incident = E_incident - m2_eV;
|
||||||
|
|
||||||
|
|
||||||
|
//double E_eV = m2_eV/2 * (pow(v1_ms,2) + pow(v2_ms,2) - 2*v1_ms*v2_ms*cos(theta)) * pow(c_ms, -2); // m1_eV equals reduced mass
|
||||||
|
|
||||||
|
//std::cout << "Energie für microsigma berechnung " << E_eV <<"\n";
|
||||||
|
return get_microSigma_m2(E_kin_incident);
|
||||||
|
};
|
||||||
|
|
||||||
|
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
return integralergebnis;
|
||||||
|
//std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//alt
|
||||||
|
auto integrand = [&](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 get_microSigma_m2(E_eV);
|
||||||
|
};
|
||||||
|
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +239,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline void TI_e_Precomputed_Interaction_Base::calc_values() {
|
inline void TI_e_Precomputed_Interaction_Base::calc_values() {
|
||||||
|
|
||||||
|
std::cout << "EI_bins " << E_scale.get_number_bins() << "\n";
|
||||||
|
std::cout << "Ee_bins " << num_Ee_bins << "\n";
|
||||||
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
for (int EI_bin=0; EI_bin<E_scale.get_number_bins(); EI_bin++) {
|
||||||
|
//std::cout<<"EI_bin = "<<EI_bin<<"\n";
|
||||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||||
precomputed_values[EI_bin][Ee_bin] = calc_microSigma_m2(E_scale.get_bin_mid(EI_bin), Ee_bin);
|
precomputed_values[EI_bin][Ee_bin] = calc_microSigma_m2(E_scale.get_bin_mid(EI_bin), Ee_bin);
|
||||||
}
|
}
|
||||||
@@ -103,25 +252,61 @@ inline void TI_e_Precomputed_Interaction_Base::calc_values() {
|
|||||||
|
|
||||||
inline double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
inline double TI_e_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
vec3 loc_m = interPart.get_x_m();
|
vec3 loc_m = interPart.get_x_m();
|
||||||
|
|
||||||
double E_eV = interPart.get_E_eV();
|
double E_eV = interPart.get_E_eV();
|
||||||
|
|
||||||
|
//std::cout << "wird das gemacht: precomputed " << "\n";
|
||||||
|
//std::cout << "Energie: " << E_eV << "\n";
|
||||||
|
//Bins loc_bin = Population-> get_loc_bin(loc_m);
|
||||||
|
|
||||||
|
//for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||||
|
// std::cout << "E_bin" << Ee_bin <<"\n";
|
||||||
|
// std::cout << "Energie in bin: "<< Population->get_E_bin_mid_eV(Ee_bin) <<"\n";
|
||||||
|
// std::cout << "Dichte in bin: "<< Population->get_density_m3(Ee_bin, loc_bin)<<"\n";
|
||||||
|
//}
|
||||||
|
|
||||||
|
//std::cout << "Pop in TI_e_precomputed_interaction_base: " << Population->get_species() << "\n";
|
||||||
|
//std::cout << "Dichte der Pop in get_macro_sigma: " << Population->get_density_m3(Ee_bin, loc_bin) <<"\n";
|
||||||
|
|
||||||
if (E_scale.in_scale(E_eV)) {
|
if (E_scale.in_scale(E_eV)) {
|
||||||
return lookup_macro_sigma_m(E_eV, loc_m);
|
std::cout << "look up" << "\n";
|
||||||
|
//double a = lookup_macro_sigma_m(E_eV, loc_m);
|
||||||
|
//std::cout << "TI_e_Precomputed_interaction_base lookup_macro_sigma: "<< a << "\n";
|
||||||
|
return lookup_macro_sigma_m(E_eV, loc_m); //ist hier richtig
|
||||||
|
//return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
} else {
|
} else {
|
||||||
|
//double a = calc_macro_sigma_m(E_eV, loc_m);
|
||||||
|
//std::cout << "TI_e_Precomputed_interaction_base calc_macro_sigma: "<< a <<"\n";
|
||||||
|
//return lookup_macro_sigma_m(E_eV, loc_m);
|
||||||
|
std::cout << "calc" << "\n";
|
||||||
return calc_macro_sigma_m(E_eV, loc_m);
|
return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
inline double TI_e_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
|
|
||||||
|
|
||||||
int EI_bin = E_scale.calc_index(E_eV);
|
int EI_bin = E_scale.calc_index(E_eV);
|
||||||
double *microSigmas = precomputed_values[EI_bin];
|
double *microSigmas = precomputed_values[EI_bin];
|
||||||
|
|
||||||
|
std::cout << "EI_bin Ion Energie bin? " << EI_bin << "\n";
|
||||||
|
//std::cout << "microSigmas schaut in precomputed values bei EI_bin: " << microSigmas << "\n";
|
||||||
|
|
||||||
Bins loc_bins = Population->get_loc_bin(loc_m);
|
Bins loc_bins = Population->get_loc_bin(loc_m);
|
||||||
double macro_sigma_m = 0;
|
double macro_sigma_m = 0;
|
||||||
|
|
||||||
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
for (int Ee_bin = 0; Ee_bin<num_Ee_bins; Ee_bin++) {
|
||||||
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
macro_sigma_m += microSigmas[Ee_bin] * Population->get_density_m3(Ee_bin, loc_bins);
|
||||||
|
if(Population->get_density_m3(Ee_bin, loc_bins) > 0){
|
||||||
|
std::cout << "Pop die Beitrag liefert: " << Population->get_species() << " "<< Population->get_density_m3(Ee_bin, loc_bins) <<"\n";
|
||||||
|
std::cout << "micro sigma in look up macro sigma: " << microSigmas[Ee_bin] <<"\n";
|
||||||
|
//std::cout << macro_sigma_m<<"\n";
|
||||||
|
//std::cout << Ee_bin <<"\n";
|
||||||
|
}
|
||||||
|
//std::cout << "hier gehts rein?" << "\n";
|
||||||
}
|
}
|
||||||
|
//std::cout << 1e17 * macro_sigma_m <<"\n";
|
||||||
|
//std::cout << macro_sigma_m<<"\n";
|
||||||
return macro_sigma_m;
|
return macro_sigma_m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
#define drift_base_h
|
#define drift_base_h
|
||||||
|
|
||||||
#include "mover_base.h"
|
#include "mover_base.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
// Drift Approximation: Assume constant B and only movement out in z=0, z=wgtsLength_m...
|
||||||
class Drift_Base : public Mover_Base {
|
class Drift_Base : public Mover_Base {
|
||||||
@@ -18,6 +20,8 @@ public:
|
|||||||
Drift_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
Drift_Base(species this_species, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(this_species, Logger, Population) {};
|
||||||
|
|
||||||
void move(Particle *movePart, const double ¯o_sigma_m);
|
void move(Particle *movePart, const double ¯o_sigma_m);
|
||||||
|
//std::default_random_engine generator;
|
||||||
|
//std::uniform_real_distribution<double> distribution(1e-15,1.0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double get_zNew_m(Particle *movePart, const double ¯o_sigma_m);
|
double get_zNew_m(Particle *movePart, const double ¯o_sigma_m);
|
||||||
@@ -27,6 +31,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
inline void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||||
|
|
||||||
vec3 oldLoc_m = movePart->get_x_m();
|
vec3 oldLoc_m = movePart->get_x_m();
|
||||||
vec3 newLoc_m = oldLoc_m;
|
vec3 newLoc_m = oldLoc_m;
|
||||||
|
|
||||||
@@ -37,7 +42,120 @@ inline void Drift_Base::move(Particle *movePart, const double ¯o_sigma_m) {
|
|||||||
movePart->set_x_m(newLoc_m);
|
movePart->set_x_m(newLoc_m);
|
||||||
do_E_calculus(movePart, oldLoc_m, macro_sigma_m);
|
do_E_calculus(movePart, oldLoc_m, macro_sigma_m);
|
||||||
Logger->log(*movePart, oldLoc_m);
|
Logger->log(*movePart, oldLoc_m);
|
||||||
|
|
||||||
|
//std::cout << "Pop in move sollte die vom current particle sein: " << Population->get_species() <<"\n";
|
||||||
|
|
||||||
|
double E_min_eV = 1e-7;
|
||||||
|
double E_max_eV = 2e4;
|
||||||
|
int number_E_bins = 50;
|
||||||
|
|
||||||
|
Log_Scale E_scale;
|
||||||
|
E_scale = Log_Scale(E_min_eV, E_max_eV, number_E_bins);
|
||||||
|
double E_eV = movePart->get_E_eV();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double n = Population->get_density_m3(oldLoc_m);
|
||||||
|
//std::cout << "Pop vor Erhöhung: " << Population->get_species() << " "<< n <<"\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(const MyException& e)
|
||||||
|
{
|
||||||
|
double E_eV = movePart->get_E_eV();
|
||||||
|
int Ee_bin = E_scale.calc_index(E_eV);
|
||||||
|
Bins loc_bin = Population->get_loc_bin(oldLoc_m);
|
||||||
|
double n = Population->get_density_m3(Ee_bin, loc_bin);
|
||||||
|
//std::cout << "Pop vor Erhöhung: " << Population->get_species() << " " << n << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bins dummyloc0 = Population->get_loc_bin(vec3(0,0,0));
|
||||||
|
Bins dummyloc1 = Population->get_loc_bin(vec3(0,0,1));
|
||||||
|
Bins dummyloc2 = Population->get_loc_bin(vec3(0,0,2));
|
||||||
|
Bins dummyloc3 = Population->get_loc_bin(vec3(0,0,3));
|
||||||
|
Bins dummyloc4 = Population->get_loc_bin(vec3(0,0,4));
|
||||||
|
Bins dummyloc5 = Population->get_loc_bin(vec3(0,0,5));
|
||||||
|
Bins dummyloc6 = Population->get_loc_bin(vec3(0,0,6));
|
||||||
|
Bins dummyloc7 = Population->get_loc_bin(vec3(0,0,7));
|
||||||
|
Bins dummyloc8 = Population->get_loc_bin(vec3(0,0,8));
|
||||||
|
Bins dummyloc9 = Population->get_loc_bin(vec3(0,0,9));
|
||||||
|
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc0) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc1) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc2) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc3) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc4) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc5) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc6) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc7) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc8) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc9) << "\n";
|
||||||
|
*/
|
||||||
|
//std::cerr << e.what() << '\n';
|
||||||
|
/*
|
||||||
|
for (int Ee_bin = 0; Ee_bin<number_E_bins; Ee_bin++) {
|
||||||
|
if(Population->get_density_m3(Ee_bin, loc_bin) > 0){
|
||||||
|
std::cout << "Dichte die einen Beitrag liefert: " << Population->get_density_m3(Ee_bin, loc_bin) <<"\n";
|
||||||
|
//std::cout << macro_sigma_m<<"\n";
|
||||||
|
//std::cout << Ee_bin <<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::cout << "hier gehts rein?" << "\n";
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Population->get_density_m3()
|
||||||
Population->increase_density(*movePart, oldLoc_m);
|
Population->increase_density(*movePart, oldLoc_m);
|
||||||
|
//Population->get_density_m3()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double n = Population->get_density_m3(oldLoc_m);
|
||||||
|
//std::cout << "Pop nach Erhöhung: " << Population->get_species() << " " << n <<"\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(const MyException& e)
|
||||||
|
{
|
||||||
|
double E_eV = movePart->get_E_eV();
|
||||||
|
int Ee_bin = E_scale.calc_index(E_eV);
|
||||||
|
Bins loc_bin = Population->get_loc_bin(oldLoc_m);
|
||||||
|
double n = Population->get_density_m3(Ee_bin, loc_bin);
|
||||||
|
//std::cout << "Pop nach Erhöhung: " << Population->get_species() << " " << n << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bins dummyloc0 = Population->get_loc_bin(vec3(0,0,0));
|
||||||
|
Bins dummyloc1 = Population->get_loc_bin(vec3(0,0,1));
|
||||||
|
Bins dummyloc2 = Population->get_loc_bin(vec3(0,0,2));
|
||||||
|
Bins dummyloc3 = Population->get_loc_bin(vec3(0,0,3));
|
||||||
|
Bins dummyloc4 = Population->get_loc_bin(vec3(0,0,4));
|
||||||
|
Bins dummyloc5 = Population->get_loc_bin(vec3(0,0,5));
|
||||||
|
Bins dummyloc6 = Population->get_loc_bin(vec3(0,0,6));
|
||||||
|
Bins dummyloc7 = Population->get_loc_bin(vec3(0,0,7));
|
||||||
|
Bins dummyloc8 = Population->get_loc_bin(vec3(0,0,8));
|
||||||
|
Bins dummyloc9 = Population->get_loc_bin(vec3(0,0,9));
|
||||||
|
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc0) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc1) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc2) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc3) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc4) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc5) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc6) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc7) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc8) << "\n";
|
||||||
|
std::cout << "pop: " << Population->get_density_m3(Ee_bin, dummyloc9) << "\n";
|
||||||
|
*/
|
||||||
|
//std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sigma_m) {
|
inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sigma_m) {
|
||||||
@@ -56,6 +174,14 @@ inline double Drift_Base::get_zNew_m(Particle *movePart, const double ¯o_sig
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
double distance_m = 1/macro_sigma_m;
|
double distance_m = 1/macro_sigma_m;
|
||||||
|
//distance * e^x mit mu=1
|
||||||
|
//std::cout<<"Distanz ohne random = " << distance_m<<"\n";
|
||||||
|
UniRNG rngUni;
|
||||||
|
double number = rngUni.random();
|
||||||
|
//double number = distribution(generator);
|
||||||
|
//std::cout << "rngUni " << x <<"\n";
|
||||||
|
distance_m = - distance_m * log(number);
|
||||||
|
//std::cout<<"Distanz mit random = " << distance_m<<"\n";
|
||||||
znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
znew_m = zold_m + zDir*vForwardAbs_ms/vTotAbs_ms * distance_m;
|
||||||
}
|
}
|
||||||
return znew_m;
|
return znew_m;
|
||||||
|
|||||||
@@ -16,10 +16,14 @@
|
|||||||
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
class eT2I_Recombination : public e_thermal_Precomputed_Interaction_Base {
|
||||||
public:
|
public:
|
||||||
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
eT2I_Recombination(Population_Base *T2IPopulation, UniRNG *rngUni) : e_thermal_Precomputed_Interaction_Base(T2IPopulation, rngUni, me_eV) {
|
||||||
|
std::cout << "Konstruktor eT2I_Recombinaton" << "\n";
|
||||||
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) {
|
||||||
|
//std::cout<<"werde ich benutzt?"<<"\n";
|
||||||
|
//std::cout << " Energie in microsigma e- mit T2+" << E_eV << "\n";
|
||||||
|
//std::cout<< " micro sigma e- mit T2+ = "<< Janev_eT2I_Recombination::get_TCS(E_eV)<<"\n";
|
||||||
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
return Janev_eT2I_Recombination::get_TCS(E_eV);
|
||||||
}
|
}
|
||||||
InteractionOut do_Interaction (Particle *interPart);
|
InteractionOut do_Interaction (Particle *interPart);
|
||||||
@@ -30,7 +34,15 @@ inline InteractionOut eT2I_Recombination::do_Interaction (Particle *interPart) {
|
|||||||
InteractionOut res;
|
InteractionOut res;
|
||||||
res.set_delete_current(true);
|
res.set_delete_current(true);
|
||||||
//std::cout<<"eT2I:\t"<<*interPart<<"\n";
|
//std::cout<<"eT2I:\t"<<*interPart<<"\n";
|
||||||
//Population->decrease_denisty(interPart->get_x_m(), 0);
|
std::cout<<interPart->get_species()<<" RECO mit " << Population->get_species() << "\n";
|
||||||
|
//std::cout << "Energie von teilchen " << interPart->get_E_eV() <<"\n";
|
||||||
|
//std::cout << "sigma von interaction e- mit T2+ " << get_microSigma_m2(interPart->get_E_eV())<< "\n";
|
||||||
|
//Bins loc_bin = Population->get_loc_bin(interPart->get_x_m());
|
||||||
|
double n1 = Population->get_density_m3(interPart->get_x_m()); //nur zum schauen
|
||||||
|
//std::cout<<"Population vor Recombination = "<< n1<<"\n";
|
||||||
|
Population->decrease_denisty(interPart->get_x_m(), 0);
|
||||||
|
double n2 = Population->get_density_m3(interPart->get_x_m());
|
||||||
|
//std::cout<<"Population nach Recombination = " <<n2<<"\n";
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
inline InteractionOut eT2_Elastic::do_Interaction (Particle *interPart) {
|
inline InteractionOut eT2_Elastic::do_Interaction (Particle *interPart) {
|
||||||
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
// Here theta and phi are COM-Angles.... prob not correct. For m1 << m2 COM - Angle ~ Lab Angle
|
||||||
vec3 v1_ms = interPart->get_v_ms();
|
vec3 v1_ms = interPart->get_v_ms();
|
||||||
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m());
|
vec3 v2_ms = Population->roll_v_ms(interPart->get_x_m()); //trifft das?
|
||||||
vec3 vLab_ms = v1_ms - v2_ms; // P2 fixed
|
vec3 vLab_ms = v1_ms - v2_ms; // P2 fixed
|
||||||
double T_eV = calc_E_eV_from_v_ms(vLab_ms, me_eV);
|
double T_eV = calc_E_eV_from_v_ms(vLab_ms, me_eV);
|
||||||
double theta_lab = dcs_gen->get_theta(T_eV);
|
double theta_lab = dcs_gen->get_theta(T_eV);
|
||||||
|
|||||||
@@ -15,17 +15,19 @@
|
|||||||
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
class e_thermal_Interaction_Base : public Interaction_Base { // Interactions of electrons with thermal Populations
|
||||||
protected:
|
protected:
|
||||||
double m1_eV; // energy of kinetic particle in CS measurement : e-
|
double m1_eV; // energy of kinetic particle in CS measurement : e-
|
||||||
|
|
||||||
double E_limit; // limit for integration calculation
|
double E_limit; // limit for integration calculation
|
||||||
double v_therm; // typical spped for thermal population
|
double v_therm; // typical spped for thermal population
|
||||||
|
|
||||||
public:
|
public:
|
||||||
e_thermal_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
e_thermal_Interaction_Base(Population_Base *Population, UniRNG *rngUni, double m_eV) : Interaction_Base(Population, rngUni) {
|
||||||
|
//std::cout << "machen wir das? "<< Population->get_species()<<"\n"; //wird am anfang geladen ist T2+ pop, also schon ok
|
||||||
if (Population->get_number_E_bins() > 1) {
|
if (Population->get_number_E_bins() > 1) {
|
||||||
throw MyException("Population is not thermal, when expected thermal.");
|
throw MyException("Population is not thermal, when expected thermal.");
|
||||||
}
|
}
|
||||||
m1_eV = m_eV;
|
m1_eV = m_eV;
|
||||||
v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
//v_therm = Population->get_thermal_v_ms(); // Typical Speed of "Thermal Blur"
|
||||||
|
//v_therm = calc_v_ms_from_E_eV(0.1, 2*mT_eV); //gleiche energie
|
||||||
|
v_therm = calc_v_ms_from_E_eV(0.001, me_eV); // gleiche geschwidingkeit
|
||||||
E_limit = calc_E_eV_from_v_ms(v_therm * 2000, m1_eV); // 2000 represents 1% variation in energy
|
E_limit = calc_E_eV_from_v_ms(v_therm * 2000, m1_eV); // 2000 represents 1% variation in energy
|
||||||
}
|
}
|
||||||
double get_macro_sigma_m(const Particle &interPart);
|
double get_macro_sigma_m(const Particle &interPart);
|
||||||
@@ -42,25 +44,172 @@ inline double e_thermal_Interaction_Base::get_macro_sigma_m(const Particle &inte
|
|||||||
vec3 loc_m = interPart.get_x_m();
|
vec3 loc_m = interPart.get_x_m();
|
||||||
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
||||||
|
//std::cout << "e-thermal-base get-macro-sigma-m"<< "\n"; //wird es nicht
|
||||||
return calc_macro_sigma_m(E_eV, loc_m);
|
return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double gammafaktor2(double v) {
|
||||||
|
return 1/sqrt(1-pow(v/c_ms, 2));
|
||||||
|
}
|
||||||
|
|
||||||
inline double e_thermal_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
inline double e_thermal_Interaction_Base::calc_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
|
//std::cout <<"calc"<<"\n";
|
||||||
|
//std::cout << "Dichte für get sigma: " << Population->get_density_m3(loc_m)<<"\n";
|
||||||
|
//std::cout << "calc macro_sigma in e_thermal interaction base macht was "<< "\n";
|
||||||
|
//std::cout << "Dichte die verwednet wird: "<<Population->get_density_m3(loc_m)<<"\n"; //die dichte ist falsch?, also sollte sich halt verkleinern
|
||||||
|
//std::cout << "macro sigma von calc macro sigma in e_thermal interaction base " << 1e15 * calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m)<<"\n";
|
||||||
|
//std::cout << "microsigma = " << get_microSigma_m2(E_eV) << "\n";
|
||||||
|
std::cout << "Energie = " << E_eV << "\n";
|
||||||
|
|
||||||
|
double v1_ms = calc_v_ms_from_E_eV(E_eV, m1_eV);
|
||||||
|
// Integration over theta and v
|
||||||
|
double m2_eV = Population->get_m_eV();
|
||||||
|
//std::cout << "m2 " << m2_eV << "\n";
|
||||||
|
|
||||||
|
double v2_ms = v_therm;
|
||||||
|
//std::cout << "v2 " << v2_ms << "\n";
|
||||||
|
|
||||||
|
//double E1 = E_eV; //unnötig
|
||||||
|
//double E2 = calc_E_eV_from_v_ms(v2_ms, m2_eV);
|
||||||
|
|
||||||
|
//auto integrand = [&](double v2_ms, double theta)
|
||||||
|
auto integrand = [&](double theta) {
|
||||||
|
|
||||||
|
|
||||||
|
//double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||||
|
|
||||||
|
//std::cout << "v1 " << v1_ms <<"\n";
|
||||||
|
//std::cout << "v2 " << v2_ms <<"\n";
|
||||||
|
|
||||||
|
double p1 = gammafaktor2(v1_ms) * m1_eV * v1_ms / c_ms; // e-
|
||||||
|
double p2 = gammafaktor2(v2_ms) * m2_eV * v2_ms / c_ms; // ion
|
||||||
|
double E1 = sqrt(pow(m1_eV, 2) + pow(p1, 2)); // e-
|
||||||
|
double E2 = sqrt(pow(m2_eV, 2) + pow(p2, 2)); // ion
|
||||||
|
/*
|
||||||
|
std::cout << "E1 " << E1 << "\n"; //elektron
|
||||||
|
std::cout << "E2 " << E2 << "\n"; // ion
|
||||||
|
std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||||
|
std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||||
|
std::cout << "p1 " << p1 << "\n"; // p von elektron
|
||||||
|
std::cout << "p2 " << p2 << "\n"; // p von ion
|
||||||
|
std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||||
|
std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||||
|
*/
|
||||||
|
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||||
|
//std::cout << "s " << s << "\n";
|
||||||
|
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||||
|
//std::cout << "theta " << theta << "\n";
|
||||||
|
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||||
|
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||||
|
double E_incident = twoEam2/(2*m2_eV);
|
||||||
|
double E_kin_incident = E_incident - m1_eV;
|
||||||
|
|
||||||
|
|
||||||
|
//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); // m1_eV equals reduced mass
|
||||||
|
//std::cout << "geschwindigkeit pop " << v2_ms << "\n";
|
||||||
|
//std::cout << "Energie " << E_eV <<"\n";
|
||||||
|
//return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||||
|
return get_microSigma_m2(E_kin_incident);
|
||||||
|
};
|
||||||
|
//std::cout << "Masse m1 " << m1_eV << "\n";
|
||||||
|
//std::cout << "Masse m2 " << m2_eV << "\n";
|
||||||
|
//std::cout << "thermal v " << v_therm << "\n";
|
||||||
|
|
||||||
|
//std::cout << "integral für e- ergebnis: " << double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N) << "\n";
|
||||||
|
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
std::cout << "integral gibt: " << integralergebnis <<"\n";
|
||||||
|
std::cout << "Energie? " << E_eV << "\n";
|
||||||
|
//std::cout << "E_limit? " << E_limit << "\n";
|
||||||
|
std::cout << "get microsigma ohne integral (wird nicht verwendet) " << get_microSigma_m2(E_eV) << "\n";
|
||||||
|
std::cout << "Monte Carlo sigma = " << calc_microSigma_m2(E_eV) << "\n";
|
||||||
|
|
||||||
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
return calc_microSigma_m2(E_eV)*Population->get_density_m3(loc_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
inline double e_thermal_Interaction_Base::calc_microSigma_m2(const double &E_eV) {
|
||||||
//return get_microSigma_m2(E_eV); //No Integration... Only e- energy
|
//return get_microSigma_m2(E_eV); //No Integration... Only e- energy
|
||||||
if (E_eV > E_limit) {
|
if (E_eV > E_limit) {
|
||||||
|
//std::cout << " microsigma = " << get_microSigma_m2(E_eV) << "\n";
|
||||||
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);
|
||||||
|
|
||||||
|
double m2_eV = Population->get_m_eV();
|
||||||
|
//std::cout << "m2 " << m2_eV << "\n";
|
||||||
|
|
||||||
|
double v2_ms = v_therm;
|
||||||
|
//std::cout << "v2 " << v2_ms << "\n";
|
||||||
|
|
||||||
|
//double E1 = E_eV; //unnötig
|
||||||
|
//double E2 = calc_E_eV_from_v_ms(v2_ms, m2_eV);
|
||||||
|
|
||||||
|
//auto integrand = [&](double v2_ms, double theta)
|
||||||
|
auto integrand = [&](double theta) {
|
||||||
|
//double v2_ms = calc_v_ms_from_E_eV(E_eV, m2_eV);
|
||||||
|
|
||||||
|
//std::cout << "v1 " << v1_ms <<"\n";
|
||||||
|
//std::cout << "v2 " << v2_ms <<"\n";
|
||||||
|
|
||||||
|
double p1 = gammafaktor2(v1_ms) * m1_eV * v1_ms / c_ms; // e-
|
||||||
|
double p2 = gammafaktor2(v2_ms) * m2_eV * v2_ms / c_ms; // ion
|
||||||
|
double E1 = sqrt(pow(m1_eV, 2) + pow(p1, 2)); // e-
|
||||||
|
double E2 = sqrt(pow(m2_eV, 2) + pow(p2, 2)); // ion
|
||||||
|
|
||||||
|
//std::cout << "E1 " << E1 << "\n"; //elektron
|
||||||
|
//std::cout << "E2 " << E2 << "\n"; // ion
|
||||||
|
//std::cout << "v1 " << v1_ms << "\n"; // elektron
|
||||||
|
//std::cout << "v2 " << v2_ms << "\n"; // ion
|
||||||
|
//std::cout << "p1 " << p1 << "\n"; // p von elektron
|
||||||
|
//std::cout << "p2 " << p2 << "\n"; // p von ion
|
||||||
|
//std::cout << "m1 " << m1_eV << "\n"; // elektron
|
||||||
|
//std::cout << "m2 " << m2_eV << "\n"; // ion
|
||||||
|
|
||||||
|
double s = pow(m1_eV,2) + pow(m2_eV,2) + 2 * E1 * E2 - 2 * p1 * p2 * cos(theta);
|
||||||
|
//std::cout << "s " << s << "\n";
|
||||||
|
double E_cm_eV = sqrt(s) - m1_eV - m2_eV;
|
||||||
|
//std::cout << "theta " << theta << "\n";
|
||||||
|
//std::cout << "E_cm_eV " << E_cm_eV << "\n";
|
||||||
|
double twoEam2 = s - pow(m1_eV, 2) - pow(m2_eV, 2);
|
||||||
|
double E_incident = twoEam2/(2*m2_eV);
|
||||||
|
double E_kin_incident = E_incident - m1_eV;
|
||||||
|
|
||||||
|
|
||||||
|
//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); // m1_eV equals reduced mass
|
||||||
|
//std::cout << "geschwindigkeit pop " << v2_ms << "\n";
|
||||||
|
//std::cout << "Energie " << E_eV <<"\n";
|
||||||
|
//return Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||||
|
return get_microSigma_m2(E_kin_incident);
|
||||||
|
};
|
||||||
|
//std::cout << "Masse m1 " << m1_eV << "\n";
|
||||||
|
//std::cout << "Masse m2 " << m2_eV << "\n";
|
||||||
|
//std::cout << "thermal v " << v_therm << "\n";
|
||||||
|
//std::cout << "integral für e- ergebnis: " << double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N) << "\n";
|
||||||
|
double integralergebnis = integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
return integralergebnis;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Integration over theta and v
|
||||||
|
double v2_ms = v_therm;
|
||||||
|
auto integrand = [&](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 get_microSigma_m2(E_eV);
|
||||||
|
};
|
||||||
|
return integrate(integrand, 0., pi, INT_N, simpson())/pi;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* //alt
|
||||||
// Integration over theta and v
|
// Integration over theta and v
|
||||||
auto integrand = [&](double v2_ms, double theta) {
|
auto integrand = [&](double v2_ms, double theta) {
|
||||||
|
v2_ms = v2_ms + Population->get_drift()
|
||||||
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);
|
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 Population->get_v_pdf(v2_ms)*get_microSigma_m2(E_eV)/pi;
|
||||||
};
|
};
|
||||||
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
return double_simpson_integrate(integrand, 0., 3*v_therm, 0., pi, INT_N, INT_N); // 3*v_therm equals 99% of the integral
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,24 +246,58 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline void e_thermal_Precomputed_Interaction_Base::calc_values() {
|
inline void e_thermal_Precomputed_Interaction_Base::calc_values() {
|
||||||
|
std::cout << "number E bins " << E_scale.get_number_bins() << "\n";
|
||||||
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
for (int i=0; i<E_scale.get_number_bins(); i++) {
|
||||||
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
precomputed_values[i] = calc_microSigma_m2(E_scale.get_bin_mid(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
inline double e_thermal_Precomputed_Interaction_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
|
//std::cout << "wird das verwendet e_termal_precomputed_interaciton_base::get_macro_sigma_m "<<"\n"; //wird verwendet, ok gut -> hier suchen!
|
||||||
|
|
||||||
vec3 loc_m = interPart.get_x_m();
|
vec3 loc_m = interPart.get_x_m();
|
||||||
|
//std::cout << "Pop in e_thermal_precomputed_interaction_base: " << Population->get_species() << "\n";
|
||||||
|
//std::cout << "verwendete Dichte für get_macro_sigma_m in e_thermal_precomputed_interaction_base: " << Population->get_species() << " "<<Population->get_density_m3(loc_m)<<"\n";
|
||||||
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
double v_ms = calc_vec3_abs(interPart.get_v_ms() - Population->get_drift_v_ms(loc_m)); // Shift to "Labframe without thermal blur"
|
||||||
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal integration
|
//std::cout << Population->get_species() << "\n";
|
||||||
|
//double v_ms = calc_vec3_abs(interPart.get_v_ms()); //test ohne shift
|
||||||
|
//std::cout << "verwendete geschwindigkeit: " << v_ms << "\n";
|
||||||
|
//std::cout << "thermal dirft v = " << Population->get_drift_v_ms(loc_m) << "\n";
|
||||||
|
double E_eV = calc_E_eV_from_v_ms(v_ms, m1_eV); // Lab energy without thermal
|
||||||
|
//E_eV = interPart.get_E_eV(); // warum nicht so?
|
||||||
|
//double microsigma_montecarlo = calc_microSigma_m2(E_eV);
|
||||||
|
//std::cout << "Monte Carlo Micro Sigma = " << microsigma_montecarlo << "\n";
|
||||||
|
//std::cout << "pop in get_macro_sigma_m in e_thermal_precomputed_interaction_base: " << Population->get_species()<<"\n";
|
||||||
|
|
||||||
|
|
||||||
|
//return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
|
|
||||||
if (E_scale.in_scale(E_eV)) {
|
if (E_scale.in_scale(E_eV)) {
|
||||||
|
//double a;
|
||||||
|
//a = lookup_macro_sigma_m(E_eV, loc_m);
|
||||||
|
//std::cout << " lookup_macro_sigma in get_macro_sigma in e_thermal_precomputed_base gibt: " << a <<"\n";
|
||||||
|
std::cout << "look_up" << "\n";
|
||||||
return lookup_macro_sigma_m(E_eV, loc_m);
|
return lookup_macro_sigma_m(E_eV, loc_m);
|
||||||
|
//return calc_macro_sigma_m(E_eV, loc_m); // zum testen
|
||||||
} else {
|
} else {
|
||||||
|
//double a;
|
||||||
|
//a = calc_macro_sigma_m(E_eV, loc_m);
|
||||||
|
//std::cout << "calc_macro_sigma in get_macro_sigma in e_thermal_precomputed_base: " << a << "\n";
|
||||||
|
std::cout<< "calc" <<"\n";
|
||||||
return calc_macro_sigma_m(E_eV, loc_m);
|
return calc_macro_sigma_m(E_eV, loc_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double e_thermal_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
inline double e_thermal_Precomputed_Interaction_Base::lookup_macro_sigma_m(const double &E_eV, const vec3 &loc_m) {
|
||||||
int i = E_scale.calc_index(E_eV);
|
int i = E_scale.calc_index(E_eV);
|
||||||
|
//std::cout <<"E index = "<<i<<"\n";
|
||||||
|
//std::cout <<"precomputed_values[i] = " << precomputed_values[i]<< "\n";
|
||||||
|
//std::cout << "pop denisity = " << Population->get_density_m3(loc_m)<<"\n";
|
||||||
|
//std::cout << "pop denisity species = " << Population->get_species()<<"\n";
|
||||||
|
//std::cout <<"look up"<<"\n";
|
||||||
|
//std::cout << "Dichte für get sigma in e_thermal_precomuputed_interaction_base: " << Population->get_density_m3(loc_m)<<"\n";
|
||||||
|
std::cout << "precomputaed value der verwendet wird (Monte Carlo Sigma): " << precomputed_values[i] <<"\n";
|
||||||
return precomputed_values[i] * Population->get_density_m3(loc_m);
|
return precomputed_values[i] * Population->get_density_m3(loc_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ private:
|
|||||||
|
|
||||||
void E_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m) {
|
void E_Mover_Boris::move(Particle *movePart, const double ¯o_sigma_m) {
|
||||||
// Prepare detection for change of z direction for logging
|
// Prepare detection for change of z direction for logging
|
||||||
|
std::cout<<"boris mover"<<"\n";
|
||||||
|
|
||||||
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
double oldzDir = movePart->get_v_ms()[2] < 0 ? -1 : 1;
|
||||||
vec3 oldLoc_m = movePart->get_x_m();
|
vec3 oldLoc_m = movePart->get_x_m();
|
||||||
|
|
||||||
|
|||||||
Executable
+130
@@ -0,0 +1,130 @@
|
|||||||
|
#ifndef ENUMERATIONS_H
|
||||||
|
#define ENUMERATIONS_H
|
||||||
|
|
||||||
|
namespace Cart {
|
||||||
|
enum Axis {
|
||||||
|
x = 0,
|
||||||
|
y = 1,
|
||||||
|
z = 2
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Cyl {
|
||||||
|
enum Axis {
|
||||||
|
rho = 0,
|
||||||
|
phi = 1,
|
||||||
|
z = 2
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace AXIS {
|
||||||
|
static const int X = 0;
|
||||||
|
static const int Y = 1;
|
||||||
|
static const int Z = 2;
|
||||||
|
static const int Rho = 3;
|
||||||
|
static const int Phi = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace GEOMETRY {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int cylinder = 1;
|
||||||
|
static const int cube = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FORMFACTOR {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int Default = 5;
|
||||||
|
static const int NGP = 1;
|
||||||
|
static const int NGPCIC = 2;
|
||||||
|
static const int CIC = 3;
|
||||||
|
static const int CICTSC = 4;
|
||||||
|
static const int TSC = 5;
|
||||||
|
static const int TSCPQS = 6;
|
||||||
|
static const int PQS = 7;
|
||||||
|
static const int PQSPCS = 8;
|
||||||
|
static const int PCS = 9;
|
||||||
|
static const int SUDS1 = 10;
|
||||||
|
static const int SUDS2 = 11;
|
||||||
|
static const int COS = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PARTICLE_PUSHER {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int Default = 1;
|
||||||
|
static const int boris = 1;
|
||||||
|
static const int vay = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CURRENT_ASSIGNMENT {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int Default = 1;
|
||||||
|
static const int esirkepov = 1;
|
||||||
|
static const int umeda = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MAXWELL_SOLVER {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int Default = 1;
|
||||||
|
static const int yee = 1;
|
||||||
|
static const int ck = 2;
|
||||||
|
static const int ck5 = 3;
|
||||||
|
static const int O4 = 4;
|
||||||
|
static const int M24 = 5;
|
||||||
|
static const int ES = 6;
|
||||||
|
static const int darwin = 7;
|
||||||
|
static const int deymittra = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CURRENT_BACKGROUND {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int precalculated = 1;
|
||||||
|
static const int homogeneous = 2;
|
||||||
|
static const int polynomial = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MAGENTIC_BACKGROUND {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int polynomial = 1;
|
||||||
|
static const int homogeneous = 2;
|
||||||
|
static const int precalculated = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ELECTRIC_BACKGROUND {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int polynomial = 1;
|
||||||
|
static const int homogeneous = 2;
|
||||||
|
static const int precalculated = 3;
|
||||||
|
static const int rearwall = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CAVITY_MODE {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int TE = 1;
|
||||||
|
static const int TM = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RANDOM_NUMBER_METHOD {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int rejection = 1;
|
||||||
|
static const int inverse = 2;
|
||||||
|
static const int gamma_boltzmann= 3;
|
||||||
|
static const int histogram = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace DISTRIBUTION_FUNCTION {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int boltzmann3D = 1;
|
||||||
|
static const int T3_beta = 2;
|
||||||
|
static const int linear = 3;
|
||||||
|
static const int power = 4;
|
||||||
|
static const int power_inverse = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace INJECTION_PLANE_TYPE {
|
||||||
|
static const int undefined = -1;
|
||||||
|
static const int density = 1;
|
||||||
|
static const int current = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ENUMERATIONS_H
|
||||||
@@ -15,43 +15,51 @@ using namespace std;
|
|||||||
|
|
||||||
pop_bin sample_log_cell = {0,0,0,0,0,0,0};
|
pop_bin sample_log_cell = {0,0,0,0,0,0,0};
|
||||||
const size_t H5TB_Population_Interface::size = sizeof(pop_bin);
|
const size_t H5TB_Population_Interface::size = sizeof(pop_bin);
|
||||||
const char *H5TB_Population_Interface::fieldNames[7] = {
|
const char *H5TB_Population_Interface::fieldNames[9] = {
|
||||||
"phys_time_s",
|
"phys_time_s",
|
||||||
"z_bin",
|
"z_bin",
|
||||||
"r_bin",
|
"r_bin",
|
||||||
"phi_bin",
|
"phi_bin",
|
||||||
"E_bin",
|
"E_bin",
|
||||||
"cum_time",
|
"cum_time",
|
||||||
"offset"};
|
"offset",
|
||||||
const size_t H5TB_Population_Interface::offset[7] = {
|
"n_m3",
|
||||||
|
"tracking"};
|
||||||
|
const size_t H5TB_Population_Interface::offset[9] = {
|
||||||
HOFFSET(pop_bin, phys_time_s),
|
HOFFSET(pop_bin, phys_time_s),
|
||||||
HOFFSET(pop_bin, z_bin),
|
HOFFSET(pop_bin, z_bin),
|
||||||
HOFFSET(pop_bin, r_bin),
|
HOFFSET(pop_bin, r_bin),
|
||||||
HOFFSET(pop_bin, phi_bin),
|
HOFFSET(pop_bin, phi_bin),
|
||||||
HOFFSET(pop_bin, E_bin),
|
HOFFSET(pop_bin, E_bin),
|
||||||
HOFFSET(pop_bin, cumulated_time_s),
|
HOFFSET(pop_bin, cumulated_time_s),
|
||||||
HOFFSET(pop_bin, offset)};
|
HOFFSET(pop_bin, offset),
|
||||||
const hid_t H5TB_Population_Interface::fieldTypes[7] = {
|
HOFFSET(pop_bin, n_m3),
|
||||||
|
HOFFSET(pop_bin, tracking)};
|
||||||
|
const hid_t H5TB_Population_Interface::fieldTypes[9] = {
|
||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
H5T_NATIVE_INT};
|
H5T_NATIVE_INT};
|
||||||
const hsize_t H5TB_Population_Interface::chunkSize = 225;
|
const hsize_t H5TB_Population_Interface::chunkSize = 225;
|
||||||
const size_t H5TB_Population_Interface::sizes[7] = {
|
const size_t H5TB_Population_Interface::sizes[9] = {
|
||||||
sizeof( sample_log_cell.phys_time_s),
|
sizeof( sample_log_cell.phys_time_s),
|
||||||
sizeof( sample_log_cell.z_bin),
|
sizeof( sample_log_cell.z_bin),
|
||||||
sizeof( sample_log_cell.r_bin),
|
sizeof( sample_log_cell.r_bin),
|
||||||
sizeof( sample_log_cell.phi_bin),
|
sizeof( sample_log_cell.phi_bin),
|
||||||
sizeof( sample_log_cell.E_bin),
|
sizeof( sample_log_cell.E_bin),
|
||||||
sizeof( sample_log_cell.cumulated_time_s),
|
sizeof( sample_log_cell.cumulated_time_s),
|
||||||
sizeof( sample_log_cell.offset)};
|
sizeof( sample_log_cell.offset),
|
||||||
|
sizeof( sample_log_cell.n_m3),
|
||||||
|
sizeof( sample_log_cell.tracking)};
|
||||||
|
|
||||||
|
|
||||||
void H5TB_Population_Interface::create() {
|
void H5TB_Population_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 9, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, NULL, 0, NULL);
|
chunkSize, NULL, 0, NULL);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
|
|||||||
@@ -24,16 +24,18 @@ struct pop_bin {
|
|||||||
int E_bin;
|
int E_bin;
|
||||||
double cumulated_time_s;
|
double cumulated_time_s;
|
||||||
int offset;
|
int offset;
|
||||||
|
double n_m3;
|
||||||
|
int tracking;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class H5TB_Population_Interface {
|
class H5TB_Population_Interface {
|
||||||
static const size_t size;
|
static const size_t size;
|
||||||
static const char *fieldNames[7];
|
static const char *fieldNames[9];
|
||||||
static const size_t offset[7];
|
static const size_t offset[9];
|
||||||
static const hid_t fieldTypes[7];
|
static const hid_t fieldTypes[9];
|
||||||
static const hsize_t chunkSize;
|
static const hsize_t chunkSize;
|
||||||
static const size_t sizes[7];
|
static const size_t sizes[9];
|
||||||
|
|
||||||
int buffer_size = 225;
|
int buffer_size = 225;
|
||||||
pop_bin buffer[225];
|
pop_bin buffer[225];
|
||||||
|
|||||||
@@ -28,10 +28,21 @@ public:
|
|||||||
Injector(UniRNG *rngUni, NormalRNG *rngNormal, Population_Base *T2Population, int method, double energy_eV, int ions) : RNG_Base(rngUni, rngNormal){
|
Injector(UniRNG *rngUni, NormalRNG *rngNormal, Population_Base *T2Population, int method, double energy_eV, int ions) : RNG_Base(rngUni, rngNormal){
|
||||||
this->T2Population = T2Population;
|
this->T2Population = T2Population;
|
||||||
this->method = method;
|
this->method = method;
|
||||||
|
//std::cout << "Method in konsturktur: " << method <<"\n";
|
||||||
this->energy_eV = energy_eV;
|
this->energy_eV = energy_eV;
|
||||||
this->ions = ions;
|
this->ions = ions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void set_method(int i){
|
||||||
|
method = i;
|
||||||
|
std::cout << "habe methode auf " << i << " gesetzt" << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_method(){
|
||||||
|
std::cout << "aktuelle method ist " << method <<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
int inject (std::vector<Particle> *particle_queue, const int &last_ID);
|
||||||
private:
|
private:
|
||||||
double roll_FermiEnergy_eV();
|
double roll_FermiEnergy_eV();
|
||||||
@@ -41,27 +52,71 @@ private:
|
|||||||
|
|
||||||
inline int Injector::inject (std::vector<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();
|
vec3 loc_m = T2Population->roll_x_ms();
|
||||||
|
vec3 v_ms;
|
||||||
|
vec3 vTI_ms;
|
||||||
|
//vec3 direction;
|
||||||
double E_eV;
|
double E_eV;
|
||||||
switch(method) {
|
switch(method) {
|
||||||
case 0: // Fermi
|
case 0: // Fermi
|
||||||
E_eV = roll_FermiEnergy_eV();
|
E_eV = roll_FermiEnergy_eV();
|
||||||
|
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||||
|
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
break;
|
break;
|
||||||
case 1: //Delta
|
case 1: //Delta
|
||||||
E_eV = energy_eV;
|
E_eV = energy_eV;
|
||||||
|
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||||
|
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
break;
|
break;
|
||||||
case 2: //Maxwell Boltzman
|
case 2: //Maxwell Boltzman
|
||||||
E_eV = roll_MBEnergy(energy_eV/kb_eVK, me_eV, rngNormal);
|
E_eV = roll_MBEnergy(energy_eV/kb_eVK, me_eV, rngNormal);
|
||||||
|
v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||||
|
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
|
break;
|
||||||
|
case 3: // Delta Injection for Recombination Testing
|
||||||
|
|
||||||
|
std::cout << "injecte e-" <<"\n";
|
||||||
|
loc_m = vec3(0.,0.,9.99);
|
||||||
|
E_eV = energy_eV;
|
||||||
|
//std::cout<<"E = "<< E_eV<<"\n";
|
||||||
|
//direction = vec3(0,0,-1);
|
||||||
|
v_ms = vec3(0.,0.,-1.) * calc_v_ms_from_E_eV(E_eV, me_eV);
|
||||||
|
std::cout << "Geschwindigkeit e-: " << v_ms << "\n";
|
||||||
|
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
std::cout << "injecte T2+" <<"\n";
|
||||||
|
E_eV = energy_eV;
|
||||||
|
loc_m = vec3(0.,0.,9.99);
|
||||||
|
vTI_ms = vec3(0.,0.,-1.) * calc_v_ms_from_E_eV(E_eV, me_eV);
|
||||||
|
std::cout << "Geschwindigkeit T+: " << vTI_ms << "\n";
|
||||||
|
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+1, last_ID+1));
|
||||||
|
|
||||||
|
//loc_m = vec3(0.,0.,z_WGTS_end_m);
|
||||||
|
//E_eV = energy_eV;
|
||||||
|
//direction = vec3(0,0,-1);
|
||||||
|
//v_ms = vec3(0.,0.,-1.) * calc_v_ms_from_E_eV(E_eV, me_eV);
|
||||||
|
//particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
throw MyException("Katrin::injectElectron: Invalid Injection Method.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
|
||||||
particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
//vec3 v_ms = roll_uniform_direction(rngUni) * calc_v_ms_from_E_eV(E_eV,me_eV);
|
||||||
|
//particle_queue->push_back(PartFac.create_e(loc_m, v_ms, last_ID+1, last_ID+1));
|
||||||
|
|
||||||
if (ions == 0) {
|
if (ions == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ions == 2) { // 2: Delta Injection for Testing Recombination
|
||||||
|
vec3 direction = vec3(0.,0.,-1.);
|
||||||
|
vec3 loc_m = vec3(0.,0.,9.99);
|
||||||
|
vec3 vTI_ms = direction * calc_v_ms_from_E_eV(E_eV, me_eV); //gleiche geschwindigkeit
|
||||||
|
//vec3 vTI_ms = direction * calc_v_ms_from_E_eV(E_eV, 2*mT_eV); // gleiche energie
|
||||||
|
particle_queue->push_back(PartFac.create_T2I(loc_m, vTI_ms, last_ID+2, last_ID+2));
|
||||||
|
return 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vec3 vTI_ms = T2Population->roll_v_ms(loc_m);
|
vec3 vTI_ms = T2Population->roll_v_ms(loc_m);
|
||||||
particle_queue->push_back(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));
|
||||||
|
|||||||
@@ -46,24 +46,24 @@
|
|||||||
#include "T5IT2_elastic.h"
|
#include "T5IT2_elastic.h"
|
||||||
#include "T5Ie_recombination.h"
|
#include "T5Ie_recombination.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
Interaction_Manager Interaction_Builder::build(Population_Manager *Populations, UniRNG *rngUni) {
|
Interaction_Manager Interaction_Builder::build(Population_Manager *Populations, UniRNG *rngUni) {
|
||||||
Interaction_Manager Interactions;
|
Interaction_Manager Interactions;
|
||||||
Interactions.add(build_electron(Populations, rngUni));
|
Interactions.add(build_electron(Populations, rngUni));
|
||||||
//Interactions.add(build_tritium(Populations, rngUni));
|
//Interactions.add(build_tritium(Populations, rngUni));
|
||||||
Interactions.add(build_tritiumI(Populations, rngUni));
|
//Interactions.add(build_tritiumI(Populations, rngUni));
|
||||||
Interactions.add(build_tritium2I(Populations, rngUni));
|
Interactions.add(build_tritium2I(Populations, rngUni));
|
||||||
Interactions.add(build_tritium3I(Populations, rngUni));
|
//Interactions.add(build_tritium3I(Populations, rngUni));
|
||||||
Interactions.add(build_tritium5I(Populations, rngUni));
|
//Interactions.add(build_tritium5I(Populations, rngUni));
|
||||||
return Interactions;
|
return Interactions;
|
||||||
}
|
}
|
||||||
Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager *Populations, UniRNG *rngUni) {
|
Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager *Populations, UniRNG *rngUni) {
|
||||||
Interaction_Channel_Base *eInteraction = new Interaction_Channel_Base(electron, rngUni);
|
Interaction_Channel_Base *eInteraction = new Interaction_Channel_Base(electron, rngUni);
|
||||||
Population_Base *T2Population = Populations->find(tritium2);
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
Population_Base *T2IPopulation = Populations->find(tritium2I);
|
Population_Base *T2IPopulation = Populations->find(tritium2I);
|
||||||
Population_Base *T3IPopulation = Populations->find(tritium3I);
|
//Population_Base *T3IPopulation = Populations->find(tritium3I);
|
||||||
Population_Base *T5IPopulation = Populations->find(tritium5I);
|
//Population_Base *T5IPopulation = Populations->find(tritium5I);
|
||||||
DCS_Base *exc_dcs = new ZeroPi_DCS(rngUni);
|
DCS_Base *exc_dcs = new ZeroPi_DCS(rngUni);
|
||||||
|
|
||||||
if (load_parameter("eT2_ELA") == 1) {
|
if (load_parameter("eT2_ELA") == 1) {
|
||||||
@@ -117,9 +117,10 @@ Interaction_Channel_Base* Interaction_Builder::build_electron(Population_Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (load_parameter("e_REC") == 1) {
|
if (load_parameter("e_REC") == 1) {
|
||||||
|
std::cout<<"Recombination für e- an"<<"\n";
|
||||||
eInteraction->add(new eT2I_Recombination(T2IPopulation, rngUni));
|
eInteraction->add(new eT2I_Recombination(T2IPopulation, rngUni));
|
||||||
eInteraction->add(new eT3I_Recombination(T3IPopulation, rngUni));
|
//eInteraction->add(new eT3I_Recombination(T3IPopulation, rngUni));
|
||||||
eInteraction->add(new eT5I_Recombination(T5IPopulation, rngUni));
|
//eInteraction->add(new eT5I_Recombination(T5IPopulation, rngUni));
|
||||||
} else if (load_parameter("e_REC") != 0) {
|
} else if (load_parameter("e_REC") != 0) {
|
||||||
throw MyException ("e_REC invalid.");
|
throw MyException ("e_REC invalid.");
|
||||||
}
|
}
|
||||||
@@ -170,9 +171,15 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium(Population_Manager
|
|||||||
Interaction_Channel_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
Interaction_Channel_Base* Interaction_Builder::build_tritiumI(Population_Manager *Populations, UniRNG *rngUni) {
|
||||||
Interaction_Channel_Base *TI_Interaction = new Interaction_Channel_Base(tritiumI, rngUni);
|
Interaction_Channel_Base *TI_Interaction = new Interaction_Channel_Base(tritiumI, rngUni);
|
||||||
Population_Base *T2Population = Populations->find(tritium2);
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
|
||||||
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
if (load_parameter("T_INTER") == 1) {
|
||||||
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
TI_Interaction->add(new TIT2_Elastic(T2Population, rngUni));
|
||||||
|
TI_Interaction->add (new TIT2_RadAsc(T2Population, rngUni));
|
||||||
|
TI_Interaction->add (new TIT2_TerAsc(T2Population, rngUni));
|
||||||
|
} else if (load_parameter("T_INTER") != 0) {
|
||||||
|
throw MyException ("T_INTER invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
return TI_Interaction;
|
return TI_Interaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,13 +189,18 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium2I(Population_Manage
|
|||||||
Population_Base *ePopulation = Populations->find(electron);
|
Population_Base *ePopulation = Populations->find(electron);
|
||||||
|
|
||||||
if (load_parameter("e_REC") == 1) {
|
if (load_parameter("e_REC") == 1) {
|
||||||
|
std::cout<<"Recombination für T2+ an"<<"\n";
|
||||||
T2I_Interaction->add(new T2Ie_Recombination(ePopulation, rngUni));
|
T2I_Interaction->add(new T2Ie_Recombination(ePopulation, rngUni));
|
||||||
} else if (load_parameter("e_REC") != 0) {
|
} else if (load_parameter("e_REC") != 0) {
|
||||||
throw MyException ("e_REC invalid.");
|
throw MyException ("e_REC invalid.");
|
||||||
}
|
}
|
||||||
//T2I_Interaction->add(new T2Ie_DissExc(ePopulation, rngUni));
|
//T2I_Interaction->add(new T2Ie_DissExc(ePopulation, rngUni));
|
||||||
|
if (load_parameter("T_INTER") == 1) {
|
||||||
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
T2I_Interaction->add(new T2IT2_Cluster(T2Population, rngUni));
|
||||||
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
T2I_Interaction->add(new T2IT2_CX(T2Population, rngUni));
|
||||||
|
} else if (load_parameter("T_INTER") != 0) {
|
||||||
|
throw MyException ("T_INTER invalid.");
|
||||||
|
}
|
||||||
return T2I_Interaction ;
|
return T2I_Interaction ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,10 +208,13 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium3I(Population_Manage
|
|||||||
Interaction_Channel_Base *T3I_Interaction = new Interaction_Channel_Base(tritium3I, rngUni);
|
Interaction_Channel_Base *T3I_Interaction = new Interaction_Channel_Base(tritium3I, rngUni);
|
||||||
Population_Base *T2Population = Populations->find(tritium2);
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
Population_Base *ePopulation = Populations->find(electron);
|
Population_Base *ePopulation = Populations->find(electron);
|
||||||
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
if (load_parameter("T_INTER") == 1) {
|
||||||
T3I_Interaction->add(new T3IT2_RadAsc(T2Population, rngUni));
|
T3I_Interaction->add(new T3IT2_Elastic(T2Population, rngUni));
|
||||||
T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
T3I_Interaction->add(new T3IT2_RadAsc(T2Population, rngUni));
|
||||||
|
T3I_Interaction->add(new T3IT2_TerAsc(T2Population, rngUni));
|
||||||
|
} else if (load_parameter("T_INTER") != 0) {
|
||||||
|
throw MyException ("T_INTER invalid.");
|
||||||
|
}
|
||||||
if (load_parameter("e_REC") == 1) {
|
if (load_parameter("e_REC") == 1) {
|
||||||
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
T3I_Interaction->add(new T3Ie_Recombination(ePopulation, rngUni));
|
||||||
} else if (load_parameter("e_REC") != 0) {
|
} else if (load_parameter("e_REC") != 0) {
|
||||||
@@ -214,8 +229,11 @@ Interaction_Channel_Base* Interaction_Builder::build_tritium5I(Population_Manage
|
|||||||
Interaction_Channel_Base *T5I_Interaction = new Interaction_Channel_Base(tritium5I, rngUni);
|
Interaction_Channel_Base *T5I_Interaction = new Interaction_Channel_Base(tritium5I, rngUni);
|
||||||
Population_Base *T2Population = Populations->find(tritium2);
|
Population_Base *T2Population = Populations->find(tritium2);
|
||||||
Population_Base *ePopulation = Populations->find(electron);
|
Population_Base *ePopulation = Populations->find(electron);
|
||||||
|
if (load_parameter("T_INTER") == 1) {
|
||||||
T5I_Interaction->add(new T5IT2_Elastic(T2Population, rngUni));
|
T5I_Interaction->add(new T5IT2_Elastic(T2Population, rngUni));
|
||||||
|
} else if (load_parameter("T_INTER") != 0) {
|
||||||
|
throw MyException ("T_INTER invalid.");
|
||||||
|
}
|
||||||
if (load_parameter("e_REC") == 1) {
|
if (load_parameter("e_REC") == 1) {
|
||||||
T5I_Interaction->add(new T5Ie_Recombination(ePopulation, rngUni));
|
T5I_Interaction->add(new T5Ie_Recombination(ePopulation, rngUni));
|
||||||
} else if (load_parameter("e_REC") != 0) {
|
} else if (load_parameter("e_REC") != 0) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "process_base.h"
|
#include "process_base.h"
|
||||||
#include "interaction_base.h"
|
#include "interaction_base.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class Interaction_Channel_Base : public Process_Base {
|
class Interaction_Channel_Base : public Process_Base {
|
||||||
Interaction_Base **SubInteractions;
|
Interaction_Base **SubInteractions;
|
||||||
@@ -31,15 +32,26 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
||||||
double macro_sigma_m = get_macro_sigma_m(*interPart);
|
|
||||||
|
double macro_sigma_m = get_macro_sigma_m(*interPart); //hier kommt 0 raus???
|
||||||
|
//std::cout<<"MacroSigma_m = "<<macro_sigma_m<<"\n"; //wird gemacht
|
||||||
double currentStackedSigma = 0;
|
double currentStackedSigma = 0;
|
||||||
double targetStackedSigma = rngUni->random() * macro_sigma_m;
|
double targetStackedSigma = rngUni->random() * macro_sigma_m;
|
||||||
|
//std::cout<<"TargetStackedSigma_m = "<<targetStackedSigma<<"\n";
|
||||||
|
//std::cout<<"numSubInteractions = "<<numSubInteractions<<"\n";
|
||||||
|
|
||||||
for (int i = 0; i < numSubInteractions; i++) {
|
for (int i = 0; i < numSubInteractions; i++) {
|
||||||
currentStackedSigma += SubInteractions[i]->get_macro_sigma_m(*interPart);
|
currentStackedSigma += SubInteractions[i]->get_macro_sigma_m(*interPart);
|
||||||
if (currentStackedSigma >= targetStackedSigma) {
|
if (currentStackedSigma > targetStackedSigma) {
|
||||||
|
std::cout << "mache Interaktion" << "\n";
|
||||||
return SubInteractions[i]->do_Interaction(interPart);
|
return SubInteractions[i]->do_Interaction(interPart);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
InteractionOut nichts;
|
||||||
|
std::cout << "Teilchen fliegt weiter"<< "\n";
|
||||||
|
return nichts;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||||
@@ -50,9 +62,14 @@ inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPa
|
|||||||
inline double Interaction_Channel_Base::get_macro_sigma_m(const Particle &interPart) {
|
inline double Interaction_Channel_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||||
double macro_sigma_m = 0;
|
double macro_sigma_m = 0;
|
||||||
for (int i = 0; i < numSubInteractions; i++) {
|
for (int i = 0; i < numSubInteractions; i++) {
|
||||||
|
//std::cout<< "macro_sigma_m = " << macro_sigma_m << "\n";
|
||||||
|
//std::cout<<"Subinteraction "<<SubInteractions[i]<<"\n";
|
||||||
macro_sigma_m += SubInteractions[i]->get_macro_sigma_m(interPart);
|
macro_sigma_m += SubInteractions[i]->get_macro_sigma_m(interPart);
|
||||||
|
//std::cout<< "macro_sigma aus get_macro_sigma in interaction_channel_base gibt im " << i << " Iterattionsschritt: " <<macro_sigma_m <<"\n";
|
||||||
}
|
}
|
||||||
return macro_sigma_m;
|
//std::cout << "wird das gemacht?"<<"\n"; ja wird es, hier kommt ein sigma raus immer auch wenn dichte 0 ???
|
||||||
|
|
||||||
|
return macro_sigma_m; // kommt dann raus bei particle looper, gut bzw. schlecht sollte 0 sein für dichte 0
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public:
|
|||||||
static double get_TCS(const double &E_eV) {
|
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 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));
|
double const2 = 0.133 * exp(-0.35*pow(E_eV-6.05,2));
|
||||||
|
//std::cout<<"E_eV = "<<E_eV<<"\n";
|
||||||
|
//std::cout<<"TCS = " <<17.3e-20 * (const1+const2)<<"\n";
|
||||||
return 17.3e-20 * (const1+const2);
|
return 17.3e-20 * (const1+const2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ typedef blitz::TinyVector<double,3> vec3;
|
|||||||
|
|
||||||
|
|
||||||
inline double calc_vec3_abs(const vec3 &vec) {
|
inline double calc_vec3_abs(const vec3 &vec) {
|
||||||
|
//std::cout << vec[0] <<"\n";
|
||||||
return sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
return sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +36,19 @@ inline double calc_v_ms_from_E_eV(const double &E_eV, const double &m_eV) {
|
|||||||
return sqrt(2*E_eV/m_eV) * c_ms;
|
return sqrt(2*E_eV/m_eV) * c_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double get_vx_from_vec3(const vec3 &vec){
|
||||||
|
|
||||||
|
double a = sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2));
|
||||||
|
//a = a / (sqrt(3));
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double calc_E_eV_from_v_ms_richtig(const vec3 &v_ms){
|
||||||
|
return get_vx_from_vec3(v_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline vec3 calc_n_new(const vec3 &direction_old, const double &theta_change, const double &phi_change) {
|
inline vec3 calc_n_new(const vec3 &direction_old, const double &theta_change, const double &phi_change) {
|
||||||
// Alireza Haghighat: Appendix 3 (p.249)
|
// Alireza Haghighat: Appendix 3 (p.249)
|
||||||
vec3 nOld = direction_old/calc_vec3_abs(direction_old);
|
vec3 nOld = direction_old/calc_vec3_abs(direction_old);
|
||||||
@@ -64,8 +78,12 @@ inline double calc_r_m(const vec3 &loc_m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline double calc_phi(const vec3 &loc_m) {
|
inline double calc_phi(const vec3 &loc_m) {
|
||||||
|
if (loc_m[1] == 0 and loc_m[0] == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (loc_m[1] >= 0) {
|
if (loc_m[1] >= 0) {
|
||||||
return acos(loc_m[0]/calc_r_m(loc_m));
|
return acos(loc_m[0]/calc_r_m(loc_m));
|
||||||
|
//return atan(loc_m[1]/loc_m[0]);
|
||||||
} else {
|
} else {
|
||||||
return 2*pi - acos(loc_m[0]/calc_r_m(loc_m));
|
return 2*pi - acos(loc_m[0]/calc_r_m(loc_m));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
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) {
|
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;
|
this->timer = timer;
|
||||||
m_eV = get_species_mass(this_species);
|
m_eV = get_species_mass(this_species);
|
||||||
|
//std::cout<< "Kinetic Population: " << this_species<<"\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void Kinetic_Population::increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
inline void Kinetic_Population::increase_density (const Particle &upPart, const vec3 &oldLoc_m) {
|
||||||
@@ -53,6 +54,7 @@ inline void Kinetic_Population::increase_density (const Particle &upPart, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
inline void Kinetic_Population::decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||||
|
//std::cout<<"Kinetic POP"<<"\n";
|
||||||
container.increase_offset(loc_m, E_eV);
|
container.increase_offset(loc_m, E_eV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,14 +76,27 @@ double Kinetic_Population::get_E_bin_mid_eV(const int &E_bin) {
|
|||||||
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
inline vec3 Kinetic_Population::roll_v_ms (const vec3 &loc_m) {
|
||||||
Bins loc_bins = get_loc_bin(loc_m);
|
Bins loc_bins = get_loc_bin(loc_m);
|
||||||
double target = 0;
|
double target = 0;
|
||||||
|
//std::cout << get_number_E_bins() <<"\n";
|
||||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||||
|
double E = get_E_bin_mid_eV(E_bin);
|
||||||
|
//std::cout<<"E_bin = "<< E_bin<<" E = "<<E<< " Dichte die dazu kommt " << get_density_m3(E_bin, loc_bins) << "\n";
|
||||||
target += get_density_m3(E_bin, loc_bins);
|
target += get_density_m3(E_bin, loc_bins);
|
||||||
}
|
}
|
||||||
target *= rngUni->random();
|
//std::cout << "Summe aller Dichten über alle bins: " << target<<"\n";
|
||||||
|
target *= rngUni->random(); //wenn 0 dann blöd
|
||||||
|
//target = 0;
|
||||||
|
//std::cout << "target mit random number:" << target<<"\n";
|
||||||
|
|
||||||
double current = 0;
|
double current = 0;
|
||||||
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
for (int E_bin = 0; E_bin<get_number_E_bins(); E_bin++) {
|
||||||
current += get_density_m3(E_bin, loc_bins);
|
current += get_density_m3(E_bin, loc_bins);
|
||||||
|
//std::cout <<"E_bin = "<< E_bin << " die dichte die vom bin dazu kommt " << current <<"\n";
|
||||||
|
|
||||||
if (current >= target) {
|
if (current >= target) {
|
||||||
|
//std::cout << "E_bin: " << E_bin <<"\n";
|
||||||
|
//std::cout<<"roll_v_ms output = "<<container.roll_E_eV_in_bin(E_bin, rngUni)<<"\n";
|
||||||
|
//double v = calc_v_ms_from_E_eV(container.roll_E_eV_in_bin(E_bin, rngUni), me_eV);
|
||||||
|
//std::cout << "v aus roll v_ms von e- pop: " << v<<"\n";
|
||||||
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
return container.roll_E_eV_in_bin(E_bin, rngUni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,26 @@ Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
|||||||
ParticleLogger.add(new SF_Particle_Logger(tritium2I, h5f));
|
ParticleLogger.add(new SF_Particle_Logger(tritium2I, h5f));
|
||||||
ParticleLogger.add(new SF_Particle_Logger(tritium3I, h5f));
|
ParticleLogger.add(new SF_Particle_Logger(tritium3I, h5f));
|
||||||
ParticleLogger.add(new SF_Particle_Logger(tritium5I, h5f));
|
ParticleLogger.add(new SF_Particle_Logger(tritium5I, h5f));
|
||||||
|
}
|
||||||
|
else if(numberZBins == -3){
|
||||||
|
|
||||||
|
double *zValues = new double[numberZBins];
|
||||||
|
double start_m = z_RW_m;
|
||||||
|
double mid_m = z_WGTS_mid_m;
|
||||||
|
double end_m = z_WGTS_end_m;
|
||||||
|
|
||||||
|
zValues[0] = start_m;
|
||||||
|
zValues[1] = mid_m;
|
||||||
|
zValues[2] = end_m;
|
||||||
|
|
||||||
|
ParticleLogger.add(new MultiZ_Particle_Logger(electron, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger.add(new MultiZ_Particle_Logger(tritiumI, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger.add(new MultiZ_Particle_Logger(tritium2I, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger.add(new MultiZ_Particle_Logger(tritium3I, h5f, numberZBins, zValues));
|
||||||
|
ParticleLogger.add(new MultiZ_Particle_Logger(tritium5I, h5f, numberZBins, zValues));
|
||||||
|
|
||||||
|
delete[] zValues;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
build_MultiZ(&ParticleLogger, h5f);
|
build_MultiZ(&ParticleLogger, h5f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,15 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
Simulation Sim;
|
Simulation Sim;
|
||||||
|
|
||||||
|
|
||||||
int start_time = MPI_Wtime();
|
int start_time = MPI_Wtime();
|
||||||
Sim.doit();
|
Sim.doit();
|
||||||
if (rank == 0) {
|
if (rank == 0) {
|
||||||
cout<<"Total Time: "<<MPI_Wtime()-start_time<<" s\n";
|
cout<<"Total Time: "<<MPI_Wtime()-start_time<<" s\n";
|
||||||
}
|
}
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
@@ -10,7 +10,13 @@ OBJS := particle_looper.o \
|
|||||||
population_builder.o \
|
population_builder.o \
|
||||||
mover_builder.o \
|
mover_builder.o \
|
||||||
interaction_builder.o BED_eT2_ionization.o uehara_eT2_elastic.o rutherford_elastic.o \
|
interaction_builder.o BED_eT2_ionization.o uehara_eT2_elastic.o rutherford_elastic.o \
|
||||||
terminator_builder.o
|
terminator_builder.o \
|
||||||
|
ElectricField.o \
|
||||||
|
Homogene.o \
|
||||||
|
Function3d.o \
|
||||||
|
RearwallPotential.o
|
||||||
|
|
||||||
|
OBJECTS_TEST := test_vec3_container.o
|
||||||
|
|
||||||
CXXFLAGS = $(X_OFLAGS) -I.. $(X_INC) -std=c++11
|
CXXFLAGS = $(X_OFLAGS) -I.. $(X_INC) -std=c++11
|
||||||
|
|
||||||
@@ -19,12 +25,16 @@ MPXFLAGS = $(X_OFLAGS) -I.. $(X_INC) $(X_HDF5P_INC) -std=c++11
|
|||||||
|
|
||||||
LDFLAGS = $(X_LIB) $(X_HDF5P_LIBS)
|
LDFLAGS = $(X_LIB) $(X_HDF5P_LIBS)
|
||||||
|
|
||||||
LOADLIBES = -lblitz -lm -lhdf5 -lhdf5_hl
|
LOADLIBES = -lblitz -lm -lhdf5 -lhdf5_hl -lgsl -lgslcblas -lm
|
||||||
|
|
||||||
|
|
||||||
TARGETS = mcelectron
|
TARGETS = mcelectron
|
||||||
|
TARGETS_TEST = mcelectron_test
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
testing: $(TARGETS_TEST)
|
||||||
|
clean:
|
||||||
|
rm *.o mcelectron mcelectron_serial mcelectron_test
|
||||||
|
|
||||||
mcelectron: main.o simulation.o $(OBJS)
|
mcelectron: main.o simulation.o $(OBJS)
|
||||||
$(MPICXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
$(MPICXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||||
@@ -32,9 +42,8 @@ mcelectron: main.o simulation.o $(OBJS)
|
|||||||
mcelectron_serial: main_serial.o simulation_serial.o $(OBJS)
|
mcelectron_serial: main_serial.o simulation_serial.o $(OBJS)
|
||||||
$(CXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
$(CXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||||
|
|
||||||
|
mcelectron_test: main_test.o $(OBJS) $(OBJECTS_TEST)
|
||||||
|
$(MPICXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||||
|
|
||||||
%.o : %.cpp
|
%.o : %.cpp
|
||||||
$(MPICXX) -c $< $(MPXFLAGS) -o $@ -g
|
$(MPICXX) -c $< $(MPXFLAGS) -o $@ -g
|
||||||
|
|
||||||
clean:
|
|
||||||
rm *.o mcelectron mcelectron_serial
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ double get_species_mass(const species &spec) {
|
|||||||
res = 3*mT_eV;
|
res = 3*mT_eV;
|
||||||
break;
|
break;
|
||||||
case tritium5I:
|
case tritium5I:
|
||||||
res = 3*mT_eV;
|
res = 5*mT_eV;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ void Particle_Looper::init_managers() {
|
|||||||
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
||||||
|
|
||||||
injector = Injector_Builder::build(&rngUni, &rngNormal, &populations);
|
injector = Injector_Builder::build(&rngUni, &rngNormal, &populations);
|
||||||
|
injector2 = Injector_Builder::build(&rngUni, &rngNormal, &populations);
|
||||||
movers = Mover_Builder::build(&part_loggers, &populations);
|
movers = Mover_Builder::build(&part_loggers, &populations);
|
||||||
interactions = Interaction_Builder::build(&populations, &rngUni);
|
interactions = Interaction_Builder::build(&populations, &rngUni);
|
||||||
terminators = Terminator_Builder::build();
|
terminators = Terminator_Builder::build();
|
||||||
@@ -31,6 +32,30 @@ void Particle_Looper::do_loops(int target_decays) {
|
|||||||
while ( (number_decays < target_decays) || (!particle_queue.empty()) ) {
|
while ( (number_decays < target_decays) || (!particle_queue.empty()) ) {
|
||||||
if (particle_queue.empty()) {
|
if (particle_queue.empty()) {
|
||||||
int num_new = injector.inject(&particle_queue, get_last_id());
|
int num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "sind wir hier? " <<"\n";
|
||||||
|
std::cout << "umschalter " << umschalter <<"\n";
|
||||||
|
int num_new;
|
||||||
|
if(umschalter == false){
|
||||||
|
|
||||||
|
std::cout << "umschalter " << umschalter << "\n";
|
||||||
|
injector.set_method(3);
|
||||||
|
injector.print_method();
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
umschalter = true;
|
||||||
|
std::cout << "wird umgeschaltet? " << umschalter << "\n";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
std::cout << "umschalter " << umschalter << "\n";
|
||||||
|
injector.set_method(4);
|
||||||
|
injector.print_method();
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
umschalter = false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
number_decays = number_decays + 1;
|
number_decays = number_decays + 1;
|
||||||
local_decays = local_decays + 1;
|
local_decays = local_decays + 1;
|
||||||
ID_counter = ID_counter + num_new;
|
ID_counter = ID_counter + num_new;
|
||||||
@@ -40,9 +65,64 @@ void Particle_Looper::do_loops(int target_decays) {
|
|||||||
pop_loggers.log();
|
pop_loggers.log();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Particle_Looper::do_loops(int target_decays, bool switcher) {
|
||||||
|
vector<Particle> particle_queue;
|
||||||
|
int number_decays = 0;
|
||||||
|
while ( (number_decays < target_decays) || (!particle_queue.empty()) ) {
|
||||||
|
if (particle_queue.empty()) {
|
||||||
|
int num_new;
|
||||||
|
if(switcher){
|
||||||
|
injector.set_method(3);
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
injector.set_method(4);
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "sind wir hier? " <<"\n";
|
||||||
|
std::cout << "umschalter " << umschalter <<"\n";
|
||||||
|
int num_new;
|
||||||
|
if(umschalter == false){
|
||||||
|
|
||||||
|
std::cout << "umschalter " << umschalter << "\n";
|
||||||
|
injector.set_method(3);
|
||||||
|
injector.print_method();
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
umschalter = true;
|
||||||
|
std::cout << "wird umgeschaltet? " << umschalter << "\n";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
std::cout << "umschalter " << umschalter << "\n";
|
||||||
|
injector.set_method(4);
|
||||||
|
injector.print_method();
|
||||||
|
num_new = injector.inject(&particle_queue, get_last_id());
|
||||||
|
umschalter = false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
number_decays = number_decays + 1;
|
||||||
|
local_decays = local_decays + 1;
|
||||||
|
ID_counter = ID_counter + num_new;
|
||||||
|
}
|
||||||
|
process_one(&particle_queue);
|
||||||
|
}
|
||||||
|
pop_loggers.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
||||||
int i = floor(rngUni.random()*particle_queue->size());
|
int i = floor(rngUni.random()*particle_queue->size());
|
||||||
|
//int i = particle_queue->size();
|
||||||
|
//i = 0;
|
||||||
|
//std::cout << i << "\n";
|
||||||
Particle curPart = particle_queue->at(i);
|
Particle curPart = particle_queue->at(i);
|
||||||
|
; std::cout<<"################################################"<<"\n";
|
||||||
|
std::cout<<"Current Particle: "<< curPart.get_species() <<"\n";
|
||||||
|
std::cout<<"current particle energy "<< curPart.get_E_eV()<<"\n";
|
||||||
//Particle curPart = particle_queue->front();
|
//Particle curPart = particle_queue->front();
|
||||||
Mover_Base *moverPtr = movers.find(curPart.get_species());
|
Mover_Base *moverPtr = movers.find(curPart.get_species());
|
||||||
Interaction_Channel_Base *interactionPtr = interactions.find(curPart.get_species());
|
Interaction_Channel_Base *interactionPtr = interactions.find(curPart.get_species());
|
||||||
@@ -53,12 +133,26 @@ void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
|||||||
vec3 oldLoc_m;
|
vec3 oldLoc_m;
|
||||||
while (!terminatorPtr->check_terminlization(curPart)) {
|
while (!terminatorPtr->check_terminlization(curPart)) {
|
||||||
oldLoc_m = curPart.get_x_m();
|
oldLoc_m = curPart.get_x_m();
|
||||||
|
std::cout << "Wo sind wir gerade? " << oldLoc_m << "\n";
|
||||||
|
//std::cout << "noch nichts passiert, richtig?"<< "\n";
|
||||||
macro_sigma_m = interactionPtr->get_macro_sigma_m(curPart);
|
macro_sigma_m = interactionPtr->get_macro_sigma_m(curPart);
|
||||||
|
//macro_sigma_m = macro_sigma_m * 1e21;
|
||||||
|
//std::cout<<"MacroSigma in particle_looper wird für move verwendet: "<< macro_sigma_m<<"\n";
|
||||||
|
|
||||||
|
//macro_sigma_m = 1; //nur test
|
||||||
|
//std::cout<<"Test macro_sigma auf 1 gesetzt -> also Interaktion "<<"\n";
|
||||||
|
std::cout << "Move: " << "\n";
|
||||||
moverPtr->move(&curPart, macro_sigma_m);
|
moverPtr->move(&curPart, macro_sigma_m);
|
||||||
|
|
||||||
|
std::cout << "Wo sind wir nach move? " << curPart.get_x_m() << "\n";
|
||||||
|
|
||||||
if (terminatorPtr->check_terminlization(curPart)) {
|
if (terminatorPtr->check_terminlization(curPart)) {
|
||||||
|
std::cout<<"Keine Interaktion."<<"\n";
|
||||||
|
|
||||||
break; // Don't double check terminlization, else n_double.
|
break; // Don't double check terminlization, else n_double.
|
||||||
} else {
|
} else {
|
||||||
|
std::cout<<"Interaktion: "<<"\n";
|
||||||
|
//curPart.set_x_m(oldLoc_m);
|
||||||
IntOut = interactionPtr->do_Interaction(&curPart);
|
IntOut = interactionPtr->do_Interaction(&curPart);
|
||||||
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
||||||
particle_queue->push_back(IntOut.get_new_particles()[i]);
|
particle_queue->push_back(IntOut.get_new_particles()[i]);
|
||||||
@@ -70,7 +164,7 @@ void Particle_Looper::process_one(std::vector<Particle> *particle_queue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particle_queue->erase(particle_queue->begin() + i);
|
particle_queue->erase(particle_queue->begin() + i );
|
||||||
}
|
}
|
||||||
|
|
||||||
long int Particle_Looper::get_new_id() {
|
long int Particle_Looper::get_new_id() {
|
||||||
@@ -91,6 +185,15 @@ void Particle_Looper::do_logging_off_loops(int target_decays) {
|
|||||||
ID_counter = prev_ID_counter;
|
ID_counter = prev_ID_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Particle_Looper::do_logging_off_loops(int taget_decays, bool switcher){
|
||||||
|
int prev_ID_counter = ID_counter;
|
||||||
|
set_logging(false);
|
||||||
|
do_loops(taget_decays, switcher);
|
||||||
|
set_logging(true);
|
||||||
|
ID_counter = prev_ID_counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Particle_Looper::set_logging(bool logging) {
|
void Particle_Looper::set_logging(bool logging) {
|
||||||
vector<species> all_species = get_all_species_vector();
|
vector<species> all_species = get_all_species_vector();
|
||||||
species current_species;
|
species current_species;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class Particle_Looper {
|
|||||||
Population_Manager populations;
|
Population_Manager populations;
|
||||||
|
|
||||||
Injector injector;
|
Injector injector;
|
||||||
|
Injector injector2;
|
||||||
Mover_Manager movers;
|
Mover_Manager movers;
|
||||||
Interaction_Manager interactions;
|
Interaction_Manager interactions;
|
||||||
Terminator_Manager terminators;
|
Terminator_Manager terminators;
|
||||||
@@ -66,6 +67,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void do_loops(int target_decays);
|
void do_loops(int target_decays);
|
||||||
|
void do_loops(int taget_decays, bool switcher);
|
||||||
private:
|
private:
|
||||||
void process_one(std::vector<Particle> *particle_queue);
|
void process_one(std::vector<Particle> *particle_queue);
|
||||||
long int get_new_id();
|
long int get_new_id();
|
||||||
@@ -73,6 +75,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void do_logging_off_loops(int target_decays);
|
void do_logging_off_loops(int target_decays);
|
||||||
|
void do_logging_off_loops(int target_decays, bool switcher);
|
||||||
private:
|
private:
|
||||||
void set_logging(bool logging);
|
void set_logging(bool logging);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
|||||||
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, POP_E_END));
|
Populations.add(new Kinetic_Population(electron, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START, POP_E_END));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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));
|
||||||
@@ -38,7 +40,18 @@ Population_Manager Population_Builder::build(Timer *timer,UniRNG *rngUni, Normal
|
|||||||
Populations.add(new Thermal_Population(tritium3I, new WGTS_Kinematics(3*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
Populations.add(new Thermal_Population(tritium3I, new WGTS_Kinematics(3*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
Populations.add(new Thermal_Population(tritium5I, new WGTS_Kinematics(5*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
Populations.add(new Thermal_Population(tritium5I, new WGTS_Kinematics(5*mT_eV, wgtsTemp_K, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
Populations.add(new T2_Population(new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), rngUni, rngNormal));
|
Populations.add(new T2_Population(new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), rngUni, rngNormal));
|
||||||
} else {
|
}
|
||||||
|
else 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, POP_E_END));
|
||||||
|
Populations.add(new Kinetic_Population(tritiumI, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START, POP_E_END));
|
||||||
|
Populations.add(new Kinetic_Population(tritium2I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START, POP_E_END));
|
||||||
|
Populations.add(new Kinetic_Population(tritium3I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START, POP_E_END));
|
||||||
|
Populations.add(new Kinetic_Population(tritium5I, timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins, num_E_bins, POP_E_START, POP_E_END));
|
||||||
|
Populations.add(new T2_Population(new WGTS_Kinematics(2*mT_eV, wgtsTemp_K, rngUni, rngNormal), rngUni, rngNormal));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
Populations.add(new Thermal_Population(tritium, new Lin_Kinematics(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(tritium, new Lin_Kinematics(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(tritiumI, new Lin_Kinematics(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(tritiumI, new Lin_Kinematics(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(tritium2I, new Lin_Kinematics(2*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(tritium2I, new Lin_Kinematics(2*mT_eV, wgtsTemp_K, v_flow, rngUni, rngNormal), timer, rngUni, rngNormal, num_z_bins, num_r_bins, num_phi_bins));
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ void Population_Container::increase_cum_time_s(const vec3 &loc1_m, const vec3 &l
|
|||||||
bin = calc_data_bin(bins_1, E_bin);
|
bin = calc_data_bin(bins_1, E_bin);
|
||||||
cum_times_s[bin] += cum_time_s;
|
cum_times_s[bin] += cum_time_s;
|
||||||
}
|
}
|
||||||
|
//double n_m3 = cum_time_s/time_s/V_m3 - offset/V_m3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +126,7 @@ void Population_Container::increase_offset(const vec3 &loc_m, const double &E_eV
|
|||||||
Bins loc_bins = calc_loc_bin(loc_m);
|
Bins loc_bins = calc_loc_bin(loc_m);
|
||||||
int bin = calc_data_bin(loc_bins, E_bin);
|
int bin = calc_data_bin(loc_bins, E_bin);
|
||||||
offsets[bin] += 1;
|
offsets[bin] += 1;
|
||||||
|
//std::cout<<"Offset[bin]= "<<offsets[bin]<<"["<<bin<<"]"<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s) {
|
double Population_Container::get_density_m3(const vec3 &loc_m, const double &E_eV, const double &time_s) {
|
||||||
@@ -137,11 +139,27 @@ double Population_Container::get_density_m3(const int &E_bin, const Bins &loc_bi
|
|||||||
int data_bin = calc_data_bin(loc_bins, E_bin);
|
int data_bin = calc_data_bin(loc_bins, E_bin);
|
||||||
double cum_time_s = cum_times_s[data_bin];
|
double cum_time_s = cum_times_s[data_bin];
|
||||||
int offset = offsets[data_bin];
|
int offset = offsets[data_bin];
|
||||||
|
//std::cout<< "Offset = " << offset<<"\n";
|
||||||
double V_m3 = size_data_m3[loc_bins.r];
|
double V_m3 = size_data_m3[loc_bins.r];
|
||||||
|
|
||||||
double n_m3 = cum_time_s/time_s/V_m3 - offset;
|
//std::cout<<"cum_time/time = "<<cum_time_s/time_s<<"\n";
|
||||||
|
//std::cout<<"offset = " <<offset<<"\n";
|
||||||
|
|
||||||
|
double n_m3 = cum_time_s/time_s/V_m3 - offset/V_m3;
|
||||||
|
//double n_m3 = cum_time_s/time_s/V_m3 ;
|
||||||
|
|
||||||
|
|
||||||
if (n_m3<0) {
|
if (n_m3<0) {
|
||||||
|
std::cout<<"Offset größer als n"<<"\n";
|
||||||
n_m3 = 0;
|
n_m3 = 0;
|
||||||
|
cum_times_s[data_bin] = 0;
|
||||||
|
offsets[data_bin] = 0;
|
||||||
|
//std::cout << "cumtime in data bin " << cum_times_s[data_bin] << "\n";
|
||||||
|
//std::cout << "cumtime in data bin+1 " << cum_times_s[data_bin+1] << "\n";
|
||||||
|
//std::cout << "offset in data bin " << offsets[data_bin] << "\n";
|
||||||
|
//std::cout << "offset in data bin+1 " << offsets[data_bin+1] << "\n";
|
||||||
|
//cumtime = 0
|
||||||
|
//offset = 0
|
||||||
}
|
}
|
||||||
return n_m3;
|
return n_m3;
|
||||||
}
|
}
|
||||||
@@ -164,8 +182,12 @@ double Population_Container::get_E_bin_mid_eV(const int &E_bin) {
|
|||||||
|
|
||||||
double Population_Container::roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni) {
|
double Population_Container::roll_E_eV_in_bin(const int &E_bin, UniRNG *rngUni) {
|
||||||
double low = E_scale.get_lower_bin_bound(E_bin);
|
double low = E_scale.get_lower_bin_bound(E_bin);
|
||||||
|
//std::cout << "low " << low<<"\n";
|
||||||
double up = E_scale.get_upper_bin_bound(E_bin);
|
double up = E_scale.get_upper_bin_bound(E_bin);
|
||||||
return low + rngUni->random()*(up-low);
|
//std::cout << "up " << up<<"\n";
|
||||||
|
double a = low + rngUni->random()*(up-low);
|
||||||
|
//std::cout << a <<"\n";
|
||||||
|
return low + rngUni->random()*(up-low);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Population_Container::calc_data_bin(const Bins &loc_bin, const double &E_bin) {
|
int Population_Container::calc_data_bin(const Bins &loc_bin, const double &E_bin) {
|
||||||
|
|||||||
@@ -95,9 +95,15 @@ inline void Population_Logger::create_h5tb() {
|
|||||||
inline void Population_Logger::log() {
|
inline void Population_Logger::log() {
|
||||||
pop_bin temp_bin;
|
pop_bin temp_bin;
|
||||||
temp_bin.phys_time_s = timer->get_time_s();
|
temp_bin.phys_time_s = timer->get_time_s();
|
||||||
|
|
||||||
|
//std::cout << "logging time " << timer->get_time_s() << "\n";
|
||||||
int bin;
|
int bin;
|
||||||
for (int i_z=0; i_z < container->scales.z.get_number_bins(); i_z++) {
|
for (int i_z=0; i_z < container->scales.z.get_number_bins(); i_z++) {
|
||||||
temp_bin.z_bin = i_z;
|
temp_bin.z_bin = i_z;
|
||||||
|
|
||||||
|
//temp_bin.tracking += 1;
|
||||||
|
//std::cout << "tracking " << temp_bin.tracking << "\n";
|
||||||
|
|
||||||
for (int i_r=0; i_r < container->scales.r.get_number_bins(); i_r++) {
|
for (int i_r=0; i_r < container->scales.r.get_number_bins(); i_r++) {
|
||||||
temp_bin.r_bin = i_r;
|
temp_bin.r_bin = i_r;
|
||||||
for (int i_phi=0; i_phi < container->scales.phi.get_number_bins(); i_phi++) {
|
for (int i_phi=0; i_phi < container->scales.phi.get_number_bins(); i_phi++) {
|
||||||
@@ -107,6 +113,11 @@ inline void Population_Logger::log() {
|
|||||||
bin = container->calc_data_bin(Bins{i_z, i_r, i_phi}, i_E);
|
bin = container->calc_data_bin(Bins{i_z, i_r, i_phi}, i_E);
|
||||||
temp_bin.cumulated_time_s = container->cum_times_s[bin];
|
temp_bin.cumulated_time_s = container->cum_times_s[bin];
|
||||||
temp_bin.offset = container->offsets[bin];
|
temp_bin.offset = container->offsets[bin];
|
||||||
|
temp_bin.n_m3 = container->get_density_m3(i_E, bin, temp_bin.phys_time_s);
|
||||||
|
//std::cout << temp_bin.n_m3 << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
h5tb.write(temp_bin);
|
h5tb.write(temp_bin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,7 @@ void Simulation::deconstruct_pop_arrays() { // Deallocate memory properly
|
|||||||
|
|
||||||
|
|
||||||
void Simulation::doit() { // 2 Phase: 1. calc average densities, 2. actual simulate
|
void Simulation::doit() { // 2 Phase: 1. calc average densities, 2. actual simulate
|
||||||
do_cycle(popCalcDecays, popCalcStep, false);
|
//do_cycle(popCalcDecays, popCalcStep, false);
|
||||||
if (mpi_rank == 0) {
|
if (mpi_rank == 0) {
|
||||||
cout<<"Population calculation done.\n";
|
cout<<"Population calculation done.\n";
|
||||||
}
|
}
|
||||||
@@ -168,8 +168,18 @@ void Simulation::do_cycle(long int number_total, long int step_size, bool loggin
|
|||||||
if (mpi_rank < overflow) { // Split overflows equaly to left over CPUs.
|
if (mpi_rank < overflow) { // Split overflows equaly to left over CPUs.
|
||||||
num_remaining += 1;
|
num_remaining += 1;
|
||||||
}
|
}
|
||||||
|
switcher = true;
|
||||||
for (int i = 0; i<(num_cycles-1); i++) {
|
for (int i = 0; i<(num_cycles-1); i++) {
|
||||||
|
std::cout << "sind wir hier?" <<"\n";
|
||||||
|
|
||||||
do_decays(step_size, logging);
|
do_decays(step_size, logging);
|
||||||
|
if(switcher == true){
|
||||||
|
switcher = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
switcher = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (num_cycles == 0) { // Rather unrealistic case.. maybe find a more elegant solution later.
|
if (num_cycles == 0) { // Rather unrealistic case.. maybe find a more elegant solution later.
|
||||||
do_decays(num_remaining, logging);
|
do_decays(num_remaining, logging);
|
||||||
@@ -182,8 +192,10 @@ void Simulation::do_cycle(long int number_total, long int step_size, bool loggin
|
|||||||
void Simulation::do_decays(const long int &number_decays, const bool &logging) {
|
void Simulation::do_decays(const long int &number_decays, const bool &logging) {
|
||||||
if (logging) {
|
if (logging) {
|
||||||
looper.do_loops(number_decays);
|
looper.do_loops(number_decays);
|
||||||
|
//looper.do_loops(number_decays, switcher);
|
||||||
} else {
|
} else {
|
||||||
looper.do_logging_off_loops(number_decays);
|
looper.do_logging_off_loops(number_decays);
|
||||||
|
//looper.do_logging_off_loops(number_decays, switcher);
|
||||||
}
|
}
|
||||||
number_local_decays += number_decays;
|
number_local_decays += number_decays;
|
||||||
sync_cpus();
|
sync_cpus();
|
||||||
@@ -246,12 +258,12 @@ void Simulation::print_term_stats() {
|
|||||||
Terminator_Manager *terminators = looper.get_terminators();
|
Terminator_Manager *terminators = looper.get_terminators();
|
||||||
vector<species> all_species = get_all_species_vector();
|
vector<species> all_species = get_all_species_vector();
|
||||||
Termination_Stats local_stats, global_stats;
|
Termination_Stats local_stats, global_stats;
|
||||||
int local_array[7], global_array[7];
|
int local_array[8], global_array[8];
|
||||||
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
for (vector<species>::iterator itr = all_species.begin(); itr!= all_species.end(); itr++) {
|
||||||
if (terminators->exists(*itr)) {
|
if (terminators->exists(*itr)) {
|
||||||
local_stats = terminators->find(*itr)->get_stats();
|
local_stats = terminators->find(*itr)->get_stats();
|
||||||
local_stats.to_array(local_array);
|
local_stats.to_array(local_array);
|
||||||
MPI_Allreduce(local_array, global_array, 7, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
MPI_Allreduce(local_array, global_array, 8, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
||||||
global_stats.from_array(global_array);
|
global_stats.from_array(global_array);
|
||||||
if (mpi_rank == 0) {
|
if (mpi_rank == 0) {
|
||||||
std::cout<<"# "<<*itr<<"\n";
|
std::cout<<"# "<<*itr<<"\n";
|
||||||
@@ -262,6 +274,7 @@ void Simulation::print_term_stats() {
|
|||||||
std::cout<<"n_max\t"<<global_stats.n_max<<"\n";
|
std::cout<<"n_max\t"<<global_stats.n_max<<"\n";
|
||||||
std::cout<<"n_energy\t"<<global_stats.n_energy<<"\n";
|
std::cout<<"n_energy\t"<<global_stats.n_energy<<"\n";
|
||||||
std::cout<<"n_reaction\t"<<global_stats.n_reaction<<"\n";
|
std::cout<<"n_reaction\t"<<global_stats.n_reaction<<"\n";
|
||||||
|
std::cout<<"n_offset\t"<<global_stats.n_offset<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class Simulation {
|
|||||||
static const long int popCalcDecays;
|
static const long int popCalcDecays;
|
||||||
static const long int popCalcStep;
|
static const long int popCalcStep;
|
||||||
|
|
||||||
|
bool switcher;
|
||||||
|
|
||||||
long int numberTotalParticles = 0;
|
long int numberTotalParticles = 0;
|
||||||
long int number_local_decays = 0;
|
long int number_local_decays = 0;
|
||||||
long int number_global_decays = 0;
|
long int number_global_decays = 0;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct Termination_Stats {
|
|||||||
int n_max = 0;
|
int n_max = 0;
|
||||||
int n_energy = 0;
|
int n_energy = 0;
|
||||||
int n_reaction = 0;
|
int n_reaction = 0;
|
||||||
|
int n_offset = 0;
|
||||||
|
|
||||||
void reset () {
|
void reset () {
|
||||||
n_total = 0;
|
n_total = 0;
|
||||||
@@ -29,6 +30,7 @@ struct Termination_Stats {
|
|||||||
n_max = 0;
|
n_max = 0;
|
||||||
n_energy = 0;
|
n_energy = 0;
|
||||||
n_reaction = 0;
|
n_reaction = 0;
|
||||||
|
n_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void to_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
void to_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
||||||
@@ -39,6 +41,7 @@ struct Termination_Stats {
|
|||||||
array [4] = n_max;
|
array [4] = n_max;
|
||||||
array [5] = n_energy;
|
array [5] = n_energy;
|
||||||
array [6] = n_reaction;
|
array [6] = n_reaction;
|
||||||
|
array [7] = n_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
void from_array(int *array) { // Ugly workarounds maybe move to casting with reinterpret cast
|
||||||
@@ -49,6 +52,7 @@ struct Termination_Stats {
|
|||||||
n_max = array [4];
|
n_max = array [4];
|
||||||
n_energy = array [5];
|
n_energy = array [5];
|
||||||
n_reaction = array [6];
|
n_reaction = array [6];
|
||||||
|
n_offset = array [7];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "ElectricField.h"
|
||||||
|
|
||||||
|
SCENARIO("Test the ElectricField class", "[ElectricField]") {
|
||||||
|
GIVEN("An electric field") {
|
||||||
|
ElectricField electric_field;
|
||||||
|
WHEN("A value is ordered") {
|
||||||
|
THEN("Jonas value is returned") {
|
||||||
|
REQUIRE(electric_field.getValue()[0] == 0);
|
||||||
|
REQUIRE(electric_field.getValue()[1] == 0);
|
||||||
|
REQUIRE(electric_field.getValue()[2] == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+72
@@ -0,0 +1,72 @@
|
|||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "blitz/array.h"
|
||||||
|
//#include "function3d/Homogene.h"
|
||||||
|
//#include "function3d/PolynomialCylinder.h"
|
||||||
|
//#include "function3d/Zeros.h"
|
||||||
|
#include "RearwallPotential.h"
|
||||||
|
|
||||||
|
#include <memory> // unique_ptr
|
||||||
|
#include <fstream> // output file
|
||||||
|
|
||||||
|
SCENARIO("Test Function3d class", "[Function3d]") {
|
||||||
|
|
||||||
|
|
||||||
|
GIVEN("A RearWall Function3d") {
|
||||||
|
double dx = 0.10984755318623787;
|
||||||
|
double radius = 4.5;
|
||||||
|
double height = dx*3060;
|
||||||
|
|
||||||
|
double rearwall_potential = 10.0;
|
||||||
|
blitz::TinyVector<double, 3> center(4.5, 4.5, 0.0);
|
||||||
|
double minimal_z_for_bessel_calculation = dx*1;
|
||||||
|
int max_bessel_zero_order = 1000;
|
||||||
|
double precision = 1E-15;
|
||||||
|
bool potential_in_si = true;
|
||||||
|
|
||||||
|
RearwallPotential rearwall(radius, height, rearwall_potential, center,
|
||||||
|
minimal_z_for_bessel_calculation,
|
||||||
|
max_bessel_zero_order, precision,
|
||||||
|
potential_in_si);
|
||||||
|
|
||||||
|
std::cout << rearwall << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
WHEN("A value in x,y,z direction is ordered"){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
THEN("The correct value is returned and saved to file. Look at that file.") {
|
||||||
|
double increment = dx;
|
||||||
|
|
||||||
|
std::ofstream output_file_potential;
|
||||||
|
output_file_potential.open("rearwall_potential_output.dat");
|
||||||
|
output_file_potential << "#r z potential\n";
|
||||||
|
|
||||||
|
for(double r = 0.0; r <= radius; r+=increment ){
|
||||||
|
for(double z = 0.0; z <= height; z+=increment){
|
||||||
|
output_file_potential << r << "," << z << ",";
|
||||||
|
output_file_potential << rearwall.getPotential(r, z) << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output_file_potential.close();
|
||||||
|
|
||||||
|
std::ofstream output_file_field;
|
||||||
|
output_file_field.open("rearwall_field_output.dat");
|
||||||
|
output_file_field << "#r z Er Ephi Ez\n";
|
||||||
|
|
||||||
|
for(double r = 0.0; r <= radius; r+=increment ){
|
||||||
|
for(double z = 0.0; z <= height; z+=increment){
|
||||||
|
output_file_field << r << "," << z << ",";
|
||||||
|
output_file_field << rearwall.getElectricField(r, z, 0) << ",";
|
||||||
|
output_file_field << rearwall.getElectricField(r, z, 1) << ",";
|
||||||
|
output_file_field << rearwall.getElectricField(r, z, 2) << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output_file_field.close();
|
||||||
|
REQUIRE(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "Homogene.h"
|
||||||
|
|
||||||
|
SCENARIO("Test the Homogene class", "[Homogene]") {
|
||||||
|
GIVEN("A homogene electric field mit 5 V/m in z Richtung") {
|
||||||
|
Homogene electric_field(vec3(5,0,0));
|
||||||
|
//vec3 value(5,0,0);
|
||||||
|
//vec3 value = blitz::TinyVector<double, 3>(5,0,0)
|
||||||
|
vec3 loc = (5,5,5);
|
||||||
|
WHEN("A value is ordered") {
|
||||||
|
THEN("Jonas value is returned") {
|
||||||
|
REQUIRE(electric_field.getValue(loc)[0] == 5);
|
||||||
|
REQUIRE(electric_field.getValue(loc)[1] == 0);
|
||||||
|
REQUIRE(electric_field.getValue(loc)[2] == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//WHEN("The value is changed and ordered"){
|
||||||
|
// electric_field.setValue(vec3(2,2,2));
|
||||||
|
// THEN("Changed Value is returned"){
|
||||||
|
// REQUIRE(electric_field.getValue()[0] == 2);
|
||||||
|
// REQUIRE(electric_field.getValue()[1] == 2);
|
||||||
|
// REQUIRE(electric_field.getValue()[2] == 2);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "vec3_container.hpp"
|
||||||
|
#include "Homogene.h"
|
||||||
|
#include "RearwallPotential.h"
|
||||||
|
#include "constants.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
SCENARIO("Test the vec3_container Constructor with Electric Field class", "[vec3_container]") {
|
||||||
|
GIVEN("Vec3 Container initilazed with a homogene electric field") {
|
||||||
|
ElectricField electric_field(load_parameter("electric_field"));
|
||||||
|
|
||||||
|
electric_field.print();
|
||||||
|
|
||||||
|
Vec3_Container efeld(1000, 50, 20, electric_field);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
THEN("The correct value is returned and saved to file. Look at that file.") {
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRE(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,12 +23,19 @@ public:
|
|||||||
Thermal_Population(species this_species, Base_Kinematics *kinematics, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, 1) {
|
Thermal_Population(species this_species, Base_Kinematics *kinematics, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species), RNG_Base(rngUni, rngNormal), container(num_z_bins, num_r_bins, num_phi_bins, 1) {
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
this->kinematics = kinematics;
|
this->kinematics = kinematics;
|
||||||
|
std::cout<<"Thermal Population: "<< this_species <<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void 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 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 decrease_denisty (const vec3 &loc_m, const double &E_eV) {container.increase_offset(loc_m, E_eV);}
|
void decrease_denisty (const vec3 &loc_m, const double &E_eV) {
|
||||||
|
container.increase_offset(loc_m, E_eV);
|
||||||
|
|
||||||
double get_density_m3(const vec3 &loc_m) {return container.get_density_m3(loc_m, 0, timer->get_time_s());}
|
}
|
||||||
|
|
||||||
|
double get_density_m3(const vec3 &loc_m) {
|
||||||
|
//std::cout << "get denistiy in thermal pop wird benutzt?"<< "\n"; //ja wird benutzt
|
||||||
|
//std::cout << "dichte von der thermal pop: "<<container.get_density_m3(loc_m, 0, timer->get_time_s())<<"\n";
|
||||||
|
return container.get_density_m3(loc_m, 0, timer->get_time_s());}
|
||||||
|
|
||||||
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
double get_density_m3(const int &E_bin, const Bins &loc_bins) {throw MyException("Should not be called.\n.");}
|
||||||
int get_number_E_bins() {return 1;}
|
int get_number_E_bins() {return 1;}
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ void Timer::set_T2_activity_s() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double Timer::get_time_s() {
|
double Timer::get_time_s() {
|
||||||
|
//std::cout << "T2 aktivity " << T2_activity_s << "\n";
|
||||||
|
//std::cout << "off set_time " << offset_time_s << "\n";
|
||||||
|
//std::cout << "calc total decays " << calc_total_decays() << "\n";
|
||||||
|
//std::cout << "get_time " << double(calc_total_decays())/T2_activity_s + offset_time_s << "\n";
|
||||||
return double(calc_total_decays())/T2_activity_s + offset_time_s;
|
return double(calc_total_decays())/T2_activity_s + offset_time_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,55 @@ Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins,
|
|||||||
load_data(load_path);
|
load_data(load_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, ElectricField &E){
|
||||||
|
z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins);
|
||||||
|
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
||||||
|
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
||||||
|
int num_tot_bins = num_z_bins * num_r_bins * num_phi_bins;
|
||||||
|
data = new vec3[num_tot_bins];
|
||||||
|
dataloc = new vec3[num_tot_bins];
|
||||||
|
std::ofstream output_file_field;
|
||||||
|
output_file_field.open("../rearwall_electricfield_test.dat");
|
||||||
|
output_file_field << "#r phi z Er Ephi Ez\n";
|
||||||
|
for(int i = 0; i < num_z_bins; i++){
|
||||||
|
for (int j = 0; j < num_r_bins; j++){
|
||||||
|
for (int k = 0; k < num_phi_bins; k++){
|
||||||
|
double z = z_scale.get_bin_mid(i);
|
||||||
|
double r = r_scale.get_bin_mid(j);
|
||||||
|
double phi = phi_scale.get_bin_mid(k);
|
||||||
|
|
||||||
|
//double x = r*cos(phi);
|
||||||
|
//double y = r*sin(phi);
|
||||||
|
//std::cout << x << ", " << y << ", " << z << std::endl;
|
||||||
|
//while(l < num_tot_bins){
|
||||||
|
// std::cout << l << std::endl;
|
||||||
|
// data[l] = E.getValue(z, r, phi);
|
||||||
|
// l++;
|
||||||
|
//}
|
||||||
|
//std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << std::endl;
|
||||||
|
data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = E.getValue(z, r, phi);
|
||||||
|
//data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = E.getPotential(r, z);
|
||||||
|
//dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = E.getLoc(z, r, phi);
|
||||||
|
dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = vec3(z, r, phi);
|
||||||
|
//std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << " " << dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << " " << data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << std::endl;
|
||||||
|
//std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << " " << dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << " " << E.getPotential(r,z) << std::endl;
|
||||||
|
|
||||||
|
output_file_field << r << "," << phi << "," << z << ",";
|
||||||
|
output_file_field << E.getValue(z, r, phi)[0] << ",";
|
||||||
|
output_file_field << E.getValue(z, r, phi)[1] << ",";
|
||||||
|
output_file_field << E.getValue(z, r, phi)[2] << "\n";
|
||||||
|
//output_file_field << E.getPotential(r, z) << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output_file_field.close();
|
||||||
|
//int l = calc_data_bin(vec3(0, 0, 5));
|
||||||
|
//std::cout << "bin " << l << " ort " << dataloc[l] <<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
Vec3_Container::~Vec3_Container() {
|
Vec3_Container::~Vec3_Container() {
|
||||||
delete[] data;
|
delete[] data;
|
||||||
}
|
}
|
||||||
@@ -99,9 +148,15 @@ int Vec3_Container::calc_data_bin(const vec3 &loc_m) {
|
|||||||
double z_m = calc_z_m(loc_m);
|
double z_m = calc_z_m(loc_m);
|
||||||
double r_m = calc_r_m(loc_m);
|
double r_m = calc_r_m(loc_m);
|
||||||
double phi = calc_phi(loc_m);
|
double phi = calc_phi(loc_m);
|
||||||
|
//double phi = 0;
|
||||||
int z_bin = z_scale.calc_index(z_m);
|
int z_bin = z_scale.calc_index(z_m);
|
||||||
int r_bin = r_scale.calc_index(r_m);
|
int r_bin = r_scale.calc_index(r_m);
|
||||||
int phi_bin = phi_scale.calc_index(phi);
|
int phi_bin = phi_scale.calc_index(phi);
|
||||||
|
//std::cout << "z " << z_m << std::endl;
|
||||||
|
//std::cout << "r " << r_m << std::endl;
|
||||||
|
//std::cout << "phi "<< phi << std::endl;
|
||||||
|
//std::cout << "zbin " << z_bin << std::endl;
|
||||||
|
//std::cout << "rbin " << r_bin << std::endl;
|
||||||
|
//std::cout << "phi_bin " << phi_bin << std::endl;
|
||||||
return z_bin * r_scale.get_number_bins() * phi_scale.get_number_bins() + r_bin * phi_scale.get_number_bins() + phi_bin;
|
return z_bin * r_scale.get_number_bins() * phi_scale.get_number_bins() + r_bin * phi_scale.get_number_bins() + phi_bin;
|
||||||
};
|
};
|
||||||
@@ -12,14 +12,18 @@
|
|||||||
#include "lin_scale.h"
|
#include "lin_scale.h"
|
||||||
#include "kinematics.h"
|
#include "kinematics.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
#include "ElectricField.h"
|
||||||
|
#include "Homogene.h"
|
||||||
|
#include "RearwallPotential.h"
|
||||||
|
|
||||||
class Vec3_Container {
|
class Vec3_Container {
|
||||||
vec3 *data;
|
vec3 *data;
|
||||||
|
vec3 *dataloc;
|
||||||
Lin_Scale z_scale, r_scale, phi_scale;
|
Lin_Scale z_scale, r_scale, phi_scale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, std::string load_path);
|
Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, std::string load_path);
|
||||||
|
Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, ElectricField &E);
|
||||||
~Vec3_Container();
|
~Vec3_Container();
|
||||||
Vec3_Container(const Vec3_Container& other);
|
Vec3_Container(const Vec3_Container& other);
|
||||||
Vec3_Container& operator=(const Vec3_Container& other);
|
Vec3_Container& operator=(const Vec3_Container& other);
|
||||||
|
|||||||
@@ -0,0 +1,296 @@
|
|||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import scipy.optimize as optimization
|
||||||
|
import glob
|
||||||
|
import h5py
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
#from decimal import Decimal
|
||||||
|
|
||||||
|
# get a list of h5 files in a directory
|
||||||
|
def get_h5list(directory, extension='h5'):
|
||||||
|
liste = []
|
||||||
|
for f in os.listdir(directory):
|
||||||
|
if f.endswith('.' + extension):
|
||||||
|
liste.append(directory + '/' + f)
|
||||||
|
return liste
|
||||||
|
|
||||||
|
def get_csv_part_e(inputpath, sim_time, num_E=100, num_r=1, Erange=[1e-5,2e4]):
|
||||||
|
|
||||||
|
#set outputpath
|
||||||
|
outputpath = inputpath + '/csv'
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir(outputpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
num_E = num_E
|
||||||
|
num_r = num_r
|
||||||
|
Erange=[1e-5,2e4]
|
||||||
|
|
||||||
|
h5list = get_h5list(inputpath)
|
||||||
|
|
||||||
|
# def some constants
|
||||||
|
me_eV = 511e3
|
||||||
|
c_ms = 3e8
|
||||||
|
rrange = [0, 0.045]
|
||||||
|
|
||||||
|
# calc bin properties
|
||||||
|
Ebins = pow(10, np.linspace(np.log10(Erange[0]), np.log10(Erange[1]), (num_E+1)))
|
||||||
|
Emids = (Ebins[1:] + Ebins[:-1]/2)
|
||||||
|
Emids = pow(10, (np.log10(Ebins[1:]) + np.log10(Ebins[:-1]))/2)
|
||||||
|
rbins = np.linspace(0, 0.045, (num_r+1))
|
||||||
|
rmids = (rbins[1:] + rbins[:-1])/2
|
||||||
|
As = np.pi*rbins[1:]**2 - np.pi*rbins[:-1]**2
|
||||||
|
|
||||||
|
# open the first h5 file to get keys
|
||||||
|
f = h5py.File(h5list[0], 'r')
|
||||||
|
g = f['Particles']['e-']
|
||||||
|
zs = list(g.keys())
|
||||||
|
f.close()
|
||||||
|
df = pd.DataFrame() # this will be our csv file
|
||||||
|
|
||||||
|
zeros = np.zeros(num_E)
|
||||||
|
|
||||||
|
for z in zs:
|
||||||
|
print(z)
|
||||||
|
# this is how our csv dataframe will look like:
|
||||||
|
a = pd.DataFrame({
|
||||||
|
'z' : float(z),
|
||||||
|
'Emin' : zeros,
|
||||||
|
'Emax' : 0,
|
||||||
|
'Emid' : 0,
|
||||||
|
'rmin' : 0,
|
||||||
|
'rmax' : 0,
|
||||||
|
'rmid' : 0,
|
||||||
|
'N' : 0,
|
||||||
|
'dndE' : 0,
|
||||||
|
'djzabsdE' : 0,
|
||||||
|
'djzdE' : 0,
|
||||||
|
'N+' : 0,
|
||||||
|
'N-' : 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
for h5 in h5list[:]:
|
||||||
|
#print(h5)
|
||||||
|
f = h5py.File(h5, 'r')
|
||||||
|
g = f['Particles']['e-']
|
||||||
|
df_z = pd.DataFrame(g[z][:])
|
||||||
|
|
||||||
|
# calc properties and calculate categories
|
||||||
|
df_z['E_eV'] = 0.5*me_eV*(df_z.vx_ms**2 + df_z.vy_ms**2 + df_z.vz_ms**2)/c_ms**2
|
||||||
|
df_z['r_m'] = np.sqrt(df_z['x_m']**2 + df_z['y_m']**2)
|
||||||
|
df_z['inv_v_z'] = 1/df_z['vz_ms'].abs()
|
||||||
|
df_z['v_sign'] = np.sign(df_z['vz_ms'])
|
||||||
|
df_z['v_sign_+'] = df_z['v_sign'].apply(lambda x: 1 if x > 0 else 0)
|
||||||
|
df_z['v_sign_-'] = df_z['v_sign'].apply(lambda x: 1 if x < 0 else 0)
|
||||||
|
df_z['E_cut'] = pd.cut(df_z['E_eV'], bins=Ebins, labels = False)
|
||||||
|
df_z['r_cut'] = pd.cut(df_z['r_m'], bins=rbins, labels = False, include_lowest = True)
|
||||||
|
|
||||||
|
# apply categories and fill empty with 0
|
||||||
|
t = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['inv_v_z'].agg([('N','size'), ('inv_v_sum','sum')])
|
||||||
|
t['v_sign'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign'].sum()
|
||||||
|
t['N+'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign_+'].sum()
|
||||||
|
t['N-'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign_-'].sum()
|
||||||
|
t = t.reindex( pd.MultiIndex.from_product([np.arange(num_E),
|
||||||
|
np.arange(num_r)], names=['E_bin', 'r_bin']) ,fill_value=0)
|
||||||
|
t = t.reset_index()
|
||||||
|
t['z'] = float(z)
|
||||||
|
|
||||||
|
# transform to df form
|
||||||
|
a['Emin'] = Ebins[t['E_bin']]
|
||||||
|
a['Emax'] = Ebins[t['E_bin']+1]
|
||||||
|
a['Emid'] = Emids[t['E_bin']]
|
||||||
|
a['rmin'] = rbins[t['r_bin']]
|
||||||
|
a['rmax'] = rbins[t['r_bin']+1]
|
||||||
|
a['rmid'] = rmids[t['r_bin']]
|
||||||
|
a['N'] += t['N']
|
||||||
|
a['dndE'] += t['inv_v_sum']/As[t['r_bin']]/sim_time
|
||||||
|
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
||||||
|
a['djzabsdE'] += t['N']/As[t['r_bin']]/sim_time
|
||||||
|
a['djzdE'] += t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
|
a['N+'] += t['N+']
|
||||||
|
a['N-'] += t['N-']
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
#append to final df
|
||||||
|
df = df.append(a)
|
||||||
|
|
||||||
|
df.to_csv(inputpath + "/csv/df_part_e.csv")
|
||||||
|
print("csv saved to " + inputpath + "/csv/df_part_e.csv")
|
||||||
|
|
||||||
|
def get_csv_part_all(inputpath, sim_time, num_r=1):
|
||||||
|
|
||||||
|
outputpath = inputpath + '/csv'
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir(outputpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# def some constants
|
||||||
|
c_ms = 3e8
|
||||||
|
rrange = [0, 0.045]
|
||||||
|
|
||||||
|
# calc bin properties
|
||||||
|
rbins = np.linspace(0, 0.045, (num_r+1))
|
||||||
|
rmids = (rbins[1:] + rbins[:-1])/2
|
||||||
|
As = np.pi*rbins[1:]**2 - np.pi*rbins[:-1]**2
|
||||||
|
|
||||||
|
h5list = get_h5list(inputpath)
|
||||||
|
|
||||||
|
# open one h5 file to get keys
|
||||||
|
f = h5py.File(h5list[0], 'r')
|
||||||
|
g = f['Particles']['e-']
|
||||||
|
|
||||||
|
species = list(f['Particles'].keys())
|
||||||
|
zs = list(g.keys())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
zeros = np.zeros(num_r)
|
||||||
|
|
||||||
|
df = pd.DataFrame()
|
||||||
|
for s in species:
|
||||||
|
print (s)
|
||||||
|
|
||||||
|
for z in zs:
|
||||||
|
# calc properties and calculate categories
|
||||||
|
#print(z)
|
||||||
|
a = pd.DataFrame({
|
||||||
|
'species' : s,
|
||||||
|
'z' : float(z),
|
||||||
|
'rmin' : zeros,
|
||||||
|
'rmax' : 0,
|
||||||
|
'rmid' : 0,
|
||||||
|
'N' : 0,
|
||||||
|
'N+' : 0,
|
||||||
|
'N-' : 0,
|
||||||
|
'n' : 0,
|
||||||
|
'jzabs' : 0,
|
||||||
|
'jz' : 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
for h5 in h5list[:]:
|
||||||
|
#print(h5)
|
||||||
|
f = h5py.File(h5, 'r')
|
||||||
|
g = f['Particles'][s]
|
||||||
|
df_z = pd.DataFrame(g[z][:])
|
||||||
|
|
||||||
|
# calc properties and calc categories
|
||||||
|
df_z['r_m'] = np.sqrt(df_z['x_m']**2 + df_z['y_m']**2)
|
||||||
|
df_z['inv_v_z'] = 1/df_z['vz_ms'].abs()
|
||||||
|
df_z['v_sign'] = np.sign(df_z['vz_ms'])
|
||||||
|
df_z['v_sign_+'] = df_z['v_sign'].apply(lambda x: 1 if x > 0 else 0)
|
||||||
|
df_z['v_sign_-'] = df_z['v_sign'].apply(lambda x: 1 if x < 0 else 0)
|
||||||
|
df_z['r_cut'] = pd.cut(df_z['r_m'], bins=rbins, labels = False, include_lowest = True)
|
||||||
|
|
||||||
|
# apply categories and fill empty with 0
|
||||||
|
t = df_z.groupby(df_z['r_cut'])['inv_v_z'].agg([('N','size'), ('inv_v_sum','sum')])
|
||||||
|
t['v_sign'] = df_z.groupby([df_z['r_cut']])['v_sign'].sum()
|
||||||
|
t['N+'] = df_z.groupby(df_z['r_cut'])['v_sign_+'].sum()
|
||||||
|
t['N-'] = df_z.groupby(df_z['r_cut'])['v_sign_-'].sum()
|
||||||
|
t = t.reindex(np.arange(num_r) ,fill_value=0)
|
||||||
|
t.index.name = 'r_bin'
|
||||||
|
t = t.reset_index()
|
||||||
|
t['z'] = float(z)
|
||||||
|
|
||||||
|
# transform to df form
|
||||||
|
a['N'] += t['N']
|
||||||
|
a['N+'] += t['N+']
|
||||||
|
a['N-'] += t['N-']
|
||||||
|
a['n'] += t['inv_v_sum']/As[t['r_bin']]/sim_time
|
||||||
|
a['n'] = a['n'].replace(np.inf, 0)
|
||||||
|
a['jzabs'] += t['N']/As[t['r_bin']]/sim_time
|
||||||
|
a['jz'] += t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
#append to final
|
||||||
|
df = df.append(a)
|
||||||
|
|
||||||
|
df.to_csv(inputpath + "/csv/df_part_all.csv")
|
||||||
|
print("csv saved to " + inputpath + "/csv/df_part_all.csv")
|
||||||
|
|
||||||
|
|
||||||
|
def get_csv_part_rw(inputpath, sim_time, Vmax = 5, number_points = 100):
|
||||||
|
|
||||||
|
outputpath = inputpath + '/csv'
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir(outputpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_rw_hits(f, s, sim_time):
|
||||||
|
def get_mass(s):
|
||||||
|
m_T = 2.81e9
|
||||||
|
if s=='e-':
|
||||||
|
return 511e3
|
||||||
|
elif s=='T+':
|
||||||
|
return m_T
|
||||||
|
elif s=='T2+':
|
||||||
|
return 2*m_T
|
||||||
|
elif s=='T3+':
|
||||||
|
return 3*m_T
|
||||||
|
elif s=='T5+':
|
||||||
|
return 5*m_T
|
||||||
|
else:
|
||||||
|
raise ('Species invalid')
|
||||||
|
def get_Z(species):
|
||||||
|
return species.count('+') - species.count('-')
|
||||||
|
|
||||||
|
try:
|
||||||
|
df_temp = pd.DataFrame(f['Particles'][s]['-3.000000'][:])
|
||||||
|
except:
|
||||||
|
return np.zeros(2*number_points-1)
|
||||||
|
E = get_mass(s)/2*(df_temp['vx_ms']**2 + df_temp['vy_ms']**2 + df_temp['vz_ms']**2)/3e8/3e8
|
||||||
|
N_tot = len(E)
|
||||||
|
N_hits = N_tot - np.cumsum(np.histogram(E, E_boarders)[0])
|
||||||
|
N_hits = np.concatenate((N_tot*np.ones(number_points), N_hits))
|
||||||
|
if (get_Z(s) < 0):
|
||||||
|
N_hits = np.flip(N_hits, axis=0)
|
||||||
|
I = N_hits * 1.602176462e-19 * get_Z(s) / sim_time * 1e9
|
||||||
|
return I
|
||||||
|
|
||||||
|
E_boarders = np.linspace(0, Vmax, number_points)
|
||||||
|
|
||||||
|
h5list = get_h5list(inputpath)
|
||||||
|
|
||||||
|
f = h5py.File(h5list[0], 'r')
|
||||||
|
|
||||||
|
species = list(f['Particles'].keys())
|
||||||
|
df_rw = pd.DataFrame()
|
||||||
|
df_rw['E'] = np.concatenate((-np.flip(E_boarders, axis = 0),E_boarders[1:]))
|
||||||
|
for s in species:
|
||||||
|
I = 0
|
||||||
|
for h5 in h5list[:]:
|
||||||
|
f = h5py.File(h5, 'r')
|
||||||
|
I += get_rw_hits(f, s, sim_time)
|
||||||
|
f.close()
|
||||||
|
df_rw[s] = I
|
||||||
|
df_rw.insert (1, 'total', df_rw.iloc[:,1:].sum(axis = 1))
|
||||||
|
df_rw.melt(id_vars = 'E', var_name = 'species', value_name = 'I')
|
||||||
|
df_rw.to_csv(inputpath + "/csv/df_part_rw.csv")
|
||||||
|
print("csv saved to " + inputpath + "/csv/df_part_rw.csv")
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
if (len(sys.argv) != 3):
|
||||||
|
print ('Error: Too many or too few number of arguments.')
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print( "This is the name of the script: ", sys.argv[0])
|
||||||
|
print( "Number of arguments: ", len(sys.argv))
|
||||||
|
print( "The arguments are: " , str(sys.argv))
|
||||||
|
|
||||||
|
inputpath = sys.argv[1]
|
||||||
|
sim_time = float(sys.argv[2])
|
||||||
|
print("inputpath = ", inputpath)
|
||||||
|
print("sim_time = ", sim_time)
|
||||||
|
get_csv_part_e(inputpath, sim_time)
|
||||||
|
get_csv_part_all(inputpath, sim_time)
|
||||||
|
get_csv_part_rw(inputpath, sim_time)
|
||||||
@@ -13,6 +13,7 @@ def get_df_part_e(file_path, sim_time, num_E, num_r, Erange = [1e-5, 2e4]):
|
|||||||
Ebins = pow(10, np.linspace(np.log10(Erange[0]), np.log10(Erange[1]), (num_E+1)))
|
Ebins = pow(10, np.linspace(np.log10(Erange[0]), np.log10(Erange[1]), (num_E+1)))
|
||||||
Emids = (Ebins[1:] + Ebins[:-1]/2)
|
Emids = (Ebins[1:] + Ebins[:-1]/2)
|
||||||
Emids = pow(10, (np.log10(Ebins[1:]) + np.log10(Ebins[:-1]))/2)
|
Emids = pow(10, (np.log10(Ebins[1:]) + np.log10(Ebins[:-1]))/2)
|
||||||
|
|
||||||
rbins = np.linspace(0, 0.045, (num_r+1))
|
rbins = np.linspace(0, 0.045, (num_r+1))
|
||||||
rmids = (rbins[1:] + rbins[:-1])/2
|
rmids = (rbins[1:] + rbins[:-1])/2
|
||||||
As = np.pi*rbins[1:]**2 - np.pi*rbins[:-1]**2
|
As = np.pi*rbins[1:]**2 - np.pi*rbins[:-1]**2
|
||||||
@@ -20,21 +21,28 @@ def get_df_part_e(file_path, sim_time, num_E, num_r, Erange = [1e-5, 2e4]):
|
|||||||
# open h5 file
|
# open h5 file
|
||||||
f = h5py.File(file_path, 'r')
|
f = h5py.File(file_path, 'r')
|
||||||
g = f['Particles']['e-']
|
g = f['Particles']['e-']
|
||||||
|
print(g)
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
|
|
||||||
# iterate over all zs and append to df
|
# iterate over all zs and append to df
|
||||||
zs = list(g.keys())
|
zs = list(g.keys())
|
||||||
|
|
||||||
for z in zs:
|
for z in zs:
|
||||||
print (z)
|
print (z)
|
||||||
# calc properties and calculate categories
|
# calc properties and calculate categories
|
||||||
df_z = pd.DataFrame(g[z][:])
|
df_z = pd.DataFrame(g[z][:])
|
||||||
|
|
||||||
df_z['E_eV'] = 0.5*me_eV*(df_z.vx_ms**2 + df_z.vy_ms**2 + df_z.vz_ms**2)/c_ms**2
|
df_z['E_eV'] = 0.5*me_eV*(df_z.vx_ms**2 + df_z.vy_ms**2 + df_z.vz_ms**2)/c_ms**2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
df_z['r_m'] = np.sqrt(df_z['x_m']**2 + df_z['y_m']**2)
|
df_z['r_m'] = np.sqrt(df_z['x_m']**2 + df_z['y_m']**2)
|
||||||
df_z['inv_v_z'] = 1/df_z['vz_ms'].abs()
|
df_z['inv_v_z'] = 1/df_z['vz_ms'].abs()
|
||||||
df_z['v_sign'] = np.sign(df_z['vz_ms'])
|
df_z['v_sign'] = np.sign(df_z['vz_ms'])
|
||||||
df_z['E_cut'] = pd.cut(df_z['E_eV'], bins=Ebins, labels = False)
|
df_z['E_cut'] = pd.cut(df_z['E_eV'], bins=Ebins, labels = False)
|
||||||
df_z['r_cut'] = pd.cut(df_z['r_m'], bins=rbins, labels = False, include_lowest = True)
|
df_z['r_cut'] = pd.cut(df_z['r_m'], bins=rbins, labels = False, include_lowest = True)
|
||||||
|
print("calc properties and calculatre categoreies fertig")
|
||||||
# apply categories and fill empty with 0
|
# apply categories and fill empty with 0
|
||||||
#t = df_z['inv_v_z'].groupby([df_z['E_cut'], df_z['r_cut']]).agg(N=np.size,inv_v_sum=np.sum)
|
#t = df_z['inv_v_z'].groupby([df_z['E_cut'], df_z['r_cut']]).agg(N=np.size,inv_v_sum=np.sum)
|
||||||
t = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['inv_v_z'].agg([('N','size'), ('inv_v_sum','sum')])
|
t = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['inv_v_z'].agg([('N','size'), ('inv_v_sum','sum')])
|
||||||
@@ -43,7 +51,7 @@ def get_df_part_e(file_path, sim_time, num_E, num_r, Erange = [1e-5, 2e4]):
|
|||||||
np.arange(num_r)], names=['E_bin', 'r_bin']) ,fill_value=0)
|
np.arange(num_r)], names=['E_bin', 'r_bin']) ,fill_value=0)
|
||||||
t = t.reset_index()
|
t = t.reset_index()
|
||||||
t['z'] = float(z)
|
t['z'] = float(z)
|
||||||
|
print("apply categoires and fill empty with 0 fertig")
|
||||||
# transform to df form
|
# transform to df form
|
||||||
a = pd.DataFrame({
|
a = pd.DataFrame({
|
||||||
'z' : t['z'],
|
'z' : t['z'],
|
||||||
@@ -58,11 +66,16 @@ def get_df_part_e(file_path, sim_time, num_E, num_r, Erange = [1e-5, 2e4]):
|
|||||||
'djzabsdE' : 0,
|
'djzabsdE' : 0,
|
||||||
'djzdE' : 0,
|
'djzdE' : 0,
|
||||||
})
|
})
|
||||||
a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
#a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
||||||
|
a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time
|
||||||
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
||||||
a['djzabsdE'] = t['N']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
#a['djzabsdE'] = t['N']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
||||||
a['djzdE'] = t['v_sign']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
a['djzabsdE'] = t['N']/As[t['r_bin']]/sim_time
|
||||||
|
#a['djzdE'] = t['v_sign']/As[t['r_bin']]/sim_time/(a['Emax']-a['Emin'])
|
||||||
|
a['djzdE'] = t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
df = df.append(a) #append to final
|
df = df.append(a) #append to final
|
||||||
|
print("transform to df form fertig ")
|
||||||
|
print("get_df_part_e fertig")
|
||||||
return df
|
return df
|
||||||
|
|
||||||
def get_df_part_all(file_path, sim_time, num_r):
|
def get_df_part_all(file_path, sim_time, num_r):
|
||||||
@@ -120,6 +133,7 @@ def get_df_part_all(file_path, sim_time, num_r):
|
|||||||
a['jz'] = t['v_sign']/As[t['r_bin']]/sim_time
|
a['jz'] = t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
|
|
||||||
df = df.append(a) #append to final
|
df = df.append(a) #append to final
|
||||||
|
print("get_df_part_all fertig")
|
||||||
return df
|
return df
|
||||||
|
|
||||||
def get_df_part_rw(file_path, sim_time, Vmax = 5, number_points = 100):
|
def get_df_part_rw(file_path, sim_time, Vmax = 5, number_points = 100):
|
||||||
@@ -165,6 +179,7 @@ def get_df_part_rw(file_path, sim_time, Vmax = 5, number_points = 100):
|
|||||||
I = get_rw_hits(f, s, sim_time)
|
I = get_rw_hits(f, s, sim_time)
|
||||||
df_rw[s] = I
|
df_rw[s] = I
|
||||||
df_rw.insert (1, 'total', df_rw.iloc[:,1:].sum(axis = 1))
|
df_rw.insert (1, 'total', df_rw.iloc[:,1:].sum(axis = 1))
|
||||||
|
print("get_df_part_rw fertig")
|
||||||
return df_rw.melt(id_vars = 'E', var_name = 'species', value_name = 'I')
|
return df_rw.melt(id_vars = 'E', var_name = 'species', value_name = 'I')
|
||||||
|
|
||||||
|
|
||||||
@@ -223,9 +238,13 @@ def get_df_part_e_vz(file_path, sim_time, num_vz, num_r, vzrange = [1e-5, 1e9]):
|
|||||||
'djzabsdvz' : 0,
|
'djzabsdvz' : 0,
|
||||||
'djzdvz' : 0,
|
'djzdvz' : 0,
|
||||||
})
|
})
|
||||||
a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
#a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
||||||
|
a['dndE'] = t['inv_v_sum']/As[t['r_bin']]/sim_time
|
||||||
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
||||||
a['djzabsdvz'] = t['N']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
#a['djzabsdvz'] = t['N']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
||||||
a['djzdvz'] = t['v_sign']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
a['djzabsdvz'] = t['N']/As[t['r_bin']]/sim_time
|
||||||
|
#a['djzdvz'] = t['v_sign']/As[t['r_bin']]/sim_time/(a['vzmax']-a['vzmin'])
|
||||||
|
a['djzdvz'] = t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
df = df.append(a) #append to final
|
df = df.append(a) #append to final
|
||||||
|
print("get_df_part_vz fertig")
|
||||||
return df
|
return df
|
||||||
@@ -51,7 +51,7 @@ def plot_part_e_dndE_z3(df_part_e, ax):
|
|||||||
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_e_dndE_z3 fertig")
|
||||||
|
|
||||||
def plot_part_e_dndE_zmid(df_part_e, ax):
|
def plot_part_e_dndE_zmid(df_part_e, ax):
|
||||||
df_plot = df_part_e[(df_part_e['z']== 5)]
|
df_plot = df_part_e[(df_part_e['z']== 5)]
|
||||||
@@ -61,7 +61,7 @@ def plot_part_e_dndE_zmid(df_part_e, ax):
|
|||||||
ax.set_yscale('log')
|
ax.set_yscale('log')
|
||||||
ax.set_xlabel ('Electron energy (eV)')
|
ax.set_xlabel ('Electron energy (eV)')
|
||||||
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
||||||
|
print("plot_part_e_dndE_zmid fertig")
|
||||||
|
|
||||||
def plot_part_e_dndE_hm(df_part_e, fig, ax):
|
def plot_part_e_dndE_hm(df_part_e, fig, ax):
|
||||||
df_temp = df_part_e[['z','Emid', 'dndE']].groupby(['z', 'Emid'], as_index = False).mean()
|
df_temp = df_part_e[['z','Emid', 'dndE']].groupby(['z', 'Emid'], as_index = False).mean()
|
||||||
@@ -93,7 +93,7 @@ def plot_part_e_dndE_hm(df_part_e, fig, ax):
|
|||||||
ax.spines['bottom'].set_visible(False)
|
ax.spines['bottom'].set_visible(False)
|
||||||
ax.spines['right'].set_visible(False)
|
ax.spines['right'].set_visible(False)
|
||||||
ax.spines['left'].set_visible(False)
|
ax.spines['left'].set_visible(False)
|
||||||
|
print("plot_part_e_dndE_hm fertig")
|
||||||
|
|
||||||
def plot_part_e_djzdE_z3(df_part_e, ax):
|
def plot_part_e_djzdE_z3(df_part_e, ax):
|
||||||
df_plot = df_part_e[(df_part_e['z']== -3) | (df_part_e['z']== 5) | (df_part_e['z']== 10)]
|
df_plot = df_part_e[(df_part_e['z']== -3) | (df_part_e['z']== 5) | (df_part_e['z']== 10)]
|
||||||
@@ -110,7 +110,7 @@ def plot_part_e_djzdE_z3(df_part_e, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_e_dndE_z3 fertig")
|
||||||
|
|
||||||
def plot_part_n_z(df_part_all, ax):
|
def plot_part_n_z(df_part_all, ax):
|
||||||
sns.lineplot(ax = ax, x="z", y="n", style = 'species', hue = 'species', data=df_part_all, err_style=None)
|
sns.lineplot(ax = ax, x="z", y="n", style = 'species', hue = 'species', data=df_part_all, err_style=None)
|
||||||
@@ -122,7 +122,7 @@ def plot_part_n_z(df_part_all, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_n_z fertig")
|
||||||
|
|
||||||
def plot_part_jz_z(df_part_all, ax):
|
def plot_part_jz_z(df_part_all, ax):
|
||||||
sns.lineplot(ax = ax, x="z", y="jz", style = 'species', hue = 'species', data=df_part_all, err_style=None)
|
sns.lineplot(ax = ax, x="z", y="jz", style = 'species', hue = 'species', data=df_part_all, err_style=None)
|
||||||
@@ -134,7 +134,7 @@ def plot_part_jz_z(df_part_all, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_jz_z fertig")
|
||||||
|
|
||||||
def plot_part_iz_z(df_part_all, ax):
|
def plot_part_iz_z(df_part_all, ax):
|
||||||
def get_charge(species):
|
def get_charge(species):
|
||||||
@@ -156,7 +156,7 @@ def plot_part_iz_z(df_part_all, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_iz_z fertig")
|
||||||
|
|
||||||
def plot_part_rw(df_part_rw, ax):
|
def plot_part_rw(df_part_rw, ax):
|
||||||
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_part_rw, err_style=None)
|
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_part_rw, err_style=None)
|
||||||
@@ -168,6 +168,7 @@ def plot_part_rw(df_part_rw, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_rw fertig")
|
||||||
|
|
||||||
def plot_part_rw_zoom(df_part_rw_zoom, ax):
|
def plot_part_rw_zoom(df_part_rw_zoom, ax):
|
||||||
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_part_rw_zoom, err_style=None)
|
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_part_rw_zoom, err_style=None)
|
||||||
@@ -179,3 +180,4 @@ def plot_part_rw_zoom(df_part_rw_zoom, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_part_rw_zoom fertig")
|
||||||
@@ -63,14 +63,15 @@ def plot_pop_n_z(df_pop, ax):
|
|||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_pop_n_z")
|
||||||
|
|
||||||
def plot_pop_e_dndE_z3(df_pop, ax):
|
def plot_pop_e_dndE_z3(df_pop, ax):
|
||||||
t_max = np.sort(df_pop.t.unique())[-1]
|
t_max = np.sort(df_pop.t.unique())[-1]
|
||||||
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
||||||
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
||||||
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
||||||
df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
#df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
||||||
|
df_plot['dndE'] = df_plot['n']
|
||||||
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
||||||
df_plot = df_plot[
|
df_plot = df_plot[
|
||||||
(abs(df_plot['zmid'] - -2.675) < 1e-1) |
|
(abs(df_plot['zmid'] - -2.675) < 1e-1) |
|
||||||
@@ -98,14 +99,15 @@ def plot_pop_e_dndE_z3(df_pop, ax):
|
|||||||
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
ax.legend(handles=handles[1:], labels=labels[1:])
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
||||||
|
print("plot_pop_e_dndE_z3 fertig")
|
||||||
|
|
||||||
def plot_pop_e_dndE_zmid(df_pop, ax):
|
def plot_pop_e_dndE_zmid(df_pop, ax):
|
||||||
t_max = np.sort(df_pop.t.unique())[-1]
|
t_max = np.sort(df_pop.t.unique())[-1]
|
||||||
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
||||||
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
||||||
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
||||||
df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
#df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
||||||
|
df_plot['dndE'] = df_plot['n']
|
||||||
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
||||||
df_plot = df_plot[abs(df_plot['zmid'] - 5.125) < 1e-1]
|
df_plot = df_plot[abs(df_plot['zmid'] - 5.125) < 1e-1]
|
||||||
|
|
||||||
@@ -116,3 +118,4 @@ def plot_pop_e_dndE_zmid(df_pop, ax):
|
|||||||
|
|
||||||
ax.set_xlabel ('Electron energy (eV)')
|
ax.set_xlabel ('Electron energy (eV)')
|
||||||
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
|
||||||
|
print("plot_pop_e_dndE_zmid fertig")
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
|
||||||
|
import h5py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (len(sys.argv) != 3):
|
||||||
|
print ('Error: Too many or too few number of arguments.')
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print( "This is the name of the script: ", sys.argv[0])
|
||||||
|
print( "Number of arguments: ", len(sys.argv))
|
||||||
|
print( "The arguments are: " , str(sys.argv))
|
||||||
|
|
||||||
|
inputpath = sys.argv[1]
|
||||||
|
sim_time = sys.argv[2]
|
||||||
|
print("inputpath = ", inputpath)
|
||||||
|
print("sim_time = ", sim_time)
|
||||||
|
|
||||||
|
import get_csv_part
|
||||||
|
get_csv_part_e(inputpath, sim_time)
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import scipy.optimize as optimization
|
||||||
|
import glob
|
||||||
|
import h5py
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def get_h5list(directory, extension='h5'):
|
||||||
|
liste = []
|
||||||
|
for f in os.listdir(directory):
|
||||||
|
if f.endswith('.' + extension):
|
||||||
|
liste.append(directory + '/' + f)
|
||||||
|
return liste
|
||||||
|
|
||||||
|
def get_csv_part_reco(inputpath, sim_time, num_E=100, num_r=1, Erange=[1e-5,2e4]):
|
||||||
|
|
||||||
|
outputpath = inputpath + '/csv'
|
||||||
|
try:
|
||||||
|
os.mkdir(outputpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# def some constants
|
||||||
|
me_eV = 511e3
|
||||||
|
mT_eV = 2.8094320212e9
|
||||||
|
c_ms = 3e8
|
||||||
|
rrange = [0, 0.045]
|
||||||
|
num_E = num_E
|
||||||
|
num_r = num_r
|
||||||
|
Erange=[1e-5,2e4]
|
||||||
|
|
||||||
|
# calc bin properties
|
||||||
|
Ebins = pow(10, np.linspace(np.log10(Erange[0]), np.log10(Erange[1]), (num_E+1)))
|
||||||
|
Emids = (Ebins[1:] + Ebins[:-1]/2)
|
||||||
|
Emids = pow(10, (np.log10(Ebins[1:]) + np.log10(Ebins[:-1]))/2)
|
||||||
|
rbins = np.linspace(0, 0.045, (num_r+1))
|
||||||
|
rmids = (rbins[1:] + rbins[:-1])/2
|
||||||
|
As = np.pi*rbins[1:]**2 - np.pi*rbins[:-1]**2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
h5list = get_h5list(inputpath)
|
||||||
|
|
||||||
|
# open irgendeine h5 file
|
||||||
|
f = h5py.File(h5list[0], 'r')
|
||||||
|
g = f['Particles']['e-']
|
||||||
|
|
||||||
|
species = list(f['Particles'].keys())
|
||||||
|
|
||||||
|
zs = list(g.keys())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
zeros = np.zeros(num_E)
|
||||||
|
|
||||||
|
df = pd.DataFrame()
|
||||||
|
for s in species:
|
||||||
|
#print (s)
|
||||||
|
if(s=='T+'):
|
||||||
|
m = mT_eV
|
||||||
|
if(s=='T2+'):
|
||||||
|
m = 2*mT_eV
|
||||||
|
if(s=='T3+'):
|
||||||
|
m = 3*mT_eV
|
||||||
|
if(s=='T5+'):
|
||||||
|
m = 5*mT_eV
|
||||||
|
if(s=='e-'):
|
||||||
|
m = me_eV
|
||||||
|
|
||||||
|
|
||||||
|
for z in zs:
|
||||||
|
# calc properties and calculate categories
|
||||||
|
#print(z)
|
||||||
|
a = pd.DataFrame({
|
||||||
|
|
||||||
|
'species' : s,
|
||||||
|
'z' : float(z),
|
||||||
|
'Emin' : zeros,
|
||||||
|
'Emax' : 0,
|
||||||
|
'Emid' : 0,
|
||||||
|
'rmin' : 0,
|
||||||
|
'rmax' : 0,
|
||||||
|
'rmid' : 0,
|
||||||
|
'N' : 0,
|
||||||
|
'dndE' : 0,
|
||||||
|
'djzabsdE' : 0,
|
||||||
|
'djzdE' : 0,
|
||||||
|
'N+' : 0,
|
||||||
|
'N-' : 0,
|
||||||
|
'dj+dE' : 0,
|
||||||
|
'dj-dE' : 0
|
||||||
|
})
|
||||||
|
|
||||||
|
for h5 in h5list[:]:
|
||||||
|
#print(h5)
|
||||||
|
f = h5py.File(h5, 'r')
|
||||||
|
g = f['Particles'][s]
|
||||||
|
df_z = pd.DataFrame(g[z][:])
|
||||||
|
#print(df_z)
|
||||||
|
#print(df_z['Id'])
|
||||||
|
# calc properties and calc categories
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
df_z['E_eV'] = 0.5*m*(df_z.vx_ms**2 + df_z.vy_ms**2 + df_z.vz_ms**2)/c_ms**2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
df_z['r_m'] = np.sqrt(df_z['x_m']**2 + df_z['y_m']**2)
|
||||||
|
df_z['inv_v_z'] = 1/df_z['vz_ms'].abs()
|
||||||
|
df_z['v_sign'] = np.sign(df_z['vz_ms'])
|
||||||
|
df_z['v_sign_+'] = df_z['v_sign'].apply(lambda x: 1 if x > 0 else 0)
|
||||||
|
df_z['v_sign_-'] = df_z['v_sign'].apply(lambda x: 1 if x < 0 else 0)
|
||||||
|
df_z['E_cut'] = pd.cut(df_z['E_eV'], bins=Ebins, labels = False)
|
||||||
|
df_z['r_cut'] = pd.cut(df_z['r_m'], bins=rbins, labels = False, include_lowest = True)
|
||||||
|
|
||||||
|
|
||||||
|
# apply categories and fill empty with 0
|
||||||
|
t = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['inv_v_z'].agg([('N','size'), ('inv_v_sum','sum')])
|
||||||
|
t['v_sign'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign'].sum()
|
||||||
|
t['N+'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign_+'].sum()
|
||||||
|
t['N-'] = df_z.groupby([df_z['E_cut'], df_z['r_cut']])['v_sign_-'].sum()
|
||||||
|
t = t.reindex( pd.MultiIndex.from_product([np.arange(num_E),
|
||||||
|
np.arange(num_r)], names=['E_bin', 'r_bin']) ,fill_value=0)
|
||||||
|
t = t.reset_index()
|
||||||
|
t['z'] = float(z)
|
||||||
|
|
||||||
|
#print(Ebins[t['E_bin']])
|
||||||
|
# transform to df form
|
||||||
|
|
||||||
|
#a['Emin'] = Ebins[t['E_bin']]
|
||||||
|
#a['Emax'] = Ebins[t['E_bin']+1]
|
||||||
|
a['Emid'] = Emids[t['E_bin']]
|
||||||
|
a['rmin'] = rbins[t['r_bin']]
|
||||||
|
a['rmax'] = rbins[t['r_bin']+1]
|
||||||
|
a['rmid'] = rmids[t['r_bin']]
|
||||||
|
a['N'] += t['N']
|
||||||
|
a['dndE'] += t['inv_v_sum']/As[t['r_bin']]/sim_time
|
||||||
|
a['dndE'] = a['dndE'].replace(np.inf, 0)
|
||||||
|
a['djzabsdE'] += t['N']/As[t['r_bin']]/sim_time
|
||||||
|
a['djzdE'] += t['v_sign']/As[t['r_bin']]/sim_time
|
||||||
|
a['N+'] += t['N+']
|
||||||
|
a['N-'] += t['N-']
|
||||||
|
a['dj+dE'] += t['N+']/As[t['r_bin']]/sim_time
|
||||||
|
a['dj-dE'] += t['N-']/As[t['r_bin']]/sim_time
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
#append to final
|
||||||
|
|
||||||
|
df = df.append(a)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
df.to_csv(inputpath + "/csv/df_part_reco.csv")
|
||||||
|
print("saved to " + inputpath + "/csv/df_part_reco.csv")
|
||||||
|
#return df
|
||||||
|
|
||||||
|
|
||||||
|
def get_csv_pop_reco(inputpath):
|
||||||
|
|
||||||
|
outputpath = inputpath + '/csv'
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir(outputpath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def append_V_m3 (df_meta):
|
||||||
|
A_m2 = np.pi*(df_meta.r_max_m**2-df_meta.r_min_m**2)*(df_meta.phi_max-df_meta.phi_min)/2/np.pi
|
||||||
|
V_m3 = A_m2*(df_meta.z_max_m-df_meta.z_min_m)
|
||||||
|
df_meta.insert(len(df_meta.columns),'V_m3',V_m3)
|
||||||
|
return df_meta
|
||||||
|
|
||||||
|
def get_V_m3(df_meta):
|
||||||
|
r_bins = np.unique(df_meta.r_bin)
|
||||||
|
#print(r_bins)
|
||||||
|
V_m3 = np.zeros(r_bins.size)
|
||||||
|
for i in np.arange(r_bins.size):
|
||||||
|
V_m3[i] = np.mean (df_meta[df_meta.r_bin==r_bins[i]].V_m3)
|
||||||
|
return V_m3
|
||||||
|
|
||||||
|
def append_n_m3 (df, V_m3):
|
||||||
|
n_m3 = df.cum_time/df.phys_time_s/V_m3[df.r_bin]
|
||||||
|
df['n_m3'] = n_m3
|
||||||
|
df['n_m3'].fillna(0., inplace=True)
|
||||||
|
return df
|
||||||
|
|
||||||
|
def append_from_meta(df, df_meta):
|
||||||
|
df_length = df.shape[0]
|
||||||
|
bin_list = ['z_bin','r_bin','phi_bin','E_bin']
|
||||||
|
min_list = ['z_min_m', 'r_min_m', 'phi_min', 'E_min_eV']
|
||||||
|
max_list = ['z_max_m', 'r_max_m', 'phi_max', 'E_max_eV']
|
||||||
|
for i in range(len(bin_list)):
|
||||||
|
i_bin = bin_list[i]
|
||||||
|
i_min = min_list[i]
|
||||||
|
i_max = max_list[i]
|
||||||
|
info_df = df_meta.groupby(i_bin, as_index=False).mean()
|
||||||
|
mins = np.zeros(df_length)
|
||||||
|
maxs = np.zeros(df_length)
|
||||||
|
for row in range(0, info_df.shape[0]):
|
||||||
|
mins[df[i_bin] == info_df[i_bin][row]] = info_df[i_min][row]
|
||||||
|
maxs[df[i_bin] == info_df[i_bin][row]] = info_df[i_max][row]
|
||||||
|
df[i_min] = mins
|
||||||
|
df[i_max] = maxs
|
||||||
|
return df
|
||||||
|
|
||||||
|
h5list = get_h5list(inputpath)
|
||||||
|
|
||||||
|
f = h5py.File(h5list[0], 'r')
|
||||||
|
|
||||||
|
df = pd.DataFrame()
|
||||||
|
species = list(f['Populations'].keys())
|
||||||
|
for s in species:
|
||||||
|
try: # If has been merged
|
||||||
|
pop_key = list(f['Populations'][s].keys())[0]
|
||||||
|
df_data = pd.DataFrame(f['Populations'][s][pop_key][s][:])
|
||||||
|
df_meta = pd.DataFrame(f['Populations'][s][pop_key][s + '_meta_data'][:])
|
||||||
|
except: # If not merged
|
||||||
|
df_data = pd.DataFrame(f['Populations'][s][s][:])
|
||||||
|
df_meta = pd.DataFrame(f['Populations'][s][s + '_meta_data'][:])
|
||||||
|
|
||||||
|
df_meta = append_V_m3(df_meta)
|
||||||
|
V_m3 = get_V_m3(df_meta)
|
||||||
|
df_data = append_n_m3(df_data, V_m3)
|
||||||
|
df_data = append_from_meta(df_data, df_meta)
|
||||||
|
|
||||||
|
a = pd.DataFrame({
|
||||||
|
'species' : s,
|
||||||
|
't' : df_data['phys_time_s'],
|
||||||
|
'zmin' : df_data['z_min_m'],
|
||||||
|
'zmax' : df_data['z_max_m'],
|
||||||
|
'rmin' : df_data['r_min_m'],
|
||||||
|
'rmax' : df_data['r_max_m'],
|
||||||
|
'phimin' : df_data['phi_min'],
|
||||||
|
'phimax' : df_data['phi_max'],
|
||||||
|
'Emin' : df_data['E_min_eV'],
|
||||||
|
'Emax' : df_data['E_max_eV'],
|
||||||
|
'n': df_data['n_m3']
|
||||||
|
})
|
||||||
|
df = df.append(a) #append to final
|
||||||
|
df.to_csv(inputpath + "/csv/df_pop_reco.csv")
|
||||||
|
print("saved to " + inputpath + "/csv/df_pop_reco.csv")
|
||||||
|
#return df
|
||||||
|
|
||||||
|
|
||||||
|
inputpath = sys.argv[1]
|
||||||
|
sim_time = float(sys.argv[2])
|
||||||
|
|
||||||
|
get_csv_part_reco(inputpath, sim_time)
|
||||||
|
get_csv_pop_reco(inputpath)
|
||||||
@@ -4,6 +4,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
|
||||||
import h5py
|
import h5py
|
||||||
|
|
||||||
base_dir = os.path.dirname(os.path.realpath(__file__)) + '/..'
|
base_dir = os.path.dirname(os.path.realpath(__file__)) + '/..'
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
+1113
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
|
|||||||
|
,species,z,rmin,rmax,rmid,N,n,jzabs,jz
|
||||||
|
0,e-,-1.0,0.0,0.045,0.0225,99985,26392481611.44686,1571664887411669.8,-1565377284721619.5
|
||||||
|
0,e-,-2.0,0.0,0.045,0.0225,99995,26397047310.47765,1571822077478921.0,-1570155862766057.8
|
||||||
|
0,e-,-3.0,0.0,0.045,0.0225,100000,26398910789.568596,1571900672512546.8,-1571900672512546.8
|
||||||
|
0,e-,0.0,0.0,0.045,0.0225,99989,26393880263.36666,1571727763438570.2,-1558115103614611.8
|
||||||
|
0,e-,1.0,0.0,0.045,0.0225,99988,26516963277.420944,1571712044431845.2,-1519587818131329.0
|
||||||
|
0,e-,10.0,0.0,0.045,0.0225,99918,25899032113.23956,1570611713961086.5,0.0
|
||||||
|
0,e-,2.0,0.0,0.045,0.0225,100114,26676161909.863304,1573692639279211.0,-1419803563440232.8
|
||||||
|
0,e-,3.0,0.0,0.045,0.0225,100039,24784061018.565693,1572513713774826.5,-1264358305935467.0
|
||||||
|
0,e-,4.0,0.0,0.045,0.0225,99931,25313564884.091675,1570816061048513.0,-1051837335011770.5
|
||||||
|
0,e-,5.0,0.0,0.045,0.0225,99993,27209450688.98409,1571790639465470.8,-779647014559498.0
|
||||||
|
0,e-,6.0,0.0,0.045,0.0225,100126,27415648873.754333,1573881267359912.5,-505146000118632.06
|
||||||
|
0,e-,7.0,0.0,0.045,0.0225,100078,27207950713.319912,1573126755037106.5,-292090582966281.44
|
||||||
|
0,e-,8.0,0.0,0.045,0.0225,99866,25972771094.585533,1569794325611380.0,-137415556791046.84
|
||||||
|
0,e-,9.0,0.0,0.045,0.0225,99892,25948051425.605534,1570203019786233.0,-39077450718661.91
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,100 @@
|
|||||||
|
-3.96 -1.62
|
||||||
|
-3.88 -2.22
|
||||||
|
-3.79 -2.13
|
||||||
|
-3.71 -2.04
|
||||||
|
-3.63 -1.95
|
||||||
|
-3.54 -1.86
|
||||||
|
-3.46 -1.77
|
||||||
|
-3.38 -1.69
|
||||||
|
-3.29 -1.61
|
||||||
|
-3.21 -1.53
|
||||||
|
-3.13 -1.46
|
||||||
|
-3.05 -1.39
|
||||||
|
-2.96 -1.33
|
||||||
|
-2.88 -1.27
|
||||||
|
-2.80 -1.22
|
||||||
|
-2.71 -1.18
|
||||||
|
-2.63 -1.15
|
||||||
|
-2.55 -1.13
|
||||||
|
-2.46 -1.13
|
||||||
|
-2.38 -1.15
|
||||||
|
-2.30 -1.19
|
||||||
|
-2.22 -1.26
|
||||||
|
-2.13 -1.36
|
||||||
|
-2.05 -1.49
|
||||||
|
-1.97 -1.66
|
||||||
|
-1.88 -1.88
|
||||||
|
-1.80 -2.15
|
||||||
|
-1.72 -2.50
|
||||||
|
-1.63 -2.88
|
||||||
|
-1.55 -3.24
|
||||||
|
-1.47 -3.42
|
||||||
|
-1.39 -3.45
|
||||||
|
-1.30 -3.49
|
||||||
|
-1.22 -3.48
|
||||||
|
-1.14 -3.49
|
||||||
|
-1.05 -3.50
|
||||||
|
-0.97 -3.50
|
||||||
|
-0.89 -3.52
|
||||||
|
-0.80 -3.53
|
||||||
|
-0.72 -3.55
|
||||||
|
-0.64 -3.61
|
||||||
|
-0.56 -3.69
|
||||||
|
-0.47 -3.79
|
||||||
|
-0.39 -3.89
|
||||||
|
-0.31 -4.00
|
||||||
|
-0.22 -4.12
|
||||||
|
-0.14 -4.21
|
||||||
|
-0.06 -4.30
|
||||||
|
0.03 -4.42
|
||||||
|
0.11 -4.55
|
||||||
|
0.19 -4.67
|
||||||
|
0.28 -4.82
|
||||||
|
0.36 -4.90
|
||||||
|
0.44 -4.98
|
||||||
|
0.52 -5.04
|
||||||
|
0.61 -5.06
|
||||||
|
0.69 -5.07
|
||||||
|
0.77 -5.09
|
||||||
|
0.86 -5.14
|
||||||
|
0.94 -5.32
|
||||||
|
1.02 -4.58
|
||||||
|
1.11 -6.06
|
||||||
|
1.19 -6.24
|
||||||
|
1.27 -6.55
|
||||||
|
1.35 -6.89
|
||||||
|
1.44 -7.10
|
||||||
|
1.52 -7.31
|
||||||
|
1.60 -7.27
|
||||||
|
1.69 -7.35
|
||||||
|
1.77 -7.47
|
||||||
|
1.85 -7.43
|
||||||
|
1.94 -7.62
|
||||||
|
2.02 -7.66
|
||||||
|
2.10 -7.66
|
||||||
|
2.18 -7.71
|
||||||
|
2.27 -7.67
|
||||||
|
2.35 -7.51
|
||||||
|
2.43 -7.75
|
||||||
|
2.52 -7.72
|
||||||
|
2.60 -7.66
|
||||||
|
2.68 -7.58
|
||||||
|
2.77 -7.42
|
||||||
|
2.85 -7.52
|
||||||
|
2.93 -7.38
|
||||||
|
3.01 -7.35
|
||||||
|
3.10 -7.18
|
||||||
|
3.18 -7.16
|
||||||
|
3.26 -7.18
|
||||||
|
3.35 -7.10
|
||||||
|
3.43 -6.92
|
||||||
|
3.51 -6.89
|
||||||
|
3.60 -6.90
|
||||||
|
3.68 -6.82
|
||||||
|
3.76 -6.74
|
||||||
|
3.84 -6.72
|
||||||
|
3.93 -6.91
|
||||||
|
4.01 -6.90
|
||||||
|
4.09 -7.11
|
||||||
|
4.18 -7.37
|
||||||
|
4.26 -22.88
|
||||||
+759
File diff suppressed because one or more lines are too long
+195
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
Binary file not shown.
+291
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user