OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
PyTrackCmd.cpp
Go to the documentation of this file.
1//
2// Python API for TrackCmd
3//
4// Copyright (c) 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
5//
6// This file is part of OPAL.
7//
8// OPAL is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12//
13// You should have received a copy of the GNU General Public License
14// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
15//
16
20
21#include "Track/TrackCmd.h"
22
23namespace PyOpal {
24 template <>
25 std::vector<PyOpalObjectNS::AttributeDef> PyOpalObjectNS::PyOpalObject<TrackCmd>::attributes = {
26 {"LINE", "line", "", PyOpalObjectNS::STRING},
27 {"BEAM", "beam", "", PyOpalObjectNS::STRING},
28 {"DT", "time_steps", "", PyOpalObjectNS::DOUBLE}, // array
29 {"DTSCINIT", "dt_space_charge", "", PyOpalObjectNS::DOUBLE},
30 {"DTAU", "dtau", "", PyOpalObjectNS::DOUBLE},
31 {"T0", "t0", "", PyOpalObjectNS::DOUBLE},
32 {"MAXSTEPS", "max_steps", "", PyOpalObjectNS::FLOAT_LIST},
33 {"STEPSPERTURN", "steps_per_turn", "", PyOpalObjectNS::DOUBLE},
34 {"ZSTART", "z_start", "", PyOpalObjectNS::DOUBLE},
35 {"ZSTOP", "z_stop", "", PyOpalObjectNS::FLOAT_LIST},
36 {"TIMEINTEGRATOR", "time_integrator", "", PyOpalObjectNS::PREDEFINED_STRING},
37 {"MAP_ORDER", "map_order", "", PyOpalObjectNS::DOUBLE},
38 };
39
40 namespace PyTrackCmdNS {
41
42 // Can't use the default PyObject execute function because we need to call
43 // setIsParseable to false (otherwise OPAL will try to parse it as an OPAL file)
45 std::shared_ptr<TrackCmd> objectPtr = cmd.getOpalShared();
46 objectPtr->setIsParseable(false);
47 objectPtr->execute();
48 }
49
54 auto trackClass = trackCmd.make_class("Track");
55 trackClass.def("execute", &executeWrapper);
56 }
57
58 } // namespace PyTrackCmdNS
59} // namespace PyOpal
void Initialise()
Definition Globals.cpp:50
void executeWrapper(PyOpalObjectNS::PyOpalObject< TrackCmd > &cmd)
static std::vector< AttributeDef > attributes
std::shared_ptr< C > getOpalShared()
boost::python::class_< PyC > make_class(const char *className)