Skip to content

Commit

Permalink
Merge pull request #13 from njoy/feature/multigroup-part7
Browse files Browse the repository at this point in the history
Feature/multigroup part7
  • Loading branch information
whaeck authored Jun 4, 2024
2 parents aee1543 + 934167b commit acf2072
Show file tree
Hide file tree
Showing 68 changed files with 2,464 additions and 61 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ if( NDItk.python )
python/src/multigroup/Kerma.python.cpp
python/src/multigroup/OutgoingParticleTypes.python.cpp
python/src/multigroup/OutgoingParticleTransportData.python.cpp
python/src/multigroup/LegendreMoment.python.cpp
python/src/multigroup/ScatteringMatrix.python.cpp
)

target_link_libraries( NDItk.python PRIVATE NDItk )
Expand Down
2 changes: 1 addition & 1 deletion cmake/develop_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include( FetchContent )

FetchContent_Declare( tools
GIT_REPOSITORY https://github.com/njoy/tools
GIT_TAG develop
GIT_TAG feature/use-case
GIT_SHALLOW TRUE
)

Expand Down
4 changes: 2 additions & 2 deletions cmake/release_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ FetchContent_Declare( spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG ad0e89cbfb4d0c1ce4d097e134eb7be67baebb36 # tag: v1.11.0
)
set( SPDLOG_BUILD_PIC CACHE INTERNAL BOOL ON )
set( SPDLOG_BUILD_PIC CACHE INTERNAL BOOL ON )

FetchContent_Declare( tools
GIT_REPOSITORY https://github.com/njoy/tools
GIT_TAG f0c91b67d0e72c906f43f79c59a5c8504110b2fa
GIT_TAG 99cc26d49e386a23d817d9f4f4989999d3e58f55
)

#######################################################################
Expand Down
2 changes: 2 additions & 0 deletions cmake/unit_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ add_subdirectory( src/NDItk/multigroup/HeatingNumbers/test )
add_subdirectory( src/NDItk/multigroup/Kerma/test )
add_subdirectory( src/NDItk/multigroup/OutgoingParticleTypes/test )
add_subdirectory( src/NDItk/multigroup/OutgoingParticleTransportData/test )
add_subdirectory( src/NDItk/multigroup/LegendreMoment/test )
add_subdirectory( src/NDItk/multigroup/ScatteringMatrix/test )

