OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
TrackRun.cpp
Go to the documentation of this file.
1//
2// Class TrackRun
3// The RUN command.
4//
5// Copyright (c) 200x - 2022, 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 = 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(nullptr),
98 fs(nullptr),
99 ds(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(nullptr),
149 fs(nullptr),
150 ds(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->execute();
240 }
241 // Track the last turn.
242 itsTracker->execute();
243
244 } else {
245 itsTracker->execute();
246
247 opal->setRestartRun(false);
248 }
249
251}
252
254 if (!itsAttr[METHOD]) {
255 throw OpalException("TrackRun::setRunMethod",
256 "The attribute \"METHOD\" isn't set for the \"RUN\" command");
257 } else {
258 auto it = stringMethod_s.right.find(Attributes::getString(itsAttr[METHOD]));
259 if (it != stringMethod_s.right.end()) {
260 method_m = it->second;
261 }
262 }
263}
264
265std::string TrackRun::getRunMethodName() const {
266 return stringMethod_s.left.at(method_m);
267}
268
270 if (isFollowupTrack_m) {
272 }
273
275
277
279
280 if (opal->inRestartRun()) {
281 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
284 H5_O_WRONLY);
285 } else if (isFollowupTrack_m) {
286 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
287 -1,
288 opal->getInputBasename() + std::string(".h5"),
289 H5_O_WRONLY);
290 } else {
291 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
292 H5_O_WRONLY);
293 }
294
296
297 *gmsg << *this << endl;
298
299 Track::block->bunch->setdT(Track::block->dT.front());
302
303 if (!isFollowupTrack_m && !opal->inRestartRun()) {
305 }
306
307 if (Track::block->bunch->getIfBeamEmitting()) {
309 } else {
311 }
312
313 // set coupling constant
314 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
316
317 // statistical data are calculated (rms, eps etc.)
319
320 initDataSink();
321
322 if (!isFollowupTrack_m) {
323 *gmsg << *dist << endl;
324 }
325
326 if (Track::block->bunch->getTotalNum() > 0) {
327 double spos = /*Track::block->bunch->get_sPos() +*/ Track::block->zstart;
328 auto &zstop = Track::block->zstop;
329 auto &timeStep = Track::block->localTimeSteps;
330 auto &dT = Track::block->dT;
331
332 unsigned int i = 0;
333 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
334 ++ i;
335 }
336
337 zstop.erase(zstop.begin(), zstop.begin() + i);
338 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
339 dT.erase(dT.begin(), dT.begin() + i);
340
341 Track::block->bunch->setdT(dT.front());
342 } else {
343 Track::block->zstart = 0.0;
344 }
345
346 *gmsg << *beam << endl;
347 *gmsg << *fs << endl;
348
349 itsTracker.reset(new ThickTracker(*Track::block->use->fetchLine(),
351 false, false, Track::block->localTimeSteps,
354}
355
356
359
360 if (isFollowupTrack_m) {
362 }
363
367
369
371
372 if (opal->inRestartRun()) {
373 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
376 H5_O_WRONLY);
377 } else if (isFollowupTrack_m) {
378 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
379 -1,
380 opal->getInputBasename() + std::string(".h5"),
381 H5_O_WRONLY);
382 } else {
383 phaseSpaceSink_m = new H5PartWrapperForPT(opal->getInputBasename() + std::string(".h5"),
384 H5_O_WRONLY);
385 }
386
389
390 *gmsg << *this << endl;
391
392 Track::block->bunch->setdT(Track::block->dT.front());
395
396 if (!isFollowupTrack_m && !opal->inRestartRun()) {
398 }
399
400 if (Track::block->bunch->getIfBeamEmitting()) {
403 } else {
406 }
407 // set coupling constant
408 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
410
411 // statistical data are calculated (rms, eps etc.)
413
414 initDataSink();
415
416 if (!isFollowupTrack_m) {
417 *gmsg << std::scientific;
418 *gmsg << *dist << endl;
419 }
420
421 if (Track::block->bunch->getTotalNum() > 0) {
422 double spos = Track::block->zstart;
423 auto& zstop = Track::block->zstop;
424 auto it = Track::block->dT.begin();
425
426 unsigned int i = 0;
427 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
428 ++ i;
429 ++ it;
430 }
431
432 Track::block->bunch->setdT(*it);
433 } else {
434 Track::block->zstart = 0.0;
435 }
436
437 *gmsg << *beam << endl;
438 *gmsg << *fs << endl;
439
440 // findPhasesForMaxEnergy();
441
442 itsTracker.reset(new ParallelTTracker(*Track::block->use->fetchLine(),
444 *ds,
446 false,
447 Attributes::getBool(itsAttr[TRACKBACK]),
451 Track::block->dT));
452}
453
455
458
460
462
465
466 std::vector<std::string> distr_str = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
467 if (distr_str.size() == 0) {
469 } else {
470 dist = Distribution::find(distr_str.at(0));
471 }
472
473 // multi-bunch parameters
474 const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
475 const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
476 const std::string mbMode = Attributes::getString(itsAttr[MBMODE]);
477 const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
478 const std::string mbBinning = Attributes::getString(itsAttr[MB_BINNING]);
479
480 if (opal->inRestartRun()) {
481 phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
484 H5_O_WRONLY);
485 } else if (isFollowupTrack_m) {
486 phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
487 -1,
488 opal->getInputBasename() + std::string(".h5"),
489 H5_O_WRONLY);
490 } else {
491 phaseSpaceSink_m = new H5PartWrapperForPC(opal->getInputBasename() + std::string(".h5"),
492 H5_O_WRONLY);
493 }
494
495 if (beam->getNumberOfParticles() < 3 || beam->getCurrent() == 0.0) {
497 macromass_m = beam->getMass();
499 beam->getNumberOfParticles(),
500 beam->getCurrent(),
502
503 } else {
510
511 if (!isFollowupTrack_m) {
512 if (!opal->inRestartRun()) {
514 beam->getNumberOfParticles(),
515 beam->getCurrent(),
517
518 } else {
520 beam->getNumberOfParticles(),
522 specifiedNumBunch,
524 }
525 }
526 }
527 Track::block->bunch->setMass(macromass_m); // set the Mass per macro-particle, [GeV/c^2]
528 Track::block->bunch->setCharge(macrocharge_m); // set the charge per macro-particle, [C]
529
530 Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * Units::MHz2Hz));
532
533 // set coupling constant
534 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
536
537 // statistical data are calculated (rms, eps etc.)
539
540 initDataSink(specifiedNumBunch);
541
542 itsTracker.reset(new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
544 false, false, Track::block->localTimeSteps.front(),
546 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
547
548 ParallelCyclotronTracker* cyclTracker = dynamic_cast<ParallelCyclotronTracker*>(itsTracker.get());
549
550 if (opal->inRestartRun()) {
552 cyclTracker->setBeGa(h5pw->getMeanMomentum());
553
554 cyclTracker->setPr(h5pw->getReferencePr());
555 cyclTracker->setPt(h5pw->getReferencePt());
556 cyclTracker->setPz(h5pw->getReferencePz());
557
558 cyclTracker->setR(h5pw->getReferenceR());
559 cyclTracker->setTheta(h5pw->getReferenceT());
560 cyclTracker->setZ(h5pw->getReferenceZ());
561
562 // The following is for restarts in local frame
563 cyclTracker->setPhi(h5pw->getAzimuth());
564 cyclTracker->setPsi(h5pw->getElevation());
565 cyclTracker->setPreviousH5Local(h5pw->getPreviousH5Local());
566
567 if ( specifiedNumBunch > 1 ) {
568 cyclTracker->setLastDumpedStep(opal->getRestartStep());
569 }
570 }
571
572 // statistical data are calculated (rms, eps etc.)
574
575 *gmsg << *this << endl;
576 *gmsg << *dist << endl;
577 *gmsg << *beam << endl;
578 *gmsg << *fs << endl;
579}
580
583
585 size_t numGridPoints = fs->getMX()*fs->getMY()*fs->getMT(); // total number of gridpoints
587 size_t numParticles = beam->getNumberOfParticles();
588
589 if (!opal->inRestartRun() && numParticles < numGridPoints
590 && fs->getFieldSolverType() != FieldSolverType::SAAMG // in SPIRAL/SAAMG we're meshing the whole domain -DW
591 && fs->getFieldSolverType() != FieldSolverType::P3M //In P3M with one-one mapping grid points can be less than particles
592 && !Options::amr)
593 {
594 throw OpalException("TrackRun::setupFieldsolver()",
595 "The number of simulation particles (" + std::to_string(numParticles) + ") \n" +
596 "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) + ").\n" +
597 "Please increase the number of particles or reduce the size of the mesh.\n");
598 }
599
603 }
604
607 if (fs->hasPeriodicZ()) {
609 } else {
611 }
612}
613
614
615void TrackRun::initDataSink(const int& numBunch) {
616 if (!opal->inRestartRun()) {
617 if (!opal->hasDataSinkAllocated()) {
618 opal->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
619 } else {
620 ds = opal->getDataSink();
622 }
623 } else {
624 opal->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
625 }
626 ds = opal->getDataSink();
627}
628
630 if (Attributes::getString(itsAttr[BOUNDARYGEOMETRY]) != "NONE") {
631 // Ask the dictionary if BoundaryGeometry is allocated.
632 // If it is allocated use the allocated BoundaryGeometry
633 if (!OpalData::getInstance()->hasGlobalGeometry()) {
634 const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
635 BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
637 }
638 }
639}
640
641
643 /*
644 * Distribution(s) can be set via a single distribution or a list
645 * (array) of distributions. If an array is defined the first in the
646 * list is treated as the primary distribution. All others are added to
647 * it to create the full distribution.
648 */
649 std::vector<std::string> distributionArray
651 const size_t numberOfDistributions = distributionArray.size();
652
653 if (numberOfDistributions == 0) {
655 } else {
656 dist = Distribution::find(distributionArray.at(0));
657 dist->setNumberOfDistributions(numberOfDistributions);
658
659 if (numberOfDistributions > 1) {
660 *gmsg << endl
661 << "---------------------------------" << endl
662 << "Found more than one distribution:" << endl << endl;
663 *gmsg << "Main Distribution" << endl
664 << "---------------------------------" << endl
665 << distributionArray.at(0) << endl << endl
666 << "Secondary Distribution(s)" << endl
667 << "---------------------------------" << endl;
668
669 for (size_t i = 1; i < numberOfDistributions; ++ i) {
670 Distribution *distribution = Distribution::find(distributionArray.at(i));
671 distribution->setNumberOfDistributions(numberOfDistributions);
672 distrs_m.push_back(distribution);
673
674 *gmsg << distributionArray.at(i) << endl;
675 }
676 *gmsg << endl
677 << "---------------------------------" << endl << endl;
678 }
679 }
680
681 /*
682 * Initialize distributions.
683 */
684 size_t numberOfParticles = beam->getNumberOfParticles();
685 if (!isFollowupTrack_m) {
686 if (!opal->inRestartRun()) {
687 /*
688 * Here we are not doing a restart run
689 * and we do not have a bunch already allocated.
690 */
692 distrs_m,
693 numberOfParticles);
694
695 /*
696 * If this is an injected beam (rather than an emitted beam), we
697 * make sure it doesn't have any particles at z < 0.
698 */
699
701 } else {
702 /*
703 * Read in beam from restart file.
704 */
705 dist->doRestartOpalT(Track::block->bunch, numberOfParticles, opal->getRestartStep(), phaseSpaceSink_m);
706 }
707 }
708
709 // Return charge per macroparticle.
710 return beam->getChargePerParticle();
711}
712
714 os << endl;
715 os << "* ************* T R A C K R U N *************************************************** " << endl;
716 if (!isFollowupTrack_m) {
717 os << "* Selected Tracking Method == " << getRunMethodName() << ", NEW TRACK" << '\n'
718 << "* ********************************************************************************** " << '\n';
719 } else {
720 os << "* Selected Tracking Method == " << getRunMethodName() << ", FOLLOWUP TRACK" << '\n'
721 << "* ********************************************************************************** " << '\n';
722 }
723 os << "* Phase space dump frequency = " << Options::psDumpFreq << '\n'
724 << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << '\n'
725 << "* DT = " << Track::block->dT.front() << " [s]\n"
726 << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << '\n'
727 << "* Mass of simulation particle = " << macromass_m << " [GeV/c^2]" << '\n'
728 << "* Charge of simulation particle = " << macrocharge_m << " [C]" << '\n';
730 os << "* Number of neighbour bunches = " << int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS])))) << '\n'
731 << "* STEPSPERTURN = " << Track::block->stepsPerTurn << '\n';
732 }
733 os << "* ********************************************************************************** ";
734 return os;
735}
736
737std::shared_ptr<Tracker> TrackRun::getTracker() {
738 return itsTracker;
739}
Inform * gmsg
Definition: Main.cpp:61
#define OPAL_VERSION_MINOR
Definition: OPALconfig.h:7
#define OPAL_VERSION_MAJOR
Definition: OPALconfig.h:6
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 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 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
std::string getInputBasename()
get input file name without extension
Definition: OpalData.cpp:669
void setInOPALCyclMode()
Definition: OpalData.cpp:284
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:751
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:193
double getCurrent() const
Return the beam current in A.
Definition: Beam.cpp:181
double getChargePerParticle() const
Charge per macro particle in C.
Definition: Beam.cpp:201
static Beam * find(const std::string &name)
Find named BEAM.
Definition: Beam.cpp:156
double getCharge() const
Return the charge number in elementary charge.
Definition: Beam.cpp:185
double getFrequency() const
Return the beam frequency in MHz.
Definition: Beam.cpp:197
size_t getNumberOfParticles() const
Return the number of (macro)particles.
Definition: Beam.cpp:166
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition: Beam.cpp:207
double getMass() const
Return Particle's rest mass in GeV.
Definition: Beam.cpp:189
static BoundaryGeometry * find(const std::string &name)
virtual BoundaryGeometry * clone(const std::string &name)
Return a clone.
void changeH5Wrapper(H5PartWrapper *h5wrapper)
Definition: DataSink.cpp:141
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
static std::shared_ptr< Tracker > itsTracker
Definition: TrackRun.h:90
RunMethod method_m
Definition: TrackRun.h:108
H5PartWrapper * phaseSpaceSink_m
Definition: TrackRun.h:100
virtual void execute()
Execute the command.
Definition: TrackRun.cpp:170
void setupTTracker()
Definition: TrackRun.cpp:357
std::vector< Distribution * > distrs_m
Definition: TrackRun.h:94
bool isFollowupTrack_m
Definition: TrackRun.h:104
Distribution * dist
Definition: TrackRun.h:92
void setRunMethod()
Definition: TrackRun.cpp:253
virtual ~TrackRun()
Definition: TrackRun.cpp:160
void initDataSink(const int &numBunch=1)
Definition: TrackRun.cpp:615
TrackRun()
Exemplar constructor.
Definition: TrackRun.cpp:93
double macromass_m
Definition: TrackRun.h:112
virtual TrackRun * clone(const std::string &name)
Make clone.
Definition: TrackRun.cpp:165
static const std::string defaultDistribution
Definition: TrackRun.h:106
double setDistributionParallelT(Beam *beam)
Definition: TrackRun.cpp:642
std::string getRunMethodName() const
Definition: TrackRun.cpp:265
void setBoundaryGeometry()
Definition: TrackRun.cpp:629
void setupFieldsolver()
Definition: TrackRun.cpp:581
void setupCyclotronTracker()
Definition: TrackRun.cpp:454
double macrocharge_m
Definition: TrackRun.h:113
DataSink * ds
Definition: TrackRun.h:98
OpalData * opal
Definition: TrackRun.h:102
FieldSolver * fs
Definition: TrackRun.h:96
Inform & print(Inform &os) const
Definition: TrackRun.cpp:713
static const boost::bimap< RunMethod, std::string > stringMethod_s
Definition: TrackRun.h:109
void setupThickTracker()
Definition: TrackRun.cpp:269
static std::shared_ptr< Tracker > getTracker()
Definition: TrackRun.cpp:737
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Definition: Inform.h:42