Skip to content

Commit

Permalink
Merge pull request #2 from njoy/feature/xs
Browse files Browse the repository at this point in the history
Initial developments
  • Loading branch information
whaeck authored Jul 5, 2024
2 parents 667620c + 9b51fde commit ef04830
Show file tree
Hide file tree
Showing 82 changed files with 21,703 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ContinuousIntegration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ ubuntu-20.04, macos-11 ]
cxx: [ clang++, g++-10 ]
os: [ ubuntu-22.04, macos-12 ]
cxx: [ clang++, g++-11 ]
build_type: [ Debug, Release ]

steps:
Expand Down
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cmake_dependent_option(
"NOT ${subproject}" OFF
)
if ( dryad.python )
set( require.ENDFtk.python CACHE BOOL ON )
set( require.scion.python CACHE BOOL ON )
endif()

########################################################################
Expand Down Expand Up @@ -94,10 +94,17 @@ if( dryad.python )

pybind11_add_module( dryad.python
python/src/dryad.python.cpp
python/src/InteractionType.python.cpp
python/src/ReactionType.python.cpp
python/src/TabulatedCrossSection.python.cpp
python/src/TabulatedMultiplicity.python.cpp
python/src/ReactionProduct.python.cpp
python/src/Reaction.python.cpp
python/src/ProjectileTarget.python.cpp
)

target_link_libraries( dryad.python PRIVATE dryad )
add_dependencies( dryad.python ENDFtk.python )
add_dependencies( dryad.python scion.python )
target_include_directories( dryad.python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/python/src )
target_compile_options( dryad.python PRIVATE "-fvisibility=hidden" )
set_target_properties( dryad.python PROPERTIES OUTPUT_NAME dryad )
Expand All @@ -107,7 +114,7 @@ if( dryad.python )
message( STATUS "Building dryad's python API" )

list( APPEND DRYAD_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR} )
list( APPEND ENDFTK_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR}/_deps/endftk-build )
list( APPEND SCION_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR}/_deps/scion-build )

if( dryad.tests )
include( cmake/unit_testing_python.cmake )
Expand Down
7 changes: 7 additions & 0 deletions cmake/develop_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ FetchContent_Declare( tools
GIT_SHALLOW TRUE
)

FetchContent_Declare( ACEtk
GIT_REPOSITORY https://github.com/njoy/ACEtk.git
GIT_TAG v1.0.0
GIT_SHALLOW TRUE
)

