|
| 1 | +// system includes |
| 2 | +#include <pybind11/pybind11.h> |
| 3 | +#include <pybind11/stl.h> |
| 4 | + |
| 5 | +// local includes |
| 6 | +#include "dryad/definitions.hpp" |
| 7 | +#include "njoy/dryad/resonances/SammyBackground.hpp" |
| 8 | + |
| 9 | +// namespace aliases |
| 10 | +namespace python = pybind11; |
| 11 | + |
| 12 | +namespace dryad { |
| 13 | +namespace resonances { |
| 14 | + |
| 15 | +void wrapSammyBackground( python::module& module ) { |
| 16 | + |
| 17 | + // type aliases |
| 18 | + using Component = njoy::dryad::resonances::SammyBackground; |
| 19 | + |
| 20 | + // wrap views created by this component |
| 21 | + |
| 22 | + // create the component |
| 23 | + python::class_< Component > component( |
| 24 | + |
| 25 | + module, |
| 26 | + "SammyBackground", |
| 27 | + "A channel background using the SAMMY parametrisation\n\n" |
| 28 | + "The SAMMY parametrisation of a channel background is a function\n" |
| 29 | + "of energy consisting of a quadratic polynomial and a logarithmic\n" |
| 30 | + "term. It is characterised by 7 parameters:\n" |
| 31 | + " - 3 coefficients of the polymonial term (R0, R1 and R2)\n" |
| 32 | + " - 2 constants for the logarithmic term (S0 and S1)\n" |
| 33 | + " - 2 logarithmic singularity values (Ed and Eu, given in eV)\n" |
| 34 | + ); |
| 35 | + |
| 36 | + // wrap the component |
| 37 | + component |
| 38 | + .def( |
| 39 | + |
| 40 | + python::init< std::array< double, 3 >, |
| 41 | + std::array< double, 2 >, |
| 42 | + double, double >(), |
| 43 | + python::arg( "polynomial_coefficients" ), |
| 44 | + python::arg( "logarithmic_coefficients" ), |
| 45 | + python::arg( "lower_singularity" ), |
| 46 | + python::arg( "upper_singularity" ), |
| 47 | + "Initialise the background function\n\n" |
| 48 | + "Parameters\n" |
| 49 | + "----------\n" |
| 50 | + " polynomial_coefficients : list of float\n" |
| 51 | + " the coefficients of the polymonial term (order 2)\n" |
| 52 | + " logarithmic_coefficients : list of float\n" |
| 53 | + " the coefficients of the logarithmic term (order 1)\n" |
| 54 | + " lower_singularity : float\n" |
| 55 | + " the lower logarithmic singularity values\n" |
| 56 | + " upper_singularity : float\n" |
| 57 | + " the upper logarithmic singularity values\n" |
| 58 | + ) |
| 59 | + .def_property_readonly( |
| 60 | + |
| 61 | + "polynomial_coefficients", |
| 62 | + &Component::polynomialCoefficients, |
| 63 | + "The coefficients of the polynomial term" |
| 64 | + ) |
| 65 | + .def_property_readonly( |
| 66 | + |
| 67 | + "logarithmic_coefficients", |
| 68 | + &Component::logarithmicCoefficients, |
| 69 | + "The coefficients of the logarithmic term" |
| 70 | + ) |
| 71 | + .def_property_readonly( |
| 72 | + |
| 73 | + "lower_singularity", |
| 74 | + &Component::lowerSingularity, |
| 75 | + "The logarithmic singularity below the energy range" |
| 76 | + ) |
| 77 | + .def_property_readonly( |
| 78 | + |
| 79 | + "upper_singularity", |
| 80 | + &Component::upperSingularity, |
| 81 | + "The logarithmic singularity above the energy range" |
| 82 | + ) |
| 83 | + .def( |
| 84 | + |
| 85 | + "__call__", |
| 86 | + [] ( const Component& self, double energy ) -> decltype(auto) |
| 87 | + { return self( energy ); }, |
| 88 | + python::arg( "energy" ), |
| 89 | + "Evaluate the background function for a given energy value\n\n" |
| 90 | + "Parameters\n" |
| 91 | + "----------\n" |
| 92 | + " energy : float\n" |
| 93 | + " the energy value" |
| 94 | + ); |
| 95 | + |
| 96 | + // add standard equality comparison definitions |
| 97 | + addStandardEqualityComparisonDefinitions< Component >( component ); |
| 98 | + |
| 99 | + // add standard copy definitions |
| 100 | + addStandardCopyDefinitions< Component >( component ); |
| 101 | +} |
| 102 | + |
| 103 | +} // resonances namespace |
| 104 | +} // dryad namespace |
0 commit comments