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."),
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);
151 phaseSpaceSink_m(nullptr),
152 isFollowupTrack_m(false),
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");
333 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
337 zstop.erase(zstop.begin(), zstop.begin() + i);
338 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
339 dT.erase(dT.begin(), dT.begin() + i);
417 *
gmsg << std::scientific;
427 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
467 if (distr_str.size() == 0) {
546 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
567 if ( specifiedNumBunch > 1 ) {
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");
649 std::vector<std::string> distributionArray
651 const size_t numberOfDistributions = distributionArray.size();
653 if (numberOfDistributions == 0) {
659 if (numberOfDistributions > 1) {
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;
669 for (
size_t i = 1; i < numberOfDistributions; ++ i) {
674 *
gmsg << distributionArray.at(i) <<
endl;
677 <<
"---------------------------------" <<
endl <<
endl;
715 os <<
"* ************* T R A C K R U N *************************************************** " <<
endl;
717 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", NEW TRACK" <<
'\n'
718 <<
"* ********************************************************************************** " <<
'\n';
720 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", FOLLOWUP TRACK" <<
'\n'
721 <<
"* ********************************************************************************** " <<
'\n';
727 <<
"* Mass of simulation particle = " <<
macromass_m <<
" [GeV/c^2]" <<
'\n'
728 <<
"* Charge of simulation particle = " <<
macrocharge_m <<
" [C]" <<
'\n';
733 os <<
"* ********************************************************************************** ";
#define OPAL_VERSION_MINOR
#define OPAL_VERSION_MAJOR
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 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.
static std::shared_ptr< Tracker > itsTracker
H5PartWrapper * phaseSpaceSink_m
virtual void execute()
Execute the command.
std::vector< Distribution * > distrs_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 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.