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),
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");
284 *gmsg << *
this <<
endl;
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);
333 *gmsg << *beam <<
endl;
364 *gmsg << *
this <<
endl;
391 *gmsg << std::scientific;
401 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
411 *gmsg << *beam <<
endl;
441 if (distr_str.size() == 0) {
507 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning));
528 if ( specifiedNumBunch > 1 ) {
536 *gmsg << *
this <<
endl;
538 *gmsg << *beam <<
endl;
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 <<
"* ********************************************************************************** ";
int getRestartStep()
get the step where to restart
double getElevation() const
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
static OpalData * getInstance()
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
void setMass(double mass)
virtual BoundaryGeometry * clone(const std::string &name)
Return a clone.
double getMY() const
Return meshsize.
ParticleAttrib< ParticleOrigin > POrigin
bool enableHDF5
If true HDF5 files are written.
void setNumberOfDistributions(unsigned int n)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
void setGlobalPhaseShift(double shift)
units: (sec)
virtual void execute()
Execute the command.
std::string getString(const Attribute &attr)
Get string value.
virtual void setBCForDCBeam()
void setLocalTrackStep(long long n)
step in a TRACK command
bool getPreviousH5Local() const
void initPhaseSpaceSink()
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
int stepsPerTurn
The timsteps per revolution period. ONLY available for OPAL-cycl.
void setMassZeroPart(double mass)
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
constexpr double epsilon_0
The permittivity of vacuum in As/Vm.
void setGlobalGeometry(BoundaryGeometry *bg)
Steppers::TimeIntegrator timeIntegrator
The ID of time integrator.
int truncOrder
Trunction order for map tracking.
std::map< unsigned int, std::string > changes
double getReferencePr() const
H5PartWrapper * phaseSpaceSink_m
static std::shared_ptr< Tracker > getTracker()
void setPType(const std::string &type)
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
std::vector< double > zstop
The location at which the simulation stops.
Track using thick-lens algorithm.
std::string getRestartFileName()
get opals restart h5 format filename
bool inRestartRun()
true if we do a restart run
void calcBeamParameters()
PartData reference
The reference data.
void setPr(double x)
Method for restart.
static BoundaryGeometry * find(const std::string &name)
size_t getNumberOfParticles() const
Return the number of (macro)particles.
void initCartesianFields()
double getReferenceZ() const
clearpage the user may choose between constant or variable radius This model includes fringe fields begin
#define OPAL_VERSION_MAJOR
constexpr double pi
The value of .
virtual Beamline * fetchLine() const =0
Return the embedded CLASSIC beam line.
Inform & endl(Inform &inf)
double getMeanMomentum() const
std::string getParticleName() const
Return Particle's name.
static FieldSolver * find(const std::string &name)
Find named FieldSolver.
void setLastDumpedStep(const int para)
set last dumped step
static std::shared_ptr< Tracker > itsTracker_m
b Accompany it with a written valid for at least three to give any third for a charge no more than your cost of physically performing source distribution
double getEmissionTimeShift() const
bool getBool(const Attribute &attr)
Return logical value.
void setRestartRun(const bool &value=true)
set OPAL in restart mode
static Distribution * find(const std::string &name)
static const boost::bimap< RunMethod, std::string > stringMethod_s
void setBeamFrequency(double v)
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
double getReferencePz() const
void setupCyclotronTracker()
The base class for all OPAL exceptions.
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.
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
FieldSolverType getFieldSolverType() const
#define OPAL_VERSION_MINOR
double getMT() const
Return meshsize.
void setChargeZeroPart(double q)
std::vector< unsigned long long > localTimeSteps
Maximal number of timesteps.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
double getReferencePt() const
void setDistribution(Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np)
static Track * block
The block of track data.
void doRestartOpalT(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, H5PartWrapper *h5wrapper)
constexpr double q_e
The elementary charge in As.
double getReferenceR() const
double zstart
The location at which the simulation starts.
FieldSolver * fieldSolver_m
std::vector< Attribute > itsAttr
The object attributes.
double getMass() const
Return Particle's rest mass in GeV.
static Beam * find(const std::string &name)
Find named BEAM.
BeamSequence * use
The lattice to be tracked through.
void setStepsPerTurn(int n)
void setDataSink(DataSink *s)
bool amr
Enable AMR if true.
double getChargePerParticle() const
Charge per macro particle in C.
Inform & print(Inform &os) const
std::vector< Distribution * > distrs_m
double getReal(const Attribute &attr)
Return real value.
double setDistributionParallelT(Beam *beam)
void setBoundaryGeometry()
int version
opal version of input file
double getCurrent() const
Return the beam current in A.
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
static const std::string defaultDistribution
std::string getInputBasename()
get input file name without extension
void changeH5Wrapper(H5PartWrapper *h5wrapper)
void setPreviousH5Local(bool x)
virtual void setBCAllOpen()
virtual TrackRun * clone(const std::string &name)
Make clone.
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
void initDataSink(const int &numBunch=1)
double getMX() const
Return meshsize.
double getReferenceT() const
std::vector< double > dT
The initial timestep.
void doRestartOpalCycl(PartBunchBase< double, 3 > *p, size_t Np, int restartStep, const int specifiedNumBunch, H5PartWrapper *h5wrapper)
std::string getRunMethodName() const
The base class for all OPAL actions.
double getAzimuth() const
TrackRun()
Exemplar constructor.
double getCharge() const
Return the charge number in elementary charge.
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
virtual void setSolver(FieldSolver *fs)
void setCouplingConstant(double c)
double getFrequency() const
Return the beam frequency in MHz.