Change in Parameter: input parameter numTotalElectrons changed to numberTotalDecays. Now running until number of decays happend, for better time scale.
This commit is contained in:
@@ -24,7 +24,7 @@ Parameter::Parameter() {
|
|||||||
// Simulation Specs
|
// Simulation Specs
|
||||||
|
|
||||||
seed = (int)getValue("seed");
|
seed = (int)getValue("seed");
|
||||||
numTotalElectrons = (long int)getValue("numTotalElectrons");
|
numberTotalDecays = (long int)getValue("numberTotalDecays");
|
||||||
dt_s = getValue("dt_s");
|
dt_s = getValue("dt_s");
|
||||||
injectionMethod = (int)getValue("injectionMethod");
|
injectionMethod = (int)getValue("injectionMethod");
|
||||||
deltaKinEnergy_eV = getValue("deltaKinEnergy_eV");
|
deltaKinEnergy_eV = getValue("deltaKinEnergy_eV");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
//Simulation Specs
|
//Simulation Specs
|
||||||
int seed ;
|
int seed ;
|
||||||
long int numTotalElectrons;
|
long int numberTotalDecays;
|
||||||
double dt_s;
|
double dt_s;
|
||||||
int injectionMethod; // 0 = Beta Decay, 1 = Delta, 2 = Maxwell Boltzmann
|
int injectionMethod; // 0 = Beta Decay, 1 = Delta, 2 = Maxwell Boltzmann
|
||||||
double deltaKinEnergy_eV;
|
double deltaKinEnergy_eV;
|
||||||
|
|||||||
@@ -17,42 +17,42 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
Simulation::Simulation() {
|
Simulation::Simulation() {
|
||||||
numberElectrons = 0;
|
numberTotalElectrons = 0;
|
||||||
|
numberDecays = 0;
|
||||||
rngUni.seed(seed);
|
rngUni.seed(seed);
|
||||||
updater_fraction = numTotalElectrons/100;
|
updater_fraction = numberTotalDecays/100;
|
||||||
updater_numberOfPrevious = 0;
|
updater_numberOfPrevious = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Simulation::doit() {
|
void Simulation::doit() {
|
||||||
vec3 oldLoc_m;
|
Electron *actionElectronPtr;
|
||||||
while ( (numberElectrons < numTotalElectrons) || (electronQue.size() > 0) ) {
|
while ( (numberDecays < numberTotalDecays) || (electronQue.size() > 0) ) {
|
||||||
if (electronQue.empty()) {
|
if (electronQue.empty()) {
|
||||||
electronQue.push_back(Kat.injectElectron(numberElectrons++, &rngUni, &rngNormal));
|
electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal));
|
||||||
|
numberDecays++;
|
||||||
}
|
}
|
||||||
|
actionElectronPtr = &electronQue.front();
|
||||||
status_updater();
|
do_statusUpdate();
|
||||||
move_electron(&electronQue.front(), &Log);
|
move_electron(actionElectronPtr, &Log);
|
||||||
if (!Kat.check_Termination (electronQue.front()) ) {
|
if (!Kat.check_Termination (*actionElectronPtr) ) {
|
||||||
do_interaction(&electronQue.front());
|
do_interaction(actionElectronPtr);
|
||||||
}
|
}
|
||||||
if (Kat.check_Termination (electronQue.front())) {
|
if (Kat.check_Termination (*actionElectronPtr)) {
|
||||||
electronQue.pop_front();
|
electronQue.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Simulation::doTC6() {
|
void Simulation::doTC6() {
|
||||||
cout<<endl<<"Simulation::doTC6: Doing Testcase 6."<<endl<<endl;
|
cout<<endl<<"Simulation::doTC6: Doing Testcase 6."<<endl<<endl;
|
||||||
parameterCheck_TC6();
|
parameterCheck_TC6();
|
||||||
|
|
||||||
while ( (numberElectrons < numTotalElectrons) || (electronQue.size() > 0) ) {
|
while ( (numberTotalElectrons < numberTotalDecays) || (electronQue.size() > 0) ) {
|
||||||
if (!electronQue.empty()) {
|
if (!electronQue.empty()) {
|
||||||
throw MyException("Simulation::doTC6: electronQue should be empty");
|
throw MyException("Simulation::doTC6: electronQue should be empty");
|
||||||
}
|
}
|
||||||
electronQue.push_back(Kat.injectElectron(numberElectrons++, &rngUni, &rngNormal));
|
electronQue.push_back(Kat.injectElectron(numberTotalElectrons++, &rngUni, &rngNormal));
|
||||||
do_interaction(&electronQue.front()); //parameter should only allow for ionizations
|
do_interaction(&electronQue.front()); //parameter should only allow for ionizations
|
||||||
electronQue.pop_front(); // delete initial electron
|
electronQue.pop_front(); // delete initial electron
|
||||||
Log.log_Electron(&electronQue.front(), vec3(0,0,0)); //should be daugther electron
|
Log.log_Electron(&electronQue.front(), vec3(0,0,0)); //should be daugther electron
|
||||||
@@ -60,12 +60,12 @@ void Simulation::doTC6() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Simulation::status_updater() {
|
void Simulation::do_statusUpdate() {
|
||||||
if (numberElectrons%updater_fraction == 0){
|
if (numberDecays%updater_fraction == 0){
|
||||||
if (updater_numberOfPrevious!=numberElectrons) {
|
if (updater_numberOfPrevious!=numberDecays) {
|
||||||
cout<<numberElectrons<<"/"<<numTotalElectrons<<endl;
|
cout<<numberDecays<<"/"<<numberTotalDecays<<endl;
|
||||||
}
|
}
|
||||||
updater_numberOfPrevious = numberElectrons;
|
updater_numberOfPrevious = numberDecays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ void Simulation::do_interaction(Electron *interactElectron) {
|
|||||||
interactElectron->do_elaScattering(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni);
|
interactElectron->do_elaScattering(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal) , &rngUni);
|
||||||
break;
|
break;
|
||||||
case 2: // Ionization
|
case 2: // Ionization
|
||||||
electronQue.push_back( interactElectron->do_Ionization(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal), numberElectrons, &rngUni) );
|
electronQue.push_back( interactElectron->do_Ionization(Kat.getTotSpeedT2_ms(newLoc_m, &rngUni, &rngNormal), numberTotalElectrons, &rngUni) );
|
||||||
numberElectrons++;
|
numberTotalElectrons++;
|
||||||
// Update Ions...
|
// Update Ions...
|
||||||
break;
|
break;
|
||||||
case 3: // Recombination
|
case 3: // Recombination
|
||||||
|
|||||||
@@ -22,21 +22,19 @@
|
|||||||
class Simulation: private Parameter, private Constants {
|
class Simulation: private Parameter, private Constants {
|
||||||
public:
|
public:
|
||||||
Simulation();
|
Simulation();
|
||||||
|
|
||||||
void doit();
|
void doit();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void status_updater();
|
void do_statusUpdate();
|
||||||
void move_electron(Electron *moveElectron, Logger *Log);
|
void move_electron(Electron *moveElectron, Logger *Log);
|
||||||
void do_interaction(Electron *interactElectron);
|
void do_interaction(Electron *interactElectron);
|
||||||
|
|
||||||
|
|
||||||
// Simulation
|
|
||||||
Katrin Kat;
|
Katrin Kat;
|
||||||
Logger Log;
|
Logger Log;
|
||||||
ranlib::Uniform<double> rngUni;
|
ranlib::Uniform<double> rngUni;
|
||||||
ranlib::NormalUnit<double> rngNormal;
|
ranlib::NormalUnit<double> rngNormal;
|
||||||
int numberElectrons;
|
int numberTotalElectrons;
|
||||||
|
int numberDecays;
|
||||||
std::deque<Electron> electronQue;
|
std::deque<Electron> electronQue;
|
||||||
int updater_numberOfPrevious;
|
int updater_numberOfPrevious;
|
||||||
int updater_fraction;
|
int updater_fraction;
|
||||||
|
|||||||
Reference in New Issue
Block a user