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 <boost/assign.hpp>
56
57#include <cmath>
58#include <fstream>
59#include <iomanip>
60
61
62extern Inform *gmsg;
63
64std::shared_ptr<Tracker> TrackRun::itsTracker_m = nullptr;
65
66namespace {
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
84const std::string TrackRun::defaultDistribution("DISTRIBUTION");
85
86const 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
113 ("MBMODE", "The working way for multi-bunch mode for OPAL-cycl.",
114 {"FORCE", "AUTO"}, "FORCE");
115
117 ("PARAMB", "Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode.", 5.0);
118
120 ("MB_ETA", "The scale parameter for binning in multi-bunch mode.", 0.01);
121
123 ("MB_BINNING", "Type of energy binning in multi-bunch mode.",
124 {"GAMMA_BINNING", "BUNCH_BINNING"}, "GAMMA_BINNING");
125
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
146TrackRun::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
165TrackRun* 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 }
222 break;
223 }
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
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
265std::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
406 Track::block->bunch->setdT(*it);
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(),
463
464 } else {
471
472 if (!isFollowupTrack_m) {
473 if (!opalData_m->inRestartRun()) {
475 beam->getNumberOfParticles(),
476 beam->getCurrent(),
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
570 } else {
572 }
573}
574
576 const std::string h5FileName = opalData_m->getInputBasename() + std::string(".h5");
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
611void 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
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
733std::shared_ptr<Tracker> TrackRun::getTracker() {
734 return itsTracker_m;
735}
Inform * gmsg
Definition: Main.cpp:70
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
@ SIZE
Definition: IndexMap.cpp:174
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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.
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: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:39
int version
opal version of input file
Definition: Options.cpp:97
bool enableHDF5
If true HDF5 files are written.
Definition: Options.cpp:81
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
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 calcBeamParameters()
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.
Definition: ThickTracker.h:86
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)
Definition: Distribution.h:241
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
Definition: FieldSolver.h:164
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:109
DataSink * dataSink_m
Definition: TrackRun.h:99
H5PartWrapper * phaseSpaceSink_m
Definition: TrackRun.h:101
virtual void execute()
Execute the command.
Definition: TrackRun.cpp:170
void setupTTracker()
Definition: TrackRun.cpp:344
std::vector< Distribution * > distrs_m
Definition: TrackRun.h:95
bool isFollowupTrack_m
Definition: TrackRun.h:105
void setRunMethod()
Definition: TrackRun.cpp:253
virtual ~TrackRun()
Definition: TrackRun.cpp:160
static std::shared_ptr< Tracker > itsTracker_m
Definition: TrackRun.h:92
FieldSolver * fieldSolver_m
Definition: TrackRun.h:97
void initDataSink(const int &numBunch=1)
Definition: TrackRun.cpp:611
TrackRun()
Exemplar constructor.
Definition: TrackRun.cpp:93
double macromass_m
Definition: TrackRun.h:113
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition: TrackRun.cpp:165
static const std::string defaultDistribution
Definition: TrackRun.h:107
double setDistributionParallelT(Beam *beam)
Definition: TrackRun.cpp:638
std::string getRunMethodName() const
Definition: TrackRun.cpp:265
void initPhaseSpaceSink()
Definition: TrackRun.cpp:575
void setBoundaryGeometry()
Definition: TrackRun.cpp:625
Distribution * dist_m
Definition: TrackRun.h:94
void setupFieldsolver()
Definition: TrackRun.cpp:542
void setupCyclotronTracker()
Definition: TrackRun.cpp:428
double macrocharge_m
Definition: TrackRun.h:114
OpalData * opalData_m
Definition: TrackRun.h:103
Inform & print(Inform &os) const
Definition: TrackRun.cpp:709
static const boost::bimap< RunMethod, std::string > stringMethod_s
Definition: TrackRun.h:110
void setupThickTracker()
Definition: TrackRun.cpp:269
static std::shared_ptr< Tracker > getTracker()
Definition: TrackRun.cpp:733
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Definition: Inform.h:42