Skip to content

Commit

Permalink
Merge pull request #19 from njoy/feature/multigroup-part10
Browse files Browse the repository at this point in the history
Feature/multigroup part10
  • Loading branch information
whaeck authored Oct 8, 2024
2 parents 76fa384 + bf7b3b5 commit 428e519
Show file tree
Hide file tree
Showing 70 changed files with 2,510 additions and 85 deletions.
18 changes: 18 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
BasedOnStyle: LLVM
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
BeforeElse: true
ColumnLimit: 100
EmptyLineAfterAccessModifier: Always
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
InsertBraces: true
PointerAlignment: Left
SpacesInAngles: Always
SpacesInParens: Custom
SpacesInParensOptions:
InConditionalStatements: true
Other: true

4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ if( NDItk.python )
python/src/multigroup/ReactionCrossSections.python.cpp
python/src/multigroup/TotalCrossSection.python.cpp
python/src/multigroup/AverageFissionEnergyRelease.python.cpp
python/src/multigroup/FissionNeutronMultiplicity.python.cpp
python/src/multigroup/FissionNeutronProduction.python.cpp
python/src/multigroup/FissionNeutronSpectrumVector.python.cpp
python/src/multigroup/FissionNeutronSpectrumMatrix.python.cpp
python/src/multigroup/Velocities.python.cpp
python/src/multigroup/HeatingNumbers.python.cpp
python/src/multigroup/Kerma.python.cpp
Expand Down
4 changes: 4 additions & 0 deletions cmake/unit_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ add_subdirectory( src/NDItk/multigroup/AverageFissionEnergyRelease/test )
add_subdirectory( src/NDItk/multigroup/Velocities/test )
add_subdirectory( src/NDItk/multigroup/HeatingNumbers/test )
add_subdirectory( src/NDItk/multigroup/Kerma/test )
add_subdirectory( src/NDItk/multigroup/FissionNeutronMultiplicity/test )
add_subdirectory( src/NDItk/multigroup/FissionNeutronProduction/test )
add_subdirectory( src/NDItk/multigroup/FissionNeutronSpectrumMatrix/test )
add_subdirectory( src/NDItk/multigroup/FissionNeutronSpectrumVector/test )
add_subdirectory( src/NDItk/multigroup/OutgoingParticleTypes/test )
add_subdirectory( src/NDItk/multigroup/OutgoingParticleTransportData/test )
add_subdirectory( src/NDItk/multigroup/LegendreMoment/test )
Expand Down
4 changes: 4 additions & 0 deletions cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ add_python_test( multigroup.EnergyGroupStructure multigroup/Test_NDItk_
add_python_test( multigroup.ReactionCrossSections multigroup/Test_NDItk_multigroup_ReactionCrossSections.py )
add_python_test( multigroup.TotalCrossSection multigroup/Test_NDItk_multigroup_TotalCrossSection.py )
add_python_test( multigroup.AverageFissionEnergyRelease multigroup/Test_NDItk_multigroup_AverageFissionEnergyRelease.py )
add_python_test( multigroup.FissionNeutronMultiplicity multigroup/Test_NDItk_multigroup_FissionNeutronMultiplicity.py )
add_python_test( multigroup.FissionNeutronProduction multigroup/Test_NDItk_multigroup_FissionNeutronProduction.py )
add_python_test( multigroup.FissionNeutronSpectrumMatrix multigroup/Test_NDItk_multigroup_FissionNeutronSpectrumMatrix.py )
add_python_test( multigroup.FissionNeutronSpectrumVector multigroup/Test_NDItk_multigroup_FissionNeutronSpectrumVector.py )
add_python_test( multigroup.Velocities multigroup/Test_NDItk_multigroup_Velocities.py )
add_python_test( multigroup.HeatingNumbers multigroup/Test_NDItk_multigroup_HeatingNumbers.py )
add_python_test( multigroup.Kerma multigroup/Test_NDItk_multigroup_Kerma.py )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "f53a715b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# a recursive function to find all files with a given extension in a directory\n",
"def getFilesInFolder( directory, extension ) :\n",
"\n",
" files = os.listdir( directory )\n",
" everything = list()\n",
"\n",
" for entry in files :\n",
"\n",
" file = os.path.join( directory, entry )\n",
"\n",
" if os.path.isdir( file ) :\n",
"\n",
" everything += getFilesInFolder( file, extension )\n",
"\n",
" else :\n",
"\n",
" everything.append( file )\n",
"\n",
" return [ file for file in everything if file.endswith( extension ) ]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "74836354",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"FAILED /Users/wim/Projects/libraries/ndi/mt80_30/t20/50118.851nm\n",
"-------------------------\n",
" 1 files\n",
" 1 failed\n",
"elapsed time = 0.000673 s\n",
"-------------------------\n"
]
}
],
"source": [
"import NDItk\n",
"import time\n",
"\n",
"path = '/Users/wim/Projects/libraries/ndi/mt80_30'\n",
"files = getFilesInFolder( path, '1001.851nm' )\n",
"failed = []\n",
"\n",
"start = time.perf_counter()\n",
"for file in files :\n",
"\n",
" try :\n",
"\n",
" table = NDItk.MultigroupTable.from_file( file )\n",
"\n",
" except :\n",
"\n",
" print( 'FAILED', file )\n",
" failed.append( file )\n",
"\n",
"end = time.perf_counter()\n",
"\n",
"print( '-------------------------' )\n",
"print( '{:4} files'.format( len( files ) ) )\n",
"print( '{:4} failed'.format( len( failed ) ) )\n",
"print( 'elapsed time = {:.3} s'.format( end - start ) )\n",
"print( '-------------------------' )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d108125",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
121 changes: 121 additions & 0 deletions python/examples/NDItk-getting-started-example-1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "f53a715b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# a recursive function to find all files with a given extension in a directory\n",
"def getFilesInFolder( directory, extension ) :\n",
"\n",
" files = os.listdir( directory )\n",
" everything = list()\n",
"\n",
" for entry in files :\n",
"\n",
" file = os.path.join( directory, entry )\n",
"\n",
" if os.path.isdir( file ) :\n",
"\n",
" everything += getFilesInFolder( file, extension )\n",
"\n",
" else :\n",
"\n",
" everything.append( file )\n",
"\n",
" return [ file for file in everything if file.endswith( extension ) ]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "74836354",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-------------------------\n",
"13455 files\n",
" 0 failed\n",
"elapsed time = 5.79e+02 s\n",
"-------------------------\n"
]
}
],
"source": [
"import NDItk\n",
"import time\n",
"\n",
"path = '/Users/wim/Projects/libraries/ndi/mt80'\n",
"files = getFilesInFolder( path, 'nm' )\n",
"failed = []\n",
"\n",
"start = time.perf_counter()\n",
"for file in files :\n",
"\n",
" try :\n",
"\n",
" table = NDItk.MultigroupTable.from_file( file )\n",
"\n",
" except :\n",
"\n",
" print( 'FAILED', file )\n",
" failed.append( file )\n",
"\n",
"end = time.perf_counter()\n",
"\n",
"print( '-------------------------' )\n",
"print( '{:4} files'.format( len( files ) ) )\n",
"print( '{:4} failed'.format( len( failed ) ) )\n",
"print( 'elapsed time = {:.3} s'.format( end - start ) )\n",
"print( '-------------------------' )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d108125",
"metadata": {},
"outputs": [],
"source": [
"import NDItk\n",
"table = NDItk.MultigroupTable.from_file( '/Users/wim/Projects/libraries/ndi/mt80_30/t22/38086.853nm' )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3ed6d2e8",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
44 changes: 44 additions & 0 deletions python/src/MultigroupTable.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
using TotalCrossSection = njoy::NDItk::multigroup::TotalCrossSection;
using ReactionCrossSections = njoy::NDItk::multigroup::ReactionCrossSections;
using AverageFissionEnergyRelease = njoy::NDItk::multigroup::AverageFissionEnergyRelease;
using FissionNeutronMultiplicity = njoy::NDItk::multigroup::FissionNeutronMultiplicity;
using FissionNeutronProduction = njoy::NDItk::multigroup::FissionNeutronProduction;
using FissionNeutronSpectrumMatrix = njoy::NDItk::multigroup::FissionNeutronSpectrumMatrix;
using FissionNeutronSpectrumVector = njoy::NDItk::multigroup::FissionNeutronSpectrumVector;
using OutgoingParticleTypes = njoy::NDItk::multigroup::OutgoingParticleTypes;
using OutgoingParticleTransportData = njoy::NDItk::multigroup::OutgoingParticleTransportData;
using HeatingNumbers = njoy::NDItk::multigroup::HeatingNumbers;
Expand Down Expand Up @@ -155,6 +159,46 @@ void wrapMultigroupTable( python::module& module, python::module& ) {
&Table::averageFissionEnergyRelease,
"The average fission energy release record"
)
.def(

"fission_neutron_multiplicity",
&Table::fissionNeutronMultiplicity,
python::arg( "type" ),
"The fission neutron multiplicity record for the requested fission type"
"Arguments:\n"
" self the table\n"
" type the fission type"
)
.def(

"fission_neutron_production",
&Table::fissionNeutronProduction,
python::arg( "type" ),
"The fission neutron production record for the requested fission type"
"Arguments:\n"
" self the table\n"
" type the fission type"
)
.def(

"fission_neutron_spectrum_matrix",
&Table::fissionNeutronSpectrumMatrix,
python::arg( "type" ),
"The fission neutron spectrum matrix record for the requested fission type"
"Arguments:\n"
" self the table\n"
" type the fission type"
)
.def(

"fission_neutron_spectrum_vector",
&Table::fissionNeutronSpectrumVector,
python::arg( "type" ),
"The fission neutron spectrum vector record for the requested fission type"
"Arguments:\n"
" self the table\n"
" type the fission type"
)
.def_property_readonly(

"primary_heating_numbers",
Expand Down
6 changes: 6 additions & 0 deletions python/src/depletion/ReactionMultiplicities.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ void wrapReactionMultiplicities( python::module& module, python::module& ) {
" type the multiplicity type (all, few or rmo)\n"
" multiplicities the multiplicity data"
)
.def_property_readonly(

"type",
&Record::type,
"The multiplicity type defined by this record"
)
.def_property_readonly(

"number_reactions",
Expand Down
8 changes: 8 additions & 0 deletions python/src/multigroup.python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace multigroup {
void wrapHeatingNumbers( python::module&, python::module& );
void wrapKerma( python::module&, python::module& );
void wrapAverageFissionEnergyRelease( python::module&, python::module& );
void wrapFissionNeutronMultiplicity( python::module&, python::module& );
void wrapFissionNeutronProduction( python::module&, python::module& );
void wrapFissionNeutronSpectrumMatrix( python::module&, python::module& );
void wrapFissionNeutronSpectrumVector( python::module&, python::module& );
void wrapOutgoingParticleTypes( python::module&, python::module& );
void wrapOutgoingParticleTransportData( python::module&, python::module& );
void wrapLegendreMoment( python::module&, python::module& );
Expand All @@ -47,6 +51,10 @@ void wrapMultigroup( python::module& module, python::module& viewmodule ) {
multigroup::wrapHeatingNumbers( submodule, viewmodule );
multigroup::wrapKerma( submodule, viewmodule );
multigroup::wrapAverageFissionEnergyRelease( submodule, viewmodule );
multigroup::wrapFissionNeutronMultiplicity( submodule, viewmodule );
multigroup::wrapFissionNeutronProduction( submodule, viewmodule );
multigroup::wrapFissionNeutronSpectrumMatrix( submodule, viewmodule );
multigroup::wrapFissionNeutronSpectrumVector( submodule, viewmodule );
multigroup::wrapOutgoingParticleTypes( submodule, viewmodule );
multigroup::wrapOutgoingParticleTransportData( submodule, viewmodule );
multigroup::wrapLegendreMoment( submodule, viewmodule );
Expand Down
Loading

0 comments on commit 428e519

Please sign in to comment.