Adding a test plotting overlap regions.

This commit is contained in:
Patrick Shriwise 2019-06-11 16:14:08 -05:00
parent 43959714ee
commit 8946bbd238
7 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<geometry>
<surface id="1" type="z-cylinder" coeffs="0 0 2" />
<surface id="20" type="z-cylinder" coeffs="0 0 5.5" />
<surface id="2" type="z-cylinder" coeffs="0 0 5" />
<surface id="3" type="z-cylinder" coeffs="0 0 10" boundary="vacuum" />
<surface id="4" type="y-plane" coeffs="5" boundary="vacuum" />
<cell id="1" material="1" region=" -1 -4" />
<cell id="2" material="3" region="1 -20 -4" />
<cell id="3" material="2" region="2 -3 -4" />
</geometry>

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U235" ao="1.0" />
</material>
<material id="2">
<density value="4.5" units="g/cc" />
<nuclide name="U235" ao="1.0" />
</material>
<material id="3">
<density value="4.5" units="g/cc" />
<nuclide name="U235" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<plots>
<plot id="1" basis="xy">
<origin>0. 0. 0.</origin>
<width>25 25</width>
<pixels>200 200</pixels>
<color id="1" rgb="255 0 0" /> <!-- Red -->
<meshlines meshtype="entropy" linewidth="0" />
<show_overlaps>true</show_overlaps>
</plot>
<plot id="2" basis="xz">
<origin>0. 0. 0.</origin>
<width>25 25</width>
<pixels>200 200</pixels>
<mask components="1 3" background="255 255 255" />
<show_overlaps>true</show_overlaps>
<overlap_color>255 211 0</overlap_color>
</plot>
<plot id="3" basis="yz" color_by="material">
<origin>0. 0. 0.</origin>
<width>25 25</width>
<pixels>200 200</pixels>
<background>0 0 0</background>
</plot>
<plot id="4" type="voxel">
<pixels>100 100 10</pixels>
<origin>0. 0. 0.</origin>
<width>20 20 10</width>
</plot>
</plots>

View file

@ -0,0 +1 @@
1f962e0dfd63fc540c39faaf16eeb4a725b16c1a82e89972524716ff763d2d9e12f5ae9f50fafd86caeeb0bab54f8501e104ced085378e98cb9d014a357c7544

View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<settings>
<run_mode>plot</run_mode>
<mesh id="1">
<dimension>5 4 3</dimension>
<lower_left>-10 -10 -10</lower_left>
<upper_right>10 10 10</upper_right>
</mesh>
<entropy_mesh>1</entropy_mesh>
</settings>

View file

@ -0,0 +1,63 @@
import glob
import hashlib
import os
import h5py
import openmc
from tests.testing_harness import TestHarness
from tests.regression_tests import config
class PlotTestHarness(TestHarness):
"""Specialized TestHarness for running OpenMC plotting tests."""
def __init__(self, plot_names):
super().__init__(None)
self._plot_names = plot_names
def _run_openmc(self):
openmc.plot_geometry(openmc_exec=config['exe'])
def _test_output_created(self):
"""Make sure *.ppm has been created."""
for fname in self._plot_names:
assert os.path.exists(fname), 'Plot output file does not exist.'
def _cleanup(self):
super()._cleanup()
for fname in self._plot_names:
if os.path.exists(fname):
os.remove(fname)
def _get_results(self):
"""Return a string hash of the plot files."""
outstr = bytes()
for fname in self._plot_names:
if fname.endswith('.ppm'):
# Add PPM output to results
with open(fname, 'rb') as fh:
outstr += fh.read()
elif fname.endswith('.h5'):
# Add voxel data to results
with h5py.File(fname, 'r') as fh:
outstr += fh.attrs['filetype']
outstr += fh.attrs['num_voxels'].tostring()
outstr += fh.attrs['lower_left'].tostring()
outstr += fh.attrs['voxel_width'].tostring()
outstr += fh['data'].value.tostring()
# Hash the information and return.
sha512 = hashlib.sha512()
sha512.update(outstr)
outstr = sha512.hexdigest()
return outstr
def test_plot():
harness = PlotTestHarness(('plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm',
'plot_4.h5'))
harness.main()