-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding logic to convert tabulated to constant multiplicity, started w…
…ork on createReactionProduct test
- Loading branch information
Showing
7 changed files
with
233 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATEMULTIPLICITY | ||
#define NJOY_DRYAD_FORMAT_ENDF_CREATEMULTIPLICITY | ||
|
||
// system includes | ||
#include <variant> | ||
|
||
// other includes | ||
#include "tools/Log.hpp" | ||
#include "dryad/format/endf/createTabulatedMultiplicity.hpp" | ||
#include "dryad/TabulatedMultiplicity.hpp" | ||
#include "ENDFtk/section/6.hpp" | ||
#include "ENDFtk/section/26.hpp" | ||
|
||
namespace njoy { | ||
namespace dryad { | ||
namespace format { | ||
namespace endf { | ||
|
||
/** | ||
* @brief Create an integer or tabulated multiplicity from a parsed ENDF multiplicity | ||
*/ | ||
template < typename Multiplicity > | ||
auto createMultiplicity( const Multiplicity& multiplicity ) | ||
-> std::enable_if_t< ( std::is_same_v< Multiplicity, ENDFtk::section::Type< 6 >::Multiplicity > || | ||
std::is_same_v< Multiplicity, ENDFtk::section::Type< 26 >::Multiplicity > ), | ||
std::variant< int, TabulatedMultiplicity > > { | ||
|
||
if ( scion::verification::isAllSameElement( multiplicity.multiplicities() ) ) { | ||
|
||
return static_cast< int >( std::round( multiplicity.multiplicities().front() ) ); | ||
} | ||
else { | ||
|
||
return createTabulatedMultiplicity( multiplicity ); | ||
} | ||
} | ||
|
||
} // endf namespace | ||
} // format namespace | ||
} // dryad namespace | ||
} // njoy namespace | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// 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/createMultiplicity.hpp" | ||
|
||
// other includes | ||
#include "ENDFtk/tree/fromFile.hpp" | ||
|
||
// convenience typedefs | ||
using namespace njoy::dryad; | ||
using Multiplicity = std::variant< int, TabulatedMultiplicity >; | ||
|
||
void verifyNeutronConstantChunk( const Multiplicity& ); | ||
void verifyNeutronTabulatedChunk( const Multiplicity& ); | ||
void verifyElectronConstantChunk( const Multiplicity& ); | ||
|
||
//! @todo look for an electron example where the multiplicity is tabulated? | ||
|
||
SCENARIO( "createTabulatedMultiplicity" ) { | ||
|
||
GIVEN( "ENDF MF6 multiplicities" ) { | ||
|
||
auto tape = njoy::ENDFtk::tree::fromFile( "n-017_Cl_035.endf" ); | ||
auto section = tape.materials().front().section( 6, 16 ).parse< 6 >(); | ||
auto constant = section.reactionProduct( 1 ).multiplicity(); | ||
auto tabulated = section.reactionProduct( 0 ).multiplicity(); | ||
|
||
WHEN( "a single parsed MF6 multiplicity with a constant value is given" ) { | ||
|
||
THEN( "it can be converted" ) { | ||
|
||
auto chunk = format::endf::createMultiplicity( constant ); | ||
|
||
verifyNeutronConstantChunk( chunk ); | ||
} // THEN | ||
} // WHEN | ||
|
||
WHEN( "a single parsed MF6 multiplicity with tabulated values is given" ) { | ||
|
||
THEN( "it can be converted" ) { | ||
|
||
auto chunk = format::endf::createMultiplicity( tabulated ); | ||
|
||
verifyNeutronTabulatedChunk( 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 constant = section.reactionProducts()[0].multiplicity(); | ||
|
||
WHEN( "a single parsed MF6 multiplicity with a constant value is given" ) { | ||
|
||
THEN( "it can be converted" ) { | ||
|
||
auto chunk = format::endf::createMultiplicity( constant ); | ||
|
||
verifyElectronConstantChunk( chunk ); | ||
} // THEN | ||
} // WHEN | ||
} // GIVEN | ||
} // SCENARIO | ||
|
||
void verifyNeutronConstantChunk( const Multiplicity& chunk ) { | ||
|
||
CHECK( true == std::holds_alternative< int >( chunk ) ); | ||
|
||
auto multiplicity = std::get< int >( chunk ); | ||
CHECK( 2 == multiplicity ); | ||
} | ||
|
||
void verifyNeutronTabulatedChunk( const Multiplicity& chunk ) { | ||
|
||
CHECK( true == std::holds_alternative< TabulatedMultiplicity >( chunk ) ); | ||
|
||
auto multiplicity = std::get< TabulatedMultiplicity >( chunk ); | ||
CHECK( true == multiplicity.isLinearised() ); | ||
CHECK( 15 == multiplicity.numberPoints() ); | ||
CHECK( 1 == multiplicity.numberRegions() ); | ||
CHECK( 15 == multiplicity.energies().size() ); | ||
CHECK( 15 == multiplicity.values().size() ); | ||
CHECK( 1 == multiplicity.boundaries().size() ); | ||
CHECK( 1 == multiplicity.interpolants().size() ); | ||
CHECK( 14 == multiplicity.boundaries()[0] ); | ||
CHECK( InterpolationType::LinearLinear == multiplicity.interpolants()[0] ); | ||
CHECK_THAT( 1.300979e+7, WithinRel( multiplicity.energies()[0] ) ); | ||
CHECK_THAT( 2e+7 , WithinRel( multiplicity.energies()[14] ) ); | ||
CHECK_THAT( 0.8634751 , WithinRel( multiplicity.values()[0] ) ); | ||
CHECK_THAT( 1.618791 , WithinRel( multiplicity.values()[14] ) ); | ||
} | ||
|
||
void verifyElectronConstantChunk( const Multiplicity& chunk ) { | ||
|
||
CHECK( true == std::holds_alternative< int >( chunk ) ); | ||
|
||
auto multiplicity = std::get< int >( chunk ); | ||
CHECK( 1 == multiplicity ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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/createReactionProduct.hpp" | ||
|
||
// other includes | ||
#include "ENDFtk/tree/fromFile.hpp" | ||
|
||
// convenience typedefs | ||
using namespace njoy::dryad; | ||
|
||
void verifyElectronlargeAngleElasticElectronProduct( const ReactionProduct& ); | ||
void verifyElectronBremsstrahlungPhotonProduct( const ReactionProduct& ); | ||
void verifyElectronBremsstrahlungElectronProduct( const ReactionProduct& ); | ||
|
||
SCENARIO( "createReactionProduct" ) { | ||
|
||
GIVEN( "ENDF reaction products - electro-atomic interactions" ) { | ||
|
||
auto tape = njoy::ENDFtk::tree::fromFile( "e-001_H_000.endf" ); | ||
auto material = tape.materials().front(); | ||
|
||
WHEN( "a single ENDF reaction product is given" ) { | ||
|
||
THEN( "a Reaction can be created" ) { | ||
|
||
auto elastic = tape.materials().front().section( 26, 525 ).parse< 26 >(); | ||
auto bremsstrahlung = tape.materials().front().section( 26, 527 ).parse< 26 >(); | ||
|
||
id::ParticleID projectile( "e-" ); | ||
id::ParticleID target( "H1" ); | ||
|
||
auto product = elastic.reactionProducts()[0]; | ||
ReactionProduct electron_elastic = format::endf::createReactionProduct( projectile, target, product ); | ||
verifyElectronlargeAngleElasticElectronProduct( electron_elastic ); | ||
|
||
product = bremsstrahlung.reactionProducts()[0]; | ||
ReactionProduct photon_bremsstrahlung = format::endf::createReactionProduct( projectile, target, product ); | ||
verifyElectronBremsstrahlungPhotonProduct( photon_bremsstrahlung ); | ||
|
||
product = bremsstrahlung.reactionProducts()[1]; | ||
ReactionProduct electron_bremsstrahlung = format::endf::createReactionProduct( projectile, target, product ); | ||
verifyElectronBremsstrahlungElectronProduct( electron_bremsstrahlung ); | ||
} // THEN | ||
} // WHEN | ||
} // GIVEN | ||
} // SCENARIO | ||
|
||
void verifyElectronlargeAngleElasticElectronProduct( const ReactionProduct& chunk ) { | ||
|
||
CHECK( id::ParticleID( "e-" ) == chunk.identifier() ); | ||
} | ||
|
||
void verifyElectronBremsstrahlungPhotonProduct( const ReactionProduct& chunk ) { | ||
|
||
CHECK( id::ParticleID( "g" ) == chunk.identifier() ); | ||
} | ||
|
||
void verifyElectronBremsstrahlungElectronProduct( const ReactionProduct& chunk ) { | ||
|
||
CHECK( id::ParticleID( "e-" ) == chunk.identifier() ); | ||
} |