Files
katrin-plasma/src/mc_electron/particle.cpp
T
Christian e77176cc76 Multiple Changes:
Conceptional Change, where terminated Particles were set to Energy = 0. Now Particles are just moved within mover and termination detects, position and starts Interaction only if particle remains in tank.

Added function_container: Filled with anker points and get values corresponding to input by interpolation. 2D Interpolation needs improvement. CSV-Read in function needs error checks of input file.
Changes in katrin class: Boris Push and Drift Approximation improved.
Minor Renamings.
2019-03-18 13:51:41 +01:00

99 lines
2.1 KiB
C++

//
// particle.cpp
// mc_electron
//
// Created by Christian Reiling on 20.09.18.
// Copyright © 2018 Christian Reiling. All rights reserved.
//
#include "particle.hpp"
using namespace std;
// Overload <<
ostream& operator<<(ostream& os, const species& SpecOut) {
switch (SpecOut) {
case undef:
os<<"undef";
break;
case electron:
os<<"e-";
break;
case positron:
os<<"e+";
break;
case proton:
os<<"p";
break;
case tritium:
os<<"T3";
break;
case tritium2:
os<<"T_2";
break;
case helium:
os<<"He3";
break;
case deuterium:
os<<"D2";
break;
case DT:
os<<"DT";
break;
default:
os<<"";
}
return (os);
}
ostream& operator<<(ostream& os, const Particle& partOut) {
os
<< partOut.Id << ";"
<<partOut.parentId << ";"
<<partOut.s << ";"
<<partOut.m_eV << ";"
<< partOut.Z << ";"
<< partOut.x_m[0] << ";"
<< partOut.x_m[1] << ";"
<< partOut.x_m[2] << ";"
<< partOut.v_ms[0] << ";"
<< partOut.v_ms[1] << ";"
<< partOut.v_ms[2] ;
return os;
}
Particle::Particle(double mass_eV, double charge_e,vec3 loc_m, vec3 speed_ms, double idnum, double parentIdnum, species spec) {
m_eV = mass_eV;
Z = charge_e;
x_m = loc_m;
v_ms = speed_ms;
Id = idnum;
parentId = parentIdnum;
s = spec;
}
double Particle::do_BorisStep_m(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s) {
double distance_m;
x_m += dt_s/2 * v_ms;
distance_m = dt_s/2 * get_SpeedAbs_ms();
this->doBoris_SpeedChange(E_Vm , B_T , dt_s);
x_m += dt_s/2 * v_ms;
distance_m += dt_s/2 * get_SpeedAbs_ms();
return(distance_m);
}
void Particle::doBoris_SpeedChange(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s) {
blitz::TinyVector<double, 3> vMinus_ms, vPlus_ms, vPrime_ms, t, s;
double q_C = -1*Z * e_C;
double m_kg = m_eV*e_C/c_ms/c_ms;
t = q_C*dt_s/(2*m_kg) * B_T;
s = (2*t)/(1+dot(t,t));
vMinus_ms = v_ms + (q_C*E_Vm*dt_s)/(2*m_kg);
vPrime_ms = vMinus_ms + cross(vMinus_ms,t);
vPlus_ms = vMinus_ms + cross(vPrime_ms,s);
v_ms = vPlus_ms + q_C/m_kg*E_Vm*0.5*dt_s;
}