Skip to content

Commit

Permalink
Adding reading MF4 data for elastic
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Aug 24, 2024
1 parent 318bc05 commit 1798392
Show file tree
Hide file tree
Showing 10 changed files with 552 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/dryad/format/endf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "dryad/format/endf/createTabulatedMultiplicity.hpp"
#include "dryad/format/endf/createMultiplicity.hpp"
#include "dryad/format/endf/createTabulatedCrossSection.hpp"
#include "dryad/format/endf/createLegendreAngularDistribution.hpp"
#include "dryad/format/endf/createLegendreAngularDistributions.hpp"
#include "dryad/format/endf/createTabulatedAngularDistribution.hpp"
#include "dryad/format/endf/createTabulatedAngularDistributions.hpp"
#include "dryad/format/endf/createTabulatedEnergyDistribution.hpp"
Expand Down
48 changes: 48 additions & 0 deletions src/dryad/format/endf/createLegendreAngularDistribution.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATELEGENDREANGULARDISTRIBUTION
#define NJOY_DRYAD_FORMAT_ENDF_CREATELEGENDREANGULARDISTRIBUTION

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/format/createVector.hpp"
#include "dryad/format/endf/createBoundaries.hpp"
#include "dryad/format/endf/createInterpolants.hpp"
#include "dryad/LegendreAngularDistribution.hpp"
#include "ENDFtk/section/6.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace endf {

/**
* @brief Create a LegendreAngularDistribution from a range of coefficients
*/
template < typename Range >
LegendreAngularDistribution createLegendreAngularDistribution( const Range& range, bool addOrderZero ) {

try {

auto coefficients = createVector( range );
if ( addOrderZero ) { coefficients.insert( coefficients.begin(), 1. ); }
for ( std::size_t index = 0; index < coefficients.size(); ++index ) {

coefficients[index] *= 0.5 * ( 2 * index + 1 );
}
return LegendreAngularDistribution( std::move( coefficients ) );
}
catch ( ... ) {

Log::info( "Error encountered while creating an energy distribution table" );
throw;
}
}

} // endf namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
56 changes: 56 additions & 0 deletions src/dryad/format/endf/createLegendreAngularDistributions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef NJOY_DRYAD_FORMAT_ENDF_CREATELEGENDREANGULARDISTRIBUTIONS
#define NJOY_DRYAD_FORMAT_ENDF_CREATELEGENDREANGULARDISTRIBUTIONS

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/format/createVector.hpp"
#include "dryad/format/endf/createBoundaries.hpp"
#include "dryad/format/endf/createInterpolants.hpp"
#include "dryad/format/endf/createLegendreAngularDistribution.hpp"
#include "dryad/LegendreAngularDistributions.hpp"
#include "ENDFtk/section/4.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace endf {

