Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 9 additions & 1 deletion cmake/OpenMCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
5 changes: 2 additions & 3 deletions docs/source/usersguide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..

Expand Down
16 changes: 3 additions & 13 deletions include/openmc/ncrystal_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define OPENMC_NCRYSTAL_INTERFACE_H

#ifdef NCRYSTAL
#include "NCrystal/NCRNG.hh"
#include "NCrystal/NCrystal.hh"
#endif

Expand Down Expand Up @@ -58,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:
Expand Down
14 changes: 7 additions & 7 deletions tests/regression_tests/ncrystal/results_true.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
46 changes: 0 additions & 46 deletions tools/ci/gha-install-ncrystal.sh

This file was deleted.

2 changes: 0 additions & 2 deletions tools/ci/gha-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion tools/ci/gha-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tools/ci/gha-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down