Skip to content

Commit

Permalink
Merge pull request #17 from njoy/feature/multigroup-part9
Browse files Browse the repository at this point in the history
Feature/multigroup part9
  • Loading branch information
whaeck authored Oct 8, 2024
2 parents 26b4a02 + 89ba432 commit 526f0ce
Show file tree
Hide file tree
Showing 46 changed files with 1,828 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ if( NDItk.python )
pybind11_add_module( NDItk.python
python/src/NDItk.python.cpp
python/src/MultigroupTable.python.cpp
python/src/depletion.python.cpp
python/src/depletion/ReactionMultiplicityType.python.cpp
python/src/depletion/Multiplicities.python.cpp
python/src/depletion/ReactionMultiplicities.python.cpp
python/src/multigroup.python.cpp
python/src/multigroup/FissionType.python.cpp
python/src/multigroup/Metadata.python.cpp
python/src/multigroup/CrossSection.python.cpp
python/src/multigroup/FluxWeights.python.cpp
Expand Down
3 changes: 3 additions & 0 deletions cmake/unit_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ add_subdirectory( src/NDItk/base/RealListRecord/test )
add_subdirectory( src/NDItk/base/StringListRecord/test )
add_subdirectory( src/NDItk/base/InformationRecord/test )

add_subdirectory( src/NDItk/depletion/Multiplicities/test )
add_subdirectory( src/NDItk/depletion/ReactionMultiplicities/test )

add_subdirectory( src/NDItk/multigroup/Metadata/test )
add_subdirectory( src/NDItk/multigroup/EnergyGroupStructure/test )
add_subdirectory( src/NDItk/multigroup/FluxWeights/test )
Expand Down
3 changes: 3 additions & 0 deletions cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ endfunction()

message( STATUS "Adding NDItk Python unit testing" )

add_python_test( depletion.Multiplicities depletion/Test_NDItk_depletion_Multiplicities.py )
add_python_test( depletion.ReactionMultiplicities depletion/Test_NDItk_depletion_ReactionMultiplicities.py )

add_python_test( multigroup.Metadata multigroup/Test_NDItk_multigroup_Metadata.py )
add_python_test( multigroup.CrossSection multigroup/Test_NDItk_multigroup_CrossSection.py )
add_python_test( multigroup.FluxWeights multigroup/Test_NDItk_multigroup_FluxWeights.py )
Expand Down
2 changes: 2 additions & 0 deletions python/src/NDItk.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace python = pybind11;
// declarations

// declarations - record and subrecord subpackages
void wrapDepletion( python::module&, python::module& );
void wrapMultigroup( python::module&, python::module& );

// declarations - NDI table types
Expand All @@ -33,6 +34,7 @@ PYBIND11_MODULE( NDItk, module ) {
);

// record and subrecord subpackages
wrapDepletion( module, viewmodule );
wrapMultigroup( module, viewmodule );

// wrap ACE table types
Expand Down
32 changes: 32 additions & 0 deletions python/src/depletion.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes

// namespace aliases
namespace python = pybind11;

namespace depletion {

// declarations - NDI enumerators
void wrapReactionMultiplicityType( python::module&, python::module& );

// declarations - NDI records and subrecords
void wrapMultiplicities( python::module&, python::module& );
void wrapReactionMultiplicities( python::module&, python::module& );
}

void wrapDepletion( python::module& module, python::module& viewmodule ) {

// create the submodule
python::module submodule = module.def_submodule(

"depletion",
"Depeltion NDI records and subrecords"
);

depletion::wrapReactionMultiplicityType( submodule, viewmodule );
depletion::wrapMultiplicities( submodule, viewmodule );
depletion::wrapReactionMultiplicities( submodule, viewmodule );
}
75 changes: 75 additions & 0 deletions python/src/depletion/Multiplicities.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "NDItk/depletion/Multiplicities.hpp"
#include "tools/views/views-python.hpp"
#include "definitions.hpp"

// namespace aliases
namespace python = pybind11;

namespace depletion {

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

// type aliases
using Record = njoy::NDItk::depletion::Multiplicities;

// wrap views created by this record

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

module,
"Multiplicities",
"A reaction product multiplicity subrecord for depletion data"
);

// wrap the record
record
.def(

python::init< int, std::vector< int >, std::vector< int > >(),
python::arg( "reaction" ), python::arg( "products" ),
python::arg( "multiplicities" ),
"Initialise the subrecord\n\n"
"Arguments:\n"
" self the record\n"
" reaction the reaction number\n"
" products the reaction product identifiers\n"
" multiplicities the multiplicity values"
)
.def_property_readonly(

"identifier",
&Record::identifier,
"The reaction identifier"
)
.def_property_readonly(

"number_reaction_products",
&Record::numberReactionProducts,
"The number of reaction products"
)
.def_property_readonly(

"reaction_products",
[] ( const Record& self ) -> IntRange
{ return self.reactionProducts(); },
"The reaction product identifiers"
)
.def_property_readonly(

"multiplicities",
[] ( const Record& self ) -> IntRange
{ return self.multiplicities(); },
"The reaction product multiplicities"
);

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

} // depletion namespace
103 changes: 103 additions & 0 deletions python/src/depletion/ReactionMultiplicities.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "NDItk/depletion/ReactionMultiplicities.hpp"
#include "tools/views/views-python.hpp"
#include "definitions.hpp"
#include "read.hpp"

// namespace aliases
namespace python = pybind11;

namespace depletion {

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

// type aliases
using Record = njoy::NDItk::depletion::ReactionMultiplicities;
using Multiplicities = njoy::NDItk::depletion::Multiplicities;
using ReactionMultiplicityType = njoy::NDItk::depletion::ReactionMultiplicityType;

// wrap views created by this record

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

module,
"ReactionMultiplicities",
"A reaction product multiplicity record for depletion data"
);

