6#ifndef IPPL_OPAL_FLAT_TOP_H
7#define IPPL_OPAL_FLAT_TOP_H
9#include <Kokkos_Random.hpp>
53 std::shared_ptr<ParticleContainer_t> pc, std::shared_ptr<FieldContainer_t> fc,
74 std::shared_ptr<ParticleContainer_t> pc, std::shared_ptr<FieldContainer_t> fc,
77 double ftOscPeriods = 0.0);
245 double ftOscPeriods);
294 size_type nlocalBefore,
size_t globalBegin,
size_t nNew,
double tStart,
double dt);
ippl::Vector< T, Dim > Vector_t
typename Kokkos::Random_XorShift64_Pool<> OpalFlatTopGeneratorPool
Implements an old-OPAL-compatible flat-top emitter with precomputed birth times.
double fallTime_m
Duration represented by the falling flank.
double getGlobalTimeShift() const override
Returns the global time shift needed to center old-OPAL pulse times.
std::pair< size_t, size_t > computeLocalEmitRange(size_t totalToEmit) const
Computes the local contiguous subrange of a global emission batch.
double riseTime_m
Duration represented by the rising flank.
double getEmissionTimeStep() const override
Returns the preferred emission time step.
void initDomainDecomp(double BoxIncr) override
Initializes a domain decomposition large enough for the emitted bunch.
double getDistArea() const
Returns the total area of the normalized flat-top distribution.
double sigmaTRise_m
Standard deviation of the rising flank.
double sampleTruncatedHalfGaussian(double sigma, double limit)
Samples an absolute value from a Gaussian truncated at a limit.
OpalFlatTopGeneratorPool rand_pool_m
Device random number generator pool.
size_t getInventorySize() const
Returns the number of precomputed birth times.
void setBirthTimesForTest(std::vector< double > birthTimes)
Replaces the birth-time inventory for tests.
static size_t determineHostSeed()
Determines the host random seed initialization.
bool emitting_m
Flag for particle emission status.
void setWithDomainDecomp(bool withDomainDecomp) override
Sets whether to use domain decomposition during emission.
std::mt19937_64 host_rng_m
Host generator used to sample birth times.
size_t nextGlobalIndex_m
First global birth-time index not emitted yet.
double sigmaTFall_m
Standard deviation of the falling flank.
std::vector< double > birthTimes_m
Sorted global particle birth times.
const std::vector< double > & getBirthTimes() const
Returns the sorted global birth-time inventory.
double normalizedFlankArea_m
Area of one normalized truncated Gaussian flank.
double flattopTime_m
Time duration of the flat profile section.
Vector_t< double, 3 > hr_m
Grid spacing.
Vector_t< double, 3 > nr_m
Number of grid points per direction.
size_t emissionSteps_m
Number of steps used to derive emission dt.
double ftOscAmplitude_m
Flat-top oscillation amplitude in percent.
void generateParticles(size_t &numberOfParticles, Vector_t< double, 3 > nr) override
Builds the global birth-time inventory for the requested particles.
bool withDomainDecomp_m
Flag for domain decomposition.
size_t getNextGlobalIndex() const
Returns the next global inventory index to be emitted.
double toBirthTime(double opalPulseTime) const
Converts old-OPAL pulse time to tracker birth time.
bool inventoryBuilt_m
True once birthTimes_m is ready for emission.
void emitParticles(double t, double dt) override
Emits all particles whose birth times fall into the current step.
void setParameters(Distribution_t *opalDist)
Reads distribution parameters from the OPALX Distribution object.
void generateLocalParticles(size_type nlocalBefore, size_t globalBegin, size_t nNew, double tStart, double dt)
Generates the local particles assigned to this rank for one emission step.
bool hasInitialReferenceMomentum() const override
Reports that this sampler provides an initial reference momentum.
bool isEmissionDone(double) const override
Returns whether all precomputed particles have been emitted.
void buildBirthTimeInventory(size_t numberOfParticles)
Builds and sorts the global particle birth-time inventory.
Vector_t< double, 3 > cutoffR_m
Cutoff multipliers for distribution support.
double emissionTime_m
Total emission time.
Vector_t< double, 3 > getInitialReferenceMomentum() const override
Returns the initial reference momentum used by the tracker.
void setInternalVariables(bool emitting, double sigmaTFall, double sigmaTRise, Vector_t< double, 3 > cutoff, double tPulseLengthFWHM, Vector_t< double, 3 > sigmaR, double ftOscAmplitude, double ftOscPeriods)
Sets derived flat-top profile and emission parameters.
double getEmissionTime() const
Returns the total emission time.
static size_t determineRandInit()
Determines the device random seed initialization.
size_t totalN_m
Total number of particles in the inventory.
double distArea_m
Total area of the flat-top distribution.
ippl::detail::size_type size_type
Vector_t< double, 3 > sigmaR_m
Semi-axis lengths of the transverse disk.
double ftOscPeriods_m
Number of oscillation periods across the flat top.