From 2a50aff588fed0224699456a9e319bfb298a4610 Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Fri, 11 Nov 2016 15:20:40 -0500 Subject: [PATCH] Pre-PR cleanup and addition of ability to read MT in types --- openmc/element.py | 18 ++---------------- openmc/material.py | 19 ++----------------- openmc/nuclide.py | 13 +++++++++---- 3 files changed, 13 insertions(+), 37 deletions(-) diff --git a/openmc/element.py b/openmc/element.py index d90cdf4fc9..6fe988195e 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -400,20 +400,6 @@ class Element(object): if cross_sections is not None: cv.check_type('cross_sections', cross_sections, str) cv.check_iterable_type('types', types, str) - - # Parse the types - mts = [] - ops = [] - yields = [] - for line in types: - if line in PLOT_TYPES: - mts.append(PLOT_TYPES_MT[line]) - yields.append(PLOT_TYPES_YIELD[line]) - ops.append(PLOT_TYPES_OP[line]) - else: - # Not a built-in type, we have to parse it ourselves - raise NotImplementedError() - cv.check_type('temperature', temperature, Real) # If cross_sections is None, get the cross sections from the @@ -462,8 +448,8 @@ class Element(object): unionE = np.union1d(unionE, E[n]) # Now we can combine all the nuclidic data - data = np.zeros((len(mts), len(unionE))) - for l in range(len(mts)): + data = np.zeros((len(types), len(unionE))) + for l in range(len(types)): if types[l] == 'unity': data[l, :] = 1. else: diff --git a/openmc/material.py b/openmc/material.py index ed54bffc30..1889a47652 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -834,21 +834,6 @@ class Material(object): # Check types if cross_sections is not None: cv.check_type('cross_sections', cross_sections, str) - cv.check_iterable_type('types', types, str) - - # Parse the types - mts = [] - ops = [] - yields = [] - for line in types: - if line in PLOT_TYPES: - mts.append(PLOT_TYPES_MT[line]) - yields.append(PLOT_TYPES_YIELD[line]) - ops.append(PLOT_TYPES_OP[line]) - else: - # Not a built-in type, we have to parse it ourselves - raise NotImplementedError() - if self.temperature is not None: T = self.temperature else: @@ -901,8 +886,8 @@ class Material(object): unionE = np.union1d(unionE, E[n]) # Now we can combine all the nuclidic data - data = np.zeros((len(mts), len(unionE))) - for l in range(len(mts)): + data = np.zeros((len(types), len(unionE))) + for l in range(len(types)): if types[l] == 'unity': data[l, :] = 1. else: diff --git a/openmc/nuclide.py b/openmc/nuclide.py index b549da8962..439aedf482 100644 --- a/openmc/nuclide.py +++ b/openmc/nuclide.py @@ -200,8 +200,10 @@ class Nuclide(object): Parameters ---------- - types : Iterable of values of PLOT_TYPES - The type of cross sections to calculate + types : Iterable of str or Integral + The type of cross sections to calculate; values can either be those + in openmc.PLOT_TYPES or integers which correspond to reaction + channel (MT) numbers. temperature : float, optional Temperature in Kelvin to plot. If not specified, a default temperature of 294K will be plotted. Note that the nearest @@ -224,7 +226,6 @@ class Nuclide(object): # Check types if cross_sections is not None: cv.check_type('cross_sections', cross_sections, str) - cv.check_iterable_type('types', types, str) if sab_name: cv.check_type('sab_name', sab_name, str) @@ -239,7 +240,11 @@ class Nuclide(object): ops.append(PLOT_TYPES_OP[line]) else: # Not a built-in type, we have to parse it ourselves - raise NotImplementedError() + cv.check_type('MT in types', line, Integral) + cv.check_greater_than('MT in types', line, 0) + mts.append((line,)) + yields.append((False,)) + ops.append(()) # If cross_sections is None, get the cross sections from the # OPENMC_CROSS_SECTIONS environment variable