|
OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
|
Implements the sampling method for the flat-top distribution. x and y coordinates are uniformly distributed inside a circle and number of particles entering domain in [t, t+dt] follows flattop profile. More...
#include <FlatTop.h>


Public Member Functions | |
| FlatTop (std::shared_ptr< ParticleContainer_t > pc, std::shared_ptr< FieldContainer_t > fc, Distribution_t *opalDist) | |
| Constructor for FlatTop. | |
| FlatTop (std::shared_ptr< ParticleContainer_t > pc, std::shared_ptr< FieldContainer_t > fc, bool emitting, double sigmaTFall, double sigmaTRise, Vector_t< double, 3 > cutoff, double tPulseLengthFWHM, Vector_t< double, 3 > sigmaR) | |
| Constructor for FlatTop. | |
| FlatTop (std::shared_ptr< ParticleContainer_t > pc, bool emitting, double sigmaTFall, double sigmaTRise, Vector_t< double, 3 > cutoff, double tPulseLengthFWHM, Vector_t< double, 3 > sigmaR) | |
| Constructor for FlatTop. | |
| void | testNumEmitParticles (size_type nsteps, double dt) override |
| Tests the number of emitted particles over a given number of steps. | |
| void | testEmitParticles (size_type nsteps, double dt) override |
| Tests particle emission over a given number of steps. | |
| void | setWithDomainDecomp (bool withDomainDecomp) override |
| Sets whether to use domain decomposition. | |
| void | setDistArea (double distArea) |
| Sets the total area of the distribution. | |
| double | getDistArea () |
| Returns the total area of the distribution. | |
| double | getEmissionTime () |
| Returns the total emission time. | |
| bool | isEmissionDone (double t) const override |
| Whether this sampler has finished all emission (no more particles will be created). | |
| void | generateUniformDisk (size_type nlocal, size_t nNew, double dt) |
| Generates particles (x,y) uniformly on a disk distribution. | |
| void | setNr (Vector_t< double, 3 > nr) |
| Sets the number of grid points per direction. | |
| void | generateParticles (size_t &numberOfParticles, Vector_t< double, 3 > nr) override |
| Generates particles with a given number and grid configuration. | |
| double | FlatTopProfile (double t) |
| Computes the flat-top profile value at a given time. | |
| size_t | computeNlocalUniformly (size_t nglobal) |
| Computes the local number of particles uniformly distributed among ranks. | |
| double | integrateTrapezoidal (double x1, double x2, double y1, double y2) |
| Integrates using the trapezoidal rule. | |
| void | initDomainDecomp (double BoxIncr) override |
| Initializes the domain decomposition. | |
| size_type | countEnteringParticlesPerRank (double t0, double tf) |
| Counts the number of particles entering per rank in a given time interval. | |
| void | allocateParticles (size_t numberOfParticles) |
| Allocates memory for a given number of particles. | |
| void | emitParticles (double t, double dt) override |
| Emits new particles within a given time interval. | |
| void | setInternalVariables (bool emitting, double sigmaTFall, double sigmaTRise, Vector_t< double, 3 > cutoff, double tPulseLengthFWHM, Vector_t< double, 3 > sigmaR) |
| void | setEmissionOffsets (ippl::Vector< double, 3 > R0, ippl::Vector< double, 3 > P0, double t0, const std::string &emissionModel="NONE") |
| void | setInitialPolarization (const ippl::Vector< double, 3 > &pol) |
| void | fillPolarization (size_t startIdx, size_t count) |
| Vector_t< double, 3 > | getEmissionR0 () const |
| virtual double | getGlobalTimeShift () const |
| Optional tracker time shift needed before the first emitted particles are born. | |
| virtual bool | hasInitialReferenceMomentum () const |
| Optional initial reference momentum in the source-local frame. | |
| virtual Vector_t< double, 3 > | getInitialReferenceMomentum () const |
| virtual double | getEmissionTimeStep () const |
| Optional OPAL-like tracker time step while this sampler is still emitting. | |
| virtual void | testNumEmitParticles (size_t, double) |
| virtual void | testEmitParticles (size_t, double) |
| size_t | computeLocalEmitCount (size_t totalToSample) const |
| Computes the number of particles this rank should emit so that the global total equals totalToSample and no rank exceeds its capacity (space left). | |
Protected Attributes | |
| std::shared_ptr< ParticleContainer_t > | pc_m |
| std::shared_ptr< FieldContainer_t > | fc_m |
| Distribution_t * | opalDist_m = nullptr |
| std::string | samplingMethod_m |
| Vector_t< double, 3 > | R0_m = 0.0 |
| Emission source offset: position R0, momentum P0, start time t0 (applied in sample step). | |
| Vector_t< double, 3 > | P0_m = 0.0 |
| double | t0_m = 0.0 |
| std::string | emissionModel_m = "NONE" |
| Vector_t< double, 3 > | initialPol_m = 0.0 |
| bool | hasEmittedOnce_m = false |
| For one-shot emitters (e.g. Gaussian at delayed t0): guard to avoid double sampling. | |
Private Types | |
| using | size_type = ippl::detail::size_type |
Private Member Functions | |
| void | setParameters (Distribution_t *opalDist) |
| Sets distribution parameters. | |
Static Private Member Functions | |
| static size_t | determineRandInit () |
| Determines the random seed initialization. | |
Private Attributes | |
| GeneratorPool | rand_pool_m |
| Random number generator pool. | |
| double | flattopTime_m |
| Time duration of when the time profile is flat. | |
| double | normalizedFlankArea_m |
| Normalized area of the distribution flanks. | |
| double | distArea_m |
| Total area of the flattop distribution. | |
| double | sigmaTFall_m |
| Standard deviation for fall time profile. | |
| double | sigmaTRise_m |
| Standard deviation for rise time profile. | |
| Vector_t< double, 3 > | cutoffR_m |
| Cutoff radius. | |
| double | fallTime_m |
| Time duration for the fall phase. | |
| double | riseTime_m |
| Time duration for the rise phase. | |
| bool | emitting_m |
| Flag for particle emission status. | |
| size_type | totalN_m |
| Total number of particles. | |
| bool | withDomainDecomp_m |
| Flag for domain decomposition. | |
| double | emissionTime_m |
| Total emission time. | |
| Vector_t< double, 3 > | nr_m |
| Number of grid points per direction. | |
| Vector_t< double, 3 > | hr_m |
| Grid spacing. | |
| Vector_t< double, 3 > | sigmaR_m |
Implements the sampling method for the flat-top distribution. x and y coordinates are uniformly distributed inside a circle and number of particles entering domain in [t, t+dt] follows flattop profile.
The FlatTop distribution is f(t)/Z = exp[ -((t-riseTime_m)/sigma)^2/2 ] t < riseTime 1.0 riseTime < t < t<riseTime + flattopTime exp[ -((t-(fallTime_m + flattopTime_m))/sigmaTFall_m)^2/2 ] t>riseTime
|
private |
| FlatTop::FlatTop | ( | std::shared_ptr< ParticleContainer_t > | pc, |
| std::shared_ptr< FieldContainer_t > | fc, | ||
| Distribution_t * | opalDist | ||
| ) |
Constructor for FlatTop.
| pc | Shared pointer to ParticleContainer. |
| fc | Shared pointer to FieldContainer. |
| opalDist | Borrowed Distribution. |
Definition at line 10 of file FlatTop.cpp.
References setParameters().

