Skip to content

Commit ca29d81

Browse files
committed
added thermal check
1 parent 115b930 commit ca29d81

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/openmc_data_to_json/core.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,11 @@ def cross_section_h5_to_json(
429429
) -> dict:
430430

431431
dict_of_reactions = [] # {}
432-
isotope_object, particle = open_h5(filename)
432+
contents = open_h5(filename)
433+
if contents is None:
434+
return []
435+
436+
isotope_object, particle = contents
433437
incident_particle_symbol = particle[0]
434438

435439
if reaction == "all":
@@ -526,14 +530,18 @@ def reactions_in_h5(filename: str):
526530

527531

528532
def open_h5(filename: str):
529-
533+
print(filename)
530534
with h5py.File(filename) as h5file:
531535
# same method as openmc library.py
532536
particle = h5file.attrs["filetype"].decode()[5:]
533537

534538
if particle == "neutron":
535539
isotope_object = openmc.data.IncidentNeutron.from_hdf5(filename)
536-
if particle == "photon":
540+
elif particle == "photon":
537541
isotope_object = openmc.data.IncidentPhoton.from_hdf5(filename)
538-
542+
elif particle == "thermal":
543+
print(f"particle not supported {particle}")
544+
return None
545+
else:
546+
raise ValueError(f"particle not recognized {particle}")
539547
return isotope_object, particle

0 commit comments

Comments
 (0)