diff --git a/openmoc/plotter.py b/openmoc/plotter.py index 455520dea..7b00ad610 100644 --- a/openmoc/plotter.py +++ b/openmoc/plotter.py @@ -2,6 +2,7 @@ import sys from numbers import Integral, Real from collections import Iterable +import warnings import numpy as np import numpy.random @@ -45,7 +46,7 @@ plt.ioff() # Default matplotlib parameters to use in all plots -matplotlib_rcparams = matplotlib.rcParamsDefault +matplotlib_rcparams = matplotlib.rcParams matplotlib_rcparams['font.family'] = 'sans-serif' matplotlib_rcparams['font.weight'] = 'normal' matplotlib_rcparams['font.size'] = 15 @@ -61,6 +62,21 @@ basestring = str +def update_rc_param(curr_rc): + """Update matplotlib rcParams without triggering deprecation warnings. + + Parameters + ---------- + curr_rc : dictionary + A dictionary of matplotlib plotting parameters + + """ + + with warnings.catch_warnings(): + warnings.simplefilter("ignore", matplotlib.MatplotlibDeprecationWarning) + matplotlib.rcParams.update(curr_rc) + + def plot_tracks(track_generator, get_figure=False, plot_3D=False): """Plot the characteristic tracks from an OpenMOC simulation. @@ -95,10 +111,8 @@ def plot_tracks(track_generator, get_figure=False, plot_3D=False): directory = openmoc.get_output_directory() + subdirectory # Ensure that normal settings are used even if called from ipython - deprecated = ['text.latex.unicode', 'examples.directory'] - curr_rc = {k: matplotlib.rcParams[k] for k in matplotlib.rcParams.keys() - if matplotlib.__version__[0] < '3.0' or k not in deprecated} - matplotlib.rcParams.update(curr_rc) + curr_rc = matplotlib.rcParams.copy() + update_rc_param(curr_rc) # Make directory if it does not exist try: @@ -112,6 +126,9 @@ def plot_tracks(track_generator, get_figure=False, plot_3D=False): vals_per_track = openmoc.NUM_VALUES_PER_RETRIEVED_TRACK num_azim = track_generator.getNumAzim() spacing = track_generator.getDesiredAzimSpacing() + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + num_polar = track_generator.getNumPolar() + z_spacing = track_generator.getDesiredZSpacing() num_tracks = int(track_generator.getNumTracks()) coords = track_generator.retrieveTrackCoords(num_tracks*vals_per_track) @@ -140,10 +157,14 @@ def plot_tracks(track_generator, get_figure=False, plot_3D=False): title = 'Tracks for {0} angles and {1} cm spacing'\ .format(num_azim, spacing) + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + title = 'Tracks for {0}/{1} azimuthal/polar angles\n and {2}/{3} cm '\ + 'azimuthal/axial spacings'.format(num_azim, num_polar, spacing, + z_spacing) plt.title(title) # Restore settings if called from ipython - matplotlib.rcParams.update(curr_rc) + update_rc_param(curr_rc) # Save the figure to a file or return to user if track_generator.getGeometry().isRootDomain(): @@ -151,10 +172,13 @@ def plot_tracks(track_generator, get_figure=False, plot_3D=False): return fig else: filename = \ - 'tracks-{1}-angles-{2}.png'.format(directory, num_azim, + 'tracks-{0}-angles-{1}.png'.format(num_azim, spacing) - if plot_3D: - filename = '3d-' + filename + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + filename = '3d-tracks-{0}-azimuthal-{1}-polar-angles-{2}-'\ + 'azimuthal-{3}-z-spacing.png'.format(num_azim, num_polar, + spacing, z_spacing) + fig.savefig(directory+filename, bbox_inches='tight') plt.close(fig) @@ -196,10 +220,8 @@ def plot_segments(track_generator, get_figure=False, plot_3D=False): directory = openmoc.get_output_directory() + subdirectory # Ensure that normal settings are used even if called from ipython - deprecated = ['text.latex.unicode', 'examples.directory'] - curr_rc = {k: matplotlib.rcParams[k] for k in matplotlib.rcParams.keys() - if matplotlib.__version__[0] < '3.0' or k not in deprecated} - matplotlib.rcParams.update(curr_rc) + curr_rc = matplotlib.rcParams.copy() + update_rc_param(curr_rc) # Make directory if it does not exist try: @@ -213,6 +235,9 @@ def plot_segments(track_generator, get_figure=False, plot_3D=False): vals_per_segment = openmoc.NUM_VALUES_PER_RETRIEVED_SEGMENT num_azim = track_generator.getNumAzim() spacing = track_generator.getDesiredAzimSpacing() + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + num_polar = track_generator.getNumPolar() + z_spacing = track_generator.getDesiredZSpacing() num_segments = int(track_generator.getNumSegments()) num_fsrs = int(track_generator.getGeometry().getNumTotalFSRs()) coords = \ @@ -241,7 +266,7 @@ def plot_segments(track_generator, get_figure=False, plot_3D=False): numpy.random.shuffle(color_map) # Make figure of line segments for each track - fig = plt.figure() + fig = plt.figure(constrained_layout=True) fig.patch.set_facecolor('none') # Create a color map corresponding to FSR IDs @@ -266,12 +291,17 @@ def plot_segments(track_generator, get_figure=False, plot_3D=False): suptitle = 'Segments ({0} angles, {1} cm spacing)'.format(num_azim, spacing) + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + suptitle = 'Segments ({0}/{1} azimuthal/polar angles\n and {2}/{3} cm '\ + 'azimuthal/axial spacings'.format(num_azim, num_polar, spacing, + z_spacing) title = 'z = {0}'.format(z[0]) plt.suptitle(suptitle) - plt.title(title) + if not plot_3D: + plt.title(title) # Restore settings if called from ipython - matplotlib.rcParams.update(curr_rc) + update_rc_param(curr_rc) if track_generator.getGeometry().isRootDomain(): if get_figure: @@ -280,8 +310,10 @@ def plot_segments(track_generator, get_figure=False, plot_3D=False): filename = 'segments-{0}-angles-{1}-spacing'.format(num_azim, spacing) filename = '{0}-z-{1}.png'.format(filename, z[0]) - if plot_3D: - filename = '3d-' + filename + if plot_3D and isinstance(track_generator, openmoc.TrackGenerator3D): + filename = '3d-segments-{0}-azimuthal-{1}-polar-angles-{2}-'\ + 'azimuthal-{3}-z-spacing.png'.format(num_azim, num_polar, + spacing, z_spacing) fig.savefig(directory+filename, bbox_inches='tight') plt.close(fig) @@ -522,10 +554,10 @@ def plot_flat_source_regions(geometry, gridsize=250, xlim=None, ylim=None, cv.check_greater_than('marker_size', marker_size, 0) if geometry.getNumTotalFSRs() == 0: - py_printf('ERROR', 'Unable to plot the flat source regions ' + + py_printf('ERROR', 'Unable to plot the source regions ' + 'since no tracks have been generated.') - py_printf('NORMAL', 'Plotting the flat source regions...') + py_printf('NORMAL', 'Plotting the source regions...') global subdirectory, matplotlib_rcparams directory = openmoc.get_output_directory() + subdirectory @@ -544,31 +576,31 @@ def plot_flat_source_regions(geometry, gridsize=250, xlim=None, ylim=None, plot_params.zlim = zlim plot_params.plane = plane plot_params.offset = offset - plot_params.suptitle = 'Flat Source Regions' + plot_params.suptitle = 'Source Regions' if plane == 'xy': plot_params.title = 'z = {0}'.format(plot_params.offset) - plot_params.filename = 'flat-source-regions-z-{0}'\ + plot_params.filename = 'source-regions-z-{0}'\ .format(plot_params.offset) elif plane == 'xz': plot_params.title = 'y = {0}'.format(plot_params.offset) - plot_params.filename = 'flat-source-regions-y-{0}'\ + plot_params.filename = 'source-regions-y-{0}'\ .format(plot_params.offset) elif plane == 'yz': plot_params.title = 'x = {0}'.format(plot_params.offset) - plot_params.filename = 'flat-source-regions-x-{0}'\ + plot_params.filename = 'source-regions-x-{0}'\ .format(plot_params.offset) plot_params.interpolation = 'nearest' plot_params.vmin = 0 plot_params.vmax = num_fsrs - # Plot a 2D color map of the flat source regions + # Plot a 2D color map of the source regions figures = plot_spatial_data(fsrs_to_fsrs, plot_params, get_figure=True) if plot_params.geometry.isRootDomain(): fig = figures[0] - # Plot centroids on top of 2D flat source region color map + # Plot centroids on top of source region color map if centroids: # Populate a NumPy array with the FSR centroid coordinates @@ -849,7 +881,7 @@ def plot_energy_fluxes(solver, fsrs, group_bounds=None, norm=True, group_bounds : Iterable of Real or None, optional The bounds of the energy groups norm : bool, optional - Whether to normalize the fluxes (True by default) + Whether to normalize the fluxes to a unity flux sum (True by default) loglog : bool Whether to use a log scale on the x- and y-axes (True by default) get_figure : bool @@ -894,10 +926,8 @@ def plot_energy_fluxes(solver, fsrs, group_bounds=None, norm=True, directory = openmoc.get_output_directory() + subdirectory # Ensure that normal settings are used even if called from ipython - deprecated = ['text.latex.unicode', 'examples.directory'] - curr_rc = {k: matplotlib.rcParams[k] for k in matplotlib.rcParams.keys() - if matplotlib.__version__[0] < '3.0' or k not in deprecated} - matplotlib.rcParams.update(curr_rc) + curr_rc = matplotlib.rcParams.copy() + update_rc_param(curr_rc) # Make directory if it does not exist try: @@ -913,7 +943,7 @@ def plot_energy_fluxes(solver, fsrs, group_bounds=None, norm=True, # Initialize an empty list of Matplotlib figures if requestd by the user figures = [] - # Iterate over all flat source regions + # Iterate over all source regions for fsr in fsrs: # Allocate memory for an array of this FSR's fluxes @@ -967,7 +997,7 @@ def plot_energy_fluxes(solver, fsrs, group_bounds=None, norm=True, plt.close(fig) # Restore settings if called from ipython - matplotlib.rcParams.update(curr_rc) + update_rc_param(curr_rc) # Return the figures if requested by user if get_figure: @@ -992,7 +1022,7 @@ def plot_fission_rates(solver, nu=False, norm=False, transparent_zeros=True, Whether use the nu-fission rates instead of the fission rates (False by default) norm : bool - Whether to normalize the fission rates (False by default) + Whether to normalize the fission rates to the mean (False by default) transparent_zeros : bool Whether to make all non-fissionable FSRs transparent (True by default) gridsize : Integral, optional @@ -1028,7 +1058,7 @@ def plot_fission_rates(solver, nu=False, norm=False, transparent_zeros=True, global solver_types cv.check_type('solver', solver, solver_types) - py_printf('NORMAL', 'Plotting the flat source region fission rates...') + py_printf('NORMAL', 'Plotting the source region fission rates...') # Compute the volume-weighted fission rates for each FSR geometry = solver.getGeometry() @@ -1045,7 +1075,7 @@ def plot_fission_rates(solver, nu=False, norm=False, transparent_zeros=True, plot_params.zlim = zlim plot_params.plane = plane plot_params.offset = offset - plot_params.suptitle = 'Flat Source Region Fission Rates' + plot_params.suptitle = 'Source Region Fission Rates' if plane == 'xy': plot_params.title = 'z = {0}'.format(offset) plot_params.filename = 'fission-rates-z-{0}.png'.format(offset) @@ -1290,9 +1320,11 @@ def plot_spatial_data(domains_to_data, plot_params, get_figure=False): # Reshape data to 2D array for Matplotlib image plot surface.shape = (plot_params.gridsize, plot_params.gridsize) - # Normalize data to maximum if requested + # Normalize data to average if requested if plot_params.norm: - surface /= np.max(surface) + if np.nanmean(surface) == 0: + py_printf('WARNING', "Normalizing plot colormap by 0.") + surface /= np.nanmean(surface) # Set zero data entries to NaN so Matplotlib will make them transparent if plot_params.transparent_zeros: @@ -1326,13 +1358,10 @@ def plot_spatial_data(domains_to_data, plot_params, get_figure=False): else: # Ensure that normal settings are used even if called from ipython - deprecated = ['text.latex.unicode', 'examples.directory'] - curr_rc = {k: matplotlib.rcParams[k] for k in - matplotlib.rcParams.keys() if matplotlib.__version__[0] - < '3.0' or k not in deprecated} - matplotlib.rcParams.update(curr_rc) + curr_rc = matplotlib.rcParams.copy() + update_rc_param(curr_rc) - fig = plt.figure() + fig = plt.figure(constrained_layout=True) fig.patch.set_facecolor('none') plt.imshow(np.flipud(surface), extent=coords['bounds'], interpolation=plot_params.interpolation, @@ -1366,7 +1395,7 @@ def plot_spatial_data(domains_to_data, plot_params, get_figure=False): plt.close() # Restore settings if called from ipython - matplotlib.rcParams.update(curr_rc) + update_rc_param(curr_rc) # Return Matplotlib figures if requested by user if get_figure: @@ -1411,10 +1440,8 @@ def plot_quadrature(solver, get_figure=False): directory = openmoc.get_output_directory() + subdirectory # Ensure that normal settings are used even if called from ipython - deprecated = ['text.latex.unicode', 'examples.directory'] - curr_rc = {k: matplotlib.rcParams[k] for k in matplotlib.rcParams.keys() - if matplotlib.__version__[0] < '3.0' or k not in deprecated} - matplotlib.rcParams.update(curr_rc) + curr_rc = matplotlib.rcParams.copy() + update_rc_param(curr_rc) # Make directory if it does not exist try: @@ -1497,7 +1524,7 @@ def plot_quadrature(solver, get_figure=False): plt.title(title) # Restore settings if called from ipython - matplotlib.rcParams.update(curr_rc) + update_rc_param(curr_rc) # Save the figure or return to user if track_generator.getGeometry().isRootDomain(): diff --git a/tests/input_set.py b/tests/input_set.py index cd51a97fc..b9b236631 100644 --- a/tests/input_set.py +++ b/tests/input_set.py @@ -12,10 +12,11 @@ class InputSet(object): __metaclass__ = ABCMeta - def __init__(self, num_dimensions=2): + def __init__(self, num_dimensions=2, small=False): self.materials = {} self.geometry = None self.dimensions = num_dimensions + self.small = small @abstractmethod def create_materials(self): @@ -416,7 +417,6 @@ def create_geometry(self): super(SimpleLatticeInput, self).create_geometry() - class PwrAssemblyInput(InputSet): """A 17x17 pin cell lattice problem from sample-input/ipython-notebook.""" @@ -569,7 +569,8 @@ def create_materials(self): directory='../../sample-input/') def create_geometry(self): - """Instantiate a 4x4 non-uniform simple lattice Geometry.""" + """Instantiate a 4x4 non-uniform simple lattice Geometry. + Lower left is at [0, 0, 0] and width is [2.62, 2.62, 2.5]""" fuel_rings = 1 moderator_rings = 1 @@ -804,8 +805,11 @@ def create_geometry(self): lower_left = [0.,0.,0.] # set the XYZ widths of non-uniform lattice + n_z = 20 + if self.small: + n_z = 5 width = ([gap_size,pin_pitch,pin_pitch,gap_size], - [gap_size,pin_pitch,pin_pitch,gap_size], [1.0]*20) + [gap_size,pin_pitch,pin_pitch,gap_size], [1.0]*n_z) lattice = openmoc.Lattice(name='lattice with gap') lattice.setWidths(width[0], width[1], width[2]) lattice.setOffset(lower_left[0]+sum(width[0])/2., @@ -817,7 +821,7 @@ def create_geometry(self): [g,f,f,g], [g,f,f,g], [g,g,g,g]]) - fill_universes = numpy.tile(a,(20,1,1)) + fill_universes = numpy.tile(a,(n_z,1,1)) # make the geometry axially heterogeneous fill_universes[2][1][1] = g diff --git a/tests/test_plot_3D_cells/test_plot_3D_cells.py b/tests/test_plot_3D_cells/test_plot_3D_cells.py new file mode 100644 index 000000000..41790f420 --- /dev/null +++ b/tests/test_plot_3D_cells/test_plot_3D_cells.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +from openmoc.plotter import plot_cells +import openmoc + + +class PlotCellsTestHarness(PlottingTestHarness): + """Test cell plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotCellsTestHarness, self).__init__() + self.input_set = NonUniformLatticeInput() + + def _run_openmoc(self): + """Plot the cells in the geometry.""" + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True)) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True)) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True, xlim=(0., 2.), ylim=(0., 2.))) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True, library='pil')) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, plane="yz", + offset=0.6, get_figure=True)) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, plane="xz", + offset=0.6, get_figure=True)) + + +if __name__ == '__main__': + harness = PlotCellsTestHarness() + harness.main() diff --git a/tests/test_plot_3D_cells/true-0.png b/tests/test_plot_3D_cells/true-0.png new file mode 100644 index 000000000..c0a8c7516 Binary files /dev/null and b/tests/test_plot_3D_cells/true-0.png differ diff --git a/tests/test_plot_3D_cells/true-1.png b/tests/test_plot_3D_cells/true-1.png new file mode 100644 index 000000000..c0a8c7516 Binary files /dev/null and b/tests/test_plot_3D_cells/true-1.png differ diff --git a/tests/test_plot_3D_cells/true-2.png b/tests/test_plot_3D_cells/true-2.png new file mode 100644 index 000000000..fe73f15b8 Binary files /dev/null and b/tests/test_plot_3D_cells/true-2.png differ diff --git a/tests/test_plot_3D_cells/true-3.png b/tests/test_plot_3D_cells/true-3.png new file mode 100644 index 000000000..052a2144a Binary files /dev/null and b/tests/test_plot_3D_cells/true-3.png differ diff --git a/tests/test_plot_3D_cells/true-4.png b/tests/test_plot_3D_cells/true-4.png new file mode 100644 index 000000000..fa767d244 Binary files /dev/null and b/tests/test_plot_3D_cells/true-4.png differ diff --git a/tests/test_plot_3D_cells/true-5.png b/tests/test_plot_3D_cells/true-5.png new file mode 100644 index 000000000..a78eedc32 Binary files /dev/null and b/tests/test_plot_3D_cells/true-5.png differ diff --git a/tests/test_plot_3D_cmfd_cells/test_plot_3D_cmfd_cells.py b/tests/test_plot_3D_cmfd_cells/test_plot_3D_cmfd_cells.py new file mode 100644 index 000000000..9271b42c5 --- /dev/null +++ b/tests/test_plot_3D_cmfd_cells/test_plot_3D_cmfd_cells.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +import openmoc +from openmoc.plotter import plot_cmfd_cells + + +class PlotCmfdCellsTestHarness(PlottingTestHarness): + """Test CMFD cells plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotCmfdCellsTestHarness, self).__init__() + self.cmfd = None + self.input_set = NonUniformLatticeInput() + self.num_polar = 4 + self.azim_spacing = 0.5 + self.z_spacing = 2.0 + self.max_iters = 1 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotCmfdCellsTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + # and for OTF ray tracing + self.solver.setNumThreads(1) + + def _create_geometry(self): + """Initialize CMFD and add it to the Geometry.""" + + super(PlotCmfdCellsTestHarness, self)._create_geometry() + + # Initialize CMFD + self.cmfd = openmoc.Cmfd() + self.cmfd.setSORRelaxationFactor(1.5) + self.cmfd.setLatticeStructure(4,4,3) + self.cmfd.setGroupStructure([[1,2,3], [4,5,6,7]]) + self.cmfd.setKNearest(3) + + # Add CMFD to the Geometry + self.input_set.geometry.setCmfd(self.cmfd) + + def _run_openmoc(self): + """Plot the flat source regions in the geometry.""" + + # Run an eigenvalue calculation to setup CMFD cells + super(PlotCmfdCellsTestHarness, self)._run_openmoc() + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.append( + plot_cmfd_cells(self.input_set.geometry, self.cmfd, offset=0.1, + plane='xy', gridsize=100, get_figure=True)) + self.figures.append( + plot_cmfd_cells(self.input_set.geometry, self.cmfd, gridsize=100, + offset=0.1, plane='yz', get_figure=True, + ylim=(0., 2.), zlim=(0., 2.))) + self.figures.append( + plot_cmfd_cells(self.input_set.geometry, self.cmfd, gridsize=100, + offset=0.1, plane='yz', get_figure=True, + library='pil')) + self.figures.append( + plot_cmfd_cells(self.input_set.geometry, self.cmfd, gridsize=100, + offset=0.1, plane='yz', get_figure=True)) + self.figures.append( + plot_cmfd_cells(self.input_set.geometry, self.cmfd, gridsize=100, + offset=0.1, plane='xz', get_figure=True)) + + +if __name__ == '__main__': + harness = PlotCmfdCellsTestHarness() + harness.main() diff --git a/tests/test_plot_3D_cmfd_cells/true-0.png b/tests/test_plot_3D_cmfd_cells/true-0.png new file mode 100644 index 000000000..fb7760974 Binary files /dev/null and b/tests/test_plot_3D_cmfd_cells/true-0.png differ diff --git a/tests/test_plot_3D_cmfd_cells/true-1.png b/tests/test_plot_3D_cmfd_cells/true-1.png new file mode 100644 index 000000000..44728cb8d Binary files /dev/null and b/tests/test_plot_3D_cmfd_cells/true-1.png differ diff --git a/tests/test_plot_3D_cmfd_cells/true-2.png b/tests/test_plot_3D_cmfd_cells/true-2.png new file mode 100644 index 000000000..42e8ad3f0 Binary files /dev/null and b/tests/test_plot_3D_cmfd_cells/true-2.png differ diff --git a/tests/test_plot_3D_cmfd_cells/true-3.png b/tests/test_plot_3D_cmfd_cells/true-3.png new file mode 100644 index 000000000..6d6963f11 Binary files /dev/null and b/tests/test_plot_3D_cmfd_cells/true-3.png differ diff --git a/tests/test_plot_3D_cmfd_cells/true-4.png b/tests/test_plot_3D_cmfd_cells/true-4.png new file mode 100644 index 000000000..5fdbce778 Binary files /dev/null and b/tests/test_plot_3D_cmfd_cells/true-4.png differ diff --git a/tests/test_plot_3D_fission_rates/test_plot_3D_fission_rates.py b/tests/test_plot_3D_fission_rates/test_plot_3D_fission_rates.py new file mode 100644 index 000000000..fc05af79d --- /dev/null +++ b/tests/test_plot_3D_fission_rates/test_plot_3D_fission_rates.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +from openmoc.plotter import plot_fission_rates +import openmoc + + +class PlotFissionRatesTestHarness(PlottingTestHarness): + """Test fission rate plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotFissionRatesTestHarness, self).__init__() + self.input_set = NonUniformLatticeInput() + self.num_polar = 4 + self.azim_spacing = 0.5 + self.z_spacing = 2.0 + self.max_iters = 10 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotFissionRatesTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + self.solver.setNumThreads(1) + + def _run_openmoc(self): + """Run OpenMOC and plot the fission rates in the geometry.""" + + # Run an eigenvalue calculation + super(PlotFissionRatesTestHarness, self)._run_openmoc() + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.append( + plot_fission_rates(self.solver, gridsize=100, offset=0.1, plane='xy', + get_figure=True)) + self.figures.append( + plot_fission_rates(self.solver, gridsize=100, get_figure=True, + offset=0.6, plane='yz', ylim=(0., 2.), zlim=(0., 2.))) + self.figures.append( + plot_fission_rates(self.solver, gridsize=100, get_figure=True, + offset=0.6, plane='xz', norm=False, transparent_zeros=False)) + self.figures.append( + plot_fission_rates(self.solver, gridsize=100, get_figure=True, + offset=1.2, plane='xz')) + + +if __name__ == '__main__': + harness = PlotFissionRatesTestHarness() + harness.main() diff --git a/tests/test_plot_3D_fission_rates/true-0.png b/tests/test_plot_3D_fission_rates/true-0.png new file mode 100644 index 000000000..83903ad52 Binary files /dev/null and b/tests/test_plot_3D_fission_rates/true-0.png differ diff --git a/tests/test_plot_3D_fission_rates/true-1.png b/tests/test_plot_3D_fission_rates/true-1.png new file mode 100644 index 000000000..c85c7e057 Binary files /dev/null and b/tests/test_plot_3D_fission_rates/true-1.png differ diff --git a/tests/test_plot_3D_fission_rates/true-2.png b/tests/test_plot_3D_fission_rates/true-2.png new file mode 100644 index 000000000..e6a321a11 Binary files /dev/null and b/tests/test_plot_3D_fission_rates/true-2.png differ diff --git a/tests/test_plot_3D_fission_rates/true-3.png b/tests/test_plot_3D_fission_rates/true-3.png new file mode 100644 index 000000000..d7b18d752 Binary files /dev/null and b/tests/test_plot_3D_fission_rates/true-3.png differ diff --git a/tests/test_plot_3D_fsrs/test_plot_3D_fsrs.py b/tests/test_plot_3D_fsrs/test_plot_3D_fsrs.py new file mode 100644 index 000000000..bc1826868 --- /dev/null +++ b/tests/test_plot_3D_fsrs/test_plot_3D_fsrs.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +from openmoc.plotter import plot_flat_source_regions +import openmoc + +class PlotFSRsTestHarness(PlottingTestHarness): + """Test flat source region plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotFSRsTestHarness, self).__init__() + self.input_set = NonUniformLatticeInput() + self.num_polar = 4 + self.azim_spacing = 0.5 + self.z_spacing = 2.0 + self.max_iters = 1 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotFSRsTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + self.solver.setNumThreads(1) + + def _run_openmoc(self): + """Plot the flat source regions in the geometry.""" + + # Run an eigenvalue calculation to setup FSR centroids + super(PlotFSRsTestHarness, self)._run_openmoc() + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.append( + plot_flat_source_regions(self.input_set.geometry, gridsize=100, + offset=0.1, get_figure=True)) + self.figures.append( + plot_flat_source_regions(self.input_set.geometry, gridsize=100, + offset=0.1, plane='yz', get_figure=True, ylim=(0., 2.), + zlim=(0., 2.))) + self.figures.append( + plot_flat_source_regions(self.input_set.geometry, gridsize=100, + offset=0.1, plane='yz', get_figure=True, centroids=True, + marker_size=3)) + self.figures.append( + plot_flat_source_regions(self.input_set.geometry, gridsize=100, + offset=0.1, plane='xz', get_figure=True, centroids=True, + library='pil')) + + +if __name__ == '__main__': + harness = PlotFSRsTestHarness() + harness.main() diff --git a/tests/test_plot_3D_fsrs/true-0.png b/tests/test_plot_3D_fsrs/true-0.png new file mode 100644 index 000000000..52f113230 Binary files /dev/null and b/tests/test_plot_3D_fsrs/true-0.png differ diff --git a/tests/test_plot_3D_fsrs/true-1.png b/tests/test_plot_3D_fsrs/true-1.png new file mode 100644 index 000000000..9fdd3b0e6 Binary files /dev/null and b/tests/test_plot_3D_fsrs/true-1.png differ diff --git a/tests/test_plot_3D_fsrs/true-2.png b/tests/test_plot_3D_fsrs/true-2.png new file mode 100644 index 000000000..da86e860a Binary files /dev/null and b/tests/test_plot_3D_fsrs/true-2.png differ diff --git a/tests/test_plot_3D_fsrs/true-3.png b/tests/test_plot_3D_fsrs/true-3.png new file mode 100644 index 000000000..d4f8f6868 Binary files /dev/null and b/tests/test_plot_3D_fsrs/true-3.png differ diff --git a/tests/test_plot_3D_materials/test_plot_3D_materials.py b/tests/test_plot_3D_materials/test_plot_3D_materials.py new file mode 100644 index 000000000..5d2ac6d4b --- /dev/null +++ b/tests/test_plot_3D_materials/test_plot_3D_materials.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +from openmoc.plotter import plot_materials +import openmoc + + +class PlotMaterialsTestHarness(PlottingTestHarness): + """Test material plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotMaterialsTestHarness, self).__init__() + self.input_set = NonUniformLatticeInput() + + def _run_openmoc(self): + """Plot the materials in the geometry.""" + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True)) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True)) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, offset=0.1, + get_figure=True, xlim=(0., 2.), ylim=(0., 2.))) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, + offset=0.1, get_figure=True, library='pil')) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, plane="yz", + offset=0.6, get_figure=True)) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, plane="xz", + offset=0.6, get_figure=True)) + + +if __name__ == '__main__': + harness = PlotMaterialsTestHarness() + harness.main() diff --git a/tests/test_plot_3D_materials/true-0.png b/tests/test_plot_3D_materials/true-0.png new file mode 100644 index 000000000..a5e2c0443 Binary files /dev/null and b/tests/test_plot_3D_materials/true-0.png differ diff --git a/tests/test_plot_3D_materials/true-1.png b/tests/test_plot_3D_materials/true-1.png new file mode 100644 index 000000000..a5e2c0443 Binary files /dev/null and b/tests/test_plot_3D_materials/true-1.png differ diff --git a/tests/test_plot_3D_materials/true-2.png b/tests/test_plot_3D_materials/true-2.png new file mode 100644 index 000000000..4ee6979dc Binary files /dev/null and b/tests/test_plot_3D_materials/true-2.png differ diff --git a/tests/test_plot_3D_materials/true-3.png b/tests/test_plot_3D_materials/true-3.png new file mode 100644 index 000000000..b07df3b8a Binary files /dev/null and b/tests/test_plot_3D_materials/true-3.png differ diff --git a/tests/test_plot_3D_materials/true-4.png b/tests/test_plot_3D_materials/true-4.png new file mode 100644 index 000000000..723e4f144 Binary files /dev/null and b/tests/test_plot_3D_materials/true-4.png differ diff --git a/tests/test_plot_3D_materials/true-5.png b/tests/test_plot_3D_materials/true-5.png new file mode 100644 index 000000000..4cf71ac29 Binary files /dev/null and b/tests/test_plot_3D_materials/true-5.png differ diff --git a/tests/test_plot_3D_segments/test_plot_3D_segments.py b/tests/test_plot_3D_segments/test_plot_3D_segments.py new file mode 100644 index 000000000..42dcfa7af --- /dev/null +++ b/tests/test_plot_3D_segments/test_plot_3D_segments.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import AxialExtendedInput +from openmoc.plotter import plot_segments +import openmoc + + +class PlotSegmentsTestHarness(PlottingTestHarness): + """Test segment plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotSegmentsTestHarness, self).__init__() + self.input_set = AxialExtendedInput(small=True) + self.num_polar = 2 + self.azim_spacing = 1.35 + self.z_spacing = 10.0 + self.max_iters = 1 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotSegmentsTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + # and for OTF ray tracing + self.solver.setNumThreads(1) + + def _run_openmoc(self): + """Plot the tracks.""" + + # Run an eigenvalue calculation to setup track generator + super(PlotSegmentsTestHarness, self)._run_openmoc() + + # Create Matplotlib Figures for the tracks + self.figures = \ + [plot_segments(self.track_generator, plot_3D=True, get_figure=True)] + + +if __name__ == '__main__': + harness = PlotSegmentsTestHarness() + harness.main() diff --git a/tests/test_plot_3D_segments/true-0.png b/tests/test_plot_3D_segments/true-0.png new file mode 100644 index 000000000..f428abcb5 Binary files /dev/null and b/tests/test_plot_3D_segments/true-0.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/test_plot_3D_spatial_fluxes.py b/tests/test_plot_3D_spatial_fluxes/test_plot_3D_spatial_fluxes.py new file mode 100644 index 000000000..08d7ddb30 --- /dev/null +++ b/tests/test_plot_3D_spatial_fluxes/test_plot_3D_spatial_fluxes.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import NonUniformLatticeInput +from openmoc.plotter import plot_spatial_fluxes +import openmoc + + +class PlotSpatialFluxesTestHarness(PlottingTestHarness): + """Test spatial flux plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotSpatialFluxesTestHarness, self).__init__() + self.input_set = NonUniformLatticeInput() + self.num_polar = 4 + self.azim_spacing = 0.5 + self.z_spacing = 2.0 + self.max_iters = 10 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotSpatialFluxesTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + self.solver.setNumThreads(1) + + def _run_openmoc(self): + """Run OpenMOC and plot the spatial fluxes in the geometry.""" + + # Run an eigenvalue calculation + super(PlotSpatialFluxesTestHarness, self)._run_openmoc() + + # Specify energy groups for which to plot the spatial flux + energy_groups = [1, 3, 5, 7] + + # Create a series of Matplotlib Figures / PIL Images for different + # plotting parameters and append to figures list + self.figures.extend( + plot_spatial_fluxes(self.solver, gridsize=100, offset=0.1, + get_figure=True, energy_groups=energy_groups)) + self.figures.extend( + plot_spatial_fluxes(self.solver, gridsize=100, get_figure=True, + xlim=(0., 2.), ylim=(0., 2.), offset=0.1, + energy_groups=energy_groups)) + self.figures.extend( + plot_spatial_fluxes(self.solver, gridsize=100, get_figure=True, + energy_groups=energy_groups, offset=0.1, + library='pil')) + self.figures.extend( + plot_spatial_fluxes(self.solver, gridsize=100, offset=0.1, + plane='yz', get_figure=True, energy_groups=energy_groups)) + self.figures.extend( + plot_spatial_fluxes(self.solver, gridsize=100, get_figure=True, + xlim=(0., 2.), ylim=(0., 2.), offset=0.1, plane='xz', + energy_groups=energy_groups)) + +if __name__ == '__main__': + harness = PlotSpatialFluxesTestHarness() + harness.main() diff --git a/tests/test_plot_3D_spatial_fluxes/true-0.png b/tests/test_plot_3D_spatial_fluxes/true-0.png new file mode 100644 index 000000000..d2e357709 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-0.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-1.png b/tests/test_plot_3D_spatial_fluxes/true-1.png new file mode 100644 index 000000000..47944b400 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-1.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-10.png b/tests/test_plot_3D_spatial_fluxes/true-10.png new file mode 100644 index 000000000..b0d6389c3 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-10.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-11.png b/tests/test_plot_3D_spatial_fluxes/true-11.png new file mode 100644 index 000000000..fe455a770 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-11.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-12.png b/tests/test_plot_3D_spatial_fluxes/true-12.png new file mode 100644 index 000000000..123b23746 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-12.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-13.png b/tests/test_plot_3D_spatial_fluxes/true-13.png new file mode 100644 index 000000000..80cf47ed3 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-13.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-14.png b/tests/test_plot_3D_spatial_fluxes/true-14.png new file mode 100644 index 000000000..3dc9032f8 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-14.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-15.png b/tests/test_plot_3D_spatial_fluxes/true-15.png new file mode 100644 index 000000000..b5cb280cc Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-15.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-16.png b/tests/test_plot_3D_spatial_fluxes/true-16.png new file mode 100644 index 000000000..8edd81e49 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-16.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-17.png b/tests/test_plot_3D_spatial_fluxes/true-17.png new file mode 100644 index 000000000..21e5831b6 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-17.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-18.png b/tests/test_plot_3D_spatial_fluxes/true-18.png new file mode 100644 index 000000000..33fd210aa Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-18.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-19.png b/tests/test_plot_3D_spatial_fluxes/true-19.png new file mode 100644 index 000000000..3e14ecc23 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-19.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-2.png b/tests/test_plot_3D_spatial_fluxes/true-2.png new file mode 100644 index 000000000..5157878a5 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-2.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-3.png b/tests/test_plot_3D_spatial_fluxes/true-3.png new file mode 100644 index 000000000..7ba1d5f27 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-3.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-4.png b/tests/test_plot_3D_spatial_fluxes/true-4.png new file mode 100644 index 000000000..3ff1284bb Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-4.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-5.png b/tests/test_plot_3D_spatial_fluxes/true-5.png new file mode 100644 index 000000000..465674bc7 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-5.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-6.png b/tests/test_plot_3D_spatial_fluxes/true-6.png new file mode 100644 index 000000000..7cf95b4f6 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-6.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-7.png b/tests/test_plot_3D_spatial_fluxes/true-7.png new file mode 100644 index 000000000..7671dacbb Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-7.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-8.png b/tests/test_plot_3D_spatial_fluxes/true-8.png new file mode 100644 index 000000000..d6a8e943b Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-8.png differ diff --git a/tests/test_plot_3D_spatial_fluxes/true-9.png b/tests/test_plot_3D_spatial_fluxes/true-9.png new file mode 100644 index 000000000..02d57aa60 Binary files /dev/null and b/tests/test_plot_3D_spatial_fluxes/true-9.png differ diff --git a/tests/test_plot_3D_tracks/test_plot_3D_tracks.py b/tests/test_plot_3D_tracks/test_plot_3D_tracks.py new file mode 100644 index 000000000..14f93a87b --- /dev/null +++ b/tests/test_plot_3D_tracks/test_plot_3D_tracks.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +sys.path.insert(0, os.path.join(os.pardir, 'openmoc')) +from testing_harness import PlottingTestHarness +from input_set import AxialExtendedInput +from openmoc.plotter import plot_tracks +import openmoc + +class PlotTracksTestHarness(PlottingTestHarness): + """Test track plotting with a 4x4 lattice.""" + + def __init__(self): + super(PlotTracksTestHarness, self).__init__() + self.input_set = AxialExtendedInput() + self.num_polar = 4 + self.azim_spacing = 0.5 + self.z_spacing = 2.0 + self.max_iters = 1 + + def _create_trackgenerator(self): + """Instantiate a TrackGenerator.""" + geometry = self.input_set.geometry + geometry.initializeFlatSourceRegions() + self.track_generator = \ + openmoc.TrackGenerator3D(geometry, self.num_azim, self.num_polar, + self.azim_spacing, self.z_spacing) + self.track_generator.setSegmentFormation(openmoc.OTF_STACKS) + + def _create_solver(self): + super(PlotTracksTestHarness, self)._create_solver() + # Use only 1 thread for FSR numbering reproducibility + # and for OTF ray tracing + self.solver.setNumThreads(1) + + def _run_openmoc(self): + """Plot the tracks.""" + + # Run an eigenvalue calculation to setup track generator + super(PlotTracksTestHarness, self)._run_openmoc() + + # Create Matplotlib Figures for the tracks + self.figures = \ + [plot_tracks(self.track_generator, get_figure=True, plot_3D=True)] + + +if __name__ == '__main__': + harness = PlotTracksTestHarness() + harness.main() diff --git a/tests/test_plot_3D_tracks/true-0.png b/tests/test_plot_3D_tracks/true-0.png new file mode 100644 index 000000000..ccab021e5 Binary files /dev/null and b/tests/test_plot_3D_tracks/true-0.png differ diff --git a/tests/test_plot_cells/test_plot_cells.py b/tests/test_plot_cells/test_plot_cells.py index 65e430c77..2253c8efa 100644 --- a/tests/test_plot_cells/test_plot_cells.py +++ b/tests/test_plot_cells/test_plot_cells.py @@ -14,7 +14,7 @@ class PlotCellsTestHarness(PlottingTestHarness): def __init__(self): super(PlotCellsTestHarness, self).__init__() - self.input_set = SimpleLatticeInput() + self.input_set = SimpleLatticeInput(num_dimensions=3) def _run_openmoc(self): """Plot the cells in the geometry.""" @@ -26,13 +26,19 @@ def _run_openmoc(self): get_figure=True)) self.figures.append( plot_cells(self.input_set.geometry, gridsize=100, - offset=10., get_figure=True)) + offset=2.5, get_figure=True)) self.figures.append( plot_cells(self.input_set.geometry, gridsize=100, get_figure=True, xlim=(0., 2.), ylim=(0., 2.))) self.figures.append( plot_cells(self.input_set.geometry, gridsize=100, get_figure=True, library='pil')) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, plane="yz", + get_figure=True)) + self.figures.append( + plot_cells(self.input_set.geometry, gridsize=100, plane="xz", + get_figure=True)) if __name__ == '__main__': diff --git a/tests/test_plot_cells/true-0.png b/tests/test_plot_cells/true-0.png index 1b0ab01d3..61c065aa5 100644 Binary files a/tests/test_plot_cells/true-0.png and b/tests/test_plot_cells/true-0.png differ diff --git a/tests/test_plot_cells/true-1.png b/tests/test_plot_cells/true-1.png index b08966f09..9b1183a8e 100644 Binary files a/tests/test_plot_cells/true-1.png and b/tests/test_plot_cells/true-1.png differ diff --git a/tests/test_plot_cells/true-2.png b/tests/test_plot_cells/true-2.png index 656726d87..1cf75802f 100644 Binary files a/tests/test_plot_cells/true-2.png and b/tests/test_plot_cells/true-2.png differ diff --git a/tests/test_plot_cells/true-3.png b/tests/test_plot_cells/true-3.png index 6f603206d..20df1a26c 100644 Binary files a/tests/test_plot_cells/true-3.png and b/tests/test_plot_cells/true-3.png differ diff --git a/tests/test_plot_cells/true-4.png b/tests/test_plot_cells/true-4.png new file mode 100644 index 000000000..38710ec55 Binary files /dev/null and b/tests/test_plot_cells/true-4.png differ diff --git a/tests/test_plot_cells/true-5.png b/tests/test_plot_cells/true-5.png new file mode 100644 index 000000000..9dddfa460 Binary files /dev/null and b/tests/test_plot_cells/true-5.png differ diff --git a/tests/test_plot_cmfd_cells/true-0.png b/tests/test_plot_cmfd_cells/true-0.png index edd71c4c1..8626ef8e4 100644 Binary files a/tests/test_plot_cmfd_cells/true-0.png and b/tests/test_plot_cmfd_cells/true-0.png differ diff --git a/tests/test_plot_cmfd_cells/true-1.png b/tests/test_plot_cmfd_cells/true-1.png index aa7e986f5..f991b94d2 100644 Binary files a/tests/test_plot_cmfd_cells/true-1.png and b/tests/test_plot_cmfd_cells/true-1.png differ diff --git a/tests/test_plot_energy_fluxes/true-0.png b/tests/test_plot_energy_fluxes/true-0.png index 4431180a5..51588dc3f 100644 Binary files a/tests/test_plot_energy_fluxes/true-0.png and b/tests/test_plot_energy_fluxes/true-0.png differ diff --git a/tests/test_plot_energy_fluxes/true-1.png b/tests/test_plot_energy_fluxes/true-1.png index 93d62904e..d8e5faa59 100644 Binary files a/tests/test_plot_energy_fluxes/true-1.png and b/tests/test_plot_energy_fluxes/true-1.png differ diff --git a/tests/test_plot_energy_fluxes/true-2.png b/tests/test_plot_energy_fluxes/true-2.png index 4431180a5..51588dc3f 100644 Binary files a/tests/test_plot_energy_fluxes/true-2.png and b/tests/test_plot_energy_fluxes/true-2.png differ diff --git a/tests/test_plot_energy_fluxes/true-3.png b/tests/test_plot_energy_fluxes/true-3.png index 93d62904e..d8e5faa59 100644 Binary files a/tests/test_plot_energy_fluxes/true-3.png and b/tests/test_plot_energy_fluxes/true-3.png differ diff --git a/tests/test_plot_fission_rates/true-0.png b/tests/test_plot_fission_rates/true-0.png index c486bc872..fc8227f52 100644 Binary files a/tests/test_plot_fission_rates/true-0.png and b/tests/test_plot_fission_rates/true-0.png differ diff --git a/tests/test_plot_fission_rates/true-1.png b/tests/test_plot_fission_rates/true-1.png index dd4967b71..4d81481db 100644 Binary files a/tests/test_plot_fission_rates/true-1.png and b/tests/test_plot_fission_rates/true-1.png differ diff --git a/tests/test_plot_fission_rates/true-2.png b/tests/test_plot_fission_rates/true-2.png index c486bc872..fc8227f52 100644 Binary files a/tests/test_plot_fission_rates/true-2.png and b/tests/test_plot_fission_rates/true-2.png differ diff --git a/tests/test_plot_fission_rates/true-3.png b/tests/test_plot_fission_rates/true-3.png index 978ba8c26..1cf45d868 100644 Binary files a/tests/test_plot_fission_rates/true-3.png and b/tests/test_plot_fission_rates/true-3.png differ diff --git a/tests/test_plot_fsrs/true-0.png b/tests/test_plot_fsrs/true-0.png index 68c8707b4..adadfa9fd 100644 Binary files a/tests/test_plot_fsrs/true-0.png and b/tests/test_plot_fsrs/true-0.png differ diff --git a/tests/test_plot_fsrs/true-1.png b/tests/test_plot_fsrs/true-1.png index 7847f45b3..790a825bd 100644 Binary files a/tests/test_plot_fsrs/true-1.png and b/tests/test_plot_fsrs/true-1.png differ diff --git a/tests/test_plot_fsrs/true-2.png b/tests/test_plot_fsrs/true-2.png index f6e191d85..9b2b0be79 100644 Binary files a/tests/test_plot_fsrs/true-2.png and b/tests/test_plot_fsrs/true-2.png differ diff --git a/tests/test_plot_fsrs/true-3.png b/tests/test_plot_fsrs/true-3.png index 9aa0b0849..8fc21e979 100644 Binary files a/tests/test_plot_fsrs/true-3.png and b/tests/test_plot_fsrs/true-3.png differ diff --git a/tests/test_plot_materials/test_plot_materials.py b/tests/test_plot_materials/test_plot_materials.py index 9be966078..b7e546142 100644 --- a/tests/test_plot_materials/test_plot_materials.py +++ b/tests/test_plot_materials/test_plot_materials.py @@ -15,6 +15,7 @@ class PlotMaterialsTestHarness(PlottingTestHarness): def __init__(self): super(PlotMaterialsTestHarness, self).__init__() self.input_set = SimpleLatticeInput() + self.input_set.dimensions = 3 def _run_openmoc(self): """Plot the materials in the geometry.""" @@ -26,13 +27,19 @@ def _run_openmoc(self): get_figure=True)) self.figures.append( plot_materials(self.input_set.geometry, gridsize=100, - offset=10., get_figure=True)) + offset=2.5, get_figure=True)) self.figures.append( plot_materials(self.input_set.geometry, gridsize=100, get_figure=True, xlim=(0., 2.), ylim=(0., 2.))) self.figures.append( plot_materials(self.input_set.geometry, gridsize=100, get_figure=True, library='pil')) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, plane="yz", + get_figure=True)) + self.figures.append( + plot_materials(self.input_set.geometry, gridsize=100, plane="xz", + get_figure=True)) if __name__ == '__main__': diff --git a/tests/test_plot_materials/true-0.png b/tests/test_plot_materials/true-0.png index 4763354da..97ef2e432 100644 Binary files a/tests/test_plot_materials/true-0.png and b/tests/test_plot_materials/true-0.png differ diff --git a/tests/test_plot_materials/true-1.png b/tests/test_plot_materials/true-1.png index a8a289c78..68820caf1 100644 Binary files a/tests/test_plot_materials/true-1.png and b/tests/test_plot_materials/true-1.png differ diff --git a/tests/test_plot_materials/true-2.png b/tests/test_plot_materials/true-2.png index 507c40f9b..35372f877 100644 Binary files a/tests/test_plot_materials/true-2.png and b/tests/test_plot_materials/true-2.png differ diff --git a/tests/test_plot_materials/true-4.png b/tests/test_plot_materials/true-4.png new file mode 100644 index 000000000..82215a8fd Binary files /dev/null and b/tests/test_plot_materials/true-4.png differ diff --git a/tests/test_plot_materials/true-5.png b/tests/test_plot_materials/true-5.png new file mode 100644 index 000000000..5057e15dd Binary files /dev/null and b/tests/test_plot_materials/true-5.png differ diff --git a/tests/test_plot_quadrature/true-0.png b/tests/test_plot_quadrature/true-0.png index 51322d385..2656933fd 100644 Binary files a/tests/test_plot_quadrature/true-0.png and b/tests/test_plot_quadrature/true-0.png differ diff --git a/tests/test_plot_segments/test_plot_segments.py b/tests/test_plot_segments/test_plot_segments.py index edd989369..d72c72749 100644 --- a/tests/test_plot_segments/test_plot_segments.py +++ b/tests/test_plot_segments/test_plot_segments.py @@ -23,7 +23,8 @@ def _run_openmoc(self): super(PlotSegmentsTestHarness, self)._run_openmoc() # Create Matplotlib Figures for the tracks - self.figures = [plot_segments(self.track_generator, get_figure=True)] + self.figures = [plot_segments(self.track_generator, get_figure=True), + plot_segments(self.track_generator, plot_3D=True, get_figure=True)] if __name__ == '__main__': diff --git a/tests/test_plot_segments/true-0.png b/tests/test_plot_segments/true-0.png index 28b6d461f..9ed32cd55 100644 Binary files a/tests/test_plot_segments/true-0.png and b/tests/test_plot_segments/true-0.png differ diff --git a/tests/test_plot_segments/true-1.png b/tests/test_plot_segments/true-1.png new file mode 100644 index 000000000..6934d2405 Binary files /dev/null and b/tests/test_plot_segments/true-1.png differ diff --git a/tests/test_plot_spatial_data/true-0.png b/tests/test_plot_spatial_data/true-0.png index bd585d56e..dc9a98920 100644 Binary files a/tests/test_plot_spatial_data/true-0.png and b/tests/test_plot_spatial_data/true-0.png differ diff --git a/tests/test_plot_spatial_data/true-1.png b/tests/test_plot_spatial_data/true-1.png index 64816a6b5..996811e24 100644 Binary files a/tests/test_plot_spatial_data/true-1.png and b/tests/test_plot_spatial_data/true-1.png differ diff --git a/tests/test_plot_spatial_data/true-2.png b/tests/test_plot_spatial_data/true-2.png index 010aa9dce..ded80a3a8 100644 Binary files a/tests/test_plot_spatial_data/true-2.png and b/tests/test_plot_spatial_data/true-2.png differ diff --git a/tests/test_plot_spatial_data/true-3.png b/tests/test_plot_spatial_data/true-3.png index 67ab87dd2..707bf071e 100644 Binary files a/tests/test_plot_spatial_data/true-3.png and b/tests/test_plot_spatial_data/true-3.png differ diff --git a/tests/test_plot_spatial_data/true-4.png b/tests/test_plot_spatial_data/true-4.png index 17cfe3068..fc059afae 100644 Binary files a/tests/test_plot_spatial_data/true-4.png and b/tests/test_plot_spatial_data/true-4.png differ diff --git a/tests/test_plot_spatial_data/true-5.png b/tests/test_plot_spatial_data/true-5.png index dd334070c..fcbe1690b 100644 Binary files a/tests/test_plot_spatial_data/true-5.png and b/tests/test_plot_spatial_data/true-5.png differ diff --git a/tests/test_plot_spatial_fluxes/true-0.png b/tests/test_plot_spatial_fluxes/true-0.png index 4ddc0702e..a8924c13a 100644 Binary files a/tests/test_plot_spatial_fluxes/true-0.png and b/tests/test_plot_spatial_fluxes/true-0.png differ diff --git a/tests/test_plot_spatial_fluxes/true-1.png b/tests/test_plot_spatial_fluxes/true-1.png index c5dbe36a4..3f13cff73 100644 Binary files a/tests/test_plot_spatial_fluxes/true-1.png and b/tests/test_plot_spatial_fluxes/true-1.png differ diff --git a/tests/test_plot_spatial_fluxes/true-10.png b/tests/test_plot_spatial_fluxes/true-10.png index 0c9d7352a..ca3babb27 100644 Binary files a/tests/test_plot_spatial_fluxes/true-10.png and b/tests/test_plot_spatial_fluxes/true-10.png differ diff --git a/tests/test_plot_spatial_fluxes/true-11.png b/tests/test_plot_spatial_fluxes/true-11.png index 1b5420eb0..7a89fb5b5 100644 Binary files a/tests/test_plot_spatial_fluxes/true-11.png and b/tests/test_plot_spatial_fluxes/true-11.png differ diff --git a/tests/test_plot_spatial_fluxes/true-2.png b/tests/test_plot_spatial_fluxes/true-2.png index 20970497b..aeda7e6ae 100644 Binary files a/tests/test_plot_spatial_fluxes/true-2.png and b/tests/test_plot_spatial_fluxes/true-2.png differ diff --git a/tests/test_plot_spatial_fluxes/true-3.png b/tests/test_plot_spatial_fluxes/true-3.png index 241587bc8..1993be8da 100644 Binary files a/tests/test_plot_spatial_fluxes/true-3.png and b/tests/test_plot_spatial_fluxes/true-3.png differ diff --git a/tests/test_plot_spatial_fluxes/true-4.png b/tests/test_plot_spatial_fluxes/true-4.png index 1e45ee13d..b2a95ba7e 100644 Binary files a/tests/test_plot_spatial_fluxes/true-4.png and b/tests/test_plot_spatial_fluxes/true-4.png differ diff --git a/tests/test_plot_spatial_fluxes/true-5.png b/tests/test_plot_spatial_fluxes/true-5.png index 39725f44a..35eab2de1 100644 Binary files a/tests/test_plot_spatial_fluxes/true-5.png and b/tests/test_plot_spatial_fluxes/true-5.png differ diff --git a/tests/test_plot_spatial_fluxes/true-6.png b/tests/test_plot_spatial_fluxes/true-6.png index 4b93023c2..ab197f003 100644 Binary files a/tests/test_plot_spatial_fluxes/true-6.png and b/tests/test_plot_spatial_fluxes/true-6.png differ diff --git a/tests/test_plot_spatial_fluxes/true-7.png b/tests/test_plot_spatial_fluxes/true-7.png index 17d08ad71..931f3b9b1 100644 Binary files a/tests/test_plot_spatial_fluxes/true-7.png and b/tests/test_plot_spatial_fluxes/true-7.png differ diff --git a/tests/test_plot_spatial_fluxes/true-8.png b/tests/test_plot_spatial_fluxes/true-8.png index 7ff93bab7..1b6e6bfa6 100644 Binary files a/tests/test_plot_spatial_fluxes/true-8.png and b/tests/test_plot_spatial_fluxes/true-8.png differ diff --git a/tests/test_plot_spatial_fluxes/true-9.png b/tests/test_plot_spatial_fluxes/true-9.png index 60e26353d..b4574926c 100644 Binary files a/tests/test_plot_spatial_fluxes/true-9.png and b/tests/test_plot_spatial_fluxes/true-9.png differ diff --git a/tests/test_plot_tracks/test_plot_tracks.py b/tests/test_plot_tracks/test_plot_tracks.py index 841c8583c..64c95d885 100644 --- a/tests/test_plot_tracks/test_plot_tracks.py +++ b/tests/test_plot_tracks/test_plot_tracks.py @@ -23,7 +23,8 @@ def _run_openmoc(self): super(PlotTracksTestHarness, self)._run_openmoc() # Create Matplotlib Figures for the tracks - self.figures = [plot_tracks(self.track_generator, get_figure=True)] + self.figures = [plot_tracks(self.track_generator, get_figure=True), + plot_tracks(self.track_generator, get_figure=True, plot_3D=True)] if __name__ == '__main__': diff --git a/tests/test_plot_tracks/true-0.png b/tests/test_plot_tracks/true-0.png index e622a5102..88f599d70 100644 Binary files a/tests/test_plot_tracks/true-0.png and b/tests/test_plot_tracks/true-0.png differ diff --git a/tests/test_plot_tracks/true-1.png b/tests/test_plot_tracks/true-1.png new file mode 100644 index 000000000..90ac58f20 Binary files /dev/null and b/tests/test_plot_tracks/true-1.png differ diff --git a/tests/test_superhomogeneization_cell/generate_library.py b/tests/test_superhomogenization_cell/generate_library.py similarity index 100% rename from tests/test_superhomogeneization_cell/generate_library.py rename to tests/test_superhomogenization_cell/generate_library.py diff --git a/tests/test_superhomogeneization_cell/mgxs.pkl b/tests/test_superhomogenization_cell/mgxs.pkl similarity index 100% rename from tests/test_superhomogeneization_cell/mgxs.pkl rename to tests/test_superhomogenization_cell/mgxs.pkl diff --git a/tests/test_superhomogeneization_cell/results_true.dat b/tests/test_superhomogenization_cell/results_true.dat similarity index 100% rename from tests/test_superhomogeneization_cell/results_true.dat rename to tests/test_superhomogenization_cell/results_true.dat diff --git a/tests/test_superhomogeneization_cell/test_superhomogeneization.py b/tests/test_superhomogenization_cell/test_superhomogenization_cell.py similarity index 97% rename from tests/test_superhomogeneization_cell/test_superhomogeneization.py rename to tests/test_superhomogenization_cell/test_superhomogenization_cell.py index d7a328365..4977fc36a 100644 --- a/tests/test_superhomogeneization_cell/test_superhomogeneization.py +++ b/tests/test_superhomogenization_cell/test_superhomogenization_cell.py @@ -69,12 +69,13 @@ def _run_openmoc(self): self.solver.setNumThreads(self.num_threads) # Compute SPH factors - sph, sph_mgxs_lib, sph_indices = \ + sph, sph_indices = \ openmoc.materialize.compute_sph_factors( mgxs_lib, azim_spacing=self.azim_spacing, num_azim=self.num_azim, num_threads=self.num_threads, solver=self.solver, track_generator=track_generator, - geometry=openmoc_geometry, sph_domains=sph_domains) + geometry=openmoc_geometry, sph_domains=sph_domains, + return_library=False) def _get_results(self, num_iters=True, keff=True, fluxes=True, num_fsrs=False, num_tracks=False, num_segments=False, diff --git a/tests/test_superhomogeneization_eigenvalue/results_true.dat b/tests/test_superhomogenization_eigenvalue/results_true.dat similarity index 100% rename from tests/test_superhomogeneization_eigenvalue/results_true.dat rename to tests/test_superhomogenization_eigenvalue/results_true.dat diff --git a/tests/test_superhomogeneization_eigenvalue/test_superhomogeneization_eigenvalue.py b/tests/test_superhomogenization_eigenvalue/test_superhomogeneization_eigenvalue.py similarity index 97% rename from tests/test_superhomogeneization_eigenvalue/test_superhomogeneization_eigenvalue.py rename to tests/test_superhomogenization_eigenvalue/test_superhomogeneization_eigenvalue.py index 43d9eabb5..f7b71199f 100644 --- a/tests/test_superhomogeneization_eigenvalue/test_superhomogeneization_eigenvalue.py +++ b/tests/test_superhomogenization_eigenvalue/test_superhomogeneization_eigenvalue.py @@ -40,7 +40,7 @@ def _run_openmoc(self): # Initialize 16-group OpenMC multi-group XS library for a pin cell mgxs_lib = openmc.mgxs.Library.load_from_file(filename='mgxs', - directory='../test_superhomogeneization_material') + directory='../test_superhomogenization_material') # Compute SPH factors sph, sph_mgxs_lib, sph_indices = \ diff --git a/tests/test_superhomogeneization_material/mgxs.pkl b/tests/test_superhomogenization_material/mgxs.pkl similarity index 100% rename from tests/test_superhomogeneization_material/mgxs.pkl rename to tests/test_superhomogenization_material/mgxs.pkl diff --git a/tests/test_superhomogeneization_material/results_true.dat b/tests/test_superhomogenization_material/results_true.dat similarity index 100% rename from tests/test_superhomogeneization_material/results_true.dat rename to tests/test_superhomogenization_material/results_true.dat diff --git a/tests/test_superhomogeneization_material/test_superhomogeneization_material.py b/tests/test_superhomogenization_material/test_superhomogenization_material.py similarity index 100% rename from tests/test_superhomogeneization_material/test_superhomogeneization_material.py rename to tests/test_superhomogenization_material/test_superhomogenization_material.py diff --git a/tests/testing_harness.py b/tests/testing_harness.py index c3f76b5a9..fbcc947c0 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -217,9 +217,9 @@ def _overwrite_results(self): def _compare_results(self): """Make sure the current results agree with the _true standard.""" - + # For comparison of files with different line endings - compare = (open('results_test.dat', 'r').read() == + compare = (open('results_test.dat', 'r').read() == open('results_true.dat', 'r').read()) if not compare: os.rename('results_test.dat', 'results_error.dat') @@ -340,7 +340,7 @@ def _overwrite_results(self): for i in range(len(outputs)): shutil.copyfile('test-{0}.png'.format(i), 'true-{0}.png'.format(i)) - def _compare_results(self, max_distance=1.): + def _compare_results(self, max_distance=0.1): """Make sure the current results agree with the true standard.""" # Loop over each Matplotlib figure / PIL Image and @@ -380,12 +380,12 @@ def _compare_images(self, img1, img2): rgba2 = np.array(img2) # Compute histograms of each images pixels - hr1, bins1 = np.histogram(rgba1[...,0], bins=256, normed=True) - hg1, bins1 = np.histogram(rgba1[...,1], bins=256, normed=True) - hb1, bins1 = np.histogram(rgba1[...,2], bins=256, normed=True) - hr2, bins2 = np.histogram(rgba2[...,0], bins=256, normed=True) - hg2, bins2 = np.histogram(rgba2[...,1], bins=256, normed=True) - hb2, bins2 = np.histogram(rgba2[...,2], bins=256, normed=True) + hr1, bins1 = np.histogram(rgba1[...,0], bins=256, density=True) + hg1, bins1 = np.histogram(rgba1[...,1], bins=256, density=True) + hb1, bins1 = np.histogram(rgba1[...,2], bins=256, density=True) + hr2, bins2 = np.histogram(rgba2[...,0], bins=256, density=True) + hg2, bins2 = np.histogram(rgba2[...,1], bins=256, density=True) + hb2, bins2 = np.histogram(rgba2[...,2], bins=256, density=True) hist1 = np.array([hr1, hg1, hb1]).ravel() hist2 = np.array([hr2, hg2, hb2]).ravel()