SolidRayTracePlot -> empty plot (aka white square)

Hi,

I really like the new SolidRayTracePlot feature.
I cannot get it running, though:
The ‘simple’ example below gives me only an empty (white) image

Anything obvious I have overlooked?

Thanks in advance,
Richard

import openmc

# Define a material
mat = openmc.Material()
mat.set_density('g/cm3', 1.0)
mat.add_nuclide('H1', 2.0)
mat.add_nuclide('O16', 1.0)

materials = openmc.Materials([mat])
materials.export_to_xml()

# Create a sphere surface
sphere = openmc.Sphere(r=10.0, boundary_type='vacuum')

# Define a cell inside the sphere
cell = openmc.Cell()
cell.region = -sphere  # Inside the sphere
cell.fill = mat

# Create a universe and geometry
universe = openmc.Universe(cells=[cell])
geometry = openmc.Geometry(universe)

# Export the geometry to XML
geometry.export_to_xml()

# Define a SolidRayTracePlot (corrected)
plot = openmc.SolidRayTracePlot()
plot.filename = "raytrace_plot"  # Output file name
plot.width = (40.0, 40.0)  # Size of the plot in cm
plot.pixels = (400, 400)  # Image resolution
#plot.basis = 'xy'  # Plane of the plot
plot.camera_position = (10.0, 20.0, -30.0)
plot.look_at = (4.0, 5.0, 1.0)


# Export plot settings to XML
plots = openmc.Plots([plot])
plots.export_to_xml()
#
openmc.plot_geometry()

img = openmc.plot_inline(plots)

Anyone else having similar issues? is perhaps a module or library missing?

Best,
Richard

I believe you need to set plot.opaque_domains to a list of cells or materials that you want to be shown. I found this a little unintuitive too that the default is not to show all domains but instead to show none. @gridley since this feature was your baby, is that the intended behavior?

Hey Paul, yes, that was the original intent. Funnily enough, I ran into this same slipup the other day and wondered why it wasn’t doing what I expected. This is because if you include a material like “air” by default, you’ll see a solid block where the problem is; this isn’t quite helpful.

Maybe having everything included by default would be better. Hm.

Anyway, adding these two lines results in the below image.

plot.color_by = 'material'
plot.opaque_domains = [mat]

Thanks a lot Gavin and Paul! - it works for me, too, now

2 Likes