Skip to content

Commit fb113ba

Browse files
authored
Merge pull request #206 from njoy/fix/mf32mt151-njsx
Fix/mf32mt151 njsx
2 parents e2e2bab + 974d0ad commit fb113ba

File tree

9 files changed

+105
-25
lines changed

9 files changed

+105
-25
lines changed

ReleaseNotes.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ In addition, the following issues were corrected:
88
- 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.
99
- In MF8 MT457 DiscreteSpectrum, NT=8 (which can occur for electrons, i.e. STYP=8), was explicitly disallowed by ENDFtk. This was corrected and a new constructor reflecting this usage was added as well.
1010
- The STA variable in MF1 MT451 was interpreted incorrectly and this has now been fixed. An additional isUnstable() function has been added to the interface.
11+
- The NJSX value (the number of spin groups) is now read from the CONT record before the particle pairs in MF32 R-matrix limited uncertainties since SAMMY does not print the NJSX value on the particle pairs (the ENDF format basically has the NJSX value appear in two places and ENDFtk used the second one while SAMMY only prints out the first one). This "breaks" some interface functions (the R-matrix limited uncertainties from_string() function now requires the number of spin groups while previously it did not).
1112

1213
A few changes were also made to remove some range-v3 code in MF1 MT451. These changes have no impact on functionality.
1314

python/src/definitions.hpp

+32-16
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ void addStandardTableDefinitions( PythonClass& component ) {
9999
}
100100

