OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
PyEndFieldModel.h
Go to the documentation of this file.
1
#ifndef PYELEMENTS_PYENDFIELDMODEL_H
2
#define PYELEMENTS_PYENDFIELDMODEL_H
3
4
#include "
PyOpal/PyCore/PyOpalObject.h
"
5
#include "
Classic/AbsBeamline/EndFieldModel/EndFieldModel.h
"
6
7
namespace
PyOpal
{
8
namespace
PyEndFieldModel
{
9
10
std::string
functionDocstring
=
11
"update the Enge object and then calculate the enge function or derivative\n"
12
"- x [float]: position at which to evaluate the function\n"
13
"- n [int]: derivative to calculate; 0 will return the enge function, 1 will\n"
14
" return the 1st derivative, etc. Note that floating point precision\n"
15
" becomes increasingly limiting for n > 10 or so.\n"
16
"Returns the function value or derivative.\n"
;
17
18
template
<
class
C>
19
double
function
(
PyOpalObjectNS::PyOpalObject<C>
pyobject,
double
x,
int
n) {
20
if
(n < 0) {
21
throw
OpalException
(
"n must be positive as it indexes the derivative"
,
22
"PyEndFieldModel::function"
);
23
}
24
std::shared_ptr<C> objectPtr = pyobject.
getOpalShared
();
25
objectPtr->update();
26
std::string
name
= objectPtr->getOpalName();
27
std::shared_ptr<endfieldmodel::EndFieldModel> model =
endfieldmodel::EndFieldModel::getEndFieldModel
(
name
);
28
model->setMaximumDerivative(n);
29
double
value = model->function(x, n);
30
return
value;
31
}
32
33
}
34
}
35
36
#endif
// PYELEMENTS_PYENDFIELDMODEL_H
PyOpalObject.h
EndFieldModel.h
name
const std::string name
Definition
MaxNormRadialPeak.cpp:32
PyOpal
Definition
ExceptionTranslation.cpp:21
PyOpal::PyEndFieldModel
Definition
PyEndFieldModel.h:8
PyOpal::PyEndFieldModel::function
double function(PyOpalObjectNS::PyOpalObject< C > pyobject, double x, int n)
Definition
PyEndFieldModel.h:19
PyOpal::PyEndFieldModel::functionDocstring
std::string functionDocstring
Definition
PyEndFieldModel.h:10
endfieldmodel::EndFieldModel::getEndFieldModel
static std::shared_ptr< EndFieldModel > getEndFieldModel(std::string name)
Definition
EndFieldModel.cpp:63
PyOpal::PyOpalObjectNS::PyOpalObject
Definition
PyOpalObject.h:138
PyOpal::PyOpalObjectNS::PyOpalObject::getOpalShared
std::shared_ptr< C > getOpalShared()
Definition
PyOpalObject.h:286
OpalException
The base class for all OPAL exceptions.
Definition
OpalException.h:28