mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
updated photon data test to check cross sections and data by from_hdf5()
This commit is contained in:
parent
ea71b9e377
commit
0f248381d1
4 changed files with 21 additions and 7 deletions
|
|
@ -349,8 +349,8 @@ class Tabulated1D(Function1D):
|
|||
raise ValueError("Expected an HDF5 attribute 'type' equal to '"
|
||||
+ cls.__name__ + "'")
|
||||
|
||||
x = dataset.value[0, :]
|
||||
y = dataset.value[1, :]
|
||||
x = dataset[0, :]
|
||||
y = dataset[1, :]
|
||||
breakpoints = dataset.attrs['breakpoints']
|
||||
interpolation = dataset.attrs['interpolation']
|
||||
return cls(x, y, breakpoints, interpolation)
|
||||
|
|
|
|||
|
|
@ -376,8 +376,8 @@ class AtomicRelaxation(EqualityMixin):
|
|||
# Write transition data with replacements
|
||||
if shell in self.transitions:
|
||||
df = self.transitions[shell].replace(
|
||||
_SUBSHELLS, np.arange(float(len(_SUBSHELLS))))
|
||||
group.create_dataset('transitions')
|
||||
_SUBSHELLS, range(len(_SUBSHELLS)))
|
||||
group.create_dataset('transitions', data=df.values.astype(float))
|
||||
|
||||
|
||||
class IncidentPhoton(EqualityMixin):
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ class CoherentElastic(EqualityMixin):
|
|||
Coherent elastic scattering cross section
|
||||
|
||||
"""
|
||||
bragg_edges = dataset.value[0, :]
|
||||
factors = dataset.value[1, :]
|
||||
bragg_edges = dataset[0, :]
|
||||
factors = dataset[1, :]
|
||||
return cls(bragg_edges, factors)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,20 @@ def test_export_to_hdf5(tmpdir, element):
|
|||
filename = str(tmpdir.join('tmp.h5'))
|
||||
element.export_to_hdf5(filename)
|
||||
assert os.path.exists(filename)
|
||||
# Read in data from hdf5 and export again
|
||||
# Read in data from hdf5
|
||||
element2 = openmc.data.IncidentPhoton.from_hdf5(filename)
|
||||
# Check for some cross section and datasets of element and element2
|
||||
energy = np.logspace(np.log10(1.0), np.log10(1.0e10), num=100)
|
||||
for mt in (502, 504, 515, 517, 522, 541, 570):
|
||||
xs = element[mt].xs(energy)
|
||||
xs2 = element2[mt].xs(energy)
|
||||
assert np.allclose(xs, xs2)
|
||||
assert element[502].scattering_factor == element2[502].scattering_factor
|
||||
assert element.atomic_relaxation.transitions['O3'].equals(
|
||||
element2.atomic_relaxation.transitions['O3'])
|
||||
assert (element.compton_profiles['binding_energy'] ==
|
||||
element2.compton_profiles['binding_energy']).all()
|
||||
assert (element.bremsstrahlung['electron_energy'] ==
|
||||
element2.bremsstrahlung['electron_energy']).all()
|
||||
# Export to hdf5 again
|
||||
element2.export_to_hdf5(filename, 'w')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue