diff --git a/src/dryad/format/endf/test/CMakeLists.txt b/src/dryad/format/endf/test/CMakeLists.txt index 388f8c8..5b779c2 100644 --- a/src/dryad/format/endf/test/CMakeLists.txt +++ b/src/dryad/format/endf/test/CMakeLists.txt @@ -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 ) diff --git a/src/dryad/format/endf/test/createProductIdentifier.test.cpp b/src/dryad/format/endf/test/createProductIdentifier.test.cpp new file mode 100644 index 0000000..cd71781 --- /dev/null +++ b/src/dryad/format/endf/test/createProductIdentifier.test.cpp @@ -0,0 +1,34 @@ +// include Catch2 +#include +#include +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 diff --git a/src/dryad/format/endf/test/createProjectileTarget.test.cpp b/src/dryad/format/endf/test/createProjectileTarget.test.cpp index 5578570..ed335e0 100644 --- a/src/dryad/format/endf/test/createProjectileTarget.test.cpp +++ b/src/dryad/format/endf/test/createProjectileTarget.test.cpp @@ -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() ); @@ -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 ) { @@ -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() ); @@ -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() ); @@ -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() ); } diff --git a/src/dryad/format/endf/test/createProjectileTargetFromFile.test.cpp b/src/dryad/format/endf/test/createProjectileTargetFromFile.test.cpp index e727a9b..2d1f1d5 100644 --- a/src/dryad/format/endf/test/createProjectileTargetFromFile.test.cpp +++ b/src/dryad/format/endf/test/createProjectileTargetFromFile.test.cpp @@ -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() ); @@ -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() ); @@ -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() ); @@ -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() ); } diff --git a/src/dryad/format/endf/test/createReaction.test.cpp b/src/dryad/format/endf/test/createReaction.test.cpp index 00fdb3e..b201748 100644 --- a/src/dryad/format/endf/test/createReaction.test.cpp +++ b/src/dryad/format/endf/test/createReaction.test.cpp @@ -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() ); @@ -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 ) { @@ -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() ); @@ -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() ); @@ -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() ); } diff --git a/src/dryad/format/endf/test/createReactions.test.cpp b/src/dryad/format/endf/test/createReactions.test.cpp index 3027998..ff39473 100644 --- a/src/dryad/format/endf/test/createReactions.test.cpp +++ b/src/dryad/format/endf/test/createReactions.test.cpp @@ -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() ); @@ -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 ) { @@ -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() ); @@ -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() ); @@ -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() ); } diff --git a/src/dryad/format/endf/test/createTabulatedMultiplicity.test.cpp b/src/dryad/format/endf/test/createTabulatedMultiplicity.test.cpp new file mode 100644 index 0000000..578ae8a --- /dev/null +++ b/src/dryad/format/endf/test/createTabulatedMultiplicity.test.cpp @@ -0,0 +1,91 @@ +// include Catch2 +#include +#include +using Catch::Matchers::WithinRel; + +// what we are testing +#include "dryad/format/endf/createTabulatedMultiplicity.hpp" + +// other includes +#include "ENDFtk/tree/fromFile.hpp" + +// convenience typedefs +using namespace njoy::dryad; + +void verifyNeutronChunk( const TabulatedMultiplicity& ); +void verifyElectronChunk( const TabulatedMultiplicity& ); + +SCENARIO( "createTabulatedMultiplicity" ) { + + GIVEN( "ENDF MF6 multiplicities" ) { + + auto tape = njoy::ENDFtk::tree::fromFile( "n-001_H_001.endf" ); + auto section = tape.materials().front().section( 6, 102 ).parse< 6 >(); + auto multiplicity = section.reactionProduct( 0 ).multiplicity(); + id::ParticleID product( "g" ); + int mt = 102; + + WHEN( "a single parsed MF6 multiplicity is given" ) { + + THEN( "it can be converted" ) { + + auto chunk = format::endf::createTabulatedMultiplicity( product, multiplicity, mt ); + + verifyNeutronChunk( chunk ); + } // THEN + } // WHEN + } // GIVEN + + GIVEN( "ENDF MF26 multiplicities" ) { + + auto tape = njoy::ENDFtk::tree::fromFile( "e-001_H_000.endf" ); + auto section = tape.materials().front().section( 26, 527 ).parse< 26 >(); + auto multiplicity = section.reactionProduct( 11 ).multiplicity(); + id::ParticleID product( "e-" ); + int mt = 102; + + WHEN( "a single parsed MF26 multiplicity is given" ) { + + THEN( "it can be converted" ) { + + auto chunk = format::endf::createTabulatedMultiplicity( product, multiplicity, mt ); + + verifyElectronChunk( chunk ); + } // THEN + } // WHEN + } // GIVEN +} // SCENARIO + +void verifyNeutronChunk( const TabulatedMultiplicity& chunk ) { + + CHECK( true == chunk.isLinearised() ); + CHECK( 2 == chunk.numberPoints() ); + CHECK( 1 == chunk.numberRegions() ); + CHECK( 2 == chunk.energies().size() ); + CHECK( 2 == chunk.values().size() ); + CHECK( 1 == chunk.boundaries().size() ); + CHECK( 1 == chunk.interpolants().size() ); + CHECK( 1 == chunk.boundaries()[0] ); + CHECK( InterpolationType::LinearLinear == chunk.interpolants()[0] ); + CHECK_THAT( 1e-5, WithinRel( chunk.energies()[0] ) ); + CHECK_THAT( 2e+7, WithinRel( chunk.energies()[1] ) ); + CHECK_THAT( 1, WithinRel( chunk.values()[0] ) ); + CHECK_THAT( 1, WithinRel( chunk.values()[1] ) ); +} + +void verifyElectronChunk( const TabulatedMultiplicity& chunk ) { + + CHECK( true == chunk.isLinearised() ); + CHECK( 2 == chunk.numberPoints() ); + CHECK( 1 == chunk.numberRegions() ); + CHECK( 2 == chunk.energies().size() ); + CHECK( 2 == chunk.values().size() ); + CHECK( 1 == chunk.boundaries().size() ); + CHECK( 1 == chunk.interpolants().size() ); + CHECK( 1 == chunk.boundaries()[0] ); + CHECK( InterpolationType::LinearLinear == chunk.interpolants()[0] ); + CHECK_THAT( 10, WithinRel( chunk.energies()[0] ) ); + CHECK_THAT( 1e+11, WithinRel( chunk.energies()[1] ) ); + CHECK_THAT( 1, WithinRel( chunk.values()[0] ) ); + CHECK_THAT( 1, WithinRel( chunk.values()[1] ) ); +}