RuntimeError: Failed to open HDF5 file with mode 'w': summary.h5

Dear Expert @paulromano @pshriwise @Shimwell I encountered this error when I ran my Python Code. For this error “with openmc.StatePoint(‘statepoint.10.h5’) as sp:
k_eff = sp.keff” I need to add this script, but I’m still a novice on how to add it.Dear experts, how can I solve this problem?

#Sample
from math import pi, sin, cos
import numpy as np
import openmc
import json
import numpy as np
from pathlib import Path
import openmc.deplete
r_fuel = 0.6122
r_clad = 0.6540
pressure_tube_ir = 5.16890
pressure_tube_or = 5.60320
calendria_ir = 6.44780
calendria_or = 6.58750
# Fuel
fuel = openmc.Material(name='fuel')
fuel.add_nuclide('U235', 6.27118E-1 , 'wo')
fuel.add_nuclide('U238', 8.75256E+1 , 'wo')
fuel.add_nuclide('O16', 1.18473E+1 , 'wo')
fuel.volume = 37*pi*r_fuel**2
fuel.set_density('g/cm3', 10.4375010)
fuel.temperature=960
# Coolant Water
heavy_water_coolant = openmc.Material(name='heavy water coolant')
heavy_water_coolant.add_nuclide('H2', 1.99768E-1 , 'wo' )
heavy_water_coolant.add_nuclide('O16', 7.99449E-1 , 'wo' )
heavy_water_coolant.add_nuclide('H1', 7.83774E-4 , 'wo' )
heavy_water_coolant.set_density('g/cm3', 0.812120)
heavy_water_coolant.temperature=561
# Calandria tube
clad_calandria = openmc.Material(name='Calandria')
clad_calandria.add_nuclide('Mn55', 1.60000E-1 , 'wo' )  
clad_calandria.add_element('Ni', 6.00000E-2 , 'wo' )  
clad_calandria.add_element('Cr', 1.10000E-1 , 'wo' )  
clad_calandria.add_element('Zr', 9.97100E+1  , 'wo' )  
clad_calandria.add_nuclide('B10', 5.7409e-05 , 'wo' )
clad_calandria.add_nuclide('B11', 2.5259E-04 , 'wo' )
clad_calandria.set_density('g/cm3', 6.44)
clad_calandria.temperature=300
# Clad
clad = openmc.Material(name='Clad')
clad.add_nuclide('Mn55', 1.60000E-1 , 'wo' )  
clad.add_element('Ni', 6.00000E-2 , 'wo' )  
clad.add_element('Cr', 1.10000E-1 , 'wo' )  
clad.add_element('Zr', 9.97100E+1  , 'wo' )  
clad.add_nuclide('B10', 5.7409e-05 , 'wo' )
clad.add_nuclide('B11', 2.5259E-04 , 'wo' )
clad.set_density('g/cm3', 6.44)
# Moder
heavy_water = openmc.Material(name='heavy water')
heavy_water.add_nuclide('H2', 2.01016E-1, 'wo' )
heavy_water.add_nuclide('O16', 7.98895E-1, 'wo' )
heavy_water.add_nuclide('H1', 8.96000E-5, 'wo' )
heavy_water.set_density('g/cm3', 1.082885 )
heavy_water.add_s_alpha_beta('c_D_in_D2O')
heavy_water.temperature=345
# Pressure Tube
tube = openmc.Material(name='PressTube')
tube.add_element('Zr', 9.75000E+1 , 'wo' )  
tube.add_nuclide('B10', 3.8889E-05 , 'wo' )
tube.add_nuclide('B11', 1.7111E-04 , 'wo' )
tube.set_density('g/cm3', 6.57)
tube.temperature=600
mats = openmc.Materials([fuel, heavy_water_coolant, clad_calandria, clad, heavy_water, tube ])
mats.export_to_xml()

# Radius to center of each ring of fuel pins
ring_radii = np.array([0.0, 1.4885, 2.8755, 4.3305])
# These are the surfaces that will divide each of the rings
radial_surf = [openmc.ZCylinder(R=r) for r in
               (ring_radii[:-1] + ring_radii[1:])/2]

