Working change, before making some adjustments in classes, structure.
This commit is contained in:
@@ -16,28 +16,20 @@ 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;
|
||||
|
||||
// Elastic Scattering
|
||||
|
||||
|
||||
// Tritium
|
||||
const double Constants::ZT2 = 2.;
|
||||
const double Constants::mT2_eV = 5.61886404234e9;
|
||||
|
||||
// Ionization
|
||||
const double Constants::rBohr_m = 0.52917721067e-10;
|
||||
const double Constants::ERydberg_eV = 13.605693009;
|
||||
const double Constants::EIonizationT2_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::ionG5 = 0.33;
|
||||
const double Constants::ionBeta = 0.6;
|
||||
const double Constants::ionGamma = 10;
|
||||
|
||||
|
||||
// Conversation
|
||||
@@ -88,6 +80,51 @@ blitz::TinyVector<double,3> Constants::getRandDir(ranlib::Uniform<double> *rngUn
|
||||
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]);
|
||||
|
||||
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) {
|
||||
@@ -103,4 +140,14 @@ double Constants::getRandEnergyMaxwell(double Temp_K,double mass_eV,ranlib::Norm
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user