52#include "OPALconfig.h"
55#include <boost/assign.hpp>
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");
95 "The \"RUN\" sub-command tracks the defined particles through "
96 "the given lattice."),
106 (
"METHOD",
"Name of tracking algorithm to use.",
107 {
"THICK",
"OPAL-T",
"PARALLEL-T",
"OPAL-CYCL",
"CYCLOTRON-T"});
110 (
"TURNS",
"Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron.", 1.0);
113 (
"MBMODE",
"The working way for multi-bunch mode for OPAL-cycl.",
114 {
"FORCE",
"AUTO"},
"FORCE");
117 (
"PARAMB",
"Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode.", 5.0);
120 (
"MB_ETA",
"The scale parameter for binning in multi-bunch mode.", 0.01);
123 (
"MB_BINNING",
"Type of energy binning in multi-bunch mode.",
124 {
"GAMMA_BINNING",
"BUNCH_BINNING"},
"GAMMA_BINNING");
127 (
"BEAM",
"Name of beam.");
130 (
"FIELDSOLVER",
"Field solver to be used.");
133 (
"BOUNDARYGEOMETRY",
"Boundary geometry to be used NONE (default).",
"NONE");
136 (
"DISTRIBUTION",
"List of particle distributions to be used.");
139 (
"TRACKBACK",
"Track in reverse direction, default: false.",
false);
171 const int currentVersion = ((OPAL_VERSION_MAJOR * 100) + OPAL_VERSION_MINOR) * 100;
174 bool newerChanges =
false;
176 if (it->first > fileVersion) {
183 errorMsg <<
"\n******************** V E R S I O N M I S M A T C H ***********************\n" <<
endl;
185 if (it->first > fileVersion) {
186 errorMsg << it->second <<
endl;
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");
202 "\"DISTRIBUTION\" must be set in \"RUN\" command.");
206 "\"FIELDSOLVER\" must be set in \"RUN\" command.");
210 "\"BEAM\" must be set in \"RUN\" command.");
230 "Unknown \"METHOD\" for the \"RUN\" command");
238 for (
int turn = 1; turn < turns; ++turn) {
256 "The attribute \"METHOD\" isn't set for the \"RUN\" command");
320 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
324 zstop.erase(zstop.begin(), zstop.begin() + i);
325 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
326 dT.erase(dT.begin(), dT.begin() + i);
391 *
gmsg << std::scientific;
401 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
441 if (distr_str.size() == 0) {
507 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
528 if ( specifiedNumBunch > 1 ) {
550 if (!
opalData_m->inRestartRun() && numParticles < numGridPoints
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");
576 const std::string h5FileName =
opalData_m->getInputBasename() + std::string(
".h5");
645 std::vector<std::string> distributionArray
647 const size_t numberOfDistributions = distributionArray.size();
649 if (numberOfDistributions == 0) {
653 dist_m->setNumberOfDistributions(numberOfDistributions);
655 if (numberOfDistributions > 1) {
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;
665 for (
size_t i = 1; i < numberOfDistributions; ++ i) {
670 *
gmsg << distributionArray.at(i) <<
endl;
673 <<
"---------------------------------" <<
endl <<
endl;
711 os <<
"* ************* T R A C K R U N *************************************************** " <<
endl;
713 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", NEW TRACK" <<
'\n'
714 <<
"* ********************************************************************************** " <<
'\n';
716 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", FOLLOWUP TRACK" <<
'\n'
717 <<
"* ********************************************************************************** " <<
'\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';
727 <<
"* STEPSPERTURN = " <<
Track::block->stepsPerTurn <<
'\n';
729 os <<
"* ********************************************************************************** ";
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
Inform & endl(Inform &inf)
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
constexpr double epsilon_0
The permittivity of vacuum in As/Vm.
constexpr double q_e
The elementary charge in As.
constexpr double pi
The value of.
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
int version
opal version of input file
bool enableHDF5
If true HDF5 files are written.
bool amr
Enable AMR if true.
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
Action(int size, const char *name, const char *help)
Constructor for exemplars.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
std::vector< Attribute > itsAttr
The object attributes.
static OpalData * getInstance()
void setLastDumpedStep(const int para)
set last dumped step
void setPr(double x)
Method for restart.
void setPreviousH5Local(bool x)
Track using thick-lens algorithm.
static Distribution * find(const std::string &name)
void setNumberOfDistributions(unsigned int n)
std::string getParticleName() const
Return Particle's name.
double getCurrent() const
Return the beam current in A.
double getChargePerParticle() const
Charge per macro particle in C.
static Beam * find(const std::string &name)
Find named BEAM.
double getCharge() const
Return the charge number in elementary charge.
double getFrequency() const
Return the beam frequency in MHz.
size_t getNumberOfParticles() const
Return the number of (macro)particles.
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
double getMass() const
Return Particle's rest mass in GeV.
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.
H5PartWrapper * phaseSpaceSink_m
virtual void execute()
Execute the command.
std::vector< Distribution * > distrs_m
static std::shared_ptr< Tracker > itsTracker_m
FieldSolver * fieldSolver_m
void initDataSink(const int &numBunch=1)
TrackRun()
Exemplar constructor.
virtual TrackRun * clone(const std::string &name)
Make clone.
static const std::string defaultDistribution
double setDistributionParallelT(Beam *beam)
std::string getRunMethodName() const
void initPhaseSpaceSink()
void setBoundaryGeometry()
void setupCyclotronTracker()
Inform & print(Inform &os) const
static const boost::bimap< RunMethod, std::string > stringMethod_s
static std::shared_ptr< Tracker > getTracker()
The base class for all OPAL exceptions.