Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/pythonapi/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ Geometry Plotting
:nosignatures:
:template: myclass.rst

openmc.Plot
openmc.SlicePlot
openmc.VoxelPlot
openmc.WireframeRayTracePlot
openmc.SolidRayTracePlot
openmc.Plots
Expand Down
46 changes: 22 additions & 24 deletions docs/source/usersguide/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Geometry Visualization

.. currentmodule:: openmc

OpenMC is capable of producing two-dimensional slice plots of a geometry as well
as three-dimensional voxel plots using the geometry plotting :ref:`run mode
<usersguide_run_modes>`. The geometry plotting mode relies on the presence of a
:ref:`plots.xml <io_plots>` file that indicates what plots should be created. To
create this file, one needs to create one or more :class:`openmc.Plot`
instances, add them to a :class:`openmc.Plots` collection, and then use the
:class:`Plots.export_to_xml` method to write the ``plots.xml`` file.
OpenMC is capable of producing two-dimensional slice plots of a geometry,
three-dimensional voxel plots, and three-dimensional raytrace plots using the
geometry plotting :ref:`run mode <usersguide_run_modes>`. The geometry plotting
mode relies on the presence of a :ref:`plots.xml <io_plots>` file that indicates
what plots should be created. To create this file, one needs to create one or
more instances of the various plot classes described below, add them to a
:class:`openmc.Plots` collection, and then use the :class:`Plots.export_to_xml`
method to write the ``plots.xml`` file.

-----------
Slice Plots
Expand All @@ -21,15 +22,14 @@ Slice Plots
.. image:: ../_images/atr.png
:width: 300px

By default, when an instance of :class:`openmc.Plot` is created, it indicates
that a 2D slice plot should be made. You can specify the origin of the plot
(:attr:`Plot.origin`), the width of the plot in each direction
(:attr:`Plot.width`), the number of pixels to use in each direction
(:attr:`Plot.pixels`), and the basis directions for the plot. For example, to
create a :math:`x` - :math:`z` plot centered at (5.0, 2.0, 3.0) with a width of
(50., 50.) and 400x400 pixels::
The :class:`openmc.SlicePlot` class indicates that a 2D slice plot should be
made. You can specify the origin of the plot (:attr:`SlicePlot.origin`), the
width of the plot in each direction (:attr:`SlicePlot.width`), the number of
pixels to use in each direction (:attr:`SlicePlot.pixels`), and the basis
directions for the plot. For example, to create a :math:`x` - :math:`z` plot
centered at (5.0, 2.0, 3.0) with a width of (50., 50.) and 400x400 pixels::

plot = openmc.Plot()
plot = openmc.SlicePlot()
plot.basis = 'xz'
plot.origin = (5.0, 2.0, 3.0)
plot.width = (50., 50.)
Expand All @@ -47,7 +47,7 @@ that location.

By default, a unique color will be assigned to each cell in the geometry. If you
want your plot to be colored by material instead, change the
:attr:`Plot.color_by` attribute::
:attr:`SlicePlot.color_by` attribute::

plot.color_by = 'material'

Expand All @@ -68,8 +68,8 @@ particular cells/materials should be given colors of your choosing::
Note that colors can be given as RGB tuples or by a string indicating a valid
`SVG color <https://www.w3.org/TR/SVG11/types.html#ColorKeywords>`_.

When you're done creating your :class:`openmc.Plot` instances, you need to then
assign them to a :class:`openmc.Plots` collection and export it to XML::
When you're done creating your :class:`openmc.SlicePlot` instances, you need to
then assign them to a :class:`openmc.Plots` collection and export it to XML::

plots = openmc.Plots([plot1, plot2, plot3])
plots.export_to_xml()
Expand Down Expand Up @@ -97,13 +97,11 @@ Voxel Plots
.. image:: ../_images/3dba.png
:width: 200px

The :class:`openmc.Plot` class can also be told to generate a 3D voxel plot
instead of a 2D slice plot. Simply change the :attr:`Plot.type` attribute to
'voxel'. In this case, the :attr:`Plot.width` and :attr:`Plot.pixels` attributes
should be three items long, e.g.::
The :class:`openmc.VoxelPlot` class enables the generation of a 3D voxel plot
instead of a 2D slice plot. In this case, the :attr:`VoxelPlot.width` and
:attr:`VoxelPlot.pixels` attributes should be three items long, e.g.::

vox_plot = openmc.Plot()
vox_plot.type = 'voxel'
vox_plot = openmc.VoxelPlot()
vox_plot.width = (100., 100., 50.)
vox_plot.pixels = (400, 400, 200)

