Openmc-plotter Error

Hi All,

I’m getting an error with the openmc-plotter that I hope I can get some help with. First off, great tool, very useful!

My problem is that the plotter works when I only have 7 materials, but when I add an 8th material, or assign material IDs higher than 7, I get errors such as the following when I turn on “Color By: material” in the plotter.

Traceback (most recent call last):
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/site-packages/openmc_plotter/plotmodel.py", line 226, in makePlot
    image = np.array([domain[id].color for id in u])[inv]
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/site-packages/openmc_plotter/plotmodel.py", line 226, in <listcomp>
    image = np.array([domain[id].color for id in u])[inv]
KeyError: 8

I’m actually not certain whether this is a problem with my model or just the plotter, but the model runs fine with no apparent geometry errors. In fact, the openmc-plotter also works as long as I have “Color By:” set to “cell”. Is anyone familiar with a solution to this error?

Thanks!

@kevinm387 glad to hear you’re enjoying the plotter! Sometimes when you regenerate a model that has changes in it, the “cached” state of the plotter gets hosed up. In the directory you’re running the plotter, you should see a plot_settings.pkl file. Just delete that and restart the plotter and hopefully it should work fine after that.

1 Like

Thank you @paulromano! That worked!

@paulromano, a follow up question: I’m trying to use an the openmc-plotter to show tally results on a regular mesh that used an EnergyFunctionFilter. The plotter gives me the error:

Traceback (most recent call last):
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/site-packages/openmc_plotter/main_window.py", line 871, in editSelectedTally
    self.tallyDock.selectTally(event)
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/site-packages/openmc_plotter/docks.py", line 465, in selectTally
    self._createFilterTree(spatial_filters)
  File "/home/kevin/anaconda3/envs/neutronics-env/lib/python3.8/site-packages/openmc_plotter/docks.py", line 415, in _createFilterTree
    for bin in sorted(tally_filter.bins, key=_bin_sort_val):
  File "/home/kevin/.local/lib/python3.8/site-packages/openmc/filter.py", line 1877, in bins
    raise AttributeError('EnergyFunctionFilters have no bins.')
AttributeError: EnergyFunctionFilters have no bins.

The plotter is able to show tallies that do not have an EnergyFunctionFilter, including tallies that have a simple EnergyFilter using the same energy bins, but for the tallies that do, I get the error. I think the tally is set up correctly, because when I look in the tally.out file, I see results in the tallies that included the EnergyFunctionFilter. Am I missing a step to be able to display tally results that included an EnergyFunctionFilter using openmc-plotter?

Thanks!

Hi again @kevinm387. I think this is probably a bug with the plotter. EnergyFunctionFilter operates a little differently than other filters and some of the logic in the plotter looks like it hasn’t accounted for this. I’ll let you know when a fix is available. Thanks for reporting!

Great, thank you @paulromano

@kevinm387 I submitted a pull request with a fix for the bug with EnergyFunctionFilter which has been merged, so the next release should work for your case.

Great, thanks @paulromano, looking forward to using that capability!