Updates for building with NCrystal support (and fix CI) (#3274)

This commit is contained in:
Thomas Kittelmann 2025-02-11 15:18:27 +01:00 committed by GitHub
parent 7e033b25ad
commit 27ce2ceee3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 33 additions and 76 deletions

View file

@ -121,7 +121,15 @@ endmacro()
#===============================================================================
if(OPENMC_USE_NCRYSTAL)
find_package(NCrystal REQUIRED)
if(NOT DEFINED "NCrystal_DIR")
#Invocation of "ncrystal-config --show cmakedir" is needed to find NCrystal
#when it is installed from Python wheels:
execute_process(
COMMAND "ncrystal-config" "--show" "cmakedir"
OUTPUT_VARIABLE "NCrystal_DIR" OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
find_package(NCrystal 3.8.0 REQUIRED)
message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})")
endif()

View file

@ -10,6 +10,14 @@ if(@OPENMC_USE_DAGMC@)
endif()
if(@OPENMC_USE_NCRYSTAL@)
if(NOT DEFINED "NCrystal_DIR")
#Invocation of "ncrystal-config --show cmakedir" is needed to find NCrystal
#when it is installed from Python wheels:
execute_process(
COMMAND "ncrystal-config" "--show" "cmakedir"
OUTPUT_VARIABLE "NCrystal_DIR" OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
find_package(NCrystal REQUIRED)
message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})")
endif()
@ -41,4 +49,4 @@ endif()
if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW})
message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.")
endif()
endif()

View file

@ -287,9 +287,8 @@ Prerequisites
Adding this option allows the creation of materials from NCrystal, which
replaces the scattering kernel treatment of ACE files with a modular,
on-the-fly approach. To use it `install
<https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ and `initialize
<https://github.com/mctools/ncrystal/wiki/Using-NCrystal#setting-up>`_
NCrystal and turn on the option in the CMake configuration step::
<https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ NCrystal and
turn on the option in the CMake configuration step::
cmake -DOPENMC_USE_NCRYSTAL=on ..

View file

@ -2,7 +2,6 @@
#define OPENMC_NCRYSTAL_INTERFACE_H
#ifdef NCRYSTAL
#include "NCrystal/NCRNG.hh"
#include "NCrystal/NCrystal.hh"
#endif
@ -58,19 +57,10 @@ public:
//----------------------------------------------------------------------------
// Trivial methods when compiling without NCRYSTAL
std::string cfg() const
{
return "";
}
double xs(const Particle& p) const
{
return -1.0;
}
std::string cfg() const { return ""; }
double xs(const Particle& p) const { return -1.0; }
void scatter(Particle& p) const {}
operator bool() const
{
return false;
}
operator bool() const { return false; }
#endif
private:

View file

