18 #ifndef PART_BUNCH_BASE_H
19 #define PART_BUNCH_BASE_H
48 template <
class T,
unsigned Dim>
49 class 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);
280 return ConstIterator(
this, 0);
283 ConstIterator
end()
const {
292 double& axmax,
double& aymax);
295 double getdT()
const;
439 double getdE()
const;
478 virtual double getRho(
int x,
int y,
int z) = 0;
488 virtual void swap(
unsigned int i,
unsigned int j);
546 void destroy(
size_t M,
size_t I,
bool doNow =
false);
729 std::shared_ptr<AbstractParticle<T, Dim> >
pbase_m;
732 template<
class T,
unsigned Dim>
734 return bunch.
begin();
737 template<
class T,
unsigned Dim>
A templated representation for vectors.
ParticleOrigin refPOrigin_m
virtual void computeSelfFields()=0
ConstIterator begin() const
ParticleAttrib< short > cavityGapCrossed
virtual void setZ(int i, double zcoo)
double get_rmsDensity() const
void setTotalNum(size_t n)
void calcBeamParametersInitial()
constexpr double c
The velocity of light in m/s.
void push_back(OpalParticle const &p)
void setMass(double mass)
void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion)
ConstIterator(PartBunchBase const *bunch, unsigned int i)
virtual double getX0(int i)
Vector_t get_normalizedEps_99Percentile() const
ParticleAttrib< ParticleOrigin > POrigin
virtual void do_binaryRepart()
void setPBins(PartBins *pbin)
ParticleAttrib< int > TriID
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
double calculateAngle(double x, double y)
angle range [0~2PI) degree
IpplTimings::TimerRef boundpUpdateTimer_m
void setLocalBinCount(size_t num, int bin)
virtual void setBCForDCBeam()
void setLocalTrackStep(long long n)
step in a TRACK command
Vector_t getGlobalMeanR()
std::pair< Vector_t, double > getLocalBoundingSphere()
long long globalTrackStep_m
if multiple TRACK commands
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
std::pair< Vector_t, double > getBoundingSphere()
virtual void initialize(FieldLayout_t *fLayout)=0
void createWithID(unsigned id)
Vector_t get_emit() const
void setMassZeroPart(double mass)
Vector_t get_rprms() const
Vector_t hr_m
meshspacing of cartesian mesh
ParticleAttrib< Vector_t > P
virtual VectorPair_t getEExtrema()=0
void switchOffUnitlessPositions(bool use_dt_per_particle=false)
std::vector< size_t > bunchLocalNum_m
ParticleAttrib< ParticleType > PType
PartBunchBase const * bunch_m
void setQKs3D(Quaternion_t q)
size_t getDestroyNum() const
std::unique_ptr< double[]> bingamma_m
holds the gamma of the bin
void setKs3DRefp(Vector_t p)
IpplTimings::TimerRef distrCreate_m
virtual double getPx0(int i)
DistributionMoments momentsComputer_m
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Ef
Inform & print(Inform &os)
Vector_t get_centroid() const
void setPType(const std::string &type)
void calcGammas()
Compute the gammas of all bins.
ParticleAttrib< short > bunchNum
Vektor< int, 3 > nr_m
meshsize of cartesian mesh
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
virtual double getRho(int x, int y, int z)=0
double getCouplingConstant() const
Vector_t get_pmean_Distribution() const
ParticleAttrib< double > M
long long localTrackStep_m
step in a TRACK command
bool operator==(ConstIterator const &rhs) const
long long getLocalTrackStep() const
Vector_t get_pmean() const
int operator-(const ConstIterator &other) const
void calcBeamParameters()
int distDump_m
counter to store the distribution dump
UnitState_t stateOfLastBoundP_
An abstract sequence of beam line components.
ParticleLayout< T, Dim > & getLayout()
void setUpdateFlag(UpdateFlags_t f, bool val)
IpplTimings::TimerRef boundpBoundsTimer_m
Vector_t get_rrms() const
virtual void updateFields(const Vector_t &hr, const Vector_t &origin)
clearpage the user may choose between constant or variable radius This model includes fringe fields begin
double getQ() const
Access to reference data.
virtual Vector_t get_hr() const
size_t getGhostNum() const
double get_plasmaParameter() const
Vector_t get_prms() const
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Timing::TimerRef TimerRef
std::unique_ptr< std::ofstream > f_stream
size_t getNumberOfEmissionSteps()
CoordinateSystemTrafo toLabTrafo_m
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void setTEmission(double t)
virtual double getY0(int i)
ParticleAttrib< double > Phi
void setSteptoLastInj(int n)
ParticleAttrib< Vector_t > Bf
size_t emitParticles(double eZ)
Emit particles in the given bin i.e. copy the particles from the bin structure into the particle cont...
virtual double getPz(int i)
virtual double getZ(int i)
void setBeamFrequency(double v)
ParticleOrigin getPOrigin() const
void switchToUnitlessPositions(bool use_dt_per_particle=false)
IpplTimings::TimerRef statParamTimer_m
IpplTimings::TimerRef selfFieldTimer_m
timer for selfField calculation
double getInitialGamma() const
virtual void set_meshEnlargement(double dh)
ConstIterator operator++()
void setTotalNumPerBunch(size_t numpart, short n)
std::vector< size_t > bunchTotalNum_m
number of particles per bunch
size_t getTotalNum() const
size_t getLoadBalance(int p) const
void setParticle(FVector< double, 6 > z, int ii)
double spos_m
the position along design trajectory
virtual void resetInterpolationCache(bool clearCache=false)
int getStepsPerTurn() const
Vector_t get_origin() const
void setEnergyBins(int numberOfEnergyBins)
FieldSolver * fs_m
stores the used field solver
ParticleType getPType() const
ParticleAttrib< Vector_t > Eftmp
size_t getLocalNum() const
double getInitialBeta() const
int getNumberOfEnergyBins()
short numBunch_m
current bunch number
std::unique_ptr< size_t[]> globalPartPerNode_m
void setChargeZeroPart(double q)
IpplTimings::TimerRef distrReload_m
timer for IC, can not be in Distribution.h
void setPOrigin(ParticleOrigin)
double getEmissionDeltaT()
void calcDebyeLength()
Compute the (global) Debye length for the beam.
virtual void updateDomainLength(Vektor< int, 3 > &grid)=0
long long getGlobalTrackStep() const
void setLocalNum(size_t n)
virtual double getX(int i)
IpplTimings::TimerRef boundpTimer_m
OpalParticle operator*() const
ParticleAttrib< double > Q
virtual FieldLayout_t & getFieldLayout()=0
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
virtual void swap(unsigned int i, unsigned int j)
ParticleLayout< T, Dim >::Position_t Position_t
double getBinGamma(int bin)
Get gamma of one bin.
bool singleInitNode() const
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix() const
void getLocalBounds(Vector_t &rmin, Vector_t &rmax) const
IpplTimings::TimerRef histoTimer_m
static const unsigned Dimension
ParticleAttrib< double > dt
virtual void resizeMesh()
ConstIterator end() const
Quaternion_t getGlobalToLocalQuaternion()
int getLastEmittedEnergyBin()
double getChargePerParticle() const
get the macro particle charge
double getMassPerParticle() const
void setKs3DRefr(Vector_t r)
virtual void setBinCharge(int bin, double q)
Set the charge of one bin to the value of q and all other to zero.
void setStepsPerTurn(int n)
void get_PBounds(Vector_t &min, Vector_t &max) const
bool resetPartBinID2(const double eta)
reset Bin[] for each particle according to the method given in paper PAST-AB(064402) by G...
double centroid_m[2 *Dim]
holds the centroid of the beam
void setBConds(const ParticleBConds< Position_t, Dimension > &bc)
std::unique_ptr< Inform > pmsg_m
Vector_t get_rmean() const
double dt_m
holds the timestep in seconds
virtual double getY(int i)
const PartData * reference
void setNumBunch(short n)
Vector_t get_norm_emit() const
void gatherLoadBalanceStatistics()
ParticleBConds< Position_t, Dimension > & getBConds()
void boundp_destroyCycl()
void setGlobalMeanR(Vector_t globalMeanR)
double dh_m
Mesh enlargement.
std::unique_ptr< size_t[]> binemitted_m
virtual void computeSelfFields_cycl(double gamma)=0
void setLocalNumPerBunch(size_t numpart, short n)
void maximumAmplitudes(const FMatrix< double, 6, 6 > &D, double &axmax, double &aymax)
Return maximum amplitudes.
Vector_t get_99Percentile() const
virtual void setBCAllOpen()
void countTotalNumPerBunch()
Quaternion_t globalToLocalQuaternion_m
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 getCharge() const
get the total charge per simulation particle
void setup(AbstractParticle< T, Dim > *pb)
void ghostDestroy(size_t M, size_t I)
Vector_t get_99_99Percentile() const
OpalParticle getParticle(int ii)
void iterateEmittedBin(int binNumber)
ConstIterator operator++(int)
const PartData * getReference() const
std::pair< Vector_t, Vector_t > VectorPair_t
void performDestroy(bool updateLocalNum=false)
bool fixed_grid
if the grid does not have to adapt
double get_meanKineticEnergy() const
ParticleAttrib< int > Bin
short getNumBunch() const
FieldSolverType getFieldSolverType() const
Return the fieldsolver type if we have a fieldsolver.
std::shared_ptr< AbstractParticle< T, Dim > > pbase_m
Vector_t get_normalizedEps_68Percentile() const
virtual double getPy(int i)
virtual double getGamma(int i)
DistributionType getDistType() const
Vector_t get_maxExtent() const
size_t calcNumPartsOutside(Vector_t x)
returns the number of particles outside of a box defined by x
void calcMomentsInitial()
Vector_t get_halo() const
double tEmission_m
relative enlargement of the mesh
virtual double getPy0(int i)
int stepsPerTurn_m
steps per turn for OPAL-cycl
void globalCreate(size_t np)
Vector_t rmin_m
minimal extend of particles
double get_temperature() const
AbstractParticle< T, Dim >::ParticleIndex_t ParticleIndex_t
bool getUpdateFlag(UpdateFlags_t f) const
double t_m
holds the actual time of the integration
AbstractParticle< T, Dim >::Position_t Position_t
virtual double getBeta(int i)
bool operator!=(ConstIterator const &rhs) const
virtual double getPx(int i)
Vector_t get_95Percentile() const
Vector_t get_normalizedEps_95Percentile() const
double couplingConstant_m
PartBunchBase(AbstractParticle< T, Dim > *pb, const PartData *ref)
double get_debyeLength() const
virtual void setBCAllPeriodic()
size_t getTotalNumPerBunch(short n) const
AbstractParticle< T, Dim >::UpdateFlags UpdateFlags_t
size_t getLocalNumPerBunch(short n) const
double calcMeanPhi()
calculate average angle of longitudinal direction of bins
Vector_t get_normalizedEps_99_99Percentile() const
double getMomentumTolerance() const
Vector_t get_68Percentile() const
int getSteptoLastInj() const
virtual void setSolver(FieldSolver *fs)
Vector_t rmax_m
maximal extend of particles
AbstractParticle< T, Dim >::ParticlePos_t ParticlePos_t
void setCouplingConstant(double c)