From e13bd5c853b4251ef5ef8f46f0c1221fdde0442f Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Sun, 15 May 2016 19:13:22 -0400 Subject: [PATCH] Fixed per @paulromano comments --- openmc/mgxs/library.py | 18 +++++++--------- openmc/mgxs_library.py | 47 ++++++++++++++++++++++++++++++++++++++++-- src/summary.F90 | 2 +- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 45b502be48..baa4d63047 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -4,9 +4,10 @@ import copy import pickle from numbers import Integral from collections import OrderedDict -import numpy as np from warnings import warn +import numpy as np + import openmc import openmc.mgxs import openmc.checkvalue as cv @@ -759,7 +760,7 @@ class Library(object): See also -------- - Library.create_mg_library(...) + Library.create_mg_library() """ @@ -890,7 +891,7 @@ class Library(object): See also -------- - Library.dump_to_file(mgxs_lib, filename, directory) + Library.dump_to_file() """ @@ -922,9 +923,7 @@ class Library(object): # support for higher orders are included in openmc.mgxs order = 0 - # Build storage for our XSdata objects - xsdatas = [] - + # Create the xsdata object and add it to the mgxs_file for i, domain in enumerate(self.domains): if self.by_nuclide: nuclides = list(domain.get_all_nuclides().keys()) @@ -943,10 +942,7 @@ class Library(object): xs_type=xs_type, xs_id=xs_ids[i], order=order) - xsdatas.append(xsdata) - - # Add XSdatas to file - mgxs_file.add_xsdatas(xsdatas) + mgxs_file.add_xsdata(xsdata) return mgxs_file @@ -977,7 +973,7 @@ class Library(object): See also -------- - Library.create_mg_library(...) + Library.create_mg_library() """ diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index 7a2c0e7b74..408175f43b 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -367,7 +367,7 @@ class XSdata(object): check_type('energy_groups', energy_groups, openmc.mgxs.EnergyGroups) if energy_group.group_edges is None: - msg = 'Unable to assign an EnergyGroups object ' + \ + msg = 'Unable to assign an EnergyGroups object ' \ 'with uninitialized group edges' raise ValueError(msg) self._energy_groups = energy_groups @@ -518,7 +518,10 @@ class XSdata(object): # Convert to a numpy array so we can easily get the shape for # checking npchi = np.asarray(chi) - check_value('chi shape', npchi.shape, [self.vector_shape]) + # Check the shape + if npchi.shape != self.vector_shape: + msg = 'Provided chi iterable does not have the expected shape.' + raise ValueError(msg) self._chi = npchi @@ -605,6 +608,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('total', total, (openmc.mgxs.TotalXS, @@ -636,6 +644,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('absorption', absorption, openmc.mgxs.AbsorptionXS) @@ -667,6 +680,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('fission', fission, openmc.mgxs.FissionXS) @@ -699,6 +717,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ # The NuFissionXS class does not have the capability to produce @@ -740,6 +763,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('k_fission', k_fission, openmc.mgxs.KappaFissionXS) @@ -770,6 +798,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ if self._use_chi is not None: @@ -810,6 +843,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('scatter', scatter, openmc.mgxs.ScatterMatrixXS) @@ -851,6 +889,11 @@ class XSdata(object): Provide the macro or micro cross section in units of cm^-1 or barns. Defaults to 'macro'. + See also + -------- + openmc.mgxs.Library.create_mg_library() + openmc.mgxs.Library.get_xsdata + """ check_type('nuscatter', nuscatter, openmc.mgxs.NuScatterMatrixXS) diff --git a/src/summary.F90 b/src/summary.F90 index 9defcc92fd..aabf6c22b2 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -118,7 +118,7 @@ contains real(8), allocatable :: awrs(:) integer, allocatable :: zaids(:) - ! Use H5LT interface to write useful data from nuclide objects + ! Write useful data from nuclide objects nuclide_group = create_group(file_id, "nuclides") call write_dataset(nuclide_group, "n_nuclides_total", n_nuclides_total)