Changes to Interaction Processor, making possible to add infinite Interactions for all kind of Particles
This commit is contained in:
@@ -19,60 +19,42 @@ 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));
|
||||
InteractionOut IntOut;
|
||||
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
||||
if (partQue.empty()) {
|
||||
curPart = Inj.injectElectron(numberTotalElectrons);
|
||||
numberDecays++;
|
||||
}
|
||||
do_statusUpdate();
|
||||
if (!electronQue.empty()) {
|
||||
process_firstElectron();
|
||||
numberTotalElectrons++;
|
||||
do_statusUpdate();
|
||||
} else {
|
||||
process_firstTIon();
|
||||
curPart = partQue.front();
|
||||
partQue.pop_front();
|
||||
}
|
||||
while (!Term.check_Termination(curPart)) {
|
||||
mfp = 1/Inter.get_macroSigma_m2(curPart);
|
||||
Mov.moveParticle(&curPart, mfp);
|
||||
if (!Term.check_Termination(curPart)) {
|
||||
IntOut = Inter.do_Interaction(&curPart);
|
||||
//appy_Inter_Output(IntOut);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
void Simulation::do_statusUpdate() {
|
||||
if (numberDecays%updater_fraction == 0){
|
||||
if (updater_numberOfPrevious!=numberDecays) {
|
||||
cout<<numberDecays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
}
|
||||
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);
|
||||
updater_numberOfPrevious = numberDecays;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void Simulation::doTC6() {
|
||||
cout<<endl<<"Simulation::doTC6: Doing Testcase 6."<<endl<<endl;
|
||||
parameterCheck_TC6();
|
||||
@@ -89,28 +71,6 @@ void Simulation::doTC6() {
|
||||
}
|
||||
};
|
||||
|
||||
void Simulation::do_statusUpdate() {
|
||||
if (numberDecays%updater_fraction == 0){
|
||||
if (updater_numberOfPrevious!=numberDecays) {
|
||||
cout<<numberDecays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
updater_numberOfPrevious = numberDecays;
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::move_electron(Electron *moveElectron, H5_Logger *Log) {
|
||||
double MFP_m = Kat.get_MFP_m(&electronQue.front());
|
||||
if (propagationMethod==0) {
|
||||
Kat.do_DriftApproximationMovement(moveElectron, MFP_m, Log);
|
||||
} else if (propagationMethod==1) {
|
||||
Kat.do_BorisPushMovement(moveElectron, MFP_m, Log); // If moved outside set v = 0,0,0;
|
||||
} else {
|
||||
stringstream ss;
|
||||
ss<<"Simulation::move_electron: propagationMethod="<<propagationMethod<<" not valid.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::do_interaction(Electron *interactElectron) {
|
||||
vec3 newLoc_m = electronQue.front().get_Location_m();
|
||||
if (Kat.check_Termination(*interactElectron)) {
|
||||
@@ -118,13 +78,13 @@ void Simulation::do_interaction(Electron *interactElectron) {
|
||||
ss<<"Simulation::do_interaction: Particle already terminated.";
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
int process = interactElectron->roll_Interaction(Kat.getFlowSpeedT2_ms(newLoc_m),&rngUni);
|
||||
int process = interactElectron->roll_Interaction(Kat.get_T2_flowSpeed_ms(newLoc_m),&rngUni);
|
||||
switch (process) {
|
||||
case 1: // Elastic Scattering
|
||||
interactElectron->do_elaScattering(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni);
|
||||
interactElectron->do_elaScattering(Kat.roll_T2_speed_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) );
|
||||
electronQue.push_back( interactElectron->do_Ionization(Kat.roll_T2_speed_ms(newLoc_m, &rngUni, &rngNormal), numberTotalElectrons, &rngUni) );
|
||||
numberTotalElectrons++;
|
||||
// Update Ions...
|
||||
break;
|
||||
@@ -151,3 +111,4 @@ void Simulation::parameterCheck_TC6() {
|
||||
throw MyException("Simulation::parameterCheck_TC6: Some Parameter is wrong");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user