Moved serial mode to target mcelecron_serial.
Implemented parallelization with mpi.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// simulation_serial.cpp
|
||||
// mc_electron_serial
|
||||
//
|
||||
// Created by Christian Reiling on 17.07.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#include "simulation_serial.hpp"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const long int Simulation::seed = load_parameter("seed");
|
||||
const long int Simulation::numberTotalDecays = load_parameter("numberTotalDecays");
|
||||
const long int Simulation::simulationStepWidth = load_parameter("simulationStepWidth");
|
||||
|
||||
std::string Simulation::calc_outfile_path() {
|
||||
string parname = get_parameter_filenamepath();
|
||||
stringstream H5name;
|
||||
int i = 1;
|
||||
do {
|
||||
H5name.str(std::string());
|
||||
H5name << parname << "_" << get_time_string() << "_" << i++<<".h5";
|
||||
} while ( is_file(H5name.str()) );
|
||||
return H5name.str();
|
||||
}
|
||||
|
||||
void Simulation::doit() {
|
||||
int num_cycles = numberTotalDecays/simulationStepWidth;
|
||||
int num_remaining = numberTotalDecays%simulationStepWidth;
|
||||
for (int i = 0; i<(num_cycles-1); i++) {
|
||||
do_decays(simulationStepWidth);
|
||||
}
|
||||
do_decays(simulationStepWidth + num_remaining);
|
||||
cout<<"Total particles: "<<looper.get_number_total_particles()<<"\n";
|
||||
};
|
||||
|
||||
void Simulation::do_decays(int number_decays) {
|
||||
looper.do_loops(number_decays);
|
||||
number_current_decays += number_decays;
|
||||
do_statusUpdate();
|
||||
}
|
||||
|
||||
void Simulation::do_statusUpdate() {
|
||||
cout<<number_current_decays<<"/"<<numberTotalDecays<<endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user