Skip to content

Commit

Permalink
Merge pull request #16 from njoy/feature/ace-part2
Browse files Browse the repository at this point in the history
Feature/ace part2
  • Loading branch information
whaeck authored Nov 8, 2024
2 parents 80a583b + b76a324 commit 01c9590
Show file tree
Hide file tree
Showing 15 changed files with 2,308 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endfunction()

message( STATUS "Adding dryad Python unit testing" )

add_python_test( id.ElementID id/Test_dryad_id_ElementID.py )
add_python_test( id.ElementID id/Test_dryad_id_ElementID.py )

add_python_test( TabulatedMultiplicity Test_dryad_TabulatedMultiplicity.py )
add_python_test( TabulatedAverageEnergy Test_dryad_TabulatedAverageEnergy.py )
Expand Down
6 changes: 6 additions & 0 deletions src/dryad/format/ace.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#include "dryad/format/ace/createTabulatedScatteringFunction.hpp"

#include "dryad/format/ace/photoatomic/createReactionNumbers.hpp"
#include "dryad/format/ace/photoatomic/createPartialReactionNumbers.hpp"
#include "dryad/format/ace/photoatomic/createTabulatedCrossSections.hpp"
#include "dryad/format/ace/photoatomic/createReactions.hpp"
#include "dryad/format/ace/photoatomic/createProjectileTarget.hpp"

#include "dryad/format/ace/electroatomic/createReactionNumbers.hpp"
#include "dryad/format/ace/electroatomic/createPartialReactionNumbers.hpp"
#include "dryad/format/ace/electroatomic/createTabulatedCrossSections.hpp"
#include "dryad/format/ace/electroatomic/createReactions.hpp"
#include "dryad/format/ace/electroatomic/createProjectileTarget.hpp"
35 changes: 35 additions & 0 deletions src/dryad/format/ace/electroatomic/createProjectileTarget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef NJOY_DRYAD_FORMAT_ACE_ELECTROATOMIC_CREATEPROJECTILETARGET
#define NJOY_DRYAD_FORMAT_ACE_ELECTROATOMIC_CREATEPROJECTILETARGET

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/ProjectileTarget.hpp"
#include "dryad/format/ace/electroatomic/createReactions.hpp"
#include "ACEtk/PhotoatomicTable.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace ace {
namespace electroatomic {

/**
* @brief Create a ProjectileTarget for electroatomic data
*/
ProjectileTarget createProjectileTarget( const ACEtk::PhotoatomicTable& table ) {

return ProjectileTarget( id::ParticleID( "e-" ), id::ParticleID( table.ZAID() ),
InteractionType::Atomic,
createReactions( table ) );
}

} // electroatomic namespace
} // ace namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
60 changes: 60 additions & 0 deletions src/dryad/format/ace/electroatomic/createReactions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef NJOY_DRYAD_FORMAT_ACE_ELECTROATOMIC_CREATEREACTIONS
#define NJOY_DRYAD_FORMAT_ACE_ELECTROATOMIC_CREATEREACTIONS

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/Reaction.hpp"
#include "dryad/format/ace/electroatomic/createReactionNumbers.hpp"
#include "dryad/format/ace/electroatomic/createPartialReactionNumbers.hpp"
#include "dryad/format/ace/electroatomic/createTabulatedCrossSections.hpp"
#include "ACEtk/PhotoatomicTable.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace ace {
namespace electroatomic {

/**
* @brief Create the reactions for electroatomic data
*/
std::vector< Reaction > createReactions( const ACEtk::PhotoatomicTable& table ) {

std::vector< Reaction > reactions;

auto numbers = createReactionNumbers( table );
auto partialNumbers = createPartialReactionNumbers( table );
auto xs = createTabulatedCrossSections( table );
auto size = numbers.size();

for ( std::size_t index = 0; index < size; ++index ) {

id::ReactionID id( std::to_string( numbers[index] ) );
if ( partialNumbers[index].size() == 0 ) {

reactions.emplace_back( std::move( id ), std::move( xs[index] ) );
}
else {

std::vector< id::ReactionID > partials( partialNumbers[index].size() );
std::transform( partialNumbers[index].begin(), partialNumbers[index].end(),
partials.begin(),
[] ( auto&& number ) { return std::to_string( number ); } );

reactions.emplace_back( std::move( id ), std::move( partials ), std::move( xs[index] ) );
}
}

return reactions;
}

} // electroatomic namespace
} // ace namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
35 changes: 35 additions & 0 deletions src/dryad/format/ace/photoatomic/createProjectileTarget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEPROJECTILETARGET
#define NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEPROJECTILETARGET

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/ProjectileTarget.hpp"
#include "dryad/format/ace/photoatomic/createReactions.hpp"
#include "ACEtk/PhotoatomicTable.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace ace {
namespace photoatomic {

/**
* @brief Create a ProjectileTarget for photoatomic data
*/
ProjectileTarget createProjectileTarget( const ACEtk::PhotoatomicTable& table ) {

return ProjectileTarget( id::ParticleID( "g" ), id::ParticleID( table.ZAID() ),
InteractionType::Atomic,
createReactions( table ) );
}

} // electroatomic namespace
} // ace namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
67 changes: 67 additions & 0 deletions src/dryad/format/ace/photoatomic/createReactionProducts.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEREACTIONPRODUCTS
#define NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEREACTIONPRODUCTS

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/ReactionProduct.hpp"
#include "dryad/format/ace/createTabulatedScatteringFunction.hpp"
#include "ACEtk/PhotoatomicTable.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace ace {
namespace photoatomic {

/**
* @brief Create partial reaction numbers for photoatomic data
*/
std::vector< std::vector< ReactionProduct > >
createReactionProducts( const ACEtk::PhotoatomicTable& table ) {

std::vector< std::vector< ReactionProduct > > products;

// total - MT501
products.push_back( {} );

// coherent scattering - MT502
products.push_back( {} );
products.back().emplace_back(
id::ParticleID( "g" ), 1,
CoherentDistributionData( ReferenceFrame::CentreOfMass,
createTabulatedScatteringFunction( table.coherentFormFactorBlock() ) ) );

// incoherent scattering - MT504
products.push_back( {} );
products.back().emplace_back(
id::ParticleID( "g" ), 1,
IncoherentDistributionData( ReferenceFrame::CentreOfMass,
createTabulatedScatteringFunction( table.incoherentScatteringFunctionBlock() ) ) );

// pair production - MT516 (sum of MT515 and MT517)
products.push_back( {} );

// photoelectric - MT522 (sum of MT534 and up)
products.push_back( {} );
if ( table.electronPhotonRelaxationFormat() > 0 ) {

for ( std::size_t index = 1; index <= table.numberElectronSubshells(); ++index ) {

// partial: subshell photoelectric - MT534 and up
products.push_back( {} );
}
}

return products;
}

} // photoatomic namespace
} // ace namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
64 changes: 64 additions & 0 deletions src/dryad/format/ace/photoatomic/createReactions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEREACTIONS
#define NJOY_DRYAD_FORMAT_ACE_PHOTOATOMIC_CREATEREACTIONS

