Skip to content

Commit ad2e0d3

Browse files
committed
Merge branch 'feature/pruning' into 'develop'
Feature/pruning See merge request njoy/dryad!96
2 parents c2a30ca + baf2545 commit ad2e0d3

21 files changed

+1838
-125
lines changed

cmake/unit_testing.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ message( STATUS "Adding njoy C++ unit testing" )
2929

3030
add_cpp_test( matrix matrix.test.cpp )
3131

32+
# dryad tests
33+
3234
add_cpp_test( dryad.base.UniformDistribution dryad/base/UniformDistribution.test.cpp )
3335

3436
add_cpp_test( dryad.atomic.ElectronSubshellConfiguration dryad/atomic/ElectronSubshellConfiguration.test.cpp )
@@ -233,3 +235,8 @@ add_cpp_test( dryad.format.gnds.createProjectileTarget d
233235
add_cpp_test( dryad.format.gnds.createProjectileTargetFromFile dryad/format/gnds/createProjectileTargetFromFile.test.cpp )
234236
add_cpp_test( dryad.format.gnds.createAtomicRelaxation dryad/format/gnds/createAtomicRelaxation.test.cpp )
235237
add_cpp_test( dryad.format.gnds.createAtomicRelaxationFromFile dryad/format/gnds/createAtomicRelaxationFromFile.test.cpp )
238+
239+
# medic tests
240+
241+
add_cpp_test( medic.pruneCrossSection medic/pruneCrossSection.test.cpp )
242+
add_cpp_test( medic.pruneCrossSections medic/pruneCrossSections.test.cpp )

cmake/unit_testing_python.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ add_python_test( dryad.Reaction dryad/Tes
9696

9797
add_python_test( dryad.ProjectileTarget dryad/Test_ProjectileTarget.py )
9898
add_python_test( dryad.AtomicRelaxation dryad/Test_AtomicRelaxation.py )
99+
100+
add_python_test( medic.prune_cross_section medic/Test_prune_cross_section.py )
101+
add_python_test( medic.prune_cross_sections medic/Test_prune_cross_sections.py )

python/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ if(njoy.python)
8787
${CMAKE_CURRENT_SOURCE_DIR}/src/dryad/Reaction.python.cpp
8888
${CMAKE_CURRENT_SOURCE_DIR}/src/dryad/ProjectileTarget.python.cpp
8989
${CMAKE_CURRENT_SOURCE_DIR}/src/dryad/AtomicRelaxation.python.cpp
90+
${CMAKE_CURRENT_SOURCE_DIR}/src/medic.python.cpp
91+
${CMAKE_CURRENT_SOURCE_DIR}/src/medic/pruneCrossSection.python.cpp
92+
${CMAKE_CURRENT_SOURCE_DIR}/src/medic/pruneCrossSections.python.cpp
9093
)
9194

9295
target_link_libraries(njoy.python PRIVATE njoy)

python/src/dryad/ProjectileTarget.python.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ void wrapProjectileTarget( python::module& module ) {
159159
" id the reaction identifier",
160160
python::return_value_policy::reference_internal
161161
)
162+
.def(
163+
164+
"unionise_cross_sections",
165+
&Component::unioniseCrossSections,
166+
python::arg( "exclude_summation" ) = false,
167+
"Unionise cross section data\n\n"
168+
"This function takes all cross section data and unionises the cross section\n"
169+
"grids. It does not linearise the data but reevaluates the data using the\n"
170+
"proper interpolation types of the cross section data.\n\n"
171+
"By default, summation cross sections are included in the unionisation process.\n"
172+
"unless explicitly excluded by the user. Switching on the exclusion of summation\n"
173+
"cross sections may be useful when the user is going to recalculate the summation\n"
174+
"cross sections after unionisation.\n\n"
175+
"Arguments:\n"
176+
" self the ProjectileTarget data\n"
177+
" exclude_summation option to exclude summation reactions in the\n"
178+
" unionisation (default: false)"
179+
)
162180
.def(
163181

164182
"calculate_summation_cross_sections",

python/src/medic.python.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
7+
// namespace aliases
8+
namespace python = pybind11;
9+
10+
namespace medic {
11+
12+
// declarations - pruning
13+
void wrapPruneCrossSection( python::module& );
14+
void wrapPruneCrossSections( python::module& );
15+
} // medic namespace
16+
17+
void wrapMedic( python::module& module ) {
18+
19+
// create the submodule
20+
python::module submodule = module.def_submodule(
21+
22+
"medic",
23+
"Correcting and updating data"
24+
);
25+
26+
// wrap components - pruning
27+
medic::wrapPruneCrossSection( submodule );
28+
medic::wrapPruneCrossSections( submodule );
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "njoy/medic/pruneCrossSection.hpp"
7+
8+
// namespace aliases
9+
namespace python = pybind11;
10+
11+
namespace medic {
12+
13+
void wrapPruneCrossSection( python::module& module ) {
14+
15+
// type aliases
16+
17+
// wrap the function
18+
module
19+
.def(
20+
21+
"prune_cross_section",
22+
&njoy::medic::pruneCrossSection,
23+
python::arg( "lower_energy" ),
24+
python::arg( "upper_energy" ),
25+
python::arg( "xs" ),
26+
"Prune cross section data\n\n"
27+
"Arguments:\n"
28+
" lower_energy the new lower energy limit\n"
29+
" upper_energy the new upper energy limit\n"
30+
" xs the cross section table to be modified"
31+
);
32+
}
33+
} // medic namespace
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "njoy/medic/pruneCrossSections.hpp"
7+
8+
// namespace aliases
9+
namespace python = pybind11;
10+
11+
namespace medic {
12+
13+
void wrapPruneCrossSections( python::module& module ) {
14+
15+
// type aliases
16+
17+
// wrap the function
18+
module
19+
.def(
20+
21+
"prune_cross_sections",
22+
&njoy::medic::pruneCrossSections,
23+
python::arg( "lower_energy" ),
24+
python::arg( "upper_energy" ),
25+
python::arg( "xs" ),
26+
"Prune cross section data\n\n"
27+
"Arguments:\n"
28+
" lower_energy the new lower energy limit\n"
29+
" upper_energy the new upper energy limit\n"
30+
" pt the projectile-target data to be modified"
31+
);
32+
}
33+
} // medic namespace

python/src/njoy.python.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ namespace python = pybind11;
1010
// declarations - matrix functions
1111
void wrapMatrix( python::module& );
1212

13-
// declarations
13+
// declarations - components and modules
1414
void wrapDryad( python::module& );
15+
void wrapMedic( python::module& );
1516

1617
/**
1718
* @brief njoy python bindings
@@ -26,4 +27,7 @@ PYBIND11_MODULE( njoy, module ) {
2627

2728
// wrap dryad
2829
wrapDryad( module );
30+
31+
// wrap medic
32+
wrapMedic( module );
2933
}

python/stubs/njoy/dryad/__init__.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,24 @@ class ProjectileTarget:
10141014
mat the ENDF mat number to be used
10151015
filename the ENDF file name
10161016
"""
1017+
def unionise_cross_sections(self, exclude_summation: bool = False) -> None:
1018+
"""
1019+
Unionise cross section data
1020+
1021+
This function takes all cross section data and unionises the cross section
1022+
grids. It does not linearise the data but reevaluates the data using the
1023+
proper interpolation types of the cross section data.
1024+
1025+
By default, summation cross sections are included in the unionisation process.
1026+
unless explicitly excluded by the user. Switching on the exclusion of summation
1027+
cross sections may be useful when the user is going to recalculate the summation
1028+
cross sections after unionisation.
1029+
1030+
Arguments:
1031+
self the ProjectileTarget data
1032+
exclude_summation option to exclude summation reactions in the
1033+
unionisation (default: false)
1034+
"""
10171035
@property
10181036
def documentation(self) -> Documentation:
10191037
"""

python/stubs/njoy/medic.pyi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Correcting and updating data
3+
"""
4+
from __future__ import annotations
5+
import njoy.dryad
6+
__all__: list[str] = ['prune_cross_section', 'prune_cross_sections']
7+
def prune_cross_section(lower_energy: float, upper_energy: float, xs: njoy.dryad.TabulatedCrossSection) -> None:
8+
"""
9+
Prune cross section data
10+
11+
Arguments:
12+
lower_energy the new lower energy limit
13+
upper_energy the new upper energy limit
14+
xs the cross section table to be modified
15+
"""
16+
def prune_cross_sections(lower_energy: float, upper_energy: float, xs: njoy.dryad.ProjectileTarget) -> None:
17+
"""
18+
Prune cross section data
19+
20+
Arguments:
21+
lower_energy the new lower energy limit
22+
upper_energy the new upper energy limit
23+
pt the projectile-target data to be modified
24+
"""

0 commit comments

Comments
 (0)