|
| 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/ThermalScattering.hpp" |
| 8 | +#include "njoy/dryad/format/endf/createThermalScatteringFromFile.hpp" |
| 9 | +#include "njoy/dryad/format/gnds/createThermalScatteringFromFile.hpp" |
| 10 | + |
| 11 | +// namespace aliases |
| 12 | +namespace python = pybind11; |
| 13 | + |
| 14 | +namespace dryad { |
| 15 | + |
| 16 | +void wrapThermalScattering( python::module& module ) { |
| 17 | + |
| 18 | + // type aliases |
| 19 | + using Component = njoy::dryad::ThermalScattering; |
| 20 | + using Documentation = njoy::dryad::Documentation; |
| 21 | + using IncoherentElasticScattering = njoy::dryad::thermal::IncoherentElasticScattering; |
| 22 | + |
| 23 | + // wrap views created by this component |
| 24 | + |
| 25 | + // create the component |
| 26 | + python::class_< Component > component( |
| 27 | + |
| 28 | + module, |
| 29 | + "ThermalScattering", |
| 30 | + "Thermal scattering data\n\n" |
| 31 | + "Parameters\n" |
| 32 | + "----------\n" |
| 33 | + " documentation : njoy.dryad.Documentation\n" |
| 34 | + " the documentation associated to the thermal sacttering data\n" |
| 35 | + " incoherent : njoy.dryad.thermal.IncoherentElasticScattering\n" |
| 36 | + " incoherent elastic scattering data (default: none)" |
| 37 | + ); |
| 38 | + |
| 39 | + // wrap the component |
| 40 | + component |
| 41 | + .def( |
| 42 | + |
| 43 | + python::init< Documentation, |
| 44 | + std::optional< IncoherentElasticScattering > >(), |
| 45 | + python::arg( "documentation" ), |
| 46 | + python::arg( "incoherent" ) = std::nullopt, |
| 47 | + "Initialise the thermal scattering data with documentation" |
| 48 | + ) |
| 49 | + .def( |
| 50 | + |
| 51 | + python::init< std::optional< IncoherentElasticScattering > >(), |
| 52 | + python::arg( "incoherent" ) = std::nullopt, |
| 53 | + "Initialise the thermal scattering data without documentation" |
| 54 | + ) |
| 55 | + .def_property( |
| 56 | + |
| 57 | + "documentation", |
| 58 | + python::overload_cast<>( &Component::documentation, python::const_ ), |
| 59 | + python::overload_cast< Documentation >( &Component::documentation ), |
| 60 | + "The documentation" |
| 61 | + ) |
| 62 | + .def_property( |
| 63 | + |
| 64 | + "incoherent_elastic_scattering", |
| 65 | + python::overload_cast<>( &Component::incoherentElasticScattering, python::const_ ), |
| 66 | + python::overload_cast< std::optional< IncoherentElasticScattering > >( &Component::incoherentElasticScattering ), |
| 67 | + "The incoherent elastic data" |
| 68 | + ) |
| 69 | + .def_property_readonly( |
| 70 | + |
| 71 | + "has_coherent_elastic_scattering", |
| 72 | + &Component::hasCoherentElasticScattering, |
| 73 | + "Return whether or not there is coherent elastic scattering" |
| 74 | + ) |
| 75 | + .def_property_readonly( |
| 76 | + |
| 77 | + "has_incoherent_elastic_scattering", |
| 78 | + &Component::hasIncoherentElasticScattering, |
| 79 | + "Return whether or not there is incoherent elastic scattering" |
| 80 | + ) |
| 81 | + .def_property_readonly( |
| 82 | + |
| 83 | + "has_elastic_scattering", |
| 84 | + &Component::hasElasticScattering, |
| 85 | + "Return whether or not there is elastic scattering (coherent and/or incoherent)" |
| 86 | + ) |
| 87 | + .def_property_readonly( |
| 88 | + |
| 89 | + "has_inelastic_scattering", |
| 90 | + &Component::hasInelasticScattering, |
| 91 | + "Return whether or not there is inelastic scattering" |
| 92 | + ) |
| 93 | + .def_static( |
| 94 | + |
| 95 | + "from_endf_file", |
| 96 | + [] ( const std::string& filename ) -> decltype(auto) { |
| 97 | + |
| 98 | + return njoy::dryad::format::endf::createThermalScatteringFromFile( filename ); |
| 99 | + }, |
| 100 | + python::arg( "filename" ), |
| 101 | + "Create ThermalScattering data from an ENDF file\n\n" |
| 102 | + "If there are multiple materials in the ENDF file, only the first material\n" |
| 103 | + "will be transformed into a ThermalScattering instance.\n\n" |
| 104 | + "Parameters\n" |
| 105 | + "----------\n" |
| 106 | + " filename : string\n" |
| 107 | + " the ENDF file name" |
| 108 | + ) |
| 109 | + .def_static( |
| 110 | + |
| 111 | + "from_gnds_file", |
| 112 | + [] ( const std::string& filename, const std::string& style ) -> decltype(auto) { |
| 113 | + |
| 114 | + return njoy::dryad::format::gnds::createThermalScatteringFromFile( filename, style ); |
| 115 | + }, |
| 116 | + python::arg( "filename" ), python::arg( "style" ) = "eval", |
| 117 | + "Create ThermalScattering data from a GNDS file\n\n" |
| 118 | + "Parameters\n" |
| 119 | + "----------\n" |
| 120 | + " filename : string\n" |
| 121 | + " the GNDS file name\n" |
| 122 | + " style : string\n" |
| 123 | + " the GNDS style to process (default is eval)" |
| 124 | + ); |
| 125 | + |
| 126 | + // add standard equality comparison definitions |
| 127 | + addStandardEqualityComparisonDefinitions< Component >( component ); |
| 128 | + |
| 129 | + // add standard copy definitions |
| 130 | + addStandardCopyDefinitions< Component >( component ); |
| 131 | +} |
| 132 | + |
| 133 | +} // dryad namespace |
0 commit comments