OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
27#include "Algorithms/Vektor.h"
34#include "Physics/Units.h"
37#include "Utility/IpplTimings.h"
38
39#include <memory>
40#include <utility>
41#include <vector>
42
43class Distribution;
44class FieldSolver;
45class PartBins;
46class PartBinsCyc;
47class PartData;
48
49template <class T, unsigned Dim>
50class PartBunchBase : std::enable_shared_from_this<PartBunchBase<T, Dim>>
51{
52public:
57
58 typedef std::pair<Vector_t, Vector_t> VectorPair_t;
59
60 static const unsigned Dimension = Dim;
61
62 enum UnitState_t { units = 0, unitless = 1 };
63
64public:
65 virtual ~PartBunchBase() { }
66
68
69 PartBunchBase(const PartBunchBase& rhs) = delete; // implement if needed
70
71 /*
72 * Bunch common member functions
73 */
74
75 // This is required since we initialize the Layout and the RegionLayout with default constructor
76 virtual void initialize(FieldLayout_t* fLayout) = 0;
77
78 bool getIfBeamEmitting();
79
81
83
85
86 void Rebin();
87
88 void setEnergyBins(int numberOfEnergyBins);
89
90 bool weHaveEnergyBins();
91
92 //FIXME: unify methods, use convention that all particles have own dt
93 void switchToUnitlessPositions(bool use_dt_per_particle = false);
94
95 //FIXME: unify methods, use convention that all particles have own dt
96 void switchOffUnitlessPositions(bool use_dt_per_particle = false);
97
99 std::vector<Distribution*> addedDistributions,
100 size_t& np);
102 size_t numberOfParticles,
103 double current, const Beamline& bl);
104
105 bool isGridFixed() const;
106
107 bool hasBinning() const;
108
109
110 /*
111 Energy bins related functions
112 */
113
114 void setTEmission(double t);
115
116 double getTEmission();
117
118 bool doEmission();
119
120 bool weHaveBins() const;
121
122 void setPBins(PartBins* pbin);
123
124 void setPBins(PartBinsCyc* pbin);
125
130 size_t emitParticles(double eZ);
131
132 void updateNumTotal();
133
134 void rebin();
135
136 int getLastemittedBin();
137
138 void setLocalBinCount(size_t num, int bin);
139
141 void calcGammas();
142
143 void calcGammas_cycl();
144
146 void calcDebyeLength();
147
151 void setComputeSCDiagnostics(bool compute) { computeSCDiagnostics_m = compute; }
152
154 double getBinGamma(int bin);
155
157 virtual void setBinCharge(int bin, double q);
158
160 virtual void setBinCharge(int bin);
161
164
165 void calcLineDensity(unsigned int nBins, std::vector<double>& lineDensity,
166 std::pair<double, double>& meshInfo);
167
168 void setBeamFrequency(double v);
169
170 /*
171 Mesh and Field Layout related functions
172 */
173
174 virtual void boundp();
175
177 void boundp_destroyCycl();
178
180 size_t boundp_destroyT();
181
182 size_t destroyT();
183
184 /*
185 Read out coordinates
186 */
187 virtual double getPx(int i);
188 virtual double getPy(int i);
189 virtual double getPz(int i);
190
191 virtual double getPx0(int i);
192 virtual double getPy0(int i);
193
194 virtual double getX(int i);
195 virtual double getY(int i);
196 virtual double getZ(int i);
197
198 virtual double getX0(int i);
199 virtual double getY0(int i);
200
201 virtual void setZ(int i, double zcoo);
202
203 void get_bounds(Vector_t& rmin, Vector_t& rmax) const;
204
205 void getLocalBounds(Vector_t& rmin, Vector_t& rmax) const;
206
207 std::pair<Vector_t, double> getBoundingSphere();
208
209 std::pair<Vector_t, double> getLocalBoundingSphere();
210
211
212 /*
213 Compatibility function push_back
214 */
215 void push_back(OpalParticle const& p);
216
217 void setParticle(FVector<double, 6> z, int ii);
218
219 void setParticle(OpalParticle const& p, int ii);
220
222
224 friend class PartBunchBase<T, Dim>;
225
226 public:
228 bunch_m(nullptr),
229 index_m(0)
230 {}
231 ConstIterator(PartBunchBase const* bunch, unsigned int i):
232 bunch_m(bunch),
233 index_m(i)
234 {}
235
238
239 bool operator == (ConstIterator const& rhs) const
240 {
241 return bunch_m == rhs.bunch_m && index_m == rhs.index_m;
242 }
243
244 bool operator != (ConstIterator const& rhs) const
245 {
246 return bunch_m != rhs.bunch_m || index_m != rhs.index_m;
247 }
248
250 {
251 if (index_m >= bunch_m->getLocalNum()) {
252 throw GeneralClassicException("PartBunchBase::ConstIterator::operator*", "out of bounds");
253 }
255 bunch_m->R[index_m],
256 bunch_m->P[index_m],
257 bunch_m->getT(),
258 bunch_m->Q[index_m],
260 }
261
263 {
264 ++index_m;
265 return *this;
266 }
267
269 {
270 ConstIterator it = *this;
271 ++index_m;
272
273 return it;
274 }
275
276 int operator-(const ConstIterator& other) const
277 {
278 return index_m - other.index_m;
279 }
280 private:
282 unsigned int index_m;
283 };
284
286 return ConstIterator(this, 0);
287 }
288
290 return ConstIterator(this, getLocalNum());
291 }
292
294 // The matrix [b]D[/b] is used to normalise the first two modes.
295 // The maximum normalised amplitudes for these modes are stored
296 // in [b]axmax[/b] and [b]aymax[/b].
298 double& axmax, double& aymax);
299
300 void setdT(double dt);
301 double getdT() const;
302
303 void setT(double t);
304 void incrementT();
305 double getT() const;
306
313 double get_sPos() const;
314
315 void set_sPos(double s);
316
317 double get_gamma() const;
318 double get_meanKineticEnergy() const;
319 double get_temperature() const;
320 double get_debyeLength() const;
321 double get_plasmaParameter() const;
322 double get_rmsDensity() const;
323 Vector_t get_origin() const;
324 Vector_t get_maxExtent() const;
325 Vector_t get_centroid() const;
326 Vector_t get_rrms() const;
327 Vector_t get_rprms() const;
328 Vector_t get_rmean() const;
329 Vector_t get_prms() const;
330 Vector_t get_pmean() const;
332 Vector_t get_emit() const;
333 Vector_t get_norm_emit() const;
334 Vector_t get_halo() const;
343 virtual Vector_t get_hr() const;
344
345 double get_Dx() const;
346 double get_Dy() const;
347 double get_DDx() const;
348 double get_DDy() const;
349
350 virtual void set_meshEnlargement(double dh);
351
353 void setMeshFit(const MeshFitParameters& meshFit);
354 const MeshFitParameters& getMeshFit() const;
355
361 void setMeshFitSolveStep(bool solveStep);
362
367 void getMeshFitFullBounds(Vector_t& rmin, Vector_t& rmax) const;
368
370 Vector_t getMeshSpacing(const Vector_t& rmin, const Vector_t& rmax) const;
371
376 void setMeshFitMode(const CoreFitSC::ModeState& mode);
377
380 bool isMeshFitToCore() const;
381
385 bool isMeshFitRepartitionDue() const;
386
389 size_t numFlagged = 0;
393 size_t numOutside = 0;
394 size_t fullSolves = 0;
395 size_t modeSwitches = 0;
396 size_t farFarSampled = 0;
398 size_t nearSampled = 0;
400 size_t turnSolves = 0;
401 size_t turnFullSolves = 0;
402 };
406 void resetMeshFitTurn();
407
409 size_t getLoadBalance(int p) const;
410
411 void get_PBounds(Vector_t &min, Vector_t &max) const;
412
413 void calcBeamParameters();
414 void calcBeamParametersInitial(); // Calculate initial beam parameters before emission.
415
416 double getCouplingConstant() const;
417 void setCouplingConstant(double c);
418
419 // set the charge per simulation particle
420 void setCharge(double q);
421 // set the charge per simulation particle when total particle number equals 0
422 void setChargeZeroPart(double q);
423
424 // set the mass per simulation particle
425 void setMass(double mass);
426 void setMassZeroPart(double mass);
427
429 double getCharge() const;
430
432 double getChargePerParticle() const;
433
434 double getMassPerParticle() const;
435
436 virtual void setSolver(FieldSolver *fs);
437
438 bool hasFieldSolver();
439
441
442 void setStepsPerTurn(int n);
443 int getStepsPerTurn() const;
444
446 void setGlobalTrackStep(long long n);
447 long long getGlobalTrackStep() const;
448
450 void setLocalTrackStep(long long n);
451 void incTrackSteps();
452 long long getLocalTrackStep() const;
453
454 void setNumBunch(short n);
455 short getNumBunch() const;
456
457 // used in ParallelCyclotronTracker for multi-bunch mode
458 void setTotalNumPerBunch(size_t numpart, short n);
459 size_t getTotalNumPerBunch(short n) const;
460
461 void setLocalNumPerBunch(size_t numpart, short n);
462 size_t getLocalNumPerBunch(short n) const;
463
464 /* used in initializeTracking_m of ParallelCyclotronTracker
465 * for multi-bunch mode
466 */
468
469 void setGlobalMeanR(Vector_t globalMeanR);
471 void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion);
473
474 void setSteptoLastInj(int n);
475 int getSteptoLastInj() const;
476
478 double calcMeanPhi();
479
481 bool resetPartBinID2(const double eta);
482
483 bool resetPartBinBunch();
484
486 double getQ() const;
487 double getM() const;
488 double getP() const;
489 double getE() const;
491 ParticleType getPType() const;
492 double getInitialBeta() const;
493 double getInitialGamma() const;
496 void resetQ(double q);
497 void resetM(double m);
499 void setPType(const std::string& type);
501 double getdE() const;
502 virtual double getGamma(int i);
503 virtual double getBeta(int i);
504 virtual void actT();
505
506 const PartData* getReference() const;
507
508 double getEmissionDeltaT();
509
511
512 double getMomentumTolerance() const;
513
520
521 void iterateEmittedBin(int binNumber);
522
523 void calcEMean();
524
525 Inform& print(Inform& os);
526
527 /*
528 * (Pure) virtual member functions
529 */
530
531 virtual void runTests();
532
533 virtual void do_binaryRepart();
534
535 virtual void resetInterpolationCache(bool clearCache = false);
536
537 //brief calculates back the max/min of the efield on the grid
539
540 virtual double getRho(int x, int y, int z) = 0;
541
542 virtual void computeSelfFields() = 0;
543
544 //brief used for self fields with binned distribution
545 virtual void computeSelfFields(int bin) = 0;
546
547 virtual void computeSelfFields_cycl(double gamma) = 0;
548 virtual void computeSelfFields_cycl(int bin) = 0;
549
550 virtual void swap(unsigned int i, unsigned int j);
551
552 /*
553 Mesh and Field Layout related functions
554 */
555
556 virtual void setBCAllPeriodic();
557 virtual void setBCAllOpen();
558
559 virtual void setBCForDCBeam();
560
561
562// virtual void setMesh(Mesh_t* mesh) = 0;
563// virtual Mesh_t &getMesh() = 0;
564
565// virtual void setFieldLayout(FieldLayout_t* fLayout) = 0;
567
568 virtual void resizeMesh() { };
569
570 /*
571 * Wrapped member functions of IpplParticleBase
572 */
573
574 size_t getTotalNum() const;
575 void setTotalNum(size_t n);
576 void setLocalNum(size_t n);
577 size_t getLocalNum() const;
578
579 size_t getDestroyNum() const;
580 size_t getGhostNum() const;
581
583 const ParticleLayout<T, Dim>& getLayout() const;
584
585 bool getUpdateFlag(UpdateFlags_t f) const;
586 void setUpdateFlag(UpdateFlags_t f, bool val);
587
588
590 return pbase_m->getBConds();
591 }
592
594 pbase_m->setBConds(bc);
595 }
596
597 bool singleInitNode() const;
598
599 void resetID();
600
601 void update();
602 void update(const ParticleAttrib<char>& canSwap);
603
604 void createWithID(unsigned id);
605 void create(size_t M);
606 void globalCreate(size_t np);
607
608 void destroy(size_t M, size_t I, bool doNow = false);
609 void performDestroy(bool updateLocalNum = false);
610 void ghostDestroy(size_t M, size_t I);
611
612protected:
613 size_t calcMoments(); // Calculates bunch moments using only emitted particles.
614
615 /* Calculates bunch moments by summing over bins
616 * (not accurate when any particles have been emitted).
617 */
620 double calculateAngle(double x, double y);
621
623 enum MeshFitWarning: unsigned int {
624 FarChargeWarning = 1, // far charge fraction above CoreFitSC::warnFarFraction
625 FullBoxWarning = 2, // core bounds equal to the bounds of all particles
626 FarFarWarning = 4 // far-far field summed over a subsample of its sources
627 };
628 void warnMeshFitOnce(MeshFitWarning warning, const std::string& message);
629
630
631private:
632 virtual void updateDomainLength(Vektor<int, 3>& grid) = 0;
633
634 virtual void updateFields(const Vector_t& hr, const Vector_t& origin);
635
642 void getSolverMeshBounds(Vector_t& rmin, Vector_t& rmax);
643
647 void checkMeshFitOutside();
648
650
651public:
652 /*
653 * Bunch attributes
654 */
657
658 // Particle container attributes
659 ParticleAttrib< Vector_t > P; // particle momentum // ParticleSpatialLayout<double, 3>::ParticlePos_t P;
660 ParticleAttrib< double > Q; // charge per simulation particle, unit: C.
661 ParticleAttrib< double > M; // mass per simulation particle, for multi-species particle tracking, unit:GeV/c^2.
662 ParticleAttrib< double > Phi; // the electric potential
664 ParticleAttrib< Vector_t > Eftmp; // e field vector for gun simulations
665
667 ParticleAttrib< int > Bin; // holds the bin in which the particle is in, if zero particle is marked for deletion
668 ParticleAttrib< double > dt; // holds the dt timestep for particle
670 ParticleAttrib< ParticleOrigin > POrigin; // we can distinguish dark current particles from primary particle
671 ParticleAttrib< int > TriID; // holds the ID of triangle that the particle hit. Only for BoundaryGeometry case.
672 ParticleAttrib< short > cavityGapCrossed; // particle just crossed cavity gap (for ParallelCyclotronTracker)
673 ParticleAttrib< short > bunchNum; // bunch number to which particle belongs (multi-bunch mode)
674
677
679
682
683 // The structure for particle binning
685
689
690 // For AMTS integrator in OPAL-T
692
693 // get 2nd order momentum matrix
695
696private:
697 // save particles in case of one core
698 std::unique_ptr<Inform> pmsg_m;
699 std::unique_ptr<std::ofstream> f_stream;
702
703protected:
708
717
719
720 /*
721 Member variables starts here
722 */
723
724 // unit state of PartBunch
727
729 double centroid_m[2 * Dim];
730
732 double dt_m;
734 double t_m;
736 double spos_m;
737
741 //Vector_t globalMeanR_m = Vector_t(0.0, 0.0, 0.0);
742 //Quaternion_t globalToLocalQuaternion_m = Quaternion_t(1.0, 0.0, 0.0, 0.0);
745
750
751 //RMS number density of particles from grid
753
756
761
764
766
767 double qi_m;
769
772
774 double dh_m;
775
779 bool meshFitSolveStep_m = false;
788 bool scRepartitionDue_m = false;
789 bool scHasSolved_m = false;
791 unsigned int scWarned_m = 0;
797 bool scCoreMesh_m = false;
802 size_t scNumCore_m = 0;
803 bool scFitted_m = false;
804
807
809 std::unique_ptr<double[]> bingamma_m;
810
811 //FIXME: this should go into the Bin class!
812 // holds number of emitted particles of the bin
813 // jjyang: opal-cycl use *nBin_m of pbin_m
814 std::unique_ptr<size_t[]> binemitted_m;
815
818
821
824
827
829 std::vector<size_t> bunchTotalNum_m;
830 std::vector<size_t> bunchLocalNum_m;
831
836
837 /*
838 Data structure for particle load balance information
839 */
840
841 std::unique_ptr<size_t[]> globalPartPerNode_m;
842
845
846 // flag to tell if we are a DC-beam
849 std::shared_ptr<AbstractParticle<T, Dim> > pbase_m;
850};
851
852template<class T, unsigned Dim>
854 return bunch.begin();
855}
856
857template<class T, unsigned Dim>
859 return bunch.end();
860}
861
862#include "PartBunchBase.hpp"
863
864#endif
FieldSolverType
Definition FieldSolver.h:38
const unsigned Dim
DistributionType
ParticleOrigin
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 eV2MeV
Definition Units.h:77
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
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 getMeshFitFullBounds(Vector_t &rmin, Vector_t &rmax) const
MESHFIT=CORE: the bounds of all particles of the same fit.
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)
void setCharge(double q)
Vector_t RefPartP_m
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
const MeshFitParameters & getMeshFit() const
double periodLength_m
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)
UnitState_t unit_state_
void resetM(double m)
ParticleAttrib< Vector_t > Eftmp
void getSolverMeshBounds(Vector_t &rmin, Vector_t &rmax)
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
void setMeshFit(const MeshFitParameters &meshFit)
FIELDSOLVER, MESHFIT: the particles the space-charge mesh is fitted to.
double t_m
holds the actual time of the integration
void set_sPos(double s)
IpplTimings::TimerRef meshFitTimer_m
void setLocalTrackStep(long long n)
step in a TRACK command
void setComputeSCDiagnostics(bool compute)
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
double get_DDy() 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
bool isMeshFitToCore() const
double calcMeanPhi()
calculate average angle of longitudinal direction of bins
Quaternion_t getGlobalToLocalQuaternion()
const PartData * reference
size_t boundp_destroyT()
void setBeamFrequency(double v)
Vector_t get_normalizedEps_68Percentile() const
double get_gamma() 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
double getTEmission()
virtual ~PartBunchBase()
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
Vector_t scBoxMin_m
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)
MeshFitStatistics scStatistics_m
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()
IpplTimings::TimerRef farFieldTimer_m
void setMeshFitMode(const CoreFitSC::ModeState &mode)
MESHFIT=CORE: restores the mode, from the step attributes of an H5 restart.
bool weHaveBins() const
Vector_t RefPartR_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()
Vector_t scMeshMax_m
void getLocalBounds(Vector_t &rmin, Vector_t &rmax) const
void setSteptoLastInj(int n)
Vector_t scBoxMax_m
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)
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
void createWithID(unsigned id)
const CoreFitSC::CoreSelection & getMeshFitCore() const
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
bool computeSCDiagnostics_m
See setComputeSCDiagnostics().
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)
Vector_t getMeshSpacing(const Vector_t &rmin, const Vector_t &rmax) const
Mesh spacing that boundp() gives to particles within [rmin, rmax].
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
Vector_t scFullMax_m
void warnMeshFitOnce(MeshFitWarning warning, const std::string &message)
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
double couplingConstant_m
std::vector< size_t > bunchLocalNum_m
void setPOrigin(ParticleOrigin)
bool isMeshFitRepartitionDue() const
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
bool meshFitSolveStep_m
See setMeshFitSolveStep().
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()
void setMeshFitSolveStep(bool solveStep)
CoreFitSC::ModeState scMode_m
double tEmission_m
if larger than 0, emitt particles for tEmission_m [s]
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)
MeshFitParameters meshFit_m
relative enlargement of the mesh
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()
Vector_t scFullMin_m
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)
AbstractParticle< T, Dim >::UpdateFlags UpdateFlags_t
Vector_t get_normalizedEps_99_99Percentile() const
double getMomentumTolerance() const
Vector_t scMeshMin_m
const CoreFitSC::ModeState & getMeshFitMode() const
OpalParticle getParticle(int ii)
virtual void swap(unsigned int i, unsigned int j)
virtual void actT()
std::unique_ptr< size_t[]> globalPartPerNode_m
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
IpplTimings::TimerRef exactCoreTimer_m
std::pair< Vector_t, double > getLocalBoundingSphere()
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 FieldLayout_t & getFieldLayout()=0
virtual VectorPair_t getEExtrema()=0
void calcDebyeLength()
Compute the (global) Debye length for the beam.
CoreFitSC::CoreSelection scCore_m
MESHFIT=CORE: see getMeshFitCore() and getMeshFitFullBounds()
double get_sPos() const
void iterateEmittedBin(int binNumber)
MeshFitWarning
MESHFIT=CORE: the warnings of the solve, each given at most once per turn.
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
const MeshFitStatistics & getMeshFitStatistics() const
unsigned int scWarned_m
virtual double getZ(int i)
Vector_t get_rmean() const
Result of selectCore(), the same on every rank.
Definition CoreFitSC.h:117
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)
MESHFIT=CORE: statistics of the solves of this TRACK/RUN, for the stat file and the log.
size_t numOutside
particles outside the mesh domain at the last update()
size_t turnFullSolves
solves in FULL mode in this turn
size_t fullSolves
solves in FULL mode
size_t modeSwitches
switches between CORE and FULL
size_t turnSolves
solves in this turn
An abstract sequence of beam line components.
Definition Beamline.h:34
A templated representation for matrices.
Definition FMatrix.h:39
A templated representation for vectors.
Definition FVector.h:38
Parameters of the mesh fit, passed to the bunch (PartBunchBase::setMeshFit())
Definition FieldSolver.h:66
ParticleLayout< T, Dim >::Position_t Position_t
Timing::TimerRef TimerRef