Files
karl/include/simulation/simulation.h
T
csendlinger 76a93f5aa4 Electrons are explicitly stored between timesteps
and can be dumped using MPI-IO.
Restarts read particles from earlier output.
2025-08-11 09:18:51 +02:00

107 lines
3.1 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();
// cpu_syncs only included for debug purposes, e.g. only drawing decay particles
// at the 0th timestep
void processEvents(int events, const double beta_particle_weight);
void processDensityEvents(int particles_per_bin, const double weight_factor);
void processUntilTermination(particle::Particle& particle);
private:
std::vector<particle::Particle> determineInjectedParticles(RandomNumbers* random,
const double beta_particle_weight);
std::vector<particle::Particle> determineInjectedDensityParticles(
RandomNumbers* random,
const double weight_factor,
const int current,
std::map<std::string, double>& particleNumbers,
bool& all_bins_done);
double meanFreePath(particle::Particle& particle, RandomNumbers* random,
std::vector<double>& macroscopic_cross_sections_m);
// 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.
double 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;
#ifdef debug
double phyLossAtWallIon = 0;
double createdDensity = 0;
#endif
};
#endif /* SIMULATION_H */