From dd74b2f43f1d2060486de2823ee30058b8971dbd Mon Sep 17 00:00:00 2001 From: Sam Powell-Gill Date: Wed, 19 Feb 2020 09:26:13 +0000 Subject: [PATCH 1/4] Fixed bug which prevents creating photon data with no atomic relax --- openmc/data/photon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 32ed3010a..9cc697b78 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -784,8 +784,9 @@ class IncidentPhoton(EqualityMixin): sub_group = shell_group.create_group(key) # Write atomic relaxation - if key in self.atomic_relaxation.subshells: - self.atomic_relaxation.to_hdf5(sub_group, key) + if self.atomic_relaxation is not None: + if key in self.atomic_relaxation.subshells: + self.atomic_relaxation.to_hdf5(sub_group, key) else: continue From 6fd08f5aecd835e695b65657598c8a7e7c64e26b Mon Sep 17 00:00:00 2001 From: Sam Powell-Gill Date: Wed, 19 Feb 2020 11:59:35 +0000 Subject: [PATCH 2/4] Unit test for exporting photon data with no atomic relax --- tests/unit_tests/test_data_photon.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit_tests/test_data_photon.py b/tests/unit_tests/test_data_photon.py index c767d19e6..02635bcc9 100644 --- a/tests/unit_tests/test_data_photon.py +++ b/tests/unit_tests/test_data_photon.py @@ -144,3 +144,11 @@ def test_export_to_hdf5(tmpdir, element): element2.bremsstrahlung['electron_energy']).all() # Export to hdf5 again element2.export_to_hdf5(filename, 'w') + +def test_photodat_only(tmpdir): + endf_data = os.environ['OPENMC_ENDF_DATA'] + filename = str(tmpdir.join('tmp.h5')) + p_file = 'photoat-{:03}_{}_000.endf'.format(1, 'H') + p_path = os.path.join(endf_data, 'photoat', p_file) + data=openmc.data.IncidentPhoton.from_endf(p_path) + data.export_to_hdf5(filename, 'w') \ No newline at end of file From 6bd4c5cd900ab38088faa68024d29f46e5c72552 Mon Sep 17 00:00:00 2001 From: Sam Powell-Gill Date: Thu, 20 Feb 2020 08:48:26 +0000 Subject: [PATCH 3/4] Added suggested changes for #1489 --- tests/unit_tests/test_data_photon.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/unit_tests/test_data_photon.py b/tests/unit_tests/test_data_photon.py index 02635bcc9..2fa0f85a7 100644 --- a/tests/unit_tests/test_data_photon.py +++ b/tests/unit_tests/test_data_photon.py @@ -2,6 +2,7 @@ from collections.abc import Mapping, Callable import os +from pathlib import Path import numpy as np import pandas as pd @@ -145,10 +146,8 @@ def test_export_to_hdf5(tmpdir, element): # Export to hdf5 again element2.export_to_hdf5(filename, 'w') -def test_photodat_only(tmpdir): - endf_data = os.environ['OPENMC_ENDF_DATA'] - filename = str(tmpdir.join('tmp.h5')) - p_file = 'photoat-{:03}_{}_000.endf'.format(1, 'H') - p_path = os.path.join(endf_data, 'photoat', p_file) - data=openmc.data.IncidentPhoton.from_endf(p_path) - data.export_to_hdf5(filename, 'w') \ No newline at end of file +def test_photodat_only(run_in_tmpdir): + endf_dir = Path(os.environ['OPENMC_ENDF_DATA']) + photoatomic_file = endf_dir / 'photoat/photoat-001_H_000.endf' + data=openmc.data.IncidentPhoton.from_endf(photoatomic_file) + data.export_to_hdf5('tmp.h5', 'w') \ No newline at end of file From 0fbfad4d49c543f9203967bb7f9ec5a5225d3734 Mon Sep 17 00:00:00 2001 From: Sam Powell-Gill Date: Thu, 20 Feb 2020 16:29:08 +0000 Subject: [PATCH 4/4] Made requested formatting change --- tests/unit_tests/test_data_photon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/test_data_photon.py b/tests/unit_tests/test_data_photon.py index 2fa0f85a7..f7274e9c1 100644 --- a/tests/unit_tests/test_data_photon.py +++ b/tests/unit_tests/test_data_photon.py @@ -148,6 +148,6 @@ def test_export_to_hdf5(tmpdir, element): def test_photodat_only(run_in_tmpdir): endf_dir = Path(os.environ['OPENMC_ENDF_DATA']) - photoatomic_file = endf_dir / 'photoat/photoat-001_H_000.endf' - data=openmc.data.IncidentPhoton.from_endf(photoatomic_file) + photoatomic_file = endf_dir / 'photoat' / 'photoat-001_H_000.endf' + data = openmc.data.IncidentPhoton.from_endf(photoatomic_file) data.export_to_hdf5('tmp.h5', 'w') \ No newline at end of file