Major changes:
- Added individul operators for species and better selecting process. - Switched to C arrays for main loop operations and calculating array indizes using knowledge of binning instead of doing sorted search - Added Recombination - Reworked elastic scattering kinematics - Added inelastic scattering kinematics
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// kinematics_base.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 23.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef kinematics_base_h
|
||||
#define kinematics_base_h
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "error_types.h"
|
||||
#include "kinematics.h"
|
||||
|
||||
// See http://www.lnl.infn.it/~pisolo/alberto/Kinematics.pdf
|
||||
|
||||
class Elastic_Kinematic_Base {
|
||||
double m1_eV, m2_eV;
|
||||
double sign;
|
||||
double const1, const2;
|
||||
|
||||
public:
|
||||
Elastic_Kinematic_Base() {};
|
||||
Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV);
|
||||
|
||||
void doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab);
|
||||
};
|
||||
|
||||
inline Elastic_Kinematic_Base::Elastic_Kinematic_Base(const double &m1_eV, const double &m2_eV) {
|
||||
this->m1_eV = m1_eV;
|
||||
this->m2_eV = m2_eV;
|
||||
sign = (m1_eV < m2_eV) ? 1 : -1;
|
||||
const1 = m1_eV*m1_eV/pow(m1_eV + m2_eV,2);
|
||||
const2 = pow(m2_eV/m1_eV,2);
|
||||
}
|
||||
|
||||
inline void Elastic_Kinematic_Base::doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab) {
|
||||
vec3 v1_ms = P1->get_Speed_ms() - v2_lab_ms;
|
||||
|
||||
double E0_eV = calc_Ekin_eV_from_speed(v1_ms, m1_eV);
|
||||
double inner_sqrt = pow( const2 - pow(sin(theta_lab),2) , 0.5 );
|
||||
double E1_eV = E0_eV * const1 * pow(cos(theta_lab) + sign*inner_sqrt , 2);
|
||||
|
||||
double v1Abs_new_ms = calc_Speed_from_Ekin_eV(E1_eV, m1_eV);
|
||||
vec3 n0 = calc_newDirection(v1_ms, theta_lab, phi_lab);
|
||||
vec3 v1_new_ms = n0 * v1Abs_new_ms + v2_lab_ms;
|
||||
P1->set_Speed_ms(v1_new_ms);
|
||||
}
|
||||
|
||||
|
||||
class Inelastic_Kinematic_Base {
|
||||
double Q_eV;
|
||||
double m1_eV, m2_eV;
|
||||
|
||||
double a, b, c, d;
|
||||
|
||||
public:
|
||||
Inelastic_Kinematic_Base();
|
||||
Inelastic_Kinematic_Base(const double &Q_eV, const double &m1_eV, const double &m2_eV);
|
||||
|
||||
void doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab);
|
||||
|
||||
private:
|
||||
double ET_eV(const double &E1_eV) {return (E1_eV + Q_eV);}
|
||||
double A (const double &E1_eV) {return (a*E1_eV/(E1_eV-Q_eV));}
|
||||
double B (const double &E1_eV) {return (b*E1_eV/(E1_eV-Q_eV));}
|
||||
double temp_cd(const double &E1_eV) {return (1 + m1_eV*Q_eV/m2_eV/(E1_eV-Q_eV));}
|
||||
double C (const double &E1_eV) {return (c*temp_cd(E1_eV));}
|
||||
double D (const double &E1_eV) {return (d*temp_cd(E1_eV));}
|
||||
};
|
||||
|
||||
inline Inelastic_Kinematic_Base::Inelastic_Kinematic_Base(const double &Q_eV, const double &m1_eV, const double &m2_eV) {
|
||||
this->Q_eV = Q_eV;
|
||||
if (Q_eV<=0) {
|
||||
std::stringstream ss;
|
||||
ss<<"Inelastic_Kinematics_Base: Q_eV<=0.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
this->m1_eV = m1_eV;
|
||||
this->m2_eV = m2_eV;
|
||||
if (m1_eV > m2_eV) {
|
||||
std::stringstream ss;
|
||||
ss<<"Inelastic_Kinematics_Base: m1_eV > m2_eV.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
double c1 = pow(m1_eV+m2_eV,2);
|
||||
a = m1_eV*m2_eV/c1;
|
||||
b = m1_eV*m1_eV/c1;
|
||||
c = a;
|
||||
d = m2_eV*m2_eV/c1;
|
||||
};
|
||||
|
||||
|
||||
inline void Inelastic_Kinematic_Base::doKinematics (Particle* P1, const vec3 &v2_lab_ms, const double &theta_lab, const double &phi_lab) {
|
||||
vec3 v1_ms = P1->get_Speed_ms() - v2_lab_ms;
|
||||
|
||||
double E1_eV = calc_Ekin_eV_from_speed(v1_ms, m1_eV);
|
||||
double ET_eV = this->ET_eV(E1_eV);
|
||||
double B = this->B(E1_eV);
|
||||
double D = this->D(E1_eV);
|
||||
double sign = B>D ? -1 : 1;
|
||||
double inner_sqrt = pow( (D/B - pow(sin(theta_lab),2) ) , 0.5 );
|
||||
double E1_new_eV = ET_eV * B * pow( cos(theta_lab) +sign * inner_sqrt, 2);
|
||||
double v1Abs_new_ms = calc_Speed_from_Ekin_eV(E1_new_eV, m1_eV);
|
||||
vec3 n0 = calc_newDirection(v1_ms, theta_lab, phi_lab);
|
||||
vec3 v1_new_ms = n0 * v1Abs_new_ms + v2_lab_ms;
|
||||
P1->set_Speed_ms(v1_new_ms);
|
||||
}
|
||||
|
||||
|
||||
#endif /* kinematics_base_h */
|
||||
Reference in New Issue
Block a user