Expand Down
6 changes: 2 additions & 4 deletions docs/source/usersguide/random_ray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1131,11 +1131,10 @@ given below:
tallies.export_to_xml()

# Create voxel plot
plot = openmc.Plot()
plot = openmc.VoxelPlot()
plot.origin = [0, 0, 0]
plot.width = [2*pitch, 2*pitch, 1]
plot.pixels = [1000, 1000, 1]
plot.type = 'voxel'

# Instantiate a Plots collection and export to XML
plots = openmc.Plots([plot])
Expand Down Expand Up @@ -1215,11 +1214,10 @@ given below:
tallies.export_to_xml()

# Create voxel plot
plot = openmc.Plot()
plot = openmc.VoxelPlot()
plot.origin = [0, 0, 0]
plot.width = [2*pitch, 2*pitch, 1]
plot.pixels = [1000, 1000, 1]
plot.type = 'voxel'

# Instantiate a Plots collection and export to XML
plots = openmc.Plots([plot])
Expand Down
4 changes: 2 additions & 2 deletions examples/lattice/hexagonal/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@
# Exporting to OpenMC plots.xml file
###############################################################################

plot_xy = openmc.Plot(plot_id=1)
plot_xy = openmc.SlicePlot(plot_id=1)
plot_xy.filename = 'plot_xy'
plot_xy.origin = [0, 0, 0]
plot_xy.width = [6, 6]
plot_xy.pixels = [400, 400]
plot_xy.color_by = 'material'

plot_yz = openmc.Plot(plot_id=2)
plot_yz = openmc.SlicePlot(plot_id=2)
plot_yz.filename = 'plot_yz'
plot_yz.basis = 'yz'
plot_yz.origin = [0, 0, 0]
Expand Down
2 changes: 1 addition & 1 deletion examples/lattice/nested/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
# Exporting to OpenMC plots.xml file
###############################################################################

plot = openmc.Plot(plot_id=1)
plot = openmc.SlicePlot(plot_id=1)
plot.origin = [0, 0, 0]
plot.width = [4, 4]
plot.pixels = [400, 400]
Expand Down
2 changes: 1 addition & 1 deletion examples/lattice/simple/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
# Exporting to OpenMC plots.xml file
###############################################################################

plot = openmc.Plot(plot_id=1)
plot = openmc.SlicePlot(plot_id=1)
plot.origin = [0, 0, 0]
plot.width = [4, 4]
plot.pixels = [400, 400]
Expand Down
3 changes: 1 addition & 2 deletions examples/pincell_random_ray/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@
# Exporting to OpenMC plots.xml file
###############################################################################

plot = openmc.Plot()
plot = openmc.VoxelPlot()
plot.origin = [0, 0, 0]
plot.width = [pitch, pitch, pitch]
plot.pixels = [1000, 1000, 1]
plot.type = 'voxel'

# Instantiate a Plots collection and export to XML
plots = openmc.Plots([plot])
Expand Down
6 changes: 3 additions & 3 deletions openmc/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def pwr_pin_cell() -> openmc.Model:
constraints={'fissionable': True}
)

plot = openmc.Plot.from_geometry(model.geometry)
plot = openmc.SlicePlot.from_geometry(model.geometry)
plot.pixels = (300, 300)
plot.color_by = 'material'
model.plots.append(plot)
Expand Down Expand Up @@ -429,7 +429,7 @@ def pwr_core() -> openmc.Model:
model.settings.source = openmc.IndependentSource(space=openmc.stats.Box(
[-160, -160, -183], [160, 160, 183]))

plot = openmc.Plot()
plot = openmc.SlicePlot()
plot.origin = (125, 125, 0)
plot.width = (250, 250)
plot.pixels = (3000, 3000)
Expand Down Expand Up @@ -544,7 +544,7 @@ def pwr_assembly() -> openmc.Model:
constraints={'fissionable': True}
)

plot = openmc.Plot()
plot = openmc.SlicePlot()
plot.origin = (0.0, 0.0, 0)
plot.width = (21.42, 21.42)
plot.pixels = (300, 300)
Expand Down
2 changes: 1 addition & 1 deletion openmc/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def plot_inline(plots, openmc_exec='openmc', cwd='.', path_input=None):

Parameters
----------
plots : Iterable of openmc.Plot
plots : Iterable of openmc.PlotBase
Plots to display
openmc_exec : str
Path to OpenMC executable
Expand Down
2 changes: 1 addition & 1 deletion openmc/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ def plot(
self.settings.plot_seed = seed

# Create plot object matching passed arguments
plot = openmc.Plot()
plot = openmc.SlicePlot()
plot.origin = origin
plot.width = width
plot.pixels = pixels
Expand Down
Loading
Loading