From ddfda7e6eddc4c23c4ea5806e04aaf22a100ee72 Mon Sep 17 00:00:00 2001 From: Jingang Liang Date: Thu, 10 Sep 2020 07:31:46 +0800 Subject: [PATCH] added unit test for wmp genetation from ENDF --- .travis.yml | 2 ++ openmc/data/multipole.py | 4 +-- tests/unit_tests/test_data_multipole.py | 15 +++++++++ tools/ci/travis-install-vectfit.sh | 43 +++++++++++++++++++++++++ tools/ci/travis-install.sh | 5 +++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100755 tools/ci/travis-install-vectfit.sh diff --git a/.travis.yml b/.travis.yml index 3c66bb680..07719bba9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,8 @@ matrix: - python: "3.8" env: OMP=n MPI=y PHDF5=n - python: "3.8" + env: OMP=n MPI=y PHDF5=n VECTFIT=y + - python: "3.7" env: OMP=n MPI=y PHDF5=y - python: "3.8" env: OMP=y MPI=y PHDF5=y DAGMC=y diff --git a/openmc/data/multipole.py b/openmc/data/multipole.py index f268b35d1..230e944e4 100644 --- a/openmc/data/multipole.py +++ b/openmc/data/multipole.py @@ -175,7 +175,7 @@ def _vectfit_xs(energy, ce_xs, mts, rtol=1e-3, atol=1e-5, orders=None, """ - # import vectfit package: https://github.com/mit-crpg/vectfit + # import vectfit package: https://github.com/liangjg/vectfit import vectfit as vf ne = energy.size @@ -568,7 +568,7 @@ def _windowing(mp_data, rtol=1e-3, atol=1e-5, n_win=None, n_cf=None, """ - # import vectfit package: https://github.com/mit-crpg/vectfit + # import vectfit package: https://github.com/liangjg/vectfit import vectfit as vf # unpack multipole data diff --git a/tests/unit_tests/test_data_multipole.py b/tests/unit_tests/test_data_multipole.py index 02147bf0e..842b2fe89 100644 --- a/tests/unit_tests/test_data_multipole.py +++ b/tests/unit_tests/test_data_multipole.py @@ -5,6 +5,14 @@ import numpy as np import pytest import openmc.data +no_vectfit = False +try: + import vectfit as vf +except: + no_vectfit = True + +vf_only = pytest.mark.skipif(no_vectfit, reason="vectfit package not installed") + @pytest.fixture(scope='module') def u235(): @@ -46,3 +54,10 @@ def test_export_to_hdf5(tmpdir, u235): filename = str(tmpdir.join('092235.h5')) u235.export_to_hdf5(filename) assert os.path.exists(filename) + +@vf_only +def test_from_endf(): + endf_data = os.environ['OPENMC_ENDF_DATA'] + endf_file = os.path.join(endf_data, 'neutrons', 'n-001_H_001.endf') + return openmc.data.WindowedMultipole.from_endf( + endf_file, wmp_options={"search": True}) diff --git a/tools/ci/travis-install-vectfit.sh b/tools/ci/travis-install-vectfit.sh new file mode 100755 index 000000000..1f2ca224d --- /dev/null +++ b/tools/ci/travis-install-vectfit.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -ex + +#pip3 install pybind11 +PYBIND_BRANCH='master' +PYBIND_REPO='https://github.com/pybind/pybind11' + +XTL_BRANCH='0.6.9' +XTL_REPO='https://github.com/xtensor-stack/xtl' + +XTENSOR_BRANCH='0.21.2' +XTENSOR_REPO='https://github.com/xtensor-stack/xtensor' + +XTENSOR_PYTHON_BRANCH='0.24.1' +XTENSOR_PYTHON_REPO='https://github.com/xtensor-stack/xtensor-python' + +XTENSOR_BLAS_BRANCH='0.17.1' +XTENSOR_BLAS_REPO='https://github.com/xtensor-stack/xtensor-blas' + +cd $HOME +git clone -b $PYBIND_BRANCH $PYBIND_REPO +cd pybind11 && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTL_BRANCH $XTL_REPO +cd xtl && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_BRANCH $XTENSOR_REPO +cd xtensor && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_PYTHON_BRANCH $XTENSOR_PYTHON_REPO +cd xtensor-python && mkdir build && cd build && cmake .. && sudo make install + +cd $HOME +git clone -b $XTENSOR_BLAS_BRANCH $XTENSOR_BLAS_REPO +cd xtensor-blas && mkdir build && cd build && cmake .. && sudo make install + +# Install vectfit +cd $HOME +git clone https://github.com/liangjg/vectfit.git +pip3 install ./vectfit diff --git a/tools/ci/travis-install.sh b/tools/ci/travis-install.sh index 4e32f31cc..7bbe160aa 100755 --- a/tools/ci/travis-install.sh +++ b/tools/ci/travis-install.sh @@ -9,6 +9,11 @@ if [[ $DAGMC = 'y' ]]; then ./tools/ci/travis-install-dagmc.sh fi +# Install vectfit for WMP generation if needed +if [[ $VECTFIT = 'y' ]]; then + ./tools/ci/travis-install-vectfit.sh +fi + # Upgrade pip, pytest, numpy before doing anything else pip install --upgrade pip pip install --upgrade pytest