Skip to content

Commit 73f676f

Browse files
committed
Merge branch 'feature/reconr-unionise' into 'develop'
Feature/reconr unionise See merge request njoy/dryad!97
2 parents ad2e0d3 + 4c6aea7 commit 73f676f

18 files changed

+1848
-1
lines changed

cmake/unit_testing.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ add_cpp_test( dryad.format.gnds.createProjectileTargetFromFile d
236236
add_cpp_test( dryad.format.gnds.createAtomicRelaxation dryad/format/gnds/createAtomicRelaxation.test.cpp )
237237
add_cpp_test( dryad.format.gnds.createAtomicRelaxationFromFile dryad/format/gnds/createAtomicRelaxationFromFile.test.cpp )
238238

239+
# reconr tests
240+
241+
add_cpp_test( reconr.unioniseCrossSections reconr/unioniseCrossSections.test.cpp )
242+
add_cpp_test( reconr.calculateSummationCrossSections reconr/calculateSummationCrossSections.test.cpp )
243+
239244
# medic tests
240245

241246
add_cpp_test( medic.pruneCrossSection medic/pruneCrossSection.test.cpp )

cmake/unit_testing_python.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,8 @@ add_python_test( dryad.Reaction dryad/Tes
9797
add_python_test( dryad.ProjectileTarget dryad/Test_ProjectileTarget.py )
9898
add_python_test( dryad.AtomicRelaxation dryad/Test_AtomicRelaxation.py )
9999

100+
add_python_test( reconr.unionise_cross_sections reconr/Test_unionise_cross_sections.py )
101+
add_python_test( reconr.calculate_summation_cross_sections reconr/Test_calculate_summation_cross_sections.py )
102+
100103
add_python_test( medic.prune_cross_section medic/Test_prune_cross_section.py )
101104
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/reconr.python.cpp
91+
${CMAKE_CURRENT_SOURCE_DIR}/src/reconr/wrapUnioniseCrossSections.python.cpp
92+
${CMAKE_CURRENT_SOURCE_DIR}/src/reconr/wrapCalculateSummationCrossSections.python.cpp
9093
${CMAKE_CURRENT_SOURCE_DIR}/src/medic.python.cpp
9194
${CMAKE_CURRENT_SOURCE_DIR}/src/medic/pruneCrossSection.python.cpp
9295
${CMAKE_CURRENT_SOURCE_DIR}/src/medic/pruneCrossSections.python.cpp

python/src/njoy.python.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ void wrapMatrix( python::module& );
1212

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

1718
/**
@@ -28,6 +29,9 @@ PYBIND11_MODULE( njoy, module ) {
2829
// wrap dryad
2930
wrapDryad( module );
3031

32+
// wrap reconr
33+
wrapReconr( module );
34+
3135
// wrap medic
3236
wrapMedic( module );
3337
}

python/src/reconr.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 reconr {
11+
12+
// declarations
13+
void wrapUnioniseCrossSections( python::module& );
14+
void wrapCalculateSummationCrossSections( python::module& );
15+
} // medic namespace
16+
17+
void wrapReconr( python::module& module ) {
18+
19+
// create the submodule
20+
python::module submodule = module.def_submodule(
21+
22+
"reconr",
23+
"Linearisation, unionisation and resonance reconstruction"
24+
);
25+
26+
// wrap components
27+
reconr::wrapUnioniseCrossSections( submodule );
28+
reconr::wrapCalculateSummationCrossSections( 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/reconr/calculateSummationCrossSections.hpp"
7+
8+
// namespace aliases
9+
namespace python = pybind11;
10+
11+
namespace reconr {
12+
13+
void wrapCalculateSummationCrossSections( python::module& module ) {
14+
15+
// type aliases
16+
17+
// wrap the function
18+
module
19+
.def(
20+
21+
"calculate_summation_cross_sections",
22+
&njoy::reconr::calculateSummationCrossSections,
23+
python::arg( "pt" ),
24+
python::arg( "tolerance" ) = njoy::dryad::ToleranceConvergence(),
25+
"This function recalculates the cross section of all summation reactions of\n"
26+
"a ProjectileTarget instance. It does so by linearising the cross sections of\n"
27+
"the partials (if required) and summing them together.\n\n"
28+
"Arguments:\n"
29+
" pt the projectile-target data to be modified\n"
30+
" tolerance the linearisation tolerance"
31+
);
32+
}
33+
} // medic namespace
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// system includes
2+
#include <pybind11/pybind11.h>
3+
#include <pybind11/stl.h>
4+
5+
// local includes
6+
#include "njoy/reconr/unioniseCrossSections.hpp"
7+
8+
// namespace aliases
9+
namespace python = pybind11;
10+
11+
namespace reconr {
12+
13+
void wrapUnioniseCrossSections( python::module& module ) {
14+
15+
// type aliases
16+
17+
// wrap the function
18+
module
19+
.def(
20+
21+
"unionise_cross_sections",
22+
&njoy::reconr::unioniseCrossSections,
23+
python::arg( "pt" ),
24+
python::arg( "exclude_summation" ) = false,
25+
"Unionise cross section data in a ProjectileTarget instance\n\n"
26+
"This function takes all cross section data in the ProjectileTarget\n"
27+
"instance and unionises the cross section grids. It does not linearise\n"
28+
"the data but reevaluates the data using the proper interpolation types\n"
29+
"of the cross section data.\n\n"
30+
"By default, summation cross sections are included in the unionisation process.\n"
31+
"unless explicitly excluded by the user. Switching on the exclusion of summation\n"
32+
"cross sections may be useful when the user is going to recalculate the summation\n"
33+
"cross sections after unionisation.\n\n"
34+
"pt the projectile-target data to be modified\n"
35+
"exclude_summation option to exclude summation reactions in the\n"
36+
" unionisation (default: false)"
37+
);
38+
}
39+
} // medic namespace

python/stubs/njoy/njoy.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ from __future__ import annotations
22
from . import dryad
33
from . import matrix
44
from . import medic
5-
__all__: list[str] = ['dryad', 'matrix', 'medic']
5+
from . import reconr
6+
__all__: list[str] = ['dryad', 'matrix', 'medic', 'reconr']

python/stubs/njoy/reconr.pyi

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Linearisation, unionisation and resonance reconstruction
3+
"""
4+
from __future__ import annotations
5+
import njoy.dryad
6+
__all__: list[str] = ['calculate_summation_cross_sections', 'unionise_cross_sections']
7+
def calculate_summation_cross_sections(pt: njoy.dryad.ProjectileTarget, tolerance: njoy.dryad.ToleranceConvergence = ...) -> None:
8+
"""
9+
This function recalculates the cross section of all summation reactions of
10+
a ProjectileTarget instance. It does so by linearising the cross sections of
11+
the partials (if required) and summing them together.
12+
13+
Arguments:
14+
pt the projectile-target data to be modified
15+
tolerance the linearisation tolerance
16+
"""
17+
def unionise_cross_sections(pt: njoy.dryad.ProjectileTarget, exclude_summation: bool = False) -> None:
18+
"""
19+
Unionise cross section data in a ProjectileTarget instance
20+
21+
This function takes all cross section data in the ProjectileTarget
22+
instance and unionises the cross section grids. It does not linearise
23+
the data but reevaluates the data using the proper interpolation types
24+
of the cross section data.
25+
26+
By default, summation cross sections are included in the unionisation process.
27+
unless explicitly excluded by the user. Switching on the exclusion of summation
28+
cross sections may be useful when the user is going to recalculate the summation
29+
cross sections after unionisation.
30+
31+
pt the projectile-target data to be modified
32+
exclude_summation option to exclude summation reactions in the
33+
unionisation (default: false)
34+
"""

0 commit comments

Comments
 (0)