mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Skip tests that require NJOY if it's not installed
This commit is contained in:
parent
33d7166aef
commit
e4e824fe4d
2 changed files with 19 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from collections.abc import Mapping, Callable
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
|
@ -12,6 +11,10 @@ import openmc.data
|
|||
_TEMPERATURES = [300., 600., 900.]
|
||||
_ENDF_DATA = os.environ['OPENMC_ENDF_DATA']
|
||||
|
||||
# Check if NJOY is available
|
||||
needs_njoy = pytest.mark.skipif(shutil.which('njoy') is None,
|
||||
reason="NJOY not installed")
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def pu239():
|
||||
|
|
@ -198,6 +201,7 @@ def test_fission(pu239):
|
|||
assert photon.particle == 'photon'
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_derived_products(am244):
|
||||
fission = am244.reactions[18]
|
||||
total_neutron = fission.derived_products[0]
|
||||
|
|
@ -220,6 +224,7 @@ def test_urr(pu239):
|
|||
assert ptable.table.shape[0] == ptable.energy.size
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_get_reaction_components(h2):
|
||||
assert h2.get_reaction_components(1) == [2, 16, 102]
|
||||
assert h2.get_reaction_components(101) == [102]
|
||||
|
|
@ -437,6 +442,7 @@ def test_laboratory(be9):
|
|||
assert np.all((-1. <= mu.x) & (mu.x <= 1.))
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_correlated(tmpdir):
|
||||
endf_file = os.path.join(_ENDF_DATA, 'neutrons', 'n-014_Si_030.endf')
|
||||
si30 = openmc.data.IncidentNeutron.from_njoy(endf_file, heatr=False)
|
||||
|
|
@ -447,6 +453,7 @@ def test_correlated(tmpdir):
|
|||
si30_copy = openmc.data.IncidentNeutron.from_hdf5(filename)
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_nbody(tmpdir, h2):
|
||||
# Convert to HDF5 and read back
|
||||
filename = str(tmpdir.join('h2.h5'))
|
||||
|
|
@ -461,6 +468,7 @@ def test_nbody(tmpdir, h2):
|
|||
assert nbody1.q_value == nbody2.q_value
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_ace_convert(run_in_tmpdir):
|
||||
filename = os.path.join(_ENDF_DATA, 'neutrons', 'n-001_H_001.endf')
|
||||
ace_ascii = 'ace_ascii'
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from collections.abc import Callable
|
||||
from math import exp
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
|
@ -12,6 +11,10 @@ import openmc.data
|
|||
|
||||
_ENDF_DATA = os.environ['OPENMC_ENDF_DATA']
|
||||
|
||||
# Check if NJOY is available
|
||||
needs_njoy = pytest.mark.skipif(shutil.which('njoy') is None,
|
||||
reason="NJOY not installed")
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def h2o():
|
||||
|
|
@ -101,6 +104,7 @@ def test_graphite_xs(graphite):
|
|||
assert elastic([1e-3, 1.0]) == pytest.approx([0.0, 0.62586153])
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_graphite_njoy():
|
||||
path_c0 = os.path.join(_ENDF_DATA, 'neutrons', 'n-006_C_000.endf')
|
||||
path_gr = os.path.join(_ENDF_DATA, 'thermal_scatt', 'tsl-graphite.endf')
|
||||
|
|
@ -112,6 +116,7 @@ def test_graphite_njoy():
|
|||
assert graphite.temperatures == ['296K']
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_export_to_hdf5(tmpdir, h2o_njoy, hzrh_njoy, graphite):
|
||||
filename = str(tmpdir.join('water.h5'))
|
||||
h2o_njoy.export_to_hdf5(filename)
|
||||
|
|
@ -131,6 +136,7 @@ def test_export_to_hdf5(tmpdir, h2o_njoy, hzrh_njoy, graphite):
|
|||
assert os.path.exists(filename)
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_continuous_dist(h2o_njoy):
|
||||
for temperature, dist in h2o_njoy.inelastic.distribution.items():
|
||||
assert temperature.endswith('K')
|
||||
|
|
@ -173,6 +179,7 @@ def test_hzrh_elastic(hzrh):
|
|||
assert dist.debye_waller > 0.0
|
||||
|
||||
|
||||
@needs_njoy
|
||||
def test_hzrh_njoy(hzrh_njoy):
|
||||
endf, ace = hzrh_njoy
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue