Major changes:
- Moved to array operations for main loops. - Changed to setting pointers to operator only once before loop. - Changed Population Containers - Added Recombination - Added Inelastic Scattering Kinematics - Reworked Elastic Scattering Cross Section - Reworked Elastic Scattering Kinematics - Reworked organisation of different particle species and corresponding operators
This commit is contained in:
@@ -13,15 +13,19 @@ using namespace std;
|
||||
|
||||
const long int Simulation::seed = getParameter("seed");
|
||||
const long int Simulation::numberTotalDecays = getParameter("numberTotalDecays");
|
||||
const int Simulation::maxInteractions = getParameter("maxInteractions");
|
||||
|
||||
void Simulation::init_Simulation() {
|
||||
void Simulation::init() {
|
||||
set_RNGs();
|
||||
Tim = Timer(&numberDecays);
|
||||
Pop = Population_Builder::build_Population(&Tim, &rngUni, &rngNormal);
|
||||
Inj = Injector(&rngUni, &rngNormal);
|
||||
Mov = Mover(&Log);
|
||||
Inter = InteractionBuilder::build_InteractionProcessor(&Pop, &rngUni, &rngNormal);
|
||||
|
||||
timer = Timer(&numberDecays);
|
||||
loggers = Particle_Logger_Builder::build(&h5f);
|
||||
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
||||
|
||||
injector = Injector(&rngUni, &rngNormal);
|
||||
movers = Mover_Builder::build(&loggers, &populations);
|
||||
interactions = Interaction_Builder::build(&populations, &rngUni);
|
||||
terminators = Terminator_Builder::build();
|
||||
|
||||
set_statusUpdater();
|
||||
}
|
||||
|
||||
@@ -36,6 +40,11 @@ void Simulation::set_statusUpdater() {
|
||||
}
|
||||
|
||||
void Simulation::doit() {
|
||||
Mover_Base *moverPtr;
|
||||
Interaction_Base *interactionPtr;
|
||||
Terminator_Base *terminatorPtr;
|
||||
|
||||
|
||||
InteractionOut IntOut;
|
||||
double mfp;
|
||||
std::deque<Particle> partQue;
|
||||
@@ -43,7 +52,7 @@ void Simulation::doit() {
|
||||
vec3 oldLoc_m;
|
||||
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
||||
if (partQue.empty()) {
|
||||
curPart = Inj.injectElectron(numberTotalParticles);
|
||||
curPart = injector.injectElectron(numberTotalParticles);
|
||||
numberDecays++;
|
||||
numberTotalParticles++;
|
||||
do_statusUpdate();
|
||||
@@ -51,16 +60,24 @@ void Simulation::doit() {
|
||||
curPart = partQue.front();
|
||||
partQue.pop_front();
|
||||
}
|
||||
moverPtr = movers.find(curPart.get_species());
|
||||
interactionPtr = interactions.find(curPart.get_species());
|
||||
terminatorPtr = terminators.find(curPart.get_species());
|
||||
|
||||
while (!Term.check_Termination(curPart)) {
|
||||
|
||||
while (!terminatorPtr->checkTermination(curPart)) {
|
||||
oldLoc_m = curPart.get_Location_m();
|
||||
mfp = 1/Inter.get_macroSigma_m2(curPart);
|
||||
Mov.moveParticle(&curPart, mfp);
|
||||
Pop.up_Denisty(oldLoc_m, curPart);
|
||||
if (!Term.check_Termination(curPart)) {
|
||||
IntOut = Inter.do_Interaction(&curPart);
|
||||
IntOut.appendDeque(&partQue, &numberTotalParticles);
|
||||
if (IntOut.terminateCurrent()) {
|
||||
mfp = 1/interactionPtr->get_macroSigma_m2(curPart);
|
||||
moverPtr->move(&curPart, mfp);
|
||||
if (!terminatorPtr->checkTermination(curPart)) {
|
||||
IntOut = interactionPtr->do_Interaction(&curPart);
|
||||
for (int i=0; i<IntOut.get_number_new_particles(); i++) {
|
||||
partQue.push_back(IntOut.get_new_particles()[i]);
|
||||
}
|
||||
if (IntOut.get_delete_density()) {
|
||||
// Decrease Density by one now.
|
||||
}
|
||||
if (IntOut.get_delete_current()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -68,6 +85,8 @@ void Simulation::doit() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void Simulation::do_statusUpdate() {
|
||||
if (numberDecays%updater_fraction == 0){
|
||||
if (updater_numberOfPrevious!=numberDecays) {
|
||||
|
||||
Reference in New Issue
Block a user