| FlatTop::FlatTop | ( | std::shared_ptr< ParticleContainer_t > | pc, |
| std::shared_ptr< FieldContainer_t > | fc, | ||
| bool | emitting, | ||
| double | sigmaTFall, | ||
| double | sigmaTRise, | ||
| Vector_t< double, 3 > | cutoff, | ||
| double | tPulseLengthFWHM, | ||
| Vector_t< double, 3 > | sigmaR | ||
| ) |
Constructor for FlatTop.
| pc | Shared pointer to ParticleContainer. |
| fc | Shared pointer to FieldContainer. |
| emitting | Flag indicating whether the distribution is emitting. |
| sigmaTFall | Standard deviation of fall in flat-top profile. |
| sigmaTRise | Standard deviation of rise in flat-top profile. |
| cutoff | Cutoff multiplier for position distribution R. |
| tPulseLengthFWHM | Time length of the pulse in FWHM. |
| sigmaR | Standard deviation for position distribution. |
Definition at line 17 of file FlatTop.cpp.
References setInternalVariables().

| FlatTop::FlatTop | ( | std::shared_ptr< ParticleContainer_t > | pc, |
| bool | emitting, | ||
| double | sigmaTFall, | ||
| double | sigmaTRise, | ||
| Vector_t< double, 3 > | cutoff, | ||
| double | tPulseLengthFWHM, | ||
| Vector_t< double, 3 > | sigmaR | ||
| ) |
Constructor for FlatTop.
| pc | Shared pointer to ParticleContainer. |
| emitting | Flag indicating whether the distribution is emitting. |
| sigmaTFall | Standard deviation of fall in flat-top profile. |
| sigmaTRise | Standard deviation of rise in flat-top profile. |
| cutoff | Cutoff multiplier for position distribution R. |
| tPulseLengthFWHM | Time span of the flat-top profile. |
| sigmaR | Standard deviation for position distribution R. |
Definition at line 25 of file FlatTop.cpp.
References setInternalVariables().

