Skip to content

Commit 49d1ac8

Browse files
authored
Merge pull request #212 from njoy/feature/mimic-tab1-interface
Feature/mimic tab1 interface
2 parents 823aac0 + f52ca48 commit 49d1ac8

File tree

8 files changed

+116
-0
lines changed

8 files changed

+116
-0
lines changed

ReleaseNotes.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Given here are some release notes for ENDFtk.
55
This update makes the following changes on interface functions:
66
- The regions() and pairs() interface functions on the TAB1 record interface functions have been removed. The removal of these interface functions has no impact on the Python interface as these interface functions were not included on the Python side. Miscellaneous documentation updates were made as well.
77
- When using the C++ interface for atomic relaxation data, a Transition now has a isRadiative() and isNonRadiative() function returning a boolean so that a user can check if a given transition emits a photon or electron without having to look at subshell identifiers. Since Transition is not exposed ont he Python side, this is not available on the Python side.
8+
- NBT(), INT(), boundaries(), interpolants(), NR(), numberInterpolationRegions() interface functions were added on TwoBodyScattering::TabulatedDistribution in MF6 and MF26 that mimic the behaviour of a TAB1 record.
89

910
In addition, the following issues were corrected:
1011
- A minor bug in the rectangular matrix covariance block was corrected. The values for the row and column energies are lifted out of a larger array using the std::ranges::take and std::ranges::drop function. For the column energies, we forgot to properly end the sequence. As a result, the end() iterator of the range did not point to the end of the column energies but to the end of the covariance values, which is now corrected.

python/src/section/26/LAW2/TabulatedDistribution.python.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void wrapTabulatedDistribution( python::module& module, python::module& ) {
111111
);
112112

113113
// add standard component definitions
114+
addStandardInterpolationTableDefinitions< Component >( component );
114115
addStandardComponentDefinitions< Component >( component );
115116
}
116117

python/src/section/6/LAW2/TabulatedDistribution.python.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void wrapTabulatedDistribution( python::module& module, python::module& ) {
111111
);
112112

113113
// add standard component definitions
114+
addStandardInterpolationTableDefinitions< Component >( component );
114115
addStandardComponentDefinitions< Component >( component );
115116
}
116117

python/test/MF26/LAW2/Test_ENDFtk_MF26_LAW2_TabulatedDistribution.py

+22
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def verify_chunk_lang12( self, chunk ) :
5050
self.assertAlmostEqual( 4., chunk.probabilities[1] )
5151
self.assertAlmostEqual( 6., chunk.probabilities[2] )
5252

53+
self.assertEqual( 1, chunk.NR )
54+
self.assertEqual( 1, chunk.number_interpolation_regions )
55+
self.assertEqual( 1, len( chunk.INT ) )
56+
self.assertEqual( 1, len( chunk.NBT ) )
57+
self.assertEqual( 2, chunk.INT[0] )
58+
self.assertEqual( 3, chunk.NBT[0] )
59+
self.assertEqual( 1, len( chunk.interpolants ) )
60+
self.assertEqual( 1, len( chunk.boundaries ) )
61+
self.assertEqual( 2, chunk.interpolants[0] )
62+
self.assertEqual( 3, chunk.boundaries[0] )
63+
5364
self.assertEqual( 2, chunk.NC )
5465

5566
# verify string
@@ -82,6 +93,17 @@ def verify_chunk_lang14( self, chunk ) :
8293
self.assertAlmostEqual( 4., chunk.probabilities[1] )
8394
self.assertAlmostEqual( 6., chunk.probabilities[2] )
8495

96+
self.assertEqual( 1, chunk.NR )
97+
self.assertEqual( 1, chunk.number_interpolation_regions )
98+
self.assertEqual( 1, len( chunk.INT ) )
99+
self.assertEqual( 1, len( chunk.NBT ) )
100+
self.assertEqual( 4, chunk.INT[0] )
101+
self.assertEqual( 3, chunk.NBT[0] )
102+
self.assertEqual( 1, len( chunk.interpolants ) )
103+
self.assertEqual( 1, len( chunk.boundaries ) )
104+
self.assertEqual( 4, chunk.interpolants[0] )
105+
self.assertEqual( 3, chunk.boundaries[0] )
106+
85107
self.assertEqual( 2, chunk.NC )
86108

87109
# verify string

python/test/MF6/LAW2/Test_ENDFtk_MF6_LAW2_TabulatedDistribution.py

+22
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def verify_chunk_lang12( self, chunk ) :
5050
self.assertAlmostEqual( 4., chunk.probabilities[1] )
5151
self.assertAlmostEqual( 6., chunk.probabilities[2] )
5252

53+
self.assertEqual( 1, chunk.NR )
54+
self.assertEqual( 1, chunk.number_interpolation_regions )
55+
self.assertEqual( 1, len( chunk.INT ) )
56+
self.assertEqual( 1, len( chunk.NBT ) )
57+
self.assertEqual( 2, chunk.INT[0] )
58+
self.assertEqual( 3, chunk.NBT[0] )
59+
self.assertEqual( 1, len( chunk.interpolants ) )
60+
self.assertEqual( 1, len( chunk.boundaries ) )
61+
self.assertEqual( 2, chunk.interpolants[0] )
62+
self.assertEqual( 3, chunk.boundaries[0] )
63+
5364
self.assertEqual( 2, chunk.NC )
5465

