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."),
88 itsTracker_m(nullptr),
92 phaseSpaceSink_m(nullptr),
93 isFollowupTrack_m(false),
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");
126 itsTracker_m(nullptr),
130 phaseSpaceSink_m(nullptr),
131 isFollowupTrack_m(false),
144 for (
unsigned i = 0; i < 3; 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) {
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;
255 *
gmsg <<
"* Particles per macro particle: " << part_per_macro_ratio <<
endl;
278 bunch_m->setCouplingConstant(cc);
290 throw OpalException(
"TrackRun::execute",
"Unknown \"METHOD\" for the \"RUN\" command");
314 long number_of_processors = sysconf(_SC_NPROCESSORS_ONLN);
315 *
gmsg <<
"number_of_processors " << number_of_processors <<
endl;
320 MPI_Comm_size( MPI_COMM_WORLD, &world_size );
321 *
gmsg <<
"MPI_Comm_size " << world_size <<
endl;
332 auto pc =
bunch_m->getParticleContainer();
333 auto fc =
bunch_m->getFieldContainer();
337 std::shared_ptr<Distribution> opalDist(
dist_m);
339 switch (opalDist->getType()){
341 sampler_m = std::make_shared<Gaussian>(pc, fc, opalDist);
344 sampler_m = std::make_shared<MultiVariateGaussian>(pc, fc, opalDist);
347 sampler_m = std::make_shared<FlatTop>(pc, fc, opalDist);
350 throw OpalException(
"Distribution::create",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
353 *
gmsg <<
"* About to create particles ..." <<
endl;
362 *
gmsg <<
"* Particle creation done" <<
endl;
384 if (
bunch_m->getTotalNum() > 0) {
390 while (i + 1 < zstop.size() && zstop[i + 1] < spos) {
426 "TrackRun::setRunMethod",
"The attribute \"METHOD\" isn't set for the \"RUN\" command");
505 const std::string geomDescriptor =
515 os <<
"* ************* T R A C K R U N *************************************************** "
518 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", NEW TRACK" <<
'\n'
520 "********************************************************************************** "
523 os <<
"* Selected Tracking Method == " <<
getRunMethodName() <<
", FOLLOWUP TRACK" <<
'\n'
525 "********************************************************************************** "
535 os <<
"* ********************************************************************************** ";
#define OPAL_VERSION_MINOR
#define OPAL_VERSION_MAJOR
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
Inform & endl(Inform &inf)
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 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
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
std::unique_ptr< mpi::Communicator > Comm
The base class for all OPAL actions.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
std::vector< Attribute > itsAttr
The object attributes.
std::string getInputBasename()
get input file name without extension
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
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
static OpalData * getInstance()
void setGlobalGeometry(BoundaryGeometry *bg)
bool inRestartRun()
true if we do a restart run
void setLocalTrackStep(long long n)
step in a TRACK command
virtual void execute()
Apply the algorithm to the top-level beamline.
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 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)
static FieldSolverCmd * find(const std::string &name)
Find named FieldSolverCmd.
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.
PartBunch_t * bunch
The particle bunch to be tracked.
std::vector< double > dT
The initial timestep.
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.
Timing::TimerRef TimerRef
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)