Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/distributions part6 #11

Merged
merged 6 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ if( dryad.python )
python/src/TabulatedAngularDistributions.python.cpp
python/src/TabulatedEnergyDistribution.python.cpp
python/src/TabulatedEnergyDistributions.python.cpp
python/src/TabulatedFormFactor.python.cpp
python/src/TabulatedScatteringFunction.python.cpp
python/src/TwoBodyDistributionData.python.cpp
python/src/UncorrelatedDistributionData.python.cpp
python/src/ReactionProduct.python.cpp
Expand Down
2 changes: 2 additions & 0 deletions cmake/unit_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ endfunction()

add_subdirectory( src/dryad/id/ElementID/test )

add_subdirectory( src/dryad/TabulatedFormFactor/test )
add_subdirectory( src/dryad/TabulatedScatteringFunction/test )
add_subdirectory( src/dryad/TabulatedMultiplicity/test )
add_subdirectory( src/dryad/TabulatedAverageEnergy/test )
add_subdirectory( src/dryad/LegendreAngularDistribution/test )
Expand Down
2 changes: 2 additions & 0 deletions cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ add_python_test( TabulatedAngularDistribution Test_dryad_TabulatedAngularDistri
add_python_test( TabulatedAngularDistributions Test_dryad_TabulatedAngularDistributions.py )
add_python_test( TabulatedEnergyDistribution Test_dryad_TabulatedEnergyDistribution.py )
add_python_test( TabulatedEnergyDistributions Test_dryad_TabulatedEnergyDistributions.py )
add_python_test( TabulatedFormFactor Test_dryad_TabulatedFormFactor.py )
add_python_test( TabulatedScatteringFunction Test_dryad_TabulatedScatteringFunction.py )
add_python_test( TwoBodyDistributionData Test_dryad_TwoBodyDistributionData.py )
add_python_test( UncorrelatedDistributionData Test_dryad_UncorrelatedDistributionData.py )
add_python_test( ReactionProduct Test_dryad_ReactionProduct.py )
Expand Down
100 changes: 100 additions & 0 deletions python/src/TabulatedFormFactor.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/operators.h>

// local includes
#include "definitions.hpp"
#include "dryad/TabulatedFormFactor.hpp"

// namespace aliases
namespace python = pybind11;

void wrapTabulatedFormFactor( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::TabulatedFormFactor;
using InterpolationType = njoy::dryad::InterpolationType;
using ToleranceConvergence = njoy::dryad::ToleranceConvergence;

// wrap views created by this component

// create the component
python::class_< Component > component(

module,
"TabulatedFormFactor",
"A form factor table"
);

// wrap the component
component
.def(

python::init< std::vector< double >, std::vector< double >,
std::vector< std::size_t >,
std::vector< InterpolationType > >(),
python::arg( "energies" ), python::arg( "values" ),
python::arg( "boundaries" ), python::arg( "interpolants" ),
"Initialise the form factor table\n\n"
"Arguments:\n"
" self the form factor table\n"
" energies the energy values\n"
" values the form factor values\n"
" boundaries the boundaries of the interpolation regions\n"
" interpolants the interpolation types of the interpolation regions,\n"
" see InterpolationType for all interpolation types"
)
.def(

python::init< std::vector< double >, std::vector< double >,
InterpolationType >(),
python::arg( "energies" ), python::arg( "values" ),
python::arg( "interpolant" ) = InterpolationType::LinearLinear,
"Initialise the form factor table\n\n"
"Arguments:\n"
" self the form factor table\n"
" energies the energy values\n"
" values the form factor values\n"
" interpolant the interpolation type (default lin-lin),\n"
" see InterpolationType for all interpolation types"
)
.def_property_readonly(

"energies",
&Component::energies,
"The energy values"
)
.def_property_readonly(

"values",
&Component::values,
"The form factor values"
)
.def_property_readonly(

"lower_energy_limit",
&Component::lowerEnergyLimit,
"The lower energy limit"
)
.def_property_readonly(

"upper_energy_limit",
&Component::upperEnergyLimit,
"The upper energy limit"
)
.def(

"__call__",
[] ( const Component& self, double energy ) -> decltype(auto)
{ return self( energy ); },
python::arg( "energy" ),
"Evaluate the table for a given energy value\n\n"
"Arguments:\n"
" self the table\n"
" energy the energy value"
);

// add standard tabulated data definitions
addStandardTabulatedDefinitions< Component >( component );
}
100 changes: 100 additions & 0 deletions python/src/TabulatedScatteringFunction.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/operators.h>

// local includes
#include "definitions.hpp"
#include "dryad/TabulatedScatteringFunction.hpp"

// namespace aliases
namespace python = pybind11;

void wrapTabulatedScatteringFunction( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::TabulatedScatteringFunction;
using InterpolationType = njoy::dryad::InterpolationType;
using ToleranceConvergence = njoy::dryad::ToleranceConvergence;

// wrap views created by this component

// create the component
python::class_< Component > component(

module,
"TabulatedScatteringFunction",
"A scattering function table"
);

// wrap the component
component
.def(

python::init< std::vector< double >, std::vector< double >,
std::vector< std::size_t >,
std::vector< InterpolationType > >(),
python::arg( "inverse_lengths" ), python::arg( "values" ),
python::arg( "boundaries" ), python::arg( "interpolants" ),
"Initialise the scattering function table\n\n"
"Arguments:\n"
" self the scattering function table\n"
" inverse_lengths the inverse length values\n"
" values the scattering function values\n"
" boundaries the boundaries of the interpolation regions\n"
" interpolants the interpolation types of the interpolation regions,\n"
" see InterpolationType for all interpolation types"
)
.def(

python::init< std::vector< double >, std::vector< double >,
InterpolationType >(),
python::arg( "inverse_lengths" ), python::arg( "values" ),
python::arg( "interpolant" ) = InterpolationType::LinearLinear,
"Initialise the scattering function table\n\n"
"Arguments:\n"
" self the scattering function table\n"
" inverse_lengths the inverse length values\n"
" values the scattering function values\n"
" interpolant the interpolation type (default lin-lin),\n"
" see InterpolationType for all interpolation types"
)
.def_property_readonly(

"inverse_lengths",
&Component::inverseLengths,
"The inverse length values"
)
.def_property_readonly(

"values",
&Component::values,
"The scattering function values"
)
.def_property_readonly(

"lower_inverse_length_limit",
&Component::lowerInverseLengthLimit,
"The lower inverse length limit"
)
.def_property_readonly(

"upper_inverse_length_limit",
&Component::upperInverseLengthLimit,
"The upper inverse length limit"
)
.def(

"__call__",
[] ( const Component& self, double inverse_length ) -> decltype(auto)
{ return self( inverse_length ); },
python::arg( "inverse_length" ),
"Evaluate the table for a given energy value\n\n"
"Arguments:\n"
" self the table\n"
" inverse_length the inverse length value"
);

// add standard tabulated data definitions
addStandardTabulatedDefinitions< Component >( component );
}
4 changes: 4 additions & 0 deletions python/src/dryad.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void wrapTabulatedEnergyDistributions( python::module&, python::module& );
void wrapTabulatedCrossSection( python::module&, python::module& );
void wrapTabulatedMultiplicity( python::module&, python::module& );
void wrapTabulatedAverageEnergy( python::module&, python::module& );
void wrapTabulatedFormFactor( python::module&, python::module& );
void wrapTabulatedScatteringFunction( python::module&, python::module& );
void wrapTwoBodyDistributionData( python::module&, python::module& );
void wrapUncorrelatedDistributionData( python::module&, python::module& );
void wrapReactionProduct( python::module&, python::module& );
Expand Down Expand Up @@ -73,6 +75,8 @@ PYBIND11_MODULE( dryad, module ) {
wrapTabulatedAngularDistributions( module, viewmodule );
wrapTabulatedEnergyDistribution( module, viewmodule );
wrapTabulatedEnergyDistributions( module, viewmodule );
wrapTabulatedFormFactor( module, viewmodule );
wrapTabulatedScatteringFunction( module, viewmodule );
wrapTwoBodyDistributionData( module, viewmodule );
wrapUncorrelatedDistributionData( module, viewmodule );
wrapReactionProduct( module, viewmodule );
Expand Down
Loading