Skip to content

Commit

Permalink
finishing adding coherent and incoherent for gnds
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Dec 7, 2024
1 parent 973b48c commit 66a127e
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 104 deletions.
6 changes: 3 additions & 3 deletions src/dryad/format/endf/createReactionProduct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace endf {

if ( real.has_value() || imaginary.has_value() ) {

auto distribution = CoherentDistributionData( ReferenceFrame::CentreOfMass,
auto distribution = CoherentDistributionData( ReferenceFrame::Laboratory,
createTabulatedScatteringFunction( coherent ),
createTabulatedFormFactor( real.value() ),
createTabulatedFormFactor( imaginary.value() ) );
Expand All @@ -161,7 +161,7 @@ namespace endf {
}
else {

auto distribution = CoherentDistributionData( ReferenceFrame::CentreOfMass,
auto distribution = CoherentDistributionData( ReferenceFrame::Laboratory,
createTabulatedScatteringFunction( coherent ) );
return ReactionProduct( std::move( id ), std::move( multiplicity ), std::move( distribution ) );
}
Expand All @@ -186,7 +186,7 @@ namespace endf {

//! @todo what about the reference frames?

auto distribution = IncoherentDistributionData( ReferenceFrame::CentreOfMass,
auto distribution = IncoherentDistributionData( ReferenceFrame::Laboratory,
createTabulatedScatteringFunction( incoherent ) );
return ReactionProduct( std::move( id ), std::move( multiplicity ), std::move( distribution ) );
}
Expand Down
4 changes: 2 additions & 2 deletions src/dryad/format/endf/test/createReactionProduct.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void verifyPhotonCoherentProduct( const ReactionProduct& chunk ) {
auto data = std::get< CoherentDistributionData >( chunk.distributionData().value() );

CHECK( DistributionDataType::Coherent == data.type() );
CHECK( ReferenceFrame::CentreOfMass == data.frame() );
CHECK( ReferenceFrame::Laboratory == data.frame() );

CHECK_THAT( 0. , WithinRel( data.scatteringFunction().lowerInverseLengthLimit() ) );
CHECK_THAT( 1e+9, WithinRel( data.scatteringFunction().upperInverseLengthLimit() ) );
Expand Down Expand Up @@ -367,7 +367,7 @@ void verifyPhotonIncoherentProduct( const ReactionProduct& chunk ) {
auto data = std::get< IncoherentDistributionData >( chunk.distributionData().value() );

CHECK( DistributionDataType::Incoherent == data.type() );
CHECK( ReferenceFrame::CentreOfMass == data.frame() );
CHECK( ReferenceFrame::Laboratory == data.frame() );

CHECK_THAT( 0. , WithinRel( data.scatteringFunction().lowerInverseLengthLimit() ) );
CHECK_THAT( 1e+9, WithinRel( data.scatteringFunction().upperInverseLengthLimit() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/dryad/format/endf/test/createReactionProducts.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void verifyPhotonCoherentProduct( const ReactionProduct& chunk ) {
auto data = std::get< CoherentDistributionData >( chunk.distributionData().value() );

CHECK( DistributionDataType::Coherent == data.type() );
CHECK( ReferenceFrame::CentreOfMass == data.frame() );
CHECK( ReferenceFrame::Laboratory == data.frame() );

CHECK_THAT( 0. , WithinRel( data.scatteringFunction().lowerInverseLengthLimit() ) );
CHECK_THAT( 1e+9, WithinRel( data.scatteringFunction().upperInverseLengthLimit() ) );
Expand Down
4 changes: 2 additions & 2 deletions src/dryad/format/endf/test/test_verification_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ void verifyPhotonCoherentReaction( const Reaction& coherent ) {
auto data = std::get< CoherentDistributionData >( gamma.distributionData().value() );

CHECK( DistributionDataType::Coherent == data.type() );
CHECK( ReferenceFrame::CentreOfMass == data.frame() );
CHECK( ReferenceFrame::Laboratory == data.frame() );

CHECK_THAT( 0. , WithinRel( data.scatteringFunction().lowerInverseLengthLimit() ) );
CHECK_THAT( 1e+9, WithinRel( data.scatteringFunction().upperInverseLengthLimit() ) );
Expand Down Expand Up @@ -871,7 +871,7 @@ void verifyPhotonIncoherentReaction( const Reaction& incoherent ) {
auto data = std::get< IncoherentDistributionData >( gamma.distributionData().value() );

CHECK( DistributionDataType::Incoherent == data.type() );
CHECK( ReferenceFrame::CentreOfMass == data.frame() );
CHECK( ReferenceFrame::Laboratory == data.frame() );

CHECK_THAT( 0. , WithinRel( data.scatteringFunction().lowerInverseLengthLimit() ) );
CHECK_THAT( 1e+9, WithinRel( data.scatteringFunction().upperInverseLengthLimit() ) );
Expand Down
68 changes: 68 additions & 0 deletions src/dryad/format/gnds/createCoherentDistributionData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef NJOY_DRYAD_FORMAT_GNDS_CREATECOHERENTDISTRIBUTIONDATA
#define NJOY_DRYAD_FORMAT_GNDS_CREATECOHERENTDISTRIBUTIONDATA

// system includes
#include <vector>

// other includes
#include "pugixml.hpp"
#include "tools/Log.hpp"
#include "dryad/format/gnds/createReferenceFrame.hpp"
#include "dryad/format/gnds/createTabulatedFormFactorFromNodes.hpp"
#include "dryad/format/gnds/createTabulatedScatteringFunctionFromNodes.hpp"
#include "dryad/CoherentDistributionData.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace gnds {

/**
* @brief Create a CoherentDistributionData from a GNDS coherentPhotonScattering node
*/
static CoherentDistributionData
createCoherentDistributionData( const pugi::xml_node& coherent ) {

// check that this is a valid coherentPhotonScattering node
throwExceptionOnWrongNode( coherent, "coherentPhotonScattering" );

// get the reference frame
auto frame = createReferenceFrame( coherent.attribute( "productFrame" ).as_string() );

auto node = coherent.child( "formFactor" ).first_child();
auto function = createTabulatedScatteringFunctionFromNodes( node );
std::optional< TabulatedFormFactor > real = std::nullopt;
std::optional< TabulatedFormFactor > imaginary = std::nullopt;

node = coherent.child( "realAnomalousFactor" ).first_child();
if ( node ) {

real = createTabulatedFormFactorFromNodes( node );
}

node = coherent.child( "imaginaryAnomalousFactor" ).first_child();
if ( node ) {

imaginary = createTabulatedFormFactorFromNodes( node );
}

if ( real.has_value() || imaginary.has_value() ) {

return CoherentDistributionData( std::move( frame ),
std::move( function ),
std::move( real.value() ),
std::move( imaginary.value() ) );
}
else {

return CoherentDistributionData( std::move( frame ),
std::move( function ) );
}
}

} // gnds namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
43 changes: 43 additions & 0 deletions src/dryad/format/gnds/createIncoherentDistributionData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef NJOY_DRYAD_FORMAT_GNDS_CREATEINIncoherentDistributionData
#define NJOY_DRYAD_FORMAT_GNDS_CREATEINIncoherentDistributionData

// system includes
#include <vector>

// other includes
#include "pugixml.hpp"
#include "tools/Log.hpp"
#include "dryad/format/gnds/createReferenceFrame.hpp"
#include "dryad/format/gnds/createTabulatedScatteringFunctionFromNodes.hpp"
#include "dryad/IncoherentDistributionData.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace gnds {

/**
* @brief Create a IncoherentDistributionData from a GNDS coherentPhotonScattering node
*/
static IncoherentDistributionData
createIncoherentDistributionData( const pugi::xml_node& incoherent ) {

// check that this is a valid coherentPhotonScattering node
throwExceptionOnWrongNode( incoherent, "incoherentPhotonScattering" );

// get the reference frame
auto frame = createReferenceFrame( incoherent.attribute( "productFrame" ).as_string() );

auto node = incoherent.child( "scatteringFactor" ).first_child();
auto function = createTabulatedScatteringFunctionFromNodes( node );

return IncoherentDistributionData( std::move( frame ),
std::move( function ) );
}

} // gnds namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
1 change: 0 additions & 1 deletion src/dryad/format/gnds/createProjectileTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// system includes
#include <vector>
#include <iostream>

// other includes
#include "pugixml.hpp"
Expand Down
18 changes: 18 additions & 0 deletions src/dryad/format/gnds/createReactionProduct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "dryad/format/gnds/createMultiplicity.hpp"
#include "dryad/format/gnds/createTwoBodyDistributionData.hpp"
#include "dryad/format/gnds/createUncorrelatedDistributionData.hpp"
#include "dryad/format/gnds/createCoherentDistributionData.hpp"
#include "dryad/format/gnds/createIncoherentDistributionData.hpp"
#include "dryad/format/gnds/createTabulatedAverageEnergy.hpp"
#include "dryad/ReactionProduct.hpp"

Expand Down Expand Up @@ -65,6 +67,22 @@ namespace gnds {
distribution = createUncorrelatedDistributionData( node );
}
}
else if ( strcmp( node.name(), "coherentPhotonScattering" ) == 0 ) {

// the data can be found in the double differential xs
node = product.parent().parent().parent().
child( "doubleDifferentialCrossSection" ).
find_child_by_attribute( "label", style.c_str() );
distribution = createCoherentDistributionData( node );
}
else if ( strcmp( node.name(), "incoherentPhotonScattering" ) == 0 ) {

// the data can be found in the double differential xs
node = product.parent().parent().parent().
child( "doubleDifferentialCrossSection" ).
find_child_by_attribute( "label", style.c_str() );
distribution = createIncoherentDistributionData( node );
}
}

// get distribution data
Expand Down
2 changes: 1 addition & 1 deletion src/dryad/format/gnds/createTabulatedCrossSection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// system includes
#include <vector>
#include <iostream>

// other includes
#include "pugixml.hpp"
#include "tools/Log.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace gnds {
}
else {

Log::error( "Expected either an XYs1d node or regions1d node with XYs1d nodes"
Log::error( "Expected either an XYs1d node or regions1d node with XYs1d nodes "
"for tabulated form factor data data" );
throw std::exception();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace gnds {
}
else {

Log::error( "Expected either an XYs1d node or regions1d node with XYs1d nodes"
Log::error( "Expected either an XYs1d node or regions1d node with XYs1d nodes "
"for tabulated scattering function data data" );
throw std::exception();
}
Expand Down
2 changes: 1 addition & 1 deletion src/dryad/format/gnds/createTwoBodyDistributionData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// system includes
#include <vector>
#include <iostream>

// other includes
#include "pugixml.hpp"
#include "tools/Log.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// system includes
#include <vector>
#include <iostream>

// other includes
#include "pugixml.hpp"
#include "tools/Log.hpp"
Expand Down
Loading

0 comments on commit 66a127e

Please sign in to comment.