101101
/**
102-
* @brief Add standard component definitions
102+
* @brief Add standard component definitions (excluding reading)
103103
*
104104
* This adds the following standard properties:
105-
* NC, from_string, to_string
105+
* copy constructor, NC, to_string
106106
*
107107
* @param[in] component the section to which the definitions have to be added
108108
*/
109109
template < typename Component, typename PythonClass >
110-
void addStandardComponentDefinitions( PythonClass& component ) {
110+
void addStandardComponentDefinitionsWithoutReading( PythonClass& component ) {
111111

112112
component
113113
.def(
@@ -125,6 +125,35 @@ void addStandardComponentDefinitions( PythonClass& component ) {
125125
[] ( const Component& self ) { return self.NC(); },
126126
"The number of lines in this component"
127127
)
128+
.def(
129+
130+
"to_string",
131+
[] ( const Component& self, int mat, int mf, int mt ) -> std::string
132+
{ return print( self, mat, mf, mt ); },
133+
python::arg( "mat" ), python::arg( "mf" ), python::arg( "mt" ),
134+
"Return the string representation of the component\n\n"
135+
"Arguments:\n"
136+
" self the component\n"
137+
" mat the MAT number to be used\n"
138+
" mf the MF number to be used\n"
139+
" mt the MT number to be used"
140+
);
141+
}
142+
143+
/**
144+
* @brief Add standard component definitions
145+
*
146+
* This adds the following standard properties:
147+
* NC, from_string, to_string
148+
*
149+
* @param[in] component the section to which the definitions have to be added
150+
*/
151+
template < typename Component, typename PythonClass >
152+
void addStandardComponentDefinitions( PythonClass& component ) {
153+
154+
addStandardComponentDefinitionsWithoutReading< Component >( component );
155+
156+
component
128157
.def_static(
129158

130159
"from_string",
@@ -140,19 +169,6 @@ void addStandardComponentDefinitions( PythonClass& component ) {
140169
" mat the MAT number of the section\n"
141170
" mf the MF number of the section\n"
142171
" mt the MT number of the section"
143-
)
144-
.def(
145-
146-
"to_string",
147-
[] ( const Component& self, int mat, int mf, int mt ) -> std::string
148-
{ return print( self, mat, mf, mt ); },
149-
python::arg( "mat" ), python::arg( "mf" ), python::arg( "mt" ),
150-
"Return the string representation of the component\n\n"
151-
"Arguments:\n"
152-
" self the component\n"
153-
" mat the MAT number to be used\n"
154-
" mf the MF number to be used\n"
155-
" mt the MT number to be used"
156172
);
157173
}
158174

python/src/section/32/151/CompactRMatrixLimitedUncertainties.python.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,34 @@ void wrapCompactRMatrixLimitedUncertainties( python::module& module, python::mod
7575
[] ( const Component& self ) -> SpinGroupRange
7676
{ return self.spinGroups(); },
7777
"The spin groups"
78+
)
79+
.def_static(
80+
81+
"from_string",
82+
[] ( const std::string& string, int mat, int mf, int mt, int njsx ) -> Component {
83+
84+
auto begin = string.begin();
85+
auto end = string.end();
86+
long lineNumber = 1;
87+
88+
return Component( begin, end, lineNumber, mat, mf, mt, njsx );
89+
},
90+
python::arg( "string" ), python::arg( "mat" ),
91+
python::arg( "mf" ), python::arg( "mt" ),
92+
python::arg( "njsx" ),
93+
"Read the component from a string\n\n"
94+
"An exception is raised if something goes wrong while reading the\n"
95+
"component\n\n"
96+
"Arguments:\n"
97+
" string the string representing the component\n"
98+
" mat the MAT number of the section\n"
99+
" mf the MF number of the section\n"
100+
" mt the MT number of the section\n"
101+
" njsx the number of spin groups"
78102
);
79103

80104
// add standard component definitions
81-
addStandardComponentDefinitions< Component >( component );
105+
addStandardComponentDefinitionsWithoutReading< Component >( component );
82106
}
83107

84108
} // namespace mf32

python/test/MF32/MT151/Test_ENDFtk_MF32_MT151_CompactRMatrixLimitedUncertainties.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def verify_chunk( self, chunk ) :
420420
verify_chunk( self, chunk )
421421

422422
# the data is read from a string
423-
chunk = CompactRMatrixLimitedUncertainties.from_string( self.chunk, 2625, 32, 151 )
423+
chunk = CompactRMatrixLimitedUncertainties.from_string( self.chunk, 2625, 32, 151, 2 )
424424

425425
verify_chunk( self, chunk )
426426

src/ENDFtk/section/32/151/CompactBreitWignerUncertainties/src/ctor.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,22 @@ CompactBreitWignerUncertainties( Iterator& it, const Iterator& end, long& lineNu
7272
int MAT, int MF, int MT ) :
7373
// no try ... catch: exceptions will be handled in the derived class
7474
CompactBreitWignerUncertainties( ListRecord( it, end, lineNumber, MAT, MF, MT ) ) {}
75+
76+
/**
77+
* @brief Constructor (from a buffer)
78+
*
79+
* @tparam Iterator a buffer iterator
80+
*
81+
* @param[in] it the current position in the buffer
82+
* @param[in] end the end of the buffer
83+
* @param[in] lineNumber the current line number
84+
* @param[in] MAT the expected MAT number
85+
* @param[in] MF the expected MF number
86+
* @param[in] MT the expected MT number
87+
* @param[in] unused placeholder
88+
*/
89+
template< typename Iterator >
90+
CompactBreitWignerUncertainties( Iterator& it, const Iterator& end, long& lineNumber,
91+
int MAT, int MF, int MT, int /* unused */ ) :
92+
// no try ... catch: exceptions will be handled in the derived class
93+
CompactBreitWignerUncertainties( it, end, lineNumber, MAT, MF, MT ) {}

src/ENDFtk/section/32/151/CompactCovarianceBase/src/ctor.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CompactCovarianceBase( double spi, double ap, long l1, long n1,
8484
// no try ... catch: exceptions will be handled in the derived class
8585
CompactCovarianceBase( spi, ap, l1, n1, std::move( dap ),
8686
ResonanceParameterUncertainties( it, end, lineNumber,
87-
MAT, MF, MT ),
87+
MAT, MF, MT, n1 ),
8888
it, end, lineNumber, MAT, MF, MT ) {}
8989

9090
/**

src/ENDFtk/section/32/151/CompactRMatrixLimitedUncertainties/src/ctor.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ template< typename Iterator >
2929
CompactRMatrixLimitedUncertainties(
3030
ParticlePairs&& pairs,
3131
Iterator& it, const Iterator& end, long& lineNumber,
32-
int MAT, int MF, int MT ) :
32+
int MAT, int MF, int MT, int NJSX ) :
3333
CompactRMatrixLimitedUncertainties(
3434
std::move( pairs ),
35-
readSequence< SpinGroup >( it, end, lineNumber, MAT, MF, MT, pairs.NJSX() ) ) {}
35+
readSequence< SpinGroup >( it, end, lineNumber, MAT, MF, MT, NJSX ) ) {}
3636

3737
public:
3838
/**
@@ -46,14 +46,15 @@ CompactRMatrixLimitedUncertainties(
4646
* @param[in] MAT the expected MAT number
4747
* @param[in] MF the expected MF number
4848
* @param[in] MT the expected MT number
49+
* @param[in] NJSX the number of spin groups to be read
4950
*/
5051
template< typename Iterator >
5152
CompactRMatrixLimitedUncertainties(
5253
Iterator& it, const Iterator& end, long& lineNumber,
53-
int MAT, int MF, int MT )
54+
int MAT, int MF, int MT, int NJSX )
5455
try : CompactRMatrixLimitedUncertainties(
5556
ParticlePairs( it, end, lineNumber, MAT, MF, MT ),
56-
it, end, lineNumber, MAT, MF, MT ) {}
57+
it, end, lineNumber, MAT, MF, MT, NJSX ) {}
5758
catch ( std::exception& e ) {
5859

5960
Log::info( "Encountered error while constructing R matrix limited "

src/ENDFtk/section/32/151/CompactRMatrixLimitedUncertainties/test/CompactRMatrixLimitedUncertainties.test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ SCENARIO( "CompactRMatrixLimitedUncertainties" ) {
7676
long lineNumber = 1;
7777

7878
CompactRMatrixLimitedUncertainties chunk( begin, end, lineNumber,
79-
2625, 32, 151 );
79+
2625, 32, 151, 2 );
8080

8181
THEN( "an CompactRMatrixLimitedUncertainties can be constructed and members can be "
8282
"tested" ) {
@@ -125,7 +125,7 @@ SCENARIO( "CompactRMatrixLimitedUncertainties" ) {
125125
THEN( "an exception is thrown" ) {
126126

127127
CHECK_THROWS( CompactRMatrixLimitedUncertainties( begin, end, lineNumber,
128-
2625, 2, 151 ) );
128+
2625, 2, 151, 0 ) );
129129
} // THEN
130130
} // WHEN
131131
} // GIVEN

