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."),
98 fieldSolver_m(nullptr),
100 phaseSpaceSink_m(nullptr),
101 isFollowupTrack_m(false),
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);
149 fieldSolver_m(nullptr),
151 phaseSpaceSink_m(nullptr),
152 isFollowupTrack_m(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 ) {
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");
645 std::vector<std::string> distributionArray
647 const size_t numberOfDistributions = distributionArray.size();
649 if (numberOfDistributions == 0) {
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';
723 <<
"* Mass of simulation particle = " <<
macromass_m <<
" [GeV/c^2]" <<
'\n'
724 <<
"* Charge of simulation particle = " <<
macrocharge_m <<
" [C]" <<
'\n';
729 os <<
"* ********************************************************************************** ";
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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.
The base class for all OPAL actions.
virtual Beamline * fetchLine() const =0
Return the embedded CLASSIC beam line.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
std::vector< Attribute > itsAttr
The object attributes.
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
void setPType(const std::string &type)
void setMass(double mass)
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)
virtual void setBCForDCBeam()
virtual void setSolver(FieldSolver *fs)
void setStepsPerTurn(int n)
std::string getInputBasename()
get input file name without extension
void setRestartRun(const bool &value=true)
set OPAL in restart mode
std::string getRestartFileName()
get opals restart h5 format filename
int getRestartStep()
get the step where to restart
void setDataSink(DataSink *s)
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
void setGlobalPhaseShift(double shift)
units: (sec)
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
static OpalData * getInstance()
void setGlobalGeometry(BoundaryGeometry *bg)
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
bool inRestartRun()
true if we do a restart run
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 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
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.
void changeH5Wrapper(H5PartWrapper *h5wrapper)
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
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.
int stepsPerTurn
The timsteps per revolution period. ONLY available for OPAL-cycl.
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
PartData reference
The reference data.
double zstart
The location at which the simulation starts.
std::vector< unsigned long long > localTimeSteps
Maximal number of timesteps.
std::vector< double > zstop
The location at which the simulation stops.
static Track * block
The block of track data.
Steppers::TimeIntegrator timeIntegrator
The ID of time integrator.
int truncOrder
Trunction order for map tracking.
std::vector< double > dT
The initial timestep.
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.