99 lines
3.3 KiB
C++
Executable File
99 lines
3.3 KiB
C++
Executable File
#ifndef SIMULATION_H
|
|
#define SIMULATION_H
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "simulation/parameter.h"
|
|
#include "simulation/particle.h"
|
|
|
|
// defined in "simulation/random_numbers.h"
|
|
class RandomNumbers;
|
|
// defined in "simulation/interaction.h"
|
|
class InteractionOutput;
|
|
// defined in "simulation/electromagnetic_field.h"
|
|
class MagneticField;
|
|
class ElectricField;
|
|
// defined in "simulation/timer.h"
|
|
class Timer;
|
|
// defined in "simulation/injector.h"
|
|
class Injector;
|
|
// defined in "IO/simulation_output.h"
|
|
class SimulationOutput;
|
|
// defined in "simulation/cpu_synchronizer.h"
|
|
class CpuSynchronizer;
|
|
|
|
// defined in "simulation/species.h"
|
|
namespace species {
|
|
class Specie;
|
|
};
|
|
|
|
// defined in "simulation/interaction.h"
|
|
namespace interaction {
|
|
class InteractionOutput;
|
|
};
|
|
|
|
class Simulation {
|
|
public:
|
|
// Constructor: initialize everything using the json file at the path in parameter_filename
|
|
Simulation(std::string parameter_filename);
|
|
|
|
// function for initialization from Parameter object
|
|
void init(Parameter& parameter);
|
|
// function for main simulation loop
|
|
void start();
|
|
// function to finalize simulation
|
|
void finalize();
|
|
// process events until "events" number of beta decay chains have been
|
|
// simulated until completion
|
|
void processEvents(int events);
|
|
// process the Particle particle until it is terminated
|
|
// any interaction product created during the interactions during the propagation of
|
|
// particle are appened to the vector particle_queue
|
|
void processUntilTermination(particle::Particle& particle,
|
|
std::vector<particle::Particle>& particle_queue);
|
|
|
|
private:
|
|
// function to create particles from the injector (i.e. the event particles)
|
|
// also increases the time in the Timer object
|
|
std::vector<particle::Particle> determineInjectedParticles(
|
|
RandomNumbers* random);
|
|
|
|
// calculate the mean free path for the Particle particle
|
|
// the calculated target density scaled cross sections are then
|
|
// appened to the vector macroscopic_cross_sections_m to be used
|
|
// later in the interact function (to avoid an unneccessary recalculation)
|
|
double meanFreePath(particle::Particle& particle, RandomNumbers* random,
|
|
std::vector<double>& macroscopic_cross_sections_m);
|
|
|
|
// randomly chooses the interaction the particle will experience by
|
|
// using the values in the macroscopic_cross_sections_m vector (does NOT have to be normalized)
|
|
// as the relative weight for the corresponding interaction to occur
|
|
// afterwards perform the interaction and return the
|
|
// output of the as an InteractionOutput object
|
|
interaction::InteractionOutput interact(particle::Particle& particle,
|
|
RandomNumbers* random,
|
|
std::vector<double>& macroscopic_cross_sections_m);
|
|
|
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
|
tracked_species_;
|
|
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
|
background_species_;
|
|
|
|
std::shared_ptr<Injector> injector_;
|
|
|
|
std::shared_ptr<MagneticField> magnetic_field_;
|
|
std::shared_ptr<ElectricField> electric_field_;
|
|
|
|
Parameter parameter_;
|
|
std::shared_ptr<RandomNumbers> random_;
|
|
|
|
std::shared_ptr<Timer> timer_;
|
|
|
|
std::shared_ptr<SimulationOutput> output_;
|
|
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
|
};
|
|
|
|
#endif /* SIMULATION_H */
|