OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
TrackRun.cpp
Go to the documentation of this file.
1 //
2 // Class TrackRun
3 // The RUN command.
4 //
5 // Copyright (c) 200x - 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 #include "Track/TrackRun.h"
22 #include "Algorithms/Tracker.h"
24 
27 
28 #include "Attributes/Attributes.h"
29 #include "Beamlines/TBeamline.h"
30 
31 #include "BasicActions/Option.h"
32 
34 #include "Track/Track.h"
36 #include "Structure/Beam.h"
38 #include "Structure/FieldSolver.h"
39 #include "Structure/DataSink.h"
43 
44 #include "OPALconfig.h"
45 #include "changes.h"
46 
47 #include <cmath>
48 #include <fstream>
49 #include <iomanip>
50 
51 extern Inform *gmsg;
52 
53 namespace {
54 
55  // The attributes of class TrackRun.
56  enum {
57  METHOD, // Tracking method to use.
58  TURNS, // The number of turns to be tracked.
59  MBMODE, // The working way for multi-bunch mode for OPAL-cycl: "FORCE" or "AUTO"
60  PARAMB, // The control parameter for "AUTO" mode of multi-bunch,
61  MB_ETA, // The scale parameter for binning in multi-bunch mode
62  MB_BINNING, // The binning type in multi-bunch mode
63  BEAM, // The beam to track
64  FIELDSOLVER, // The field solver attached
65  BOUNDARYGEOMETRY, // The boundary geometry
66  DISTRIBUTION, // The particle distribution
67  TRACKBACK,
68  SIZE
69  };
70 }
71 
72 const std::string TrackRun::defaultDistribution("DISTRIBUTION");
73 
75  Action(SIZE, "RUN",
76  "The \"RUN\" sub-command tracks the defined particles through "
77  "the given lattice."),
78  itsTracker(NULL),
79  dist(NULL),
80  fs(NULL),
81  ds(NULL),
82  phaseSpaceSink_m(NULL) {
84  ("METHOD", "Name of tracking algorithm to use.",
85  {"THICK", "OPAL-T", "PARALLEL-T", "OPAL-CYCL", "CYCLOTRON-T"});
87  ("TURNS", "Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron", 1.0);
88 
90  ("MBMODE", "The working way for multi-bunch mode for OPAL-cycl.",
91  {"FORCE", "AUTO"}, "FORCE");
92 
94  ("PARAMB", "Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode ", 5.0);
95 
96  itsAttr[MB_ETA] = Attributes::makeReal("MB_ETA",
97  "The scale parameter for binning in multi-bunch mode",
98  0.01);
99 
101  ("MB_BINNING", "Type of energy binning in multi-bunch mode.",
102  {"GAMMA_BINNING", "BUNCH_BINNING"}, "GAMMA_BINNING");
103 
105  ("BEAM", "Name of beam ", "BEAM");
106  itsAttr[FIELDSOLVER] = Attributes::makeString
107  ("FIELDSOLVER", "Field solver to be used ", "FIELDSOLVER");
108  itsAttr[BOUNDARYGEOMETRY] = Attributes::makeString
109  ("BOUNDARYGEOMETRY", "Boundary geometry to be used NONE (default)", "NONE");
111  ("DISTRIBUTION", "List of particle distributions to be used ");
112  itsAttr[TRACKBACK] = Attributes::makeBool
113  ("TRACKBACK", "Track in reverse direction, default: false", false);
115 
117 }
118 
119 
120 TrackRun::TrackRun(const std::string &name, TrackRun *parent):
121  Action(name, parent),
122  itsTracker(NULL),
123  dist(NULL),
124  fs(NULL),
125  ds(NULL),
126  phaseSpaceSink_m(NULL) {
128 }
129 
130 
132 {
133  delete phaseSpaceSink_m;
134 }
135 
136 
137 TrackRun *TrackRun::clone(const std::string &name) {
138  return new TrackRun(name, this);
139 }
140 
141 
143  const int currentVersion = ((OPAL_VERSION_MAJOR * 100) + OPAL_VERSION_MINOR) * 100;
144  if (Options::version < currentVersion) {
145  unsigned int fileVersion = Options::version / 100;
146  bool newerChanges = false;
147  for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
148  if (it->first > fileVersion) {
149  newerChanges = true;
150  break;
151  }
152  }
153  if (newerChanges) {
154  Inform errorMsg("Error");
155  errorMsg << "\n******************** V E R S I O N M I S M A T C H ***********************\n" << endl;
156  for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
157  if (it->first > fileVersion) {
158  errorMsg << it->second << endl;
159  }
160  }
161  errorMsg << "\n"
162  << "* Make sure you do understand these changes and adjust your input file \n"
163  << "* accordingly. Then add\n"
164  << "* OPTION, VERSION = " << currentVersion << ";\n"
165  << "* to your input file. " << endl;
166  errorMsg << "\n****************************************************************************\n" << endl;
167  throw OpalException("TrackRun::execute", "Version mismatch");
168  }
169  }
170 
171  // Get algorithm to use.
172  std::string method = Attributes::getString(itsAttr[METHOD]);
173  if (method == "THICK") {
175  } else if(method == "PARALLEL-T" || method == "OPAL-T") {
176  setupTTracker();
177  } else if(method == "CYCLOTRON-T" || method == "OPAL-CYCL") {
179  }
180 
181  if (method == "THICK") {
182  int turns = int(std::round(Attributes::getReal(itsAttr[TURNS])));
183 
184  // Track for the all but last turn.
185  for(int turn = 1; turn < turns; ++turn) {
186  itsTracker->execute();
187  }
188 
189  // Track the last turn.
190  itsTracker->execute();
191 
192  } else {
193  itsTracker->execute();
194 
195  opal->setRestartRun(false);
196  }
197 
199 
200  delete itsTracker;
201 }
202 
203 
205 {
206  bool isFollowupTrack = opal->hasBunchAllocated();
207 
208  if(isFollowupTrack) {
209  *gmsg << "* ********************************************************************************** " << endl;
210  *gmsg << "* Selected Tracking Method == THICK, FOLLOWUP TRACK" << endl;
211  *gmsg << "* ********************************************************************************** " << endl;
213  } else {
214  *gmsg << "* ********************************************************************************** " << endl;
215  *gmsg << "* Selected Tracking Method == THICK, NEW TRACK" << endl;
216  *gmsg << "* ********************************************************************************** " << endl;
217  }
218 
220  if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
221  // Ask the dictionary if BoundaryGeometry is allocated.
222  // If it is allocated use the allocated BoundaryGeometry
223  if (!OpalData::getInstance()->hasGlobalGeometry()) {
224  const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
225  BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
227  }
228  }
229 
231 
232  if(opal->inRestartRun()) {
233  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
234  opal->getRestartStep(),
236  H5_O_WRONLY);
237  } else if (isFollowupTrack) {
238  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
239  -1,
240  opal->getInputBasename() + std::string(".h5"),
241  H5_O_WRONLY);
242  } else {
243  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
244  H5_O_WRONLY);
245  }
246 
247  double charge = setDistributionParallelT(beam);
248 
249  Track::block->bunch->setdT(Track::block->dT.front());
252 
253  if (!isFollowupTrack && !opal->inRestartRun())
255  if (Track::block->bunch->getIfBeamEmitting()) {
257  } else {
258  Track::block->bunch->setCharge(charge);
259  }
260  // set coupling constant
261  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
263 
264 
265  // statistical data are calculated (rms, eps etc.)
267 
268  initDataSink();
269 
270  if(!opal->hasBunchAllocated())
271  *gmsg << *dist << endl;
272 
273  if (Track::block->bunch->getTotalNum() > 0) {
274  double spos = /*Track::block->bunch->get_sPos() +*/ Track::block->zstart;
275  auto &zstop = Track::block->zstop;
276  auto &timeStep = Track::block->localTimeSteps;
277  auto &dT = Track::block->dT;
278 
279  unsigned int i = 0;
280  while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
281  ++ i;
282  }
283 
284  zstop.erase(zstop.begin(), zstop.begin() + i);
285  timeStep.erase(timeStep.begin(), timeStep.begin() + i);
286  dT.erase(dT.begin(), dT.begin() + i);
287 
288  Track::block->bunch->setdT(dT.front());
289  } else {
290  Track::block->zstart = 0.0;
291  }
292 
293  *gmsg << *beam << endl;
294  *gmsg << *fs << endl;
295  *gmsg << level2
296  << "Phase space dump frequency " << Options::psDumpFreq << " and "
297  << "statistics dump frequency " << Options::statDumpFreq << " w.r.t. the time step." << endl;
298 
299  itsTracker = new ThickTracker(*Track::block->use->fetchLine(),
301  false, false, Track::block->localTimeSteps,
304 }
305 
306 
309  bool isFollowupTrack = opal->hasBunchAllocated();
310 
311  if(isFollowupTrack) {
312  *gmsg << "* ********************************************************************************** " << endl;
313  *gmsg << "* Selected Tracking Method == PARALLEL-T, FOLLOWUP TRACK" << endl;
314  *gmsg << "* ********************************************************************************** " << endl;
316  } else {
317  *gmsg << "* ********************************************************************************** " << endl;
318  *gmsg << "* Selected Tracking Method == PARALLEL-T, NEW TRACK" << endl;
319  *gmsg << "* ********************************************************************************** " << endl;
320  }
321 
324 
326 
327  if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
328  // Ask the dictionary if BoundaryGeometry is allocated.
329  // If it is allocated use the allocated BoundaryGeometry
330  if (!OpalData::getInstance()->hasGlobalGeometry()) {
331  const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
332  BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
334  }
335  }
336 
338 
339  if(opal->inRestartRun()) {
340  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
341  opal->getRestartStep(),
343  H5_O_WRONLY);
344  } else if (isFollowupTrack) {
345  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
346  -1,
347  opal->getInputBasename() + std::string(".h5"),
348  H5_O_WRONLY);
349  } else {
350  phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
351  H5_O_WRONLY);
352  }
353 
354  double charge = setDistributionParallelT(beam);
355 
356  Track::block->bunch->setdT(Track::block->dT.front());
359 
360  if (!isFollowupTrack && !opal->inRestartRun())
362 
363  if (Track::block->bunch->getIfBeamEmitting()) {
366  } else {
367  Track::block->bunch->setCharge(charge);
369  }
370  // set coupling constant
371  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
373 
374  // statistical data are calculated (rms, eps etc.)
376 
377  initDataSink();
378 
379  if(!opal->hasBunchAllocated()) {
380  *gmsg << std::scientific;
381  *gmsg << *dist << endl;
382  }
383 
384  if (Track::block->bunch->getTotalNum() > 0) {
385  double spos = Track::block->zstart;
386  auto &zstop = Track::block->zstop;
387  auto it = Track::block->dT.begin();
388 
389  unsigned int i = 0;
390  while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
391  ++ i;
392  ++ it;
393  }
394 
395  Track::block->bunch->setdT(*it);
396  } else {
397  Track::block->zstart = 0.0;
398  }
399 
400  *gmsg << *beam << endl;
401  *gmsg << *fs << endl;
402 
403  // findPhasesForMaxEnergy();
404 
405  *gmsg << level2
406  << "Phase space dump frequency " << Options::psDumpFreq << " and "
407  << "statistics dump frequency " << Options::statDumpFreq << " w.r.t. the time step." << endl;
408 #ifdef P3M_TEST
409 
411 
412 #else
413  itsTracker = new ParallelTTracker(*Track::block->use->fetchLine(),
415  *ds,
417  false,
418  Attributes::getBool(itsAttr[TRACKBACK]),
422  Track::block->dT);
423 #endif
424 }
425 
429 
430  if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
431  // Ask the dictionary if BoundaryGeometry is allocated.
432  // If it is allocated use the allocated BoundaryGeometry
433  if (!OpalData::getInstance()->hasGlobalGeometry()) {
434  const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
435  BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
437  }
438  }
439 
441 
444 
445  std::vector<std::string> distr_str = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
446  if (distr_str.size() == 0) {
448  } else {
449  dist = Distribution::find(distr_str.at(0));
450  }
451 
452  // set macromass and charge for simulation particles
453  double macromass = 0.0;
454  double macrocharge = 0.0;
455 
456  // multi-bunch parameters
457  const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
458  const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
459  const std::string mbMode = Attributes::getString(itsAttr[MBMODE]);
460  const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
461  const std::string mbBinning = Attributes::getString(itsAttr[MB_BINNING]);
462 
463  if(opal->inRestartRun()) {
464  phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
465  opal->getRestartStep(),
467  H5_O_WRONLY);
468  } else if (opal->hasBunchAllocated()) {
469  phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
470  -1,
471  opal->getInputBasename() + std::string(".h5"),
472  H5_O_WRONLY);
473  } else {
474  phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
475  H5_O_WRONLY);
476  }
477 
478  if(beam->getNumberOfParticles() < 3 || beam->getCurrent() == 0.0) {
479  macrocharge = beam->getCharge() * Physics::q_e;
480  macromass = beam->getMass();
482  beam->getNumberOfParticles(),
483  beam->getCurrent(),*Track::block->use->fetchLine());
484 
485  } else {
486 
492  macrocharge = beam->getChargePerParticle();
493  macromass = beam->getMassPerParticle();
494 
495  if(!opal->hasBunchAllocated()) {
496  if(!opal->inRestartRun()) {
498  beam->getNumberOfParticles(),
499  beam->getCurrent(),
500  *Track::block->use->fetchLine());
501 
502  } else {
504  beam->getNumberOfParticles(),
505  opal->getRestartStep(),
506  specifiedNumBunch,
508  }
509  }
510  }
511  Track::block->bunch->setMass(macromass); // set the Mass per macro-particle, [GeV/c^2]
512  Track::block->bunch->setCharge(macrocharge); // set the charge per macro-particle, [C]
513 
514  *gmsg << "* Mass of simulation particle= " << macromass << " GeV/c^2" << endl;
515  *gmsg << "* Charge of simulation particle= " << macrocharge << " [C]" << endl;
516 
517  Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * 1.0e6));
519 
520  // set coupling constant
521  double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
523 
524  // statistical data are calculated (rms, eps etc.)
526 
527  initDataSink(specifiedNumBunch);
528 
529  if(!opal->hasBunchAllocated()) {
530  *gmsg << "* ********************************************************************************** " << endl;
531  *gmsg << "* Selected Tracking Method == CYCLOTRON-T, NEW TRACK" << endl;
532  *gmsg << "* ********************************************************************************** " << endl;
533  } else {
534  *gmsg << "* ********************************************************************************** " << endl;
535  *gmsg << "* Selected Tracking Method == CYCLOTRON-T, FOLLOWUP TRACK" << endl;
536  *gmsg << "* ********************************************************************************** " << endl;
537  }
538  *gmsg << "* Number of neighbour bunches = " << specifiedNumBunch << endl;
539  *gmsg << "* DT = " << Track::block->dT.front() << endl;
540  *gmsg << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << endl;
541  *gmsg << "* STEPSPERTURN = " << Track::block->stepsPerTurn << endl;
542  *gmsg << "* Phase space dump frequency = " << Options::psDumpFreq << endl;
543  *gmsg << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << endl;
544  *gmsg << "* ********************************************************************************** " << endl;
545 
546  itsTracker = new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
548  false, false, Track::block->localTimeSteps.front(),
550  specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning);
551 
552  ParallelCyclotronTracker* cyclTracker = dynamic_cast<ParallelCyclotronTracker*>(itsTracker);
553 
554  if(opal->inRestartRun()) {
555 
557  cyclTracker->setBeGa(h5pw->getMeanMomentum());
558 
559  cyclTracker->setPr(h5pw->getReferencePr());
560  cyclTracker->setPt(h5pw->getReferencePt());
561  cyclTracker->setPz(h5pw->getReferencePz());
562 
563  cyclTracker->setR(h5pw->getReferenceR());
564  cyclTracker->setTheta(h5pw->getReferenceT());
565  cyclTracker->setZ(h5pw->getReferenceZ());
566 
567  // The following is for restarts in local frame
568  cyclTracker->setPhi(h5pw->getAzimuth());
569  cyclTracker->setPsi(h5pw->getElevation());
570  cyclTracker->setPreviousH5Local(h5pw->getPreviousH5Local());
571 
572  if ( specifiedNumBunch > 1 ) {
573  cyclTracker->setLastDumpedStep(opal->getRestartStep());
574  }
575  }
576 
577  // statistical data are calculated (rms, eps etc.)
579 
580  *gmsg << *dist << endl;
581  *gmsg << *beam << endl;
582  *gmsg << *fs << endl;
583  // *gmsg << *Track::block->bunch << endl;
584 }
585 
588 
589  if (fs->getType() != std::string("NONE")) {
590  size_t numGridPoints = fs->getMX()*fs->getMY()*fs->getMT(); // total number of gridpoints
592  size_t numParticles = beam->getNumberOfParticles();
593 
594  if (!opal->inRestartRun() && numParticles < numGridPoints
595  && fs->getType() != std::string("SAAMG") // in SPIRAL/SAAMG we're meshing the whole domain -DW
596  && !Options::amr)
597  {
598  throw OpalException("TrackRun::setupFieldsolver()",
599  "The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
600  "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
601  "Please increase the number of particles or reduce the size of the mesh.\n");
602  }
603 
607 
608  }
609 
612  if (fs->hasPeriodicZ())
614  else
616 }
617 
618 
619 void TrackRun::initDataSink(const int& numBunch) {
620  if(!opal->inRestartRun()) {
621  if(!opal->hasDataSinkAllocated()) {
622  opal->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
623  } else {
624  ds = opal->getDataSink();
626  }
627  } else {
628  opal->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
629  }
630 
631  ds = opal->getDataSink();
632 }
633 
634 
636 
637  /*
638  * Distribution(s) can be set via a single distribution or a list
639  * (array) of distributions. If an array is defined the first in the
640  * list is treated as the primary distribution. All others are added to
641  * it to create the full distribution.
642  */
643  std::vector<std::string> distributionArray
645  const size_t numberOfDistributions = distributionArray.size();
646 
647  if (numberOfDistributions == 0) {
649  } else {
650  dist = Distribution::find(distributionArray.at(0));
651  dist->setNumberOfDistributions(numberOfDistributions);
652 
653  if (numberOfDistributions > 1) {
654  *gmsg << endl
655  << "---------------------------------" << endl
656  << "Found more than one distribution:" << endl << endl;
657  *gmsg << "Main Distribution" << endl
658  << "---------------------------------" << endl
659  << distributionArray.at(0) << endl << endl
660  << "Secondary Distribution(s)" << endl
661  << "---------------------------------" << endl;
662 
663  for (size_t i = 1; i < numberOfDistributions; ++ i) {
664  Distribution *distribution = Distribution::find(distributionArray.at(i));
665  distribution->setNumberOfDistributions(numberOfDistributions);
666  distrs_m.push_back(distribution);
667 
668  *gmsg << distributionArray.at(i) << endl;
669  }
670  *gmsg << endl
671  << "---------------------------------" << endl << endl;
672  }
673  }
674 
675  /*
676  * Initialize distributions.
677  */
678  size_t numberOfParticles = beam->getNumberOfParticles();
679  if (!opal->hasBunchAllocated()) {
680  if (!opal->inRestartRun()) {
681  /*
682  * Here we are not doing a restart run
683  * and we do not have a bunch already allocated.
684  */
686  distrs_m,
687  numberOfParticles);
688 
689  /*
690  * If this is an injected beam (rather than an emitted beam), we
691  * make sure it doesn't have any particles at z < 0.
692  */
693 
695  } else {
696  /*
697  * Read in beam from restart file.
698  */
699  dist->doRestartOpalT(Track::block->bunch, numberOfParticles, opal->getRestartStep(), phaseSpaceSink_m);
700  }
701  }
702 
703  // Return charge per macroparticle.
704  return beam->getChargePerParticle();
705 
706 }
@ SIZE
Definition: IndexMap.cpp:174
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
#define OPAL_VERSION_MINOR
Definition: OPALconfig.h:7
#define OPAL_VERSION_MAJOR
Definition: OPALconfig.h:6
Inform * gmsg
Definition: Main.cpp:62
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
Inform & level2(Inform &inf)
Definition: Inform.cpp:46
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Definition: Attributes.cpp:473
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
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
Definition: Attributes.cpp:478
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
std::map< unsigned int, std::string > changes
Definition: changes.cpp:7
constexpr double epsilon_0
The permittivity of vacuum in As/Vm.
Definition: Physics.h:57
constexpr double q_e
The elementary charge in As.
Definition: Physics.h:75
constexpr double pi
The value of.
Definition: Physics.h:30
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
Definition: Options.cpp:39
int version
opal version of input file
Definition: Options.cpp:97
bool amr
Enable AMR if true.
Definition: Options.cpp:99
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
Definition: Options.cpp:41
FRONT * fs
Definition: hypervolume.cpp:59
The base class for all OPAL actions.
Definition: Action.h:30
virtual Beamline * fetchLine() const =0
Return the embedded CLASSIC beam line.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:191
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
void setMass(double mass)
void setCharge(double q)
void setLocalTrackStep(long long n)
step in a TRACK command
void setMassZeroPart(double mass)
void setBeamFrequency(double v)
ParticleAttrib< ParticleOrigin > POrigin
void calcBeamParameters()
virtual void runTests()
void setChargeZeroPart(double q)
virtual void setBCAllOpen()
void setCouplingConstant(double c)
void setdT(double dt)
virtual void setBCForDCBeam()
void setPType(std::string type)
virtual void setSolver(FieldSolver *fs)
void setT(double t)
void setStepsPerTurn(int n)
DataSink * getDataSink()
Definition: OpalData.cpp:389
std::string getInputBasename()
get input file name without extension
Definition: OpalData.cpp:658
void setInOPALCyclMode()
Definition: OpalData.cpp:283
void setRestartRun(const bool &value=true)
set OPAL in restart mode
Definition: OpalData.cpp:315
std::string getRestartFileName()
get opals restart h5 format filename
Definition: OpalData.cpp:327
void bunchIsAllocated()
Definition: OpalData.cpp:368
int getRestartStep()
get the step where to restart
Definition: OpalData.cpp:323
void setDataSink(DataSink *s)
Definition: OpalData.cpp:384
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
Definition: OpalData.cpp:380
void setGlobalPhaseShift(double shift)
units: (sec)
Definition: OpalData.cpp:446
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
Definition: OpalData.cpp:364
static OpalData * getInstance()
Definition: OpalData.cpp:195
void setInOPALTMode()
Definition: OpalData.cpp:287
void setGlobalGeometry(BoundaryGeometry *bg)
Definition: OpalData.cpp:456
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition: OpalData.cpp:740
bool inRestartRun()
true if we do a restart run
Definition: OpalData.cpp:311
void setLastDumpedStep(const int para)
set last dumped step
void setPr(double x)
Method for restart.
Track using thick-lens algorithm.
Definition: ThickTracker.h:86
virtual void execute()
Apply the algorithm to the top-level beamline.
static Distribution * find(const std::string &name)
void createOpalCycl(PartBunchBase< double, 3 > *beam, size_t numberOfParticles, double current, const Beamline &bl)
void doRestartOpalT(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, H5PartWrapper *h5wrapper)
void doRestartOpalCycl(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, const int specifiedNumBunch, H5PartWrapper *h5wrapper)
void setNumberOfDistributions(unsigned int n)
Definition: Distribution.h:258
double getEmissionTimeShift() const
double getTEmission()
Definition: Beam.h:32
std::string getParticleName() const
Return Particle's name.
Definition: Beam.cpp:177
double getCurrent() const
Return the beam current in A.
Definition: Beam.cpp:165
double getChargePerParticle() const
Charge per macro particle in C.
Definition: Beam.cpp:185
static Beam * find(const std::string &name)
Find named BEAM.
Definition: Beam.cpp:145
double getCharge() const
Return the charge number in elementary charge.
Definition: Beam.cpp:169
double getFrequency() const
Return the beam frequency in MHz.
Definition: Beam.cpp:181
size_t getNumberOfParticles() const
Return the number of (macro)particles.
Definition: Beam.cpp:155
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition: Beam.cpp:191
double getMass() const
Return Particle's rest mass in GeV.
Definition: Beam.cpp:173
static BoundaryGeometry * find(const std::string &name)
virtual BoundaryGeometry * clone(const std::string &name)
Return a clone.
void changeH5Wrapper(H5PartWrapper *h5wrapper)
Definition: DataSink.cpp:145
void initCartesianFields()
double getMY() const
Return meshsize.
std::string getType()
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
double getMX() const
Return meshsize.
bool hasPeriodicZ()
double getMT() const
Return meshsize.
double getReferencePz() const
double getReferenceZ() const
double getAzimuth() const
bool getPreviousH5Local() const
double getElevation() const
double getReferencePr() const
double getReferenceT() const
double getReferenceR() const
double getMeanMomentum() const
double getReferencePt() const
BeamSequence * use
The lattice to be tracked through.
Definition: Track.h:50
int stepsPerTurn
The timsteps per revolution period. ONLY available for OPAL-cycl.
Definition: Track.h:75
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
Definition: Track.h:44
PartData reference
The reference data.
Definition: Track.h:47
double zstart
The location at which the simulation starts.
Definition: Track.h:78
std::vector< unsigned long long > localTimeSteps
Maximal number of timesteps.
Definition: Track.h:72
double deltaTau
Definition: Track.h:65
int timeIntegrator
The ID of time integrator.
Definition: Track.h:88
std::vector< double > zstop
The location at which the simulation stops.
Definition: Track.h:81
static Track * block
The block of track data.
Definition: Track.h:56
double dtScInit
Definition: Track.h:65
int truncOrder
Trunction order for map tracking.
Definition: Track.h:91
std::vector< double > dT
The initial timestep.
Definition: Track.h:62
H5PartWrapper * phaseSpaceSink_m
Definition: TrackRun.h:79
virtual void execute()
Execute the command.
Definition: TrackRun.cpp:142
void setupTTracker()
Definition: TrackRun.cpp:307
Distribution * dist
Definition: TrackRun.h:71
virtual ~TrackRun()
Definition: TrackRun.cpp:131
void initDataSink(const int &numBunch=1)
Definition: TrackRun.cpp:619
TrackRun()
Exemplar constructor.
Definition: TrackRun.cpp:74
std::vector< Distribution * > distrs_m
Definition: TrackRun.h:73
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition: TrackRun.cpp:137
static const std::string defaultDistribution
Definition: TrackRun.h:83
Tracker * itsTracker
Definition: TrackRun.h:69
double setDistributionParallelT(Beam *beam)
Definition: TrackRun.cpp:635
void setupFieldsolver()
Definition: TrackRun.cpp:586
void setupCyclotronTracker()
Definition: TrackRun.cpp:426
DataSink * ds
Definition: TrackRun.h:77
OpalData * opal
Definition: TrackRun.h:81
FieldSolver * fs
Definition: TrackRun.h:75
void setupThickTracker()
Definition: TrackRun.cpp:204
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Definition: Inform.h:42