// wrap the record
record
.def(

python::init< std::vector< Multiplicities > >(),
python::arg( "multiplicities" ),
"Initialise the record\n\n"
"Arguments:\n"
" self the record\n"
" multiplicities the multiplicity data"
)
.def(

python::init< const ReactionMultiplicityType&,
std::vector< Multiplicities > >(),
python::arg( "type" ),python::arg( "multiplicities" ),
"Initialise the record\n\n"
"Arguments:\n"
" self the record\n"
" type the multiplicity type (all, few or rmo)\n"
" multiplicities the multiplicity data"
)
.def_property_readonly(

"number_reactions",
&Record::numberReactions,
"The number of reactions defined by this record"
)
.def_property_readonly(

"reactions",
&Record::reactions,
"The multiplicity data for all reactions"
)
.def(

"has_reaction",
&Record::hasReaction,
python::arg( "reaction" ),
"Return whether or not a given reaction is present\n\n"
" self the record\n"
" reaction the reaction to look for"
)
.def(

"reaction",
&Record::reaction,
python::arg( "reaction" ),
"Return the multiplicity data for a given reaction\n\n"
" self the record\n"
" reaction the reaction to look for"
)
.def_static(

"from_string",
[] ( const std::string& string, unsigned int reactions ) -> Record
{ return readWithMultiplicitySubtype< Record >( string, reactions ); },
python::arg( "string" ), python::arg( "reactions" ),
"Read the record from a string\n\n"
"An exception is raised if something goes wrong while reading the\n"
"record\n\n"
"Arguments:\n"
" string the string representing the record\n"
" reactions the number of reactions to be read"
);

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

} // depletion namespace
36 changes: 36 additions & 0 deletions python/src/depletion/ReactionMultiplicityType.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "NDItk/depletion/ReactionMultiplicityType.hpp"

// namespace aliases
namespace python = pybind11;

namespace depletion {

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

// type aliases
using Component = njoy::NDItk::depletion::ReactionMultiplicityType;

// wrap views created by this component

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

module,
"ReactionMultiplicityType",
"The reaction multiplicity types",
python::arithmetic()
);

// wrap the component
component
.value( "All", Component::All )
.value( "Few", Component::Few )
.value( "RMO", Component::RMO );
}

} // namespace depletion
2 changes: 2 additions & 0 deletions python/src/multigroup.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace python = pybind11;
namespace multigroup {

// declarations - NDI records and subrecords
void wrapFissionType( python::module&, python::module& );
void wrapMetadata( python::module&, python::module& );
void wrapCrossSection( python::module&, python::module& );
void wrapFluxWeights( python::module&, python::module& );
Expand All @@ -35,6 +36,7 @@ void wrapMultigroup( python::module& module, python::module& viewmodule ) {
"Multigroup neutron and photon NDI records and subrecords"
);

multigroup::wrapFissionType( submodule, viewmodule );
multigroup::wrapMetadata( submodule, viewmodule );
multigroup::wrapCrossSection( submodule, viewmodule );
multigroup::wrapFluxWeights( submodule, viewmodule );
Expand Down
2 changes: 1 addition & 1 deletion python/src/multigroup/EnergyGroupStructure.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void wrapEnergyGroupStructure( python::module& module, python::module& ) {

"from_string",
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
{ return readWithParticleSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
"An exception is raised if something goes wrong while reading the\n"
Expand Down
36 changes: 36 additions & 0 deletions python/src/multigroup/FissionType.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "NDItk/multigroup/FissionType.hpp"

// namespace aliases
namespace python = pybind11;

namespace multigroup {

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

// type aliases
using Component = njoy::NDItk::multigroup::FissionType;

// wrap views created by this component

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

module,
"FissionType",
"The fission data types",
python::arithmetic()
);

// wrap the component
component
.value( "Prompt", Component::Prompt )
.value( "Delayed", Component::Delayed )
.value( "Total", Component::Total );
}

} // namespace multigroup
2 changes: 1 addition & 1 deletion python/src/multigroup/HeatingNumbers.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void wrapHeatingNumbers( python::module& module, python::module& ) {

"from_string",
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
{ return readWithParticleSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
"An exception is raised if something goes wrong while reading the\n"
Expand Down
2 changes: 1 addition & 1 deletion python/src/multigroup/Kerma.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void wrapKerma( python::module& module, python::module& ) {

"from_string",
[] ( const std::string& string, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, number ); },
{ return readWithParticleSubtype< Record >( string, number ); },
python::arg( "string" ), python::arg( "number" ),
"Read the record from a string\n\n"
"An exception is raised if something goes wrong while reading the\n"
Expand Down
4 changes: 2 additions & 2 deletions python/src/multigroup/ScatteringMatrix.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void wrapScatteringMatrix( python::module& module, python::module& ) {
"from_string",
[] ( const std::string& string, unsigned int incident,
unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, incident, number ); },
{ return readWithParticleSubtype< Record >( string, incident, number ); },
python::arg( "string" ), python::arg( "incident" ),
python::arg( "number" ),
"Read the record from a string\n\n"
Expand All @@ -119,7 +119,7 @@ void wrapScatteringMatrix( python::module& module, python::module& ) {
"from_string",
[] ( const std::string& string, unsigned int incident,
unsigned int outgoing, unsigned int number ) -> Record
{ return readWithSubtype< Record >( string, incident, outgoing, number ); },
{ return readWithParticleSubtype< Record >( string, incident, outgoing, number ); },
python::arg( "string" ), python::arg( "incident" ),
python::arg( "outgoing" ), python::arg( "number" ),
"Read the record from a string\n\n"
Expand Down
Loading

0 comments on commit 526f0ce

Please sign in to comment.