OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
PyScalingFFAMagnet.cpp
Go to the documentation of this file.
1 //
2 // Python API for OpalScalingFFAMagnet
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 //
17 #include "PyOpal/PyCore/Globals.h"
19 
22 
23 namespace PyOpal {
24 
31 template <>
34  dynamic_cast<ScalingFFAMagnet*>(object_m->getElement());
35  magnet->setupEndField();
36 }
37 
38 namespace PyScalingFFAMagnet {
39 
40 const char* module_docstring =
41  "scaling_ffa_magnet contains the ScalingFFAMagnet class";
42 
43 template <>
44 std::vector<PyOpalObjectNS::AttributeDef> PyOpalObjectNS::PyOpalObject<OpalScalingFFAMagnet>::attributes = {
45  {"B0", "b0", "", PyOpalObjectNS::DOUBLE},
46  {"R0", "r0", "", PyOpalObjectNS::DOUBLE},
47  {"FIELD_INDEX", "field_index", "", PyOpalObjectNS::DOUBLE},
48  {"TAN_DELTA", "tan_delta", "", PyOpalObjectNS::DOUBLE},
49  {"MAX_Y_POWER", "max_vertical_power", "", PyOpalObjectNS::INT},
50  {"END_FIELD_MODEL", "end_field_model", "", PyOpalObjectNS::STRING},
51  {"END_LENGTH", "end_length", "", PyOpalObjectNS::DOUBLE},
52  {"CENTRE_LENGTH", "centre_length", "", PyOpalObjectNS::DOUBLE},
53  {"HEIGHT", "height", "", PyOpalObjectNS::DOUBLE},
54  {"RADIAL_NEG_EXTENT", "radial_neg_extent", "", PyOpalObjectNS::DOUBLE},
55  {"RADIAL_POS_EXTENT", "radial_pos_extent", "", PyOpalObjectNS::DOUBLE},
56  {"MAGNET_START", "magnet_start", "", PyOpalObjectNS::DOUBLE},
57  {"MAGNET_END", "magnet_end", "", PyOpalObjectNS::DOUBLE},
58  {"AZIMUTHAL_EXTENT", "azimuthal_extent", "", PyOpalObjectNS::DOUBLE},
59 };
60 
61 template <>
63 "ScalingFFAMagnet class is a field element that models a Scaling FFA magnet.";
64 
65 std::string update_docstr =
66 "Check for changes to the EndFieldModel and update the ScalingFFAMagnet appropriately.\n"
67 "This is done automatically the first time the ScalingFFAMagnet is used but not for\n"
68 "subsequent uses. WARNING: if user changes the end field model, user must call\n"
69 "'update_end_field' manually to load the new parameters.\n"
70 "\n"
71 "May throw RuntimeError if the EndFieldModel is not valid or cannot be found.\n"
72 "\n"
73 "Returns None.\n";
74 
75 BOOST_PYTHON_MODULE(scaling_ffa_magnet) {
79  auto elementClass = element.make_element_class("ScalingFFAMagnet");
80  element.addGetFieldValue(elementClass, 1.0, 1.0, 1.0, 1e-1);
81 
82  elementClass.def("update_end_field", &PyOpalObjectNS::PyOpalObject<OpalScalingFFAMagnet>::doSetup, update_docstr.c_str());
83 }
84 
85 }
86 }
void Initialise()
Definition: Globals.cpp:50
BOOST_PYTHON_MODULE(scaling_ffa_magnet)
boost::python::class_< PyC > make_element_class(const char *className)
Definition: PyOpalObject.h:752
void addGetFieldValue(PYCLASS &pyclass, double distanceUnits, double timeUnits, double bfieldUnits, double efieldUnits)
Definition: PyOpalObject.h:805
constexpr double e
The value of .
Definition: Physics.h:39
item[EANGLE] Entrance edge counterclockwise This enables to obtain skew at each point along the magnet
Definition: multipole_t.tex:32