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,118 @@
|
||||
//
|
||||
// electron_boris.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 16.05.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef electron_boris_h
|
||||
#define electron_boris_h
|
||||
|
||||
#include "mover_base.h"
|
||||
|
||||
|
||||
class E_Mover_Boris : public Mover_Base {
|
||||
double dt_s;
|
||||
public:
|
||||
E_Mover_Boris(double dt_s, Particle_Logger_Base *Logger, Population_Base *Population) : Mover_Base(electron, Logger, Population) {
|
||||
this->dt_s = dt_s;
|
||||
};
|
||||
|
||||
void move(Particle *movePart, const double &distance_m);
|
||||
|
||||
private:
|
||||
double doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T);
|
||||
void doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T);
|
||||
bool doBoris_WallInteraction(Particle *movePart);
|
||||
void doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m);
|
||||
};
|
||||
|
||||
void E_Mover_Boris::move(Particle *movePart, const double &distance_m) {
|
||||
// Prepare detection for change of z direction for logging
|
||||
double oldzDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
vec3 oldLoc_m = movePart->get_Location_m();
|
||||
|
||||
double traveledDistance_m = 0;
|
||||
vec3 loc_m, E_Vm ,B_T;
|
||||
while (traveledDistance_m < distance_m) {
|
||||
loc_m = movePart->get_Location_m();
|
||||
E_Vm = Katrin_Fields::getElField_Vm(loc_m);
|
||||
B_T = Katrin_Fields::getMagField_T(loc_m);
|
||||
|
||||
traveledDistance_m += doBoris_singleStep_m(movePart, E_Vm, B_T);
|
||||
if (doBoris_WallInteraction(movePart) == true) {
|
||||
Logger->log(*movePart, oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
doBoris_LogzDirChange(movePart, &oldzDir, &oldLoc_m); // Log if z direction changes, and adapt quantities
|
||||
}
|
||||
Logger->log(*movePart,oldLoc_m);
|
||||
Population->increase_density(*movePart, oldLoc_m);
|
||||
return;
|
||||
}
|
||||
|
||||
double E_Mover_Boris::doBoris_singleStep_m(Particle *movePart, const vec3 &E_Vm , const vec3 &B_T) {
|
||||
double distance_m;
|
||||
vec3 x_m = movePart->get_Location_m();
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m = dt_s/2 * vec3Abs(v_ms);
|
||||
doBoris_speedChange(movePart, E_Vm , B_T);
|
||||
x_m += dt_s/2 * v_ms;
|
||||
distance_m += dt_s/2 * vec3Abs(v_ms);
|
||||
movePart->set_Location_m(x_m);
|
||||
return(distance_m);
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_speedChange(Particle *movePart, const vec3 &E_Vm, const vec3 &B_T) {
|
||||
double q_C = movePart->get_Charge_nat() * e_C;
|
||||
double m_kg = movePart->get_Mass_eV() * e_C/c_ms/c_ms;
|
||||
vec3 v_ms = movePart->get_Speed_ms();
|
||||
|
||||
vec3 t = q_C*dt_s/(2*m_kg) * B_T;
|
||||
vec3 s = (2*t)/(1+dot(t,t));
|
||||
vec3 vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
|
||||
vec3 vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
|
||||
vec3 vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
|
||||
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
|
||||
movePart->set_Speed_ms(v_ms);
|
||||
}
|
||||
|
||||
bool E_Mover_Boris::doBoris_WallInteraction(Particle *movePart) {
|
||||
vec3 loc_m = movePart->get_Location_m();
|
||||
double r_m = movePart->get_Radius_m();
|
||||
if (loc_m[2]<=Katrin_Geo::get_z_RW_m()) { // Rear Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
newLoc_m[2] = 0;
|
||||
movePart->set_Location_m(newLoc_m);
|
||||
return (true);
|
||||
}
|
||||
if (r_m>=Katrin_Geo::get_radius_m()) { // WGTS Wall Termination
|
||||
vec3 newLoc_m = movePart->get_Location_m();
|
||||
double z_m = newLoc_m[2];
|
||||
newLoc_m[2] = 0;
|
||||
newLoc_m = (Katrin_Geo::get_radius_m() * 1.01)/vec3Abs(newLoc_m) * newLoc_m; //1.01 to move Particle slightly out of WGTS
|
||||
newLoc_m[2] = z_m;
|
||||
return (true);
|
||||
}
|
||||
if (loc_m[2]>=Katrin_Geo::get_z_WGTSend_m()) { // Spectrometer Reflection
|
||||
movePart->set_Speed_ms( -1*(movePart->get_Speed_ms()) );
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
void E_Mover_Boris::doBoris_LogzDirChange(Particle *movePart, double *oldzDir, vec3 *oldLoc_m) {
|
||||
double zDir = movePart->get_Speed_ms()[2] < 0 ? -1 : 1;
|
||||
if (*oldzDir != zDir) {
|
||||
Logger->log(*movePart, *oldLoc_m);
|
||||
Population->increase_density(*movePart, *oldLoc_m);
|
||||
*oldzDir = zDir;
|
||||
*oldLoc_m = movePart->get_Location_m();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif /* electron_boris_h */
|
||||
Reference in New Issue
Block a user