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),
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),
154 macromass_m(0.0),
155 macrocharge_m(0.0) {
157}
158
159
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
199 isFollowupTrack_m = opalData_m->hasBunchAllocated();
200 if (!itsAttr[DISTRIBUTION] && !isFollowupTrack_m) {
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
247 opalData_m->setRestartRun(false);
248 }
249
250 opalData_m->bunchIsAllocated();
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) {
271 Track::block->bunch->setLocalTrackStep(0);
272 }
273
275
277
279
281
283
284 *gmsg << *this << endl;
285
286 Track::block->bunch->setdT(Track::block->dT.front());
287 Track::block->bunch->dtScInit_m = Track::block->dtScInit;
288 Track::block->bunch->deltaTau_m = Track::block->deltaTau;
289
290 if (!isFollowupTrack_m && !opalData_m->inRestartRun()) {
291 Track::block->bunch->setT(Track::block->t0_m);
292 }
293
294 if (Track::block->bunch->getIfBeamEmitting()) {
295 Track::block->bunch->setChargeZeroPart(macrocharge_m);
296 } else {
297 Track::block->bunch->setCharge(macrocharge_m);
298 }
299
300 // set coupling constant
301 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
302 Track::block->bunch->setCouplingConstant(coefE);
303
304 // statistical data are calculated (rms, eps etc.)
305 Track::block->bunch->calcBeamParameters();
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(),
337 Track::block->bunch, *beam, *dataSink_m, Track::block->reference,
338 false, false, Track::block->localTimeSteps,
339 Track::block->zstart, Track::block->zstop, Track::block->dT,
340 Track::block->truncOrder));
341}
342
343
345 opalData_m->setInOPALTMode();
346
347 if (isFollowupTrack_m) {
348 Track::block->bunch->setLocalTrackStep(0);
349 }
350
352 Track::block->bunch->setBeamFrequency(beam->getFrequency() * Units::MHz2Hz);
353 Track::block->bunch->setPType(beam->getParticleName());
354
356
358
360
363
364 *gmsg << *this << endl;
365
366 Track::block->bunch->setdT(Track::block->dT.front());
367 Track::block->bunch->dtScInit_m = Track::block->dtScInit;
368 Track::block->bunch->deltaTau_m = Track::block->deltaTau;
369
370 if (!isFollowupTrack_m && !opalData_m->inRestartRun()) {
371 Track::block->bunch->setT(Track::block->t0_m);
372 }
373
374 if (Track::block->bunch->getIfBeamEmitting()) {
375 Track::block->bunch->setChargeZeroPart(macrocharge_m);
376 Track::block->bunch->setMassZeroPart(macromass_m);
377 } else {
378 Track::block->bunch->setCharge(macrocharge_m);
379 Track::block->bunch->setMass(macromass_m);
380 }
381 // set coupling constant
382 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
383 Track::block->bunch->setCouplingConstant(coefE);
384
385 // statistical data are calculated (rms, eps etc.)
386 Track::block->bunch->calcBeamParameters();
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(),
417 Track::block->bunch,
418 *dataSink_m,
419 Track::block->reference,
420 false,
421 Attributes::getBool(itsAttr[TRACKBACK]),
422 Track::block->localTimeSteps,
423 Track::block->zstart,
424 Track::block->zstop,
425 Track::block->dT));
426}
427
429 opalData_m->setInOPALCyclMode();
430
432
434
436
437 Track::block->bunch->setPType(beam->getParticleName());
438 Track::block->bunch->POrigin = ParticleOrigin::REGULAR;
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();
459 Track::block->bunch->setDistribution(dist_m,
460 beam->getNumberOfParticles(),
461 beam->getCurrent(),
462 *Track::block->use->fetchLine());
463
464 } else {
471
472 if (!isFollowupTrack_m) {
473 if (!opalData_m->inRestartRun()) {
474 Track::block->bunch->setDistribution(dist_m,
475 beam->getNumberOfParticles(),
476 beam->getCurrent(),
477 *Track::block->use->fetchLine());
478
479 } else {
480 dist_m->doRestartOpalCycl(Track::block->bunch,
481 beam->getNumberOfParticles(),
482 opalData_m->getRestartStep(),
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));
492 Track::block->bunch->setStepsPerTurn(Track::block->stepsPerTurn);
493
494 // set coupling constant
495 double coefE = 1.0 / (4 * Physics::pi * Physics::epsilon_0);
496 Track::block->bunch->setCouplingConstant(coefE);
497
498 // statistical data are calculated (rms, eps etc.)
499 Track::block->bunch->calcBeamParameters();
500
501 initDataSink(specifiedNumBunch);
502
503 itsTracker_m.reset(new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
504 Track::block->bunch, *dataSink_m, Track::block->reference,
505 false, false, Track::block->localTimeSteps.front(),
506 Track::block->timeIntegrator,
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 ) {
529 cyclTracker->setLastDumpedStep(opalData_m->getRestartStep());
530 }
531 }
532
533 // statistical data are calculated (rms, eps etc.)
534 Track::block->bunch->calcBeamParameters();
535
536 *gmsg << *this << endl;
537 *gmsg << *dist_m << endl;
538 *gmsg << *beam << endl;
539 *gmsg << *fieldSolver_m << endl;
540}
541
544
545 if (fieldSolver_m->getFieldSolverType() != FieldSolverType::NONE) {
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
561 opalData_m->addProblemCharacteristicValue("MX", fieldSolver_m->getMX());
562 opalData_m->addProblemCharacteristicValue("MY", fieldSolver_m->getMY());
563 opalData_m->addProblemCharacteristicValue("MT", fieldSolver_m->getMT());
564 }
565
566 fieldSolver_m->initCartesianFields();
567 Track::block->bunch->setSolver(fieldSolver_m);
568 if (fieldSolver_m->hasPeriodicZ()) {
569 Track::block->bunch->setBCForDCBeam();
570 } else {
571 Track::block->bunch->setBCAllOpen();
572 }
573}
574
576 const std::string h5FileName = opalData_m->getInputBasename() + std::string(".h5");
577 if (opalData_m->isInOPALCyclMode()) {
578 if (opalData_m->inRestartRun()) {
579 phaseSpaceSink_m = new H5PartWrapperForPC(h5FileName,
580 opalData_m->getRestartStep(),
581 opalData_m->getRestartFileName(),
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,
595 opalData_m->getRestartStep(),
596 opalData_m->getRestartFileName(),
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()) {
613 if (!opalData_m->hasDataSinkAllocated()) {
614 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, false, numBunch));
615 } else {
616 dataSink_m = opalData_m->getDataSink();
617 dataSink_m->changeH5Wrapper(phaseSpaceSink_m);
618 }
619 } else {
620 opalData_m->setDataSink(new DataSink(phaseSpaceSink_m, true, numBunch));
621 }
622 dataSink_m = opalData_m->getDataSink();
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
629 if (!opalData_m->hasGlobalGeometry()) {
630 const std::string geomDescriptor = Attributes::getString(itsAttr[BOUNDARYGEOMETRY]);
631 BoundaryGeometry* bg = BoundaryGeometry::find(geomDescriptor)->clone(geomDescriptor);
632 opalData_m->setGlobalGeometry(bg);
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
646 = Attributes::getStringArray(itsAttr[DISTRIBUTION]);
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 */
687 Track::block->bunch->setDistribution(dist_m,
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
696 opalData_m->setGlobalPhaseShift(0.5 * dist_m->getTEmission() + dist_m->getEmissionTimeShift());
697 } else {
698 /*
699 * Read in beam from restart file.
700 */
701 dist_m->doRestartOpalT(Track::block->bunch, numberOfParticles, opalData_m->getRestartStep(), phaseSpaceSink_m);
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}
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
@ SIZE
Definition IndexMap.cpp:174
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: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
Action(int size, const char *name, const char *help)
Constructor for exemplars.
Definition Action.cpp:54
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:191
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
static OpalData * getInstance()
Definition OpalData.cpp:196
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 setNumberOfDistributions(unsigned int n)
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.
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
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
static Track * block
The block of track data.
Definition Track.h:59
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.