| void FlatTop::allocateParticles | ( | size_t | numberOfParticles | ) |
Allocates memory for a given number of particles.
| numberOfParticles | Number of particles to allocate. |
Definition at line 350 of file FlatTop.cpp.
References totalN_m.
Referenced by generateParticles(), and TEST_F().
|
inherited |
Computes the number of particles this rank should emit so that the global total equals totalToSample and no rank exceeds its capacity (space left).
| totalToSample | Global number of particles to emit this timestep. |
Definition at line 6 of file SamplingBase.cpp.
References SamplingBase::pc_m.
Referenced by countEnteringParticlesPerRank(), FromFile::generateParticles(), Gaussian::generateParticles(), and MultiVariateGaussian::generateParticles().
| size_t FlatTop::computeNlocalUniformly | ( | size_t | nglobal | ) |
Computes the local number of particles uniformly distributed among ranks.
| nglobal | Total global number of particles. |
Definition at line 222 of file FlatTop.cpp.
Referenced by countEnteringParticlesPerRank().
| FlatTop::size_type FlatTop::countEnteringParticlesPerRank | ( | double | t0, |
| double | tf | ||
| ) |
Counts the number of particles entering per rank in a given time interval.
| t0 | Start time. |
| tf | End time. |
Definition at line 263 of file FlatTop.cpp.
References SamplingBase::computeLocalEmitCount(), computeNlocalUniformly(), distArea_m, FlatTopProfile(), integrateTrapezoidal(), SamplingBase::pc_m, and totalN_m.
Referenced by emitParticles(), TEST_F(), and testNumEmitParticles().

|
staticprivate |
Determines the random seed initialization.
Definition at line 35 of file FlatTop.cpp.
References gmsg, and Options::seed.
|
overridevirtual |
Emits new particles within a given time interval.
| t | Start time. |
| dt | Time step. |
Reimplemented from SamplingBase.
Definition at line 360 of file FlatTop.cpp.
References countEnteringParticlesPerRank(), SamplingBase::fillPolarization(), generateUniformDisk(), SamplingBase::pc_m, and SamplingBase::t0_m.
Referenced by testEmitParticles().

|
inlineinherited |
Fill the Pol particle attribute with initialPol_m on the half-open range [startIdx, startIdx + count). No-op when the container does not store spin. Must be called after the particles have been created and before they are pushed downstream.
Definition at line 63 of file SamplingBase.hpp.
References SamplingBase::initialPol_m, and SamplingBase::pc_m.
Referenced by emitParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), and MultiVariateGaussian::generateParticles().
| double FlatTop::FlatTopProfile | ( | double | t | ) |
Computes the flat-top profile value at a given time.
| t | Time value. |
Definition at line 204 of file FlatTop.cpp.
References fallTime_m, flattopTime_m, riseTime_m, sigmaTFall_m, and sigmaTRise_m.
Referenced by countEnteringParticlesPerRank(), and TEST_F().
|
overridevirtual |
Generates particles with a given number and grid configuration.
| numberOfParticles | Number of particles to generate. |
| nr | Number of grid points in each dimension. |
Reimplemented from SamplingBase.
Definition at line 183 of file FlatTop.cpp.
References allocateParticles(), nr, and setNr().

