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
63namespace {
64 // The attributes of class TrackRun.
65 enum {
66 METHOD, // Tracking method to use.
67 TURNS, // The number of turns to be tracked.
68 MBMODE, // The working way for multi-bunch mode for OPAL-cycl: "FORCE" or "AUTO"
69 PARAMB, // The control parameter for "AUTO" mode of multi-bunch,
70 MB_ETA, // The scale parameter for binning in multi-bunch mode
71 MB_BINNING, // The binning type in multi-bunch mode
72 BEAM, // The beam to track
73 FIELDSOLVER, // The field solver attached
74 BOUNDARYGEOMETRY, // The boundary geometry
75 DISTRIBUTION, // The particle distribution
76 TRACKBACK,
77 SIZE
78 };
79}
80
81const std::string TrackRun::defaultDistribution("DISTRIBUTION");
82
84 Action(SIZE, "RUN",
85 "The \"RUN\" sub-command tracks the defined particles through "
86 "the given lattice."),
87 dist_m(nullptr),
88 fieldSolver_m(nullptr),
89 dataSink_m(nullptr),
90 phaseSpaceSink_m(nullptr),
91 isFollowupTrack_m(false),
92 method_m(RunMethod::NONE),
93 macromass_m(0.0),
94 macrocharge_m(0.0) {
96 ("METHOD", "Name of tracking algorithm to use.",
97 {"THICK", "PARALLEL-T", "CYCLOTRON-T"});
98
100 ("TURNS", "Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron.", 1.0);
101
103 ("MBMODE", "The working way for multi-bunch mode for OPAL-cycl.",
104 {"FORCE", "AUTO"}, "FORCE");
105
107 ("PARAMB", "Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode.", 5.0);
108
110 ("MB_ETA", "The scale parameter for binning in multi-bunch mode.", 0.01);
111
113 ("MB_BINNING", "Type of energy binning in multi-bunch mode.",
114 {"GAMMA_BINNING", "BUNCH_BINNING"}, "GAMMA_BINNING");
115
117 ("BEAM", "Name of beam.");
118
119 itsAttr[FIELDSOLVER] = Attributes::makeString
120 ("FIELDSOLVER", "Field solver to be used.");
121
122 itsAttr[BOUNDARYGEOMETRY] = Attributes::makeString
123 ("BOUNDARYGEOMETRY", "Boundary geometry to be used NONE (default).", "NONE");
124
126 ("DISTRIBUTION", "List of particle distributions to be used.");
127
128 itsAttr[TRACKBACK] = Attributes::makeBool
129 ("TRACKBACK", "Track in reverse direction, default: false.", false);
130
133}
134
135TrackRun::TrackRun(const std::string& name, TrackRun* parent):
136 Action(name, parent),
137 dist_m(nullptr),
138 fieldSolver_m(nullptr),
139 dataSink_m(nullptr),
140 phaseSpaceSink_m(nullptr),
141 isFollowupTrack_m(false),
142 method_m(RunMethod::NONE),
143 macromass_m(0.0),
144 macrocharge_m(0.0) {
146}
147
151
152TrackRun* TrackRun::clone(const std::string& name) {
153 return new TrackRun(name, this);
154}
155
157 const int currentVersion = ((OPAL_VERSION_MAJOR * 100) + OPAL_VERSION_MINOR) * 100;
158 if (Options::version < currentVersion) {
159 unsigned int fileVersion = Options::version / 100;
160 bool newerChanges = false;
161 for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
162 if (it->first > fileVersion) {
163 newerChanges = true;
164 break;
165 }
166 }
167 if (newerChanges) {
168 Inform errorMsg("Error");
169 errorMsg << "\n******************** V E R S I O N M I S M A T C H ***********************\n" << endl;
170 for (auto it = Versions::changes.begin(); it != Versions::changes.end(); ++ it) {
171 if (it->first > fileVersion) {
172 errorMsg << it->second << endl;
173 }
174 }
175 errorMsg << "\n"
176 << "* Make sure you do understand these changes and adjust your input file \n"
177 << "* accordingly. Then add\n"
178 << "* OPTION, VERSION = " << currentVersion << ";\n"
179 << "* to your input file. " << endl;
180 errorMsg << "\n****************************************************************************\n" << endl;
181 throw OpalException("TrackRun::execute", "Version mismatch");
182 }
183 }
184
186 if (!itsAttr[DISTRIBUTION] && !isFollowupTrack_m) {
187 throw OpalException("TrackRun::execute",
188 "\"DISTRIBUTION\" must be set in \"RUN\" command.");
189 }
190 if (!itsAttr[FIELDSOLVER]) {
191 throw OpalException("TrackRun::execute",
192 "\"FIELDSOLVER\" must be set in \"RUN\" command.");
193 }
194 if (!itsAttr[BEAM]) {
195 throw OpalException("TrackRun::execute",
196 "\"BEAM\" must be set in \"RUN\" command.");
197 }
198
199 // Get algorithm to use.
200 setRunMethod();
201 switch (method_m) {
202 case RunMethod::THICK: {
204 break;
205 }
208 break;
209 }
212 break;
213 }
214 default: {
215 throw OpalException("TrackRun::execute",
216 "Unknown \"METHOD\" for the \"RUN\" command");
217 }
218 }
219
220 if (method_m == RunMethod::THICK) {
221 int turns = int(std::round(Attributes::getReal(itsAttr[TURNS])));
222
223 // Track for the all but last turn.
224 for (int turn = 1; turn < turns; ++turn) {
225 itsTracker_m->execute();
226 }
227 // Track the last turn.
228 itsTracker_m->execute();
229
230 } else {
231 itsTracker_m->execute();
232
234 }
235
237}
238
240 if (!itsAttr[METHOD]) {
241 throw OpalException("TrackRun::setRunMethod",
242 "The attribute \"METHOD\" isn't set for the \"RUN\" command");
243 }
244 std::string_view method = Attributes::getString(itsAttr[METHOD]);
246}
247
248std::string TrackRun::getRunMethodName() const {
249 return std::string(Util::enumToString(method_m, runMethodMap, "NONE"));
250}
251
253 if (isFollowupTrack_m) {
255 }
256
258
260
262
264
266
267 *gmsg << *this << endl;
268
269 Track::block->bunch->setdT(Track::block->dT.front());
272
275 }
276
277 if (Track::block->bunch->getIfBeamEmitting()) {
279 } else {
281 }
282
283 // set coupling constant
284 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
286
287 // statistical data are calculated (rms, eps etc.)
289
290 initDataSink();
291
292 if (!isFollowupTrack_m) {
293 *gmsg << *dist_m << endl;
294 }
295
296 if (Track::block->bunch->getTotalNum() > 0) {
297 double spos = /*Track::block->bunch->get_sPos() +*/ Track::block->zstart;
298 auto &zstop = Track::block->zstop;
299 auto &timeStep = Track::block->localTimeSteps;
300 auto &dT = Track::block->dT;
301
302 unsigned int i = 0;
303 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
304 ++ i;
305 }
306
307 zstop.erase(zstop.begin(), zstop.begin() + i);
308 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
309 dT.erase(dT.begin(), dT.begin() + i);
310
311 Track::block->bunch->setdT(dT.front());
312 } else {
313 Track::block->zstart = 0.0;
314 }
315
316 *gmsg << *beam << endl;
317 *gmsg << *fieldSolver_m << endl;
318
319 itsTracker_m.reset(new ThickTracker(*Track::block->use->fetchLine(),
321 false, false, Track::block->localTimeSteps,
324}
325
326
329
330 if (isFollowupTrack_m) {
332 }
333
337
339
341
343
346
347 *gmsg << *this << endl;
348
349 Track::block->bunch->setdT(Track::block->dT.front());
352
355 }
356
357 if (Track::block->bunch->getIfBeamEmitting()) {
360 } else {
363 }
364 // set coupling constant
365 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
367
368 // statistical data are calculated (rms, eps etc.)
370
371 initDataSink();
372
373 if (!isFollowupTrack_m) {
374 *gmsg << std::scientific;
375 *gmsg << *dist_m << endl;
376 }
377
378 if (Track::block->bunch->getTotalNum() > 0) {
379 double spos = Track::block->zstart;
380 auto& zstop = Track::block->zstop;
381 auto it = Track::block->dT.begin();
382
383 unsigned int i = 0;
384 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
385 ++ i;
386 ++ it;
387 }
388
389 Track::block->bunch->setdT(*it);
390 } else {
391 Track::block->zstart = 0.0;
392 }
393
394 *gmsg << *beam << endl;
395 *gmsg << *fieldSolver_m << endl;
396
397 // findPhasesForMaxEnergy();
398
399 itsTracker_m.reset(new ParallelTTracker(*Track::block->use->fetchLine(),
401 *dataSink_m,
403 false,
404 Attributes::getBool(itsAttr[TRACKBACK]),
408 Track::block->dT));
409}
410
413
415
417
419
422
423 std::vector<std::string> distr_str = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
424 if (distr_str.size() == 0) {
426 } else {
427 dist_m = Distribution::find(distr_str.at(0));
428 }
429
430 // multi-bunch parameters
431 const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
432 const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
433 const std::string mbMode = Attributes::getString(itsAttr[MBMODE]);
434 const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
435 const std::string mbBinning = Attributes::getString(itsAttr[MB_BINNING]);
436
438
439 if (beam->getNumberOfParticles() < 3 || beam->getCurrent() == 0.0) {
441 macromass_m = beam->getMass();
443 beam->getNumberOfParticles(),
444 beam->getCurrent(),
446
447 } else {
454
455 if (!isFollowupTrack_m) {
456 if (!opalData_m->inRestartRun()) {
458 beam->getNumberOfParticles(),
459 beam->getCurrent(),
461
462 } else {
464 beam->getNumberOfParticles(),
466 specifiedNumBunch,
468 }
469 }
470 }
471 Track::block->bunch->setMass(macromass_m); // set the Mass per macro-particle, [GeV/c^2]
472 Track::block->bunch->setCharge(macrocharge_m); // set the charge per macro-particle, [C]
473
474 Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * Units::MHz2Hz));
476
477 // set coupling constant
478 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
480
481 // statistical data are calculated (rms, eps etc.)
483
484 initDataSink(specifiedNumBunch);
485
486 itsTracker_m.reset(new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
488 false, false, Track::block->localTimeSteps.front(),
490 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
491
492 ParallelCyclotronTracker* cyclTracker = dynamic_cast<ParallelCyclotronTracker*>(itsTracker_m.get());
493
494 if (opalData_m->inRestartRun()) {
496 cyclTracker->setBeGa(h5pw->getMeanMomentum());
497
498 cyclTracker->setPr(h5pw->getReferencePr());
499 cyclTracker->setPt(h5pw->getReferencePt());
500 cyclTracker->setPz(h5pw->getReferencePz());
501
502 cyclTracker->setR(h5pw->getReferenceR());
503 cyclTracker->setTheta(h5pw->getReferenceT());
504 cyclTracker->setZ(h5pw->getReferenceZ());
505
506 // The following is for restarts in local frame
507 cyclTracker->setPhi(h5pw->getAzimuth());
508 cyclTracker->setPsi(h5pw->getElevation());
509 cyclTracker->setPreviousH5Local(h5pw->getPreviousH5Local());
510
511 if ( specifiedNumBunch > 1 ) {
513 }
514 }
515
516 // statistical data are calculated (rms, eps etc.)
518
519 *gmsg << *this << endl;
520 *gmsg << *dist_m << endl;
521 *gmsg << *beam << endl;
522 *gmsg << *fieldSolver_m << endl;
523}
524
527
529 size_t numGridPoints = fieldSolver_m->getMX()*fieldSolver_m->getMY()*fieldSolver_m->getMT(); // total number of gridpoints
531 size_t numParticles = beam->getNumberOfParticles();
532
533 if (!opalData_m->inRestartRun() && numParticles < numGridPoints
534 && fieldSolver_m->getFieldSolverType() != FieldSolverType::SAAMG // in SPIRAL/SAAMG we're meshing the whole domain -DW
535 && fieldSolver_m->getFieldSolverType() != FieldSolverType::P3M //In P3M with one-one mapping grid points can be less than particles
536 && !Options::amr)
537 {
538 throw OpalException("TrackRun::setupFieldsolver()",
539 "The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
540 "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
541 "Please increase the number of particles or reduce the size of the mesh.\n");
542 }
543
547 }
548
553 } else {
555 }
556}
557
559 const std::string h5FileName = opalData_m->getInputBasename() + std::string(".h5");
561 if (opalData_m->inRestartRun()) {
562 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
565 H5_O_WRONLY);
566 } else if (isFollowupTrack_m) {
567 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
568 -1,
569 h5FileName,
570 H5_O_WRONLY);
571 } else if (Options::enableHDF5) {
572 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
573 H5_O_WRONLY);
574 }
575 } else {
576 if (opalData_m->inRestartRun()) {
577 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
580 H5_O_WRONLY);
581 } else if (isFollowupTrack_m) {
582 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
583 -1,
584 h5FileName,
585 H5_O_WRONLY);
586 } else if (Options::enableHDF5) {
587 phaseSpaceSink_m = new H5PartWrapperForPT(h5FileName,
588 H5_O_WRONLY);
589 }
590 }
591}
592
593
594void TrackRun::initDataSink(const int& numBunch) {
595 if (!opalData_m->inRestartRun()) {
597 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
598 } else {
601 }
602 } else {
603 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
604 }
606}
607
609 if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
610 // Ask the dictionary if BoundaryGeometry is allocated.
611 // If it is allocated use the allocated BoundaryGeometry
613 const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
614 BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
616 }
617 }
618}
619
620
622 /*
623 * Distribution(s) can be set via a single distribution or a list
624 * (array) of distributions. If an array is defined the first in the
625 * list is treated as the primary distribution. All others are added to
626 * it to create the full distribution.
627 */
628 std::vector<std::string> distributionArray
629 = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
630 const size_t numberOfDistributions = distributionArray.size();
631
632 if (numberOfDistributions == 0) {
634 } else {
635 dist_m = Distribution::find(distributionArray.at(0));
636 dist_m->setNumberOfDistributions(numberOfDistributions);
637
638 if (numberOfDistributions > 1) {
639 *gmsg << endl
640 << "---------------------------------" << endl
641 << "Found more than one distribution:" << endl << endl;
642 *gmsg << "Main Distribution" << endl
643 << "---------------------------------" << endl
644 << distributionArray.at(0) << endl << endl
645 << "Secondary Distribution(s)" << endl
646 << "---------------------------------" << endl;
647
648 for (size_t i = 1; i < numberOfDistributions; ++ i) {
649 Distribution *distribution = Distribution::find(distributionArray.at(i));
650 distribution->setNumberOfDistributions(numberOfDistributions);
651 distrs_m.push_back(distribution);
652
653 *gmsg << distributionArray.at(i) << endl;
654 }
655 *gmsg << endl
656 << "---------------------------------" << endl << endl;
657 }
658 }
659
660 /*
661 * Initialize distributions.
662 */
663 size_t numberOfParticles = beam->getNumberOfParticles();
664 if (!isFollowupTrack_m) {
665 if (!opalData_m->inRestartRun()) {
666 /*
667 * Here we are not doing a restart run
668 * and we do not have a bunch already allocated.
669 */
671 distrs_m,
672 numberOfParticles);
673
674 /*
675 * If this is an injected beam (rather than an emitted beam), we
676 * make sure it doesn't have any particles at z < 0.
677 */
678
680 } else {
681 /*
682 * Read in beam from restart file.
683 */
685 }
686 }
687
688 // Return charge per macroparticle.
689 return beam->getChargePerParticle();
690}
691
693 os << endl;
694 os << "* ************* T R A C K R U N *************************************************** " << endl;
695 if (!isFollowupTrack_m) {
696 os << "* Selected Tracking Method == " << getRunMethodName() << ", NEW TRACK" << '\n'
697 << "* ********************************************************************************** " << '\n';
698 } else {
699 os << "* Selected Tracking Method == " << getRunMethodName() << ", FOLLOWUP TRACK" << '\n'
700 << "* ********************************************************************************** " << '\n';
701 }
702 os << "* Phase space dump frequency = " << Options::psDumpFreq << '\n'
703 << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << '\n'
704 << "* DT = " << Track::block->dT.front() << " [s]\n"
705 << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << '\n'
706 << "* Mass of simulation particle = " << macromass_m << " [GeV/c^2]" << '\n'
707 << "* Charge of simulation particle = " << macrocharge_m << " [C]" << '\n';
709 os << "* Number of neighbour bunches = " << int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS])))) << '\n'
710 << "* STEPSPERTURN = " << Track::block->stepsPerTurn << '\n';
711 }
712 os << "* ********************************************************************************** ";
713 return os;
714}
715
716std::shared_ptr<Tracker> TrackRun::getTracker() {
717 return itsTracker_m;
718}
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
@ SIZE
Definition IndexMap.cpp:174
Inform * gmsg
Definition Main.cpp:70
Inform * gmsg
Definition Main.cpp:70
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:237
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:247
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:143
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:116
DataSink * dataSink_m
Definition TrackRun.h:106
H5PartWrapper * phaseSpaceSink_m
Definition TrackRun.h:108
virtual void execute()
Execute the command.
Definition TrackRun.cpp:156
void setupTTracker()
Definition TrackRun.cpp:327
std::vector< Distribution * > distrs_m
Definition TrackRun.h:102
bool isFollowupTrack_m
Definition TrackRun.h:112
void setRunMethod()
Definition TrackRun.cpp:239
virtual ~TrackRun()
Definition TrackRun.cpp:148
static std::shared_ptr< Tracker > itsTracker_m
Definition TrackRun.h:99
FieldSolver * fieldSolver_m
Definition TrackRun.h:104
void initDataSink(const int &numBunch=1)
Definition TrackRun.cpp:594
TrackRun()
Exemplar constructor.
Definition TrackRun.cpp:83
double macromass_m
Definition TrackRun.h:119
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition TrackRun.cpp:152
static const std::string defaultDistribution
Definition TrackRun.h:114
double setDistributionParallelT(Beam *beam)
Definition TrackRun.cpp:621
std::string getRunMethodName() const
Definition TrackRun.cpp:248
void initPhaseSpaceSink()
Definition TrackRun.cpp:558
void setBoundaryGeometry()
Definition TrackRun.cpp:608
Distribution * dist_m
Definition TrackRun.h:101
void setupFieldsolver()
Definition TrackRun.cpp:525
void setupCyclotronTracker()
Definition TrackRun.cpp:411
double macrocharge_m
Definition TrackRun.h:120
static constexpr std::array< std::pair< RunMethod, std::string_view >, 5 > runMethodMap
Definition TrackRun.h:66
OpalData * opalData_m
Definition TrackRun.h:110
Inform & print(Inform &os) const
Definition TrackRun.cpp:692
void setupThickTracker()
Definition TrackRun.cpp:252
static std::shared_ptr< Tracker > getTracker()
Definition TrackRun.cpp:716
The base class for all OPAL exceptions.