// // simulation.cpp // mc_electron // // Created by Christian Reiling on 20.09.18. // Copyright © 2018 Christian Reiling. All rights reserved. // #include "simulation.hpp" #include "constants.hpp" #include "functions.hpp" #include "fstream" using namespace std; const long int Simulation::seed = getParameter("seed"); const long int Simulation::numberTotalDecays = getParameter("numberTotalDecays"); const int Simulation::propagationMethod = getParameter("propagationMethod"); const int Simulation::maxInteractions = getParameter("maxInteractions"); Simulation::Simulation() { rngUni.seed(seed); updater_fraction = numberTotalDecays/100; } void Simulation::doit() { while ( (numberDecays < numberTotalDecays) || (!electronQue.empty()) || (!tritiumIonQue.empty()) ) { if (electronQue.empty() && tritiumIonQue.empty()) { electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal)); numberDecays++; } do_statusUpdate(); if (!electronQue.empty()) { process_firstElectron(); } else { process_firstTIon(); } } }; void Simulation::process_firstElectron() { int numberInteractionsThisElectron = 0; actionElectronPtr = &electronQue.front(); while (!Kat.check_Termination (*actionElectronPtr) && !check_NumberInteractions(numberInteractionsThisElectron)) { move_electron(actionElectronPtr, &Log); if (!Kat.check_Termination (*actionElectronPtr) ) { do_interaction(actionElectronPtr); } } electronQue.pop_front(); } void Simulation::process_firstTIon() { } bool Simulation::check_NumberInteractions(int &numberInteractionsThisElectron) { if (maxInteractions == 0) { return(false); } if (numberInteractionsThisElectron < maxInteractions) { numberInteractionsThisElectron++; return(false); } else { return(true); } } void Simulation::doTC6() { cout< 0) ) { if (!electronQue.empty()) { throw MyException("Simulation::doTC6: electronQue should be empty"); } electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal)); do_interaction(&electronQue.front()); //parameter should only allow for ionizations electronQue.pop_front(); // delete initial electron Log.log_Electron(&electronQue.front(), vec3(0,0,0)); //should be daugther electron electronQue.pop_front(); //delete daugther electron } }; void Simulation::do_statusUpdate() { if (numberDecays%updater_fraction == 0){ if (updater_numberOfPrevious!=numberDecays) { cout<roll_Interaction(Kat.getFlowSpeedT2_ms(newLoc_m),&rngUni); switch (process) { case 1: // Elastic Scattering interactElectron->do_elaScattering(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni); break; case 2: // Ionization electronQue.push_back( interactElectron->do_Ionization(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal), numberTotalElectrons, &rngUni) ); numberTotalElectrons++; // Update Ions... break; case 3: // Recombination break; default: stringstream ss; ss<<"Simulation::do_interaction: process="<