| void FlatTop::generateUniformDisk | ( | size_type | nlocal, |
| size_t | nNew, | ||
| double | dt | ||
| ) |
Generates particles (x,y) uniformly on a disk distribution.
Each new particle is assigned a fractional per-particle dt sampled uniformly in (0, dt), representing the fraction of the next integration step the particle will experience (as if born at a random time within the current emission interval).
| nlocal | Number of local particles. |
| nNew | Number of new particles to generate. |
| dt | Global timestep; used to sample fractional per-particle dt. |
Definition at line 88 of file FlatTop.cpp.
References Physics::c, SamplingBase::emissionModel_m, euclidean_norm(), SamplingBase::P0_m, SamplingBase::pc_m, Physics::pi, SamplingBase::R0_m, rand_pool_m, and sigmaR_m.
Referenced by emitParticles(), TEST_F(), and testNumEmitParticles().

|
inline |
Returns the total area of the distribution.
Definition at line 103 of file FlatTop.h.
References distArea_m.
Referenced by TEST_F().
|
inlineinherited |
Definition at line 78 of file SamplingBase.hpp.
References SamplingBase::R0_m.
|
inline |
Returns the total emission time.
Definition at line 108 of file FlatTop.h.
References emissionTime_m.
|
inlinevirtualinherited |
Optional OPAL-like tracker time step while this sampler is still emitting.
Reimplemented in EmittedFromFile, and OpalFlatTop.
Definition at line 102 of file SamplingBase.hpp.
|
inlinevirtualinherited |
Optional tracker time shift needed before the first emitted particles are born.
Reimplemented in EmittedFromFile, and OpalFlatTop.
Definition at line 92 of file SamplingBase.hpp.
|
inlinevirtualinherited |
Reimplemented in EmittedFromFile, and OpalFlatTop.
Definition at line 97 of file SamplingBase.hpp.
|
inlinevirtualinherited |
Optional initial reference momentum in the source-local frame.
Reimplemented in EmittedFromFile, and OpalFlatTop.
Definition at line 95 of file SamplingBase.hpp.
|
overridevirtual |
Initializes the domain decomposition.
| BoxIncr | Box increment factor. |
Reimplemented from SamplingBase.
Definition at line 242 of file FlatTop.cpp.
References Physics::c, emissionTime_m, SamplingBase::fc_m, hr_m, nr_m, SamplingBase::pc_m, and sigmaR_m.
| double FlatTop::integrateTrapezoidal | ( | double | x1, |
| double | x2, | ||
| double | y1, | ||
| double | y2 | ||
| ) |
Integrates using the trapezoidal rule.
| x1 | begining of interval [x1,x2]. |
| x2 | end of interval [x1,x2]. |
| y1 | value of f(x1). |
| y2 | value of f(x2). |
Definition at line 238 of file FlatTop.cpp.
Referenced by countEnteringParticlesPerRank().
|
inlineoverridevirtual |
Whether this sampler has finished all emission (no more particles will be created).
| t | Current simulation time (s). |
Reimplemented from SamplingBase.
Definition at line 111 of file FlatTop.h.
References emissionTime_m, and SamplingBase::t0_m.
|
inline |
Sets the total area of the distribution.
Definition at line 97 of file FlatTop.h.
References distArea_m.
|
inlineinherited |
Definition at line 48 of file SamplingBase.hpp.
References SamplingBase::emissionModel_m, SamplingBase::P0_m, SamplingBase::R0_m, and SamplingBase::t0_m.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlineinherited |
Definition at line 57 of file SamplingBase.hpp.
References SamplingBase::initialPol_m.
| void FlatTop::setInternalVariables | ( | bool | emitting, |
| double | sigmaTFall, | ||
| double | sigmaTRise, | ||
| Vector_t< double, 3 > | cutoff, | ||
| double | tPulseLengthFWHM, | ||
| Vector_t< double, 3 > | sigmaR | ||
| ) |
Definition at line 58 of file FlatTop.cpp.
References cutoffR_m, distArea_m, emissionTime_m, emitting_m, fallTime_m, flattopTime_m, normalizedFlankArea_m, riseTime_m, sigmaR_m, sigmaTFall_m, sigmaTRise_m, and Physics::two_pi.
Referenced by FlatTop(), FlatTop(), and setParameters().
| void FlatTop::setNr | ( | Vector_t< double, 3 > | nr | ) |
Sets the number of grid points per direction.
| nr | Vector specifying the number of grid points. |
Definition at line 181 of file FlatTop.cpp.
Referenced by generateParticles().
|
private |
Sets distribution parameters.
| opalDist | Shared pointer to the distribution object. |
Definition at line 47 of file FlatTop.cpp.
References emissionTime_m, Distribution::emitting_m, SamplingBase::fc_m, Distribution::getCutoffR(), Distribution::getSigmaR(), Distribution::getSigmaTFall(), Distribution::getSigmaTRise(), Distribution::getTPulseLengthFWHM(), SamplingBase::opalDist_m, setInternalVariables(), and Distribution::setTEmission().
Referenced by FlatTop().

