Projection Plot Help

Hello,

I’m modeling a square pitch TRIGA reactor, and have run into an issue when attempting to create a Projection Plot. I’ve defined a few slice plots beforehand, and have added a modified version of the openmc.ProjectionPlot() example code from the manual. This is what I have:

plot1 = openmc.Plot()
plot1.basis = 'yz'
plot1.origin = (5.99313, 0.0, 96.917065)
plot1.width = (100, 125)
plot1.pixels = (6000, int(6000 * 1.25))
plot1.color_by = 'material'
plot1.colors = cmap

#
# a bunch more slice plots here, these aren't the issue
#

plot13 = openmc.Plot()
plot13.basis = 'xy'
plot13.origin = (0.0, 0.0, 96.594935)
plot13.width = (90, 90)
plot13.pixels = (8000, 8000)
plot13.color_by = 'cell'

plot_list = [plot1, plot2, plot3, plot11, plot12, plot13]

# This is the code from the manual, without the for loop or wire frames
# and adjusted for my geometry:

r = 90
phi = 2 * np.pi / 100
thisp = openmc.ProjectionPlot(plot_id = 10)
thisp.look_at = [0, 0, 96.594935]
thisp.camera_position = [r * np.cos(phi), r * np.sin(phi), 6 * np.sin(phi)]
thisp.pixels = [200, 200]
thisp.color_by = 'material'
thisp.set_transparent(geometry)
thisp.colorize(geometry)
thisp.colors = cmap
thisp.xs[mats.m_SS304] = 1

# print(thisp)
plot_list.append(thisp)
  
plots = openmc.Plots(plot_list)

Whenever I run this code, I get an error that thisp is the incorrect type. When I print thisp, I get a dictionary full of materials and some value:

> print(thisp)

{Material
        ID             =        1175501
        Name           =        B_11755
        Temperature    =        None
        Density        =        6.9218 [g/cm3]
        Volume         =        None [cm^3]
        Depletable     =        True
        S(a,b) Tables
        S(a,b)         =        ('c_H_in_ZrH', 1.0)
        S(a,b)         =        ('c_Zr_in_ZrH', 1.0)
        Nuclides
        U232           =        1.23348002589786e-10 [ao]
        U234           =        0.00015897950983257992 [ao]
        U235           =        0.012024796157039701 [ao]
        U236           =        0.00027888274320547404 [ao]
        U238           =        0.04787119849549626 [ao]
        (... lots more nuclides after this)
: 0.0, Material
        ID             =        1175501
        Name           =        B_11755
        Temperature    =        None
        Density        =        6.9218 [g/cm3]
        Volume         =        None [cm^3]
        Depletable     =        True
        S(a,b) Tables
        S(a,b)         =        ('c_H_in_ZrH', 1.0)
        S(a,b)         =        ('c_Zr_in_ZrH', 1.0)
        Nuclides
        U232           =        1.23348002589786e-10 [ao]
        U234           =        0.00015897950983257992 [ao]
        U235           =        0.012024796157039701 [ao]
        U236           =        0.00027888274320547404 [ao]
        U238           =        0.04787119849549626 [ao]
        (... lots more nuclides after this)
: 0.0, ... etc.}

I’m not really sure what’s going on here. The error is as follows:

> python triga_model.py

Traceback (most recent call last):
  File "<filepath>/triga_model.py", line 826, in <module>
    model = create_model()
  File "<filepath>/triga_model.py", line 820, in create_model
    model.plots = plots
  File "<filepath>/openmc-env/lib/python3.10/site-packages/openmc/model/model.py", line 137, in plots
    check_type('plots', plots, Iterable, openmc.Plot)
  File "<filepath>/openmc-env/lib/python3.10/site-packages/openmc/checkvalue.py", line 63, in check_type
    raise TypeError(msg)
TypeError: Unable to set "plots" to "[Plot 
     (... full plot list here, ending with the output above)
     ]" since each item must be of type "Plot"

Any suggestions?

Hi Paul, welcome back to the openmc community.
have you tried to append the projection plot into an openmc.Plots()?

plot_file = openmc.Plots()
r = ...
for i in range(100):
    phi = 2 * np.pi * i/100
    thisp = openmc.ProjectionPlot(plot_id = 200 + i)
    thisp.filename = 'frame%s'%(str(i).zfill(3))
    thisp.look_at = [x,y,z coordinate]
    thisp.camera_position = [r * np.cos(phi), r * np.sin(phi), 6 * np.sin(phi)]
    thisp.pixels = [200, 200]
    thisp.color_by = 'material'
    thisp.colorize(geometry)
    thisp.set_transparent(geometry)
    ...
    plot_file.append(thisp)

plot_file.export_to_xml()
openmc.plot_geometry()

also, I hope this topic can help you

Dear Wahid,

Thanks for the extra command.

I was using openmc –plot,

openmc.plot_geometry() is more convenient to produce the .png files.

I have posted a “fully working example” for future noob users such as me.

Regards

Hi Frederic,
I am also still learning to use openmc properly, so thanks to you for giving the nice examples right there.

Thanks for the article.

I did append the plots to the openmc.Plots() instance, and that is what is throwing the error. It seems to be localized to my model, as the Projection plots from the example generate just fine. I’ll have to do some digging.