OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
FlatTop Class Reference

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>

Inheritance diagram for FlatTop:
Collaboration diagram for FlatTop:

Public Member Functions

 FlatTop (std::shared_ptr< ParticleContainer_t > &pc, std::shared_ptr< FieldContainer_t > &fc, std::shared_ptr< Distribution_t > &opalDist)
 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 generateUniformDisk (size_type nlocal, size_t nNew)
 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.
double 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.
virtual void testNumEmitParticles (size_t nsteps, double dt)
virtual void testEmitParticles (size_t nsteps, double dt)

Protected Attributes

std::shared_ptr< ParticleContainer_tpc_m
std::shared_ptr< FieldContainer_tfc_m
std::shared_ptr< Distribution_topalDist_m
std::string samplingMethod_m

Private Types

using size_type = ippl::detail::size_type

Private Member Functions

void setWithDomainDecomp (bool withDomainDecomp) override
 Sets whether to use domain decomposition.
void setParameters (const std::shared_ptr< 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.

Detailed Description

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 + flattopTime where Z is the normalizing factor.

Definition at line 36 of file FlatTop.h.

Member Typedef Documentation

◆ size_type

using FlatTop::size_type = ippl::detail::size_type
private

Definition at line 61 of file FlatTop.h.

Constructor & Destructor Documentation

◆ FlatTop()

FlatTop::FlatTop ( std::shared_ptr< ParticleContainer_t > & pc,
std::shared_ptr< FieldContainer_t > & fc,
std::shared_ptr< Distribution_t > & opalDist )

Constructor for FlatTop.

Parameters
pcShared pointer to ParticleContainer.
fcShared pointer to FieldContainer.
opalDistShared pointer to Distribution.

Definition at line 13 of file FlatTop.cpp.

References determineRandInit(), rand_pool_m, SamplingBase::SamplingBase(), and setParameters().

Here is the call graph for this function:

Member Function Documentation

◆ allocateParticles()

void FlatTop::allocateParticles ( size_t numberOfParticles)

Allocates memory for a given number of particles.

Parameters
numberOfParticlesNumber of particles to allocate.

Definition at line 254 of file FlatTop.cpp.

References computeNlocalUniformly(), SamplingBase::pc_m, and totalN_m.

Referenced by generateParticles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeNlocalUniformly()

size_t FlatTop::computeNlocalUniformly ( size_t nglobal)

Computes the local number of particles uniformly distributed among ranks.

Parameters
nglobalTotal global number of particles.
Returns
Number of local particles.

Definition at line 135 of file FlatTop.cpp.

Referenced by allocateParticles(), and countEnteringParticlesPerRank().

Here is the caller graph for this function:

◆ countEnteringParticlesPerRank()

double FlatTop::countEnteringParticlesPerRank ( double t0,
double tf )

Counts the number of particles entering per rank in a given time interval.

Parameters
t0Start time.
tfEnd time.
Returns
Number of entering particles per rank.

Definition at line 178 of file FlatTop.cpp.

References Physics::c, computeNlocalUniformly(), Dim, distArea_m, FlatTopProfile(), integrateTrapezoidal(), SamplingBase::opalDist_m, SamplingBase::pc_m, totalN_m, and withDomainDecomp_m.

Referenced by emitParticles(), and testNumEmitParticles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ determineRandInit()

size_t FlatTop::determineRandInit ( )
staticprivate

Determines the random seed initialization.

Returns
The seed value.

Definition at line 24 of file FlatTop.cpp.

References gmsg, and Options::seed.

Referenced by FlatTop().

Here is the caller graph for this function:

◆ emitParticles()

void FlatTop::emitParticles ( double t,
double dt )
overridevirtual

Emits new particles within a given time interval.

Parameters
tStart time.
dtTime step.

Reimplemented from SamplingBase.

Definition at line 264 of file FlatTop.cpp.

References countEnteringParticlesPerRank(), generateUniformDisk(), gmsg, and SamplingBase::pc_m.

Referenced by testEmitParticles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlatTopProfile()

double FlatTop::FlatTopProfile ( double t)

Computes the flat-top profile value at a given time.

Parameters
tTime value.
Returns
Profile value at time t.

Definition at line 116 of file FlatTop.cpp.

References fallTime_m, flattopTime_m, riseTime_m, sigmaTFall_m, and sigmaTRise_m.

Referenced by countEnteringParticlesPerRank().

Here is the caller graph for this function:

◆ generateParticles()

void FlatTop::generateParticles ( size_t & numberOfParticles,
Vector_t< double, 3 > nr )
overridevirtual

Generates particles with a given number and grid configuration.

Parameters
numberOfParticlesNumber of particles to generate.
nrNumber of grid points in each dimension.

Reimplemented from SamplingBase.

Definition at line 99 of file FlatTop.cpp.

References allocateParticles(), emitting_m, nr, SamplingBase::pc_m, and setNr().

Here is the call graph for this function:

◆ generateUniformDisk()

void FlatTop::generateUniformDisk ( size_type nlocal,
size_t nNew )

Generates particles (x,y) uniformly on a disk distribution.

Parameters
nlocalNumber of local particles.
nNewNumber of new particles to generate.

Definition at line 65 of file FlatTop.cpp.

References SamplingBase::opalDist_m, SamplingBase::pc_m, Physics::pi, pi, and rand_pool_m.

Referenced by emitParticles(), and testNumEmitParticles().

Here is the caller graph for this function:

◆ initDomainDecomp()

void FlatTop::initDomainDecomp ( double BoxIncr)
overridevirtual

Initializes the domain decomposition.

Parameters
BoxIncrBox increment factor.

Reimplemented from SamplingBase.

Definition at line 157 of file FlatTop.cpp.

References Physics::c, emissionTime_m, SamplingBase::fc_m, hr_m, nr_m, SamplingBase::opalDist_m, and SamplingBase::pc_m.

◆ integrateTrapezoidal()

double FlatTop::integrateTrapezoidal ( double x1,
double x2,
double y1,
double y2 )

Integrates using the trapezoidal rule.

Parameters
x1begining of interval [x1,x2].
x2end of interval [x1,x2].
y1value of f(x1).
y2value of f(x2).
Returns
Integrated result.

Definition at line 153 of file FlatTop.cpp.

Referenced by countEnteringParticlesPerRank().

Here is the caller graph for this function:

◆ setNr()

void FlatTop::setNr ( Vector_t< double, 3 > nr)

Sets the number of grid points per direction.

Parameters
nrVector specifying the number of grid points.

Definition at line 95 of file FlatTop.cpp.

References nr, and nr_m.

Referenced by generateParticles().

Here is the caller graph for this function:

◆ setParameters()

void FlatTop::setParameters ( const std::shared_ptr< Distribution_t > & opalDist)
private

Sets distribution parameters.

Parameters
opalDistShared pointer to the distribution object.

Definition at line 36 of file FlatTop.cpp.

References cutoffR_m, distArea_m, emissionTime_m, emitting_m, fallTime_m, SamplingBase::fc_m, flattopTime_m, normalizedFlankArea_m, SamplingBase::opalDist_m, riseTime_m, sigmaTFall_m, sigmaTRise_m, and Physics::two_pi.

Referenced by FlatTop().

Here is the caller graph for this function:

◆ setWithDomainDecomp()

void FlatTop::setWithDomainDecomp ( bool withDomainDecomp)
overrideprivatevirtual

Sets whether to use domain decomposition.

Parameters
withDomainDecompBoolean flag for domain decomposition.

Reimplemented from SamplingBase.

Definition at line 20 of file FlatTop.cpp.

References withDomainDecomp_m.

◆ testEmitParticles() [1/2]

void FlatTop::testEmitParticles ( size_type nsteps,
double dt )
override

Tests particle emission over a given number of steps.

Parameters
nstepsNumber of time steps to simulate.
dtTime step size.

Definition at line 328 of file FlatTop.cpp.

References emitParticles().

Here is the call graph for this function:

◆ testEmitParticles() [2/2]

virtual void SamplingBase::testEmitParticles ( size_t nsteps,
double dt )
inlinevirtualinherited

Definition at line 37 of file SamplingBase.hpp.

◆ testNumEmitParticles() [1/2]

void FlatTop::testNumEmitParticles ( size_type nsteps,
double dt )
override

Tests the number of emitted particles over a given number of steps.

Parameters
nstepsNumber of time steps to simulate.
dtTime step size.

Definition at line 283 of file FlatTop.cpp.

References Physics::c, countEnteringParticlesPerRank(), emissionTime_m, generateUniformDisk(), and SamplingBase::pc_m.

Here is the call graph for this function:

◆ testNumEmitParticles() [2/2]

virtual void SamplingBase::testNumEmitParticles ( size_t nsteps,
double dt )
inlinevirtualinherited

Definition at line 34 of file SamplingBase.hpp.

Member Data Documentation

◆ cutoffR_m

Vector_t<double, 3> FlatTop::cutoffR_m
private

Cutoff radius.

Definition at line 68 of file FlatTop.h.

Referenced by setParameters().

◆ distArea_m

double FlatTop::distArea_m
private

Total area of the flattop distribution.

Definition at line 65 of file FlatTop.h.

Referenced by countEnteringParticlesPerRank(), and setParameters().

◆ emissionTime_m

double FlatTop::emissionTime_m
private

Total emission time.

Definition at line 74 of file FlatTop.h.

Referenced by initDomainDecomp(), setParameters(), and testNumEmitParticles().

◆ emitting_m

bool FlatTop::emitting_m
private

Flag for particle emission status.

Definition at line 71 of file FlatTop.h.

Referenced by generateParticles(), and setParameters().

◆ fallTime_m

double FlatTop::fallTime_m
private

Time duration for the fall phase.

Definition at line 69 of file FlatTop.h.

Referenced by FlatTopProfile(), and setParameters().

◆ fc_m

std::shared_ptr<FieldContainer_t> SamplingBase::fc_m
protectedinherited

◆ flattopTime_m

double FlatTop::flattopTime_m
private

Time duration of when the time profile is flat.

Definition at line 63 of file FlatTop.h.

Referenced by FlatTopProfile(), and setParameters().

◆ hr_m

Vector_t<double, 3> FlatTop::hr_m
private

Grid spacing.

Definition at line 76 of file FlatTop.h.

Referenced by initDomainDecomp().

◆ normalizedFlankArea_m

double FlatTop::normalizedFlankArea_m
private

Normalized area of the distribution flanks.

Definition at line 64 of file FlatTop.h.

Referenced by setParameters().

◆ nr_m

Vector_t<double, 3> FlatTop::nr_m
private

Number of grid points per direction.

Definition at line 75 of file FlatTop.h.

Referenced by initDomainDecomp(), and setNr().

◆ opalDist_m

◆ pc_m

◆ rand_pool_m

GeneratorPool FlatTop::rand_pool_m
private

Random number generator pool.

Definition at line 62 of file FlatTop.h.

Referenced by FlatTop(), and generateUniformDisk().

◆ riseTime_m

double FlatTop::riseTime_m
private

Time duration for the rise phase.

Definition at line 70 of file FlatTop.h.

Referenced by FlatTopProfile(), and setParameters().

◆ samplingMethod_m

std::string SamplingBase::samplingMethod_m
protectedinherited

Definition at line 16 of file SamplingBase.hpp.

◆ sigmaTFall_m

double FlatTop::sigmaTFall_m
private

Standard deviation for fall time profile.

Definition at line 66 of file FlatTop.h.

Referenced by FlatTopProfile(), and setParameters().

◆ sigmaTRise_m

double FlatTop::sigmaTRise_m
private

Standard deviation for rise time profile.

Definition at line 67 of file FlatTop.h.

Referenced by FlatTopProfile(), and setParameters().

◆ totalN_m

size_type FlatTop::totalN_m
private

Total number of particles.

Definition at line 72 of file FlatTop.h.

Referenced by allocateParticles(), and countEnteringParticlesPerRank().

◆ withDomainDecomp_m

bool FlatTop::withDomainDecomp_m
private

Flag for domain decomposition.

Definition at line 73 of file FlatTop.h.

Referenced by countEnteringParticlesPerRank(), and setWithDomainDecomp().


The documentation for this class was generated from the following files: