OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
TrackRun.cpp
Go to the documentation of this file.
1 //
2 // Class TrackRun
3 // The RUN command.
4 //
5 // Copyright (c) 200x - 2023, 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 #include "Track/TrackRun.h"
19 
23 
27 #include "Algorithms/Tracker.h"
28 
29 #include "Attributes/Attributes.h"
30 
31 #include "Beamlines/TBeamline.h"
32 
33 #include "BasicActions/Option.h"
34 
36 
37 #include "Physics/Physics.h"
38 #include "Physics/Units.h"
39 
40 #include "Track/Track.h"
41 
43 
44 #include "Structure/Beam.h"
46 #include "Structure/DataSink.h"
47 #include "Structure/FieldSolver.h"
51 
52 #include "OPALconfig.h"
53 #include "changes.h"
54 
55 #include <boost/assign.hpp>
56 
57 #include <cmath>
58 #include <fstream>
59 #include <iomanip>
60 
61 
62 extern Inform *gmsg;
63 
64 std::shared_ptr<Tracker> TrackRun::itsTracker_m = nullptr;
65 
66 namespace {
67  // The attributes of class TrackRun.
68  enum {
69  METHOD, // Tracking method to use.
70  TURNS, // The number of turns to be tracked.
71  MBMODE, // The working way for multi-bunch mode for OPAL-cycl: "FORCE" or "AUTO"
72  PARAMB, // The control parameter for "AUTO" mode of multi-bunch,
73  MB_ETA, // The scale parameter for binning in multi-bunch mode
74  MB_BINNING, // The binning type in multi-bunch mode
75  BEAM, // The beam to track
76  FIELDSOLVER, // The field solver attached
77  BOUNDARYGEOMETRY, // The boundary geometry
78  DISTRIBUTION, // The particle distribution
79  TRACKBACK,
80  SIZE
81  };
82 }
83 
84 const std::string TrackRun::defaultDistribution("DISTRIBUTION");
85 
86 const boost::bimap<TrackRun::RunMethod, std::string> TrackRun::stringMethod_s =
87  boost::assign::list_of<const boost::bimap<TrackRun::RunMethod, std::string>::relation>
88  (RunMethod::PARALLELT, "PARALLEL-T")
89  (RunMethod::CYCLOTRONT, "CYCLOTRON-T")
90  (RunMethod::THICK, "THICK");
91 
92 
94  Action(SIZE, "RUN",
95  "The \"RUN\" sub-command tracks the defined particles through "
96  "the given lattice."),
97  dist_m(nullptr),
98  fieldSolver_m(nullptr),
99  dataSink_m(nullptr),
100  phaseSpaceSink_m(nullptr),
101  isFollowupTrack_m(false),
102  method_m(RunMethod::NONE),
103  macromass_m(0.0),
104  macrocharge_m(0.0) {
106  ("METHOD", "Name of tracking algorithm to use.",
107  {"THICK", "OPAL-T", "PARALLEL-T", "OPAL-CYCL", "CYCLOTRON-T"});
108 
110  ("TURNS", "Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron.", 1.0);
111 
112  itsAttr[MBMODE] = Attributes::makePredefinedString
113  ("MBMODE", "The working way for multi-bunch mode for OPAL-cycl.",
114  {"FORCE", "AUTO"}, "FORCE");
115 
116  itsAttr[PARAMB] = Attributes::makeReal
117  ("PARAMB", "Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode.", 5.0);
118 
119  itsAttr[MB_ETA] = Attributes::makeReal
120  ("MB_ETA", "The scale parameter for binning in multi-bunch mode.", 0.01);
121 
122  itsAttr[MB_BINNING] = Attributes::makePredefinedString
123  ("MB_BINNING", "Type of energy binning in multi-bunch mode.",
124  {"GAMMA_BINNING", "BUNCH_BINNING"}, "GAMMA_BINNING");
125 
126  itsAttr[BEAM] = Attributes::makeString
127  ("BEAM", "Name of beam.");
128 
129  itsAttr[FIELDSOLVER] = Attributes::makeString
130  ("FIELDSOLVER", "Field solver to be used.");
131 
132  itsAttr[BOUNDARYGEOMETRY] = Attributes::makeString
133  ("BOUNDARYGEOMETRY", "Boundary geometry to be used NONE (default).", "NONE");
134 
136  ("DISTRIBUTION", "List of particle distributions to be used.");
137 
138  itsAttr[TRACKBACK] = Attributes::makeBool
139  ("TRACKBACK", "Track in reverse direction, default: false.", false);
140 
143 }
144 
145 
146 TrackRun::TrackRun(const std::string& name, TrackRun* parent):
147  Action(name, parent),
148  dist_m(nullptr),
149  fieldSolver_m(nullptr),
150  dataSink_m(nullptr),
151  phaseSpaceSink_m(nullptr),
152  isFollowupTrack_m(false),
153  method_m(RunMethod::NONE),
154  macromass_m(0.0),
155  macrocharge_m(0.0) {
157 }
158 
159 
161  delete phaseSpaceSink_m;
162 }
163 
164 
165 TrackRun* TrackRun::clone(const std::string& name) {
166  return new TrackRun(name, this);
167 }
168 
169 
171  const int currentVersion = ((OPAL_VERSION_MAJOR * 100) + OPAL_VERSION_MINOR) * 100;
172  if (Options::version < currentVersion) {
173  unsigned int fileVersion = Options::version / 100;
174  bool newerChanges = false;
175  for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
176  if (it->first > fileVersion) {
177  newerChanges = true;
178  break;
179  }
180  }
181  if (newerChanges) {
182  Inform errorMsg("Error");
183  errorMsg << "\n******************** V E R S I O N M I S M A T C H ***********************\n" << endl;
184  for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
185  if (it->first > fileVersion) {
186  errorMsg << it->second << endl;
187  }
188  }
189  errorMsg << "\n"
190  << "* Make sure you do understand these changes and adjust your input file \n"
191  << "* accordingly. Then add\n"
192  << "* OPTION, VERSION = " << currentVersion << ";\n"
193  << "* to your input file. " << endl;
194  errorMsg << "\n****************************************************************************\n" << endl;
195  throw OpalException("TrackRun::execute", "Version mismatch");
196  }
197  }
198 
201  throw OpalException("TrackRun::execute",
202  "\"DISTRIBUTION\" must be set in \"RUN\" command.");
203  }
204  if (!itsAttr[FIELDSOLVER]) {
205  throw OpalException("TrackRun::execute",
206  "\"FIELDSOLVER\" must be set in \"RUN\" command.");
207  }
208  if (!itsAttr[BEAM]) {
209  throw OpalException("TrackRun::execute",
210  "\"BEAM\" must be set in \"RUN\" command.");
211  }
212 
213  // Get algorithm to use.
214  setRunMethod();
215  switch (method_m) {
216  case RunMethod::THICK: {
218  break;
219  }
220  case RunMethod::PARALLELT: {
221  setupTTracker();
222  break;
223  }
224  case RunMethod::CYCLOTRONT: {
226  break;
227  }
228  default: {
229  throw OpalException("TrackRun::execute",
230  "Unknown \"METHOD\" for the \"RUN\" command");
231  }
232  }
233 
234  if (method_m == RunMethod::THICK) {
235  int turns = int(std::round(Attributes::getReal(itsAttr[TURNS])));
236 
237  // Track for the all but last turn.
238  for (int turn = 1; turn < turns; ++turn) {
239  itsTracker_m->execute();
240  }
241  // Track the last turn.
242  itsTracker_m->execute();
243 
244  } else {
245  itsTracker_m->execute();
246 
247  opalData_m->setRestartRun(false);
248  }
249 
251 }
252 
254  if (!itsAttr[METHOD]) {
255  throw OpalException("TrackRun::setRunMethod",
256  "The attribute \"METHOD\" isn't set for the \"RUN\" command");
257  } else {
258  auto it = stringMethod_s.right.find(Attributes::getString(itsAttr[METHOD]));
259  if (it != stringMethod_s.right.end()) {
260  method_m = it->second;
261  }
262  }
263 }
264 
265 std::string TrackRun::getRunMethodName() const {
266  return stringMethod_s.left.at(method_m);
267 }
268 
270  if (isFollowupTrack_m) {
272  }
273 
275 
277 
279 
281 
283 
284  *gmsg << *this << endl;
285 
286  Track::block->bunch->setdT(Track::block->dT.front());
289 
292  }
293 
294  if (Track::block->bunch->getIfBeamEmitting()) {
296  } else {
298  }
299 
300  // set coupling constant
301  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
303 
304  // statistical data are calculated (rms, eps etc.)
306 
307  initDataSink();
308 
309  if (!isFollowupTrack_m) {
310  *gmsg << *dist_m << endl;
311  }
312 
313  if (Track::block->bunch->getTotalNum() > 0) {
314  double spos = /*Track::block->bunch->get_sPos() +*/ Track::block->zstart;
315  auto &zstop = Track::block->zstop;
316  auto &timeStep = Track::block->localTimeSteps;
317  auto &dT = Track::block->dT;
318 
319  unsigned int i = 0;
320  while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
321  ++ i;
322  }
323 
324  zstop.erase(zstop.begin(), zstop.begin() + i);
325  timeStep.erase(timeStep.begin(), timeStep.begin() + i);
326  dT.erase(dT.begin(), dT.begin() + i);
327 
328  Track::block->bunch->setdT(dT.front());
329  } else {
330  Track::block->zstart = 0.0;
331  }
332 
333  *gmsg << *beam << endl;
334  *gmsg << *fieldSolver_m << endl;
335 
336  itsTracker_m.reset(new ThickTracker(*Track::block->use->fetchLine(),
338  false, false, Track::block->localTimeSteps,
341 }
342 
343 
346 
347  if (isFollowupTrack_m) {
349  }
350 
354 
356 
358 
360 
363 
364  *gmsg << *this << endl;
365 
366  Track::block->bunch->setdT(Track::block->dT.front());
369 
372  }
373 
374  if (Track::block->bunch->getIfBeamEmitting()) {
377  } else {
380  }
381  // set coupling constant
382  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
384 
385  // statistical data are calculated (rms, eps etc.)
387 
388  initDataSink();
389 
390  if (!isFollowupTrack_m) {
391  *gmsg << std::scientific;
392  *gmsg << *dist_m << endl;
393  }
394 
395  if (Track::block->bunch->getTotalNum() > 0) {
396  double spos = Track::block->zstart;
397  auto& zstop = Track::block->zstop;
398  auto it = Track::block->dT.begin();
399 
400  unsigned int i = 0;
401  while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
402  ++ i;
403  ++ it;
404  }
405 
407  } else {
408  Track::block->zstart = 0.0;
409  }
410 
411  *gmsg << *beam << endl;
412  *gmsg << *fieldSolver_m << endl;
413 
414  // findPhasesForMaxEnergy();
415 
416  itsTracker_m.reset(new ParallelTTracker(*Track::block->use->fetchLine(),
418  *dataSink_m,
420  false,
421  Attributes::getBool(itsAttr[TRACKBACK]),
425  Track::block->dT));
426 }
427 
430 
432 
434 
436 
439 
440  std::vector<std::string> distr_str = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
441  if (distr_str.size() == 0) {
443  } else {
444  dist_m = Distribution::find(distr_str.at(0));
445  }
446 
447  // multi-bunch parameters
448  const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
449  const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
450  const std::string mbMode = Attributes::getString(itsAttr[MBMODE]);
451  const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
452  const std::string mbBinning = Attributes::getString(itsAttr[MB_BINNING]);
453 
455 
456  if (beam->getNumberOfParticles() < 3 || beam->getCurrent() == 0.0) {
458  macromass_m = beam->getMass();
460  beam->getNumberOfParticles(),
461  beam->getCurrent(),
462  *Track::block->use->fetchLine());
463 
464  } else {
471 
472  if (!isFollowupTrack_m) {
473  if (!opalData_m->inRestartRun()) {
475  beam->getNumberOfParticles(),
476  beam->getCurrent(),
477  *Track::block->use->fetchLine());
478 
479  } else {
481  beam->getNumberOfParticles(),
483  specifiedNumBunch,
485  }
486  }
487  }
488  Track::block->bunch->setMass(macromass_m); // set the Mass per macro-particle, [GeV/c^2]
489  Track::block->bunch->setCharge(macrocharge_m); // set the charge per macro-particle, [C]
490 
491  Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * Units::MHz2Hz));
493 
494  // set coupling constant
495  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
497 
498  // statistical data are calculated (rms, eps etc.)
500 
501  initDataSink(specifiedNumBunch);
502 
503  itsTracker_m.reset(new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
505  false, false, Track::block->localTimeSteps.front(),
507  specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
508 
509  ParallelCyclotronTracker* cyclTracker = dynamic_cast<ParallelCyclotronTracker*>(itsTracker_m.get());
510 
511  if (opalData_m->inRestartRun()) {
513  cyclTracker->setBeGa(h5pw->getMeanMomentum());
514 
515  cyclTracker->setPr(h5pw->getReferencePr());
516  cyclTracker->setPt(h5pw->getReferencePt());
517  cyclTracker->setPz(h5pw->getReferencePz());
518 
519  cyclTracker->setR(h5pw->getReferenceR());
520  cyclTracker->setTheta(h5pw->getReferenceT());
521  cyclTracker->setZ(h5pw->getReferenceZ());
522 
523  // The following is for restarts in local frame
524  cyclTracker->setPhi(h5pw->getAzimuth());
525  cyclTracker->setPsi(h5pw->getElevation());
526  cyclTracker->setPreviousH5Local(h5pw->getPreviousH5Local());
527 
528  if ( specifiedNumBunch > 1 ) {
530  }
531  }
532 
533  // statistical data are calculated (rms, eps etc.)
535 
536  *gmsg << *this << endl;
537  *gmsg << *dist_m << endl;
538  *gmsg << *beam << endl;
539  *gmsg << *fieldSolver_m << endl;
540 }
541 
544 
546  size_t numGridPoints = fieldSolver_m->getMX()*fieldSolver_m->getMY()*fieldSolver_m->getMT(); // total number of gridpoints
548  size_t numParticles = beam->getNumberOfParticles();
549 
550  if (!opalData_m->inRestartRun() && numParticles < numGridPoints
551  && fieldSolver_m->getFieldSolverType() != FieldSolverType::SAAMG // in SPIRAL/SAAMG we're meshing the whole domain -DW
552  && fieldSolver_m->getFieldSolverType() != FieldSolverType::P3M //In P3M with one-one mapping grid points can be less than particles
553  && !Options::amr)
554  {
555  throw OpalException("TrackRun::setupFieldsolver()",
556  "The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
557  "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
558  "Please increase the number of particles or reduce the size of the mesh.\n");
559  }
560 
564  }
565 
568  if (fieldSolver_m->hasPeriodicZ()) {
570  } else {
572  }
573 }
574 
576  const std::string h5FileName = opalData_m->getInputBasename() + std::string(".h5");
577  if (opalData_m->isInOPALCyclMode()) {
578  if (opalData_m->inRestartRun()) {
579  phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
582  H5_O_WRONLY);
583  } else if (isFollowupTrack_m) {
584  phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
585  -1,
586  h5FileName,
587  H5_O_WRONLY);
588  } else if (Options::enableHDF5) {
589  phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
590  H5_O_WRONLY);
591  }
592  } else {
593  if (opalData_m->inRestartRun()) {
594  phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
597  H5_O_WRONLY);
598  } else if (isFollowupTrack_m) {
599  phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
600  -1,
601  h5FileName,
602  H5_O_WRONLY);
603  } else if (Options::enableHDF5) {
604  phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
605  H5_O_WRONLY);
606  }
607  }
608 }
609 
610 
611 void TrackRun::initDataSink(const int& numBunch) {
612  if (!opalData_m->inRestartRun()) {
614  opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
615  } else {
618  }
619  } else {
620  opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
621  }
623 }
624 
626  if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
627  // Ask the dictionary if BoundaryGeometry is allocated.
628  // If it is allocated use the allocated BoundaryGeometry
629  if (!opalData_m->hasGlobalGeometry()) {
630  const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
631  BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
633  }
634  }
635 }
636 
637 
639  /*
640  * Distribution(s) can be set via a single distribution or a list
641  * (array) of distributions. If an array is defined the first in the
642  * list is treated as the primary distribution. All others are added to
643  * it to create the full distribution.
644  */
645  std::vector<std::string> distributionArray
647  const size_t numberOfDistributions = distributionArray.size();
648 
649  if (numberOfDistributions == 0) {
651  } else {
652  dist_m = Distribution::find(distributionArray.at(0));
653  dist_m->setNumberOfDistributions(numberOfDistributions);
654 
655  if (numberOfDistributions > 1) {
656  *gmsg << endl
657  << "---------------------------------" << endl
658  << "Found more than one distribution:" << endl << endl;
659  *gmsg << "Main Distribution" << endl
660  << "---------------------------------" << endl
661  << distributionArray.at(0) << endl << endl
662  << "Secondary Distribution(s)" << endl
663  << "---------------------------------" << endl;
664 
665  for (size_t i = 1; i < numberOfDistributions; ++ i) {
666  Distribution *distribution = Distribution::find(distributionArray.at(i));
667  distribution->setNumberOfDistributions(numberOfDistributions);
668  distrs_m.push_back(distribution);
669 
670  *gmsg << distributionArray.at(i) << endl;
671  }
672  *gmsg << endl
673  << "---------------------------------" << endl << endl;
674  }
675  }
676 
677  /*
678  * Initialize distributions.
679  */
680  size_t numberOfParticles = beam->getNumberOfParticles();
681  if (!isFollowupTrack_m) {
682  if (!opalData_m->inRestartRun()) {
683  /*
684  * Here we are not doing a restart run
685  * and we do not have a bunch already allocated.
686  */
688  distrs_m,
689  numberOfParticles);
690 
691  /*
692  * If this is an injected beam (rather than an emitted beam), we
693  * make sure it doesn't have any particles at z < 0.
694  */
695 
697  } else {
698  /*
699  * Read in beam from restart file.
700  */
702  }
703  }
704 
705  // Return charge per macroparticle.
706  return beam->getChargePerParticle();
707 }
708 
710  os << endl;
711  os << "* ************* T R A C K R U N *************************************************** " << endl;
712  if (!isFollowupTrack_m) {
713  os << "* Selected Tracking Method == " << getRunMethodName() << ", NEW TRACK" << '\n'
714  << "* ********************************************************************************** " << '\n';
715  } else {
716  os << "* Selected Tracking Method == " << getRunMethodName() << ", FOLLOWUP TRACK" << '\n'
717  << "* ********************************************************************************** " << '\n';
718  }
719  os << "* Phase space dump frequency = " << Options::psDumpFreq << '\n'
720  << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << '\n'
721  << "* DT = " << Track::block->dT.front() << " [s]\n"
722  << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << '\n'
723  << "* Mass of simulation particle = " << macromass_m << " [GeV/c^2]" << '\n'
724  << "* Charge of simulation particle = " << macrocharge_m << " [C]" << '\n';
726  os << "* Number of neighbour bunches = " << int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS])))) << '\n'
727  << "* STEPSPERTURN = " << Track::block->stepsPerTurn << '\n';
728  }
729  os << "* ********************************************************************************** ";
730  return os;
731 }
732 
733 std::shared_ptr<Tracker> TrackRun::getTracker() {
734  return itsTracker_m;
735 }
int getRestartStep()
get the step where to restart
Definition: OpalData.cpp:324
double getElevation() const
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
static OpalData * getInstance()
Definition: OpalData.cpp:196
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
Definition: OpalData.cpp:381
void setMass(double mass)
virtual BoundaryGeometry * clone(const std::string &name)
Return a clone.
double getMY() const
Return meshsize.
ParticleAttrib< ParticleOrigin > POrigin
bool enableHDF5
If true HDF5 files are written.
Definition: Options.cpp:81
void setNumberOfDistributions(unsigned int n)
Definition: Distribution.h:241
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
void setGlobalPhaseShift(double shift)
units: (sec)
Definition: OpalData.cpp:447
virtual void execute()
Execute the command.
Definition: TrackRun.cpp:170
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
virtual void setBCForDCBeam()
void setLocalTrackStep(long long n)
step in a TRACK command
void setupTTracker()
Definition: TrackRun.cpp:344
bool getPreviousH5Local() const
void initPhaseSpaceSink()
Definition: TrackRun.cpp:575
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition: Beam.cpp:214
void setCharge(double q)
int stepsPerTurn
The timsteps per revolution period. ONLY available for OPAL-cycl.
Definition: Track.h:78
void setMassZeroPart(double mass)
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
Definition: OpalData.cpp:365
void setdT(double dt)
void setRunMethod()
Definition: TrackRun.cpp:253
constexpr double epsilon_0
The permittivity of vacuum in As/Vm.
Definition: Physics.h:51
void setGlobalGeometry(BoundaryGeometry *bg)
Definition: OpalData.cpp:457
void setT(double t)
Steppers::TimeIntegrator timeIntegrator
The ID of time integrator.
Definition: Track.h:87
int truncOrder
Trunction order for map tracking.
Definition: Track.h:90
bool isFollowupTrack_m
Definition: TrackRun.h:105
std::map< unsigned int, std::string > changes
Definition: changes.cpp:7
double getReferencePr() const
H5PartWrapper * phaseSpaceSink_m
Definition: TrackRun.h:101
static std::shared_ptr< Tracker > getTracker()
Definition: TrackRun.cpp:733
void setPType(const std::string &type)
void setupFieldsolver()
Definition: TrackRun.cpp:542
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
Definition: Track.h:47
std::vector< double > zstop
The location at which the simulation stops.
Definition: Track.h:84
Track using thick-lens algorithm.
Definition: ThickTracker.h:86
std::string getRestartFileName()
get opals restart h5 format filename
Definition: OpalData.cpp:328
bool inRestartRun()
true if we do a restart run
Definition: OpalData.cpp:312
void calcBeamParameters()
void bunchIsAllocated()
Definition: OpalData.cpp:369
PartData reference
The reference data.
Definition: Track.h:50
void setPr(double x)
Method for restart.
static BoundaryGeometry * find(const std::string &name)
size_t getNumberOfParticles() const
Return the number of (macro)particles.
Definition: Beam.cpp:173
void initCartesianFields()
void setInOPALTMode()
Definition: OpalData.cpp:288
double getReferenceZ() const
clearpage the user may choose between constant or variable radius This model includes fringe fields begin
Definition: multipole_t.tex:6
#define OPAL_VERSION_MAJOR
Definition: config.h.in:6
constexpr double pi
The value of .
Definition: Physics.h:30
virtual Beamline * fetchLine() const =0
Return the embedded CLASSIC beam line.
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
double getMeanMomentum() const
double deltaTau
Definition: Track.h:68
std::string getParticleName() const
Return Particle&#39;s name.
Definition: Beam.cpp:200
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
void setLastDumpedStep(const int para)
set last dumped step
double dtScInit
Definition: Track.h:68
static std::shared_ptr< Tracker > itsTracker_m
Definition: TrackRun.h:92
b Accompany it with a written valid for at least three to give any third for a charge no more than your cost of physically performing source distribution
Definition: LICENSE:140
Distribution * dist_m
Definition: TrackRun.h:94
double getEmissionTimeShift() const
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
void setRestartRun(const bool &value=true)
set OPAL in restart mode
Definition: OpalData.cpp:316
static Distribution * find(const std::string &name)
static const boost::bimap< RunMethod, std::string > stringMethod_s
Definition: TrackRun.h:110
void setBeamFrequency(double v)
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:191
double getReferencePz() const
void setupCyclotronTracker()
Definition: TrackRun.cpp:428
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Definition: Attributes.cpp:473
double macrocharge_m
Definition: TrackRun.h:114
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Definition: Attributes.cpp:409
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
Definition: Options.cpp:39
DataSink * getDataSink()
Definition: OpalData.cpp:390
Definition: Inform.h:42
FieldSolverType getFieldSolverType() const
Definition: FieldSolver.h:164
#define OPAL_VERSION_MINOR
Definition: config.h.in:7
double getMT() const
Return meshsize.
void setChargeZeroPart(double q)
std::vector< unsigned long long > localTimeSteps
Maximal number of timesteps.
Definition: Track.h:75
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
double getReferencePt() const
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
static Track * block
The block of track data.
Definition: Track.h:59
void doRestartOpalT(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, H5PartWrapper *h5wrapper)
constexpr double q_e
The elementary charge in As.
Definition: Physics.h:69
double getReferenceR() const
double zstart
The location at which the simulation starts.
Definition: Track.h:81
FieldSolver * fieldSolver_m
Definition: TrackRun.h:97
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
double getMass() const
Return Particle&#39;s rest mass in GeV.
Definition: Beam.cpp:196
static Beam * find(const std::string &name)
Find named BEAM.
Definition: Beam.cpp:163
BeamSequence * use
The lattice to be tracked through.
Definition: Track.h:53
void setStepsPerTurn(int n)
void setDataSink(DataSink *s)
Definition: OpalData.cpp:385
bool amr
Enable AMR if true.
Definition: Options.cpp:99
double getChargePerParticle() const
Charge per macro particle in C.
Definition: Beam.cpp:208
RunMethod method_m
Definition: TrackRun.h:109
const std::string name
constexpr double MHz2Hz
Definition: Units.h:113
Inform & print(Inform &os) const
Definition: TrackRun.cpp:709
std::vector< Distribution * > distrs_m
Definition: TrackRun.h:95
double getTEmission()
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
double setDistributionParallelT(Beam *beam)
Definition: TrackRun.cpp:638
void setBoundaryGeometry()
Definition: TrackRun.cpp:625
int version
opal version of input file
Definition: Options.cpp:97
DataSink * dataSink_m
Definition: TrackRun.h:99
double getCurrent() const
Return the beam current in A.
Definition: Beam.cpp:188
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition: OpalData.cpp:756
OpalData * opalData_m
Definition: TrackRun.h:103
static const std::string defaultDistribution
Definition: TrackRun.h:107
std::string getInputBasename()
get input file name without extension
Definition: OpalData.cpp:674
void changeH5Wrapper(H5PartWrapper *h5wrapper)
Definition: DataSink.cpp:143
bool isInOPALCyclMode()
Definition: OpalData.cpp:272
virtual void setBCAllOpen()
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition: TrackRun.cpp:165
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
Definition: Attributes.cpp:478
void initDataSink(const int &numBunch=1)
Definition: TrackRun.cpp:611
double getMX() const
Return meshsize.
bool hasPeriodicZ()
double getReferenceT() const
std::vector< double > dT
The initial timestep.
Definition: Track.h:65
void doRestartOpalCycl(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, const int specifiedNumBunch, H5PartWrapper *h5wrapper)
void setupThickTracker()
Definition: TrackRun.cpp:269
Definition: Beam.h:31
std::string getRunMethodName() const
Definition: TrackRun.cpp:265
The base class for all OPAL actions.
Definition: Action.h:30
double getAzimuth() const
TrackRun()
Exemplar constructor.
Definition: TrackRun.cpp:93
virtual ~TrackRun()
Definition: TrackRun.cpp:160
double macromass_m
Definition: TrackRun.h:113
Inform * gmsg
Definition: Main.cpp:70
double getCharge() const
Return the charge number in elementary charge.
Definition: Beam.cpp:192
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
Definition: Options.cpp:41
void setInOPALCyclMode()
Definition: OpalData.cpp:284
virtual void setSolver(FieldSolver *fs)
void setCouplingConstant(double c)
double getFrequency() const
Return the beam frequency in MHz.
Definition: Beam.cpp:204
bool hasGlobalGeometry()
Definition: OpalData.cpp:465