/**
* @brief Create a LegendreAngularDistributions instance from a parsed
* ENDF MF4 section
*/
LegendreAngularDistributions
createLegendreAngularDistributions(
const ENDFtk::section::Type< 4 >::LegendreDistributions& distribution ) {

try {

auto energies = createVector( distribution.incidentEnergies() );
std::vector< LegendreAngularDistribution > distributions;
distributions.reserve( energies.size() );
for ( auto&& entry : distribution.angularDistributions() ) {

distributions.emplace_back( createLegendreAngularDistribution( entry.coefficients(), true ) );
}
auto boundaries = createBoundaries( distribution.boundaries() );
auto interpolants = createInterpolants( distribution.interpolants() );
return LegendreAngularDistributions(
std::move( energies ), std::move( distributions ),
std::move( boundaries ), std::move( interpolants ) );
}
catch ( ... ) {

Log::info( "Error encountered while creating a Legendre angular distribution table" );
throw;
}
}

} // endf namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
20 changes: 20 additions & 0 deletions src/dryad/format/endf/createReactionProduct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "dryad/format/endf/createMultiplicity.hpp"
#include "dryad/format/endf/createTabulatedEnergyDistributions.hpp"
#include "dryad/format/endf/createTabulatedAngularDistributions.hpp"
#include "dryad/format/endf/createLegendreAngularDistributions.hpp"
#include "dryad/format/endf/createTabulatedAverageEnergy.hpp"
#include "dryad/format/endf/createTabulatedFormFactor.hpp"
#include "dryad/format/endf/createTabulatedScatteringFunction.hpp"
Expand All @@ -22,6 +23,25 @@ namespace dryad {
namespace format {
namespace endf {

/**
* @brief Create a ReactionProduct from a parsed ENDF MF4 LegendreDistributions
*
* @param[in] projectile the projectile identifier
* @param[in] target the target identifier
* @param[in] distributions the MF4 LegendreDistributions
*/
ReactionProduct
createReactionProduct( const id::ParticleID& projectile, const id::ParticleID& target,
const ENDFtk::section::Type< 4 >::LegendreDistributions& distributions ) {

id::ParticleID id = createProductIdentifier( 1, 0 );
Log::info( "Reading reaction product data for \'{}\'", id );
int multiplicity = 1;
auto distribution = TwoBodyDistributionData( ReferenceFrame::CentreOfMass,
createLegendreAngularDistributions( distributions ) );
return ReactionProduct( std::move( id ), std::move( multiplicity ), std::move( distribution ) );
}

/**
* @brief Create a ReactionProduct from a parsed ENDF MF6 reaction product
*
Expand Down
29 changes: 28 additions & 1 deletion src/dryad/format/endf/createReactionProducts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,34 @@ namespace endf {

if ( material.hasSection( 4, mt ) || material.hasSection( 5, mt ) ) {

Log::info( "Reading reaction product data from MF4 and/or MF5 is not implemented yet" );
switch ( mt ) {

case 2 : {

auto section = material.section( 4, mt ).parse< 4 >();
switch ( section.LTT() ) {

case 1 : {

using LegendreDistributions = ENDFtk::section::Type< 4 >::LegendreDistributions;
auto distributions = std::get< LegendreDistributions >( section.distributions() );
products.emplace_back( createReactionProduct( projectile, target, distributions ) );
break;
}
default : {

Log::info( "Any MF4 LTT different from 1 is not implemented yet" );
break;
}
}
break;
}
default : {

Log::info( "Reading reaction product data from MF4 and/or MF5 is not implemented yet" );
break;
}
}
}
else if ( material.hasSection( 6, mt ) ) {

Expand Down
28 changes: 27 additions & 1 deletion src/dryad/format/endf/createTabulatedEnergyDistribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,39 @@
#include "dryad/format/endf/createBoundaries.hpp"
#include "dryad/format/endf/createInterpolants.hpp"
#include "dryad/TabulatedEnergyDistribution.hpp"
#include "ENDFtk/section/6.hpp"
#include "ENDFtk/section/26.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace endf {

/**
* @brief Create a TabulatedEnergyDistribution from a parsed ENDF MF6 LAW = 1
* LegendreCoefficients entry
*/
TabulatedEnergyDistribution
createTabulatedEnergyDistribution(
const ENDFtk::section::Type< 6 >::ContinuumEnergyAngle::LegendreCoefficients& distribution ) {

//! @todo interpolants and boundaries on LegendreCoefficients for interpolation on
//! outgoing energy?
//! @todo what is the interpolation type over the outgoing energy axis?

try {

auto energies = createVector( distribution.energies() );
auto values = createVector( distribution.totalEmissionProbabilities() );
return TabulatedEnergyDistribution( std::move( energies ), std::move( values ) );
}
catch ( ... ) {

Log::info( "Error encountered while creating an energy distribution table" );
throw;
}
}

/**
* @brief Create a TabulatedEnergyDistribution from a parsed ENDF MF26 LAW = 1
* LegendreCoefficients entry (with NA = 0)
Expand Down Expand Up @@ -44,7 +70,7 @@ namespace endf {
}
catch ( ... ) {

Log::info( "Error encountered while creating an average reaction product energy table" );
Log::info( "Error encountered while creating an energy distribution table" );
throw;
}
}
Expand Down
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 @@ -10,6 +10,8 @@ add_cpp_test( format.endf.createReactionType createReactionType.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.createMultiplicity createMultiplicity.test.cpp )
add_cpp_test( format.endf.createLegendreAngularDistribution createLegendreAngularDistribution.test.cpp )
add_cpp_test( format.endf.createLegendreAngularDistributions createLegendreAngularDistributions.test.cpp )
add_cpp_test( format.endf.createTabulatedAngularDistribution createTabulatedAngularDistribution.test.cpp )
add_cpp_test( format.endf.createTabulatedAngularDistributions createTabulatedAngularDistributions.test.cpp )
add_cpp_test( format.endf.createTabulatedEnergyDistribution createTabulatedEnergyDistribution.test.cpp )
Expand Down
Loading

0 comments on commit 1798392

Please sign in to comment.