add_subdirectory( src/NDItk/MultigroupTable/test )
2 changes: 2 additions & 0 deletions cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ add_python_test( multigroup.HeatingNumbers multigroup/Test_NDItk_
add_python_test( multigroup.Kerma multigroup/Test_NDItk_multigroup_Kerma.py )
add_python_test( multigroup.OutgoingParticleTypes multigroup/Test_NDItk_multigroup_OutgoingParticleTypes.py )
add_python_test( multigroup.OutgoingParticleTransportData multigroup/Test_NDItk_multigroup_OutgoingParticleTransportData.py )
add_python_test( multigroup.LegendreMoment multigroup/Test_NDItk_multigroup_LegendreMoment.py )
add_python_test( multigroup.ScatteringMatrix multigroup/Test_NDItk_multigroup_ScatteringMatrix.py )

add_python_test( MultigroupTable Test_NDItk_MultigroupTable.py )
29 changes: 25 additions & 4 deletions python/src/MultigroupTable.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
using OutgoingParticleTransportData = njoy::NDItk::multigroup::OutgoingParticleTransportData;
using HeatingNumbers = njoy::NDItk::multigroup::HeatingNumbers;
using Kerma = njoy::NDItk::multigroup::Kerma;
using ScatteringMatrix = njoy::NDItk::multigroup::ScatteringMatrix;

// wrap views created by this table

Expand All @@ -47,12 +48,14 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
Velocities,
FluxWeights,
ReactionCrossSections,
ScatteringMatrix,
std::optional< std::string >,
std::optional< double >,
std::optional< TotalCrossSection >,
std::optional< AverageFissionEnergyRelease >,
std::optional< OutgoingParticleTypes >,
std::optional< OutgoingParticleTransportData >,
std::vector< ScatteringMatrix >,
std::optional< HeatingNumbers >,
std::vector< HeatingNumbers >,
std::optional< Kerma >,
Expand All @@ -62,13 +65,14 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
python::arg( "temperature" ), python::arg( "dilution" ),
python::arg( "structure" ), python::arg( "outgoing" ),
python::arg( "velocities" ), python::arg( "flux" ),
python::arg( "xs" ),
python::arg( "xs" ), python::arg( "scattering" ),
python::arg( "source" ) = std::nullopt,
python::arg( "weight" ) = std::nullopt,
python::arg( "total" ) = std::nullopt,
python::arg( "release" ) = std::nullopt,
python::arg( "types" ) = std::nullopt,
python::arg( "transport" ) = std::nullopt,
python::arg( "production" ) = std::vector< ScatteringMatrix >{},
python::arg( "primary_heating" ) = std::nullopt,
python::arg( "outgoing_heating" ) = std::vector< HeatingNumbers >{},
python::arg( "primary_kerma" ) = std::nullopt,
Expand All @@ -88,6 +92,7 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
" velocities the velocities\n"
" flux the flux weights\n"
" xs the reaction cross section data\n"
" scattering the scattering matrix\n"
" source the source date (optional)\n"
" weight the atomic weight of the target (optional)\n"
" total the total cross section (optional)\n"
Expand Down Expand Up @@ -123,6 +128,12 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
&Table::fluxWeights,
"The flux weight record"
)
.def_property_readonly(

"total_cross_section",
&Table::totalCrossSection,
"The total cross section record"
)
.def_property_readonly(

"reaction_cross_sections",
Expand All @@ -131,9 +142,9 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
)
.def_property_readonly(

"total_cross_section",
&Table::totalCrossSection,
"The total cross section record"
"scattering_matrix",
&Table::scatteringMatrix,
"The scattering matrix record"
)
.def_property_readonly(

Expand Down Expand Up @@ -175,6 +186,16 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
" self the table\n"
" particle the outgoing particle identifier"
)
.def(

"outgoing_production_matrix",
&Table::outgoingProductionMatrix,
python::arg( "particle" ),
"The production record for an outgoing particle\n\n"
"Arguments:\n"
" self the table\n"
" particle the outgoing particle identifier"
)
.def(

"outgoing_heating_numbers",
Expand Down
4 changes: 4 additions & 0 deletions python/src/multigroup.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace multigroup {
void wrapAverageFissionEnergyRelease( python::module&, python::module& );
void wrapOutgoingParticleTypes( python::module&, python::module& );
void wrapOutgoingParticleTransportData( python::module&, python::module& );
void wrapLegendreMoment( python::module&, python::module& );
void wrapScatteringMatrix( python::module&, python::module& );
}

void wrapMultigroup( python::module& module, python::module& viewmodule ) {
Expand All @@ -45,4 +47,6 @@ void wrapMultigroup( python::module& module, python::module& viewmodule ) {
multigroup::wrapAverageFissionEnergyRelease( submodule, viewmodule );
multigroup::wrapOutgoingParticleTypes( submodule, viewmodule );
multigroup::wrapOutgoingParticleTransportData( submodule, viewmodule );
multigroup::wrapLegendreMoment( submodule, viewmodule );
multigroup::wrapScatteringMatrix( submodule, viewmodule );
}
8 changes: 7 additions & 1 deletion python/src/multigroup/EnergyGroupStructure.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void wrapEnergyGroupStructure( python::module& module, python::module& ) {
" particle the secondary particle identifier\n"
" boundaries the group structure boundaries"
)
.def_property_readonly(

"particle",
[] ( const Record& self ) { return self.particle(); },
"The particle identifier"
)
.def_property_readonly(

"number_groups",
Expand All @@ -58,7 +64,7 @@ void wrapEnergyGroupStructure( python::module& module, python::module& ) {
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
2 changes: 1 addition & 1 deletion python/src/multigroup/FluxWeights.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void wrapFluxWeights( python::module& module, python::module& ) {
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return read< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
8 changes: 7 additions & 1 deletion python/src/multigroup/HeatingNumbers.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void wrapHeatingNumbers( python::module& module, python::module& ) {
" particle the secondary particle identifier\n"
" values the heating numbers"
)
.def_property_readonly(

"particle",
[] ( const Record& self ) { return self.particle(); },
"The particle identifier"
)
.def_property_readonly(

"number_groups",
Expand All @@ -58,7 +64,7 @@ void wrapHeatingNumbers( python::module& module, python::module& ) {
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
8 changes: 7 additions & 1 deletion python/src/multigroup/Kerma.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void wrapKerma( python::module& module, python::module& ) {
" particle the secondary particle identifier\n"
" values the kerma values"
)
.def_property_readonly(

"particle",
[] ( const Record& self ) { return self.particle(); },
"The particle identifier"
)
.def_property_readonly(

"number_groups",
Expand All @@ -58,7 +64,7 @@ void wrapKerma( python::module& module, python::module& ) {
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
87 changes: 87 additions & 0 deletions python/src/multigroup/LegendreMoment.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "NDItk/multigroup/LegendreMoment.hpp"
#include "tools/views/views-python.hpp"
#include "definitions.hpp"

// namespace aliases
namespace python = pybind11;

namespace multigroup {

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

// type aliases
using Record = njoy::NDItk::multigroup::LegendreMoment;

// wrap views created by this record

// create the record
python::class_< Record > record(

module,
"LegendreMoment",
"A Legendre moment subrecord for multigroup neutron and photon data"
);

// wrap the record
record
.def(

python::init< int, std::vector< double >, unsigned int >(),
python::arg( "order" ), python::arg( "values" ),
python::arg( "incident" ),
"Initialise the subrecord\n\n"
"Arguments:\n"
" self the record\n"
" order the Legendre order\n"
" values the values of the matrix\n"
" incident the number of primary groups"
)
.def(

python::init< int, std::vector< double >, unsigned int, unsigned int >(),
python::arg( "order" ), python::arg( "values" ),
python::arg( "incident" ), python::arg( "outgoing" ),
"Initialise the subrecord\n\n"
"Arguments:\n"
" self the record\n"
" order the Legendre order\n"
" values the values of the matrix\n"
" incident the number of primary groups\n"
" outgoing the number of outgoing groups"
)
.def_property_readonly(

"order",
&Record::order,
"The Legendre moment order"
)
.def_property_readonly(

"number_primary_groups",
&Record::numberPrimaryGroups,
"The number of incident groups"
)
.def_property_readonly(

"number_outgoing_groups",
&Record::numberOutgoingGroups,
"The number of outgoing groups"
)
.def_property_readonly(

"matrix",
[] ( const Record& self ) -> DoubleRange2D
{ return self.matrix(); },
"The matrix defined by this subrecord"
);

// add standard record definitions
addStandardSubrecordDefinitions< Record, DoubleRange >( record );
}

} // multigroup namespace
23 changes: 15 additions & 8 deletions python/src/multigroup/Metadata.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ void wrapMetadata( python::module& module, python::module& ) {
python::init< std::string, std::string, std::string,
double, double, double,
unsigned int, std::map< unsigned int, unsigned int >,
unsigned int,
unsigned int, unsigned int,
std::optional< std::string >,
std::optional< double >,
std::optional< int >,
std::optional< int > >(),
python::arg( "zaid" ), python::arg( "libname" ),
python::arg( "process" ), python::arg( "awr" ),
python::arg( "temperature" ), python::arg( "dilution" ), python::arg( "groups" ),
python::arg( "outgoing" ), python::arg( "reactions" ),
python::arg( "outgoing" ), python::arg( "reactions" ), python::arg( "legendre" ),
python::arg( "source" ) = std::nullopt,
python::arg( "weight" ) = std::nullopt,
python::arg( "upscatter" ) = std::nullopt,
Expand All @@ -61,6 +61,7 @@ void wrapMetadata( python::module& module, python::module& ) {
" groups the number of groups in the primary group structure\n"
" outgoing the number of groups in the outgoing group structures\n"
" reactions the number of reactions defined in the table\n"
" legendre the number of Legendre moments in the table\n"
" source the source date (optional)\n"
" weight the atomic weight of the target (optional)\n"
" upscatter the number of upscatter groups (optional)\n"
Expand Down Expand Up @@ -122,22 +123,28 @@ void wrapMetadata( python::module& module, python::module& ) {
)
.def_property_readonly(

"number_upscatter_groups",
&Record::numberUpscatterGroups,
"The number of upscatter groups defined by this record"
"number_legendre_moments",
&Record::numberLegendreMoments,
"The number of Legendre moments defined by this record"
)
.def_property_readonly(

"number_outgoing_particles",
&Record::numberOutgoingParticles,
"The number of outgoing particles by this record"
"number_upscatter_groups",
&Record::numberUpscatterGroups,
"The number of upscatter groups defined by this record"
)
.def_property_readonly(

"number_downscatter_groups",
&Record::numberDownscatterGroups,
"The number of downscatter groups defined by this record"
)
.def_property_readonly(

"number_outgoing_particles",
&Record::numberOutgoingParticles,
"The number of outgoing particles by this record"
)
.def(

"number_outgoing_groups",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void wrapOutgoingParticleTransportData( python::module& module, python::module&
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return read< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
2 changes: 1 addition & 1 deletion python/src/multigroup/OutgoingParticleTypes.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void wrapOutgoingParticleTypes( python::module& module, python::module& ) {
.def_static(

"from_string",
[] ( const std::string& string, std::size_t number ) -> Record
[] ( const std::string& string, unsigned int number ) -> Record
{ return read< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
Loading

0 comments on commit acf2072

Please sign in to comment.