Files
karl/include/simulation/injector.h
T
csendlinger 047cfa8491 Decoupled the number of events simulated from
the timestep;
Bug with density drawing present
(if CPU syncs don't line up with the timestep)
2025-02-12 14:07:43 +01:00

80 lines
2.4 KiB
C++
Executable File

#ifndef INJECTOR_H
#define INJECTOR_H
#include <map>
#include <memory>
#include <random>
#include <vector>
#include "simulation/coordinates.h"
class DriftVelocity;
class VelocityDistribution;
class DynamicDensityField;
class MagneticField;
namespace particle {
class Particle;
}
namespace species {
class Specie;
class TrackedSpecie;
} // namespace species
class EventPositionDistribution;
struct InjectorInfo {
public:
std::shared_ptr<species::TrackedSpecie> created_specie;
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
// int multiplicity;
};
class Injector {
public:
Injector(std::vector<InjectorInfo>& injector_info,
double activity,
std::shared_ptr<EventPositionDistribution> position_distribution,
std::shared_ptr<DriftVelocity> mother_drift_velocity);
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
const double current_time,
const double beta_particle_weight);
// draw new particles from the DynamicDensityField of the provided specie
// the new particles are then appened to the vector queue
// the magnetic field is necessary for the determination of the direction of the
// injected particles
// the weight scales the time a particle contributes to a certain bin
// and the injection time specifies the time the particle is injected (has to be
// between T, T+\DeltaT)
void drawNewParticleFromDensityField(std::mt19937* engine,
std::shared_ptr<species::TrackedSpecie> specie,
std::vector<particle::Particle>& queue,
std::shared_ptr<MagneticField> field,
const double weight,
const double injection_time);
void initInjectionTimeDistribution(double delta_t);
double timePassed() const;
private:
std::vector<InjectorInfo> injector_infos_;
const double activity_;
std::shared_ptr<EventPositionDistribution> position_distribution_;
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
std::uniform_real_distribution<double> injection_time_distribution_;
particle::Particle rollNewParticle(
std::mt19937* engine,
const Coordinate& position,
std::shared_ptr<species::TrackedSpecie> created_specie,
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
const double time_birth,
const double weight);
};
#endif /* INJECTOR_H */