From 6d98e461947dd608defd49f5512eac9d507745dc Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 23 Jan 2025 09:51:38 +0100 Subject: [PATCH 1/6] Remove spurious NCrystal include which will be removed in NCrystal 4.0.0 --- include/openmc/ncrystal_interface.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index 5a3882df9c3..ade959288eb 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -2,7 +2,6 @@ #define OPENMC_NCRYSTAL_INTERFACE_H #ifdef NCRYSTAL -#include "NCrystal/NCRNG.hh" #include "NCrystal/NCrystal.hh" #endif From 8f3e86bfa94e02a0b7b222e40c0a3c706d626b01 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 23 Jan 2025 09:52:40 +0100 Subject: [PATCH 2/6] Make sure find_package(NCrystal) also works with pip installed NCrystal --- CMakeLists.txt | 10 +++++++++- docs/source/usersguide/install.rst | 5 ++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e15de1b6f66..f7079aebcdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index 1c0b7fa5b32..b86f5fee032 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -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 - `_ and `initialize - `_ - NCrystal and turn on the option in the CMake configuration step:: + `_ NCrystal and + turn on the option in the CMake configuration step:: cmake -DOPENMC_USE_NCRYSTAL=on .. From 571dce80c204ec55e378905a04f6d42c6425092b Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Tue, 11 Feb 2025 10:03:20 +0100 Subject: [PATCH 3/6] Also make OpenMCConfig.cmake work with NCrystal from pip wheels --- cmake/OpenMCConfig.cmake.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/OpenMCConfig.cmake.in b/cmake/OpenMCConfig.cmake.in index b3b901de427..b02bbffe5cf 100644 --- a/cmake/OpenMCConfig.cmake.in +++ b/cmake/OpenMCConfig.cmake.in @@ -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() \ No newline at end of file +endif() From bf3818b1baa34913be47733a23a3fe08dfa48f03 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Mon, 3 Feb 2025 07:08:12 +0100 Subject: [PATCH 4/6] Try to appease clang-format --- include/openmc/ncrystal_interface.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index ade959288eb..22422e378cf 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -57,19 +57,10 @@ class NCrystalMat { //---------------------------------------------------------------------------- // 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: From c4657fbb64317ac8a576644c254a2dbc968533d9 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Mon, 10 Feb 2025 19:17:03 +0100 Subject: [PATCH 5/6] Replace manual git clone and cmake build of NCrystal with pip install --- tools/ci/gha-install-ncrystal.sh | 46 -------------------------------- tools/ci/gha-install.py | 2 -- tools/ci/gha-install.sh | 4 ++- tools/ci/gha-script.sh | 2 -- 4 files changed, 3 insertions(+), 51 deletions(-) delete mode 100755 tools/ci/gha-install-ncrystal.sh diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh deleted file mode 100755 index 16f77e13e2b..00000000000 --- a/tools/ci/gha-install-ncrystal.sh +++ /dev/null @@ -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 diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index d52c4c8254c..1eb9a55b4dc 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -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') diff --git a/tools/ci/gha-install.sh b/tools/ci/gha-install.sh index cff7dc834f5..0475e28072b 100755 --- a/tools/ci/gha-install.sh +++ b/tools/ci/gha-install.sh @@ -16,7 +16,9 @@ fi # Install NCrystal if needed if [[ $NCRYSTAL = 'y' ]]; then - ./tools/ci/gha-install-ncrystal.sh + pip install ncrystal + #Basic verification: + nctool --test fi # Install vectfit for WMP generation if needed diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index 9de84f3e553..4733907eb25 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -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 From 14688c9741df786335319d30c615a7c08b816c10 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Tue, 11 Feb 2025 12:14:22 +0100 Subject: [PATCH 6/6] Update ncrystal/results_true.dat for NCrystal 4.0.0 --- tests/regression_tests/ncrystal/results_true.dat | 14 +++++++------- tools/ci/gha-install.sh | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/regression_tests/ncrystal/results_true.dat b/tests/regression_tests/ncrystal/results_true.dat index 3ef0306fdf4..28c02c51c44 100644 --- a/tests/regression_tests/ncrystal/results_true.dat +++ b/tests/regression_tests/ncrystal/results_true.dat @@ -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 diff --git a/tools/ci/gha-install.sh b/tools/ci/gha-install.sh index 0475e28072b..50f110ed4e6 100755 --- a/tools/ci/gha-install.sh +++ b/tools/ci/gha-install.sh @@ -16,8 +16,8 @@ fi # Install NCrystal if needed if [[ $NCRYSTAL = 'y' ]]; then - pip install ncrystal - #Basic verification: + pip install 'ncrystal>=4.0.0' + #Basic quick verification: nctool --test fi