#ifndef SIMULATION_H #define SIMULATION_H #include #include #include #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_queue); private: // function to create particles from the injector (i.e. the event particles) // also increases the time in the Timer object std::vector 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& 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& macroscopic_cross_sections_m); std::map> tracked_species_; std::map> background_species_; std::shared_ptr injector_; std::shared_ptr magnetic_field_; std::shared_ptr electric_field_; Parameter parameter_; std::shared_ptr random_; std::shared_ptr timer_; std::shared_ptr output_; std::shared_ptr cpu_synchronizer_; }; #endif /* SIMULATION_H */