|
overridevirtual |
Sets whether to use domain decomposition.
| withDomainDecomp | Boolean flag for domain decomposition. |
Reimplemented from SamplingBase.
Definition at line 33 of file FlatTop.cpp.
References withDomainDecomp_m.
Referenced by TEST_F().
|
inlinevirtualinherited |
Definition at line 108 of file SamplingBase.hpp.
|
override |
Tests particle emission over a given number of steps.
| nsteps | Number of time steps to simulate. |
| dt | Time step size. |
Definition at line 440 of file FlatTop.cpp.
References emitParticles().

|
inlinevirtualinherited |
Definition at line 105 of file SamplingBase.hpp.
|
override |
Tests the number of emitted particles over a given number of steps.
| nsteps | Number of time steps to simulate. |
| dt | Time step size. |
Definition at line 394 of file FlatTop.cpp.
References Physics::c, countEnteringParticlesPerRank(), emissionTime_m, generateUniformDisk(), and SamplingBase::pc_m.

|
private |
|
private |
Total area of the flattop distribution.
Definition at line 118 of file FlatTop.h.
Referenced by countEnteringParticlesPerRank(), getDistArea(), setDistArea(), and setInternalVariables().
|
protectedinherited |
Definition at line 25 of file SamplingBase.hpp.
Referenced by OpalFlatTop::generateLocalParticles(), EmittedFromFile::generateParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), generateUniformDisk(), OpalFlatTop::getInitialReferenceMomentum(), and SamplingBase::setEmissionOffsets().
|
private |
Total emission time.
Definition at line 127 of file FlatTop.h.
Referenced by getEmissionTime(), initDomainDecomp(), isEmissionDone(), setInternalVariables(), setParameters(), and testNumEmitParticles().
|
private |
Flag for particle emission status.
Definition at line 124 of file FlatTop.h.
Referenced by setInternalVariables().
|
private |
Time duration for the fall phase.
Definition at line 122 of file FlatTop.h.
Referenced by FlatTopProfile(), and setInternalVariables().
|
protectedinherited |
Definition at line 18 of file SamplingBase.hpp.
Referenced by initDomainDecomp(), OpalFlatTop::initDomainDecomp(), setParameters(), and OpalFlatTop::setParameters().
|
private |
Time duration of when the time profile is flat.
Definition at line 116 of file FlatTop.h.
Referenced by FlatTopProfile(), and setInternalVariables().
|
protectedinherited |
For one-shot emitters (e.g. Gaussian at delayed t0): guard to avoid double sampling.
Definition at line 33 of file SamplingBase.hpp.
Referenced by FromFile::emitParticles(), Gaussian::emitParticles(), MultiVariateGaussian::emitParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), and SamplingBase::isEmissionDone().
|
private |
|
protectedinherited |
Initial polarization vector P applied to every particle this sampler creates. Rest-frame Pauli expectations along lab-frame axes; |Pol| in [0, 1]. Ignored when the container does not have a spin attribute (hasSpin() == false).
Definition at line 30 of file SamplingBase.hpp.
Referenced by SamplingBase::fillPolarization(), and SamplingBase::setInitialPolarization().
|
private |
Normalized area of the distribution flanks.
Definition at line 117 of file FlatTop.h.
Referenced by setInternalVariables().
|
private |
Number of grid points per direction.
Definition at line 128 of file FlatTop.h.
Referenced by initDomainDecomp(), and setNr().
|
protectedinherited |
Definition at line 19 of file SamplingBase.hpp.
Referenced by EmittedFromFile::buildInventory(), FromFile::emitParticles(), Gaussian::emitParticles(), MultiVariateGaussian::emitParticles(), EmittedFromFile::generateParticles(), MultiVariateGaussian::MultiVariateGaussian(), and setParameters().
|
protectedinherited |
Definition at line 23 of file SamplingBase.hpp.
Referenced by EmittedFromFile::buildInventory(), EmittedFromFile::generateLocalParticles(), OpalFlatTop::generateLocalParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), generateUniformDisk(), OpalFlatTop::getInitialReferenceMomentum(), and SamplingBase::setEmissionOffsets().
|
protectedinherited |
Definition at line 17 of file SamplingBase.hpp.
Referenced by SamplingBase::computeLocalEmitCount(), EmittedFromFile::computeLocalEmitRange(), OpalFlatTop::computeLocalEmitRange(), countEnteringParticlesPerRank(), EmittedFromFile::emitParticles(), emitParticles(), FromFile::emitParticles(), Gaussian::emitParticles(), MultiVariateGaussian::emitParticles(), OpalFlatTop::emitParticles(), SamplingBase::fillPolarization(), EmittedFromFile::generateLocalParticles(), OpalFlatTop::generateLocalParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), generateUniformDisk(), initDomainDecomp(), OpalFlatTop::initDomainDecomp(), and testNumEmitParticles().
|
protectedinherited |
Emission source offset: position R0, momentum P0, start time t0 (applied in sample step).
Definition at line 22 of file SamplingBase.hpp.
Referenced by EmittedFromFile::generateLocalParticles(), OpalFlatTop::generateLocalParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), generateUniformDisk(), SamplingBase::getEmissionR0(), and SamplingBase::setEmissionOffsets().
|
private |
Random number generator pool.
Definition at line 115 of file FlatTop.h.
Referenced by generateUniformDisk().
|
private |
Time duration for the rise phase.
Definition at line 123 of file FlatTop.h.
Referenced by FlatTopProfile(), and setInternalVariables().
|
protectedinherited |
Definition at line 20 of file SamplingBase.hpp.
|
private |
Definition at line 130 of file FlatTop.h.
Referenced by generateUniformDisk(), initDomainDecomp(), and setInternalVariables().
|
private |
Standard deviation for fall time profile.
Definition at line 119 of file FlatTop.h.
Referenced by FlatTopProfile(), and setInternalVariables().
|
private |
Standard deviation for rise time profile.
Definition at line 120 of file FlatTop.h.
Referenced by FlatTopProfile(), and setInternalVariables().
|
protectedinherited |
Definition at line 24 of file SamplingBase.hpp.
Referenced by EmittedFromFile::buildInventory(), emitParticles(), FromFile::emitParticles(), Gaussian::emitParticles(), MultiVariateGaussian::emitParticles(), FromFile::generateParticles(), Gaussian::generateParticles(), MultiVariateGaussian::generateParticles(), EmittedFromFile::getGlobalTimeShift(), OpalFlatTop::getGlobalTimeShift(), isEmissionDone(), SamplingBase::setEmissionOffsets(), and OpalFlatTop::toBirthTime().
|
private |
Total number of particles.
Definition at line 125 of file FlatTop.h.
Referenced by allocateParticles(), and countEnteringParticlesPerRank().
|
private |
Flag for domain decomposition.
Definition at line 126 of file FlatTop.h.
Referenced by setWithDomainDecomp().