From 60f17ea4663886af845a15f393e6e026f4b373f7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 25 Sep 2019 12:36:47 -0500 Subject: [PATCH] Make sure from_ace classmethods get correct type of ACE table --- openmc/data/neutron.py | 3 +++ openmc/data/photon.py | 4 +++- openmc/data/thermal.py | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index 022cf8283d..8a6c889817 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -588,6 +588,9 @@ class IncidentNeutron(EqualityMixin): # If mass number hasn't been specified, make an educated guess zaid, xs = ace.name.split('.') + if not xs.endswith('c'): + raise TypeError( + "{} is not a continuous-energy neutron ACE table.".format(ace)) name, element, Z, mass_number, metastable = \ get_metadata(int(zaid), metastable_scheme) diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 0d0e527533..3766b697e0 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -549,7 +549,9 @@ class IncidentPhoton(EqualityMixin): ace = get_table(ace_or_filename) # Get atomic number based on name of ACE table - zaid = ace.name.split('.')[0] + zaid, xs = ace.name.split('.') + if not xs.endswith('p'): + raise TypeError("{} is not a photoatomic transport ACE table.".format(ace)) Z = get_metadata(int(zaid))[2] # Read each reaction diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 06e50c6618..4fbe963631 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -600,6 +600,8 @@ class ThermalScattering(EqualityMixin): # Get new name that is GND-consistent ace_name, xs = ace.name.split('.') + if not xs.endswith('t'): + raise TypeError("{} is not a thermal scattering ACE table.".format(ace)) name = get_thermal_name(ace_name) # Assign temperature to the running list