Skip to content

Commit

Permalink
Updating create tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Aug 5, 2024
1 parent 443e27d commit 382217c
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/dryad/format/endf/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ add_cpp_test( format.endf.createBoundaries createBoundaries.test.cpp )
add_cpp_test( format.endf.createInterpolant createInterpolant.test.cpp )
add_cpp_test( format.endf.createInterpolants createInterpolants.test.cpp )
add_cpp_test( format.endf.createProjectileIdentifier createProjectileIdentifier.test.cpp )
add_cpp_test( format.endf.createProductIdentifier createProductIdentifier.test.cpp )
add_cpp_test( format.endf.createTargetIdentifier createTargetIdentifier.test.cpp )
add_cpp_test( format.endf.createInteractionType createInteractionType.test.cpp )

add_cpp_test( format.endf.createTabulatedCrossSection createTabulatedCrossSection.test.cpp )
add_cpp_test( format.endf.createTabulatedMultiplicity createTabulatedMultiplicity.test.cpp )
add_cpp_test( format.endf.createReaction createReaction.test.cpp )
add_cpp_test( format.endf.createReactions createReactions.test.cpp )
add_cpp_test( format.endf.createProjectileTarget createProjectileTarget.test.cpp )
Expand Down
34 changes: 34 additions & 0 deletions src/dryad/format/endf/test/createProductIdentifier.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// include Catch2
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
using Catch::Matchers::WithinRel;

// what we are testing
#include "dryad/format/endf/createProductIdentifier.hpp"

// other includes

// convenience typedefs
using namespace njoy::dryad;

SCENARIO( "createProductIdentifier" ) {

GIVEN( "ENDF zap values" ) {

WHEN( "a single zap value is given" ) {

THEN( "it can be converted" ) {

CHECK( id::ParticleID( "g" ) == format::endf::createProductIdentifier( 0 ) );
CHECK( id::ParticleID( "n" ) == format::endf::createProductIdentifier( 1 ) );
CHECK( id::ParticleID( "e-" ) == format::endf::createProductIdentifier( 11 ) );
CHECK( id::ParticleID( "p" ) == format::endf::createProductIdentifier( 1001 ) );
CHECK( id::ParticleID( "d" ) == format::endf::createProductIdentifier( 1002 ) );
CHECK( id::ParticleID( "t" ) == format::endf::createProductIdentifier( 1003 ) );
CHECK( id::ParticleID( "he3" ) == format::endf::createProductIdentifier( 2003 ) );
CHECK( id::ParticleID( "a" ) == format::endf::createProductIdentifier( 2004 ) );
CHECK( id::ParticleID( "13027" ) == format::endf::createProductIdentifier( 13027 ) );
} // THEN
} // WHEN
} // GIVEN
} // SCENARIO
18 changes: 17 additions & 1 deletion src/dryad/format/endf/test/createProjectileTarget.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK( ReactionType::Summation == total.type() );
CHECK( false == total.hasProducts() );
CHECK( false == total.isLinearised() );

CHECK( std::nullopt == total.massDifferenceQValue() );
CHECK( std::nullopt == total.reactionQValue() );

CHECK( false == total.crossSection().isLinearised() );
CHECK( 153 == total.crossSection().numberPoints() );
CHECK( 2 == total.crossSection().numberRegions() );
Expand All @@ -90,6 +92,8 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK_THAT( 3.716477e+1, WithinRel( total.crossSection().values()[0] ) );
CHECK_THAT( 2.118421e+1, WithinRel( total.crossSection().values()[8] ) );
CHECK_THAT( 4.818679e-1, WithinRel( total.crossSection().values()[152] ) );

CHECK( 0 == total.products().size() );
}

void verifyElasticReaction( const Reaction& elastic ) {
Expand All @@ -98,10 +102,12 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK( ReactionType::Primary == elastic.type() );
CHECK( false == elastic.hasProducts() );
CHECK( true == elastic.isLinearised() );

CHECK( std::nullopt != elastic.massDifferenceQValue() );
CHECK( std::nullopt != elastic.reactionQValue() );
CHECK_THAT( 0, WithinRel( elastic.massDifferenceQValue().value() ) );
CHECK_THAT( 0, WithinRel( elastic.reactionQValue().value() ) );

CHECK( true == elastic.crossSection().isLinearised() );
CHECK( 153 == elastic.crossSection().numberPoints() );
CHECK( 1 == elastic.crossSection().numberRegions() );
Expand All @@ -115,18 +121,22 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK_THAT( 2e+7, WithinRel( elastic.crossSection().energies()[152] ) );
CHECK_THAT( 2.043608e+1, WithinRel( elastic.crossSection().values()[0] ) );
CHECK_THAT( 4.818408e-1, WithinRel( elastic.crossSection().values()[152] ) );

CHECK( 0 == elastic.products().size() );
}

