OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 
24 #include "Algorithms/PBunchDefs.h"
25 #include "Algorithms/Quaternion.h"
26 #include "Algorithms/Vektor.h"
28 #include "FixedAlgebra/FMatrix.h"
29 #include "FixedAlgebra/FVector.h"
33 #include "Physics/Units.h"
34 #include "Structure/FieldSolver.h"
36 #include "Utility/IpplTimings.h"
37 
38 #include <memory>
39 #include <utility>
40 #include <vector>
41 
42 class Distribution;
43 class FieldSolver;
44 class PartBins;
45 class PartBinsCyc;
46 class PartData;
47 
48 template <class T, unsigned Dim>
49 class PartBunchBase : std::enable_shared_from_this<PartBunchBase<T, Dim>>
50 {
51 public:
56 
57  typedef std::pair<Vector_t, Vector_t> VectorPair_t;
58 
59  static const unsigned Dimension = Dim;
60 
61  enum UnitState_t { units = 0, unitless = 1 };
62 
63 public:
64  virtual ~PartBunchBase() { }
65 
67 
68  PartBunchBase(const PartBunchBase& rhs) = delete; // implement if needed
69 
70  /*
71  * Bunch common member functions
72  */
73 
74  // This is required since we initialize the Layout and the RegionLayout with default constructor
75  virtual void initialize(FieldLayout_t* fLayout) = 0;
76 
77  bool getIfBeamEmitting();
78 
80 
81  size_t getNumberOfEmissionSteps();
82 
84 
85  void Rebin();
86 
87  void setEnergyBins(int numberOfEnergyBins);
88 
89  bool weHaveEnergyBins();
90 
91  //FIXME: unify methods, use convention that all particles have own dt
92  void switchToUnitlessPositions(bool use_dt_per_particle = false);
93 
94  //FIXME: unify methods, use convention that all particles have own dt
95  void switchOffUnitlessPositions(bool use_dt_per_particle = false);
96 
98  std::vector<Distribution*> addedDistributions,
99  size_t& np);
101  size_t numberOfParticles,
102  double current, const Beamline& bl);
103 
104  bool isGridFixed() const;
105 
106  bool hasBinning() const;
107 
108 
109  /*
110  Energy bins related functions
111  */
112 
113  void setTEmission(double t);
114 
115  double getTEmission();
116 
117  bool doEmission();
118 
119  bool weHaveBins() const;
120 
121  void setPBins(PartBins* pbin);
122 
123  void setPBins(PartBinsCyc* pbin);
124 
129  size_t emitParticles(double eZ);
130 
131  void updateNumTotal();
132 
133  void rebin();
134 
135  int getLastemittedBin();
136 
137  void setLocalBinCount(size_t num, int bin);
138 
140  void calcGammas();
141 
142  void calcGammas_cycl();
143 
145  void calcDebyeLength();
146 
148  double getBinGamma(int bin);
149 
151  virtual void setBinCharge(int bin, double q);
152 
154  virtual void setBinCharge(int bin);
155 
157  size_t calcNumPartsOutside(Vector_t x);
158 
159  void calcLineDensity(unsigned int nBins, std::vector<double>& lineDensity,
160  std::pair<double, double>& meshInfo);
161 
162  void setBeamFrequency(double v);
163 
164  /*
165  Mesh and Field Layout related functions
166  */
167 
168  virtual void boundp();
169 
171  void boundp_destroyCycl();
172 
174  size_t boundp_destroyT();
175 
176  size_t destroyT();
177 
178  /*
179  Read out coordinates
180  */
181  virtual double getPx(int i);
182  virtual double getPy(int i);
183  virtual double getPz(int i);
184 
185  virtual double getPx0(int i);
186  virtual double getPy0(int i);
187 
188  virtual double getX(int i);
189  virtual double getY(int i);
190  virtual double getZ(int i);
191 
192  virtual double getX0(int i);
193  virtual double getY0(int i);
194 
195  virtual void setZ(int i, double zcoo);
196 
197  void get_bounds(Vector_t& rmin, Vector_t& rmax) const;
198 
199  void getLocalBounds(Vector_t& rmin, Vector_t& rmax) const;
200 
201  std::pair<Vector_t, double> getBoundingSphere();
202 
203  std::pair<Vector_t, double> getLocalBoundingSphere();
204 
205 
206  /*
207  Compatibility function push_back
208  */
209  void push_back(OpalParticle const& p);
210 
211  void setParticle(FVector<double, 6> z, int ii);
212 
213  void setParticle(OpalParticle const& p, int ii);
214 
215  OpalParticle getParticle(int ii);
216 
218  friend class PartBunchBase<T, Dim>;
219 
220  public:
222  bunch_m(nullptr),
223  index_m(0)
224  {}
225  ConstIterator(PartBunchBase const* bunch, unsigned int i):
226  bunch_m(bunch),
227  index_m(i)
228  {}
229 
231  {}
232 
233  bool operator == (ConstIterator const& rhs) const
234  {
235  return bunch_m == rhs.bunch_m && index_m == rhs.index_m;
236  }
237 
238  bool operator != (ConstIterator const& rhs) const
239  {
240  return bunch_m != rhs.bunch_m || index_m != rhs.index_m;
241  }
242 
244  {
245  if (index_m >= bunch_m->getLocalNum()) {
246  throw GeneralClassicException("PartBunchBase::ConstIterator::operator*", "out of bounds");
247  }
248  return OpalParticle(bunch_m->ID[index_m],
249  bunch_m->R[index_m],
250  bunch_m->P[index_m],
251  bunch_m->getT(),
252  bunch_m->Q[index_m],
253  bunch_m->getM() * Units::eV2MeV);
254  }
255 
257  {
258  ++index_m;
259  return *this;
260  }
261 
263  {
264  ConstIterator it = *this;
265  ++index_m;
266 
267  return it;
268  }
269 
270  int operator-(const ConstIterator& other) const
271  {
272  return index_m - other.index_m;
273  }
274  private:
276  unsigned int index_m;
277  };
278 
279  ConstIterator begin() const {
280  return ConstIterator(this, 0);
281  }
282 
283  ConstIterator end() const {
284  return ConstIterator(this, getLocalNum());
285  }
286 
288  // The matrix [b]D[/b] is used to normalise the first two modes.
289  // The maximum normalised amplitudes for these modes are stored
290  // in [b]axmax[/b] and [b]aymax[/b].
292  double& axmax, double& aymax);
293 
294  void setdT(double dt);
295  double getdT() const;
296 
297  void setT(double t);
298  void incrementT();
299  double getT() const;
300 
307  double get_sPos() const;
308 
309  void set_sPos(double s);
310 
311  double get_gamma() const;
312  double get_meanKineticEnergy() const;
313  double get_temperature() const;
314  double get_debyeLength() const;
315  double get_plasmaParameter() const;
316  double get_rmsDensity() const;
317  Vector_t get_origin() const;
318  Vector_t get_maxExtent() const;
319  Vector_t get_centroid() const;
320  Vector_t get_rrms() const;
321  Vector_t get_rprms() const;
322  Vector_t get_rmean() const;
323  Vector_t get_prms() const;
324  Vector_t get_pmean() const;
326  Vector_t get_emit() const;
327  Vector_t get_norm_emit() const;
328  Vector_t get_halo() const;
329  Vector_t get_68Percentile() const;
330  Vector_t get_95Percentile() const;
331  Vector_t get_99Percentile() 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 
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  double getInitialBeta() const;
431  double getInitialGamma() const;
434  void resetQ(double q);
435  void resetM(double m);
437  void setPType(const std::string& type);
439  double getdE() const;
440  virtual double getGamma(int i);
441  virtual double getBeta(int i);
442  virtual void actT();
443 
444  const PartData* getReference() const;
445 
446  double getEmissionDeltaT();
447 
449 
450  double getMomentumTolerance() const;
451 
453  void setQKs3D(Quaternion_t q);
455  void setKs3DRefr(Vector_t r);
457  void setKs3DRefp(Vector_t p);
458 
459  void iterateEmittedBin(int binNumber);
460 
461  void calcEMean();
462 
463  Inform& print(Inform& os);
464 
465  /*
466  * (Pure) virtual member functions
467  */
468 
469  virtual void runTests();
470 
471  virtual void do_binaryRepart();
472 
473  virtual void resetInterpolationCache(bool clearCache = false);
474 
475  //brief calculates back the max/min of the efield on the grid
476  virtual VectorPair_t getEExtrema() = 0;
477 
478  virtual double getRho(int x, int y, int z) = 0;
479 
480  virtual void computeSelfFields() = 0;
481 
482  //brief used for self fields with binned distribution
483  virtual void computeSelfFields(int bin) = 0;
484 
485  virtual void computeSelfFields_cycl(double gamma) = 0;
486  virtual void computeSelfFields_cycl(int bin) = 0;
487 
488  virtual void swap(unsigned int i, unsigned int j);
489 
490  /*
491  Mesh and Field Layout related functions
492  */
493 
494  virtual void setBCAllPeriodic();
495  virtual void setBCAllOpen();
496 
497  virtual void setBCForDCBeam();
498 
499 
500 // virtual void setMesh(Mesh_t* mesh) = 0;
501 // virtual Mesh_t &getMesh() = 0;
502 
503 // virtual void setFieldLayout(FieldLayout_t* fLayout) = 0;
504  virtual FieldLayout_t& getFieldLayout() = 0;
505 
506  virtual void resizeMesh() { };
507 
508  /*
509  * Wrapped member functions of IpplParticleBase
510  */
511 
512  size_t getTotalNum() const;
513  void setTotalNum(size_t n);
514  void setLocalNum(size_t n);
515  size_t getLocalNum() const;
516 
517  size_t getDestroyNum() const;
518  size_t getGhostNum() const;
519 
521  const ParticleLayout<T, Dim>& getLayout() const;
522 
523  bool getUpdateFlag(UpdateFlags_t f) const;
524  void setUpdateFlag(UpdateFlags_t f, bool val);
525 
526 
528  return pbase_m->getBConds();
529  }
530 
532  pbase_m->setBConds(bc);
533  }
534 
535  bool singleInitNode() const;
536 
537  void resetID();
538 
539  void update();
540  void update(const ParticleAttrib<char>& canSwap);
541 
542  void createWithID(unsigned id);
543  void create(size_t M);
544  void globalCreate(size_t np);
545 
546  void destroy(size_t M, size_t I, bool doNow = false);
547  void performDestroy(bool updateLocalNum = false);
548  void ghostDestroy(size_t M, size_t I);
549 
550 protected:
551  size_t calcMoments(); // Calculates bunch moments using only emitted particles.
552 
553  /* Calculates bunch moments by summing over bins
554  * (not accurate when any particles have been emitted).
555  */
556  void calcMomentsInitial();
558  double calculateAngle(double x, double y);
559 
560 
561 private:
562  virtual void updateDomainLength(Vektor<int, 3>& grid) = 0;
563 
564  virtual void updateFields(const Vector_t& hr, const Vector_t& origin);
565 
567 
568 public:
569  /*
570  * Bunch attributes
571  */
574 
575  // Particle container attributes
576  ParticleAttrib< Vector_t > P; // particle momentum // ParticleSpatialLayout<double, 3>::ParticlePos_t P;
577  ParticleAttrib< double > Q; // charge per simulation particle, unit: C.
578  ParticleAttrib< double > M; // mass per simulation particle, for multi-species particle tracking, unit:GeV/c^2.
579  ParticleAttrib< double > Phi; // the electric potential
580  ParticleAttrib< Vector_t > Ef; // e field vector
581  ParticleAttrib< Vector_t > Eftmp; // e field vector for gun simulations
582 
583  ParticleAttrib< Vector_t > Bf; // b field vector
584  ParticleAttrib< int > Bin; // holds the bin in which the particle is in, if zero particle is marked for deletion
585  ParticleAttrib< double > dt; // holds the dt timestep for particle
587  ParticleAttrib< ParticleOrigin > POrigin; // we can distinguish dark current particles from primary particle
588  ParticleAttrib< int > TriID; // holds the ID of triangle that the particle hit. Only for BoundaryGeometry case.
589  ParticleAttrib< short > cavityGapCrossed; // particle just crossed cavity gap (for ParallelCyclotronTracker)
590  ParticleAttrib< short > bunchNum; // bunch number to which particle belongs (multi-bunch mode)
591 
594 
596 
599 
600  // The structure for particle binning
602 
606 
607  // For AMTS integrator in OPAL-T
609 
610  // get 2nd order momentum matrix
612 
613 private:
614  // save particles in case of one core
615  std::unique_ptr<Inform> pmsg_m;
616  std::unique_ptr<std::ofstream> f_stream;
619 
620 protected:
625 
629 
631 
632  /*
633  Member variables starts here
634  */
635 
636  // unit state of PartBunch
639 
641  double centroid_m[2 * Dim];
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 
663  //RMS number density of particles from grid
664  double rmsDensity_m;
665 
670 
673 
675 
676  double qi_m;
678 
681 
683  double dh_m;
684 
686  double tEmission_m;
687 
689  std::unique_ptr<double[]> bingamma_m;
690 
691  //FIXME: this should go into the Bin class!
692  // holds number of emitted particles of the bin
693  // jjyang: opal-cycl use *nBin_m of pbin_m
694  std::unique_ptr<size_t[]> binemitted_m;
695 
698 
700  long long localTrackStep_m;
701 
703  long long globalTrackStep_m;
704 
706  short numBunch_m;
707 
709  std::vector<size_t> bunchTotalNum_m;
710  std::vector<size_t> bunchLocalNum_m;
711 
716 
717  /*
718  Data structure for particle load balance information
719  */
720 
721  std::unique_ptr<size_t[]> globalPartPerNode_m;
722 
725 
726  // flag to tell if we are a DC-beam
727  bool dcBeam_m;
729  std::shared_ptr<AbstractParticle<T, Dim> > pbase_m;
730 };
731 
732 template<class T, unsigned Dim>
734  return bunch.begin();
735 }
736 
737 template<class T, unsigned Dim>
739  return bunch.end();
740 }
741 
742 #include "PartBunchBase.hpp"
743 
744 #endif
A templated representation for vectors.
Definition: FTps.h:34
double periodLength_m
double getE() const
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.
Definition: Physics.h:45
ParticleOrigin
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)
double massPerParticle_m
Vector_t get_normalizedEps_99Percentile() const
double rmsDensity_m
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
Definition: LICENSE:43
virtual void runTests()
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
double get_Dx() const
void createWithID(unsigned id)
Vector_t get_emit() const
void setCharge(double q)
void setMassZeroPart(double mass)
Vector_t get_rprms() const
void setdT(double dt)
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)
bool isGridFixed() const
std::vector< size_t > bunchLocalNum_m
ParticleAttrib< ParticleType > PType
bool hasBinning() const
PartBunchBase const * bunch_m
size_t calcMoments()
void setT(double t)
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)
double get_DDy() const
DistributionMoments momentsComputer_m
void destroy(size_t M, size_t I, bool doNow=false)
Definition: TSVMeta.h:24
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 resetPartBinBunch()
bool operator==(ConstIterator const &rhs) const
long long getLocalTrackStep() const
Vector_t get_pmean() const
void resetM(double m)
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.
Definition: Beamline.h:34
double get_sPos() const
virtual void actT()
UnitState_t unit_state_
ParticleLayout< T, Dim > & getLayout()
void setUpdateFlag(UpdateFlags_t f, bool val)
double getdE() const
Distribution * dist_m
PartBins * pbin_m
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
Definition: multipole_t.tex:6
double getQ() const
Access to reference data.
virtual Vector_t get_hr() const
size_t getGhostNum() const
double get_plasmaParameter() const
double getdT() const
double getM() const
Vector_t get_prms() const
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:76
Timing::TimerRef TimerRef
Definition: IpplTimings.h:176
std::unique_ptr< std::ofstream > f_stream
size_t getNumberOfEmissionSteps()
CoordinateSystemTrafo toLabTrafo_m
Vector_t globalMeanR_m
virtual void boundp()
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
void setTEmission(double t)
virtual double getY0(int i)
ParticleAttrib< double > Phi
void setSteptoLastInj(int n)
void calcGammas_cycl()
bool weHaveBins() const
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)
double get_gamma() const
void set_sPos(double s)
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
double getT() const
virtual void set_meshEnlargement(double dh)
void setTotalNumPerBunch(size_t numpart, short n)
std::vector< size_t > bunchTotalNum_m
number of particles per bunch
size_t getTotalNum() const
FRONT * fs
Definition: hypervolume.cpp:59
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
virtual ~PartBunchBase()
Definition: PartBunchBase.h:64
ParticleAttrib< Vector_t > Eftmp
size_t getLocalNum() const
double getInitialBeta() const
int getNumberOfEnergyBins()
Definition: Inform.h:42
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
DistributionType
Definition: Distribution.h:50
virtual FieldLayout_t & getFieldLayout()=0
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
const unsigned Dim
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
Definition: PartBunchBase.h:59
ParticleAttrib< double > dt
virtual void resizeMesh()
ConstIterator end() const
Quaternion_t getGlobalToLocalQuaternion()
double get_DDx() const
int getLastEmittedEnergyBin()
size_t boundp_destroyT()
double getChargePerParticle() const
get the macro particle charge
double getMassPerParticle() const
double get_Dy() const
FieldSolverType
Definition: FieldSolver.h:38
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
void resetQ(double q)
ParticlePos_t & R
virtual double getY(int i)
const PartData * reference
ParticleType
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)
ParticleIndex_t & ID
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()
Vector_t RefPartR_m
void countTotalNumPerBunch()
double getP() const
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)
void create(size_t M)
const PartData * getReference() const
std::pair< Vector_t, Vector_t > VectorPair_t
Definition: PartBunchBase.h:57
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
Vector_t RefPartP_m
void calcMomentsInitial()
Vector_t get_halo() const
Vector_t getKs3DRefp()
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
Definition: PartBunchBase.h:53
bool weHaveEnergyBins()
bool getUpdateFlag(UpdateFlags_t f) const
double t_m
holds the actual time of the integration
AbstractParticle< T, Dim >::Position_t Position_t
Definition: PartBunchBase.h:55
virtual double getBeta(int i)
bool operator!=(ConstIterator const &rhs) const
bool getIfBeamEmitting()
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)
Vector_t getKs3DRefr()
double get_debyeLength() const
SDDS1 &description type
Definition: test.stat:4
virtual void setBCAllPeriodic()
size_t getTotalNumPerBunch(short n) const
AbstractParticle< T, Dim >::UpdateFlags UpdateFlags_t
Definition: PartBunchBase.h:54
end
Definition: multipole_t.tex:9
size_t getLocalNumPerBunch(short n) const
double calcMeanPhi()
calculate average angle of longitudinal direction of bins
Vector_t get_normalizedEps_99_99Percentile() const
ParticleType refPType_m
constexpr double eV2MeV
Definition: Units.h:77
double getMomentumTolerance() const
Vector_t get_68Percentile() const
int getSteptoLastInj() const
double getTEmission()
virtual void setSolver(FieldSolver *fs)
Vector_t rmax_m
maximal extend of particles
Quaternion_t getQKs3D()
AbstractParticle< T, Dim >::ParticlePos_t ParticlePos_t
Definition: PartBunchBase.h:52
void setCouplingConstant(double c)