Outdated examples. Confusing documentation but solved?

Hi, I’m new to OpenMC and is trying to learn how to use it through the provided examples, but they’re horribly outdated! I am using verison 0.15.1 and they’re for 0.9.0, which of course leads to deprecated and removed functionalities.


Edit from later:

There is working documentation for v0.12.2, but was not obvious to me at first. When clicking the latest button on the documentation page, it does not show up. Yes I could have checked through every single version but I didn’t because I didn’t realize. Perhaps… Perhaps how the “Read the Docs” panel works could be changed, or maybe I am stupid. This does seem to fix all my problems though, but I will leave this up so confused beginners like me don’t have to make the same mistake. Also, it still would be nice if the examples were up to date.

My suggestions for preventing unececcary confusion is to perhaps underline versions that have documentation, make the latest button work and provide the version for both stable and latest like latest(v.x.x.x) or something. This is a bit embarassing but I’ll leave it up anyway


I have literally copied the Tally Arithmetic example (previously tried altering it to fix the problem but I didn’t really fix much.) and straight away I get an error message as follows after doing openmc.run() for the first time in the example.

 ERROR: Cannot tally currents without surface type filters
Traceback (most recent call last):
  File "/(undisclosed=/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_2.py", line 231, in <module>
    openmc.run()
  File "/usr/local/lib/python3.10/dist-packages/openmc/executor.py", line 314, in run
    _run(args, output, cwd)
  File "/usr/local/lib/python3.10/dist-packages/openmc/executor.py", line 125, in _run
    raise RuntimeError(error_msg)
RuntimeError: Cannot tally currents without surface type filters

I cannot add files yet, but my file is the same untilIn[22]: except for that i have added tally_id = n where n is a number for each tally to easily identify the problematic tallies.

After this i tried doing as in this forum post where MeshFilter is changed to MeshSurfaceFilter which does allow me to run the code. The issue then arises when I try to use the tallies as described in the examples, as detailed here:

Debugging:
    1.
        Changed MeshFilter to MeshSurfaceFilter as per devs recommendation https://openmc.discourse.group/t/problem-with-reading-current-tallies/453
        Error message:
            Traceback (most recent call last):
            File "/(undisclosed)/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_arithemtic.py", line 308, in <module>
                leak = leak.summation(filter_type=openmc.SurfaceFilter, remove_filter=True)
            File "/usr/local/lib/python3.10/dist-packages/openmc/tallies.py", line 2747, in summation
                find_filter = self.find_filter(filter_type)
            File "/usr/local/lib/python3.10/dist-packages/openmc/tallies.py", line 1001, in find_filter
                raise ValueError(msg)
            ValueError: Unable to find filter type "<class 'openmc.filter.SurfaceFilter'>" in Tally ID="4"
        Changed it back

    2.
        Added mesh_surface_filter = openmc.MeshSurfaceFilter(mesh) to solve "RuntimeError: Cannot tally currents without surface type filters"
        Added mesh_surface_filter to all leakage tallies in their filter
        -> did not work as it requests SurfaceFilter, not MeshSurfaceFilter. Removed mesh_surface_filter from all leakage tally filters
        Error message:
                Traceback (most recent call last):
            File "/(undisclosed)/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_arithemtic.py", line 264, in <module>
                leak = leak.summation(filter_type=openmc.SurfaceFilter, remove_filter=True)
            File "/usr/local/lib/python3.10/dist-packages/openmc/tallies.py", line 2747, in summation
                find_filter = self.find_filter(filter_type)
            File "/usr/local/lib/python3.10/dist-packages/openmc/tallies.py", line 1001, in find_filter
                raise ValueError(msg)
            ValueError: Unable to find filter type "<class 'openmc.filter.SurfaceFilter'>" in Tally ID="4"

    3.
        Added surface_filter = openmc,Surfacefilter(mesh) to solve "ValueError: Unable to find filter type "<class 'openmc.filter.SurfaceFilter> in Tally ID=4"
        Error message: 
            Traceback (most recent call last):
            File "/(undisclosed)/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_arithemtic.py", line 182, in <module>
                surface_filter = openmc.SurfaceFilteR(mesh)
            AttributeError: module 'openmc' has no attribute 'SurfaceFilteR'. Did you mean: 'SurfaceFilter'?
            OpenMC-env-0.1.0 >python3 tally_arithemtic.py 
            /usr/local/lib/python3.10/dist-packages/openmc/source.py:656: FutureWarning: This class is deprecated in favor of 'IndependentSource'
            warnings.warn("This class is deprecated in favor of 'IndependentSource'", FutureWarning)
            Traceback (most recent call last):
            File "/(undisclosed)/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_arithemtic.py", line 182, in <module>
                surface_filter = openmc.SurfaceFilter(mesh)
            File "/usr/local/lib/python3.10/dist-packages/openmc/filter.py", line 435, in __init__
                cv.check_iterable_type('filter bins', bins,
            File "/usr/local/lib/python3.10/dist-packages/openmc/checkvalue.py", line 137, in check_iterable_type
                f'"{expected_type.__name__}", but item at {ind_str} is '
            AttributeError: 'tuple' object has no attribute '__name__'. Did you mean: '__ne__'?

In my opinion the docs are also somewhat hard to navigate, and provide relatively little information on how to fix my problems. I tried just skipping the tallies where meshes are needed, and was out of luck there too. Again, I have just copied the example except for adding IDs.

At this part I get an error too:

Compute fast fission factor factor using tally arithmetic

therm_fiss_rate = sp.get_tally(name='therm. fiss. rate')

fast_fiss = fiss_rate / therm_fiss_rate

print(fast_fiss.get_pandas_dataframe())

Traceback (most recent call last):
  File "/(undisclosed)/hume/student-u50/hannawes/summer_project_2025/Tally_Arithmetic/tally_arithemtic.py", line 356, in <module>
    fast_fiss = fiss_rate / therm_fiss_rate
  File "/usr/local/lib/python3.10/dist-packages/openmc/tallies.py", line 2338, in __truediv__
    raise ValueError(msg)
ValueError: Unable to use tally arithmetic with Tally ID="7" since it does not contain any results.

I’m unsure what the problems here are, but they must be about how I have tried to tally and so on but it’s the same as in the example. Please help :blush:

I checked the tallies.out-file, and there is data there for every tally that I am looking at. As in the example I’m using sp = openmc.Statepoint('statepoint.20.h5') and tally_data = sp.get_tally(name = 'tally_data). How do I access the data when the code suggests it does not exist? (<- reminder! all of this was solved when using v.0.12.2 documentation)