water_cells = []
for i in range(ring_radii.size):
    # Create annular region
    if i == 0:
        water_region = -radial_surf[i]
    elif i == ring_radii.size - 1:
        water_region = +radial_surf[i-1]
    else:
        water_region = +radial_surf[i-1] & -radial_surf[i]
        
    water_cells.append(openmc.Cell(fill=heavy_water, region=water_region))
bundle_universe = openmc.Universe(cells=water_cells)
surf_fuel = openmc.ZCylinder(R=r_fuel)
surf_clad = openmc.ZCylinder(R=r_clad)

fuel_cell = openmc.Cell(fill=fuel, region=-surf_fuel)
clad_cell = openmc.Cell(fill=clad, region=+surf_fuel & -surf_clad)
cool_cell = openmc.Cell(fill=heavy_water_coolant, region=+surf_clad & -surf_clad)

pin_universe = openmc.Universe(cells=(fuel_cell, clad_cell, cool_cell))
num_pins = [1, 6, 12, 18]
angles = [0, 0, 15, 0]

for i, (r, n, a) in enumerate(zip(ring_radii, num_pins, angles)):
    for j in range(n):
        # Determine location of center of pin
        theta = (a + j/n*360.) * pi/180.
        x = r*cos(theta)
        y = r*sin(theta)
        
        pin_boundary = openmc.ZCylinder(x0=x, y0=y, R=r_clad)
        water_cells[i].region &= +pin_boundary
        
         
        # That we can identify the pin later when looking at tallies
        pin = openmc.Cell(fill=pin_universe, region=-pin_boundary)
        pin.translation = (x, y, 0)
        pin.id = (i + 1)*100 + j
        bundle_universe.add_cell(pin)

pt_inner = openmc.ZCylinder(R=pressure_tube_ir)
pt_outer = openmc.ZCylinder(R=pressure_tube_or)
calendria_inner = openmc.ZCylinder(R=calendria_ir)
calendria_outer = openmc.ZCylinder(R=calendria_or)
bound_box = openmc.model.rectangular_prism(20, 20 , axis='z', origin=(0.0, 0.0), boundary_type='reflective', corner_radius=0.0)

bundle = openmc.Cell(fill=bundle_universe, region=-pt_inner)
pressure_tube = openmc.Cell(fill=tube, region=+pt_inner & -pt_outer)
v1 = openmc.Cell(fill=clad_calandria,region=+pt_outer & -calendria_inner)
calendria = openmc.Cell(fill=clad_calandria, region=+calendria_inner & -calendria_outer)
moderator_cell=openmc.Cell(fill=heavy_water , region=+calendria_outer & bound_box)
root_universe = openmc.Universe(cells=[bundle, pressure_tube, v1, calendria,moderator_cell])
geom = openmc.Geometry(root_universe)
geom.export_to_xml()
settings = openmc.Settings()
settings.particles = 500
settings.batches = 50
settings.inactive = 5
settings.source = openmc.Source(space=openmc.stats.Point())
settings.temperature = {'default': 345 , 'method': 'interpolation',}
settings.export_to_xml()
# Instantiate an empty Tallies object
tallies = openmc.Tallies()
# Create mesh which will be used for tally
mesh = openmc.RegularMesh()
mesh.dimension = [100, 100]
mesh.lower_left = [-10, -10]
mesh.upper_right = [10, 10]

# Create mesh filter for tally
mesh_filter = openmc.MeshFilter(mesh)

# Create mesh tally to score flux and fission rate
tally = openmc.Tally(name='flux')
tally.filters = [mesh_filter]
tally.scores = ['flux', 'fission']
tallies.append(tally)
# Export to "tallies.xml"
tallies.export_to_xml()
openmc.run()

Hi @pfproton,

Thanks for posting! Sorry you ran into this issue. I’m linking a previous response to a similar query from a while back. It has a link to some relevant information on this topic in the documentation and some background information on why you’re running into this issue.

https://docs.openmc.org/en/stable/usersguide/troubleshoot.html#runtimeerror-failed-to-open-hdf5-file-with-mode-w-summary-h5

Hope this helps! Best of luck.

– Patrick

1 Like

Hello Expert, to which part of the code should I add this code script?

Hi @pfproton,

You may not need to add anything to your script. It’s quite possible that a statepoint file was open in another Python interpreter or in the OpenMC plotter, this will also cause the error described in the documentation links above.

1 Like