OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
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"
51
52#include "OPALconfig.h"
53#include "changes.h"
54
55#include <cmath>
56#include <fstream>
57#include <iomanip>
58
59extern Inform *gmsg;
60
61std::shared_ptr<Tracker> TrackRun::itsTracker_m = nullptr;
62
64 itsTracker_m.reset();
65}
66
67namespace {
68 // The attributes of class TrackRun.
69 enum {
70 METHOD, // Tracking method to use.
71 TURNS, // The number of turns to be tracked.
72 MBMODE, // The working way for multi-bunch mode for OPAL-cycl: "FORCE" or "AUTO"
73 PARAMB, // The control parameter for "AUTO" mode of multi-bunch,
74 MB_ETA, // The scale parameter for binning in multi-bunch mode
75 MB_BINNING, // The binning type in multi-bunch mode
76 BEAM, // The beam to track
77 FIELDSOLVER, // The field solver attached
78 BOUNDARYGEOMETRY, // The boundary geometry
79 DISTRIBUTION, // The particle distribution
80 TRACKBACK,
81 SIZE
82 };
83}
84
85const std::string TrackRun::defaultDistribution("DISTRIBUTION");
86
88 Action(SIZE, "RUN",
89 "The \"RUN\" sub-command tracks the defined particles through "
90 "the given lattice."),
91 dist_m(nullptr),
92 fieldSolver_m(nullptr),
93 dataSink_m(nullptr),
94 phaseSpaceSink_m(nullptr),
95 isFollowupTrack_m(false),
96 method_m(RunMethod::NONE),
97 macromass_m(0.0),
98 macrocharge_m(0.0) {
100 ("METHOD", "Name of tracking algorithm to use.",
101 {"THICK", "PARALLEL-T", "CYCLOTRON-T"});
102
104 ("TURNS", "Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron.", 1.0);
105
107 ("MBMODE", "The working way for multi-bunch mode for OPAL-cycl.",
108 {"FORCE", "AUTO"}, "FORCE");
109
111 ("PARAMB", "Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode.", 5.0);
112
114 ("MB_ETA", "The scale parameter for binning in multi-bunch mode.", 0.01);
115
117 ("MB_BINNING", "Type of energy binning in multi-bunch mode.",
118 {"GAMMA_BINNING", "BUNCH_BINNING"}, "GAMMA_BINNING");
119
121 ("BEAM", "Name of beam.");
122
123 itsAttr[FIELDSOLVER] = Attributes::makeString
124 ("FIELDSOLVER", "Field solver to be used.");
125
126 itsAttr[BOUNDARYGEOMETRY] = Attributes::makeString
127 ("BOUNDARYGEOMETRY", "Boundary geometry to be used NONE (default).", "NONE");
128
130 ("DISTRIBUTION", "List of particle distributions to be used.");
131
132 itsAttr[TRACKBACK] = Attributes::makeBool
133 ("TRACKBACK", "Track in reverse direction, default: false.", false);
134
137}
138
139TrackRun::TrackRun(const std::string& name, TrackRun* parent):
140 Action(name, parent),
141 dist_m(nullptr),
142 fieldSolver_m(nullptr),
143 dataSink_m(nullptr),
144 phaseSpaceSink_m(nullptr),
145 isFollowupTrack_m(false),
146 method_m(RunMethod::NONE),
147 macromass_m(0.0),
148 macrocharge_m(0.0) {
150}
151
155
156TrackRun* TrackRun::clone(const std::string& name) {
157 return new TrackRun(name, this);
158}
159
161 const int currentVersion = ((OPAL_VERSION_MAJOR * 100) + OPAL_VERSION_MINOR) * 100;
162 if (Options::version < currentVersion) {
163 unsigned int fileVersion = Options::version / 100;
164 bool newerChanges = false;
165 for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
166 if (it->first > fileVersion) {
167 newerChanges = true;
168 break;
169 }
170 }
171 if (newerChanges) {
172 Inform errorMsg("Error");
173 errorMsg << "\n******************** V E R S I O N M I S M A T C H ***********************\n" << endl;
174 for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
175 if (it->first > fileVersion) {
176 errorMsg << it->second << endl;
177 }
178 }
179 errorMsg << "\n"
180 << "* Make sure you do understand these changes and adjust your input file \n"
181 << "* accordingly. Then add\n"
182 << "* OPTION, VERSION = " << currentVersion << ";\n"
183 << "* to your input file. " << endl;
184 errorMsg << "\n****************************************************************************\n" << endl;
185 throw OpalException("TrackRun::execute", "Version mismatch");
186 }
187 }
188
190 if (!itsAttr[DISTRIBUTION] && !isFollowupTrack_m) {
191 throw OpalException("TrackRun::execute",
192 "\"DISTRIBUTION\" must be set in \"RUN\" command.");
193 }
194 if (!itsAttr[FIELDSOLVER]) {
195 throw OpalException("TrackRun::execute",
196 "\"FIELDSOLVER\" must be set in \"RUN\" command.");
197 }
198 if (!itsAttr[BEAM]) {
199 throw OpalException("TrackRun::execute",
200 "\"BEAM\" must be set in \"RUN\" command.");
201 }
202
203 // Get algorithm to use.
204 setRunMethod();
205 switch (method_m) {
206 case RunMethod::THICK: {
208 break;
209 }
212 break;
213 }
216 break;
217 }
218 default: {
219 throw OpalException("TrackRun::execute",
220 "Unknown \"METHOD\" for the \"RUN\" command");
221 }
222 }
223
224 if (method_m == RunMethod::THICK) {
225 int turns = int(std::round(Attributes::getReal(itsAttr[TURNS])));
226
227 // Track for the all but last turn.
228 for (int turn = 1; turn < turns; ++turn) {
229 itsTracker_m->execute();
230 }
231 // Track the last turn.
232 itsTracker_m->execute();
233
234 } else {
235 itsTracker_m->execute();
236
238 }
239
241}
242
244 if (!itsAttr[METHOD]) {
245 throw OpalException("TrackRun::setRunMethod",
246 "The attribute \"METHOD\" isn't set for the \"RUN\" command");
247 }
248 std::string method = Attributes::getString(itsAttr[METHOD]);
250}
251
252std::string TrackRun::getRunMethodName() const {
253 return std::string(Util::enumToString(method_m, runMethodMap, "NONE"));
254}
255
257 if (isFollowupTrack_m) {
259 }
260
262
264
266
268
270
271 *gmsg << *this << endl;
272
273 Track::block->bunch->setdT(Track::block->dT.front());
276
279 }
280
281 if (Track::block->bunch->getIfBeamEmitting()) {
283 } else {
285 }
286
287 // set coupling constant
288 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
290
291 // statistical data are calculated (rms, eps etc.)
293
294 initDataSink();
295
296 if (!isFollowupTrack_m) {
297 *gmsg << *dist_m << endl;
298 }
299
300 if (Track::block->bunch->getTotalNum() > 0) {
301 double spos = /*Track::block->bunch->get_sPos() +*/ Track::block->zstart;
302 auto &zstop = Track::block->zstop;
303 auto &timeStep = Track::block->localTimeSteps;
304 auto &dT = Track::block->dT;
305
306 unsigned int i = 0;
307 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
308 ++ i;
309 }
310
311 zstop.erase(zstop.begin(), zstop.begin() + i);
312 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
313 dT.erase(dT.begin(), dT.begin() + i);
314
315 Track::block->bunch->setdT(dT.front());
316 } else {
317 Track::block->zstart = 0.0;
318 }
319
320 *gmsg << *beam << endl;
321 *gmsg << *fieldSolver_m << endl;
322
323 itsTracker_m.reset(new ThickTracker(*Track::block->use->fetchLine(),
325 false, false, Track::block->localTimeSteps,
328}
329
330
333
334 if (isFollowupTrack_m) {
336 }
337
341
343
345
347
350
351 *gmsg << *this << endl;
352
353 Track::block->bunch->setdT(Track::block->dT.front());
356
359 }
360
361 if (Track::block->bunch->getIfBeamEmitting()) {
364 } else {
367 }
368 // set coupling constant
369 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
371
372 // statistical data are calculated (rms, eps etc.)
374
375 initDataSink();
376
377 if (!isFollowupTrack_m) {
378 *gmsg << std::scientific;
379 *gmsg << *dist_m << endl;
380 }
381
382 if (Track::block->bunch->getTotalNum() > 0) {
383 double spos = Track::block->zstart;
384 auto& zstop = Track::block->zstop;
385 auto it = Track::block->dT.begin();
386
387 unsigned int i = 0;
388 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
389 ++ i;
390 ++ it;
391 }
392
393 Track::block->bunch->setdT(*it);
394 } else {
395 Track::block->zstart = 0.0;
396 }
397
398 *gmsg << *beam << endl;
399 *gmsg << *fieldSolver_m << endl;
400
401 // findPhasesForMaxEnergy();
402
403 itsTracker_m.reset(new ParallelTTracker(*Track::block->use->fetchLine(),
405 *dataSink_m,
407 false,
408 Attributes::getBool(itsAttr[TRACKBACK]),
412 Track::block->dT));
413}
414
417
419
421
423
426
427 std::vector<std::string> distr_str = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
428 if (distr_str.size() == 0) {
430 } else {
431 dist_m = Distribution::find(distr_str.at(0));
432 }
433
434 // multi-bunch parameters
435 const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
436 const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
437 const std::string mbMode = Attributes::getString(itsAttr[MBMODE]);
438 const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
439 const std::string mbBinning = Attributes::getString(itsAttr[MB_BINNING]);
440
442
443 if (beam->getNumberOfParticles() < 3 || beam->getCurrent() == 0.0) {
445 macromass_m = beam->getMass();
447 beam->getNumberOfParticles(),
448 beam->getCurrent(),
450
451 } else {
458
459 if (!isFollowupTrack_m) {
460 if (!opalData_m->inRestartRun()) {
462 beam->getNumberOfParticles(),
463 beam->getCurrent(),
465
466 } else {
468 beam->getNumberOfParticles(),
470 specifiedNumBunch,
472 }
473 }
474 }
475 Track::block->bunch->setMass(macromass_m); // set the Mass per macro-particle, [GeV/c^2]
476 Track::block->bunch->setCharge(macrocharge_m); // set the charge per macro-particle, [C]
477
478 Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * Units::MHz2Hz));
480
481 // set coupling constant
482 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
484
485 // statistical data are calculated (rms, eps etc.)
487
488 initDataSink(specifiedNumBunch);
489
490 itsTracker_m.reset(new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
492 false, false, Track::block->localTimeSteps.front(),
494 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
495
496 ParallelCyclotronTracker* cyclTracker = dynamic_cast<ParallelCyclotronTracker*>(itsTracker_m.get());
497
498 if (opalData_m->inRestartRun()) {
500 cyclTracker->setBeGa(h5pw->getMeanMomentum());
501
502 cyclTracker->setPr(h5pw->getReferencePr());
503 cyclTracker->setPt(h5pw->getReferencePt());
504 cyclTracker->setPz(h5pw->getReferencePz());
505
506 cyclTracker->setR(h5pw->getReferenceR());
507 cyclTracker->setTheta(h5pw->getReferenceT());
508 cyclTracker->setZ(h5pw->getReferenceZ());
509
510 // The following is for restarts in local frame
511 cyclTracker->setPhi(h5pw->getAzimuth());
512 cyclTracker->setPsi(h5pw->getElevation());
513 cyclTracker->setPreviousH5Local(h5pw->getPreviousH5Local());
514
515 if ( specifiedNumBunch > 1 ) {
517 }
518 }
519
520 // statistical data are calculated (rms, eps etc.)
522
523 *gmsg << *this << endl;
524 *gmsg << *dist_m << endl;
525 *gmsg << *beam << endl;
526 *gmsg << *fieldSolver_m << endl;
527}
528
531
533 size_t numGridPoints = fieldSolver_m->getMX()*fieldSolver_m->getMY()*fieldSolver_m->getMT(); // total number of gridpoints
535 size_t numParticles = beam->getNumberOfParticles();
536
537 if (!opalData_m->inRestartRun() && numParticles < numGridPoints
538 && fieldSolver_m->getFieldSolverType() != FieldSolverType::SAAMG // in SPIRAL/SAAMG we're meshing the whole domain -DW
539 && fieldSolver_m->getFieldSolverType() != FieldSolverType::P3M //In P3M with one-one mapping grid points can be less than particles
540 && !Options::amr)
541 {
542 throw OpalException("TrackRun::setupFieldsolver()",
543 "The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
544 "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
545 "Please increase the number of particles or reduce the size of the mesh.\n");
546 }
547
551 }
552
557 } else {
559 }
560}
561
563 const std::string h5FileName = opalData_m->getInputBasename() + std::string(".h5");
565 if (opalData_m->inRestartRun()) {
566 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
569 H5_O_WRONLY);
570 } else if (isFollowupTrack_m) {
571 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
572 -1,
573 h5FileName,
574 H5_O_WRONLY);
575 } else if (Options::enableHDF5) {
576 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
577 H5_O_WRONLY);
578 }
579 } else {
580 if (opalData_m->inRestartRun()) {
581 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
584 H5_O_WRONLY);
585 } else if (isFollowupTrack_m) {
586 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
587 -1,
588 h5FileName,
589 H5_O_WRONLY);
590 } else if (Options::enableHDF5) {
591 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
592 H5_O_WRONLY);
593 }
594 }
595}
596
597
598void TrackRun::initDataSink(const int& numBunch) {
599 if (!opalData_m->inRestartRun()) {
601 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
602 } else {
605 }
606 } else {
607 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
608 }
610}
611
613 if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
614 // Ask the dictionary if BoundaryGeometry is allocated.
615 // If it is allocated use the allocated BoundaryGeometry
617 const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
618 BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
620 }
621 }
622}
623
624
626 /*
627 * Distribution(s) can be set via a single distribution or a list
628 * (array) of distributions. If an array is defined the first in the
629 * list is treated as the primary distribution. All others are added to
630 * it to create the full distribution.
631 */
632 std::vector<std::string> distributionArray
633 = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
634 const size_t numberOfDistributions = distributionArray.size();
635
636 if (numberOfDistributions == 0) {
638 } else {
639 dist_m = Distribution::find(distributionArray.at(0));
640 dist_m->setNumberOfDistributions(numberOfDistributions);
641
642 if (numberOfDistributions > 1) {
643 *gmsg << endl
644 << "---------------------------------" << endl
645 << "Found more than one distribution:" << endl << endl;
646 *gmsg << "Main Distribution" << endl
647 << "---------------------------------" << endl
648 << distributionArray.at(0) << endl << endl
649 << "Secondary Distribution(s)" << endl
650 << "---------------------------------" << endl;
651
652 for (size_t i = 1; i < numberOfDistributions; ++ i) {
653 Distribution *distribution = Distribution::find(distributionArray.at(i));
654 distribution->setNumberOfDistributions(numberOfDistributions);
655 distrs_m.push_back(distribution);
656
657 *gmsg << distributionArray.at(i) << endl;
658 }
659 *gmsg << endl
660 << "---------------------------------" << endl << endl;
661 }
662 }
663
664 /*
665 * Initialize distributions.
666 */
667 size_t numberOfParticles = beam->getNumberOfParticles();
668 if (!isFollowupTrack_m) {
669 if (!opalData_m->inRestartRun()) {
670 /*
671 * Here we are not doing a restart run
672 * and we do not have a bunch already allocated.
673 */
675 distrs_m,
676 numberOfParticles);
677
678 /*
679 * If this is an injected beam (rather than an emitted beam), we
680 * make sure it doesn't have any particles at z < 0.
681 */
682
684 } else {
685 /*
686 * Read in beam from restart file.
687 */
689 }
690 }
691
692 // Return charge per macroparticle.
693 return beam->getChargePerParticle();
694}
695
697 os << endl;
698 os << "* ************* T R A C K R U N *************************************************** " << endl;
699 if (!isFollowupTrack_m) {
700 os << "* Selected Tracking Method == " << getRunMethodName() << ", NEW TRACK" << '\n'
701 << "* ********************************************************************************** " << '\n';
702 } else {
703 os << "* Selected Tracking Method == " << getRunMethodName() << ", FOLLOWUP TRACK" << '\n'
704 << "* ********************************************************************************** " << '\n';
705 }
706 os << "* Phase space dump frequency = " << Options::psDumpFreq << '\n'
707 << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << '\n'
708 << "* DT = " << Track::block->dT.front() << " [s]\n"
709 << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << '\n'
710 << "* Mass of simulation particle = " << macromass_m << " [GeV/c^2]" << '\n'
711 << "* Charge of simulation particle = " << macrocharge_m << " [C]" << '\n';
713 os << "* Number of neighbour bunches = " << int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS])))) << '\n'
714 << "* STEPSPERTURN = " << Track::block->stepsPerTurn << '\n';
715 }
716 os << "* ********************************************************************************** ";
717 return os;
718}
719
720std::shared_ptr<Tracker> TrackRun::getTracker() {
721 return itsTracker_m;
722}
Inform * gmsg
Definition Main.cpp:70
Inform * gmsg
Definition Main.cpp:70
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
@ SIZE
Definition IndexMap.cpp:178
Inform & endl(Inform &inf)
Definition Inform.cpp:42
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
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:51
constexpr double q_e
The elementary charge in As.
Definition Physics.h:69
constexpr double pi
The value of.
Definition Physics.h:30
constexpr double MHz2Hz
Definition Units.h:113
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
Definition Options.cpp:37
int version
opal version of input file
Definition Options.cpp:95
bool enableHDF5
If true HDF5 files are written.
Definition Options.cpp:79
bool amr
Enable AMR if true.
Definition Options.cpp:97
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
Definition Options.cpp:39
constexpr Enum stringToEnum(std::string_view str, const std::array< std::pair< Enum, std::string_view >, N > &map, Enum defaultEnum) noexcept
Definition Util.h:261
constexpr std::string_view enumToString(Enum e, const std::array< std::pair< Enum, std::string_view >, N > &map, std::string_view defaultStr) noexcept
Definition Util.h:271
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 setPType(const std::string &type)
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 setChargeZeroPart(double q)
virtual void setBCAllOpen()
void setCouplingConstant(double c)
void setdT(double dt)
virtual void setBCForDCBeam()
virtual void setSolver(FieldSolver *fs)
void setT(double t)
void setStepsPerTurn(int n)
DataSink * getDataSink()
Definition OpalData.cpp:390
bool hasGlobalGeometry()
Definition OpalData.cpp:465
std::string getInputBasename()
get input file name without extension
Definition OpalData.cpp:674
void setInOPALCyclMode()
Definition OpalData.cpp:284
bool isInOPALCyclMode()
Definition OpalData.cpp:272
void setRestartRun(const bool &value=true)
set OPAL in restart mode
Definition OpalData.cpp:316
std::string getRestartFileName()
get opals restart h5 format filename
Definition OpalData.cpp:328
void bunchIsAllocated()
Definition OpalData.cpp:369
int getRestartStep()
get the step where to restart
Definition OpalData.cpp:324
void setDataSink(DataSink *s)
Definition OpalData.cpp:385
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
Definition OpalData.cpp:381
void setGlobalPhaseShift(double shift)
units: (sec)
Definition OpalData.cpp:447
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
Definition OpalData.cpp:365
static OpalData * getInstance()
Definition OpalData.cpp:196
void setInOPALTMode()
Definition OpalData.cpp:288
void setGlobalGeometry(BoundaryGeometry *bg)
Definition OpalData.cpp:457
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition OpalData.cpp:756
bool inRestartRun()
true if we do a restart run
Definition OpalData.cpp:312
void setLastDumpedStep(const int para)
set last dumped step
void setPr(double x)
Method for restart.
Track using thick-lens algorithm.
static Distribution * find(const std::string &name)
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)
double getEmissionTimeShift() const
double getTEmission()
Definition Beam.h:31
std::string getParticleName() const
Return Particle's name.
Definition Beam.cpp:200
double getCurrent() const
Return the beam current in A.
Definition Beam.cpp:188
double getChargePerParticle() const
Charge per macro particle in C.
Definition Beam.cpp:208
static Beam * find(const std::string &name)
Find named BEAM.
Definition Beam.cpp:163
double getCharge() const
Return the charge number in elementary charge.
Definition Beam.cpp:192
double getFrequency() const
Return the beam frequency in MHz.
Definition Beam.cpp:204
size_t getNumberOfParticles() const
Return the number of (macro)particles.
Definition Beam.cpp:173
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition Beam.cpp:214
double getMass() const
Return Particle's rest mass in GeV.
Definition Beam.cpp:196
static BoundaryGeometry * find(const std::string &name)
virtual BoundaryGeometry * clone(const std::string &name)
Return a clone.
void changeH5Wrapper(H5PartWrapper *h5wrapper)
Definition DataSink.cpp:152
void initCartesianFields()
double getMY() const
Return meshsize.
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
double getMX() const
Return meshsize.
FieldSolverType getFieldSolverType() const
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:53
int stepsPerTurn
The timsteps per revolution period. ONLY available for OPAL-cycl.
Definition Track.h:78
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
Definition Track.h:47
PartData reference
The reference data.
Definition Track.h:50
double zstart
The location at which the simulation starts.
Definition Track.h:81
std::vector< unsigned long long > localTimeSteps
Maximal number of timesteps.
Definition Track.h:75
double deltaTau
Definition Track.h:68
std::vector< double > zstop
The location at which the simulation stops.
Definition Track.h:84
static Track * block
The block of track data.
Definition Track.h:59
Steppers::TimeIntegrator timeIntegrator
The ID of time integrator.
Definition Track.h:87
double dtScInit
Definition Track.h:68
int truncOrder
Trunction order for map tracking.
Definition Track.h:90
std::vector< double > dT
The initial timestep.
Definition Track.h:65
RunMethod method_m
Definition TrackRun.h:125
static void releaseTracker()
Definition TrackRun.cpp:63
DataSink * dataSink_m
Definition TrackRun.h:115
H5PartWrapper * phaseSpaceSink_m
Definition TrackRun.h:117
virtual void execute()
Execute the command.
Definition TrackRun.cpp:160
void setupTTracker()
Definition TrackRun.cpp:331
std::vector< Distribution * > distrs_m
Definition TrackRun.h:111
bool isFollowupTrack_m
Definition TrackRun.h:121
void setRunMethod()
Definition TrackRun.cpp:243
virtual ~TrackRun()
Definition TrackRun.cpp:152
static std::shared_ptr< Tracker > itsTracker_m
Definition TrackRun.h:108
FieldSolver * fieldSolver_m
Definition TrackRun.h:113
void initDataSink(const int &numBunch=1)
Definition TrackRun.cpp:598
TrackRun()
Exemplar constructor.
Definition TrackRun.cpp:87
double macromass_m
Definition TrackRun.h:128
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition TrackRun.cpp:156
static const std::string defaultDistribution
Definition TrackRun.h:123
double setDistributionParallelT(Beam *beam)
Definition TrackRun.cpp:625
std::string getRunMethodName() const
Definition TrackRun.cpp:252
void initPhaseSpaceSink()
Definition TrackRun.cpp:562
void setBoundaryGeometry()
Definition TrackRun.cpp:612
Distribution * dist_m
Definition TrackRun.h:110
void setupFieldsolver()
Definition TrackRun.cpp:529
void setupCyclotronTracker()
Definition TrackRun.cpp:415
double macrocharge_m
Definition TrackRun.h:129
static constexpr std::array< std::pair< RunMethod, std::string_view >, 5 > runMethodMap
Definition TrackRun.h:75
OpalData * opalData_m
Definition TrackRun.h:119
Inform & print(Inform &os) const
Definition TrackRun.cpp:696
void setupThickTracker()
Definition TrackRun.cpp:256
static std::shared_ptr< Tracker > getTracker()
Definition TrackRun.cpp:720
The base class for all OPAL exceptions.