18#ifndef PART_BUNCH_BASE_H
19#define PART_BUNCH_BASE_H
48template <
class T,
unsigned Dim>
49class PartBunchBase : std::enable_shared_from_this<PartBunchBase<T, Dim>>
98 std::vector<Distribution*> addedDistributions,
101 size_t numberOfParticles,
102 double current,
const Beamline& bl);
159 void calcLineDensity(
unsigned int nBins, std::vector<double>& lineDensity,
160 std::pair<double, double>& meshInfo);
181 virtual double getPx(
int i);
182 virtual double getPy(
int i);
183 virtual double getPz(
int i);
185 virtual double getPx0(
int i);
186 virtual double getPy0(
int i);
188 virtual double getX(
int i);
189 virtual double getY(
int i);
190 virtual double getZ(
int i);
192 virtual double getX0(
int i);
193 virtual double getY0(
int i);
195 virtual void setZ(
int i,
double zcoo);
292 double& axmax,
double& aymax);
295 double getdT()
const;
439 double getdE()
const;
476 virtual double getRho(
int x,
int y,
int z) = 0;
486 virtual void swap(
unsigned int i,
unsigned int j);
544 void destroy(
size_t M,
size_t I,
bool doNow =
false);
727 std::shared_ptr<AbstractParticle<T, Dim> >
pbase_m;
730template<
class T,
unsigned Dim>
732 return bunch.
begin();
735template<
class T,
unsigned Dim>
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
constexpr double c
The velocity of light in m/s.
boost::function< boost::tuple< double, bool >(arguments_t)> type
ParticleLayout< T, Dim > & getLayout()
void setEnergyBins(int numberOfEnergyBins)
ParticleAttrib< Vector_t > Ef
double get_meanKineticEnergy() const
std::shared_ptr< AbstractParticle< T, Dim > > pbase_m
double spos_m
the position along design trajectory
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
virtual void resetInterpolationCache(bool clearCache=false)
std::vector< size_t > bunchTotalNum_m
number of particles per bunch
void setPType(const std::string &type)
long long localTrackStep_m
step in a TRACK command
const PartData * getReference() const
ParticleAttrib< int > Bin
ParticleOrigin getPOrigin() const
void setMass(double mass)
int getSteptoLastInj() const
Vector_t get_99Percentile() const
void boundp_destroyCycl()
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
bool resetPartBinID2(const double eta)
reset Bin[] for each particle according to the method given in paper PAST-AB(064402) by G....
virtual void resizeMesh()
void setNumBunch(short n)
AbstractParticle< T, Dim >::ParticlePos_t ParticlePos_t
double getMassPerParticle() const
AbstractParticle< T, Dim >::ParticleIndex_t ParticleIndex_t
bool fixed_grid
if the grid does not have to adapt
double getQ() const
Access to reference data.
double getCouplingConstant() const
Vector_t get_normalizedEps_99Percentile() const
double getChargePerParticle() const
get the macro particle charge
virtual void computeSelfFields()=0
virtual void set_meshEnlargement(double dh)
ParticleAttrib< Vector_t > Eftmp
virtual double getBeta(int i)
virtual double getPx0(int i)
size_t getLocalNum() const
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix() const
IpplTimings::TimerRef boundpTimer_m
double t_m
holds the actual time of the integration
void setLocalTrackStep(long long n)
step in a TRACK command
void setLocalBinCount(size_t num, int bin)
long long globalTrackStep_m
if multiple TRACK commands
double get_debyeLength() const
bool getUpdateFlag(UpdateFlags_t f) const
void setParticle(FVector< double, 6 > z, int ii)
Vector_t rmax_m
maximal extend of particles
ParticleAttrib< double > M
size_t emitParticles(double eZ)
Emit particles in the given bin i.e. copy the particles from the bin structure into the particle cont...
void maximumAmplitudes(const FMatrix< double, 6, 6 > &D, double &axmax, double &aymax)
Return maximum amplitudes.
double get_plasmaParameter() const
void setMassZeroPart(double mass)
size_t getTotalNum() const
virtual void updateFields(const Vector_t &hr, const Vector_t &origin)
Vector_t get_95Percentile() const
virtual void setZ(int i, double zcoo)
std::unique_ptr< size_t[]> binemitted_m
double calcMeanPhi()
calculate average angle of longitudinal direction of bins
Quaternion_t getGlobalToLocalQuaternion()
const PartData * reference
void setBeamFrequency(double v)
Vector_t get_normalizedEps_68Percentile() const
ParticleBConds< Position_t, Dimension > & getBConds()
ParticleAttrib< Vector_t > P
void switchToUnitlessPositions(bool use_dt_per_particle=false)
size_t calcNumPartsOutside(Vector_t x)
returns the number of particles outside of a box defined by x
IpplTimings::TimerRef histoTimer_m
ParticleAttrib< ParticleType > PType
short numBunch_m
current bunch number
Quaternion_t globalToLocalQuaternion_m
virtual void initialize(FieldLayout_t *fLayout)=0
Inform & print(Inform &os)
FieldSolverType getFieldSolverType() const
Return the fieldsolver type if we have a fieldsolver.
double getEmissionDeltaT()
virtual void updateDomainLength(Vektor< int, 3 > &grid)=0
void setLocalNumPerBunch(size_t numpart, short n)
size_t getLocalNumPerBunch(short n) const
void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion)
ParticleAttrib< ParticleOrigin > POrigin
virtual void computeSelfFields_cycl(double gamma)=0
Vector_t get_rrms() const
std::unique_ptr< Inform > pmsg_m
double get_rmsDensity() const
virtual double getPy(int i)
double getBinGamma(int bin)
Get gamma of one bin.
ParticleAttrib< double > Q
double getInitialBeta() const
int getLastEmittedEnergyBin()
void calcBeamParameters()
void getLocalBounds(Vector_t &rmin, Vector_t &rmax) const
void setSteptoLastInj(int n)
virtual double getX0(int i)
virtual double getRho(int x, int y, int z)=0
double getInitialGamma() const
virtual void setBCAllPeriodic()
void setQKs3D(Quaternion_t q)
Vector_t rmin_m
minimal extend of particles
void setChargeZeroPart(double q)
virtual double getY0(int i)
int stepsPerTurn_m
steps per turn for OPAL-cycl
IpplTimings::TimerRef statParamTimer_m
ParticleType getPType() const
Vector_t get_origin() const
Vector_t get_prms() const
void createWithID(unsigned id)
PartBunchBase(AbstractParticle< T, Dim > *pb, const PartData *ref)
double getCharge() const
get the total charge per simulation particle
virtual double getPy0(int i)
double get_temperature() const
IpplTimings::TimerRef distrReload_m
timer for IC, can not be in Distribution.h
size_t getTotalNumPerBunch(short n) const
double centroid_m[2 *Dim]
holds the centroid of the beam
virtual double getPx(int i)
Vector_t get_pmean_Distribution() const
void setBConds(const ParticleBConds< Position_t, Dimension > &bc)
ParticleAttrib< short > cavityGapCrossed
size_t getNumberOfEmissionSteps()
ParticleAttrib< double > Phi
void calcLineDensity(unsigned int nBins, std::vector< double > &lineDensity, std::pair< double, double > &meshInfo)
calculates the 1d line density (not normalized) and append it to a file.
double dt_m
holds the timestep in seconds
Vector_t get_68Percentile() const
void setup(AbstractParticle< T, Dim > *pb)
virtual void setBCAllOpen()
void setTotalNum(size_t n)
CoordinateSystemTrafo toLabTrafo_m
void calcBeamParametersInitial()
IpplTimings::TimerRef boundpBoundsTimer_m
FieldSolver * fs_m
stores the used field solver
std::pair< Vector_t, Vector_t > VectorPair_t
void setKs3DRefp(Vector_t p)
AbstractParticle< T, Dim >::Position_t Position_t
long long getLocalTrackStep() const
void setGlobalMeanR(Vector_t globalMeanR)
void setCouplingConstant(double c)
short getNumBunch() const
virtual void computeSelfFields(int bin)=0
virtual void do_binaryRepart()
ParticleAttrib< int > TriID
Vector_t get_norm_emit() const
void calcGammas()
Compute the gammas of all bins.
double dh_m
Mesh enlargement.
ParticleAttrib< double > dt
int getStepsPerTurn() const
PartBunchBase(const PartBunchBase &rhs)=delete
Vector_t get_rprms() const
IpplTimings::TimerRef boundpUpdateTimer_m
static const unsigned Dimension
double couplingConstant_m
std::vector< size_t > bunchLocalNum_m
void setPOrigin(ParticleOrigin)
Vector_t get_maxExtent() const
Vector_t get_normalizedEps_95Percentile() const
void gatherLoadBalanceStatistics()
void countTotalNumPerBunch()
DistributionType getDistType() const
void get_PBounds(Vector_t &min, Vector_t &max) const
virtual void setBinCharge(int bin, double q)
Set the charge of one bin to the value of q and all other to zero.
Vector_t get_halo() const
void performDestroy(bool updateLocalNum=false)
Vector_t getGlobalMeanR()
void ghostDestroy(size_t M, size_t I)
int getNumberOfEnergyBins()
Vector_t hr_m
meshspacing of cartesian mesh
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
std::pair< Vector_t, double > getBoundingSphere()
double tEmission_m
relative enlargement of the mesh
Vector_t get_centroid() const
Vector_t get_99_99Percentile() const
void push_back(OpalParticle const &p)
virtual double getX(int i)
virtual double getPz(int i)
ParticleAttrib< short > bunchNum
void setLocalNum(size_t n)
std::unique_ptr< std::ofstream > f_stream
Vector_t get_pmean() const
void setTotalNumPerBunch(size_t numpart, short n)
virtual void setBCForDCBeam()
void setKs3DRefr(Vector_t r)
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Bf
IpplTimings::TimerRef distrCreate_m
void globalCreate(size_t np)
AbstractParticle< T, Dim >::UpdateFlags UpdateFlags_t
Vector_t get_normalizedEps_99_99Percentile() const
OpalParticle getParticle(int ii)
virtual void swap(unsigned int i, unsigned int j)
std::unique_ptr< size_t[]> globalPartPerNode_m
void setPBins(PartBins *pbin)
ConstIterator end() const
int distDump_m
counter to store the distribution dump
ConstIterator begin() const
size_t getDestroyNum() const
virtual double getGamma(int i)
virtual void setSolver(FieldSolver *fs)
long long getGlobalTrackStep() const
std::unique_ptr< double[]> bingamma_m
holds the gamma of the bin
size_t getGhostNum() const
void setTEmission(double t)
size_t getLoadBalance(int p) const
virtual void computeSelfFields_cycl(int bin)=0
std::pair< Vector_t, double > getLocalBoundingSphere()
virtual Vector_t get_hr() const
DistributionMoments momentsComputer_m
Vector_t get_emit() const
double calculateAngle(double x, double y)
angle range [0~2PI) degree
virtual FieldLayout_t & getFieldLayout()=0
virtual VectorPair_t getEExtrema()=0
void calcDebyeLength()
Compute the (global) Debye length for the beam.
void iterateEmittedBin(int binNumber)
bool singleInitNode() const
void setUpdateFlag(UpdateFlags_t f, bool val)
Vektor< int, 3 > nr_m
meshsize of cartesian mesh
void calcMomentsInitial()
UnitState_t stateOfLastBoundP_
virtual double getY(int i)
ParticleOrigin refPOrigin_m
void switchOffUnitlessPositions(bool use_dt_per_particle=false)
void setStepsPerTurn(int n)
IpplTimings::TimerRef selfFieldTimer_m
timer for selfField calculation
virtual double getZ(int i)
Vector_t get_rmean() const
bool operator!=(ConstIterator const &rhs) const
int operator-(const ConstIterator &other) const
OpalParticle operator*() const
bool operator==(ConstIterator const &rhs) const
ConstIterator(PartBunchBase const *bunch, unsigned int i)
ConstIterator operator++()
PartBunchBase const * bunch_m
ConstIterator operator++(int)
An abstract sequence of beam line components.
A templated representation for vectors.
ParticleLayout< T, Dim >::Position_t Position_t
Timing::TimerRef TimerRef