@ -106,8 +106,8 @@
104 1 1.82e+00 1.83e+00 1 total current 1.10e-05 4.07e-06
105 1 1.83e+00 1.85e+00 1 total current 1.50e-05 4.01e-06
106 1 1.85e+00 1.87e+00 1 total current 1.90e-05 4.82e-06
107 1 1.87e+00 1.88e+00 1 total current 2.20e-05 3.89e-06
108 1 1.88e+00 1.90e+00 1 total current 2.10e-05 3.79e-06
107 1 1.87e+00 1.88e+00 1 total current 2.30e-05 3.96e-06
108 1 1.88e+00 1.90e+00 1 total current 2.00e-05 3.94e-06
109 1 1.90e+00 1.92e+00 1 total current 1.50e-05 3.42e-06
110 1 1.92e+00 1.94e+00 1 total current 2.20e-05 5.12e-06
111 1 1.94e+00 1.95e+00 1 total current 2.10e-05 5.86e-06
@ -118,12 +118,12 @@
116 1 2.02e+00 2.04e+00 1 total current 1.30e-05 3.35e-06
117 1 2.04e+00 2.06e+00 1 total current 1.90e-05 4.07e-06
118 1 2.06e+00 2.08e+00 1 total current 1.30e-05 3.00e-06
119 1 2.08e+00 2.09e+00 1 total current 1.40e-05 4.00e-06
120 1 2.09e+00 2.11e+00 1 total current 3.10e-05 5.47e-06
119 1 2.08e+00 2.09e+00 1 total current 1.50e-05 4.28e-06
120 1 2.09e+00 2.11e+00 1 total current 3.00e-05 4.94e-06
121 1 2.11e+00 2.13e+00 1 total current 2.30e-05 5.39e-06
122 1 2.13e+00 2.15e+00 1 total current 2.20e-05 4.67e-06
123 1 2.15e+00 2.16e+00 1 total current 1.70e-05 4.48e-06
124 1 2.16e+00 2.18e+00 1 total current 1.60e-05 4.00e-06
123 1 2.15e+00 2.16e+00 1 total current 1.80e-05 4.67e-06
124 1 2.16e+00 2.18e+00 1 total current 1.50e-05 4.01e-06
125 1 2.18e+00 2.20e+00 1 total current 1.80e-05 4.16e-06
126 1 2.20e+00 2.22e+00 1 total current 1.80e-05 4.42e-06
127 1 2.22e+00 2.23e+00 1 total current 1.80e-05 5.54e-06
@ -135,7 +135,7 @@
133 1 2.32e+00 2.34e+00 1 total current 2.30e-05 3.96e-06
134 1 2.34e+00 2.36e+00 1 total current 1.90e-05 3.48e-06
135 1 2.36e+00 2.37e+00 1 total current 1.60e-05 3.71e-06
136 1 2.37e+00 2.39e+00 1 total current 1.60e-05 4.27e-06
136 1 2.37e+00 2.39e+00 1 total current 1.70e-05 4.48e-06
137 1 2.39e+00 2.41e+00 1 total current 2.30e-05 4.48e-06
138 1 2.41e+00 2.43e+00 1 total current 2.10e-05 3.48e-06
139 1 2.43e+00 2.44e+00 1 total current 1.60e-05 2.21e-06

View file

@ -1,46 +0,0 @@
#!/bin/bash
set -ex
cd $HOME
#Use the NCrystal develop branch (in the near future we can move this to master):
git clone https://github.com/mctools/ncrystal --branch develop --single-branch --depth 1 ncrystal_src
SRC_DIR="$PWD/ncrystal_src"
BLD_DIR="$PWD/ncrystal_bld"
INST_DIR="$PWD/ncrystal_inst"
PYTHON=$(which python3)
CPU_COUNT=1
mkdir "$BLD_DIR"
cd ncrystal_bld
cmake \
"${SRC_DIR}" \
-DBUILD_SHARED_LIBS=ON \
-DNCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE=ON \
-DNCRYSTAL_MODIFY_RPATH=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DNCRYSTAL_ENABLE_EXAMPLES=OFF \
-DNCRYSTAL_ENABLE_SETUPSH=OFF \
-DNCRYSTAL_ENABLE_DATA=EMBED \
-DCMAKE_INSTALL_PREFIX="${INST_DIR}" \
-DPython3_EXECUTABLE="$PYTHON"
make -j${CPU_COUNT:-1}
make install
#Note: There is no "make test" or "make ctest" functionality for NCrystal
# yet. If it appears in the future, we should add it here.
# Output the configuration to the log
"${INST_DIR}/bin/ncrystal-config" --setup
# Change environmental variables
eval $( "${INST_DIR}/bin/ncrystal-config" --setup )
# Check installation worked
nctool --test

View file

@ -42,8 +42,6 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys
if ncrystal:
cmake_cmd.append('-DOPENMC_USE_NCRYSTAL=ON')
ncrystal_path = os.environ.get('HOME') + '/ncrystal_inst'
cmake_cmd.append(f'-DCMAKE_PREFIX_PATH={ncrystal_path}')
# Build in coverage mode for coverage testing
cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on')

View file

@ -16,7 +16,9 @@ fi
# Install NCrystal if needed
if [[ $NCRYSTAL = 'y' ]]; then
./tools/ci/gha-install-ncrystal.sh
pip install 'ncrystal>=4.0.0'
#Basic quick verification:
nctool --test
fi
# Install vectfit for WMP generation if needed

View file

@ -16,8 +16,6 @@ fi
# Check NCrystal installation
if [[ $NCRYSTAL = 'y' ]]; then
# Change environmental variables
eval $( "${HOME}/ncrystal_inst/bin/ncrystal-config" --setup )
nctool --test
fi