5566
# verify string
@@ -82,6 +93,17 @@ def verify_chunk_lang14( self, chunk ) :
8293
self.assertAlmostEqual( 4., chunk.probabilities[1] )
8394
self.assertAlmostEqual( 6., chunk.probabilities[2] )
8495

96+
self.assertEqual( 1, chunk.NR )
97+
self.assertEqual( 1, chunk.number_interpolation_regions )
98+
self.assertEqual( 1, len( chunk.INT ) )
99+
self.assertEqual( 1, len( chunk.NBT ) )
100+
self.assertEqual( 4, chunk.INT[0] )
101+
self.assertEqual( 3, chunk.NBT[0] )
102+
self.assertEqual( 1, len( chunk.interpolants ) )
103+
self.assertEqual( 1, len( chunk.boundaries ) )
104+
self.assertEqual( 4, chunk.interpolants[0] )
105+
self.assertEqual( 3, chunk.boundaries[0] )
106+
85107
self.assertEqual( 2, chunk.NC )
86108

87109
# verify string

src/ENDFtk/section/26/DiscreteTwoBodyScattering/TabulatedDistribution/test/TabulatedDistribution.test.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ void verifyChunk( const TabulatedDistribution& chunk ) {
168168
CHECK_THAT( 4., WithinRel( chunk.probabilities()[1] ) );
169169
CHECK_THAT( 6., WithinRel( chunk.probabilities()[2] ) );
170170

171+
CHECK( 1 == chunk.NR() );
172+
CHECK( 1 == chunk.numberInterpolationRegions() );
173+
CHECK( 1 == chunk.INT().size() );
174+
CHECK( 1 == chunk.interpolants().size() );
175+
CHECK( 1 == chunk.NBT().size() );
176+
CHECK( 1 == chunk.boundaries().size() );
177+
CHECK( 2 == chunk.INT()[0] );
178+
CHECK( 2 == chunk.interpolants()[0] );
179+
CHECK( 3 == chunk.NBT()[0] );
180+
CHECK( 3 == chunk.boundaries()[0] );
181+
171182
CHECK( 2 == chunk.NC() );
172183
}
173184

src/ENDFtk/section/6/DiscreteTwoBodyScattering/TabulatedDistribution.hpp

+36
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,42 @@ class ENDFTK_PYTHON_EXPORT TabulatedDistribution : protected ListRecord {
9090
return this->F();
9191
}
9292

93+
/**
94+
* @brief Return the number of interpolation ranges
95+
*/
96+
static constexpr long NR() { return 1; }
97+
98+
/**
99+
* @brief Return the number of interpolation ranges
100+
*/
101+
static constexpr long numberInterpolationRegions() { return NR(); }
102+
103+
/**
104+
* @brief Return the interpolants
105+
*/
106+
auto INT() const {
107+
108+
return ranges::cpp20::views::single( this->LANG() - 10 );
109+
}
110+
111+
/**
112+
* @brief Return the interpolants
113+
*/
114+
auto interpolants() const { return this->INT(); }
115+
116+
/**
117+
* @brief Return the boundaries
118+
*/
119+
auto NBT() const {
120+
121+
return ranges::cpp20::views::single( this->numberCosineValues() );
122+
}
123+
124+
/**
125+
* @brief Return the boundaries
126+
*/
127+
auto boundaries() const { return this->NBT(); }
128+
93129
using ListRecord::NC;
94130
using ListRecord::print;
95131
};

src/ENDFtk/section/6/DiscreteTwoBodyScattering/TabulatedDistribution/test/TabulatedDistribution.test.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ void verifyChunkLANG12( const TabulatedDistribution& chunk ) {
223223
CHECK_THAT( 4., WithinRel( chunk.probabilities()[1] ) );
224224
CHECK_THAT( 6., WithinRel( chunk.probabilities()[2] ) );
225225

226+
CHECK( 1 == chunk.NR() );
227+
CHECK( 1 == chunk.numberInterpolationRegions() );
228+
CHECK( 1 == chunk.INT().size() );
229+
CHECK( 1 == chunk.interpolants().size() );
230+
CHECK( 1 == chunk.NBT().size() );
231+
CHECK( 1 == chunk.boundaries().size() );
232+
CHECK( 2 == chunk.INT()[0] );
233+
CHECK( 2 == chunk.interpolants()[0] );
234+
CHECK( 3 == chunk.NBT()[0] );
235+
CHECK( 3 == chunk.boundaries()[0] );
236+
226237
CHECK( 2 == chunk.NC() );
227238
}
228239

@@ -258,6 +269,17 @@ void verifyChunkLANG14( const TabulatedDistribution& chunk ) {
258269
CHECK_THAT( 4., WithinRel( chunk.probabilities()[1] ) );
259270
CHECK_THAT( 6., WithinRel( chunk.probabilities()[2] ) );
260271

272+
CHECK( 1 == chunk.NR() );
273+
CHECK( 1 == chunk.numberInterpolationRegions() );
274+
CHECK( 1 == chunk.INT().size() );
275+
CHECK( 1 == chunk.interpolants().size() );
276+
CHECK( 1 == chunk.NBT().size() );
277+
CHECK( 1 == chunk.boundaries().size() );
278+
CHECK( 4 == chunk.INT()[0] );
279+
CHECK( 4 == chunk.interpolants()[0] );
280+
CHECK( 3 == chunk.NBT()[0] );
281+
CHECK( 3 == chunk.boundaries()[0] );
282+
261283
CHECK( 2 == chunk.NC() );
262284
}
263285

0 commit comments

Comments
 (0)