OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
PartBunch.h
Go to the documentation of this file.
1#ifndef PARTBUNCH_H
2#define PARTBUNCH_H
3
4#include <memory>
5
10#include "Manager/BaseManager.h"
11#include "Manager/PicManager.h"
16#include "Physics/Physics.h"
17#include "Random/Distribution.h"
20#include "Random/Randn.h"
22#include "BCHandler.hpp"
23
25
26#include "Algorithms/PartData.h"
27
28#include "Utilities/Options.h" // Needed to define binning parameters!
29#include "PartBunch/Binning/AdaptBins.h" // TODO: binning
30
31
32extern Inform* gmsg;
33
34template <typename T>
35KOKKOS_INLINE_FUNCTION typename T::value_type L2Norm(T& x) {
36 return sqrt(dot(x, x).apply());
37}
38
40
41template <typename T, unsigned Dim>
42class PartBunch
43 : public ippl::PicManager<
44 T, Dim, ParticleContainer<T, Dim>, FieldContainer<T, Dim>, LoadBalancer<T, Dim>> {
45public:
51
55
57
58 double time_m;
59
61
63 // int nt_m;
64
65 double lbt_m;
66
67 double dt_m;
68
69 int it_m;
70
72
73 std::string solver_m;
74
76
77private:
78 double qi_m;
79
80 double mi_m;
81
83
84 std::shared_ptr<BCHandler_t> bcHandler_m;
85
86public:
88
92
95
96 // Landau damping specific
97 double Bext_m;
98 double alpha_m;
99 double DrInv_m;
100
102 std::array<bool, Dim> decomp_m;
103
104 /*
105 Up to here it is like the opaltest
106 */
107
114
116
117private:
118
119 std::unique_ptr<size_t[]> globalPartPerNode_m;
120
121 // ParticleOrigin refPOrigin_m;
122 // ParticleType refPType_m;
123
127 // Vector_t globalMeanR_m = Vector_t(0.0, 0.0, 0.0);
128 // Quaternion_t globalToLocalQuaternion_m = Quaternion_t(1.0, 0.0, 0.0, 0.0);
131
136 // PartBins* pbin_m;
137
139 double tEmission_m;
140
142 std::unique_ptr<double[]> bingamma_m;
143
144 // FIXME: this should go into the Bin class!
145 // holds number of emitted particles of the bin
146 // jjyang: opal-cycl use *nBin_m of pbin_m
147 //std::unique_ptr<size_t[]> binemitted_m; // liemen_a: TODO remove!
148 std::shared_ptr<AdaptBins_t> bins_m; // added by liemen_a for AdaptBins class!
149
151 int stepsPerTurn_m;
152
154 short numBunch_m;
155
157 std::vector<size_t> bunchTotalNum_m;
158 std::vector<size_t> bunchLocalNum_m;
159
163 int SteptoLastInj_m;
164
165 bool fixed_grid;
166
168
169 double couplingConstant_m;
170
172 long long localTrackStep_m;
173
175 long long globalTrackStep_m;
176
177
178 std::shared_ptr<Distribution> OPALdist_m;
179
180 std::shared_ptr<FieldSolverCmd> OPALFieldSolver_m;
181
182 // unit state of PartBunch --> always false after initialization, so use this as standard flag
183 // UnitState_t unit_state_m;
184 bool isUnitless_m = false;
185 // UnitState_t stateOfLastBoundP_m;
186
188 double t_m;
189
191 double spos_m;
192
193 /*
194 flags to tell if we are a DC-beam
195 */
196 bool dcBeam_m;
197 double periodLength_m;
198
200 std::shared_ptr<VField_t<T, Dim>> Etmp_m;
201
202public:
203
204 PartBunch(double qi,
205 double mi,
206 size_t totalP,
207 /*int nt,*/
208 double lbt,
209 std::string integration_method,
210 std::shared_ptr<Distribution> &OPALdistribution,
211 std::shared_ptr<FieldSolverCmd> &OPALFieldSolver);
212
213 void bunchUpdate();
214
216
218 *gmsg << "* PartBunch Destructor: Finished time step: " << this->it_m << " time: " << this->time_m << endl;
219 }
220
221 std::shared_ptr<ParticleContainer_t> getParticleContainer() {
222 return this->pcontainer_m;
223 }
224
225 void setSolver(std::string solver);
226
227 void pre_run() override ;
228
229 void performBunchSanityChecks() const;
230
231public:
232 std::shared_ptr<VField_t<T, Dim>> getTempEField() { return this->Etmp_m; }
233 void setTempEField(std::shared_ptr<VField_t<T, Dim>> Etmp) { this->Etmp_m = Etmp; }
234
235 std::shared_ptr<AdaptBins_t> getBins() { return bins_m; } // TODO: Binning
236
237 void setBins(std::shared_ptr<AdaptBins_t> bins) { bins_m = bins; } // TODO: Binning
238
239 void setBCHandler(std::shared_ptr<BCHandler_t> bcHandler) { bcHandler_m = bcHandler; }
240 std::shared_ptr<BCHandler_t> getBCHandler() const { return bcHandler_m; }
241
243 this->pcontainer_m->updateMoments();
244 }
245
246 size_t getTotalNum() const {
247 return this->pcontainer_m->getTotalNum();
248 }
249
250 size_t getLocalNum() const {
251 return this->pcontainer_m->getLocalNum();
252 }
253
254 Vector_t<double, Dim> R(size_t /*i*/) {
255 *gmsg << "not implemented" << endl;
256 return Vector_t<double, Dim>(0.0);
257 }
258
259 Vector_t<double, Dim> P(size_t /*i*/) {
260 *gmsg << "not implemented" << endl;
261 return Vector_t<double, Dim>(0.0);
262 }
263
264 Vector_t<double, Dim> Ef(size_t /*i*/) {
265 *gmsg << "not implemented" << endl;
266 return Vector_t<double, Dim>(0.0);
267 }
268
269 Vector_t<double, Dim> Bf(size_t /*i*/) {
270 *gmsg << "not implemented" << endl;
271 return Vector_t<double, Dim>(0.0);
272 }
273
274 Vector_t<double, Dim> dt(size_t /*i*/) {
275 *gmsg << "not implemented" << endl;
276 return Vector_t<double, Dim>(0.0);
277 }
278
279 void advance() override {
280 // \todo needs to go
281 *gmsg << "not implemented" << endl;
282 }
283
284 void par2grid() override {
285 scatterCIC();
286 }
287
288 void grid2par() override {
289 gatherCIC();
290 }
291
292 void gatherCIC();
293
294 void scatterCIC() {
296 }
297
298 void scatterCICPerBin(binIndex_t binIndex);
299
300 /*
301 Up to here it is like the opaltest
302 */
303
304 double getCouplingConstant() const {
305 return couplingConstant_m;
306 }
307
308 void setCouplingConstant(double c) {
310 }
311
313
315
316 void setCharge() {
317 this->getParticleContainer()->Q = qi_m;
318 }
319
320 void setMass() {
321 this->getParticleContainer()->M = mi_m;
322 }
323
324 double getCharge() const {
325 return qi_m*this->getTotalNum();
326 }
327
328 double getChargePerParticle() const {
329 return qi_m;
330 }
331 double getMassPerParticle() const {
332 return mi_m;
333 }
334
335 double getQ() const {
336 return this->getCharge();
337 }
338 double getM() const {
339 return mi_m*this->getTotalNum();
340 }
341
342 double getdE() const {
343 return this->pcontainer_m->getStdKineticEnergy();
344 }
345
346 double getGamma(int /*i*/) const {
347 *gmsg << "not implemented" << endl;
348 return 0.0;
349 }
350 double getBeta(int /*i*/) const {
351 *gmsg << "not implemented" << endl;
352 return 0.0;
353 }
354
355 void actT() {
356 *gmsg << "not implemented" << endl;
357 }
358
360 return reference_m;
361 }
362
364 *gmsg << "not implemented" << endl;
365 return 1.0;
366 }
367
369
370 size_t getLoadBalance(int p) {
371 return globalPartPerNode_m[p];
372 }
373
374 void resizeMesh() {
375 *gmsg << "not implemented" << endl;
376 }
377
378 bool isGridFixed() {
379 *gmsg << "not implemented" << endl;
380 return false;
381 }
382
383 void boundp() {
384 *gmsg << "not implemented" << endl;
385 }
386
388 *gmsg << "not implemented" << endl;
389 return 1;
390 }
391
393 *gmsg << "not implemented" << endl;
394 }
396 *gmsg << "not implemented" << endl;
397 }
398 void setupBCs() {
399 *gmsg << "not implemented" << endl;
400 }
402 *gmsg << "not implemented" << endl;
403 }
404
405 void resetInterpolationCache(bool /*clearCache = false*/) {
406 *gmsg << "not implemented" << endl;
407 }
408 void swap(unsigned int /*i*/, unsigned int /*j*/) {
409 *gmsg << "not implemented" << endl;
410 }
411 double getRho(int /*x*/, int /*y*/, int /*z*/) {
412 *gmsg << "not implemented" << endl;
413 return 0.0;
414 }
415 void gatherStatistics(unsigned int /*totalP*/) {
416 *gmsg << "not implemented" << endl;
417 }
443 void switchToUnitlessPositions(bool use_dt_per_particle = false) {
444 if (isUnitless_m) {
445 throw OpalException("PartBunch::switchToUnitlessPositions",
446 "PartBunch is already in unitless positions!");
447 }
448
449 // Divide by c*dt
450 double unitless_factor = 1.0 / (Physics::c * this->getdT());
451 auto Rview = this->getParticleContainer()->R.getView();
452 auto dtview = this->getParticleContainer()->dt.getView();
454 "switchToUnitlessPositions", ippl::getRangePolicy(Rview),
455 KOKKOS_LAMBDA(const size_t i) {
456 double fac = use_dt_per_particle ? (1.0 / (Physics::c * dtview(i)))
457 : unitless_factor;
458 Rview(i) *= fac;
459 });
460 isUnitless_m = true;
461
463 *gmsg << "* Switched to unitless positions." << endl;
464 }
488 void switchOffUnitlessPositions(bool use_dt_per_particle = false) {
489 if (!isUnitless_m) {
490 throw OpalException("PartBunch::switchOffUnitlessPositions",
491 "PartBunch is already in physical positions!");
492 }
493
494 // Multiply by c*dt
495 double unitless_factor = Physics::c * this->getdT();
496 auto Rview = this->getParticleContainer()->R.getView();
497 auto dtview = this->getParticleContainer()->dt.getView();
499 "switchOffUnitlessPositions", ippl::getRangePolicy(Rview),
500 KOKKOS_LAMBDA(const size_t i) {
501 double fac = use_dt_per_particle ? (Physics::c * dtview(i))
502 : unitless_factor;
503 Rview(i) *= fac;
504 });
505 isUnitless_m = false;
506
508 *gmsg << "* Switched to physical positions." << endl;
509 }
510
512 *gmsg << "not implemented" << endl;
513 return 0;
514 }
515
517 unsigned int /*nBins*/, std::vector<double>& /*lineDensity*/, std::pair<double, double>& /*meshInfo*/) {
518 *gmsg << "not implemented" << endl;
519 }
520
521 void setBeamFrequency(double /*v*/) {
522 *gmsg << "not implemented" << endl;
523 }
524
526 *gmsg << "not implemented" << endl;
527 return Vector_t<double, Dim>(0);
528 }
529
531
533
535 *gmsg << "not implemented" << endl;
536 return true;
537 }
538
540 *gmsg << "not implemented" << endl;
541 return false;
542 }
543
545 *gmsg << "not implemented" << endl;
546 return false;
547 }
549 *gmsg << "not implemented" << endl;
550 return 0;
551 }
553 *gmsg << "not implemented" << endl;
554 return 0;
555 }
557 *gmsg << "not implemented" << endl;
558 return 0;
559 }
560
561 void Rebin() {
562 *gmsg << "not implemented" << endl;
563 }
564
565 void setEnergyBins(int /*numberOfEnergyBins*/) {
566 *gmsg << "not implemented" << endl;
567 }
569 *gmsg << "not implemented" << endl;
570 return false;
571 }
572 void setTEmission(double /*t*/) {
573 *gmsg << "not implemented" << endl;
574 }
575 double getTEmission() {
576 *gmsg << "not implemented" << endl;
577 return 0.0;
578 }
579 bool weHaveBins() {
580 *gmsg << "not implemented" << endl;
581 return false;
582 }
583 // void setPBins(PartBins* pbin) {}
584 size_t emitParticles(double /*eZ*/) {
585 *gmsg << "not implemented" << endl;
586 return 0;
587 }
589 *gmsg << "not implemented" << endl;
590 }
591 void rebin() {
592 *gmsg << "not implemented" << endl;
593 }
595 *gmsg << "not implemented" << endl;
596 return 0;
597 }
598 void setLocalBinCount(size_t /*num*/, int /*bin*/) {
599 *gmsg << "not implemented" << endl;
600 }
601 void calcGammas() {
602 *gmsg << "not implemented" << endl;
603 }
604 double getBinGamma(int /*bin*/) {
605 *gmsg << "not implemented" << endl;
606 return 0.0;
607 }
608 bool hasBinning() {
609 *gmsg << "not implemented" << endl;
610 return false;
611 }
612 void setBinCharge(int /*bin*/, double /*q*/) {
613 *gmsg << "not implemented" << endl;
614 }
615 void setBinCharge(int /*bin*/) {
616 *gmsg << "not implemented" << endl;
617 }
618 double calcMeanPhi() {
619 *gmsg << "not implemented" << endl;
620 return 0.0;
621 }
622 bool resetPartBinID2(const double /*eta*/) {
623 *gmsg << "not implemented" << endl;
624 return false;
625 }
627 *gmsg << "not implemented" << endl;
628 return false;
629 }
630 double getPx(int /*i*/) {
631 *gmsg << "not implemented" << endl;
632 return 0.0;
633 }
634 double getPy(int /*i*/) {
635 *gmsg << "not implemented" << endl;
636 return 0.0;
637 }
638 double getPz(int /*i*/) {
639 *gmsg << "not implemented" << endl;
640 return 0.0;
641 }
642 double getPx0(int /*i*/) {
643 *gmsg << "not implemented" << endl;
644 return 0.0;
645 }
646 double getPy0(int /*i*/) {
647 *gmsg << "not implemented" << endl;
648 return 0.0;
649 }
650 double getX(int /*i*/) {
651 *gmsg << "not implemented" << endl;
652 return 0.0;
653 }
654 double getY(int /*i*/) {
655 *gmsg << "not implemented" << endl;
656 return 0.0;
657 }
658 double getZ(int /*i*/) {
659 *gmsg << "not implemented" << endl;
660 return 0.0;
661 }
662 double getX0(int /*i*/) {
663 *gmsg << "not implemented" << endl;
664 return 0.0;
665 }
666 double getY0(int /*i*/) {
667 *gmsg << "not implemented" << endl;
668 return 0.0;
669 }
670
671 void setZ(int /*i*/, double /*zcoo*/) {
672 *gmsg << "not implemented" << endl;
673 }
674
676 rmin = rmin_m;
677 rmax = rmax_m;
678 }
679
681 *gmsg << "not implemented" << endl;
682 }
683
685 *gmsg << "not implemented" << endl;
686 }
687
688 void setdT(double dt) {
689 dt_m = dt;
690 }
691
692 double getdT() const {
693 return dt_m;
694 }
695
696 void setT(double t) {
697 t_m = t;
698 }
699
700 void incrementT() {
701 t_m += dt_m;
702 }
703
704 double getT() const {
705 return t_m;
706 }
707
708 void set_sPos(double s) {
709 spos_m = s;
710 }
711
712 double get_sPos() const {
713 return spos_m;
714 }
715
716 double get_gamma() const {
717 *gmsg << "not implemented" << endl;
718 return 1.00;
719 }
720
722 return this->pcontainer_m->getMeanKineticEnergy();
723 }
724
726 return rmin_m;
727 }
729 return rmax_m;
730 }
731
732 // in opal, MeanPosition is return for get_centroid, which I think is wrong. We already have get_rmean()
734 return this->pcontainer_m->getCentroid();
735 }
736
738 return this->pcontainer_m->getRmsR();
739 }
740
742 return this->pcontainer_m->getRmsRP();
743 }
744
746 return this->pcontainer_m->getRmsP();
747 }
748
750 return this->pcontainer_m->getMeanR();
751 }
752
754 return this->pcontainer_m->getMeanP();
755 }
757 *gmsg << "not implemented" << endl;
758 return Vector_t<double, Dim>(0.0);
759 }
761 *gmsg << "not implemented" << endl;
762 return Vector_t<double, Dim>(0.0);
763 }
765 return this->pcontainer_m->getNormEmit();
766 }
768 *gmsg << "not implemented" << endl;
769 return Vector_t<double, Dim>(0.0);
770 }
772 *gmsg << "not implemented" << endl;
773 return Vector_t<double, Dim>(0.0);
774 }
776 *gmsg << "not implemented" << endl;
777 return Vector_t<double, Dim>(0.0);
778 }
780 *gmsg << "not implemented" << endl;
781 return Vector_t<double, Dim>(0.0);
782 }
784 *gmsg << "not implemented" << endl;
785 return Vector_t<double, Dim>(0.0);
786 }
788 *gmsg << "not implemented" << endl;
789 return Vector_t<double, Dim>(0.0);
790 }
792 *gmsg << "not implemented" << endl;
793 return Vector_t<double, Dim>(0.0);
794 }
796 *gmsg << "not implemented" << endl;
797 return Vector_t<double, Dim>(0.0);
798 }
800 *gmsg << "not implemented" << endl;
801 return Vector_t<double, Dim>(0.0);
802 }
804 *gmsg << "not implemented" << endl;
805 return Vector_t<double, Dim>(0.0);
806 }
807
808 double get_Dx() const {
809 return this->pcontainer_m->getDx();
810 }
811 double get_Dy() const {
812 return this->pcontainer_m->getDy();
813 }
814 double get_DDx() const {
815 return this->pcontainer_m->getDDx();
816 }
817 double get_DDy() const {
818 return this->pcontainer_m->getDDy();
819 }
820
821 double get_temperature() const {
822 return this->pcontainer_m->getTemperature();
823 }
824
826 this->pcontainer_m->computeDebyeLength(rmsDensity_m);
827 }
828
829 double get_debyeLength() const {
830 return this->pcontainer_m->getDebyeLength();
831 }
832
833 double get_plasmaParameter() const {
834 return this->pcontainer_m->getPlasmaParameter();
835 }
836
837 double get_rmsDensity() const {
838 return rmsDensity_m;
839 }
840
841 /*
842 Some quantities related to integrations/tracking
843 */
844
845 void setStepsPerTurn(int n) {
846 stepsPerTurn_m = n;
847 }
848
849 int getStepsPerTurn() const {
850 return stepsPerTurn_m;
851 }
852
854 void setGlobalTrackStep(long long n) {
856 }
857
858 long long getGlobalTrackStep() const {
859 return globalTrackStep_m;
860 }
861
863 void setLocalTrackStep(long long n) {
865 }
866
870 }
871
872 long long getLocalTrackStep() const {
873 return localTrackStep_m;
874 }
875
876 void setNumBunch(short n) {
877 numBunch_m = n;
878 bunchTotalNum_m.resize(n);
879 bunchLocalNum_m.resize(n);
880 }
881
882 short getNumBunch() const {
883 return numBunch_m;
884 }
885
887 globalMeanR_m = globalMeanR;
888 }
889
891 return globalMeanR_m;
892 }
893
894 void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion) {
895 globalToLocalQuaternion_m = globalToLocalQuaternion;
896 }
897
900 }
901
902 void setSteptoLastInj(int n) {
903 SteptoLastInj_m = n;
904 }
905
906 int getSteptoLastInj() const {
907 return SteptoLastInj_m;
908 }
909
910 double calculateAngle(double /*x*/, double /*y*/) {
911 *gmsg << "not implemented" << endl;
912 return 0.0;
913 }
914
915 // Sanity check functions
917
918};
919
920// Explicit instantiations
921extern template class PartBunch<double, 3>;
922
923#endif
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
KOKKOS_INLINE_FUNCTION T::value_type L2Norm(T &x)
Definition: PartBunch.h:35
typename ippl::detail::ViewType< ippl::Vector< double, 3 >, 1 >::view_type view_type
Definition: PartBunch.h:39
Inform * gmsg
Definition: changes.cpp:7
Defines a structure to hold particles in energy bins and their associated data.
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
KOKKOS_INLINE_FUNCTION constexpr decltype(auto) apply(const View &view, const Coords &coords)
RangePolicy< View::rank, typenameView::execution_space, PolicyArgs... >::policy_type getRangePolicy(const View &view, int shift=0)
void parallel_for(const std::string &name, const ExecPolicy &policy, const FunctorType &functor)
long long localTrackStep_m
step in a TRACK command
Vector_t< double, Dim > get_rprms() const
Definition: PartBunch.h:741
void setGlobalMeanR(Vector_t< double, Dim > globalMeanR)
Definition: PartBunch.h:886
size_t boundp_destroyT()
Definition: PartBunch.h:387
PartData * getReference()
Definition: PartBunch.h:359
long long getLocalTrackStep() const
Definition: PartBunch.h:872
void setT(double t)
Definition: PartBunch.h:696
void incTrackSteps()
Definition: PartBunch.h:867
double get_Dx() const
Definition: PartBunch.h:808
void performBunchSanityChecks() const
Definition: PartBunch.cpp:669
double getdE() const
Definition: PartBunch.h:342
Vector_t< double, Dim > rmin_m
double getBinGamma(int)
Definition: PartBunch.h:604
void set_sPos(double s)
Definition: PartBunch.h:708
void gatherLoadBalanceStatistics()
void do_binaryRepart()
std::array< bool, Dim > decomp_m
Definition: PartBunch.h:102
size_t getNumberOfEmissionSteps()
Definition: PartBunch.h:552
double rmsDensity_m
Definition: PartBunch.h:82
void calcLineDensity(unsigned int, std::vector< double > &, std::pair< double, double > &)
Definition: PartBunch.h:516
Vector_t< double, Dim > R(size_t)
Definition: PartBunch.h:254
double getdT() const
Vector_t< double, Dim > get_rrms() const
Definition: PartBunch.h:737
void pre_run() override
A method that should be used for setting up the simulation.
Definition: PartBunch.cpp:341
Vector_t< T, Dim > globalMeanR_m
Initialize the translation vector and rotation quaternion here.
Definition: #PartBunch.hpp#:98
void setSteptoLastInj(int n)
Definition: PartBunch.h:902
void setBinCharge(int, double)
Definition: PartBunch.h:612
double t_m
holds the actual time of the integration
void updateMoments()
Definition: PartBunch.h:242
void setBeamFrequency(double)
Definition: PartBunch.h:521
Vector_t< double, Dim > P(size_t)
Definition: PartBunch.h:259
size_t getTotalNum() const
Definition: PartBunch.h:246
double getY0(int)
Definition: PartBunch.h:666
void rebin()
Definition: PartBunch.h:591
Vector_t< double, Dim > get_normalizedEps_99_99Percentile() const
Definition: PartBunch.h:799
void swap(unsigned int, unsigned int)
Definition: PartBunch.h:408
Vector_t< double, Dim > get_norm_emit() const
Definition: PartBunch.h:764
void setTEmission(double)
Definition: PartBunch.h:572
double get_plasmaParameter() const
Definition: PartBunch.h:833
void getLocalBounds(Vector_t< double, Dim > &, Vector_t< double, Dim > &)
Definition: PartBunch.h:680
void switchOffUnitlessPositions(bool use_dt_per_particle=false)
Convert particle positions from unitless back to physical coordinates.
Definition: PartBunch.h:488
Vector_t< double, Dim > get_prms() const
Definition: PartBunch.h:745
int getSteptoLastInj() const
Definition: PartBunch.h:906
void resetInterpolationCache(bool)
Definition: PartBunch.h:405
void calcDebyeLength()
Definition: PartBunch.h:825
bool fixed_grid
void scatterCIC()
Definition: PartBunch.h:294
void setCharge()
Definition: PartBunch.h:316
void setCouplingConstant(double c)
Definition: PartBunch.h:308
Vector_t< double, Dim > get_pmean_Distribution() const
Definition: PartBunch.h:756
std::string solver_m
Definition: PartBunch.h:73
double DrInv_m
Definition: PartBunch.h:99
int getLastEmittedEnergyBin()
Definition: PartBunch.h:548
double getM() const
Definition: PartBunch.h:338
bool resetPartBinID2(const double)
Definition: PartBunch.h:622
bool resetPartBinBunch()
Definition: PartBunch.h:626
long long getGlobalTrackStep() const
Definition: PartBunch.h:858
double get_rmsDensity() const
Definition: PartBunch.h:837
Vector_t< double, Dim > get_emit() const
Definition: PartBunch.h:760
double getChargePerParticle() const
Definition: PartBunch.h:328
double getdT() const
Definition: PartBunch.h:692
Vector_t< double, Dim > get_95Percentile() const
Definition: PartBunch.h:775
int stepsPerTurn_m
steps per turn for OPAL-cycl
int getStepsPerTurn() const
Definition: PartBunch.h:849
double alpha_m
Definition: PartBunch.h:98
std::shared_ptr< VField_t< T, Dim > > getTempEField()
Definition: PartBunch.h:232
double qi_m
double spos_m
the position along design trajectory
double getCouplingConstant() const
Definition: PartBunch.h:304
Vector_t< double, Dim > get_rmean() const
Definition: PartBunch.h:749
double getBeta(int) const
Definition: PartBunch.h:350
bool hasBinning()
Definition: PartBunch.h:608
double get_sPos() const
Definition: PartBunch.h:712
void grid2par() override
Grid-to-particle operation.
Definition: PartBunch.h:288
void computeSelfFields()
Quaternion_t globalToLocalQuaternion_m
Definition: PartBunch.h:130
void scatterCICPerBin(binIndex_t binIndex)
Definition: PartBunch.cpp:601
typename ParticleBinning::AdaptBins< ParticleContainer_t, BinningSelector_t > AdaptBins_t
Definition: PartBunch.h:53
void get_PBounds(Vector_t< double, Dim > &, Vector_t< double, Dim > &)
Definition: PartBunch.h:684
bool isGridFixed()
Definition: PartBunch.h:378
Vector_t< double, Dim > rmax_m
double get_Dy() const
Definition: PartBunch.h:811
double getPy(int)
Definition: PartBunch.h:634
void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion)
Definition: PartBunch.h:894
void actT()
Definition: PartBunch.h:355
bool hasFieldSolver()
Definition: PartBunch.h:534
Vector_t< double, Dim > get_maxExtent() const
Definition: PartBunch.h:728
std::shared_ptr< FieldSolverCmd > OPALFieldSolver_m
Definition: PartBunch.h:180
size_type totalP_m
Definition: PartBunch.h:60
Vector_t< double, Dim > globalMeanR_m
Initialize the translation vector and rotation quaternion here.
Definition: PartBunch.h:129
double getCharge() const
get the total charge per simulation particle
Vector_t< double, Dim > get_68Percentile() const
Definition: PartBunch.h:771
void setBinCharge(int)
Definition: PartBunch.h:615
double getTEmission()
Definition: PartBunch.h:575
int getNumberOfEnergyBins()
Definition: PartBunch.h:556
std::shared_ptr< BCHandler_t > getBCHandler() const
Definition: PartBunch.h:240
double getPx(int)
Definition: PartBunch.h:630
void get_bounds(Vector_t< double, Dim > &rmin, Vector_t< double, Dim > &rmax)
Definition: PartBunch.h:675
void setZ(int, double)
Definition: PartBunch.h:671
size_t calcNumPartsOutside(Vector_t< double, Dim >)
Definition: PartBunch.h:511
bool isUnitless_m
Definition: PartBunch.h:184
bool isFirstRepartition_m
Definition: PartBunch.h:75
double get_debyeLength() const
Definition: PartBunch.h:829
short numBunch_m
current bunch number
void setBCHandler(std::shared_ptr< BCHandler_t > bcHandler)
Definition: PartBunch.h:239
double tEmission_m
if larger than 0, emitt particles for tEmission_m [s]
Vector_t< double, Dim > Bf(size_t)
Definition: PartBunch.h:269
int getLastemittedBin()
Definition: PartBunch.h:594
typename ParticleContainer_t::bin_index_type binIndex_t
Definition: PartBunch.h:54
Vector_t< double, Dim > getEExtrema()
Definition: PartBunch.h:525
double getT() const
Definition: PartBunch.h:704
void setBCForDCBeam()
Definition: PartBunch.h:395
Inform & print(Inform &os)
Vector_t< int, Dim > nr_m
Definition: PartBunch.h:87
std::shared_ptr< ParticleContainer_t > getParticleContainer()
Definition: PartBunch.h:221
double getQ() const
Definition: PartBunch.h:335
ParticleAttrib< double > dt
Definition: #PartBunch.hpp#:76
double getPy0(int)
Definition: PartBunch.h:646
PartBunch()=delete
Vector_t< double, Dim > get_normalizedEps_68Percentile() const
Definition: PartBunch.h:787
double get_meanKineticEnergy()
Definition: PartBunch.h:721
void boundp()
Definition: PartBunch.h:383
double dt_m
6x6 matrix of the moments of the beam
void setLocalTrackStep(long long n)
step in a TRACK command
Definition: PartBunch.h:863
Vector_t< double, 2 *Dim > get_centroid() const
Definition: PartBunch.h:733
void par2grid() override
Particle-to-grid operation.
Definition: PartBunch.h:284
double time_m
Definition: PartBunch.h:58
~PartBunch()
Definition: PartBunch.h:217
double getPx0(int)
Definition: PartBunch.h:642
long long globalTrackStep_m
if multiple TRACK commands
Vector_t< double, Dim > get_halo() const
Definition: PartBunch.h:767
std::shared_ptr< VField_t< T, Dim > > Etmp_m
Temporary E field container used to store temporary E field during binned solver.
Definition: PartBunch.h:200
void setMass()
Definition: PartBunch.h:320
size_t emitParticles(double)
Definition: PartBunch.h:584
bool getFieldSolverType()
Definition: PartBunch.h:539
double get_DDx() const
Definition: PartBunch.h:814
double lbt_m
Definition: PartBunch.h:65
std::vector< size_t > bunchTotalNum_m
number of particles per bunch
void setSolver(std::string solver)
double calcMeanPhi()
Definition: PartBunch.h:618
double get_gamma() const
Definition: PartBunch.h:716
void resizeMesh()
Definition: PartBunch.h:374
void gatherStatistics(unsigned int)
Definition: PartBunch.h:415
size_t getLocalNum() const
Definition: PartBunch.h:250
int it_m
Definition: PartBunch.h:69
short getNumBunch() const
Definition: PartBunch.h:882
Vector_t< double, Dim > get_normalizedEps_95Percentile() const
Definition: PartBunch.h:791
int SteptoLastInj_m
this parameter records the current steps since last bunch injection it helps to inject new bunches co...
bool weHaveBins()
Definition: PartBunch.h:579
double getX(int)
Definition: PartBunch.h:650
void setupBCs()
Definition: PartBunch.h:398
Vector_t< double, Dim > get_99_99Percentile() const
Definition: PartBunch.h:783
void gatherCIC()
double getZ(int)
Definition: PartBunch.h:658
double getX0(int)
Definition: PartBunch.h:662
std::string integration_method_m
Definition: PartBunch.h:71
double periodLength_m
double get_temperature() const
Definition: PartBunch.h:821
ippl::NDIndex< Dim > domain_m
Definition: PartBunch.h:101
Vector_t< double, Dim > get_hr() const
Definition: PartBunch.h:803
double Bext_m
Definition: PartBunch.h:97
Vector_t< double, Dim > dt(size_t)
Definition: PartBunch.h:274
Vector_t< double, Dim > RefPartR_m
Reference particle structures.
Definition: PartBunch.h:112
void calcBeamParameters()
void setStepsPerTurn(int n)
Definition: PartBunch.h:845
void bunchUpdate()
Definition: PartBunch.cpp:425
bool getIfBeamEmitting()
Definition: PartBunch.h:544
Vector_t< double, Dim > hr_m
mesh size [m]
void spaceChargeEFieldCheck(Vector_t< double, 3 > efScale)
Definition: PartBunch.cpp:171
double calculateAngle(double, double)
Definition: PartBunch.h:910
void setNumBunch(short n)
Definition: PartBunch.h:876
void setLocalBinCount(size_t, int)
Definition: PartBunch.h:598
void switchToUnitlessPositions(bool use_dt_per_particle=false)
Transform particle positions to a unitless coordinate system.
Definition: PartBunch.h:443
void setBins(std::shared_ptr< AdaptBins_t > bins)
Definition: PartBunch.h:237
size_t getLoadBalance(int p)
Definition: PartBunch.h:370
std::vector< size_t > bunchLocalNum_m
typename ParticleBinning::CoordinateSelector< ParticleContainer_t > BinningSelector_t
Definition: PartBunch.h:52
void setBCAllOpen()
Definition: PartBunch.h:392
Quaternion_t getGlobalToLocalQuaternion()
Definition: PartBunch.h:898
Vector_t< double, Dim > origin_m
Definition: PartBunch.h:89
double couplingConstant_m
void calcGammas()
Definition: PartBunch.h:601
double getCharge() const
Definition: PartBunch.h:324
void setBCAllPeriodic()
Definition: PartBunch.h:401
void gatherCIC()
void advance() override
A method that should be used to execute/advance a step of simulation.
Definition: PartBunch.h:279
void updateNumTotal()
Definition: PartBunch.h:588
double mi_m
Definition: PartBunch.h:80
double getPz(int)
Definition: PartBunch.h:638
size_t getTotalNum() const
Vector_t< double, Dim > get_normalizedEps_99Percentile() const
Definition: PartBunch.h:795
double get_DDy() const
Definition: PartBunch.h:817
PartData * reference_m
Definition: PartBunch.h:167
void setdT(double dt)
Definition: PartBunch.h:688
std::shared_ptr< BCHandler_t > bcHandler_m
Definition: PartBunch.h:84
std::shared_ptr< Distribution > OPALdist_m
Definition: PartBunch.h:178
std::shared_ptr< AdaptBins_t > getBins()
Definition: PartBunch.h:235
Vector_t< double, Dim > Ef(size_t)
Definition: PartBunch.h:264
bool weHaveEnergyBins()
Definition: PartBunch.h:568
Vector_t< double, Dim > get_origin() const
Definition: PartBunch.h:725
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
Definition: PartBunch.h:854
double getEmissionDeltaT()
Definition: PartBunch.h:363
double getMassPerParticle() const
Definition: PartBunch.h:331
void Rebin()
Definition: PartBunch.h:561
void incrementT()
Definition: PartBunch.h:700
Vector_t< double, Dim > RefPartP_m
Definition: PartBunch.h:113
double getRho(int, int, int)
Definition: PartBunch.h:411
double getY(int)
Definition: PartBunch.h:654
Vector_t< double, Dim > getGlobalMeanR()
Definition: PartBunch.h:890
Vector_t< double, Dim > get_99Percentile() const
Definition: PartBunch.h:779
void setEnergyBins(int)
Definition: PartBunch.h:565
Vector_t< double, Dim > get_pmean() const
Definition: PartBunch.h:753
std::unique_ptr< size_t[]> globalPartPerNode_m
double getGamma(int) const
Definition: PartBunch.h:346
std::shared_ptr< AdaptBins_t > bins_m
Definition: PartBunch.h:148
CoordinateSystemTrafo toLabTrafo_m
Definition: #PartBunch.hpp#:88
std::unique_ptr< double[]> bingamma_m
holds the gamma of the bin
void setTempEField(std::shared_ptr< VField_t< T, Dim > > Etmp)
Definition: PartBunch.h:233
Particle reference data.
Definition: PartData.h:37
Handler for boundary conditions per spatial dimension.
Definition: BCHandler.hpp:26
A class that bins particles in energy bins and allows for adaptive runtime rebinning.
Definition: AdaptBins.h:36
Example struct used to access the binning variable for each particle.
Definition: BinningTools.h:77
short int bin_index_type
Defines which type to use as a particle bin.
The base class for all OPAL exceptions.
Definition: OpalException.h:28
A template class for managing Particle-in-Cell (PIC) simulations.
Definition: PicManager.h:27
detail::size_type size_type
Definition: ParticleBase.h:111
Definition: Inform.h:40