Files
katrin-plasma/src/mc_electron/particle.cpp
T
Christian d06afad131 Added T5+ Interactions.
Preparing for adding direction dependend electron Containers.
2019-09-16 16:14:13 +02:00

141 lines
2.6 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;
std::string get_species_string(const species &spec) {
string res;
switch (spec) {
case electron:
res = "e-";
break;
case tritium:
res = "T";
break;
case tritiumI:
res = "T+";
break;
case tritium2I:
res = "T2+";
break;
case tritium2:
res = "T2";
break;
case tritium3I:
res = "T3+";
break;
case tritium5I:
res = "T5+";
break;
default:
stringstream ss;
ss<<"get_species_string: Species not defined\n";
throw MyException(ss.str());
}
return res;
}
std::vector<species> get_all_species_vector() {
std::vector<species> all;
all.push_back(electron);
all.push_back(tritium);
all.push_back(tritiumI);
all.push_back(tritium2I);
all.push_back(tritium2);
all.push_back(tritium3I);
all.push_back(tritium5I);
return all;
};
species get_species_from_string(const std::string &species_string) {
std::vector<species> all = get_all_species_vector();
for (std::vector<species>::iterator itr = all.begin(); itr!= all.end(); itr++) {
if (get_species_string(*itr) == species_string) {
return *itr;
}
}
stringstream ss;
ss<<"get_species_from_string: Species not defined\n";
throw MyException(ss.str());
}
double get_species_mass(const species &spec) {
double res;
switch (spec) {
case electron:
res = me_eV;
break;
case tritium:
res = mT_eV;
break;
case tritiumI:
res = mT_eV;
break;
case tritium2I:
res = 2*mT_eV;
break;
case tritium2:
res = 2*mT_eV;
break;
case tritium3I:
res = 3*mT_eV;
break;
case tritium5I:
res = 3*mT_eV;
break;
default:
stringstream ss;
ss<<"get_species_mass: Species not defined\n";
throw MyException(ss.str());
}
return res;
}
ostream& operator<<(ostream& os, const species& spec) {
os<<get_species_string(spec);
return os;
}
ostream& operator<<(ostream& os, const Particle& partOut) {
os
<< partOut.Id << ";"
<<partOut.PId << ";"
<<partOut.spec << ";"
<<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 m_eV, double Z, vec3 x_m, vec3 v_ms, double Id, double PId, species spec) {
this->m_eV = m_eV;
this->Z = Z;
this->x_m = x_m;
this->v_ms = v_ms;
this->Id = Id;
this->PId = PId;
this->spec = spec;
calc_E_eV();
}
void Particle::calc_E_eV() {
E_eV = calc_E_eV_from_v_ms(v_ms, m_eV);
}