OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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//
19
22
23namespace PyOpal {
24
31 template <>
33 ScalingFFAMagnet* magnet = dynamic_cast<ScalingFFAMagnet*>(object_m->getElement());
34 magnet->setupEndField();
35 }
36
37 template <>
38 std::vector<PyOpalObjectNS::AttributeDef>
40 {"B0", "b0", "", PyOpalObjectNS::DOUBLE},
41 {"R0", "r0", "", PyOpalObjectNS::DOUBLE},
42 {"FIELD_INDEX", "field_index", "", PyOpalObjectNS::DOUBLE},
43 {"TAN_DELTA", "tan_delta", "", PyOpalObjectNS::DOUBLE},
44 {"MAX_Y_POWER", "max_vertical_power", "", PyOpalObjectNS::INT},
45 {"END_FIELD_MODEL", "end_field_model", "", PyOpalObjectNS::STRING},
46 {"END_LENGTH", "end_length", "", PyOpalObjectNS::DOUBLE},
47 {"CENTRE_LENGTH", "centre_length", "", PyOpalObjectNS::DOUBLE},
48 {"HEIGHT", "height", "", PyOpalObjectNS::DOUBLE},
49 {"RADIAL_NEG_EXTENT", "radial_neg_extent", "", PyOpalObjectNS::DOUBLE},
50 {"RADIAL_POS_EXTENT", "radial_pos_extent", "", PyOpalObjectNS::DOUBLE},
51 {"MAGNET_START", "magnet_start", "", PyOpalObjectNS::DOUBLE},
52 {"MAGNET_END", "magnet_end", "", PyOpalObjectNS::DOUBLE},
53 {"AZIMUTHAL_EXTENT", "azimuthal_extent", "", PyOpalObjectNS::DOUBLE},
54 };
55
56 template <>
58 "ScalingFFAMagnet class is a field element that models a Scaling FFA magnet.";
59
61
62 const char* module_docstring = "scaling_ffa_magnet contains the ScalingFFAMagnet class";
63
64 std::string update_docstr =
65 "Check for changes to the EndFieldModel and update the ScalingFFAMagnet "
66 "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(
84 update_docstr.c_str());
85 }
86
87 } // namespace PyScalingFFAMagnet
88} // namespace PyOpal
void Initialise()
Definition Globals.cpp:50
BOOST_PYTHON_MODULE(scaling_ffa_magnet)
static std::vector< AttributeDef > attributes
void addGetFieldValue(PYCLASS &pyclass, double distanceUnits, double timeUnits, double bfieldUnits, double efieldUnits)
boost::python::class_< PyC > make_element_class(const char *className)