Major changes:
- Moved to array operations for main loops. - Changed to setting pointers to operator only once before loop. - Changed Population Containers - Added Recombination - Added Inelastic Scattering Kinematics - Reworked Elastic Scattering Cross Section - Reworked Elastic Scattering Kinematics - Reworked organisation of different particle species and corresponding operators
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#define kinematics_h
|
||||
|
||||
#include <sstream>
|
||||
#include <blitz/array.h>
|
||||
#include <blitz/tinyvec2.h>
|
||||
|
||||
#include "constants.h"
|
||||
@@ -90,38 +91,39 @@ inline double calc_Speed_from_Ekin_eV(const double &Ekin_eV, const double &mass_
|
||||
}
|
||||
|
||||
inline vec3 calc_newDirection(const vec3 &direction_old, const double &theta_change, const double &phi_change) {
|
||||
// Transformation of direction following Plante and Cucinotta
|
||||
double theta_old = acos(direction_old[2]/vec3Abs(direction_old));
|
||||
double phi_old = atan2(direction_old[1],direction_old[0]);
|
||||
|
||||
double A3 = sin(theta_change)*cos(phi_change);
|
||||
double A4 = A3*cos(theta_old) + cos(theta_change)*sin(theta_old);
|
||||
double A5 = sin(theta_change)*sin(phi_change);
|
||||
double A11 = A4*cos(phi_old) - A5*sin(phi_old);
|
||||
double A21 = A4*sin(phi_old) + A5*cos(phi_old);
|
||||
double theta_new = acos( cos(theta_old)*cos(theta_change)-A3*sin(theta_old) );
|
||||
|
||||
// Get right phi1, maybe more elegant way later. Problem comes from reverse functions only being on range of pi. So combine both statements to get proper phi over 2pi.
|
||||
int digits = 6;
|
||||
double fac = pow(10,digits);
|
||||
double phi_new = -1;
|
||||
double phi_new_candidates [4];
|
||||
phi_new_candidates[0] = acos( roundf ( A11/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[1] = 2*pi - phi_new_candidates[0];
|
||||
phi_new_candidates[2] = asin ( roundf ( A21/sin(theta_new) *fac)/fac );
|
||||
phi_new_candidates[3] = pi - phi_new_candidates[2];
|
||||
phi_new_candidates[2] = (phi_new_candidates[2] > 0) ? phi_new_candidates[2] : 2*pi + phi_new_candidates[2];
|
||||
for (int i=0;i<3;i++) {
|
||||
for (int j=i+1;j<4;j++) {
|
||||
if (phi_new_candidates[i]-phi_new_candidates[j] < 0.0001) {
|
||||
phi_new = phi_new_candidates[i];
|
||||
}
|
||||
}
|
||||
// Alireza Haghighat: Appendix 3 (p.249)
|
||||
vec3 nOld = direction_old/vec3Abs(direction_old);
|
||||
double u = nOld[0];
|
||||
double v = nOld[1];
|
||||
double w = nOld[2];
|
||||
double s = sqrt(1-w*w);
|
||||
double uNew, vNew, wNew;
|
||||
if (w!=1) {
|
||||
uNew = -(u*w/s*cos(phi_change) - v/s*sin(phi_change))*sin(theta_change) + u*cos(theta_change);
|
||||
vNew = -(v*w/s*cos(phi_change) + u/s*sin(phi_change))*sin(theta_change) + v*cos(theta_change);
|
||||
wNew = s*(sin(theta_change)*cos(phi_change)) + w*cos(theta_change);
|
||||
} else {
|
||||
uNew = sin(theta_change)*cos(phi_change);
|
||||
vNew = sin(theta_change)*sin(phi_change);
|
||||
wNew = cos(theta_change);
|
||||
}
|
||||
if (phi_new == -1) {
|
||||
throw MyException("Interaction::getElaNewDir: phi1 not found.");
|
||||
return(vec3(uNew, vNew, wNew));
|
||||
}
|
||||
|
||||
inline double get_z_m(const vec3 &loc_m) {
|
||||
return (loc_m[2]);
|
||||
}
|
||||
|
||||
inline double get_r_m(const vec3 &loc_m) {
|
||||
return (sqrt(loc_m[0]*loc_m[0] + loc_m[1]*loc_m[1]));
|
||||
}
|
||||
|
||||
inline double get_phi(const vec3 &loc_m) {
|
||||
if (loc_m[0] >= 0) {
|
||||
return ( acos(loc_m[1]/get_r_m(loc_m)) );
|
||||
} else {
|
||||
return ( 2*pi - acos(loc_m[1]/get_r_m(loc_m)) );
|
||||
}
|
||||
return(vec3(sin(theta_new)*cos(phi_new) , sin(theta_new)*sin(phi_new) , cos(theta_new)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user