OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
PyVariableRFCavity.cpp
Go to the documentation of this file.
1//
2// Python API for OpalVariableRFCavity
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#include "Physics/Units.h"
23
24namespace PyOpal {
25
33 template <>
35 object_m->update();
36 VariableRFCavity* rf = dynamic_cast<VariableRFCavity*>(object_m->getElement());
37 rf->initialise();
38 }
39
40 template <>
41 std::vector<PyOpalObjectNS::AttributeDef>
43 {"PHASE_MODEL", "phase_model", "", PyOpalObjectNS::STRING},
44 {"AMPLITUDE_MODEL", "amplitude_model", "", PyOpalObjectNS::STRING},
45 {"FREQUENCY_MODEL", "frequency_model", "", PyOpalObjectNS::STRING},
46 {"WIDTH", "width", "", PyOpalObjectNS::DOUBLE},
47 {"HEIGHT", "height", "", PyOpalObjectNS::DOUBLE},
48 {"L", "length", "", PyOpalObjectNS::DOUBLE},
49 };
50
51 template <>
53 "VariableRFCavity class is a field element that models a rectangular RF cavity.";
54
55 namespace PyVariableRFCavity {
56
57 const char* module_docstring = "variable_rf_cavity contains the VariableRFCavity class";
58
59 BOOST_PYTHON_MODULE(variable_rf_cavity) {
63 auto elementClass = element.make_element_class("VariableRFCavity");
64 element.addGetFieldValue(elementClass, 1.0, Units::s2ns, 1.0, 1e-1);
65 elementClass.def(
66 "update_time_dependence",
68 }
69 } // namespace PyVariableRFCavity
70} // namespace PyOpal
constexpr double e
The value of.
Definition: Physics.h:39
constexpr double s2ns
Definition: Units.h:44
void registerExceptions()
Register exception translations with boost.
void Initialise()
Globals namespace provides routines to initialise global objects:
Definition: Globals.cpp:50
BOOST_PYTHON_MODULE(variable_rf_cavity)
Generates a field like E = a(t) * sin{2*pi * integral(f(tau),0,t) + q(t)} B = 0 where E0,...
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Initialise ready for tracking.
PyOpalObject<C> is the basic wrapper class for Opal Objects.
Definition: PyOpalObject.h:138
void addGetFieldValue(PYCLASS &pyclass, double distanceUnits, double timeUnits, double bfieldUnits, double efieldUnits)
Add a "get_field_value" method to the python class (for elements that expose a field)
Definition: PyOpalObject.h:805
virtual void doSetup()
Overload the method to perform any additional setup that can be made before the OpalObject is accesse...
Definition: PyOpalObject.h:258
boost::python::class_< PyC > make_element_class(const char *className)
This is the basic method to make a class for elements.
Definition: PyOpalObject.h:752