FetchContent_Declare( ENDFtk
GIT_REPOSITORY https://github.com/njoy/ENDFtk.git
GIT_TAG v1.1.0
Expand Down Expand Up @@ -45,6 +51,7 @@ FetchContent_Declare( eigen
#######################################################################

FetchContent_MakeAvailable(
ACEtk
ENDFtk
scion
tools
Expand Down
8 changes: 7 additions & 1 deletion cmake/release_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ include( FetchContent )
# Declare project dependencies
#######################################################################

FetchContent_Declare( ACEtk
GIT_REPOSITORY https://github.com/njoy/ACEtk.git
GIT_TAG 29684a986a9c3df1281cbadb73a83775acf9fb69 # tag: v1.0.0
)

FetchContent_Declare( Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2
GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc # tag: v3.3.2
Expand Down Expand Up @@ -37,7 +42,7 @@ FetchContent_Declare( range-v3

FetchContent_Declare( scion
GIT_REPOSITORY https://github.com/njoy/scion
GIT_TAG d828ef47aa0d60daece9cdd5ff486d76aa6c8882 # develop
GIT_TAG ba080204ee9c9db5dc1a453c552c68bcd50b4e9b
)

FetchContent_Declare( spdlog
Expand All @@ -55,6 +60,7 @@ FetchContent_Declare( tools
#######################################################################

FetchContent_MakeAvailable(
ACEtk
eigen
ENDFtk
fast_float
Expand Down
9 changes: 9 additions & 0 deletions cmake/unit_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ endfunction()
#######################################################################
# Unit testing directories
#######################################################################

add_subdirectory( src/dryad/TabulatedCrossSection/test )
add_subdirectory( src/dryad/TabulatedMultiplicity/test )
add_subdirectory( src/dryad/ReactionProduct/test )
add_subdirectory( src/dryad/Reaction/test )
add_subdirectory( src/dryad/ProjectileTarget/test )

add_subdirectory( src/dryad/format/test )
add_subdirectory( src/dryad/format/endf/test )
8 changes: 7 additions & 1 deletion cmake/unit_testing_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function( add_python_test name source )
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python )
set_tests_properties( ${test_name}
PROPERTIES ENVIRONMENT
PYTHONPATH=${ENDFTK_PYTHONPATH}:${CODEX_PYTHONPATH}:$ENV{PYTHONPATH})
PYTHONPATH=${SCION_PYTHONPATH}:${DRYAD_PYTHONPATH}:$ENV{PYTHONPATH})

endfunction()

Expand All @@ -21,3 +21,9 @@ endfunction()
#######################################################################

message( STATUS "Adding dryad Python unit testing" )

add_python_test( TabulatedCrossSection Test_dryad_TabulatedCrossSection.py )
add_python_test( TabulatedMultiplicity Test_dryad_TabulatedMultiplicity.py )
add_python_test( ReactionProduct Test_dryad_ReactionProduct.py )
add_python_test( Reaction Test_dryad_Reaction.py )
add_python_test( ProjectileTarget Test_dryad_ProjectileTarget.py )
31 changes: 31 additions & 0 deletions python/src/InteractionType.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "dryad/InteractionType.hpp"

// namespace aliases
namespace python = pybind11;

void wrapInteractionType( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::InteractionType;

// wrap views created by this component

// create the component
python::enum_< Component > component(

module,
"InteractionType",
"The projectile-target interaction type",
python::arithmetic()
);

// wrap the component
component
.value( "Atomic", Component::Atomic )
.value( "Nuclear", Component::Nuclear );
}
135 changes: 135 additions & 0 deletions python/src/ProjectileTarget.python.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

// local includes
#include "dryad/ProjectileTarget.hpp"
#include "dryad/format/endf/createProjectileTargetFromFile.hpp"

// namespace aliases
namespace python = pybind11;

void wrapProjectileTarget( python::module& module, python::module& ) {

// type aliases
using Component = njoy::dryad::ProjectileTarget;
using ParticleID = njoy::dryad::ParticleID;
using Reaction = njoy::dryad::Reaction;
using ToleranceConvergence = njoy::dryad::ToleranceConvergence;
using InteractionType = njoy::dryad::InteractionType;

// wrap views created by this component

// create the component
python::class_< Component > component(

module,
"ProjectileTarget",
"A data associated to a given projectile and target"
);

// wrap the component
component
.def(

python::init< ParticleID, ParticleID, InteractionType,
std::vector< Reaction > >(),
python::arg( "projectile" ), python::arg( "target" ),
python::arg( "type" ), python::arg( "reactions" ),
"Initialise the ProjectileTarget\n\n"
"Arguments:\n"
" self the reaction\n"
" projectile the particle identifier\n"
" target the target identifier\n"
" type the interaction type\n"
" reactions the reaction data"
)
.def_property_readonly(

"projectile_identifier",
&Component::projectileIdentifier,
"The projectile identifier"
)
.def_property_readonly(

"target_identifier",
&Component::targetIdentifier,
"The target identifier"
)
.def_property_readonly(

"interaction_type",
&Component::interactionType,
"The interaction type (atomic or nuclear)"
)
.def_property_readonly(

"resonances",
&Component::resonances,
"The resonance parameters"
)
.def_property_readonly(

"reactions",
&Component::reactions,
"The reactions"
)
.def(

"has_reaction",
&Component::hasReaction,
"Return whether or not a reaction is present\n\n"
"Arguments:\n"
" self the ProjectileTarget\n"
" id the the reaction identifier"
)
.def(

"reaction",
&Component::reaction,
"Return the requested reaction\n\n"
"Arguments:\n"
" self the ProjectileTarget\n"
" id the the reaction identifier"
)
.def_property_readonly(

"is_linearised",
&Component::isLinearised,
"Flag indicating whether or not the data is linearised"
)
.def(

"linearise",
&Component::linearise,
python::arg( "tolerance" ) = ToleranceConvergence(),
"Linearise the data and return a new object\n\n"
"Arguments:\n"
" self the ProjectileTarget\n"
" tolerance the linearisation tolerance"
)
.def(

"linearise_inplace",
&Component::lineariseInplace,
python::arg( "tolerance" ) = ToleranceConvergence(),
"Linearise the data inplace\n\n"
"Arguments:\n"
" self the ProjectileTarget\n"
" tolerance the linearisation tolerance"
)
.def_static(

"from_endf_file",
[] ( const std::string& filename ) -> Component {

return njoy::dryad::format::endf::createProjectileTargetFromFile( filename );
},
python::arg( "filename" ),
"Create a ProjectileTarget from an ENDF file\n\n"
"If there are multiple materials in the ENDF file, only the first material\n"
"will be transformed into a ProjectileTarget.\n\n"
"Arguments:\n"
" filename the ENDF file name"
);
}
Loading

0 comments on commit ef04830

Please sign in to comment.