mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Added regression tests for dlopen source
This commit is contained in:
parent
f387d2cba9
commit
cba7e9bc87
5 changed files with 93 additions and 57 deletions
23
tests/regression_tests/source_dlopen/inputs_true.dat
Normal file
23
tests/regression_tests/source_dlopen/inputs_true.dat
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<geometry>
|
||||
<cell id="13" material="1" region="-9" universe="9" />
|
||||
<surface boundary="vacuum" coeffs="0.0 0.0 0.0 100" id="9" type="sphere" />
|
||||
</geometry>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<materials>
|
||||
<material id="1" name="natural_lead">
|
||||
<density units="g/cm3" value="11.34" />
|
||||
<nuclide ao="0.014" name="Pb204" />
|
||||
<nuclide ao="0.241" name="Pb206" />
|
||||
<nuclide ao="0.221" name="Pb207" />
|
||||
<nuclide ao="0.524" name="Pb208" />
|
||||
</material>
|
||||
</materials>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<settings>
|
||||
<run_mode>fixed source</run_mode>
|
||||
<particles>1000</particles>
|
||||
<batches>10</batches>
|
||||
<inactive>0</inactive>
|
||||
<source library="./libsource.so" strength="1.0" />
|
||||
</settings>
|
||||
0
tests/regression_tests/source_dlopen/results_true.dat
Normal file
0
tests/regression_tests/source_dlopen/results_true.dat
Normal file
70
tests/regression_tests/source_dlopen/test.py
Normal file
70
tests/regression_tests/source_dlopen/test.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import openmc
|
||||
import pytest
|
||||
import os
|
||||
import glob
|
||||
|
||||
from tests.testing_harness import PyAPITestHarness
|
||||
|
||||
# compile the external source
|
||||
def compile_source():
|
||||
# first one should be CMakelists in share/
|
||||
files = glob.glob('../../../*/CMakeLists.txt')
|
||||
assert len(files) != 0
|
||||
|
||||
# copy the cmakefile
|
||||
status = os.system('rm -rf build')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
status = os.system('mkdir build ; cd build ; cp ../'+files[0]+' .')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
status = os.system('cd build ; cmake -DSOURCE_FILES=../source_sampling.cpp ; make')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
status = os.system('cp build/libsource.so .')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
status = os.system('rm -rf build')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
|
||||
return 0
|
||||
|
||||
class SourceTestHarness(PyAPITestHarness):
|
||||
# build the test geometry
|
||||
def _build_inputs(self):
|
||||
mats = openmc.Materials()
|
||||
|
||||
natural_lead = openmc.Material(1, "natural_lead")
|
||||
natural_lead.add_element('Pb', 1,'ao')
|
||||
natural_lead.set_density('g/cm3', 11.34)
|
||||
mats.append(natural_lead)
|
||||
|
||||
# surfaces
|
||||
surface_sph1 = openmc.Sphere(r=100,boundary_type='vacuum')
|
||||
volume_sph1 = -surface_sph1
|
||||
|
||||
# cell
|
||||
cell_1 = openmc.Cell(region=volume_sph1)
|
||||
cell_1.fill = natural_lead #assigning a material to a cell
|
||||
universe = openmc.Universe(cells=[cell_1]) #hint, this list will need to include the new cell
|
||||
geom = openmc.Geometry(universe)
|
||||
|
||||
# settings
|
||||
sett = openmc.Settings()
|
||||
batches = 10
|
||||
sett.batches = batches
|
||||
sett.inactive = 0
|
||||
sett.particles = 1000
|
||||
sett.particle = "neutron"
|
||||
sett.run_mode = 'fixed source'
|
||||
|
||||
#source
|
||||
source = openmc.Source()
|
||||
source.library = './libsource.so'
|
||||
sett.source = source
|
||||
|
||||
# run
|
||||
model = openmc.model.Model(geom,mats,sett)
|
||||
model.export_to_xml()
|
||||
return
|
||||
|
||||
def test_dlopen_source():
|
||||
compile_source()
|
||||
harness = SourceTestHarness('statepoint.10.h5')
|
||||
harness.main()
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import openmc
|
||||
import pytest
|
||||
import os
|
||||
|
||||
# compile the external source
|
||||
def compile_source():
|
||||
# needs a more robust way to know where the
|
||||
# Makefile is
|
||||
status = os.system('cp /usr/local/share/Makefile .')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
status = os.system('make')
|
||||
assert os.WEXITSTATUS(status) == 0
|
||||
|
||||
return
|
||||
|
||||
# build the test geometry
|
||||
def make_geometry():
|
||||
mats = openmc.Materials()
|
||||
|
||||
natural_lead = openmc.Material(1, "natural_lead")
|
||||
natural_lead.add_element('Pb', 1,'ao')
|
||||
natural_lead.set_density('g/cm3', 11.34)
|
||||
mats.append(natural_lead)
|
||||
|
||||
# surfaces
|
||||
surface_sph1 = openmc.Sphere(r=100)
|
||||
volume_sph1 = -surface_sph1
|
||||
|
||||
# cell
|
||||
cell_1 = openmc.Cell(region=volume_sph1)
|
||||
cell_1.fill = natural_lead #assigning a material to a cell
|
||||
universe = openmc.Universe(cells=[cell_1]) #hint, this list will need to include the new cell
|
||||
geom = openmc.Geometry(universe)
|
||||
|
||||
# settings
|
||||
sett = openmc.Settings()
|
||||
batches = 10
|
||||
sett.batches = batches
|
||||
sett.inactive = 0
|
||||
sett.particles = 1000
|
||||
sett.particle = "neutron"
|
||||
sett.run_mode = 'fixed source'
|
||||
|
||||
#source
|
||||
source = openmc.Source()
|
||||
source.library = PATH+'source_sampling.so'
|
||||
sett.source = source
|
||||
|
||||
# run
|
||||
model = openmc.model.Model(geom,mats,sett)
|
||||
return model
|
||||
|
||||
def test_dlopen_source():
|
||||
compile_source()
|
||||
model = make_geometry()
|
||||
model.run()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue