// // 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 get_all_species_vector() { std::vector 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 all = get_all_species_vector(); for (std::vector::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<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); }