src/ENDFtk/section/32/151/CompactReichMooreUncertainties/src/ctor.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,22 @@ CompactReichMooreUncertainties( Iterator& it, const Iterator& end, long& lineNum
7474
int MAT, int MF, int MT ) :
7575
// no try ... catch: exceptions will be handled in the derived class
7676
CompactReichMooreUncertainties( ListRecord( it, end, lineNumber, MAT, MF, MT ) ) {}
77+
78+
/**
79+
* @brief Constructor (from a buffer)
80+
*
81+
* @tparam Iterator a buffer iterator
82+
*
83+
* @param[in] it the current position in the buffer
84+
* @param[in] end the end of the buffer
85+
* @param[in] lineNumber the current line number
86+
* @param[in] MAT the expected MAT number
87+
* @param[in] MF the expected MF number
88+
* @param[in] MT the expected MT number
89+
* @param[in] unused placeholder
90+
*/
91+
template< typename Iterator >
92+
CompactReichMooreUncertainties( Iterator& it, const Iterator& end, long& lineNumber,
93+
int MAT, int MF, int MT, int /* unused */ ) :
94+
// no try ... catch: exceptions will be handled in the derived class
95+
CompactReichMooreUncertainties( it, end, lineNumber, MAT, MF, MT ) {}

0 commit comments

Comments
 (0)