55#include <boost/assign.hpp>
80 boost::assign::list_of<const boost::bimap<TrackRun::RunMethod, std::string>::relation>(
81 RunMethod::PARALLEL,
"PARALLEL");
86 "The \"RUN\" sub-command tracks the defined particles through "
87 "the given lattice."),
99 "METHOD",
"Name of tracking algorithm to use.", {
"PARALLEL"});
103 "Number of turns to be tracked; Number of neighboring bunches to be tracked in cyclotron.",
112 "BOUNDARYGEOMETRY",
"Boundary geometry to be used NONE (default).",
"NONE");
143 ippl::NDIndex<3> domain;
144 for (
unsigned i = 0; i < 3; i++) {
145 domain[i] = ippl::Index(
nr[i]);
148 std::array<bool, 3> isParallel;
150 for (
unsigned d = 0; d < 3; ++d) {
151 isParallel[d] =
true;
169 bool newerChanges =
false;
171 if (it->first > fileVersion) {
177 Inform errorMsg(
"Error");
178 errorMsg <<
"\n******************** V E R S I O N M I S M A T C H "
179 "***********************\n"
182 if (it->first > fileVersion) {
183 errorMsg << it->second << endl;
187 <<
"* Make sure you do understand these changes and adjust your input file \n"
188 <<
"* accordingly. Then add\n"
189 <<
"* OPTION, VERSION = " << currentVersion <<
";\n"
190 <<
"* to your input file. " << endl;
191 errorMsg <<
"\n************************************************************************"
194 throw OpalException(
"TrackRun::execute",
"Version mismatch");
201 "TrackRun::execute",
"\"DISTRIBUTION\" must be set in \"RUN\" command.");
204 throw OpalException(
"TrackRun::execute",
"\"FIELDSOLVER\" must be set in \"RUN\" command.");
207 throw OpalException(
"TrackRun::execute",
"\"BEAM\" must be set in \"RUN\" command.");
228 std::vector<std::string> distributionArray =
230 const size_t numberOfDistributions = distributionArray.size();
232 *
gmsg <<
"* Number of distributions " << numberOfDistributions << endl;
246 *
gmsg << *beam << endl;
264 bunch_m->setCouplingConstant(cc);
276 throw OpalException(
"TrackRun::execute",
"Unknown \"METHOD\" for the \"RUN\" command");
299 if (ippl::Comm->rank() == 0) {
300 long number_of_processors = sysconf(_SC_NPROCESSORS_ONLN);
301 *
gmsg <<
"number_of_processors " << number_of_processors << endl;
306 MPI_Comm_size( MPI_COMM_WORLD, &world_size );
307 *
gmsg <<
"MPI_Comm_size " << world_size << endl;
310 static IpplTimings::TimerRef samplingTime = IpplTimings::getTimer(
"samplingTime");
311 IpplTimings::startTimer(samplingTime);
318 auto pc =
bunch_m->getParticleContainer();
319 auto fc =
bunch_m->getFieldContainer();
323 std::shared_ptr<Distribution> opalDist(
dist_m);
325 switch (opalDist->getType()){
327 sampler_m = std::make_shared<Gaussian>(pc, fc, opalDist);
330 sampler_m = std::make_shared<MultiVariateGaussian>(pc, fc, opalDist);
333 sampler_m = std::make_shared<FlatTop>(pc, fc, opalDist);
336 throw OpalException(
"Distribution::create",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
339 *
gmsg <<
"* About to create particles ..." << endl;
341 static IpplTimings::TimerRef GenParticlesTimer = IpplTimings::getTimer(
"GenParticles");
342 IpplTimings::startTimer(GenParticlesTimer);
346 IpplTimings::stopTimer(GenParticlesTimer);
348 *
gmsg <<
"* Particle creation done" << endl;
350 IpplTimings::stopTimer(samplingTime);
370 if (
bunch_m->getTotalNum() > 0) {
376 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
412 "TrackRun::setRunMethod",
"The attribute \"METHOD\" isn't set for the \"RUN\" command");
460 if (
opal_m->inRestartRun()) {
462 opal_m->getInputBasename() + std::string(
".h5"),
opal_m->getRestartStep(),
466 opal_m->getInputBasename() + std::string(
".h5"), -1,
467 opal_m->getInputBasename() + std::string(
".h5"), H5_O_WRONLY);
473 if (!
opal_m->inRestartRun()) {
474 if (!
opal_m->hasDataSinkAllocated()) {
491 const std::string geomDescriptor =
501 os <<
"* ************* T R A C K R U N *************************************************** "
504 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", NEW TRACK" <<
'\n'
506 "********************************************************************************** "
509 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", FOLLOWUP TRACK" <<
'\n'
511 "********************************************************************************** "
518 <<
"* MAXSTEPS = " <<
Track::block->localTimeSteps.front() <<
'\n'
521 os <<
"* ********************************************************************************** ";
#define OPAL_VERSION_MINOR
#define OPAL_VERSION_MAJOR
ippl::Vector< T, Dim > Vector_t
PartBunch< T, Dim >::ConstIterator begin(PartBunch< T, Dim > const &bunch)
Defines the FlatTop class used for sampling emitting particles.
ippl::detail::size_type size_type
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
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 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
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 setGlobalGeometry(BoundaryGeometry *bg)
static Distribution * find(const std::string &name)
double getChargePerParticle() const
Charge per macro particle in C.
double getMomentum() const
static Beam * find(const std::string &name)
Find named BEAM.
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 FieldSolverCmd * find(const std::string &name)
Find named FieldSolverCmd.
static Track * block
The block of track data.
void setupBoundaryGeometry()
std::shared_ptr< SamplingBase > sampler_m
H5PartWrapper * phaseSpaceSink_m
virtual void execute()
Execute the command.
std::shared_ptr< FieldSolverCmd > fs_m
std::shared_ptr< Distribution > dist_m
TrackRun()
Exemplar constructor.
std::shared_ptr< bunch_type > bunch_m
virtual TrackRun * clone(const std::string &name)
Make clone.
std::string getRunMethodName() const
Inform & print(Inform &os) const
static const boost::bimap< RunMethod, std::string > stringMethod_s
The base class for all OPAL exceptions.