OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
PartBunch.cpp
Go to the documentation of this file.
1//
2// Class PartBunch
3// Particle Bunch.
4// A representation of a particle bunch as a vector of particles.
5//
6// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
20
21#include <cfloat>
22#include <memory>
23#include <utility>
24
28
29#include "Algorithms/ListElem.h"
33
34#ifdef DBG_SCALARFIELD
36#endif
37
38//#define FIELDSTDOUT
39
40PartBunch::PartBunch(const PartData *ref): // Layout is set using setSolver()
41 PartBunchBase<double, 3>(new PartBunch::pbase_t(new Layout_t()), ref),
42 interpolationCacheSet_m(false)
43{
44
45}
46
47
51
52// PartBunch::pbase_t* PartBunch::clone() {
53// return new pbase_t(new Layout_t());
54// }
55
56
58 Layout_t* layout = static_cast<Layout_t*>(&getLayout());
59 layout->getLayout().changeDomain(*fLayout);
60}
61
62
65
66 pbase_t* underlyingPbase =
67 dynamic_cast<pbase_t*>(pbase_m.get());
68
69 BinaryRepartition(*underlyingPbase);
70 update();
72 boundp();
73}
74
75
76void PartBunch::computeSelfFields(int binNumber) {
78
80 throw GeneralClassicException("PartBunch::computeSelfFields(int binNumber)",
81 "P3M solver not available during emission");
82 }
83
86 rho_m = 0.0;
87 Field_t imagePotential = rho_m;
88
90 eg_m = Vector_t(0.0);
91
92 if(fs_m->hasValidSolver()) {
94 resizeMesh();
95
97 this->Q *= this->dt;
101 } else {
103 getLocalNum(),
104 true);
105 }
107 this->Q.scatter(this->rho_m, this->R, IntrplCIC_t(), interpolationCache_m);
108 } else {
110 }
111
112 this->Q /= this->dt;
113 this->rho_m /= getdT();
114
116 double scaleFactor = 1;
117 // double scaleFactor = Physics::c * getdT();
118 double gammaz = getBinGamma(binNumber);
119
122 double tmp2 = 1 / hr_m[0] * 1 / hr_m[1] * 1 / hr_m[2] / (scaleFactor * scaleFactor * scaleFactor) / gammaz;
123 rho_m *= tmp2;
124
127 Vector_t hr_scaled = hr_m * Vector_t(scaleFactor);
128 hr_scaled[2] *= gammaz;
129
132 imagePotential = rho_m;
133
134 fs_m->solver_m->computePotential(rho_m, hr_scaled);
135
137 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
138
142
145 eg_m = -Grad(rho_m, eg_m);
146
149 eg_m *= Vector_t({gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz)});
150
151 // If desired write E-field and potential to terminal
152#ifdef FIELDSTDOUT
153 // Immediate debug output:
154 // Output potential and e-field along the x-, y-, and z-axes
155 int mx = (int)nr_m[0];
156 int mx2 = (int)nr_m[0] / 2;
157 int my = (int)nr_m[1];
158 int my2 = (int)nr_m[1] / 2;
159 int mz = (int)nr_m[2];
160 int mz2 = (int)nr_m[2] / 2;
161
162 for (int i=0; i<mx; i++ )
163 *gmsg << "Bin " << binNumber
164 << ", Self Field along x axis E = " << eg_m[i][my2][mz2]
165 << ", Pot = " << rho_m[i][my2][mz2] << endl;
166
167 for (int i=0; i<my; i++ )
168 *gmsg << "Bin " << binNumber
169 << ", Self Field along y axis E = " << eg_m[mx2][i][mz2]
170 << ", Pot = " << rho_m[mx2][i][mz2] << endl;
171
172 for (int i=0; i<mz; i++ )
173 *gmsg << "Bin " << binNumber
174 << ", Self Field along z axis E = " << eg_m[mx2][my2][i]
175 << ", Pot = " << rho_m[mx2][my2][i] << endl;
176#endif
177
183 //Eftmp.gather(eg_m, this->R, IntrplCIC_t());
184
192 double betaC = std::sqrt(gammaz * gammaz - 1.0) / gammaz / Physics::c;
193
194 Bf(0) = Bf(0) - betaC * Eftmp(1);
195 Bf(1) = Bf(1) + betaC * Eftmp(0);
196
197 Ef += Eftmp;
198
201
204 Vector_t origin = rho_m.get_mesh().get_origin();
205 double hz = rho_m.get_mesh().get_meshSpacing(2);
206 double zshift = -(2 * origin(2) + (domain[2].first() + domain[2].last() + 1) * hz) * gammaz * scaleFactor;
207
210 fs_m->solver_m->computePotential(imagePotential, hr_scaled, zshift);
211
213 imagePotential *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
214
217 imagePotential *= getCouplingConstant();
218
219#ifdef DBG_SCALARFIELD
220 const int dumpFreq = 100;
221 VField_t tmp_eg = eg_m;
222
223 if ((localTrackStep_m + 1) % dumpFreq == 0) {
224 FieldWriter fwriter;
225 fwriter.dumpField(rho_m, "phi", "V", localTrackStep_m / dumpFreq, &imagePotential);
226 }
227#endif
228
232 eg_m = -Grad(imagePotential, eg_m);
233
236 eg_m *= Vector_t({gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz)});
237
238 // If desired write E-field and potential to terminal
239#ifdef FIELDSTDOUT
240 // Immediate debug output:
241 // Output potential and e-field along the x-, y-, and z-axes
242 //int mx = (int)nr_m[0];
243 //int mx2 = (int)nr_m[0] / 2;
244 //int my = (int)nr_m[1];
245 //int my2 = (int)nr_m[1] / 2;
246 //int mz = (int)nr_m[2];
247 //int mz2 = (int)nr_m[2] / 2;
248
249 for (int i=0; i<mx; i++ )
250 *gmsg << "Bin " << binNumber
251 << ", Image Field along x axis E = " << eg_m[i][my2][mz2]
252 << ", Pot = " << rho_m[i][my2][mz2] << endl;
253
254 for (int i=0; i<my; i++ )
255 *gmsg << "Bin " << binNumber
256 << ", Image Field along y axis E = " << eg_m[mx2][i][mz2]
257 << ", Pot = " << rho_m[mx2][i][mz2] << endl;
258
259 for (int i=0; i<mz; i++ )
260 *gmsg << "Bin " << binNumber
261 << ", Image Field along z axis E = " << eg_m[mx2][my2][i]
262 << ", Pot = " << rho_m[mx2][my2][i] << endl;
263#endif
264
265#ifdef DBG_SCALARFIELD
266 tmp_eg += eg_m;
267 if ((localTrackStep_m + 1) % dumpFreq == 0) {
268 FieldWriter fwriter;
269 fwriter.dumpField(tmp_eg, "e", "V/m", localTrackStep_m / dumpFreq);
270 }
271#endif
272
278 //Eftmp.gather(eg_m, this->R, IntrplCIC_t());
279
288 Bf(0) = Bf(0) + betaC * Eftmp(1);
289 Bf(1) = Bf(1) - betaC * Eftmp(0);
290
291 Ef += Eftmp;
292
293 }
295}
296
299 return;
300 }
301
302 double xmin = fs_m->solver_m->getXRangeMin();
303 double xmax = fs_m->solver_m->getXRangeMax();
304 double ymin = fs_m->solver_m->getYRangeMin();
305 double ymax = fs_m->solver_m->getYRangeMax();
306
307 if(xmin > rmin_m[0] || xmax < rmax_m[0] ||
308 ymin > rmin_m[1] || ymax < rmax_m[1]) {
309
310 for (unsigned int n = 0; n < getLocalNum(); n++) {
311
312 if(R[n](0) < xmin || R[n](0) > xmax ||
313 R[n](1) < ymin || R[n](1) > ymax) {
314
315 // delete the particle
316 INFOMSG(level2 << "destroyed particle with id=" << ID[n] << endl);
317 destroy(1, n);
318 }
319
320 }
321
322 update();
323 boundp();
325 }
326
327 Vector_t origin = Vector_t({0.0, 0.0, 0.0});
328
329 // update the mesh origin and mesh spacing hr_m
331
333 getMesh().set_origin(origin);
334
338 bc_m);
342 vbc_m);
343
344 update();
345
346// setGridIsFixed();
347}
348
351 rho_m = 0.0;
352 eg_m = Vector_t(0.0);
353
354 if(fs_m->hasValidSolver()) {
355 //mesh the whole domain
356 resizeMesh();
357
358 //scatter charges onto grid
359 this->Q *= this->dt;
360 this->Q.scatter(this->rho_m, this->R, IntrplCIC_t());
361 this->Q /= this->dt;
362 this->rho_m /= getdT();
363
364 //calculating mesh-scale factor
365 double gammaz = sum(this->P)[2] / getTotalNum();
366 gammaz *= gammaz;
367 gammaz = std::sqrt(gammaz + 1.0);
368 double scaleFactor = 1;
369 // double scaleFactor = Physics::c * getdT();
370 //and get meshspacings in real units [m]
371 Vector_t hr_scaled = hr_m * Vector_t(scaleFactor);
372 hr_scaled[2] *= gammaz;
373
374 //double tmp2 = 1/hr_m[0] * 1/hr_m[1] * 1/hr_m[2] / (scaleFactor*scaleFactor*scaleFactor) / gammaz;
375 double tmp2 = 1 / hr_scaled[0] * 1 / hr_scaled[1] * 1 / hr_scaled[2];
376 //divide charge by a 'grid-cube' volume to get [C/m^3]
377 rho_m *= tmp2;
378
379 double Npoints = nr_m[0] * nr_m[1] * nr_m[2];
380 rmsDensity_m = std::sqrt((1.0 /Npoints) * sum((rho_m / Physics::q_e) * (rho_m / Physics::q_e)));
381
383
384
385#ifdef DBG_SCALARFIELD
386 FieldWriter fwriter;
387 fwriter.dumpField(rho_m, "rho", "C/m^3", localTrackStep_m);
388#endif
389
390 // charge density is in rho_m
391 fs_m->solver_m->computePotential(rho_m, hr_scaled);
392
393 //do the multiplication of the grid-cube volume coming
394 //from the discretization of the convolution integral.
395 //this is only necessary for the FFT solver
396 //FIXME: later move this scaling into FFTPoissonSolver
399 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
400 }
401
402 // the scalar potential is given back in rho_m in units
403 // [C/m] = [F*V/m] and must be divided by
404 // 4*pi*\epsilon_0 [F/m] resulting in [V]
406
407 //write out rho
408#ifdef DBG_SCALARFIELD
409 fwriter.dumpField(rho_m, "phi", "V", localTrackStep_m);
410#endif
411
412 // IPPL Grad divides by hr_m [m] resulting in
413 // [V/m] for the electric field
414 eg_m = -Grad(rho_m, eg_m);
415
416 //write out e field
417#ifdef FIELDSTDOUT
418 // Immediate debug output:
419 // Output potential and e-field along the x-, y-, and z-axes
420 int mx = (int)nr_m[0];
421 int mx2 = (int)nr_m[0] / 2;
422 int my = (int)nr_m[1];
423 int my2 = (int)nr_m[1] / 2;
424 int mz = (int)nr_m[2];
425 int mz2 = (int)nr_m[2] / 2;
426
427 for (int i=0; i<mx; i++ )
428 *gmsg << "Field along x axis Ex = " << eg_m[i][my2][mz2] << " Pot = " << rho_m[i][my2][mz2] << endl;
429
430 for (int i=0; i<my; i++ )
431 *gmsg << "Field along y axis Ey = " << eg_m[mx2][i][mz2] << " Pot = " << rho_m[mx2][i][mz2] << endl;
432
433 for (int i=0; i<mz; i++ )
434 *gmsg << "Field along z axis Ez = " << eg_m[mx2][my2][i] << " Pot = " << rho_m[mx2][my2][i] << endl;
435#endif
436
437#ifdef DBG_SCALARFIELD
438 fwriter.dumpField(eg_m, "e", "V/m", localTrackStep_m);
439#endif
440
441 // interpolate electric field at particle positions. We reuse the
442 // cached information about where the particles are relative to the
443 // field, since the particles have not moved since this the most recent
444 // scatter operation.
445 Ef.gather(eg_m, this->R, IntrplCIC_t());
446
448 fs_m->solver_m->calculatePairForces(this,gammaz);
449 }
450
451 Ef = Ef * Vector_t({gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz)});
452
460 double betaC = std::sqrt(gammaz * gammaz - 1.0) / gammaz / Physics::c;
461
462 Bf(0) = Bf(0) - betaC * Ef(1);
463 Bf(1) = Bf(1) + betaC * Ef(0);
464 }
466}
467
482
483 if (getTotalNum() == 0) {
484 return;
485 }
486
488 std::size_t numGridPoints = static_cast<std::size_t>(nr_m[0]) * static_cast<std::size_t>(nr_m[1]) * static_cast<std::size_t>(nr_m[2]);
489 if (getTotalNum() < numGridPoints) {
490 WARNMSG("The number of particles decreased below the grid points. Skip space-charge calculation." << endl);
491 return;
492 }
493 }
494
496
498 throw GeneralClassicException("PartBunch::computeSelfFields_cycl(double gamma)",
499 "P3M solver not available yet for cyclotrons");
500 }
501
503 rho_m = 0.0;
504
506 eg_m = Vector_t(0.0);
507
508 if (fs_m->hasValidSolver()) {
510 resizeMesh();
511
513 this->Q.scatter(this->rho_m, this->R, IntrplCIC_t());
514
517 Vector_t hr_scaled = hr_m ;
518 hr_scaled[1] *= gamma;
519
521 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
522 rho_m *= tmp2;
523
524 double Npoints = nr_m[0] * nr_m[1] * nr_m[2];
525 rmsDensity_m = std::sqrt((1.0 /Npoints) * sum((rho_m / Physics::q_e) * (rho_m / Physics::q_e)));
526
528
529 // If debug flag is set, dump scalar field (charge density 'rho') into file under ./data/
530#ifdef DBG_SCALARFIELD
531 FieldWriter fwriter;
532 fwriter.dumpField(rho_m, "rho", "C/m^3", localTrackStep_m);
533#endif
534
537 fs_m->solver_m->computePotential(rho_m, hr_scaled);
538
539 //do the multiplication of the grid-cube volume coming
540 //from the discretization of the convolution integral.
541 //this is only necessary for the FFT solver
542 //TODO FIXME: later move this scaling into FFTPoissonSolver
545 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
546 }
547
550
551 // If debug flag is set, dump scalar field (potential 'phi') into file under ./data/
552#ifdef DBG_SCALARFIELD
553 fwriter.dumpField(rho_m, "phi", "V", localTrackStep_m);
554#endif
555
557 eg_m = -Grad(rho_m, eg_m);
558
563 eg_m *= Vector_t({gamma, 1.0 / gamma, gamma});
564
565#ifdef FIELDSTDOUT
566 // Immediate debug output:
567 // Output potential and e-field along the x-, y-, and z-axes
568 int mx = (int)nr_m[0];
569 int mx2 = (int)nr_m[0] / 2;
570 int my = (int)nr_m[1];
571 int my2 = (int)nr_m[1] / 2;
572 int mz = (int)nr_m[2];
573 int mz2 = (int)nr_m[2] / 2;
574
575 for (int i=0; i<mx; i++ )
576 *gmsg << "Field along x axis Ex = " << eg_m[i][my2][mz2] << " Pot = " << rho_m[i][my2][mz2] << endl;
577
578 for (int i=0; i<my; i++ )
579 *gmsg << "Field along y axis Ey = " << eg_m[mx2][i][mz2] << " Pot = " << rho_m[mx2][i][mz2] << endl;
580
581 for (int i=0; i<mz; i++ )
582 *gmsg << "Field along z axis Ez = " << eg_m[mx2][my2][i] << " Pot = " << rho_m[mx2][my2][i] << endl;
583#endif
584
585#ifdef DBG_SCALARFIELD
586 fwriter.dumpField(eg_m, "e", "V/m", localTrackStep_m);
587#endif
588
590 Ef.gather(eg_m, this->R, IntrplCIC_t());
591
593 // Relativistic E&M says gamma*v/c^2 = gamma*beta/c = sqrt(gamma*gamma-1)/c
594 // but because we already transformed E_trans into the moving frame we have to
595 // add 1/gamma so we are using the E_trans from the rest frame -DW
596 double betaC = std::sqrt(gamma * gamma - 1.0) / gamma / Physics::c;
597
599 Bf(0) = betaC * Ef(2);
600 Bf(2) = -betaC * Ef(0);
601 }
602
603 /*
604 *gmsg << "gamma =" << gamma << endl;
605 *gmsg << "dx,dy,dz =(" << hr_m[0] << ", " << hr_m[1] << ", " << hr_m[2] << ") [m] " << endl;
606 *gmsg << "max of bunch is (" << rmax_m(0) << ", " << rmax_m(1) << ", " << rmax_m(2) << ") [m] " << endl;
607 *gmsg << "min of bunch is (" << rmin_m(0) << ", " << rmin_m(1) << ", " << rmin_m(2) << ") [m] " << endl;
608 */
609
611}
612
632
634 throw GeneralClassicException("PartBunch::computeSelfFields_cycl(int bin)",
635 "P3M solver not available yet for cyclotrons");
636 }
637
639 rho_m = 0.0;
640
642 eg_m = Vector_t(0.0);
643
645 double gamma = getBinGamma(bin);
646
647 if(fs_m->hasValidSolver()) {
649 resizeMesh();
650
652 this->Q.scatter(this->rho_m, this->R, IntrplCIC_t());
653
656 Vector_t hr_scaled = hr_m ;
657 hr_scaled[1] *= gamma;
658
660 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
661 rho_m *= tmp2;
662
663 // If debug flag is set, dump scalar field (charge density 'rho') into file under ./data/
664#ifdef DBG_SCALARFIELD
665 FieldWriter fwriter;
666 fwriter.dumpField(rho_m, "rho", "C/m^3", localTrackStep_m);
667#endif
668
671 fs_m->solver_m->computePotential(rho_m, hr_scaled);
672
673 // Do the multiplication of the grid-cube volume coming from the discretization of the convolution integral.
674 // This is only necessary for the FFT solver. FIXME: later move this scaling into FFTPoissonSolver
677 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
678 }
679
682
683 // If debug flag is set, dump scalar field (potential 'phi') into file under ./data/
684#ifdef DBG_SCALARFIELD
685 fwriter.dumpField(rho_m, "phi", "V", localTrackStep_m);
686#endif
687
689 eg_m = -Grad(rho_m, eg_m);
690
695 eg_m *= Vector_t({gamma, 1.0 / gamma, gamma});
696
697#ifdef FIELDSTDOUT
698 // Immediate debug output:
699 // Output potential and e-field along the x-, y-, and z-axes
700 int mx = (int)nr_m[0];
701 int mx2 = (int)nr_m[0] / 2;
702 int my = (int)nr_m[1];
703 int my2 = (int)nr_m[1] / 2;
704 int mz = (int)nr_m[2];
705 int mz2 = (int)nr_m[2] / 2;
706
707 for (int i=0; i<mx; i++ )
708 *gmsg << "Bin " << bin
709 << ", Field along x axis Ex = " << eg_m[i][my2][mz2]
710 << ", Pot = " << rho_m[i][my2][mz2] << endl;
711
712 for (int i=0; i<my; i++ )
713 *gmsg << "Bin " << bin
714 << ", Field along y axis Ey = " << eg_m[mx2][i][mz2]
715 << ", Pot = " << rho_m[mx2][i][mz2] << endl;
716
717 for (int i=0; i<mz; i++ )
718 *gmsg << "Bin " << bin
719 << ", Field along z axis Ez = " << eg_m[mx2][my2][i]
720 << ", Pot = " << rho_m[mx2][my2][i] << endl;
721#endif
722
723 // If debug flag is set, dump vector field (electric field) into file under ./data/
724#ifdef DBG_SCALARFIELD
725 fwriter.dumpField(eg_m, "e", "V/m", localTrackStep_m);
726#endif
727
729 Eftmp.gather(eg_m, this->R, IntrplCIC_t());
730
731
732
734 double betaC = std::sqrt(gamma * gamma - 1.0) / gamma / Physics::c;
735
737 Bf(0) = Bf(0) + betaC * Eftmp(2);
738 Bf(2) = Bf(2) - betaC * Eftmp(0);
739
740 Ef += Eftmp;
741 }
742
743 /*
744 *gmsg << "gamma =" << gamma << endl;
745 *gmsg << "dx,dy,dz =(" << hr_m[0] << ", " << hr_m[1] << ", " << hr_m[2] << ") [m] " << endl;
746 *gmsg << "max of bunch is (" << rmax_m(0) << ", " << rmax_m(1) << ", " << rmax_m(2) << ") [m] " << endl;
747 *gmsg << "min of bunch is (" << rmin_m(0) << ", " << rmin_m(1) << ", " << rmin_m(2) << ") [m] " << endl;
748 */
749
750
752}
753
754
755// void PartBunch::setMesh(Mesh_t* mesh) {
756// Layout_t* layout = static_cast<Layout_t*>(&getLayout());
757// // layout->getLayout().setMesh(mesh);
758// }
759
760
761// void PartBunch::setFieldLayout(FieldLayout_t* fLayout) {
762// Layout_t* layout = static_cast<Layout_t*>(&getLayout());
763// // layout->getLayout().setFieldLayout(fLayout);
764// // layout->rebuild_neighbor_data();
765// layout->getLayout().changeDomain(*fLayout);
766// }
767
768
770 Layout_t* layout = static_cast<Layout_t*>(&getLayout());
771 return dynamic_cast<FieldLayout_t &>(layout->getLayout().getFieldLayout());
772}
773
775 for (int i = 0; i < 2 * 3; ++i) {
776
777 if (Ippl::getNodes()>1) {
779 //std periodic boundary conditions for gradient computations etc.
781 }
782 else {
784 //std periodic boundary conditions for gradient computations etc.
786 }
788 }
789 dcBeam_m=true;
790 INFOMSG(level3 << "BC set all periodic" << endl);
791}
792
794 for (int i = 0; i < 2 * 3; ++i) {
798 }
799 dcBeam_m=false;
800 INFOMSG(level3 << "BC set for normal Beam" << endl);
801}
802
804 for (int i = 0; i < 2 * 3; ++ i) {
805 if (i >= 4) {
806 if (Ippl::getNodes() > 1) {
809 } else {
812 }
813
815 } else {
819 }
820 }
821 dcBeam_m=true;
822 INFOMSG(level3 << "BC set for DC-Beam, longitudinal periodic" << endl);
823}
824
825
828 for (unsigned int i = 0; i < Dimension; i++)
829 grid[i] = domain[i].length();
830}
831
832
833void PartBunch::updateFields(const Vector_t& /*hr*/, const Vector_t& origin) {
835 getMesh().set_origin(origin);
839 bc_m);
843 vbc_m);
844}
845
846inline
848 const Vector_t maxE = max(eg_m);
849 // const double maxL = max(dot(eg_m,eg_m));
850 const Vector_t minE = min(eg_m);
851 // INFOMSG("MaxE= " << maxE << " MinE= " << minE << endl);
852 return VectorPair_t(maxE, minE);
853}
854
855
856inline
859 if(clearCache) {
861 }
862}
863
864void PartBunch::swap(unsigned int i, unsigned int j) {
865
866 // FIXME
868
871}
872
873
IntCIC IntrplCIC_t
Definition PBunchDefs.h:17
Inform * gmsg
Definition Main.cpp:69
Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > & Grad(Field< T, 1U, Cartesian< 1U, MFLOAT >, Vert > &x, Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > &r)
#define INFOMSG(msg)
Definition IpplInfo.h:348
#define WARNMSG(msg)
Definition IpplInfo.h:349
Inform & level2(Inform &inf)
Definition Inform.cpp:46
Inform & endl(Inform &inf)
Definition Inform.cpp:42
Inform & level3(Inform &inf)
Definition Inform.cpp:47
void BinaryRepartition(FieldLayout< Dim > &layout, BareField< double, Dim > &weights)
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)
T ParticlePeriodicBCond(const T t, const T minval, const T maxval)
T ParticleNoBCond(const T t, const T, const T)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Definition PETE.h:1111
constexpr double q_e
The elementary charge in As.
Definition Physics.h:69
constexpr double c
The velocity of light in m/s.
Definition Physics.h:45
ParticleAttrib< Vector_t > Ef
std::shared_ptr< AbstractParticle< double, Dim > > pbase_m
long long localTrackStep_m
step in a TRACK command
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
ParticleAttrib< Vector_t > Eftmp
Vector_t rmax_m
maximal extend of particles
ParticleBConds< Position_t, Dimension > & getBConds()
ParticleAttrib< Vector_t > P
Inform & print(Inform &os)
double getBinGamma(int bin)
Get gamma of one bin.
ParticleAttrib< double > Q
Vector_t rmin_m
minimal extend of particles
FieldSolver * fs_m
stores the used field solver
std::pair< Vector_t, Vector_t > VectorPair_t
double dh_m
Mesh enlargement.
ParticleAttrib< double > dt
static const unsigned Dimension
Vector_t hr_m
meshspacing of cartesian mesh
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Bf
virtual void swap(unsigned int i, unsigned int j)
void calcDebyeLength()
Compute the (global) Debye length for the beam.
Vektor< int, 3 > nr_m
meshsize of cartesian mesh
IpplTimings::TimerRef selfFieldTimer_m
timer for selfField calculation
void resetInterpolationCache(bool clearCache=false)
BConds< double, 3, Mesh_t, Center_t > bc_m
for defining the boundary conditions
Definition PartBunch.h:111
void computeSelfFields()
void do_binaryRepart()
Definition PartBunch.cpp:63
Field_t rho_m
scalar potential
Definition PartBunch.h:94
PartBunch()=delete
void swap(unsigned int i, unsigned int j)
ParticleLayout< double, 3 > & getLayout()
Definition PartBunch.h:120
void initialize(FieldLayout_t *fLayout)
Definition PartBunch.cpp:57
void setBCAllOpen()
bool interpolationCacheSet_m
Definition PartBunch.h:115
Inform & print(Inform &os)
void updateDomainLength(Vektor< int, 3 > &grid)
void setBCForDCBeam()
FieldLayout_t & getFieldLayout()
VField_t eg_m
vector field on the grid
Definition PartBunch.h:97
VectorPair_t getEExtrema()
void setBCAllPeriodic()
const Mesh_t & getMesh() const
Definition PartBunch.h:138
ParticleAttrib< CacheDataCIC< double, 3U > > interpolationCache_m
Definition PartBunch.h:117
void resizeMesh()
resize mesh to geometry specified
BConds< Vector_t, 3, Mesh_t, Center_t > vbc_m
Definition PartBunch.h:112
void computeSelfFields_cycl(double gamma)
Calculates the self electric field from the charge density distribution for use in cyclotrons.
void updateFields(const Vector_t &hr, const Vector_t &origin)
virtual void computePotential(Field_t &rho, Vector_t hr)=0
virtual double getYRangeMin(unsigned short level=0)=0
virtual double getXRangeMin(unsigned short level=0)=0
virtual void calculatePairForces(PartBunchBase< double, 3 > *, double)
virtual void resizeMesh(Vector_t &, Vector_t &, const Vector_t &, const Vector_t &, double)
virtual double getYRangeMax(unsigned short level=0)=0
virtual double getXRangeMax(unsigned short level=0)=0
PoissonSolver * solver_m
the actual solver, should be a base object
FieldSolverType getFieldSolverType() const
bool hasValidSolver()
void dumpField(FieldType &field, std::string name, std::string unit, long long step, FieldType *image=nullptr)
Dump a scalar or vector field to a file.
void initialize(Layout_t &)
Mesh_t & get_mesh() const
Definition Field.h:110
size_t size(void) const
void scatter(Field< T, Dim, M, C > &f, const ParticleAttrib< Vektor< PT, Dim > > &pp, const IntOp &) const
virtual void destroy(size_t M, size_t I, bool optDestroy=true)
virtual void create(size_t)
const NDIndex< Dim > & getDomain() const
void set_origin(const Vektor< MFLOAT, Dim > &o)
void set_meshSpacing(MFLOAT *const del)
RegionLayout< T, Dim, Mesh > & getLayout()
static int getNodes()
Definition IpplInfo.cpp:670
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t
Definition Vektor.h:6