void verifyCaptureReaction( const Reaction& capture ) {

CHECK( id::ReactionID( "102" ) == capture.identifier() );
CHECK( ReactionType::Primary == capture.type() );
CHECK( false == capture.hasProducts() );
CHECK( true == capture.hasProducts() );
CHECK( false == capture.isLinearised() );

CHECK( std::nullopt != capture.massDifferenceQValue() );
CHECK( std::nullopt != capture.reactionQValue() );
CHECK_THAT( 2.224648e+6, WithinRel( capture.massDifferenceQValue().value() ) );
CHECK_THAT( 2.224648e+6, WithinRel( capture.reactionQValue().value() ) );

CHECK( false == capture.crossSection().isLinearised() );
CHECK( 153 == capture.crossSection().numberPoints() );
CHECK( 2 == capture.crossSection().numberRegions() );
Expand All @@ -144,4 +154,10 @@ void verifyCaptureReaction( const Reaction& capture ) {
CHECK_THAT( 1.672869e+1, WithinRel( capture.crossSection().values()[0] ) );
CHECK_THAT( 4.950573e-4, WithinRel( capture.crossSection().values()[32] ) );
CHECK_THAT( 2.710792e-5, WithinRel( capture.crossSection().values()[152] ) );

CHECK( 2 == capture.products().size() );
auto gamma = capture.products()[0];
CHECK( id::ParticleID( "g" ) == gamma.identifier() );
auto deuterium = capture.products()[1];
CHECK( id::ParticleID( "d" ) == deuterium.identifier() );
}
20 changes: 20 additions & 0 deletions src/dryad/format/endf/test/createProjectileTargetFromFile.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ void verifyTotalReaction( const Reaction& total ) {

CHECK( id::ReactionID( "1" ) == total.identifier() );
CHECK( ReactionType::Summation == total.type() );
CHECK( false == total.hasProducts() );
CHECK( false == total.isLinearised() );

CHECK( std::nullopt == total.massDifferenceQValue() );
CHECK( std::nullopt == total.reactionQValue() );

CHECK( false == total.crossSection().isLinearised() );
CHECK( 153 == total.crossSection().numberPoints() );
CHECK( 2 == total.crossSection().numberRegions() );
Expand All @@ -86,17 +89,22 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK_THAT( 3.716477e+1, WithinRel( total.crossSection().values()[0] ) );
CHECK_THAT( 2.118421e+1, WithinRel( total.crossSection().values()[8] ) );
CHECK_THAT( 4.818679e-1, WithinRel( total.crossSection().values()[152] ) );

CHECK( 0 == total.products().size() );
}

void verifyElasticReaction( const Reaction& elastic ) {

CHECK( id::ReactionID( "2" ) == elastic.identifier() );
CHECK( ReactionType::Primary == elastic.type() );
CHECK( false == elastic.hasProducts() );
CHECK( true == elastic.isLinearised() );

CHECK( std::nullopt != elastic.massDifferenceQValue() );
CHECK( std::nullopt != elastic.reactionQValue() );
CHECK_THAT( 0, WithinRel( elastic.massDifferenceQValue().value() ) );
CHECK_THAT( 0, WithinRel( elastic.reactionQValue().value() ) );

CHECK( true == elastic.crossSection().isLinearised() );
CHECK( 153 == elastic.crossSection().numberPoints() );
CHECK( 1 == elastic.crossSection().numberRegions() );
Expand All @@ -110,16 +118,22 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK_THAT( 2e+7, WithinRel( elastic.crossSection().energies()[152] ) );
CHECK_THAT( 2.043608e+1, WithinRel( elastic.crossSection().values()[0] ) );
CHECK_THAT( 4.818408e-1, WithinRel( elastic.crossSection().values()[152] ) );

CHECK( 0 == elastic.products().size() );
}

void verifyCaptureReaction( const Reaction& capture ) {

CHECK( id::ReactionID( "102" ) == capture.identifier() );
CHECK( ReactionType::Primary == capture.type() );
CHECK( true == capture.hasProducts() );
CHECK( false == capture.isLinearised() );

CHECK( std::nullopt != capture.massDifferenceQValue() );
CHECK( std::nullopt != capture.reactionQValue() );
CHECK_THAT( 2.224648e+6, WithinRel( capture.massDifferenceQValue().value() ) );
CHECK_THAT( 2.224648e+6, WithinRel( capture.reactionQValue().value() ) );

CHECK( false == capture.crossSection().isLinearised() );
CHECK( 153 == capture.crossSection().numberPoints() );
CHECK( 2 == capture.crossSection().numberRegions() );
Expand All @@ -137,4 +151,10 @@ void verifyCaptureReaction( const Reaction& capture ) {
CHECK_THAT( 1.672869e+1, WithinRel( capture.crossSection().values()[0] ) );
CHECK_THAT( 4.950573e-4, WithinRel( capture.crossSection().values()[32] ) );
CHECK_THAT( 2.710792e-5, WithinRel( capture.crossSection().values()[152] ) );

CHECK( 2 == capture.products().size() );
auto gamma = capture.products()[0];
CHECK( id::ParticleID( "g" ) == gamma.identifier() );
auto deuterium = capture.products()[1];
CHECK( id::ParticleID( "d" ) == deuterium.identifier() );
}
18 changes: 17 additions & 1 deletion src/dryad/format/endf/test/createReaction.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK( ReactionType::Summation == total.type() );
CHECK( false == total.hasProducts() );
CHECK( false == total.isLinearised() );

CHECK( std::nullopt == total.massDifferenceQValue() );
CHECK( std::nullopt == total.reactionQValue() );

CHECK( false == total.crossSection().isLinearised() );
CHECK( 153 == total.crossSection().numberPoints() );
CHECK( 2 == total.crossSection().numberRegions() );
Expand All @@ -68,6 +70,8 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK_THAT( 3.716477e+1, WithinRel( total.crossSection().values()[0] ) );
CHECK_THAT( 2.118421e+1, WithinRel( total.crossSection().values()[8] ) );
CHECK_THAT( 4.818679e-1, WithinRel( total.crossSection().values()[152] ) );

CHECK( 0 == total.products().size() );
}

void verifyElasticReaction( const Reaction& elastic ) {
Expand All @@ -76,10 +80,12 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK( ReactionType::Primary == elastic.type() );
CHECK( false == elastic.hasProducts() );
CHECK( true == elastic.isLinearised() );

CHECK( std::nullopt != elastic.massDifferenceQValue() );
CHECK( std::nullopt != elastic.reactionQValue() );
CHECK_THAT( 0, WithinRel( elastic.massDifferenceQValue().value() ) );
CHECK_THAT( 0, WithinRel( elastic.reactionQValue().value() ) );

CHECK( true == elastic.crossSection().isLinearised() );
CHECK( 153 == elastic.crossSection().numberPoints() );
CHECK( 1 == elastic.crossSection().numberRegions() );
Expand All @@ -93,18 +99,22 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK_THAT( 2e+7, WithinRel( elastic.crossSection().energies()[152] ) );
CHECK_THAT( 2.043608e+1, WithinRel( elastic.crossSection().values()[0] ) );
CHECK_THAT( 4.818408e-1, WithinRel( elastic.crossSection().values()[152] ) );

CHECK( 0 == elastic.products().size() );
}

void verifyCaptureReaction( const Reaction& capture ) {

CHECK( id::ReactionID( "102" ) == capture.identifier() );
CHECK( ReactionType::Primary == capture.type() );
CHECK( false == capture.hasProducts() );
CHECK( true == capture.hasProducts() );
CHECK( false == capture.isLinearised() );

CHECK( std::nullopt != capture.massDifferenceQValue() );
CHECK( std::nullopt != capture.reactionQValue() );
CHECK_THAT( 2.224648e+6, WithinRel( capture.massDifferenceQValue().value() ) );
CHECK_THAT( 2.224648e+6, WithinRel( capture.reactionQValue().value() ) );

CHECK( false == capture.crossSection().isLinearised() );
CHECK( 153 == capture.crossSection().numberPoints() );
CHECK( 2 == capture.crossSection().numberRegions() );
Expand All @@ -122,4 +132,10 @@ void verifyCaptureReaction( const Reaction& capture ) {
CHECK_THAT( 1.672869e+1, WithinRel( capture.crossSection().values()[0] ) );
CHECK_THAT( 4.950573e-4, WithinRel( capture.crossSection().values()[32] ) );
CHECK_THAT( 2.710792e-5, WithinRel( capture.crossSection().values()[152] ) );

CHECK( 2 == capture.products().size() );
auto gamma = capture.products()[0];
CHECK( id::ParticleID( "g" ) == gamma.identifier() );
auto deuterium = capture.products()[1];
CHECK( id::ParticleID( "d" ) == deuterium.identifier() );
}
18 changes: 17 additions & 1 deletion src/dryad/format/endf/test/createReactions.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK( ReactionType::Summation == total.type() );
CHECK( false == total.hasProducts() );
CHECK( false == total.isLinearised() );

CHECK( std::nullopt == total.massDifferenceQValue() );
CHECK( std::nullopt == total.reactionQValue() );

CHECK( false == total.crossSection().isLinearised() );
CHECK( 153 == total.crossSection().numberPoints() );
CHECK( 2 == total.crossSection().numberRegions() );
Expand All @@ -69,6 +71,8 @@ void verifyTotalReaction( const Reaction& total ) {
CHECK_THAT( 3.716477e+1, WithinRel( total.crossSection().values()[0] ) );
CHECK_THAT( 2.118421e+1, WithinRel( total.crossSection().values()[8] ) );
CHECK_THAT( 4.818679e-1, WithinRel( total.crossSection().values()[152] ) );

CHECK( 0 == total.products().size() );
}

void verifyElasticReaction( const Reaction& elastic ) {
Expand All @@ -77,10 +81,12 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK( ReactionType::Primary == elastic.type() );
CHECK( false == elastic.hasProducts() );
CHECK( true == elastic.isLinearised() );

CHECK( std::nullopt != elastic.massDifferenceQValue() );
CHECK( std::nullopt != elastic.reactionQValue() );
CHECK_THAT( 0, WithinRel( elastic.massDifferenceQValue().value() ) );
CHECK_THAT( 0, WithinRel( elastic.reactionQValue().value() ) );

CHECK( true == elastic.crossSection().isLinearised() );
CHECK( 153 == elastic.crossSection().numberPoints() );
CHECK( 1 == elastic.crossSection().numberRegions() );
Expand All @@ -94,18 +100,22 @@ void verifyElasticReaction( const Reaction& elastic ) {
CHECK_THAT( 2e+7, WithinRel( elastic.crossSection().energies()[152] ) );
CHECK_THAT( 2.043608e+1, WithinRel( elastic.crossSection().values()[0] ) );
CHECK_THAT( 4.818408e-1, WithinRel( elastic.crossSection().values()[152] ) );

CHECK( 0 == elastic.products().size() );
}

void verifyCaptureReaction( const Reaction& capture ) {

CHECK( id::ReactionID( "102" ) == capture.identifier() );
CHECK( ReactionType::Primary == capture.type() );
CHECK( false == capture.hasProducts() );
CHECK( true == capture.hasProducts() );
CHECK( false == capture.isLinearised() );

CHECK( std::nullopt != capture.massDifferenceQValue() );
CHECK( std::nullopt != capture.reactionQValue() );
CHECK_THAT( 2.224648e+6, WithinRel( capture.massDifferenceQValue().value() ) );
CHECK_THAT( 2.224648e+6, WithinRel( capture.reactionQValue().value() ) );

CHECK( false == capture.crossSection().isLinearised() );
CHECK( 153 == capture.crossSection().numberPoints() );
CHECK( 2 == capture.crossSection().numberRegions() );
Expand All @@ -123,4 +133,10 @@ void verifyCaptureReaction( const Reaction& capture ) {
CHECK_THAT( 1.672869e+1, WithinRel( capture.crossSection().values()[0] ) );
CHECK_THAT( 4.950573e-4, WithinRel( capture.crossSection().values()[32] ) );
CHECK_THAT( 2.710792e-5, WithinRel( capture.crossSection().values()[152] ) );

CHECK( 2 == capture.products().size() );
auto gamma = capture.products()[0];
CHECK( id::ParticleID( "g" ) == gamma.identifier() );
auto deuterium = capture.products()[1];
CHECK( id::ParticleID( "d" ) == deuterium.identifier() );
}
Loading

0 comments on commit 382217c

Please sign in to comment.