// system includes
#include <vector>

// other includes
#include "tools/Log.hpp"
#include "dryad/Reaction.hpp"
#include "dryad/format/ace/photoatomic/createReactionNumbers.hpp"
#include "dryad/format/ace/photoatomic/createPartialReactionNumbers.hpp"
#include "dryad/format/ace/photoatomic/createTabulatedCrossSections.hpp"
#include "dryad/format/ace/photoatomic/createReactionProducts.hpp"
#include "ACEtk/PhotoatomicTable.hpp"

namespace njoy {
namespace dryad {
namespace format {
namespace ace {
namespace photoatomic {

/**
* @brief Create the reactions for photoatomic data
*/
std::vector< Reaction > createReactions( const ACEtk::PhotoatomicTable& table ) {

std::vector< Reaction > reactions;

auto numbers = createReactionNumbers( table );
auto partialNumbers = createPartialReactionNumbers( table );
auto xs = createTabulatedCrossSections( table );
auto products = createReactionProducts( table );
auto size = numbers.size();

for ( std::size_t index = 0; index < size; ++index ) {

id::ReactionID id( std::to_string( numbers[index] ) );
if ( partialNumbers[index].size() == 0 ) {

reactions.emplace_back( std::move( id ), std::move( xs[index] ),
std::move( products[index] ) );
}
else {

std::vector< id::ReactionID > partials( partialNumbers[index].size() );
std::transform( partialNumbers[index].begin(), partialNumbers[index].end(),
partials.begin(),
[] ( auto&& number ) { return std::to_string( number ); } );

reactions.emplace_back( std::move( id ), std::move( partials ), std::move( xs[index] ),
std::move( products[index] ) );
}
}

return reactions;
}

} // electroatomic namespace
} // ace namespace
} // format namespace
} // dryad namespace
} // njoy namespace

#endif
5 changes: 5 additions & 0 deletions src/dryad/format/ace/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ add_cpp_test( format.ace.createTabulatedScatteringFunction createTabula
add_cpp_test( format.ace.electroatomic.createReactionNumbers electroatomic/createReactionNumbers.test.cpp )
add_cpp_test( format.ace.electroatomic.createPartialReactionNumbers electroatomic/createPartialReactionNumbers.test.cpp )
add_cpp_test( format.ace.electroatomic.createTabulatedCrossSections electroatomic/createTabulatedCrossSections.test.cpp )
add_cpp_test( format.ace.electroatomic.createReactions electroatomic/createReactions.test.cpp )
add_cpp_test( format.ace.electroatomic.createProjectileTarget electroatomic/createProjectileTarget.test.cpp )

add_cpp_test( format.ace.photoatomic.createReactionNumbers photoatomic/createReactionNumbers.test.cpp )
add_cpp_test( format.ace.photoatomic.createPartialReactionNumbers photoatomic/createPartialReactionNumbers.test.cpp )
add_cpp_test( format.ace.photoatomic.createTabulatedCrossSections photoatomic/createTabulatedCrossSections.test.cpp )
add_cpp_test( format.ace.photoatomic.createReactionProducts photoatomic/createReactionProducts.test.cpp )
add_cpp_test( format.ace.photoatomic.createReactions photoatomic/createReactions.test.cpp )
add_cpp_test( format.ace.photoatomic.createProjectileTarget photoatomic/createProjectileTarget.test.cpp )
Loading

0 comments on commit 01c9590

Please sign in to comment.