OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
PartBunchBase.h
Go to the documentation of this file.
1 //
2 // Class PartBunchBase
3 // Base class for representing particle bunches.
4 //
5 // Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #ifndef PART_BUNCH_BASE_H
19 #define PART_BUNCH_BASE_H
20 
23 #include "Utility/IpplTimings.h"
25 
29 #include "Algorithms/PBunchDefs.h"
30 #include "Algorithms/Quaternion.h"
31 #include "Algorithms/Vektor.h"
32 
33 #include "FixedAlgebra/FMatrix.h"
34 #include "FixedAlgebra/FVector.h"
35 
36 #include <memory>
37 #include <utility>
38 #include <vector>
39 
40 class Distribution;
41 class FieldSolver;
42 class PartBins;
43 class PartBinsCyc;
44 class PartData;
45 
46 enum class ParticleOrigin:short {REGULAR,
47  SECONDARY,
48  STRIPPED};
49 
50 enum class ParticleType:short {ELECTRON,
51  PROTON,
52  POSITRON,
53  ANTIPROTON,
54  CARBON,
55  HMINUS,
56  URANIUM,
57  MUON,
58  DEUTERON,
59  XENON,
60  H2P,
61  ALPHA,
62  HYDROGEN,
63  H3P,
64  UNNAMED};
65 
66 template <class T, unsigned Dim>
67 class PartBunchBase : std::enable_shared_from_this<PartBunchBase<T, Dim>>
68 {
69 public:
74 
75  typedef std::pair<Vector_t, Vector_t> VectorPair_t;
76 
77  static const unsigned Dimension = Dim;
78 
79  enum UnitState_t { units = 0, unitless = 1 };
80 
81 public:
82  virtual ~PartBunchBase() { }
83 
85 
86  PartBunchBase(const PartBunchBase& rhs) = delete; // implement if needed
87 
88  /*
89  * Bunch common member functions
90  */
91 
92  // This is required since we initialize the Layout and the RegionLayout with default constructor
93  virtual void initialize(FieldLayout_t* fLayout) = 0;
94 
95  bool getIfBeamEmitting();
96 
98 
99  size_t getNumberOfEmissionSteps();
100 
101  int getNumberOfEnergyBins();
102 
103  void Rebin();
104 
105  void setEnergyBins(int numberOfEnergyBins);
106 
107  bool weHaveEnergyBins();
108 
109  //FIXME: unify methods, use convention that all particles have own dt
110  void switchToUnitlessPositions(bool use_dt_per_particle = false);
111 
112  //FIXME: unify methods, use convention that all particles have own dt
113  void switchOffUnitlessPositions(bool use_dt_per_particle = false);
114 
116  std::vector<Distribution*> addedDistributions,
117  size_t& np);
118 
119  bool isGridFixed() const;
120 
121  bool hasBinning() const;
122 
123 
124  /*
125  Energy bins related functions
126  */
127 
128  void setTEmission(double t);
129 
130  double getTEmission();
131 
132  bool doEmission();
133 
134  bool weHaveBins() const;
135 
136  void setPBins(PartBins* pbin);
137 
138  void setPBins(PartBinsCyc* pbin);
139 
144  size_t emitParticles(double eZ);
145 
146  void updateNumTotal();
147 
148  void rebin();
149 
150  int getLastemittedBin();
151 
152  void setLocalBinCount(size_t num, int bin);
153 
155  void calcGammas();
156 
157  void calcGammas_cycl();
158 
160  double getBinGamma(int bin);
161 
163  virtual void setBinCharge(int bin, double q);
164 
166  virtual void setBinCharge(int bin);
167 
169  size_t calcNumPartsOutside(Vector_t x);
170 
171  void calcLineDensity(unsigned int nBins, std::vector<double>& lineDensity,
172  std::pair<double, double>& meshInfo);
173 
174  void setBeamFrequency(double v);
175 
176  /*
177  Mesh and Field Layout related functions
178  */
179 
180  virtual void boundp();
181 
183  void boundp_destroyCycl();
184 
186  size_t boundp_destroyT();
187 
188  size_t destroyT();
189 
190  /*
191  Read out coordinates
192  */
193  virtual double getPx(int i);
194  virtual double getPy(int i);
195  virtual double getPz(int i);
196 
197  virtual double getPx0(int i);
198  virtual double getPy0(int i);
199 
200  virtual double getX(int i);
201  virtual double getY(int i);
202  virtual double getZ(int i);
203 
204  virtual double getX0(int i);
205  virtual double getY0(int i);
206 
207  virtual void setZ(int i, double zcoo);
208 
209  void get_bounds(Vector_t& rmin, Vector_t& rmax);
210 
211  void getLocalBounds(Vector_t& rmin, Vector_t& rmax);
212 
213  std::pair<Vector_t, double> getBoundingSphere();
214 
215  std::pair<Vector_t, double> getLocalBoundingSphere();
216 
217 
218  /*
219  Compatibility function push_back
220  */
221  void push_back(OpalParticle const& p);
222 
223  void setParticle(FVector<double, 6> z, int ii);
224 
225  void setParticle(OpalParticle const& p, int ii);
226 
227  OpalParticle getParticle(int ii);
228 
230  friend class PartBunchBase<T, Dim>;
231 
232  public:
234  bunch_m(nullptr),
235  index_m(0)
236  {}
237  ConstIterator(PartBunchBase const* bunch, unsigned int i):
238  bunch_m(bunch),
239  index_m(i)
240  {}
241 
243  {}
244 
245  bool operator == (ConstIterator const& rhs) const
246  {
247  return bunch_m == rhs.bunch_m && index_m == rhs.index_m;
248  }
249 
250  bool operator != (ConstIterator const& rhs) const
251  {
252  return bunch_m != rhs.bunch_m || index_m != rhs.index_m;
253  }
254 
256  {
257  if (index_m >= bunch_m->getLocalNum()) {
258  throw GeneralClassicException("PartBunchBase::ConstIterator::operator*", "out of bounds");
259  }
260  return OpalParticle(bunch_m->ID[index_m],
261  bunch_m->R[index_m],
262  bunch_m->P[index_m],
263  bunch_m->getT(),
264  bunch_m->Q[index_m],
265  bunch_m->getM() * 1e-6);
266  }
267 
269  {
270  ++index_m;
271  return *this;
272  }
273 
275  {
276  ConstIterator it = *this;
277  ++index_m;
278 
279  return it;
280  }
281 
282  int operator-(const ConstIterator& other) const
283  {
284  return index_m - other.index_m;
285  }
286  private:
288  unsigned int index_m;
289  };
290 
292  return ConstIterator(this, 0);
293  }
294 
295  ConstIterator end() const {
296  return ConstIterator(this, getLocalNum());
297  }
298 
300  // The matrix [b]D[/b] is used to normalise the first two modes.
301  // The maximum normalised amplitudes for these modes are stored
302  // in [b]axmax[/b] and [b]aymax[/b].
304  double& axmax, double& aymax);
305 
306  void setdT(double dt);
307  double getdT() const;
308 
309  void setT(double t);
310  void incrementT();
311  double getT() const;
312 
319  double get_sPos() const;
320 
321  void set_sPos(double s);
322 
323  double get_gamma() const;
324  double get_meanKineticEnergy() const;
325  Vector_t get_origin() const;
326  Vector_t get_maxExtent() const;
327  Vector_t get_centroid() const;
328  Vector_t get_rrms() const;
329  Vector_t get_rprms() const;
330  Vector_t get_rmean() const;
331  Vector_t get_prms() const;
332  Vector_t get_pmean() const;
334  Vector_t get_emit() const;
335  Vector_t get_norm_emit() const;
336  Vector_t get_halo() const;
337  virtual Vector_t get_hr() const;
338 
339  double get_Dx() const;
340  double get_Dy() const;
341  double get_DDx() const;
342  double get_DDy() const;
343 
344  virtual void set_meshEnlargement(double dh);
345 
347  size_t getLoadBalance(int p) const;
348 
349  void get_PBounds(Vector_t &min, Vector_t &max) const;
350 
351  void calcBeamParameters();
352  void calcBeamParametersInitial(); // Calculate initial beam parameters before emission.
353 
354  double getCouplingConstant() const;
355  void setCouplingConstant(double c);
356 
357  // set the charge per simulation particle
358  void setCharge(double q);
359  // set the charge per simulation particle when total particle number equals 0
360  void setChargeZeroPart(double q);
361 
362  // set the mass per simulation particle
363  void setMass(double mass);
364  void setMassZeroPart(double mass);
365 
367  double getCharge() const;
368 
370  double getChargePerParticle() const;
371 
372  double getMassPerParticle() const;
373 
374  virtual void setSolver(FieldSolver *fs);
375 
376  bool hasFieldSolver();
377 
378  std::string getFieldSolverType() const;
379 
380  void setStepsPerTurn(int n);
381  int getStepsPerTurn() const;
382 
384  void setGlobalTrackStep(long long n);
385  long long getGlobalTrackStep() const;
386 
388  void setLocalTrackStep(long long n);
389  void incTrackSteps();
390  long long getLocalTrackStep() const;
391 
392  void setNumBunch(short n);
393  short getNumBunch() const;
394 
395  // used in ParallelCyclotronTracker for multi-bunch mode
396  void setTotalNumPerBunch(size_t numpart, short n);
397  size_t getTotalNumPerBunch(short n) const;
398 
399  void setLocalNumPerBunch(size_t numpart, short n);
400  size_t getLocalNumPerBunch(short n) const;
401 
402  /* used in initializeTracking_m of ParallelCyclotronTracker
403  * for multi-bunch mode
404  */
405  void countTotalNumPerBunch();
406 
407  void setGlobalMeanR(Vector_t globalMeanR);
409  void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion);
411 
412  void setSteptoLastInj(int n);
413  int getSteptoLastInj() const;
414 
416  double calcMeanPhi();
417 
419  bool resetPartBinID2(const double eta);
420 
421  bool resetPartBinBunch();
422 
424  double getQ() const;
425  double getM() const;
426  double getP() const;
427  double getE() const;
428  ParticleOrigin getPOrigin() const;
429  ParticleType getPType() const;
430  std::string getPTypeString();
431  double getInitialBeta() const;
432  double getInitialGamma() const;
435  void resetQ(double q);
436  void resetM(double m);
438  void setPType(std::string type);
440  double getdE() const;
441  virtual double getGamma(int i);
442  virtual double getBeta(int i);
443  virtual void actT();
444 
445  const PartData* getReference() const;
446 
447  double getEmissionDeltaT();
448 
455 
456  void iterateEmittedBin(int binNumber);
457 
458  void calcEMean();
459 
460  Inform& print(Inform& os);
461 
462  /*
463  * (Pure) virtual member functions
464  */
465 
466  virtual void runTests();
467 
468  virtual void do_binaryRepart();
469 
470  virtual void resetInterpolationCache(bool clearCache = false);
471 
472  //brief calculates back the max/min of the efield on the grid
473  virtual VectorPair_t getEExtrema() = 0;
474 
475  virtual double getRho(int x, int y, int z) = 0;
476 
477  virtual void computeSelfFields() = 0;
478 
479  //brief used for self fields with binned distribution
480  virtual void computeSelfFields(int bin) = 0;
481 
482  virtual void computeSelfFields_cycl(double gamma) = 0;
483  virtual void computeSelfFields_cycl(int bin) = 0;
484 
485  virtual void swap(unsigned int i, unsigned int j);
486 
487  /*
488  Mesh and Field Layout related functions
489  */
490 
491  virtual void setBCAllPeriodic();
492  virtual void setBCAllOpen();
493 
494  virtual void setBCForDCBeam();
495 
496 
497 // virtual void setMesh(Mesh_t* mesh) = 0;
498 // virtual Mesh_t &getMesh() = 0;
499 
500 // virtual void setFieldLayout(FieldLayout_t* fLayout) = 0;
502 
503  virtual void resizeMesh() { };
504 
505  /*
506  * Wrapped member functions of IpplParticleBase
507  */
508 
509  size_t getTotalNum() const;
510  void setTotalNum(size_t n);
511  void setLocalNum(size_t n);
512  size_t getLocalNum() const;
513 
514  size_t getDestroyNum() const;
515  size_t getGhostNum() const;
516 
518  const ParticleLayout<T, Dim>& getLayout() const;
519 
520  bool getUpdateFlag(UpdateFlags_t f) const;
521  void setUpdateFlag(UpdateFlags_t f, bool val);
522 
523 
525  return pbase_m->getBConds();
526  }
527 
529  pbase_m->setBConds(bc);
530  }
531 
532  bool singleInitNode() const;
533 
534  void resetID();
535 
536  void update();
537  void update(const ParticleAttrib<char>& canSwap);
538 
539  void createWithID(unsigned id);
540  void create(size_t M);
541  void globalCreate(size_t np);
542 
543  void destroy(size_t M, size_t I, bool doNow = false);
544  void performDestroy(bool updateLocalNum = false);
545  void ghostDestroy(size_t M, size_t I);
546 
547 protected:
548  size_t calcMoments(); // Calculates bunch moments using only emitted particles.
549 
550  /* Calculates bunch moments by summing over bins
551  * (not accurate when any particles have been emitted).
552  */
555  double calculateAngle(double x, double y);
556 
557 
558 private:
559  virtual void updateDomainLength(Vektor<int, 3>& grid) = 0;
560 
561  virtual void updateFields(const Vector_t& hr, const Vector_t& origin);
562 
564 
565 public:
566  /*
567  * Bunch attributes
568  */
571 
572  // Particle container attributes
573  ParticleAttrib< Vector_t > P; // particle momentum // ParticleSpatialLayout<double, 3>::ParticlePos_t P;
574  ParticleAttrib< double > Q; // charge per simulation particle, unit: C.
575  ParticleAttrib< double > M; // mass per simulation particle, for multi-species particle tracking, unit:GeV/c^2.
576  ParticleAttrib< double > Phi; // the electric potential
577  ParticleAttrib< Vector_t > Ef; // e field vector
578  ParticleAttrib< Vector_t > Eftmp; // e field vector for gun simulations
579 
580  ParticleAttrib< Vector_t > Bf; // b field vector
581  ParticleAttrib< int > Bin; // holds the bin in which the particle is in, if zero particle is marked for deletion
582  ParticleAttrib< double > dt; // holds the dt timestep for particle
584  ParticleAttrib< ParticleOrigin > POrigin; // we can distinguish dark current particles from primary particle
585  ParticleAttrib< int > TriID; // holds the ID of triangle that the particle hit. Only for BoundaryGeometry case.
586  ParticleAttrib< short > cavityGapCrossed; // particle just crossed cavity gap (for ParallelCyclotronTracker)
587  ParticleAttrib< short > bunchNum; // bunch number to which particle belongs (multi-bunch mode)
588 
591 
593 
596 
597  // The structure for particle binning
599 
603 
604  // For AMTS integrator in OPAL-T
606 
607  // get 2nd order momentum matrix
609 
610 private:
611  // save particles in case of one core
612  std::unique_ptr<Inform> pmsg_m;
613  std::unique_ptr<std::ofstream> f_stream;
616 
617 protected:
622 
626 
628 
629  /*
630  Member variables starts here
631  */
632 
633  // unit state of PartBunch
636 
638  double centroid_m[2 * Dim];
639 
642 
644  double dt_m;
646  double t_m;
648  double spos_m;
649 
653  //Vector_t globalMeanR_m = Vector_t(0.0, 0.0, 0.0);
654  //Quaternion_t globalToLocalQuaternion_m = Quaternion_t(1.0, 0.0, 0.0, 0.0);
657 
662 
667 
670 
672 
673  double qi_m;
675 
678 
680  double dh_m;
681 
683  double tEmission_m;
684 
686  std::unique_ptr<double[]> bingamma_m;
687 
688  //FIXME: this should go into the Bin class!
689  // holds number of emitted particles of the bin
690  // jjyang: opal-cycl use *nBin_m of pbin_m
691  std::unique_ptr<size_t[]> binemitted_m;
692 
695 
697  long long localTrackStep_m;
698 
700  long long globalTrackStep_m;
701 
703  short numBunch_m;
704 
706  std::vector<size_t> bunchTotalNum_m;
707  std::vector<size_t> bunchLocalNum_m;
708 
713 
714  /*
715  Data structure for particle load balance information
716  */
717 
718  std::unique_ptr<size_t[]> globalPartPerNode_m;
719 
722 
723  // flag to tell if we are a DC-beam
724  bool dcBeam_m;
726  std::shared_ptr<AbstractParticle<T, Dim> > pbase_m;
727 };
728 
729 template<class T, unsigned Dim>
731  return bunch.begin();
732 }
733 
734 template<class T, unsigned Dim>
736  return bunch.end();
737 }
738 
739 #include "PartBunchBase.hpp"
740 
741 #endif
ParticleOrigin
Definition: PartBunchBase.h:46
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
ParticleType
Definition: PartBunchBase.h:50
const unsigned Dim
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:76
constexpr double e
The value of.
Definition: Physics.h:39
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:51
boost::function< boost::tuple< double, bool >arguments_t)> type
Definition: function.hpp:21
FRONT * fs
Definition: hypervolume.cpp:59
ParticleLayout< T, Dim > & getLayout()
double get_Dx() const
double getP() const
void setEnergyBins(int numberOfEnergyBins)
ParticleAttrib< Vector_t > Ef
double get_meanKineticEnergy() const
std::shared_ptr< AbstractParticle< T, Dim > > pbase_m
ParticlePos_t & R
double spos_m
the position along design trajectory
AbstractParticle< T, Dim >::ParticleIndex_t ParticleIndex_t
Definition: PartBunchBase.h:71
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
long long localTrackStep_m
step in a TRACK command
ParticleBConds< Position_t, Dimension > & getBConds()
const PartData * getReference() const
ParticleAttrib< int > Bin
ParticleOrigin getPOrigin() const
void setMass(double mass)
void setCharge(double q)
Vector_t RefPartP_m
int getSteptoLastInj() const
void boundp_destroyCycl()
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)
std::string getPTypeString()
double periodLength_m
double getMassPerParticle() const
bool fixed_grid
if the grid does not have to adapt
double getQ() const
Access to reference data.
double getCouplingConstant() const
double getChargePerParticle() const
get the macro particle charge
virtual void computeSelfFields()=0
virtual void set_meshEnlargement(double dh)
UnitState_t unit_state_
void resetM(double m)
ParticleAttrib< Vector_t > Eftmp
virtual double getBeta(int i)
void getLocalBounds(Vector_t &rmin, Vector_t &rmax)
virtual double getPx0(int i)
size_t getLocalNum() const
IpplTimings::TimerRef boundpTimer_m
double t_m
holds the actual time of the integration
void set_sPos(double s)
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
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.
void setMassZeroPart(double mass)
size_t getTotalNum() const
bool weHaveEnergyBins()
double get_DDy() const
virtual void updateFields(const Vector_t &hr, const Vector_t &origin)
bool resetPartBinBunch()
virtual void setZ(int i, double zcoo)
std::unique_ptr< size_t[]> binemitted_m
AbstractParticle< T, Dim >::ParticlePos_t ParticlePos_t
Definition: PartBunchBase.h:70
double calcMeanPhi()
calculate average angle of longitudinal direction of bins
Quaternion_t getGlobalToLocalQuaternion()
const PartData * reference
size_t boundp_destroyT()
void setBeamFrequency(double v)
double get_gamma() const
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
double getTEmission()
AbstractParticle< T, Dim >::UpdateFlags UpdateFlags_t
Definition: PartBunchBase.h:72
virtual ~PartBunchBase()
Definition: PartBunchBase.h:82
IpplTimings::TimerRef histoTimer_m
ParticleAttrib< ParticleType > PType
short numBunch_m
current bunch number
double getdT() const
Quaternion_t globalToLocalQuaternion_m
virtual void initialize(FieldLayout_t *fLayout)=0
Inform & print(Inform &os)
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
bool getIfBeamEmitting()
bool weHaveBins() const
Vector_t RefPartR_m
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 setSteptoLastInj(int n)
virtual double getX0(int i)
virtual double getRho(int x, int y, int z)=0
double getInitialGamma() const
virtual void setBCAllPeriodic()
virtual void runTests()
void setQKs3D(Quaternion_t q)
Vector_t rmin_m
minimal extend of particles
void setChargeZeroPart(double q)
virtual double getY0(int i)
AbstractParticle< T, Dim >::Position_t Position_t
Definition: PartBunchBase.h:73
int stepsPerTurn_m
steps per turn for OPAL-cycl
IpplTimings::TimerRef statParamTimer_m
ParticleType getPType() const
Vector_t get_origin() const
Distribution * dist_m
Vector_t get_prms() const
double getdE() const
virtual FieldLayout_t & getFieldLayout()=0
FMatrix< double, 2 *Dim, 2 *Dim > moments_m
6x6 matrix of the moments of the beam
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)
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
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
Definition: PartBunchBase.h:75
void setKs3DRefp(Vector_t p)
long long getLocalTrackStep() const
void setGlobalMeanR(Vector_t globalMeanR)
PartBins * pbin_m
void setCouplingConstant(double c)
short getNumBunch() const
double get_DDx() 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
void setdT(double dt)
double get_Dy() const
Vector_t get_rprms() const
IpplTimings::TimerRef boundpUpdateTimer_m
Quaternion_t getQKs3D()
static const unsigned Dimension
Definition: PartBunchBase.h:77
double couplingConstant_m
std::vector< size_t > bunchLocalNum_m
void setPOrigin(ParticleOrigin)
Vector_t get_maxExtent() const
void gatherLoadBalanceStatistics()
void countTotalNumPerBunch()
void get_bounds(Vector_t &rmin, Vector_t &rmax)
void get_PBounds(Vector_t &min, Vector_t &max) const
void calcGammas_cycl()
virtual void setBinCharge(int bin, double q)
Set the charge of one bin to the value of q and all other to zero.
bool isGridFixed() const
Vector_t get_halo() const
void performDestroy(bool updateLocalNum=false)
Vector_t getGlobalMeanR()
void ghostDestroy(size_t M, size_t I)
ParticleType refPType_m
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
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()
bool hasBinning() const
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)
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix()
OpalParticle getParticle(int ii)
virtual void swap(unsigned int i, unsigned int j)
virtual void actT()
std::unique_ptr< size_t[]> globalPartPerNode_m
void setPType(std::string type)
void setPBins(PartBins *pbin)
Vector_t globalMeanR_m
virtual void boundp()
ConstIterator end() const
int distDump_m
counter to store the distribution dump
ConstIterator begin() const
void create(size_t M)
Vector_t getKs3DRefp()
size_t getDestroyNum() const
virtual double getGamma(int i)
void resetQ(double q)
double massPerParticle_m
virtual void setSolver(FieldSolver *fs)
long long getGlobalTrackStep() const
std::unique_ptr< double[]> bingamma_m
holds the gamma of the bin
void setT(double t)
Vector_t getKs3DRefr()
size_t calcMoments()
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()
std::string getFieldSolverType() const
Return the fieldsolver type if we have a fieldsolver.
virtual Vector_t get_hr() const
DistributionMoments momentsComputer_m
ParticleIndex_t & ID
Vector_t get_emit() const
double calculateAngle(double x, double y)
angle range [0~2PI) degree
virtual VectorPair_t getEExtrema()=0
double get_sPos() const
void iterateEmittedBin(int binNumber)
bool singleInitNode() const
double getM() 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)
double getT() const
ParticleOrigin refPOrigin_m
double getE() const
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)
PartBunchBase const * bunch_m
ConstIterator operator++(int)
Particle reference data.
Definition: PartData.h:35
A templated representation for vectors.
Definition: FVector.h:38
The FieldSolver definition.
Definition: FieldSolver.h:43
ParticleLayout< T, Dim >::Position_t Position_t
Definition: Inform.h:42
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176