76 "The \"RUN\" sub-command tracks the defined particles through "
77 "the given lattice."),
82 phaseSpaceSink_m(NULL) {
84 (
"METHOD",
"Name of tracking algorithm to use.",
85 {
"THICK",
"OPAL-T",
"PARALLEL-T",
"OPAL-CYCL",
"CYCLOTRON-T"});
87 (
"TURNS",
"Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron", 1.0);
90 (
"MBMODE",
"The working way for multi-bunch mode for OPAL-cycl.",
91 {
"FORCE",
"AUTO"},
"FORCE");
94 (
"PARAMB",
"Control parameter to define when to start multi-bunch mode, only available in \"AUTO\" mode ", 5.0);
97 "The scale parameter for binning in multi-bunch mode",
101 (
"MB_BINNING",
"Type of energy binning in multi-bunch mode.",
102 {
"GAMMA_BINNING",
"BUNCH_BINNING"},
"GAMMA_BINNING");
105 (
"BEAM",
"Name of beam ",
"BEAM");
107 (
"FIELDSOLVER",
"Field solver to be used ",
"FIELDSOLVER");
109 (
"BOUNDARYGEOMETRY",
"Boundary geometry to be used NONE (default)",
"NONE");
111 (
"DISTRIBUTION",
"List of particle distributions to be used ");
113 (
"TRACKBACK",
"Track in reverse direction, default: false",
false);
126 phaseSpaceSink_m(NULL) {
146 bool newerChanges =
false;
148 if (it->first > fileVersion) {
155 errorMsg <<
"\n******************** V E R S I O N M I S M A T C H ***********************\n" <<
endl;
157 if (it->first > fileVersion) {
158 errorMsg << it->second <<
endl;
162 <<
"* Make sure you do understand these changes and adjust your input file \n"
163 <<
"* accordingly. Then add\n"
164 <<
"* OPTION, VERSION = " << currentVersion <<
";\n"
165 <<
"* to your input file. " <<
endl;
166 errorMsg <<
"\n****************************************************************************\n" <<
endl;
167 throw OpalException(
"TrackRun::execute",
"Version mismatch");
173 if (method ==
"THICK") {
175 }
else if(method ==
"PARALLEL-T" || method ==
"OPAL-T") {
177 }
else if(method ==
"CYCLOTRON-T" || method ==
"OPAL-CYCL") {
181 if (method ==
"THICK") {
185 for(
int turn = 1; turn < turns; ++turn) {
208 if(isFollowupTrack) {
209 *
gmsg <<
"* ********************************************************************************** " <<
endl;
210 *
gmsg <<
"* Selected Tracking Method == THICK, FOLLOWUP TRACK" <<
endl;
211 *
gmsg <<
"* ********************************************************************************** " <<
endl;
214 *
gmsg <<
"* ********************************************************************************** " <<
endl;
215 *
gmsg <<
"* Selected Tracking Method == THICK, NEW TRACK" <<
endl;
216 *
gmsg <<
"* ********************************************************************************** " <<
endl;
237 }
else if (isFollowupTrack) {
280 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
284 zstop.erase(zstop.begin(), zstop.begin() + i);
285 timeStep.erase(timeStep.begin(), timeStep.begin() + i);
286 dT.erase(dT.begin(), dT.begin() + i);
311 if(isFollowupTrack) {
312 *
gmsg <<
"* ********************************************************************************** " <<
endl;
313 *
gmsg <<
"* Selected Tracking Method == PARALLEL-T, FOLLOWUP TRACK" <<
endl;
314 *
gmsg <<
"* ********************************************************************************** " <<
endl;
317 *
gmsg <<
"* ********************************************************************************** " <<
endl;
318 *
gmsg <<
"* Selected Tracking Method == PARALLEL-T, NEW TRACK" <<
endl;
319 *
gmsg <<
"* ********************************************************************************** " <<
endl;
344 }
else if (isFollowupTrack) {
380 *
gmsg << std::scientific;
390 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
446 if (distr_str.size() == 0) {
453 double macromass = 0.0;
454 double macrocharge = 0.0;
514 *
gmsg <<
"* Mass of simulation particle= " << macromass <<
" GeV/c^2" <<
endl;
515 *
gmsg <<
"* Charge of simulation particle= " << macrocharge <<
" [C]" <<
endl;
530 *
gmsg <<
"* ********************************************************************************** " <<
endl;
531 *
gmsg <<
"* Selected Tracking Method == CYCLOTRON-T, NEW TRACK" <<
endl;
532 *
gmsg <<
"* ********************************************************************************** " <<
endl;
534 *
gmsg <<
"* ********************************************************************************** " <<
endl;
535 *
gmsg <<
"* Selected Tracking Method == CYCLOTRON-T, FOLLOWUP TRACK" <<
endl;
536 *
gmsg <<
"* ********************************************************************************** " <<
endl;
538 *
gmsg <<
"* Number of neighbour bunches = " << specifiedNumBunch <<
endl;
544 *
gmsg <<
"* ********************************************************************************** " <<
endl;
550 specifiedNumBunch, mbEta, mbPara, mbMode, mbBinning);
572 if ( specifiedNumBunch > 1 ) {
589 if (
fs->
getType() != std::string(
"NONE")) {
599 "The number of simulation particles (" + std::to_string(numParticles) +
") \n" +
600 "is smaller than the number of gridpoints (" + std::to_string(numGridPoints) +
").\n" +
601 "Please increase the number of particles or reduce the size of the mesh.\n");
643 std::vector<std::string> distributionArray
645 const size_t numberOfDistributions = distributionArray.size();
647 if (numberOfDistributions == 0) {
653 if (numberOfDistributions > 1) {
655 <<
"---------------------------------" <<
endl
656 <<
"Found more than one distribution:" <<
endl <<
endl;
657 *
gmsg <<
"Main Distribution" <<
endl
658 <<
"---------------------------------" <<
endl
659 << distributionArray.at(0) <<
endl <<
endl
660 <<
"Secondary Distribution(s)" <<
endl
661 <<
"---------------------------------" <<
endl;
663 for (
size_t i = 1; i < numberOfDistributions; ++ i) {
668 *
gmsg << distributionArray.at(i) <<
endl;
671 <<
"---------------------------------" <<
endl <<
endl;
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
#define OPAL_VERSION_MINOR
#define OPAL_VERSION_MAJOR
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Inform & level2(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 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()
void setPType(std::string type)
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.
virtual void execute()
Apply the algorithm to the top-level beamline.
static Distribution * find(const std::string &name)
void createOpalCycl(PartBunchBase< double, 3 > *beam, size_t numberOfParticles, double current, const Beamline &bl)
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.
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.
int timeIntegrator
The ID of time integrator.
std::vector< double > zstop
The location at which the simulation stops.
static Track * block
The block of track data.
int truncOrder
Trunction order for map tracking.
std::vector< double > dT
The initial timestep.
H5PartWrapper * phaseSpaceSink_m
virtual void execute()
Execute the command.
void initDataSink(const int &numBunch=1)
TrackRun()
Exemplar constructor.
std::vector< Distribution * > distrs_m
virtual TrackRun * clone(const std::string &name)
Make clone.
static const std::string defaultDistribution
double setDistributionParallelT(Beam *beam)
void setupCyclotronTracker()
The base class for all OPAL exceptions.