Screenshot with working ionization function.
Ionization will be changed to BED model.
This commit is contained in:
+24
-134
@@ -2,152 +2,42 @@
|
||||
// constants.cpp
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 06.11.18.
|
||||
// Copyright © 2018 Christian Reiling. All rights reserved.
|
||||
// Created by Christian Reiling on 09.02.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "constants.h"
|
||||
#include "constants.hpp"
|
||||
|
||||
// Natural Constants
|
||||
const double Constants::pi = 3.1415;
|
||||
const double Constants::c_nat = 1.;
|
||||
const double Constants::c_ms = 299792458;
|
||||
const double Constants::kb_eVK = 8.6173303e-5;
|
||||
const double Constants::me_eV = 0.511e6;
|
||||
const double Constants::qe_e = 1;
|
||||
const double Constants::re_m = 2.817940322719e-15;
|
||||
const double Constants::e_C = 1.602176462e-19;
|
||||
const double Constants::rBohr_m = 0.52917721067e-10;
|
||||
const double Constants::ERyd_eV = 13.605693009;
|
||||
|
||||
// Beta Decay
|
||||
const double Constants::BetaDecayC = 1.2072343416696292e-47;
|
||||
const double Constants::ZHe3 = 2.;
|
||||
const double Constants::Etridecay_eV = 18.574e3;
|
||||
|
||||
|
||||
|
||||
// Tritium
|
||||
// Particle Properties
|
||||
const double Constants::me_eV = 0.511e6;
|
||||
const double Constants::re_m = 2.817940322719e-15;
|
||||
const double Constants::ZT2 = 2.;
|
||||
const double Constants::mT2_eV = 5.61886404234e9;
|
||||
|
||||
// Beta Decay
|
||||
const double Constants::BetaDecayConst = 1.2072343416696292e-47;
|
||||
const double Constants::TritiumDecayEndpoint_eV = 18.574e3;
|
||||
|
||||
|
||||
// Conversation
|
||||
double Constants::calcAbs(blitz::TinyVector<double,3> vec) {
|
||||
return( sqrt( pow(vec[0],2) + pow(vec[1],2) + pow(vec[2],2)) );
|
||||
}
|
||||
|
||||
|
||||
double Constants::calcV_msFromEkin_eV(double Ekin_eV, double m_eV) {
|
||||
double gamma = calcGammaFromEkin_eV(Ekin_eV, m_eV);
|
||||
double beta = calcBetaFromGamma(gamma);
|
||||
return(beta * c_ms);
|
||||
}
|
||||
|
||||
double Constants::calcGammaFromEkin_eV(double Ekin_eV, double m_eV) {
|
||||
return (1. + Ekin_eV/m_eV);
|
||||
}
|
||||
|
||||
double Constants::calcBetaFromGamma(double gamma) {
|
||||
return( sqrt(1 - pow(gamma,-2)) );
|
||||
}
|
||||
|
||||
double Constants::calcEkin_eVFromVAbs_ms(double vAbs_ms, double m_eV) {
|
||||
double beta = calcBetaFromVAbs_ms(vAbs_ms);
|
||||
double gamma = calcGammaFromBeta(beta);
|
||||
return ( (gamma-1) * m_eV * pow(c_nat,2) );
|
||||
}
|
||||
|
||||
double Constants::calcBetaFromVAbs_ms(double vAbs_ms) {
|
||||
return(vAbs_ms/c_ms);
|
||||
}
|
||||
|
||||
double Constants::calcGammaFromBeta(double beta) {
|
||||
return( pow(1 - pow(beta,2),-0.5) ) ;
|
||||
}
|
||||
|
||||
// Help Functions
|
||||
blitz::TinyVector<double,3> Constants::zeroVec() {
|
||||
blitz::TinyVector<double,3> zeroVec;
|
||||
zeroVec = 0,0,0;
|
||||
return(zeroVec);
|
||||
}
|
||||
blitz::TinyVector<double,3> Constants::getRandDir(ranlib::Uniform<double> *rngUni) {
|
||||
blitz::TinyVector<double,3> dir;
|
||||
double Phi_rad = 2*pi*rngUni->random();
|
||||
double Theta_rad = pi*rngUni->random();
|
||||
dir = sin(Theta_rad)*cos(Phi_rad) , sin(Theta_rad)*sin(Phi_rad) , cos(Theta_rad);
|
||||
return(dir);
|
||||
}
|
||||
|
||||
blitz::TinyVector<double,3> Constants::getNewDir(blitz::TinyVector<double,3> oldDir, double theta,double phi) {
|
||||
// Transformation of direction following Plante and Cucinotta
|
||||
double theta0, phi0, A3, A4, A5, A11, A21, theta1, phi1;
|
||||
double phi1c [4];
|
||||
theta0 = acos(oldDir[2]/calcAbs(oldDir));
|
||||
phi0 = atan2(oldDir[1],oldDir[0]);
|
||||
// Elastic Scattering
|
||||
const double Constants::elaBeta[5] = {7.51525,-0.419122,7.2017e-3,-4.646e-5,1.02897e-7};
|
||||
const double Constants::elaDelta[5] = {2.9612,-0.26376,4.307e-3,-2.6895e-5,5.83505e-8};
|
||||
const double Constants::elaGamma[14] = {1.7013,-1.484284,0.6331,-0.10911,8.358e-3,-2.388e-4,-3.32517, 0.10996,-4.5255e-3,5.8372e-5,-2.4659e-7,2.4775e-2,-2.96264e-5,-1.20655e-7};
|
||||
|
||||
A3 = sin(theta)*cos(phi);
|
||||
A4 = A3*cos(theta0) + cos(theta)*sin(theta0);
|
||||
A5 = sin(theta)*sin(phi);
|
||||
A11 = A4*cos(phi0) - A5*sin(phi0);
|
||||
A21 = A4*sin(phi0) + A5*cos(phi0);
|
||||
theta1 = acos( cos(theta0)*cos(theta)-A3*sin(theta0) );
|
||||
|
||||
// Get right phi1, maybe more elegant way later.
|
||||
int digits = 6;
|
||||
double fac = pow(10,digits);
|
||||
phi1 = -1;
|
||||
phi1c[0] = acos( roundf ( A11/sin(theta1) *fac)/fac );
|
||||
phi1c[1] = 2*pi - phi1c[0];
|
||||
phi1c[2] = asin ( roundf ( A21/sin(theta1) *fac)/fac );
|
||||
phi1c[3] = pi - phi1c[2];
|
||||
phi1c[2] = (phi1c[2] > 0) ? phi1c[2] : 2*pi + phi1c[2];
|
||||
for (int i=0;i<3;i++) {
|
||||
for (int j=i+1;j<4;j++) {
|
||||
if (phi1c[i]-phi1c[j] < 0.0001) {
|
||||
phi1 = phi1c[i];
|
||||
goto endloops;
|
||||
}
|
||||
}
|
||||
}
|
||||
endloops:
|
||||
if (phi1 == -1) {
|
||||
for (int j = 0;j<3;j++) {
|
||||
cout<<"phi1c["<<j<<"]="<<phi1c[j]<<endl;
|
||||
}
|
||||
|
||||
std::cerr<<"Interaction::getElaNewDir: phi1 not found."<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
blitz::TinyVector<double,3> newDir;
|
||||
newDir = sin(theta1)*cos(phi1) , sin(theta1)*sin(phi1) , cos(theta1);
|
||||
return(newDir);
|
||||
}
|
||||
|
||||
// Random Generators
|
||||
|
||||
double Constants::getRandEnergyMaxwell(double Temp_K,double mass_eV,ranlib::NormalUnit<double> *rngNormal) {
|
||||
double C, beta, N1,N2,N3;
|
||||
C = kb_eVK*Temp_K/mass_eV;
|
||||
beta = 0;
|
||||
N1 = rngNormal->random();
|
||||
N2 = rngNormal->random();
|
||||
N3 = rngNormal->random();
|
||||
beta = sqrt(C*(N1*N1 + N2*N2 + N3*N3));
|
||||
|
||||
return((calcGammaFromBeta(beta)-1)*mass_eV);
|
||||
|
||||
}
|
||||
|
||||
|
||||
double Constants::doRejectionMethod(double (*pdf)(double), double xmin, double xmax, double pmax, ranlib::Uniform<double> *rngUni) {
|
||||
// get Energy distribution using Rejection Method
|
||||
double xcan,eta1,eta2;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
xcan = xmin + eta1*(xmax - xmin);
|
||||
} while( eta2*pmax > pdf(xcan) );
|
||||
return(xcan);
|
||||
}
|
||||
// Ionization
|
||||
const double Constants::ionET2_eV = 13.603;
|
||||
const double Constants::ionA1 = 0.74;
|
||||
const double Constants::ionA2 = 0.87;
|
||||
const double Constants::ionA3 = -0.6;
|
||||
const double Constants::ionN = 2.4;
|
||||
const double Constants::ionBeta = 0.6;
|
||||
const double Constants::ionGamma = 10;
|
||||
const double Constants::ionG5 = 0.33;
|
||||
const double Constants::iongb = 2.9;
|
||||
|
||||
Reference in New Issue
Block a user