|
| 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/thermal/TabulatedScatteringFunction.hpp" |
| 8 | + |
| 9 | +// namespace aliases |
| 10 | +namespace python = pybind11; |
| 11 | + |
| 12 | +namespace dryad { |
| 13 | +namespace thermal { |
| 14 | + |
| 15 | +void wrapTabulatedScatteringFunction( python::module& module ) { |
| 16 | + |
| 17 | + // type aliases |
| 18 | + using Component = njoy::dryad::thermal::TabulatedScatteringFunction; |
| 19 | + using InterpolationType = njoy::dryad::InterpolationType; |
| 20 | + |
| 21 | + // wrap views created by this component |
| 22 | + |
| 23 | + // create the component |
| 24 | + python::class_< Component > component( |
| 25 | + |
| 26 | + module, |
| 27 | + "TabulatedScatteringFunction", |
| 28 | + "A tabulated scattering function S(alpha)\n\n" |
| 29 | + "Parameters\n" |
| 30 | + "----------\n" |
| 31 | + " momentum_transfers : list of float\n" |
| 32 | + " the momentum transfer values\n" |
| 33 | + " values : list of float\n" |
| 34 | + " the scattering function values\n" |
| 35 | + " boundaries : list of int\n" |
| 36 | + " the boundaries of the interpolation regions\n" |
| 37 | + " interpolants : list of njoy.dryad.InterpolationType\n" |
| 38 | + " the interpolation types of the interpolation regions\n" |
| 39 | + " interpolant : njoy.dryad.InterpolationType, default njoy.dryad.InterpolationType.LinearLinear\n" |
| 40 | + " the interpolation type (default lin-lin)" |
| 41 | + ); |
| 42 | + |
| 43 | + // wrap the component |
| 44 | + component |
| 45 | + .def( |
| 46 | + |
| 47 | + python::init< std::vector< double >, std::vector< double >, |
| 48 | + std::vector< std::size_t >, |
| 49 | + std::vector< InterpolationType > >(), |
| 50 | + python::arg( "momentum_transfers" ), python::arg( "values" ), |
| 51 | + python::arg( "boundaries" ), python::arg( "interpolants" ), |
| 52 | + "Initialise the scattering function table with multiple interpolation zones" |
| 53 | + ) |
| 54 | + .def( |
| 55 | + |
| 56 | + python::init< std::vector< double >, std::vector< double >, |
| 57 | + InterpolationType >(), |
| 58 | + python::arg( "momentum_transfers" ), python::arg( "values" ), |
| 59 | + python::arg( "interpolant" ) = InterpolationType::LinearLinear, |
| 60 | + "Initialise the scattering function table with a single interpolation zone" |
| 61 | + ) |
| 62 | + .def_property_readonly( |
| 63 | + |
| 64 | + "momentum_transfers", |
| 65 | + &Component::momentumTransfers, |
| 66 | + "The momentum transfer values" |
| 67 | + ) |
| 68 | + .def_property_readonly( |
| 69 | + |
| 70 | + "values", |
| 71 | + &Component::values, |
| 72 | + "The scattering function values" |
| 73 | + ) |
| 74 | + .def_property_readonly( |
| 75 | + |
| 76 | + "lower_momentum_transfer_limit", |
| 77 | + &Component::lowerMomentumTransferLimit, |
| 78 | + "The lower momentum transfer limit" |
| 79 | + ) |
| 80 | + .def_property_readonly( |
| 81 | + |
| 82 | + "upper_momentum_transfer_limit", |
| 83 | + &Component::upperMomentumTransferLimit, |
| 84 | + "The upper momentum transfer limit" |
| 85 | + ) |
| 86 | + .def( |
| 87 | + |
| 88 | + "__call__", |
| 89 | + [] ( const Component& self, double momentumTransfer ) -> decltype(auto) |
| 90 | + { return self( momentumTransfer ); }, |
| 91 | + python::arg( "momentum_transfer" ), |
| 92 | + "Evaluate the scattering function for a given momentum transfer value\n\n" |
| 93 | + "Parameters\n" |
| 94 | + "----------\n" |
| 95 | + " momentum_transfer : float\n" |
| 96 | + " the momentum transfer value" |
| 97 | + ); |
| 98 | + |
| 99 | + // add standard equality comparison definitions |
| 100 | + addStandardEqualityComparisonDefinitions< Component >( component ); |
| 101 | + |
| 102 | + // add standard tabulated data definitions |
| 103 | + addStandardTabulatedDefinitions< Component >( component ); |
| 104 | + |
| 105 | + // add standard copy definitions |
| 106 | + addStandardCopyDefinitions< Component >( component ); |
| 107 | +} |
| 108 | + |
| 109 | +} // thermal namespace |
| 110 | +} // dryad namespace |
0 commit comments