Skip to content

Commit

Permalink
Verification tests of the multigroup table
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Apr 25, 2024
1 parent 4184675 commit 2541ff8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/NDItk/MultigroupTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MultigroupTable {
/* auxiliary functions */

#include "NDItk/MultigroupTable/src/readRecord.hpp"
#include "NDItk/MultigroupTable/src/verify.hpp"

public:

Expand Down
5 changes: 4 additions & 1 deletion src/NDItk/MultigroupTable/src/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ MultigroupTable( std::string zaid, std::string libname, std::string source,
xs.numberGroups(), xs.numberReactions() ),
structure_( std::move( structure ) ),
weights_( std::move( weigths ) ),
xs_( std::move( xs ) ) {}
xs_( std::move( xs ) ) {

this->verify();
}
23 changes: 23 additions & 0 deletions src/NDItk/MultigroupTable/src/verify.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @brief Verify the multigroup data
*
* The following verification tests are performed:
* - the number of groups accross the data is consistent
*/
void verify() {

// consistent group structure
const auto groups = this->metadata().numberGroups().value();
if ( ( this->structure().numberGroups() != groups ) ||
( this->flux().numberGroups() != groups ) ||
( this->reactionCrossSections().numberGroups() != groups ) ) {

Log::error( "Found inconsistent number of primary groups across the table" );
Log::info( "Number of primary groups in the metadata: {}", this->metadata().numberGroups().value() );
Log::info( "Number of primary groups in the structure: {}", this->structure().numberGroups() );
Log::info( "Number of primary groups in the flux weights: {}", this->flux().numberGroups() );
Log::info( "Number of primary groups in the reaction cross section data: {}",
this->reactionCrossSections().numberGroups() );
throw std::exception();
}
};
26 changes: 26 additions & 0 deletions src/NDItk/MultigroupTable/test/MultigroupTable.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ SCENARIO( "MultigroupTable" ) {
} // THEN
} // WHEN
} // GIVEN

GIVEN( "invalid data for a MultigroupTable instance" ) {

WHEN( "the number of groups is inconsistent" ) {

std::string zaid = "92235.711nm";
std::string name = "mendf71x";
std::string source = "12/22/2011";
std::string process = "08/07/2013";
double awr = 233.0248;
double weight = 235.043937521619;
double temperature = 2.53e-8;
double dilution = 1e+10;
multigroup::Structure structure( { 20., 18., 16., 14., 10., 5, 1, 1e-11 } ); // <-- 7 groups
multigroup::FluxWeights weights( { 0.1, 0.2, 0.25, 0.05, 0.15, 0.04 } ); // <-- 6 groups
multigroup::ReactionCrossSections xs( { { 2, 0.0, { 10., 20., 30., 40., 50., 60., 70., 80. } }, // <-- 8 groups
{ 16, 1.1234567, { 1., 2., 3., 4., 5., 6., 7., 8. } } } );

THEN( "an exception is thrown" ) {

CHECK_THROWS( MultigroupTable( std::move( zaid ), std::move( name ), std::move( source ),
std::move( process ), awr, weight, temperature, dilution,
std::move( structure ), std::move( weights ), std::move( xs ) ) );
} // THEN
} // WHEN
} // GIVEN
} // SCENARIO

std::string chunk() {
Expand Down

0 comments on commit 2541ff8

Please sign in to comment.