95 lines
2.7 KiB
C++
Executable File
95 lines
2.7 KiB
C++
Executable File
#ifndef SIMULATION_H
|
|
#define SIMULATION_H
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "simulation/parameter.h"
|
|
#include "simulation/particle.h"
|
|
|
|
class RandomNumbers;
|
|
class InteractionOutput;
|
|
class MagneticField;
|
|
class ElectricField;
|
|
class GravityField;
|
|
class Timer;
|
|
class Injector;
|
|
class SimulationOutput;
|
|
class CpuSynchronizer;
|
|
class PoissonSolver;
|
|
|
|
namespace species {
|
|
class Specie;
|
|
};
|
|
|
|
namespace interaction {
|
|
class InteractionOutput;
|
|
};
|
|
|
|
class Simulation {
|
|
public:
|
|
Simulation(std::string parameter_filename);
|
|
|
|
void init(Parameter& parameter);
|
|
void start();
|
|
void finalize();
|
|
void processEvents(int events);
|
|
|
|
void processDensityEvents(int particles_per_bin, const double weight_factor);
|
|
void processUntilTermination(particle::Particle& particle);
|
|
|
|
private:
|
|
std::vector<particle::Particle> determineInjectedDensityParticles(
|
|
RandomNumbers* random,
|
|
const double weight_factor,
|
|
const int current,
|
|
std::map<std::string, double>& particleNumbers,
|
|
bool& all_bins_done);
|
|
|
|
// draw the individual collision times of the possible interactions and return the
|
|
// minimum of them. Also sets the "nextInteractionIndex" in the particle to the
|
|
// interaction of the chosen time.
|
|
void collisionTime(particle::Particle& particle, RandomNumbers* random);
|
|
interaction::InteractionOutput interact(particle::Particle& particle,
|
|
RandomNumbers* random);
|
|
|
|
interaction::InteractionOutput interact(particle::Particle& particle,
|
|
RandomNumbers* random,
|
|
std::vector<double>& macroscopic_cross_sections_m);
|
|
|
|
blitz::Array<double,3> chargedensity();
|
|
|
|
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_;
|
|
std::shared_ptr<GravityField> gravity_field_;
|
|
|
|
std::shared_ptr<PoissonSolver> poisson_solver_;
|
|
|
|
Parameter parameter_;
|
|
std::shared_ptr<RandomNumbers> random_;
|
|
|
|
std::shared_ptr<Timer> timer_;
|
|
|
|
std::shared_ptr<SimulationOutput> output_;
|
|
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
|
|
|
std::vector<particle::Particle> queue_;
|
|
std::vector<particle::SerializedParticle> storage_queue_[2];
|
|
|
|
int active_storage = 0;
|
|
int inactive_storage = 1;
|
|
|
|
int timestep = 0;
|
|
int injectionGroupOffset = 0;
|
|
};
|
|
|
|
#endif /* SIMULATION_H */
|