From f622300b7fc3c9f991aace1b13ac2336ec53a59c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 08:29:36 -0500 Subject: [PATCH 1/8] Various improvements/fixes to Python API. Also fix MPI F08 binding issue. --- openmc/filter.py | 3 +- openmc/material.py | 35 +- openmc/plots.py | 4 +- openmc/surface.py | 588 ++++++++++-------- src/simulation.F90 | 2 +- tests/test_asymmetric_lattice/inputs_true.dat | 2 +- tests/test_distribmat/inputs_true.dat | 2 +- tests/test_iso_in_lab/inputs_true.dat | 2 +- tests/test_mg_basic/inputs_true.dat | 2 +- tests/test_mg_max_order/inputs_true.dat | 2 +- tests/test_mg_nuclide/inputs_true.dat | 2 +- tests/test_mg_tallies/inputs_true.dat | 2 +- .../inputs_true.dat | 2 +- .../inputs_true.dat | 2 +- tests/test_mgxs_library_hdf5/inputs_true.dat | 2 +- .../inputs_true.dat | 2 +- .../inputs_true.dat | 2 +- tests/test_tallies/inputs_true.dat | 2 +- tests/test_tally_aggregation/inputs_true.dat | 2 +- tests/test_tally_arithmetic/inputs_true.dat | 2 +- tests/test_tally_slice_merge/inputs_true.dat | 2 +- 21 files changed, 365 insertions(+), 299 deletions(-) diff --git a/openmc/filter.py b/openmc/filter.py index 249bdcc029..b0e59874b4 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -27,7 +27,8 @@ class Filter(object): type : str The type of the tally filter. Acceptable values are "universe", "material", "cell", "cellborn", "surface", "mesh", "energy", - "energyout", and "distribcell". + "energyout", "distribcell", "mu", "polar", "azimuthal", and + "delayedgroup". bins : Integral or Iterable of Integral or Iterable of Real The bins for the filter. This takes on different meaning for different filters. See the OpenMC online documentation for more details. diff --git a/openmc/material.py b/openmc/material.py index 2c04a9ecf2..16af82439b 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -25,9 +25,6 @@ def reset_auto_material_id(): DENSITY_UNITS = ['g/cm3', 'g/cc', 'kg/cm3', 'atom/b-cm', 'atom/cm3', 'sum', 'macro'] -# Constant for density when not needed -NO_DENSITY = 99999. - class Material(object): """A material composed of a collection of nuclides/elements that can be @@ -141,9 +138,9 @@ class Material(object): string += '{0: <16}\n'.format('\tElements') for element in self._elements: - percent = self._nuclides[element][1] - percent_type = self._nuclides[element][2] - string += '{0: >16}'.format('\t{0}'.format(element)) + percent = self._elements[element][1] + percent_type = self._elements[element][2] + string += '{0: <16}'.format('\t{0}'.format(element)) string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type) return string @@ -218,13 +215,13 @@ class Material(object): else: self._name = '' - def set_density(self, units, density=NO_DENSITY): + def set_density(self, units, density=None): """Set the density of the material Parameters ---------- - units : str - Physical units of density + units : {'g/cm3', 'g/cc', 'km/cm3', 'atom/b-cm', 'atom/cm3', 'sum', 'macro'} + Physical units of density. density : float, optional Value of the density. Must be specified unless units is given as 'sum'. @@ -235,8 +232,8 @@ class Material(object): density, Real) check_value('density units', units, DENSITY_UNITS) - if density == NO_DENSITY and units is not 'sum': - msg = 'Unable to set the density Material ID="{0}" ' \ + if density is None and units is not 'sum': + msg = 'Unable to set the density for Material ID="{0}" ' \ 'because a density must be set when not using ' \ 'sum unit'.format(self._id) raise ValueError(msg) @@ -274,7 +271,7 @@ class Material(object): Nuclide to add percent : float Atom or weight percent - percent_type : str + percent_type : {'ao', 'wo'} 'ao' for atom percent and 'wo' for weight percent """ @@ -394,7 +391,7 @@ class Material(object): Element to add percent : float Atom or weight percent - percent_type : str + percent_type : {'ao', 'wo'} 'ao' for atom percent and 'wo' for weight percent """ @@ -420,7 +417,10 @@ class Material(object): raise ValueError(msg) # Copy this Element to separate it from same Element in other Materials - element = deepcopy(element) + if isinstance(element, openmc.Element): + element = deepcopy(element) + else: + element = openmc.Element(element) self._elements[element._name] = (element, percent, percent_type) @@ -498,7 +498,7 @@ class Material(object): xml_element.set("name", nuclide[0]._name) if not distrib: - if nuclide[2] is 'ao': + if nuclide[2] == 'ao': xml_element.set("ao", str(nuclide[1])) else: xml_element.set("wo", str(nuclide[1])) @@ -525,11 +525,14 @@ class Material(object): xml_element.set("name", str(element[0]._name)) if not distrib: - if element[2] is 'ao': + if element[2] == 'ao': xml_element.set("ao", str(element[1])) else: xml_element.set("wo", str(element[1])) + if element[0].xs is not None: + xml_element.set("xs", element[0].xs) + if not element[0].scattering is None: xml_element.set("scattering", element[0].scattering) diff --git a/openmc/plots.py b/openmc/plots.py index 6e78995f4d..5e7c47743e 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -125,7 +125,7 @@ class Plot(object): return self._background @property - def mask_componenets(self): + def mask_components(self): return self._mask_components @property @@ -227,7 +227,7 @@ class Plot(object): self._col_spec = col_spec - @mask_componenets.setter + @mask_components.setter def mask_components(self, mask_components): cv.check_type('plot mask_components', mask_components, Iterable, Integral) for component in mask_components: diff --git a/openmc/surface.py b/openmc/surface.py index 5c8b208564..c6f3f2cd0d 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -23,8 +23,7 @@ def reset_auto_surface_id(): class Surface(object): - """A two-dimensional surface that can be used define regions of space with an - associated boundary condition. + """A two-dimensional surface with an associated boundary condition. Parameters ---------- @@ -56,7 +55,6 @@ class Surface(object): """ def __init__(self, surface_id=None, boundary_type='transmission', name=''): - # Initialize class attributes self.id = surface_id self.name = name self._type = '' @@ -173,7 +171,8 @@ class Surface(object): element.set("name", str(self._name)) element.set("type", self._type) - element.set("boundary", self._boundary_type) + if self.boundary_type != 'transmission': + element.set("boundary", self.boundary_type) element.set("coeffs", ' '.join([str(self._coeffs.setdefault(key, 0.0)) for key in self._coeff_keys])) @@ -185,22 +184,22 @@ class Plane(Surface): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - A : float - The 'A' parameter for the plane - B : float - The 'B' parameter for the plane - C : float - The 'C' parameter for the plane - D : float - The 'D' parameter for the plane - name : str + A : float, optional + The 'A' parameter for the plane. Defaults to 1. + B : float, optional + The 'B' parameter for the plane. Defaults to 0. + C : float, optional + The 'C' parameter for the plane. Defaults to 0. + D : float, optional + The 'D' parameter for the plane. Defaults to 0. + name : str, optional Name of the plane. If not specified, the name will be the empty string. Attributes @@ -213,32 +212,30 @@ class Plane(Surface): The 'C' parameter for the plane d : float The 'D' parameter for the plane + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - A=None, B=None, C=None, D=None, name=''): - # Initialize Plane class attributes + A=1., B=0., C=0., D=0., name=''): super(Plane, self).__init__(surface_id, boundary_type, name=name) self._type = 'plane' self._coeff_keys = ['A', 'B', 'C', 'D'] - self._coeffs['A'] = 1. - self._coeffs['B'] = 0. - self._coeffs['C'] = 0. - self._coeffs['D'] = 0. - - if A is not None: - self.a = A - - if B is not None: - self.b = B - - if C is not None: - self.c = C - - if D is not None: - self.d = D + self.a = A + self.b = B + self.c = C + self.d = D @property def a(self): @@ -282,36 +279,43 @@ class XPlane(Plane): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - Location of the plane - name : str + x0 : float, optional + Location of the plane. Defaults to 0. + name : str, optional Name of the plane. If not specified, the name will be the empty string. Attributes ---------- x0 : float Location of the plane + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, name=''): - # Initialize XPlane class attributes + x0=0., name=''): super(XPlane, self).__init__(surface_id, boundary_type, name=name) self._type = 'x-plane' self._coeff_keys = ['x0'] - self._coeffs['x0'] = 0. - - if x0 is not None: - self.x0 = x0 + self.x0 = x0 @property def x0(self): @@ -359,36 +363,44 @@ class YPlane(Plane): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - y0 : float + y0 : float, optional Location of the plane - name : str + name : str, optional Name of the plane. If not specified, the name will be the empty string. Attributes ---------- y0 : float Location of the plane + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - y0=None, name=''): + y0=0., name=''): # Initialize YPlane class attributes super(YPlane, self).__init__(surface_id, boundary_type, name=name) self._type = 'y-plane' self._coeff_keys = ['y0'] - self._coeffs['y0'] = 0. - - if y0 is not None: - self.y0 = y0 + self.y0 = y0 @property def y0(self): @@ -436,36 +448,44 @@ class ZPlane(Plane): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - z0 : float - Location of the plane - name : str + z0 : float, optional + Location of the plane. Defaults to 0. + name : str, optional Name of the plane. If not specified, the name will be the empty string. Attributes ---------- z0 : float Location of the plane + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - z0=None, name=''): + z0=0., name=''): # Initialize ZPlane class attributes super(ZPlane, self).__init__(surface_id, boundary_type, name=name) self._type = 'z-plane' self._coeff_keys = ['z0'] - self._coeffs['z0'] = 0. - - if z0 is not None: - self.z0 = z0 + self.z0 = z0 @property def z0(self): @@ -513,16 +533,16 @@ class Cylinder(Surface): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - R : float - Radius of the cylinder - name : str + R : float, optional + Radius of the cylinder. Defaults to 1. + name : str, optional Name of the cylinder. If not specified, the name will be the empty string. @@ -530,21 +550,28 @@ class Cylinder(Surface): ---------- r : float Radius of the cylinder + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ __metaclass__ = ABCMeta def __init__(self, surface_id=None, boundary_type='transmission', - R=None, name=''): - # Initialize Cylinder class attributes + R=1., name=''): super(Cylinder, self).__init__(surface_id, boundary_type, name=name) self._coeff_keys = ['R'] - self._coeffs['R'] = 1. - - if R is not None: - self.r = R + self.r = R @property def r(self): @@ -557,25 +584,25 @@ class Cylinder(Surface): class XCylinder(Cylinder): - """An infinite cylinder whose length is parallel to the x-axis. This is a - quadratic surface of the form :math:`(y - y_0)^2 + (z - z_0)^2 = R^2`. + """An infinite cylinder whose length is parallel to the x-axis of the form + :math:`(y - y_0)^2 + (z - z_0)^2 = R^2`. Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - y0 : float - y-coordinate of the center of the cylinder - z0 : float - z-coordinate of the center of the cylinder - R : float - Radius of the cylinder - name : str + y0 : float, optional + y-coordinate of the center of the cylinder. Defaults to 0. + z0 : float, optional + z-coordinate of the center of the cylinder. Defaults to 0. + R : float, optional + Radius of the cylinder. Defaults to 0. + name : str, optional Name of the cylinder. If not specified, the name will be the empty string. @@ -585,24 +612,28 @@ class XCylinder(Cylinder): y-coordinate of the center of the cylinder z0 : float z-coordinate of the center of the cylinder + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - y0=None, z0=None, R=None, name=''): - # Initialize XCylinder class attributes + y0=0., z0=0., R=1., name=''): super(XCylinder, self).__init__(surface_id, boundary_type, R, name=name) self._type = 'x-cylinder' self._coeff_keys = ['y0', 'z0', 'R'] - self._coeffs['y0'] = 0. - self._coeffs['z0'] = 0. - - if y0 is not None: - self.y0 = y0 - - if z0 is not None: - self.z0 = z0 + self.y0 = y0 + self.z0 = z0 @property def y0(self): @@ -656,25 +687,25 @@ class XCylinder(Cylinder): class YCylinder(Cylinder): - """An infinite cylinder whose length is parallel to the y-axis. This is a - quadratic surface of the form :math:`(x - x_0)^2 + (z - z_0)^2 = R^2`. + """An infinite cylinder whose length is parallel to the y-axis of the form + :math:`(x - x_0)^2 + (z - z_0)^2 = R^2`. Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the center of the cylinder - z0 : float - z-coordinate of the center of the cylinder - R : float - Radius of the cylinder - name : str + x0 : float, optional + x-coordinate of the center of the cylinder. Defaults to 0. + z0 : float, optional + z-coordinate of the center of the cylinder. Defaults to 0. + R : float, optional + Radius of the cylinder. Defaults to 1. + name : str, optional Name of the cylinder. If not specified, the name will be the empty string. @@ -684,24 +715,28 @@ class YCylinder(Cylinder): x-coordinate of the center of the cylinder z0 : float z-coordinate of the center of the cylinder + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, z0=None, R=None, name=''): - # Initialize YCylinder class attributes + x0=0., z0=0., R=1., name=''): super(YCylinder, self).__init__(surface_id, boundary_type, R, name=name) self._type = 'y-cylinder' self._coeff_keys = ['x0', 'z0', 'R'] - self._coeffs['x0'] = 0. - self._coeffs['z0'] = 0. - - if x0 is not None: - self.x0 = x0 - - if z0 is not None: - self.z0 = z0 + self.x0 = x0 + self.z0 = z0 @property def x0(self): @@ -755,25 +790,25 @@ class YCylinder(Cylinder): class ZCylinder(Cylinder): - """An infinite cylinder whose length is parallel to the z-axis. This is a - quadratic surface of the form :math:`(x - x_0)^2 + (y - y_0)^2 = R^2`. + """An infinite cylinder whose length is parallel to the z-axis of the form + :math:`(x - x_0)^2 + (y - y_0)^2 = R^2`. Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the center of the cylinder - y0 : float - y-coordinate of the center of the cylinder - R : float - Radius of the cylinder - name : str + x0 : float, optional + x-coordinate of the center of the cylinder. Defaults to 0. + y0 : float, optional + y-coordinate of the center of the cylinder. Defaults to 0. + R : float, optional + Radius of the cylinder. Defaults to 1. + name : str, optional Name of the cylinder. If not specified, the name will be the empty string. @@ -783,24 +818,28 @@ class ZCylinder(Cylinder): x-coordinate of the center of the cylinder y0 : float y-coordinate of the center of the cylinder + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, R=None, name=''): - # Initialize ZCylinder class attributes + x0=0., y0=0., R=1., name=''): super(ZCylinder, self).__init__(surface_id, boundary_type, R, name=name) self._type = 'z-cylinder' self._coeff_keys = ['x0', 'y0', 'R'] - self._coeffs['x0'] = 0. - self._coeffs['y0'] = 0. - - if x0 is not None: - self.x0 = x0 - - if y0 is not None: - self.y0 = y0 + self.x0 = x0 + self.y0 = y0 @property def x0(self): @@ -858,22 +897,22 @@ class Sphere(Surface): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the center of the sphere - y0 : float - y-coordinate of the center of the sphere - z0 : float - z-coordinate of the center of the sphere - R : float - Radius of the sphere - name : str + x0 : float, optional + x-coordinate of the center of the sphere. Defaults to 0. + y0 : float, optional + y-coordinate of the center of the sphere. Defaults to 0. + z0 : float, optional + z-coordinate of the center of the sphere. Defaults to 0. + R : float, optional + Radius of the sphere. Defaults to 1. + name : str, optional Name of the sphere. If not specified, the name will be the empty string. Attributes @@ -886,32 +925,30 @@ class Sphere(Surface): z-coordinate of the center of the sphere R : float Radius of the sphere + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, z0=None, R=None, name=''): - # Initialize Sphere class attributes + x0=0., y0=0., z0=0., R=1., name=''): super(Sphere, self).__init__(surface_id, boundary_type, name=name) self._type = 'sphere' self._coeff_keys = ['x0', 'y0', 'z0', 'R'] - self._coeffs['x0'] = 0. - self._coeffs['y0'] = 0. - self._coeffs['z0'] = 0. - self._coeffs['R'] = 1. - - if x0 is not None: - self.x0 = x0 - - if y0 is not None: - self.y0 = y0 - - if z0 is not None: - self.z0 = z0 - - if R is not None: - self.r = R + self.x0 = x0 + self.y0 = y0 + self.z0 = z0 + self.r = R @property def x0(self): @@ -988,21 +1025,21 @@ class Cone(Surface): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the apex + x0 : float, optional + x-coordinate of the apex. Defaults to 0. y0 : float - y-coordinate of the apex + y-coordinate of the apex. Defaults to 0. z0 : float - z-coordinate of the apex + z-coordinate of the apex. Defaults to 0. R2 : float - Parameter related to the aperature + Parameter related to the aperature. Defaults to 1. name : str Name of the cone. If not specified, the name will be the empty string. @@ -1016,33 +1053,31 @@ class Cone(Surface): z-coordinate of the apex R2 : float Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ __metaclass__ = ABCMeta def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, z0=None, R2=None, name=''): - # Initialize Cone class attributes + x0=0., y0=0., z0=0., R2=1., name=''): super(Cone, self).__init__(surface_id, boundary_type, name=name) self._coeff_keys = ['x0', 'y0', 'z0', 'R2'] - self._coeffs['x0'] = 0. - self._coeffs['y0'] = 0. - self._coeffs['z0'] = 0. - self._coeffs['R2'] = 1. - - if x0 is not None: - self.x0 = x0 - - if y0 is not None: - self.y0 = y0 - - if z0 is not None: - self.z0 = z0 - - if R2 is not None: - self.r2 = R2 + self.x0 = x0 + self.y0 = y0 + self.z0 = z0 + self.r2 = R2 @property def x0(self): @@ -1087,22 +1122,22 @@ class XCone(Cone): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the apex - y0 : float - y-coordinate of the apex - z0 : float - z-coordinate of the apex - R2 : float - Parameter related to the aperature - name : str + x0 : float, optional + x-coordinate of the apex. Defaults to 0. + y0 : float, optional + y-coordinate of the apex. Defaults to 0. + z0 : float, optional + z-coordinate of the apex. Defaults to 0. + R2 : float, optional + Parameter related to the aperature. Defaults to 1. + name : str, optional Name of the cone. If not specified, the name will be the empty string. Attributes @@ -1115,12 +1150,22 @@ class XCone(Cone): z-coordinate of the apex R2 : float Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, z0=None, R2=None, name=''): - # Initialize XCone class attributes + x0=0., y0=0., z0=0., R2=1., name=''): super(XCone, self).__init__(surface_id, boundary_type, x0, y0, z0, R2, name=name) @@ -1133,22 +1178,22 @@ class YCone(Cone): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the apex - y0 : float - y-coordinate of the apex - z0 : float - z-coordinate of the apex - R2 : float - Parameter related to the aperature - name : str + x0 : float, optional + x-coordinate of the apex. Defaults to 0. + y0 : float, optional + y-coordinate of the apex. Defaults to 0. + z0 : float, optional + z-coordinate of the apex. Defaults to 0. + R2 : float, optional + Parameter related to the aperature. Defaults to 1. + name : str, optional Name of the cone. If not specified, the name will be the empty string. Attributes @@ -1161,12 +1206,22 @@ class YCone(Cone): z-coordinate of the apex R2 : float Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, z0=None, R2=None, name=''): - # Initialize YCone class attributes + x0=0., y0=0., z0=0., R2=1., name=''): super(YCone, self).__init__(surface_id, boundary_type, x0, y0, z0, R2, name=name) @@ -1179,22 +1234,22 @@ class ZCone(Cone): Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - x0 : float - x-coordinate of the apex - y0 : float - y-coordinate of the apex - z0 : float - z-coordinate of the apex - R2 : float - Parameter related to the aperature - name : str + x0 : float, optional + x-coordinate of the apex. Defaults to 0. + y0 : float, optional + y-coordinate of the apex. Defaults to 0. + z0 : float, optional + z-coordinate of the apex. Defaults to 0. + R2 : float, optional + Parameter related to the aperature. Defaults to 1. + name : str, optional Name of the cone. If not specified, the name will be the empty string. Attributes @@ -1207,12 +1262,22 @@ class ZCone(Cone): z-coordinate of the apex R2 : float Parameter related to the aperature + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - x0=None, y0=None, z0=None, R2=None, name=''): - # Initialize ZCone class attributes + x0=0., y0=0., z0=0., R2=1., name=''): super(ZCone, self).__init__(surface_id, boundary_type, x0, y0, z0, R2, name=name) @@ -1220,61 +1285,58 @@ class ZCone(Cone): class Quadric(Surface): - """A sphere of the form :math:`Ax^2 + By^2 + Cz^2 + Dxy + Eyz + Fxz + Gx + Hy + - Jz + K`. + """A surface of the form :math:`Ax^2 + By^2 + Cz^2 + Dxy + Eyz + Fxz + Gx + Hy + + Jz + K = 0`. Parameters ---------- - surface_id : int + surface_id : int, optional Unique identifier for the surface. If not specified, an identifier will automatically be assigned. - boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional Boundary condition that defines the behavior for particles hitting the surface. Defaults to transmissive boundary condition where particles freely pass through the surface. - a, b, c, d, e, f, g, h, j, k : float - coefficients for the surface - name : str + a, b, c, d, e, f, g, h, j, k : float, optional + coefficients for the surface. All default to 0. + name : str, optional Name of the sphere. If not specified, the name will be the empty string. Attributes ---------- a, b, c, d, e, f, g, h, j, k : float coefficients for the surface + boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} + Boundary condition that defines the behavior for particles hitting the + surface. + coeffs : dict + Dictionary of surface coefficients + id : int + Unique identifier for the surface + name : str + Name of the surface + type : str + Type of the surface, e.g. 'x-plane' """ def __init__(self, surface_id=None, boundary_type='transmission', - a=None, b=None, c=None, d=None, e=None, f=None, g=None, - h=None, j=None, k=None, name=''): - # Initialize Quadric class attributes + a=0., b=0., c=0., d=0., e=0., f=0., g=0., + h=0., j=0., k=0., name=''): super(Quadric, self).__init__(surface_id, boundary_type, name=name) self._type = 'quadric' self._coeff_keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k'] - for key in self._coeff_keys: - self._coeffs[key] = 0. - - if a is not None: - self.a = a - if b is not None: - self.b = b - if c is not None: - self.c = c - if d is not None: - self.d = d - if e is not None: - self.e = e - if f is not None: - self.f = f - if g is not None: - self.g = g - if h is not None: - self.h = h - if j is not None: - self.j = j - if k is not None: - self.k = k + self.a = a + self.b = b + self.c = c + self.d = d + self.e = e + self.f = f + self.g = g + self.h = h + self.j = j + self.k = k @property def a(self): diff --git a/src/simulation.F90 b/src/simulation.F90 index 41a28741c3..b762979d73 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -1,7 +1,7 @@ module simulation #ifdef MPI - use mpi + use message_passing #endif use cmfd_execute, only: cmfd_init_batch, execute_cmfd diff --git a/tests/test_asymmetric_lattice/inputs_true.dat b/tests/test_asymmetric_lattice/inputs_true.dat index e3b00b185c..f40e661b33 100644 --- a/tests/test_asymmetric_lattice/inputs_true.dat +++ b/tests/test_asymmetric_lattice/inputs_true.dat @@ -1 +1 @@ -b9b4222c4beea80fe6083590f6b785303d174972d80671fb661bac8e030db6f4a61648240cfad6162799361fc0e08a23c61d31aff844d978528d6dad5b5fbc63 \ No newline at end of file +9b859eb5501c05b6a652d299bd0cadc0a924ffae31117babbdc9f7f8ca87689322c275818eb0dde0ff5fa78317d8d8f1585b18dcc772e3ff4ed499de8a491dc3 \ No newline at end of file diff --git a/tests/test_distribmat/inputs_true.dat b/tests/test_distribmat/inputs_true.dat index fddab0a60d..9c8a86bfa7 100644 --- a/tests/test_distribmat/inputs_true.dat +++ b/tests/test_distribmat/inputs_true.dat @@ -1 +1 @@ -401b8be1b296db7f21ccae089c7ac480044d953b7264ca0ae8e34bb79e24cbb57195bcb568deda6f2f7e07366bbfac408a92306351b9169edd04499723707e1b \ No newline at end of file +96c54eb4f1da175445bf2187449ee32c9ff435d8c60e9421a4a16497aae9f233e3e494f531892dd55f6ac1a06e0240799503ff19e14e2436a0b0f0d83ba56cb8 \ No newline at end of file diff --git a/tests/test_iso_in_lab/inputs_true.dat b/tests/test_iso_in_lab/inputs_true.dat index 9a21b06f1f..bd722c9f67 100644 --- a/tests/test_iso_in_lab/inputs_true.dat +++ b/tests/test_iso_in_lab/inputs_true.dat @@ -1 +1 @@ -e0409e0660d58857a6a96ff5cb539ccc41c82f0e443e8081ee00bbee7b6c81b0ad43c870950ae37d4a18c329067b09479a27aa171c3a3f5771f53b384496fe61 \ No newline at end of file +85faac9b8c725ec9242ebc3793b70dcd1c8e58aeb4296345aefd8031304263bd66eaad0c6f1c61a1c644b73f397699856ab3d76d2b397295176650b4069acc9e \ No newline at end of file diff --git a/tests/test_mg_basic/inputs_true.dat b/tests/test_mg_basic/inputs_true.dat index fdbdb1c968..3f83de7600 100644 --- a/tests/test_mg_basic/inputs_true.dat +++ b/tests/test_mg_basic/inputs_true.dat @@ -1 +1 @@ -04b4a5099f0097bbe02983c67dea691d0d0d4ece7fb7c264b9b2c29955baa9e870b6fa999480da08ead1e5a0c078ae33ce1b0a5c8594ad465aedf9bf3933e104 \ No newline at end of file +2fdba76bad058eec6e43657692ef759de79c934076067d4ec5c9f2bdb131877e001f67e16b16bb14889e5e0a1ba84c780979b9d6772573aa6f82d979774c2af8 \ No newline at end of file diff --git a/tests/test_mg_max_order/inputs_true.dat b/tests/test_mg_max_order/inputs_true.dat index 1ad336e195..913f8200fb 100644 --- a/tests/test_mg_max_order/inputs_true.dat +++ b/tests/test_mg_max_order/inputs_true.dat @@ -1 +1 @@ -abe20c626d613e73ccb1a3f8468ad1b9aecca528afa9e8131a411d754eb86b8ab64a6fb1fdc9c0b8b8158ff7c82f548de5912041bf035aa5a2d4532cfe0c9510 \ No newline at end of file +7f7465abaf559b3ef56cb6b0f28050c12f392f55db33dc5d2cefc14b92beb2c9068834c05273e51323d3516643e8a385e4c177a7a471678c961808d19055a30f \ No newline at end of file diff --git a/tests/test_mg_nuclide/inputs_true.dat b/tests/test_mg_nuclide/inputs_true.dat index eb643bbaf4..32a7773c1e 100644 --- a/tests/test_mg_nuclide/inputs_true.dat +++ b/tests/test_mg_nuclide/inputs_true.dat @@ -1 +1 @@ -c9f9e7211bfb2af58130bedfd64592d093b7bfa424953eba433ecf08940595a96b8de7a892f12d1ab465cebd8e5dd784114c1b1299b534ed329df92752c9ed1f \ No newline at end of file +825dee3ca35d48788f1a4d5364789bbd83b36e33af9a990da758dd73c3bfcbee14bce2a41e6c80e0147f45575e59078653c8dfa8590cd361c09f19c26dc8c88e \ No newline at end of file diff --git a/tests/test_mg_tallies/inputs_true.dat b/tests/test_mg_tallies/inputs_true.dat index 304d2e8880..41bbd2136e 100644 --- a/tests/test_mg_tallies/inputs_true.dat +++ b/tests/test_mg_tallies/inputs_true.dat @@ -1 +1 @@ -ca8490e0e4549fed727ddc75b6d92cfe5162e11b905218a0afaa3ce2ee0763e2ff38074de27aaa678818624f49c5823650475dfa8f66f502a98fc03145399c0d \ No newline at end of file +6c437c3f9281c52a80a9b166971aa0f5db7ff8b6cf65c79b6d7bf294fad30cc7044f6a665cd9059f8580441bcbb581f7152ff5bccbc21fbcc407847ea6fe3306 \ No newline at end of file diff --git a/tests/test_mgxs_library_condense/inputs_true.dat b/tests/test_mgxs_library_condense/inputs_true.dat index b94f64122d..51fc95c60c 100644 --- a/tests/test_mgxs_library_condense/inputs_true.dat +++ b/tests/test_mgxs_library_condense/inputs_true.dat @@ -1 +1 @@ -53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc \ No newline at end of file +3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c \ No newline at end of file diff --git a/tests/test_mgxs_library_distribcell/inputs_true.dat b/tests/test_mgxs_library_distribcell/inputs_true.dat index 04e56658f2..78ffa3faf0 100644 --- a/tests/test_mgxs_library_distribcell/inputs_true.dat +++ b/tests/test_mgxs_library_distribcell/inputs_true.dat @@ -1 +1 @@ -224a9e84e87c8a21385326d34ef27c046107d4a2ace6ee85d7a36142a3726e12532e2fc1a318ab707437e0b306a81c6d2b80c531d4c3210d4162242e6265ba70 \ No newline at end of file +2c078f650fed5fc241f42b2d7404fb7fae59d782102fad66b4cd2c8a4b1f266d64e8ce1ec0556117c2a2b1fe49aa583f340dc43df3ddc9320557aa97bb554c05 \ No newline at end of file diff --git a/tests/test_mgxs_library_hdf5/inputs_true.dat b/tests/test_mgxs_library_hdf5/inputs_true.dat index b94f64122d..51fc95c60c 100644 --- a/tests/test_mgxs_library_hdf5/inputs_true.dat +++ b/tests/test_mgxs_library_hdf5/inputs_true.dat @@ -1 +1 @@ -53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc \ No newline at end of file +3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c \ No newline at end of file diff --git a/tests/test_mgxs_library_no_nuclides/inputs_true.dat b/tests/test_mgxs_library_no_nuclides/inputs_true.dat index b94f64122d..51fc95c60c 100644 --- a/tests/test_mgxs_library_no_nuclides/inputs_true.dat +++ b/tests/test_mgxs_library_no_nuclides/inputs_true.dat @@ -1 +1 @@ -53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc \ No newline at end of file +3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c \ No newline at end of file diff --git a/tests/test_mgxs_library_nuclides/inputs_true.dat b/tests/test_mgxs_library_nuclides/inputs_true.dat index f87bc242dc..9436f03a03 100644 --- a/tests/test_mgxs_library_nuclides/inputs_true.dat +++ b/tests/test_mgxs_library_nuclides/inputs_true.dat @@ -1 +1 @@ -c6a2a1c707bc723fd38bafd18efcfb22beaac0bd5953d7524ced1d47866cc1e1ee4152e39234d32a06fe43aff446fb12f8c5b62a44075607f274778b49110762 \ No newline at end of file +b035f783fa75ada619b0a58675913e318fef94e519c85cae6982f650d7655cb130f625572fde2058e005b490359180cb9d1e1095f5d35d41c9a0f8ff6e0dc3c1 \ No newline at end of file diff --git a/tests/test_tallies/inputs_true.dat b/tests/test_tallies/inputs_true.dat index 657a9e77da..be789fc838 100644 --- a/tests/test_tallies/inputs_true.dat +++ b/tests/test_tallies/inputs_true.dat @@ -1 +1 @@ -5e168146d91b7b5fadecb80a32df9edc906718fb2d70b68b4c18dbed0641739251a1c16177c9f4d47516dfd528ec930879534292ff0eb82af89eca2c3fa4a3e0 \ No newline at end of file +0597eff3fddbc45a09b5b324c9704e540b694b07c136f2040426fdcfe5ec544f036073e4afa34a5fb0fbd721a4c0a609b9b68bf17ce4ec78302023b46b71930c \ No newline at end of file diff --git a/tests/test_tally_aggregation/inputs_true.dat b/tests/test_tally_aggregation/inputs_true.dat index 7b4276f59e..055ac76fd4 100644 --- a/tests/test_tally_aggregation/inputs_true.dat +++ b/tests/test_tally_aggregation/inputs_true.dat @@ -1 +1 @@ -530a5e969901e153531f74aed46246b1e8783a0e2f347e472f7554c9970152f45d85499f17d7df9c35c74fed6f78d449aa70bf0c1f8947cd34d3a829483a0055 \ No newline at end of file +f819f1b3564ca1df1e235f120f4bd65003cd80935fa8261f0a5982b7e7ec5b2e7497716673c142fab99f3fb26c174ac7a12e145b9a6f2caf707d2a07702f6eb2 \ No newline at end of file diff --git a/tests/test_tally_arithmetic/inputs_true.dat b/tests/test_tally_arithmetic/inputs_true.dat index 1b6046f1ae..d7b854a51d 100644 --- a/tests/test_tally_arithmetic/inputs_true.dat +++ b/tests/test_tally_arithmetic/inputs_true.dat @@ -1 +1 @@ -57384883e37964076aa82c19fa542434331cdb09735d710485b5aa0ca3445d543729e40cb9c7b6a70e7101ef186923eb1ff6315c73b01ff257052838add68fc7 \ No newline at end of file +bb7e730630f7bb4694a27fd77c3c0171f70c78df2681acc26b0ef88bcff367523b11335f487b46269325adbcee7faeb756484af64055c3c91b0103f7ed962053 \ No newline at end of file diff --git a/tests/test_tally_slice_merge/inputs_true.dat b/tests/test_tally_slice_merge/inputs_true.dat index 29f0f1d827..be2ec63dc5 100644 --- a/tests/test_tally_slice_merge/inputs_true.dat +++ b/tests/test_tally_slice_merge/inputs_true.dat @@ -1 +1 @@ -8d1ab9e4add51b99045e990ac9c3dad9447e9720d811bc430d4bfdd7c2c035424bcb7750e4a4d0ec0460ea1ef4be46ac58372ed01d55f5d8cfeebbce75559066 \ No newline at end of file +bb4ae3b75445846bd5db05a06cc20e7589990154ccef8302f276cd8356630d585c513ebb6bfa99f9fc93dd2d30c42bfbb67dd3454134f4c9fcb3bac128d1f1c5 \ No newline at end of file From cccca4062aea16d8894a2257173ce33fad0a25d3 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 09:04:52 -0500 Subject: [PATCH 2/8] Goodbye openmc.Executor. Hello openmc.run and openmc.plot. --- openmc/executor.py | 177 ++++++++---------- tests/test_plot/test_plot.py | 5 +- .../test_statepoint_restart.py | 17 +- tests/testing_harness.py | 25 +-- 4 files changed, 92 insertions(+), 132 deletions(-) diff --git a/openmc/executor.py b/openmc/executor.py index 214517d6ed..89bcc2e10d 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -1,131 +1,100 @@ from __future__ import print_function import subprocess from numbers import Integral -import os import sys -from openmc.checkvalue import check_type - if sys.version_info[0] >= 3: basestring = str -class Executor(object): - """Control execution of OpenMC +def _run(command, output, cwd): + # Launch a subprocess + p = subprocess.Popen(command, shell=True, cwd=cwd, stdout=subprocess.PIPE, + universal_newlines=True) - Attributes + # Capture and re-print OpenMC output in real-time + while True: + # If OpenMC is finished, break loop + line = p.stdout.readline() + if not line and p.poll() != None: + break + + # If user requested output, print to screen + if output: + print(line, end='') + + # Return the returncode (integer, zero if no problems encountered) + return p.returncode + + +def plot(output=True, openmc_exec='openmc', cwd='.'): + """Run OpenMC in plotting mode + + Parameters ---------- - working_directory : str - Path to working directory to run in + output : bool + Capture OpenMC output from standard out + openmc_exec : str + Path to OpenMC executable + cwd : str, optional + Path to working directory to run in. Defaults to the current working directory. """ - def __init__(self): - self._working_directory = '.' + return _run(openmc_exec + ' -p', output, cwd) - def _run_openmc(self, command, output): - # Launch a subprocess to run OpenMC - p = subprocess.Popen(command, shell=True, - cwd=self._working_directory, - stdout=subprocess.PIPE, - universal_newlines=True) - # Capture and re-print OpenMC output in real-time - while True: - # If OpenMC is finished, break loop - line = p.stdout.readline() - if not line and p.poll() != None: - break +def run(particles=None, threads=None, geometry_debug=False, + restart_file=None, tracks=False, mpi_procs=1, output=True, + openmc_exec='openmc', mpi_exec='mpiexec', cwd='.'): + """Run an OpenMC simulation. - # If user requested output, print to screen - if output: - print(line, end='') + Parameters + ---------- + particles : int, optional + Number of particles to simulate per generation. + threads : int, optional + Number of OpenMP threads. + geometry_debug : bool, optional + Turn on geometry debugging during simulation. Defaults to False. + restart_file : str, optional + Path to restart file to use + tracks : bool, optional + Write tracks for all particles. Defaults to False. + mpi_procs : int, optional + Number of MPI processes. + output : bool, optional + Capture OpenMC output from standard out. Defaults to True. + openmc_exec : str, optional + Path to OpenMC executable. Defaults to 'openmc'. + mpi_exec : str, optional + MPI execute command. Defaults to 'mpiexec'. + cwd : str, optional + Path to working directory to run in. Defaults to the current working directory. - # Return the returncode (integer, zero if no problems encountered) - return p.returncode + """ - @property - def working_directory(self): - return self._working_directory + post_args = ' ' + pre_args = '' - @working_directory.setter - def working_directory(self, working_directory): - check_type("Executor's working directory", working_directory, - basestring) - if not os.path.isdir(working_directory): - msg = 'Unable to set Executor\'s working directory to "{0}" ' \ - 'which does not exist'.format(working_directory) - raise ValueError(msg) + if isinstance(particles, Integral) and particles > 0: + post_args += '-n {0} '.format(particles) - self._working_directory = working_directory + if isinstance(threads, Integral) and threads > 0: + post_args += '-s {0} '.format(threads) - def plot_geometry(self, output=True, openmc_exec='openmc'): - """Run OpenMC in plotting mode""" + if geometry_debug: + post_args += '-g ' - return self._run_openmc(openmc_exec + ' -p', output) + if isinstance(restart_file, basestring): + post_args += '-r {0} '.format(restart_file) - def run_simulation(self, particles=None, threads=None, - geometry_debug=False, restart_file=None, - tracks=False, mpi_procs=1, output=True, - openmc_exec='openmc', mpi_exec=None): - """Run an OpenMC simulation. + if tracks: + post_args += '-t' - Parameters - ---------- - particles : int - Number of particles to simulate per generation - threads : int - Number of OpenMP threads - geometry_debug : bool - Turn on geometry debugging during simulation - restart_file : str - Path to restart file to use - tracks : bool - Write tracks for all particles - mpi_procs : int - Number of MPI processes - output : bool - Capture OpenMC output from standard out - openmc_exec : str - Path to OpenMC executable + if isinstance(mpi_procs, Integral) and mpi_procs > 1: + pre_args += '{} -n {} '.format(mpi_exec, mpi_procs) - """ + command = pre_args + openmc_exec + ' ' + post_args - post_args = ' ' - pre_args = '' - - if isinstance(particles, Integral) and particles > 0: - post_args += '-n {0} '.format(particles) - - if isinstance(threads, Integral) and threads > 0: - post_args += '-s {0} '.format(threads) - - if geometry_debug: - post_args += '-g ' - - if isinstance(restart_file, basestring): - post_args += '-r {0} '.format(restart_file) - - if tracks: - post_args += '-t' - - if isinstance(mpi_procs, Integral) and mpi_procs > 1: - np_present = True - else: - np_present = False - - if mpi_exec is not None and isinstance(mpi_exec, basestring): - mpi_exec_present = True - else: - mpi_exec_present = False - - if np_present or mpi_exec_present: - if mpi_exec_present: - pre_args += mpi_exec + ' ' - else: - pre_args += 'mpirun ' - pre_args += '-n {0} '.format(mpi_procs) - - command = pre_args + openmc_exec + ' ' + post_args - - return self._run_openmc(command, output) + return _run(command, output, cwd) diff --git a/tests/test_plot/test_plot.py b/tests/test_plot/test_plot.py index 015577d215..e40cef49c0 100644 --- a/tests/test_plot/test_plot.py +++ b/tests/test_plot/test_plot.py @@ -9,7 +9,7 @@ from testing_harness import TestHarness import h5py -from openmc import Executor +import openmc class PlotTestHarness(TestHarness): @@ -19,8 +19,7 @@ class PlotTestHarness(TestHarness): self._plot_names = plot_names def _run_openmc(self): - executor = Executor() - returncode = executor.plot_geometry(openmc_exec=self._opts.exe) + returncode = openmc.plot(openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self): diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py index c842689d99..d39bf7cd5f 100644 --- a/tests/test_statepoint_restart/test_statepoint_restart.py +++ b/tests/test_statepoint_restart/test_statepoint_restart.py @@ -5,8 +5,7 @@ import os import sys sys.path.insert(0, os.pardir) from testing_harness import TestHarness -from openmc.statepoint import StatePoint -from openmc.executor import Executor +import openmc class StatepointRestartTestHarness(TestHarness): @@ -50,17 +49,15 @@ class StatepointRestartTestHarness(TestHarness): statepoint = statepoint[0] # Run OpenMC - executor = Executor() - if self._opts.mpi_exec is not None: - returncode = executor.run_simulation(mpi_procs=self._opts.mpi_np, - restart_file=statepoint, - openmc_exec=self._opts.exe, - mpi_exec=self._opts.mpi_exec) + returncode = openmc.run(mpi_procs=self._opts.mpi_np, + restart_file=statepoint, + openmc_exec=self._opts.exe, + mpi_exec=self._opts.mpi_exec) else: - returncode = executor.run_simulation(openmc_exec=self._opts.exe, - restart_file=statepoint) + returncode = openmc.run(openmc_exec=self._opts.exe, + restart_file=statepoint) assert returncode == 0, 'OpenMC did not exit successfully.' diff --git a/tests/testing_harness.py b/tests/testing_harness.py index 7d6dbc914f..78e5553e8c 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -13,9 +13,7 @@ import numpy as np sys.path.insert(0, os.path.join(os.pardir, os.pardir)) from input_set import InputSet, MGInputSet -from openmc.statepoint import StatePoint -from openmc.executor import Executor -import openmc.particle_restart as pr +import openmc class TestHarness(object): @@ -63,15 +61,13 @@ class TestHarness(object): self._cleanup() def _run_openmc(self): - executor = Executor() - if self._opts.mpi_exec is not None: - returncode = executor.run_simulation(mpi_procs=self._opts.mpi_np, - openmc_exec=self._opts.exe, - mpi_exec=self._opts.mpi_exec) + returncode = openmc.run(mpi_procs=self._opts.mpi_np, + openmc_exec=self._opts.exe, + mpi_exec=self._opts.mpi_exec) else: - returncode = executor.run_simulation(openmc_exec=self._opts.exe) + returncode = openmc.run(openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' @@ -90,7 +86,7 @@ class TestHarness(object): """Digest info in the statepoint and return as a string.""" # Read the statepoint file. statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0] - sp = StatePoint(statepoint) + sp = openmc.StatePoint(statepoint) # Write out k-combined. outstr = 'k-combined:\n' @@ -158,7 +154,7 @@ class CMFDTestHarness(TestHarness): """Digest info in the statepoint and return as a string.""" # Read the statepoint file. statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0] - sp = StatePoint(statepoint) + sp = openmc.StatePoint(statepoint) # Write out the eigenvalue and tallies. outstr = super(CMFDTestHarness, self)._get_results() @@ -195,13 +191,12 @@ class ParticleRestartTestHarness(TestHarness): 'mpi_exec': self._opts.mpi_exec}) # Initial run - executor = Executor() - returncode = executor.run_simulation(**args) + returncode = openmc.run(**args) assert returncode == 0, 'OpenMC did not exit successfully.' # Run particle restart args.update({'restart_file': self._sp_name}) - returncode = executor.run_simulation(**args) + returncode = openmc.run(**args) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self): @@ -216,7 +211,7 @@ class ParticleRestartTestHarness(TestHarness): """Digest info in the statepoint and return as a string.""" # Read the particle restart file. particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0] - p = pr.Particle(particle) + p = openmc.Particle(particle) # Write out the properties. outstr = '' From 50a80693b5d4ac0fb1bc0e88a4c105338c35601e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 10:37:06 -0500 Subject: [PATCH 3/8] Rename main Python API classes to get rid of File. --- docs/source/_templates/myfunction.rst | 6 ++ docs/source/pythonapi/index.rst | 18 ++--- examples/python/basic/build-xml.py | 28 ++++---- examples/python/boxes/build-xml.py | 20 +++--- .../python/lattice/hexagonal/build-xml.py | 28 ++++---- examples/python/lattice/nested/build-xml.py | 34 ++++----- examples/python/lattice/simple/build-xml.py | 34 ++++----- examples/python/pincell/build-xml.py | 28 ++++---- .../python/pincell_multigroup/build-xml.py | 32 ++++----- examples/python/reflective/build-xml.py | 22 +++--- openmc/cmfd.py | 2 +- openmc/executor.py | 2 +- openmc/geometry.py | 71 ++++++------------- openmc/material.py | 9 ++- openmc/mgxs/library.py | 6 +- openmc/mgxs_library.py | 9 ++- openmc/plots.py | 5 +- openmc/settings.py | 2 +- openmc/tallies.py | 7 +- tests/input_set.py | 26 ++----- .../test_asymmetric_lattice.py | 10 ++- tests/test_distribmat/test_distribmat.py | 10 ++- tests/test_mg_max_order/test_mg_max_order.py | 2 +- tests/test_mg_nuclide/test_mg_nuclide.py | 2 +- tests/test_mg_tallies/test_mg_tallies.py | 2 +- .../test_mgxs_library_condense.py | 4 +- .../test_mgxs_library_distribcell.py | 4 +- .../test_mgxs_library_hdf5.py | 8 +-- .../test_mgxs_library_no_nuclides.py | 4 +- .../test_mgxs_library_nuclides.py | 4 +- tests/test_plot/test_plot.py | 2 +- .../test_resonance_scattering.py | 8 +-- tests/test_source/test_source.py | 16 ++--- tests/test_tallies/test_tallies.py | 4 +- .../test_tally_aggregation.py | 2 +- .../test_tally_arithmetic.py | 2 +- .../test_tally_slice_merge.py | 14 ++-- 37 files changed, 203 insertions(+), 284 deletions(-) create mode 100644 docs/source/_templates/myfunction.rst diff --git a/docs/source/_templates/myfunction.rst b/docs/source/_templates/myfunction.rst new file mode 100644 index 0000000000..4d7ea38a18 --- /dev/null +++ b/docs/source/_templates/myfunction.rst @@ -0,0 +1,6 @@ +{{ fullname }} +{{ underline }} + +.. currentmodule:: {{ module }} + +.. autofunction:: {{ objname }} diff --git a/docs/source/pythonapi/index.rst b/docs/source/pythonapi/index.rst index 9fd70cb5a2..3bedaf2c7b 100644 --- a/docs/source/pythonapi/index.rst +++ b/docs/source/pythonapi/index.rst @@ -29,7 +29,7 @@ Classes :template: myclass.rst openmc.XSdata - openmc.MGXSLibraryFile + openmc.MGXSLibrary Functions +++++++++ @@ -50,7 +50,7 @@ Simulation Settings openmc.Source openmc.ResonanceScattering - openmc.SettingsFile + openmc.Settings Material Specification ---------------------- @@ -64,7 +64,7 @@ Material Specification openmc.Element openmc.Macroscopic openmc.Material - openmc.MaterialsFile + openmc.Materials Building geometry ----------------- @@ -96,7 +96,6 @@ Building geometry openmc.RectLattice openmc.HexLattice openmc.Geometry - openmc.GeometryFile Many of the above classes are derived from several abstract classes: @@ -121,7 +120,7 @@ Constructing Tallies openmc.Mesh openmc.Trigger openmc.Tally - openmc.TalliesFile + openmc.Tallies Coarse Mesh Finite Difference Acceleration ------------------------------------------ @@ -132,7 +131,7 @@ Coarse Mesh Finite Difference Acceleration :template: myclass.rst openmc.CMFDMesh - openmc.CMFDFile + openmc.CMFD Plotting -------- @@ -143,7 +142,7 @@ Plotting :template: myclass.rst openmc.Plot - openmc.PlotsFile + openmc.Plots Running OpenMC -------------- @@ -151,9 +150,10 @@ Running OpenMC .. autosummary:: :toctree: generated :nosignatures: - :template: myclass.rst + :template: myfunction.rst - openmc.Executor + openmc.run + openmc.plot_geometry Post-processing --------------- diff --git a/examples/python/basic/build-xml.py b/examples/python/basic/build-xml.py index fbe6836616..19737cf91f 100644 --- a/examples/python/basic/build-xml.py +++ b/examples/python/basic/build-xml.py @@ -12,7 +12,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -31,15 +31,15 @@ fuel = openmc.Material(material_id=40, name='fuel') fuel.set_density('g/cc', 4.5) fuel.add_nuclide(u235, 1.) -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials collection, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate ZCylinder surfaces @@ -74,22 +74,18 @@ cell1.fill = universe1 universe1.add_cells([cell2, cell3]) root.add_cells([cell1, cell4]) -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -103,7 +99,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate some tally Filters @@ -128,8 +124,8 @@ third_tally = openmc.Tally(tally_id=3, name='third tally') third_tally.filters = [cell_filter, energy_filter, energyout_filter] third_tally.scores = ['scatter', 'nu-scatter', 'nu-fission'] -# Instantiate a TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register all Tallies, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_tally(first_tally) tallies_file.add_tally(second_tally) tallies_file.add_tally(third_tally) diff --git a/examples/python/boxes/build-xml.py b/examples/python/boxes/build-xml.py index ea3e81d172..196a10ca7b 100644 --- a/examples/python/boxes/build-xml.py +++ b/examples/python/boxes/build-xml.py @@ -36,15 +36,15 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([fuel1, fuel2, moderator]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate planar surfaces @@ -97,14 +97,10 @@ outer_box.fill = moderator root = openmc.Universe(universe_id=0, name='root universe') root.add_cells([inner_box, middle_box, outer_box]) -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### @@ -112,7 +108,7 @@ geometry_file.export_to_xml() ############################################################################### # Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -133,7 +129,7 @@ plot.width = [20, 20] plot.pixels = [200, 200] plot.color = 'cell' -# Instantiate a PlotsFile, add Plot, and export to XML -plot_file = openmc.PlotsFile() +# Instantiate a Plots object, add Plot, and export to XML +plot_file = openmc.Plots() plot_file.add_plot(plot) plot_file.export_to_xml() diff --git a/examples/python/lattice/hexagonal/build-xml.py b/examples/python/lattice/hexagonal/build-xml.py index 7f92e66027..a9d7f68991 100644 --- a/examples/python/lattice/hexagonal/build-xml.py +++ b/examples/python/lattice/hexagonal/build-xml.py @@ -35,15 +35,15 @@ iron = openmc.Material(material_id=3, name='iron') iron.set_density('g/cc', 7.9) iron.add_nuclide(fe56, 1.) -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel, iron]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate Surfaces @@ -105,22 +105,18 @@ lattice.outer = univ2 # Fill Cell with the Lattice cell1.fill = lattice -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### # Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -137,7 +133,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC plots.xml File +# Exporting to OpenMC plots.xml file ############################################################################### plot_xy = openmc.Plot(plot_id=1) @@ -155,8 +151,8 @@ plot_yz.width = [8, 8] plot_yz.pixels = [400, 400] plot_yz.color = 'mat' -# Instantiate a PlotsFile, add Plot, and export to XML -plot_file = openmc.PlotsFile() +# Instantiate a Plots object, add plots, and export to XML +plot_file = openmc.Plots() plot_file.add_plot(plot_xy) plot_file.add_plot(plot_yz) plot_file.export_to_xml() @@ -171,7 +167,7 @@ tally = openmc.Tally(tally_id=1) tally.filters = [openmc.Filter(type='distribcell', bins=[cell2.id])] tally.scores = ['total'] -# Instantiate a TalliesFile, register Tally/Mesh, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register Tally/Mesh, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index f54f064530..eb16c83278 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -11,7 +11,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -30,15 +30,15 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate Surfaces @@ -116,22 +116,18 @@ lattice2.universes = [[univ4, univ4], cell1.fill = lattice2 cell2.fill = lattice1 -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -145,7 +141,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC plots.xml File +# Exporting to OpenMC plots.xml file ############################################################################### plot = openmc.Plot(plot_id=1) @@ -154,14 +150,14 @@ plot.width = [4, 4] plot.pixels = [400, 400] plot.color = 'mat' -# Instantiate a PlotsFile, add Plot, and export to XML -plot_file = openmc.PlotsFile() +# Instantiate a Plots object, add Plot, and export to XML +plot_file = openmc.Plots() plot_file.add_plot(plot) plot_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate a tally mesh @@ -180,8 +176,8 @@ tally = openmc.Tally(tally_id=1) tally.filters = [mesh_filter] tally.scores = ['total'] -# Instantiate a TalliesFile, register Tally/Mesh, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register Tally/Mesh, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index f633fa96f7..6e44e4da0a 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -11,7 +11,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -30,15 +30,15 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate Surfaces @@ -106,22 +106,18 @@ lattice.universes = [[univ1, univ2, univ1, univ2], # Fill Cell with the Lattice cell1.fill = lattice -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -137,7 +133,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC plots.xml File +# Exporting to OpenMC plots.xml file ############################################################################### plot = openmc.Plot(plot_id=1) @@ -146,14 +142,14 @@ plot.width = [4, 4] plot.pixels = [400, 400] plot.color = 'mat' -# Instantiate a PlotsFile, add Plot, and export to XML -plot_file = openmc.PlotsFile() +# Instantiate a Plots object, add Plot, and export to XML +plot_file = openmc.Plots() plot_file.add_plot(plot) plot_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate a tally mesh @@ -177,8 +173,8 @@ tally.filters = [mesh_filter] tally.scores = ['total'] tally.triggers = [trigger] -# Instantiate a TalliesFile, register Tally/Mesh, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register Tally/Mesh, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 2e72d82ab4..10cd4944d4 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -11,7 +11,7 @@ particles = 1000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -100,15 +100,15 @@ borated_water.add_nuclide(o16, 2.4672e-2) borated_water.add_nuclide(o17, 6.0099e-5) borated_water.add_s_alpha_beta('HH2O', '71t') -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([uo2, helium, zircaloy, borated_water]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate ZCylinder surfaces @@ -149,22 +149,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, gap, clad, water]) -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles @@ -181,7 +177,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate a tally mesh @@ -201,8 +197,8 @@ tally = openmc.Tally(tally_id=1, name='tally 1') tally.filters = [energy_filter, mesh_filter] tally.scores = ['flux', 'fission', 'nu-fission'] -# Instantiate a TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register all Tallies, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/pincell_multigroup/build-xml.py b/examples/python/pincell_multigroup/build-xml.py index 60026c0892..2337281423 100644 --- a/examples/python/pincell_multigroup/build-xml.py +++ b/examples/python/pincell_multigroup/build-xml.py @@ -12,7 +12,7 @@ inactive = 10 particles = 1000 ############################################################################### -# Exporting to OpenMC mg_cross_sections.xml File +# Exporting to OpenMC mg_cross_sections.xml file ############################################################################### # Instantiate the energy group data @@ -59,13 +59,13 @@ scatter = [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0 [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]] h2o_xsdata.scatter = np.array(scatter) -mg_cross_sections_file = openmc.MGXSLibraryFile(groups) +mg_cross_sections_file = openmc.MGXSLibrary(groups) mg_cross_sections_file.add_xsdatas([uo2_xsdata,h2o_xsdata]) mg_cross_sections_file.export_to_xml() ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Macroscopic Data @@ -81,15 +81,15 @@ water = openmc.Material(material_id=2, name='Water') water.set_density('macro', 1.0) water.add_macroscopic(h2o_data) -# Instantiate a MaterialsFile, register all Materials, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register all Materials, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '300K' materials_file.add_materials([uo2, water]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate ZCylinder surfaces @@ -122,22 +122,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, moderator]) -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.energy_mode = "multi-group" settings_file.cross_sections = "./mg_cross_sections.xml" settings_file.batches = batches @@ -152,7 +148,7 @@ settings_file.source = openmc.source.Source(space=uniform_dist) settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate a tally mesh @@ -177,8 +173,8 @@ tally.add_score('flux') tally.add_score('fission') tally.add_score('nu-fission') -# Instantiate a TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register all Tallies, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/reflective/build-xml.py b/examples/python/reflective/build-xml.py index 01a5c7815f..7d96e296da 100644 --- a/examples/python/reflective/build-xml.py +++ b/examples/python/reflective/build-xml.py @@ -12,7 +12,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate a Nuclides @@ -23,15 +23,15 @@ fuel = openmc.Material(material_id=1, name='fuel') fuel.set_density('g/cc', 4.5) fuel.add_nuclide(u235, 1.) -# Instantiate a MaterialsFile, register Material, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register Material, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_material(fuel) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate Surfaces @@ -64,22 +64,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cell with Universe root.add_cell(cell) -# Instantiate a Geometry and register the root Universe +# Instantiate a Geometry and register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root - -# Instantiate a GeometryFile, register Geometry, and export to XML -geometry_file = openmc.GeometryFile() -geometry_file.geometry = geometry -geometry_file.export_to_xml() +geometry.export_to_xml() ############################################################################### -# Exporting to OpenMC settings.xml File +# Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML -settings_file = openmc.SettingsFile() +# Instantiate a Settings object, set all runtime parameters, and export to XML +settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles diff --git a/openmc/cmfd.py b/openmc/cmfd.py index b9977a288d..d4cce2af5a 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -187,7 +187,7 @@ class CMFDMesh(object): return element -class CMFDFile(object): +class CMFD(object): """Parameters that control the use of coarse-mesh finite difference acceleration in OpenMC. This corresponds directly to the cmfd.xml input file. diff --git a/openmc/executor.py b/openmc/executor.py index 89bcc2e10d..9bb3477c50 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -27,7 +27,7 @@ def _run(command, output, cwd): return p.returncode -def plot(output=True, openmc_exec='openmc', cwd='.'): +def plot_geometry(output=True, openmc_exec='openmc', cwd='.'): """Run OpenMC in plotting mode Parameters diff --git a/openmc/geometry.py b/openmc/geometry.py index f5dfe97e4a..ed437f6e19 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -23,7 +23,6 @@ class Geometry(object): """ def __init__(self): - # Initialize Geometry class attributes self._root_universe = None self._offsets = {} @@ -42,6 +41,27 @@ class Geometry(object): self._root_universe = root_universe + def export_to_xml(self): + """Create a geometry.xml file that can be used for a simulation. + + """ + + # Clear OpenMC written IDs used to optimize XML generation + openmc.universe.WRITTEN_IDS = {} + + # Create XML representation + geometry_file = ET.Element("geometry") + self.root_universe.create_xml_subelement(geometry_file) + + # Clean the indentation in the file to be user-readable + sort_xml_elements(geometry_file) + clean_xml_indentation(geometry_file) + + # Write the XML Tree to the geometry.xml file + tree = ET.ElementTree(geometry_file) + tree.write("geometry.xml", xml_declaration=True, encoding='utf-8', + method="xml") + def get_cell_instance(self, path): """Return the instance number for the final cell in a geometry path. @@ -436,52 +456,3 @@ class Geometry(object): lattices = list(lattices) lattices.sort(key=lambda x: x.id) return lattices - - -class GeometryFile(object): - """Geometry file used for an OpenMC simulation. Corresponds directly to the - geometry.xml input file. - - Attributes - ---------- - geometry : openmc.Geometry - The geometry to be used - - """ - - def __init__(self): - # Initialize GeometryFile class attributes - self._geometry = None - self._geometry_file = ET.Element("geometry") - - @property - def geometry(self): - return self._geometry - - @geometry.setter - def geometry(self, geometry): - check_type('the geometry', geometry, Geometry) - self._geometry = geometry - - def export_to_xml(self): - """Create a geometry.xml file that can be used for a simulation. - - """ - - # Clear OpenMC written IDs used to optimize XML generation - openmc.universe.WRITTEN_IDS = {} - - # Reset xml element tree - self._geometry_file.clear() - - root_universe = self.geometry.root_universe - root_universe.create_xml_subelement(self._geometry_file) - - # Clean the indentation in the file to be user-readable - sort_xml_elements(self._geometry_file) - clean_xml_indentation(self._geometry_file) - - # Write the XML Tree to the geometry.xml file - tree = ET.ElementTree(self._geometry_file) - tree.write("geometry.xml", xml_declaration=True, - encoding='utf-8', method="xml") diff --git a/openmc/material.py b/openmc/material.py index 16af82439b..6b0a0f2468 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -642,8 +642,8 @@ class Material(object): return element -class MaterialsFile(object): - """Materials file used for an OpenMC simulation. Corresponds directly to the +class Materials(object): + """Materials used for an OpenMC simulation. Corresponds directly to the materials.xml input file. Attributes @@ -655,7 +655,6 @@ class MaterialsFile(object): """ def __init__(self): - # Initialize MaterialsFile class attributes self._materials = [] self._default_xs = None self._materials_file = ET.Element("materials") @@ -681,7 +680,7 @@ class MaterialsFile(object): if not isinstance(material, Material): msg = 'Unable to add a non-Material "{0}" to the ' \ - 'MaterialsFile'.format(material) + 'Materials instance'.format(material) raise ValueError(msg) self._materials.append(material) @@ -716,7 +715,7 @@ class MaterialsFile(object): if not isinstance(material, Material): msg = 'Unable to remove a non-Material "{0}" from the ' \ - 'MaterialsFile'.format(material) + 'Materials instance'.format(material) raise ValueError(msg) self._materials.remove(material) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 4de4bb48ac..ca7bf39cd8 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -354,8 +354,8 @@ class Library(object): Parameters ---------- - tallies_file : openmc.TalliesFile - A TalliesFile object to add each MGXS' tallies to generate a + tallies_file : openmc.Tallies + A Tallies object to add each MGXS' tallies to generate a "tallies.xml" input file for OpenMC merge : bool Indicate whether tallies should be merged when possible. Defaults @@ -363,7 +363,7 @@ class Library(object): """ - cv.check_type('tallies_file', tallies_file, openmc.TalliesFile) + cv.check_type('tallies_file', tallies_file, openmc.Tallies) # Add tallies from each MGXS for each domain and mgxs type for domain in self.domains: diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index c0b04fed1e..8db3c84ff7 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -647,7 +647,7 @@ class XSdata(object): return element -class MGXSLibraryFile(object): +class MGXSLibrary(object): """Multi-Group Cross Sections file used for an OpenMC simulation. Corresponds directly to the MG version of the cross_sections.xml input file. @@ -662,7 +662,6 @@ class MGXSLibraryFile(object): """ def __init__(self, energy_groups): - # Initialize MGXSLibraryFile class attributes self._xsdatas = [] self._energy_groups = energy_groups self._inverse_velocities = None @@ -701,12 +700,12 @@ class MGXSLibraryFile(object): # Check the type if not isinstance(xsdata, XSdata): msg = 'Unable to add a non-XSdata "{0}" to the ' \ - 'MGXSLibraryFile'.format(xsdata) + 'MGXSLibrary instance'.format(xsdata) raise ValueError(msg) # Make sure energy groups match. if xsdata.energy_groups != self._energy_groups: - msg = 'Energy groups of XSdata do not match that of MGXSLibraryFile!' + msg = 'Energy groups of XSdata do not match that of MGXSLibrary!' raise ValueError(msg) self._xsdatas.append(xsdata) @@ -741,7 +740,7 @@ class MGXSLibraryFile(object): if not isinstance(xsdata, XSdata): msg = 'Unable to remove a non-XSdata "{0}" from the ' \ - 'XSdatasFile'.format(xsdata) + 'MGXSLibrary instance'.format(xsdata) raise ValueError(msg) self._xsdatas.remove(xsdata) diff --git a/openmc/plots.py b/openmc/plots.py index 5e7c47743e..ae34678bba 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -401,14 +401,13 @@ class Plot(object): return element -class PlotsFile(object): +class Plots(object): """Plots file used for an OpenMC simulation. Corresponds directly to the plots.xml input file. """ def __init__(self): - # Initialize PlotsFile class attributes self._plots = [] self._plots_file = ET.Element("plots") @@ -423,7 +422,7 @@ class PlotsFile(object): """ if not isinstance(plot, Plot): - msg = 'Unable to add a non-Plot "{0}" to the PlotsFile'.format(plot) + msg = 'Unable to add a non-Plot "{0}" to the Plots instance'.format(plot) raise ValueError(msg) self._plots.append(plot) diff --git a/openmc/settings.py b/openmc/settings.py index 0be50bc563..ec38bf54c3 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -16,7 +16,7 @@ if sys.version_info[0] >= 3: basestring = str -class SettingsFile(object): +class Settings(object): """Settings file used for an OpenMC simulation. Corresponds directly to the settings.xml input file. diff --git a/openmc/tallies.py b/openmc/tallies.py index 2ee03c6752..1af3b12bc7 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -3419,14 +3419,13 @@ class Tally(object): return new_tally -class TalliesFile(object): +class Tallies(object): """Tallies file used for an OpenMC simulation. Corresponds directly to the tallies.xml input file. """ def __init__(self): - # Initialize TalliesFile class attributes self._tallies = [] self._meshes = [] self._tallies_file = ET.Element("tallies") @@ -3453,7 +3452,7 @@ class TalliesFile(object): """ if not isinstance(tally, Tally): - msg = 'Unable to add a non-Tally "{0}" to the TalliesFile'.format(tally) + msg = 'Unable to add a non-Tally "{0}" to the Tallies instance'.format(tally) raise ValueError(msg) if merge: @@ -3524,7 +3523,7 @@ class TalliesFile(object): """ if not isinstance(mesh, Mesh): - msg = 'Unable to add a non-Mesh "{0}" to the TalliesFile'.format(mesh) + msg = 'Unable to add a non-Mesh "{0}" to the Tallies instance'.format(mesh) raise ValueError(msg) self._meshes.append(mesh) diff --git a/tests/input_set.py b/tests/input_set.py index daff38ba1e..3be6c1db44 100644 --- a/tests/input_set.py +++ b/tests/input_set.py @@ -5,9 +5,9 @@ from openmc.stats import Box class InputSet(object): def __init__(self): - self.settings = openmc.SettingsFile() - self.materials = openmc.MaterialsFile() - self.geometry = openmc.GeometryFile() + self.settings = openmc.Settings() + self.materials = openmc.Materials() + self.geometry = openmc.Geometry() self.tallies = None self.plots = None @@ -550,11 +550,8 @@ class InputSet(object): root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12)) - # Define the geometry file. - geometry = openmc.Geometry() - geometry.root_universe = root - - self.geometry.geometry = geometry + # Assign root universe to geometry + self.geometry.root_universe = root def build_default_settings(self): self.settings.batches = 10 @@ -630,12 +627,8 @@ class MGInputSet(InputSet): root.add_cells((c1,c2,c3)) - # Define the geometry file. - geometry = openmc.Geometry() - geometry.root_universe = root - - self.geometry.geometry = geometry - + # Assign root universe to geometry + self.geometry.root_universe = root def build_default_settings(self): self.settings.batches = 10 @@ -656,8 +649,3 @@ class MGInputSet(InputSet): plot.color = 'mat' self.plots.add_plot(plot) - - - - - diff --git a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py index fdb21db33c..94562e6d9e 100644 --- a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py +++ b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py @@ -7,8 +7,6 @@ import hashlib sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness import openmc -from openmc.source import Source -from openmc.stats import Box class AsymmetricLatticeTestHarness(PyAPITestHarness): @@ -20,7 +18,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): self._input_set.build_default_materials_and_geometry() # Extract universes encapsulating fuel and water assemblies - geometry = self._input_set.geometry.geometry + geometry = self._input_set.geometry water = geometry.get_universes_by_name('water assembly (hot)')[0] fuel = geometry.get_universes_by_name('fuel assembly (hot)')[0] @@ -49,7 +47,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): root_univ.add_cell(root_cell) # Over-ride geometry in the input set with this 3x3 lattice - self._input_set.geometry.geometry.root_universe = root_univ + self._input_set.geometry.root_universe = root_univ # Initialize a "distribcell" filter for the fuel pin cell distrib_filter = openmc.Filter(type='distribcell', bins=[27]) @@ -60,7 +58,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): tally.add_score('nu-fission') # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() tallies_file.add_tally(tally) # Assign the tallies file to the input set @@ -70,7 +68,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): self._input_set.build_default_settings() # Specify summary output and correct source sampling box - source = Source(space=Box([-32, -32, 0], [32, 32, 32])) + source = openmc.Source(space=openmc.stats.Box([-32, -32, 0], [32, 32, 32])) source.space.only_fissionable = True self._input_set.settings.source = source self._input_set.settings.output = {'summary': True} diff --git a/tests/test_distribmat/test_distribmat.py b/tests/test_distribmat/test_distribmat.py index a0608c108a..ded2863bdb 100644 --- a/tests/test_distribmat/test_distribmat.py +++ b/tests/test_distribmat/test_distribmat.py @@ -28,7 +28,7 @@ class DistribmatTestHarness(PyAPITestHarness): light_fuel.set_density('g/cc', 2.0) light_fuel.add_nuclide('U-235', 1.0) - mats_file = openmc.MaterialsFile() + mats_file = openmc.Materials() mats_file.default_xs = '71c' mats_file.add_materials([moderator, dense_fuel, light_fuel]) mats_file.export_to_xml() @@ -74,16 +74,14 @@ class DistribmatTestHarness(PyAPITestHarness): geometry = openmc.Geometry() geometry.root_universe = root_univ - geo_file = openmc.GeometryFile() - geo_file.geometry = geometry - geo_file.export_to_xml() + geometry.export_to_xml() #################### # Settings #################### - sets_file = openmc.SettingsFile() + sets_file = openmc.Settings() sets_file.batches = 5 sets_file.inactive = 0 sets_file.particles = 1000 @@ -96,7 +94,7 @@ class DistribmatTestHarness(PyAPITestHarness): # Plots #################### - plots_file = openmc.PlotsFile() + plots_file = openmc.Plots() plot = openmc.Plot(plot_id=1) plot.basis = 'xy' diff --git a/tests/test_mg_max_order/test_mg_max_order.py b/tests/test_mg_max_order/test_mg_max_order.py index 2f5ee4e4e6..2c4db58df0 100644 --- a/tests/test_mg_max_order/test_mg_max_order.py +++ b/tests/test_mg_max_order/test_mg_max_order.py @@ -68,7 +68,7 @@ class MGNuclideInputSet(MGInputSet): geometry = openmc.Geometry() geometry.root_universe = root - self.geometry.geometry = geometry + self.geometry = geometry class MGMaxOrderTestHarness(PyAPITestHarness): def __init__(self, statepoint_name, tallies_present, mg=False): diff --git a/tests/test_mg_nuclide/test_mg_nuclide.py b/tests/test_mg_nuclide/test_mg_nuclide.py index deb784bad9..0fa7184a32 100644 --- a/tests/test_mg_nuclide/test_mg_nuclide.py +++ b/tests/test_mg_nuclide/test_mg_nuclide.py @@ -67,7 +67,7 @@ class MGNuclideInputSet(MGInputSet): geometry = openmc.Geometry() geometry.root_universe = root - self.geometry.geometry = geometry + self.geometry = geometry class MGNuclideTestHarness(PyAPITestHarness): def __init__(self, statepoint_name, tallies_present, mg=False): diff --git a/tests/test_mg_tallies/test_mg_tallies.py b/tests/test_mg_tallies/test_mg_tallies.py index c54fb4d32d..ffc57f9e9e 100644 --- a/tests/test_mg_tallies/test_mg_tallies.py +++ b/tests/test_mg_tallies/test_mg_tallies.py @@ -41,7 +41,7 @@ class MGTalliesTestHarness(PyAPITestHarness): tally2.add_score('scatter') tally2.add_score('nu-scatter') - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self._input_set.tallies.add_mesh(mesh) self._input_set.tallies.add_tally(tally1) self._input_set.tallies.add_tally(tally2) diff --git a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py index 82ce3acabc..97bb853b62 100644 --- a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py +++ b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py index 1de21a6037..6812661860 100644 --- a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py +++ b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py @@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness): # Initialize MGXS Library for a few cross section types # for one material-filled cell in the geometry - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -35,7 +35,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py index 642073104b..30be46b4cc 100644 --- a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py +++ b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py @@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -33,7 +33,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() @@ -51,7 +51,7 @@ class MGXSTestHarness(PyAPITestHarness): # Load the MGXS library from the statepoint self.mgxs_lib.load_from_statepoint(sp) - + # Export the MGXS Library to an HDF5 file self.mgxs_lib.build_hdf5_store(directory='.') @@ -67,7 +67,7 @@ class MGXSTestHarness(PyAPITestHarness): outstr += str(f[key][...]) + '\n' key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type) outstr += str(f[key][...]) + '\n' - + # Close the MGXS HDF5 file f.close() diff --git a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py index 2afa9039e8..381b5b87c2 100644 --- a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py +++ b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py index 173043cf04..c3e4f5f770 100644 --- a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py +++ b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = True self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_plot/test_plot.py b/tests/test_plot/test_plot.py index e40cef49c0..606a1fd647 100644 --- a/tests/test_plot/test_plot.py +++ b/tests/test_plot/test_plot.py @@ -19,7 +19,7 @@ class PlotTestHarness(TestHarness): self._plot_names = plot_names def _run_openmc(self): - returncode = openmc.plot(openmc_exec=self._opts.exe) + returncode = openmc.plot_geometry(openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self): diff --git a/tests/test_resonance_scattering/test_resonance_scattering.py b/tests/test_resonance_scattering/test_resonance_scattering.py index d977488bfe..5cecfedc45 100644 --- a/tests/test_resonance_scattering/test_resonance_scattering.py +++ b/tests/test_resonance_scattering/test_resonance_scattering.py @@ -17,7 +17,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): mat.add_nuclide('Pu-239', 0.02) mat.add_nuclide('H-1', 20.0) - mats_file = openmc.MaterialsFile() + mats_file = openmc.Materials() mats_file.default_xs = '71c' mats_file.add_material(mat) mats_file.export_to_xml() @@ -35,9 +35,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): geometry = openmc.Geometry() geometry.root_universe = root_univ - geo_file = openmc.GeometryFile() - geo_file.geometry = geometry - geo_file.export_to_xml() + geometry.export_to_xml() # Settings nuclide = openmc.Nuclide('U-238', '71c') @@ -67,7 +65,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): res_scatt_ares.E_min = 1e-6 res_scatt_ares.E_max = 210e-6 - sets_file = openmc.SettingsFile() + sets_file = openmc.Settings() sets_file.batches = 10 sets_file.inactive = 5 sets_file.particles = 1000 diff --git a/tests/test_source/test_source.py b/tests/test_source/test_source.py index 9d303b06bc..1e41bd10e7 100644 --- a/tests/test_source/test_source.py +++ b/tests/test_source/test_source.py @@ -9,8 +9,6 @@ import numpy as np sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness import openmc -import openmc.stats -from openmc.source import Source class SourceTestHarness(PyAPITestHarness): @@ -18,7 +16,7 @@ class SourceTestHarness(PyAPITestHarness): mat1 = openmc.Material(material_id=1) mat1.set_density('g/cm3', 4.5) mat1.add_nuclide(openmc.Nuclide('U-235', '71c'), 1.0) - materials = openmc.MaterialsFile() + materials = openmc.Materials() materials.add_material(mat1) materials.export_to_xml() @@ -31,9 +29,7 @@ class SourceTestHarness(PyAPITestHarness): root.add_cell(inside_sphere) geometry = openmc.Geometry() geometry.root_universe = root - geometry_xml = openmc.GeometryFile() - geometry_xml.geometry = geometry - geometry_xml.export_to_xml() + geometry.export_to_xml() # Create an array of different sources x_dist = openmc.stats.Uniform(-3., 3.) @@ -56,11 +52,11 @@ class SourceTestHarness(PyAPITestHarness): energy2 = openmc.stats.Watt(0.988, 2.249) energy3 = openmc.stats.Tabular(E, p, interpolation='histogram') - source1 = Source(spatial1, angle1, energy1, strength=0.5) - source2 = Source(spatial2, angle2, energy2, strength=0.3) - source3 = Source(spatial3, angle3, energy3, strength=0.2) + source1 = openmc.Source(spatial1, angle1, energy1, strength=0.5) + source2 = openmc.Source(spatial2, angle2, energy2, strength=0.3) + source3 = openmc.Source(spatial3, angle3, energy3, strength=0.2) - settings = openmc.SettingsFile() + settings = openmc.Settings() settings.batches = 10 settings.inactive = 5 settings.particles = 1000 diff --git a/tests/test_tallies/test_tallies.py b/tests/test_tallies/test_tallies.py index 81e8641dec..bb0273589e 100644 --- a/tests/test_tallies/test_tallies.py +++ b/tests/test_tallies/test_tallies.py @@ -4,7 +4,7 @@ import os import sys sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness -from openmc import Filter, Mesh, Tally, TalliesFile +from openmc import Filter, Mesh, Tally, Tallies from openmc.source import Source from openmc.stats import Box @@ -170,7 +170,7 @@ class TalliesTestHarness(PyAPITestHarness): all_nuclide_tallies[0].estimator = 'tracklength' all_nuclide_tallies[0].estimator = 'collision' - self._input_set.tallies = TalliesFile() + self._input_set.tallies = Tallies() self._input_set.tallies.add_tally(azimuthal_tally1) self._input_set.tallies.add_tally(azimuthal_tally2) self._input_set.tallies.add_tally(azimuthal_tally3) diff --git a/tests/test_tally_aggregation/test_tally_aggregation.py b/tests/test_tally_aggregation/test_tally_aggregation.py index 7d682b6986..009a7dc09c 100644 --- a/tests/test_tally_aggregation/test_tally_aggregation.py +++ b/tests/test_tally_aggregation/test_tally_aggregation.py @@ -16,7 +16,7 @@ class TallyAggregationTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Initialize the nuclides u235 = openmc.Nuclide('U-235') diff --git a/tests/test_tally_arithmetic/test_tally_arithmetic.py b/tests/test_tally_arithmetic/test_tally_arithmetic.py index cf8d012e8c..ffea74603c 100644 --- a/tests/test_tally_arithmetic/test_tally_arithmetic.py +++ b/tests/test_tally_arithmetic/test_tally_arithmetic.py @@ -16,7 +16,7 @@ class TallyArithmeticTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Initialize the nuclides u235 = openmc.Nuclide('U-235') diff --git a/tests/test_tally_slice_merge/test_tally_slice_merge.py b/tests/test_tally_slice_merge/test_tally_slice_merge.py index 79acf182d6..933fdf6fa3 100644 --- a/tests/test_tally_slice_merge/test_tally_slice_merge.py +++ b/tests/test_tally_slice_merge/test_tally_slice_merge.py @@ -17,7 +17,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Define nuclides and scores to add to both tallies self.nuclides = ['U-235', 'U-238'] @@ -69,8 +69,8 @@ class TallySliceMergeTestHarness(PyAPITestHarness): for nuclide in self.nuclides: distribcell_tally.add_nuclide(nuclide) - # Add tallies to a TalliesFile - tallies_file = openmc.TalliesFile() + # Add tallies to a Tallies object + tallies_file = openmc.Tallies() tallies_file.add_tally(tallies[0]) tallies_file.add_tally(distribcell_tally) @@ -95,7 +95,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness): # Slice the tallies by cell filter bins cell_filter_prod = itertools.product(tallies, self.cell_filters) - tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type], + tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type], filter_bins=[tf[1].get_bin(0)]), cell_filter_prod) # Slice the tallies by energy filter bins @@ -133,11 +133,11 @@ class TallySliceMergeTestHarness(PyAPITestHarness): # Extract the distribcell tally distribcell_tally = sp.get_tally(name='distribcell tally') - # Sum up a few subdomains from the distribcell tally - sum1 = distribcell_tally.summation(filter_type='distribcell', + # Sum up a few subdomains from the distribcell tally + sum1 = distribcell_tally.summation(filter_type='distribcell', filter_bins=[0,100,2000,30000]) # Sum up a few subdomains from the distribcell tally - sum2 = distribcell_tally.summation(filter_type='distribcell', + sum2 = distribcell_tally.summation(filter_type='distribcell', filter_bins=[500,5000,50000]) # Merge the distribcell tally slices From 68f7de13155231cf88213b19d9dd7e0aba8571ae Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 10:44:20 -0500 Subject: [PATCH 4/8] Update Jupyter notebooks --- .../pythonapi/examples/mgxs-part-i.ipynb | 27 ++++++-------- .../pythonapi/examples/mgxs-part-ii.ipynb | 29 ++++++--------- .../pythonapi/examples/mgxs-part-iii.ipynb | 37 ++++++++----------- .../examples/pandas-dataframes.ipynb | 37 ++++++++----------- .../pythonapi/examples/post-processing.ipynb | 27 ++++++-------- .../pythonapi/examples/tally-arithmetic.ipynb | 29 ++++++--------- 6 files changed, 78 insertions(+), 108 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-i.ipynb b/docs/source/pythonapi/examples/mgxs-part-i.ipynb index de66cbb837..c7a5b2ffa3 100644 --- a/docs/source/pythonapi/examples/mgxs-part-i.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-i.ipynb @@ -201,7 +201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our material, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our material, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -212,8 +212,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, register all Materials, and export to XML\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, register all Materials, and export to XML\n", + "materials_file = openmc.Materials()\n", "materials_file.default_xs = '71c'\n", "materials_file.add_material(inf_medium)\n", "materials_file.export_to_xml()" @@ -290,7 +290,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -305,12 +305,8 @@ "openmc_geometry = openmc.Geometry()\n", "openmc_geometry.root_universe = root_universe\n", "\n", - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = openmc_geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "openmc_geometry.export_to_xml()" ] }, { @@ -333,8 +329,8 @@ "inactive = 10\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -455,7 +451,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `TalliesFile` object to generate the \"tallies.xml\" input file for OpenMC." + "The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `Tallies` object to generate the \"tallies.xml\" input file for OpenMC." ] }, { @@ -466,8 +462,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "\n", "# Add total tallies to the tallies file\n", "for tally in total.tallies.values():\n", @@ -644,8 +640,7 @@ ], "source": [ "# Run OpenMC\n", - "executor = openmc.Executor()\n", - "executor.run_simulation()" + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb index 6ed5cd38d8..49e301f5b0 100644 --- a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb @@ -122,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our materials, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -133,8 +133,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -238,7 +238,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -253,12 +253,8 @@ "openmc_geometry = openmc.Geometry()\n", "openmc_geometry.root_universe = root_universe\n", "\n", - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = openmc_geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "openmc_geometry.export_to_xml()" ] }, { @@ -281,8 +277,8 @@ "inactive = 10\n", "particles = 10000\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -396,8 +392,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "\n", "# Iterate over all cells and cross section types\n", "for cell in openmc_cells:\n", @@ -607,8 +603,7 @@ ], "source": [ "# Run OpenMC\n", - "executor = openmc.Executor()\n", - "executor.run_simulation(output=True)" + "openmc.run(output=True)" ] }, { @@ -1360,7 +1355,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", @@ -1699,7 +1694,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", diff --git a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb index 5fccc4f03d..3a3533ffec 100644 --- a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb @@ -122,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our three materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our three materials, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -133,8 +133,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -331,7 +331,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -355,12 +355,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -383,8 +379,8 @@ "inactive = 10\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -403,7 +399,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let us also create a `PlotsFile` that we can use to verify that our fuel assembly geometry was created successfully." + "Let us also create a `Plots` file that we can use to verify that our fuel assembly geometry was created successfully." ] }, { @@ -422,8 +418,8 @@ "plot.width = [-10.71*2, -10.71*2]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -455,8 +451,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -643,7 +638,7 @@ "source": [ "The tallies can now be export to a \"tallies.xml\" input file for OpenMC. \n", "\n", - "**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `TalliesFile` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below." + "**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `Tallies` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below." ] }, { @@ -655,7 +650,7 @@ "outputs": [], "source": [ "# Create a \"tallies.xml\" file for the MGXS Library\n", - "tallies_file = openmc.TalliesFile()\n", + "tallies_file = openmc.Tallies()\n", "mgxs_lib.add_to_tallies_file(tallies_file, merge=True)" ] }, @@ -690,7 +685,7 @@ "tally.filters = [mesh_filter]\n", "tally.scores = ['fission', 'nu-fission']\n", "\n", - "# Add mesh and Tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_mesh(mesh)\n", "tallies_file.add_tally(tally)" ] @@ -860,7 +855,7 @@ ], "source": [ "# Run OpenMC\n", - "executor.run_simulation()" + "openmc.run()" ] }, { @@ -1449,7 +1444,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", diff --git a/docs/source/pythonapi/examples/pandas-dataframes.ipynb b/docs/source/pythonapi/examples/pandas-dataframes.ipynb index 388e4aaa69..b0f2f6b133 100644 --- a/docs/source/pythonapi/examples/pandas-dataframes.ipynb +++ b/docs/source/pythonapi/examples/pandas-dataframes.ipynb @@ -108,8 +108,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -239,7 +239,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -263,12 +263,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -292,8 +288,8 @@ "inactive = 5\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = min_batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -333,8 +329,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -366,8 +362,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -412,8 +407,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "tallies_file._tallies = []" ] }, @@ -453,7 +448,7 @@ "tally.filters = [mesh_filter, energy_filter]\n", "tally.scores = ['fission', 'nu-fission']\n", "\n", - "# Add mesh and Tally to TalliesFile\n", + "# Add mesh and Tally to Tallies\n", "tallies_file.add_mesh(mesh)\n", "tallies_file.add_tally(tally)" ] @@ -482,7 +477,7 @@ "tally.scores = ['scatter-y2']\n", "tally.nuclides = [u235, u238]\n", "\n", - "# Add mesh and tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_tally(tally)" ] }, @@ -514,7 +509,7 @@ "tally.scores = ['absorption', 'scatter']\n", "tally.triggers = [trigger]\n", "\n", - "# Add mesh and tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_tally(tally)" ] }, @@ -669,8 +664,8 @@ "# Remove old HDF5 (summary, statepoint) files\n", "!rm statepoint.*\n", "\n", - "# Run OpenMC with MPI!\n", - "executor.run_simulation()" + "# Run OpenMC!\n", + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/post-processing.ipynb b/docs/source/pythonapi/examples/post-processing.ipynb index 0dc18d5a29..ce9209b03c 100644 --- a/docs/source/pythonapi/examples/post-processing.ipynb +++ b/docs/source/pythonapi/examples/post-processing.ipynb @@ -104,8 +104,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -236,12 +236,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -264,8 +260,8 @@ "inactive = 10\n", "particles = 5000\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -302,8 +298,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -335,8 +331,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -381,8 +376,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()" + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()" ] }, { @@ -634,7 +629,7 @@ ], "source": [ "# Run OpenMC!\n", - "executor.run_simulation()" + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/tally-arithmetic.ipynb b/docs/source/pythonapi/examples/tally-arithmetic.ipynb index 0948428959..81334efc26 100644 --- a/docs/source/pythonapi/examples/tally-arithmetic.ipynb +++ b/docs/source/pythonapi/examples/tally-arithmetic.ipynb @@ -126,8 +126,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -258,12 +258,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -286,8 +282,8 @@ "inactive = 5\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -325,8 +321,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -358,8 +354,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -404,8 +399,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()" + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()" ] }, { @@ -673,8 +668,8 @@ "# Remove old HDF5 (summary, statepoint) files\n", "!rm statepoint.*\n", "\n", - "# Run OpenMC with MPI!\n", - "executor.run_simulation()" + "# Run OpenMC!\n", + "openmc.run()" ] }, { From 3da96a89be182d72cec65f6ce448fdc7780ee76d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 12:43:38 -0500 Subject: [PATCH 5/8] Fix assignment of universe IDs for lattices --- openmc/lattice.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/openmc/lattice.py b/openmc/lattice.py index 7e78abf068..baccbad909 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -7,7 +7,7 @@ import sys import numpy as np import openmc.checkvalue as cv -from openmc.universe import Universe, AUTO_UNIVERSE_ID +import openmc if sys.version_info[0] >= 3: basestring = str @@ -93,9 +93,8 @@ class Lattice(object): @id.setter def id(self, lattice_id): if lattice_id is None: - global AUTO_UNIVERSE_ID - self._id = AUTO_UNIVERSE_ID - AUTO_UNIVERSE_ID += 1 + self._id = openmc.universe.AUTO_UNIVERSE_ID + openmc.universe.AUTO_UNIVERSE_ID += 1 else: cv.check_type('lattice ID', lattice_id, Integral) cv.check_greater_than('lattice ID', lattice_id, 0, equality=True) @@ -111,12 +110,12 @@ class Lattice(object): @outer.setter def outer(self, outer): - cv.check_type('outer universe', outer, Universe) + cv.check_type('outer universe', outer, openmc.Universe) self._outer = outer @universes.setter def universes(self, universes): - cv.check_iterable_type('lattice universes', universes, Universe, + cv.check_iterable_type('lattice universes', universes, openmc.Universe, min_depth=2, max_depth=3) self._universes = np.asarray(universes) @@ -127,20 +126,20 @@ class Lattice(object): ------- universes : collections.OrderedDict Dictionary whose keys are universe IDs and values are - :class:`Universe` instances + :class:`openmc.Universe` instances """ univs = OrderedDict() for k in range(len(self._universes)): for j in range(len(self._universes[k])): - if isinstance(self._universes[k][j], Universe): + if isinstance(self._universes[k][j], openmc.Universe): u = self._universes[k][j] univs[u._id] = u else: for i in range(len(self._universes[k][j])): u = self._universes[k][j][i] - assert isinstance(u, Universe) + assert isinstance(u, openmc.Universe) univs[u._id] = u if self.outer is not None: @@ -615,10 +614,10 @@ class HexLattice(Lattice): # clockwise fashion. # Check to see if the given universes look like a 2D or a 3D array. - if isinstance(self._universes[0][0], Universe): + if isinstance(self._universes[0][0], openmc.Universe): n_dims = 2 - elif isinstance(self._universes[0][0][0], Universe): + elif isinstance(self._universes[0][0][0], openmc.Universe): n_dims = 3 else: From 34bd4052452d034e3bcd096054ae9aafc0eae8df Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 12:58:33 -0500 Subject: [PATCH 6/8] Fix Python 3.5-related issue in mgxs module --- openmc/mgxs/mgxs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 0c3612e9f8..33255de30c 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -412,7 +412,7 @@ class MGXS(object): # Otherwise, return all nuclides in the spatial domain else: nuclides = self.domain.get_all_nuclides() - return nuclides.keys() + return list(nuclides.keys()) def get_nuclide_density(self, nuclide): """Get the atomic number density in units of atoms/b-cm for a nuclide From 6234c4e05ebe416c48ba113b39c1911afb9e6ef4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 26 Apr 2016 07:06:18 -0500 Subject: [PATCH 7/8] Update copyright in two places and link to license in header --- docs/source/license.rst | 2 +- src/output.F90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/license.rst b/docs/source/license.rst index 73e3296172..c51902d6ff 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -4,7 +4,7 @@ License Agreement ================= -Copyright © 2011-2015 Massachusetts Institute of Technology +Copyright © 2011-2016 Massachusetts Institute of Technology Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/src/output.F90 b/src/output.F90 index fafa198f7b..4b4b966dcb 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -52,9 +52,9 @@ contains ! Write version information write(UNIT=OUTPUT_UNIT, FMT=*) & - ' Copyright: 2011-2015 Massachusetts Institute of Technology' + ' Copyright: 2011-2016 Massachusetts Institute of Technology' write(UNIT=OUTPUT_UNIT, FMT=*) & - ' License: http://mit-crpg.github.io/openmc/license.html' + ' License: http://openmc.readthedocs.org/en/latest/license.html' write(UNIT=OUTPUT_UNIT, FMT='(6X,"Version:",8X,I1,".",I1,".",I1)') & VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE #ifdef GIT_SHA1 From 1e57cb84074c4d35500fcb9f027b203a20a546de Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 26 Apr 2016 07:08:03 -0500 Subject: [PATCH 8/8] Respond to @wbinventor comments on #632 --- examples/python/basic/build-xml.py | 4 +- examples/python/boxes/build-xml.py | 8 +- .../python/lattice/hexagonal/build-xml.py | 10 +- examples/python/lattice/nested/build-xml.py | 6 +- examples/python/lattice/simple/build-xml.py | 8 +- examples/python/pincell/build-xml.py | 6 +- .../python/pincell_multigroup/build-xml.py | 6 +- examples/python/reflective/build-xml.py | 4 +- openmc/executor.py | 5 +- openmc/material.py | 4 +- openmc/mgxs/library.py | 2 +- openmc/mgxs_library.py | 2 +- openmc/plots.py | 4 +- openmc/surface.py | 211 +++++++++--------- openmc/tallies.py | 4 +- 15 files changed, 146 insertions(+), 138 deletions(-) diff --git a/examples/python/basic/build-xml.py b/examples/python/basic/build-xml.py index 19737cf91f..05accbc5ed 100644 --- a/examples/python/basic/build-xml.py +++ b/examples/python/basic/build-xml.py @@ -74,7 +74,7 @@ cell1.fill = universe1 universe1.add_cells([cell2, cell3]) root.add_cells([cell1, cell4]) -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -124,7 +124,7 @@ third_tally = openmc.Tally(tally_id=3, name='third tally') third_tally.filters = [cell_filter, energy_filter, energyout_filter] third_tally.scores = ['scatter', 'nu-scatter', 'nu-fission'] -# Instantiate a Tallies object, register all Tallies, and export to XML +# Instantiate a Tallies collection, register all Tallies, and export to XML tallies_file = openmc.Tallies() tallies_file.add_tally(first_tally) tallies_file.add_tally(second_tally) diff --git a/examples/python/boxes/build-xml.py b/examples/python/boxes/build-xml.py index 196a10ca7b..318af22654 100644 --- a/examples/python/boxes/build-xml.py +++ b/examples/python/boxes/build-xml.py @@ -36,7 +36,7 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([fuel1, fuel2, moderator]) @@ -97,7 +97,7 @@ outer_box.fill = moderator root = openmc.Universe(universe_id=0, name='root universe') root.add_cells([inner_box, middle_box, outer_box]) -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -107,7 +107,7 @@ geometry.export_to_xml() # Exporting to OpenMC settings.xml File ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML +# Instantiate a Settings object, set all runtime parameters, and export to XML settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive @@ -129,7 +129,7 @@ plot.width = [20, 20] plot.pixels = [200, 200] plot.color = 'cell' -# Instantiate a Plots object, add Plot, and export to XML +# Instantiate a Plots collection, add Plot, and export to XML plot_file = openmc.Plots() plot_file.add_plot(plot) plot_file.export_to_xml() diff --git a/examples/python/lattice/hexagonal/build-xml.py b/examples/python/lattice/hexagonal/build-xml.py index a9d7f68991..04002faf2f 100644 --- a/examples/python/lattice/hexagonal/build-xml.py +++ b/examples/python/lattice/hexagonal/build-xml.py @@ -35,7 +35,7 @@ iron = openmc.Material(material_id=3, name='iron') iron.set_density('g/cc', 7.9) iron.add_nuclide(fe56, 1.) -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel, iron]) @@ -105,7 +105,7 @@ lattice.outer = univ2 # Fill Cell with the Lattice cell1.fill = lattice -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -115,7 +115,7 @@ geometry.export_to_xml() # Exporting to OpenMC settings.xml file ############################################################################### -# Instantiate a SettingsFile, set all runtime parameters, and export to XML +# Instantiate a Settings object, set all runtime parameters, and export to XML settings_file = openmc.Settings() settings_file.batches = batches settings_file.inactive = inactive @@ -151,7 +151,7 @@ plot_yz.width = [8, 8] plot_yz.pixels = [400, 400] plot_yz.color = 'mat' -# Instantiate a Plots object, add plots, and export to XML +# Instantiate a Plots collection, add plots, and export to XML plot_file = openmc.Plots() plot_file.add_plot(plot_xy) plot_file.add_plot(plot_yz) @@ -167,7 +167,7 @@ tally = openmc.Tally(tally_id=1) tally.filters = [openmc.Filter(type='distribcell', bins=[cell2.id])] tally.scores = ['total'] -# Instantiate a Tallies object, register Tally/Mesh, and export to XML +# Instantiate a Tallies collection, register Tally/Mesh, and export to XML tallies_file = openmc.Tallies() tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index eb16c83278..0e4e459e2e 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -30,7 +30,7 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel]) @@ -116,7 +116,7 @@ lattice2.universes = [[univ4, univ4], cell1.fill = lattice2 cell2.fill = lattice1 -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -176,7 +176,7 @@ tally = openmc.Tally(tally_id=1) tally.filters = [mesh_filter] tally.scores = ['total'] -# Instantiate a Tallies object, register Tally/Mesh, and export to XML +# Instantiate a Tallies collection, register Tally/Mesh, and export to XML tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index 6e44e4da0a..8d9481aaa5 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -30,7 +30,7 @@ moderator.add_nuclide(h1, 2.) moderator.add_nuclide(o16, 1.) moderator.add_s_alpha_beta('HH2O', '71t') -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([moderator, fuel]) @@ -106,7 +106,7 @@ lattice.universes = [[univ1, univ2, univ1, univ2], # Fill Cell with the Lattice cell1.fill = lattice -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -142,7 +142,7 @@ plot.width = [4, 4] plot.pixels = [400, 400] plot.color = 'mat' -# Instantiate a Plots object, add Plot, and export to XML +# Instantiate a Plots collection, add Plot, and export to XML plot_file = openmc.Plots() plot_file.add_plot(plot) plot_file.export_to_xml() @@ -173,7 +173,7 @@ tally.filters = [mesh_filter] tally.scores = ['total'] tally.triggers = [trigger] -# Instantiate a Tallies object, register Tally/Mesh, and export to XML +# Instantiate a Tallies collection, register Tally/Mesh, and export to XML tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 10cd4944d4..561df2b5a1 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -100,7 +100,7 @@ borated_water.add_nuclide(o16, 2.4672e-2) borated_water.add_nuclide(o17, 6.0099e-5) borated_water.add_s_alpha_beta('HH2O', '71t') -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_materials([uo2, helium, zircaloy, borated_water]) @@ -149,7 +149,7 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, gap, clad, water]) -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -197,7 +197,7 @@ tally = openmc.Tally(tally_id=1, name='tally 1') tally.filters = [energy_filter, mesh_filter] tally.scores = ['flux', 'fission', 'nu-fission'] -# Instantiate a Tallies object, register all Tallies, and export to XML +# Instantiate a Tallies collection, register all Tallies, and export to XML tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) diff --git a/examples/python/pincell_multigroup/build-xml.py b/examples/python/pincell_multigroup/build-xml.py index 2337281423..697a596d97 100644 --- a/examples/python/pincell_multigroup/build-xml.py +++ b/examples/python/pincell_multigroup/build-xml.py @@ -81,7 +81,7 @@ water = openmc.Material(material_id=2, name='Water') water.set_density('macro', 1.0) water.add_macroscopic(h2o_data) -# Instantiate a Materials object, register all Materials, and export to XML +# Instantiate a Materials collection, register all Materials, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '300K' materials_file.add_materials([uo2, water]) @@ -122,7 +122,7 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, moderator]) -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() @@ -173,7 +173,7 @@ tally.add_score('flux') tally.add_score('fission') tally.add_score('nu-fission') -# Instantiate a Tallies object, register all Tallies, and export to XML +# Instantiate a Tallies collection, register all Tallies, and export to XML tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) diff --git a/examples/python/reflective/build-xml.py b/examples/python/reflective/build-xml.py index 7d96e296da..e4776e7443 100644 --- a/examples/python/reflective/build-xml.py +++ b/examples/python/reflective/build-xml.py @@ -23,7 +23,7 @@ fuel = openmc.Material(material_id=1, name='fuel') fuel.set_density('g/cc', 4.5) fuel.add_nuclide(u235, 1.) -# Instantiate a Materials object, register Material, and export to XML +# Instantiate a Materials collection, register Material, and export to XML materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_material(fuel) @@ -64,7 +64,7 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cell with Universe root.add_cell(cell) -# Instantiate a Geometry and register the root Universe, and export to XML +# Instantiate a Geometry, register the root Universe, and export to XML geometry = openmc.Geometry() geometry.root_universe = root geometry.export_to_xml() diff --git a/openmc/executor.py b/openmc/executor.py index 9bb3477c50..edbbaddc40 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -54,7 +54,10 @@ def run(particles=None, threads=None, geometry_debug=False, particles : int, optional Number of particles to simulate per generation. threads : int, optional - Number of OpenMP threads. + Number of OpenMP threads. If OpenMC is compiled with OpenMP threading + enabled, the default is implementation-dependent but is usually equal to + the number of hardware threads available (or a value set by the + OMP_NUM_THREADS environment variable). geometry_debug : bool, optional Turn on geometry debugging during simulation. Defaults to False. restart_file : str, optional diff --git a/openmc/material.py b/openmc/material.py index 6b0a0f2468..c6030a8e67 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -643,8 +643,8 @@ class Material(object): class Materials(object): - """Materials used for an OpenMC simulation. Corresponds directly to the - materials.xml input file. + """Collection of Materials used for an OpenMC simulation. Corresponds directly + to the materials.xml input file. Attributes ---------- diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index ca7bf39cd8..8d5e9854ee 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -355,7 +355,7 @@ class Library(object): Parameters ---------- tallies_file : openmc.Tallies - A Tallies object to add each MGXS' tallies to generate a + A Tallies collection to add each MGXS' tallies to generate a "tallies.xml" input file for OpenMC merge : bool Indicate whether tallies should be merged when possible. Defaults diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index 8db3c84ff7..d3e49b238e 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -705,7 +705,7 @@ class MGXSLibrary(object): # Make sure energy groups match. if xsdata.energy_groups != self._energy_groups: - msg = 'Energy groups of XSdata do not match that of MGXSLibrary!' + msg = 'Energy groups of XSdata do not match that of MGXSLibrary.' raise ValueError(msg) self._xsdatas.append(xsdata) diff --git a/openmc/plots.py b/openmc/plots.py index ae34678bba..a967cb0604 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -402,8 +402,8 @@ class Plot(object): class Plots(object): - """Plots file used for an OpenMC simulation. Corresponds directly to the - plots.xml input file. + """Collection of Plots used for an OpenMC simulation. Corresponds directly to + the plots.xml input file. """ diff --git a/openmc/surface.py b/openmc/surface.py index c6f3f2cd0d..37e7c2ffdb 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -23,7 +23,11 @@ def reset_auto_surface_id(): class Surface(object): - """A two-dimensional surface with an associated boundary condition. + """An implicit surface with an associated boundary condition. + + An implicit surface is defined as the set of zeros of a function of the + three Cartesian coordinates. Surfaces in OpenMC are limited to a set of + algebraic surfaces, i.e., surfaces that are polynomial in x, y, and z. Parameters ---------- @@ -43,14 +47,14 @@ class Surface(object): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -63,7 +67,7 @@ class Surface(object): # A dictionary of the quadratic surface coefficients # Key - coefficeint name # Value - coefficient value - self._coeffs = {} + self._coefficients = {} # An ordered list of the coefficient names to export to XML in the # proper order @@ -82,12 +86,13 @@ class Surface(object): string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._boundary_type) - coeffs = '{0: <16}'.format('\tCoefficients') + '\n' + coefficients = '{0: <16}'.format('\tCoefficients') + '\n' - for coeff in self._coeffs: - coeffs += '{0: <16}{1}{2}\n'.format(coeff, '=\t', self._coeffs[coeff]) + for coeff in self._coefficients: + coefficients += '{0: <16}{1}{2}\n'.format( + coeff, '=\t', self._coefficients[coeff]) - string += coeffs + string += coefficients return string @@ -108,8 +113,8 @@ class Surface(object): return self._boundary_type @property - def coeffs(self): - return self._coeffs + def coefficients(self): + return self._coefficients @id.setter def id(self, surface_id): @@ -173,7 +178,7 @@ class Surface(object): element.set("type", self._type) if self.boundary_type != 'transmission': element.set("boundary", self.boundary_type) - element.set("coeffs", ' '.join([str(self._coeffs.setdefault(key, 0.0)) + element.set("coeffs", ' '.join([str(self._coefficients.setdefault(key, 0.0)) for key in self._coeff_keys])) return element @@ -215,14 +220,14 @@ class Plane(Surface): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -239,39 +244,39 @@ class Plane(Surface): @property def a(self): - return self.coeffs['A'] + return self.coefficients['A'] @property def b(self): - return self.coeffs['B'] + return self.coefficients['B'] @property def c(self): - return self.coeffs['C'] + return self.coefficients['C'] @property def d(self): - return self.coeffs['D'] + return self.coefficients['D'] @a.setter def a(self, A): check_type('A coefficient', A, Real) - self._coeffs['A'] = A + self._coefficients['A'] = A @b.setter def b(self, B): check_type('B coefficient', B, Real) - self._coeffs['B'] = B + self._coefficients['B'] = B @c.setter def c(self, C): check_type('C coefficient', C, Real) - self._coeffs['C'] = C + self._coefficients['C'] = C @d.setter def d(self, D): check_type('D coefficient', D, Real) - self._coeffs['D'] = D + self._coefficients['D'] = D class XPlane(Plane): @@ -298,14 +303,14 @@ class XPlane(Plane): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -319,12 +324,12 @@ class XPlane(Plane): @property def x0(self): - return self.coeffs['x0'] + return self.coefficients['x0'] @x0.setter def x0(self, x0): check_type('x0 coefficient', x0, Real) - self._coeffs['x0'] = x0 + self._coefficients['x0'] = x0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -382,14 +387,14 @@ class YPlane(Plane): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -404,12 +409,12 @@ class YPlane(Plane): @property def y0(self): - return self.coeffs['y0'] + return self.coefficients['y0'] @y0.setter def y0(self, y0): check_type('y0 coefficient', y0, Real) - self._coeffs['y0'] = y0 + self._coefficients['y0'] = y0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -467,14 +472,14 @@ class ZPlane(Plane): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -489,12 +494,12 @@ class ZPlane(Plane): @property def z0(self): - return self.coeffs['z0'] + return self.coefficients['z0'] @z0.setter def z0(self, z0): check_type('z0 coefficient', z0, Real) - self._coeffs['z0'] = z0 + self._coefficients['z0'] = z0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -553,14 +558,14 @@ class Cylinder(Surface): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -575,12 +580,12 @@ class Cylinder(Surface): @property def r(self): - return self.coeffs['R'] + return self.coefficients['R'] @r.setter def r(self, R): check_type('R coefficient', R, Real) - self._coeffs['R'] = R + self._coefficients['R'] = R class XCylinder(Cylinder): @@ -615,14 +620,14 @@ class XCylinder(Cylinder): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -637,21 +642,21 @@ class XCylinder(Cylinder): @property def y0(self): - return self.coeffs['y0'] + return self.coefficients['y0'] @property def z0(self): - return self.coeffs['z0'] + return self.coefficients['z0'] @y0.setter def y0(self, y0): check_type('y0 coefficient', y0, Real) - self._coeffs['y0'] = y0 + self._coefficients['y0'] = y0 @z0.setter def z0(self, z0): check_type('z0 coefficient', z0, Real) - self._coeffs['z0'] = z0 + self._coefficients['z0'] = z0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -718,14 +723,14 @@ class YCylinder(Cylinder): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -740,21 +745,21 @@ class YCylinder(Cylinder): @property def x0(self): - return self.coeffs['x0'] + return self.coefficients['x0'] @property def z0(self): - return self.coeffs['z0'] + return self.coefficients['z0'] @x0.setter def x0(self, x0): check_type('x0 coefficient', x0, Real) - self._coeffs['x0'] = x0 + self._coefficients['x0'] = x0 @z0.setter def z0(self, z0): check_type('z0 coefficient', z0, Real) - self._coeffs['z0'] = z0 + self._coefficients['z0'] = z0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -821,14 +826,14 @@ class ZCylinder(Cylinder): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -843,21 +848,21 @@ class ZCylinder(Cylinder): @property def x0(self): - return self.coeffs['x0'] + return self.coefficients['x0'] @property def y0(self): - return self.coeffs['y0'] + return self.coefficients['y0'] @x0.setter def x0(self, x0): check_type('x0 coefficient', x0, Real) - self._coeffs['x0'] = x0 + self._coefficients['x0'] = x0 @y0.setter def y0(self, y0): check_type('y0 coefficient', y0, Real) - self._coeffs['y0'] = y0 + self._coefficients['y0'] = y0 def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -928,14 +933,14 @@ class Sphere(Surface): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -952,39 +957,39 @@ class Sphere(Surface): @property def x0(self): - return self.coeffs['x0'] + return self.coefficients['x0'] @property def y0(self): - return self.coeffs['y0'] + return self.coefficients['y0'] @property def z0(self): - return self.coeffs['z0'] + return self.coefficients['z0'] @property def r(self): - return self.coeffs['R'] + return self.coefficients['R'] @x0.setter def x0(self, x0): check_type('x0 coefficient', x0, Real) - self._coeffs['x0'] = x0 + self._coefficients['x0'] = x0 @y0.setter def y0(self, y0): check_type('y0 coefficient', y0, Real) - self._coeffs['y0'] = y0 + self._coefficients['y0'] = y0 @z0.setter def z0(self, z0): check_type('z0 coefficient', z0, Real) - self._coeffs['z0'] = z0 + self._coefficients['z0'] = z0 @r.setter def r(self, R): check_type('R coefficient', R, Real) - self._coeffs['R'] = R + self._coefficients['R'] = R def bounding_box(self, side): """Determine an axis-aligned bounding box. @@ -1056,14 +1061,14 @@ class Cone(Surface): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -1081,39 +1086,39 @@ class Cone(Surface): @property def x0(self): - return self.coeffs['x0'] + return self.coefficients['x0'] @property def y0(self): - return self.coeffs['y0'] + return self.coefficients['y0'] @property def z0(self): - return self.coeffs['z0'] + return self.coefficients['z0'] @property def r2(self): - return self.coeffs['r2'] + return self.coefficients['r2'] @x0.setter def x0(self, x0): check_type('x0 coefficient', x0, Real) - self._coeffs['x0'] = x0 + self._coefficients['x0'] = x0 @y0.setter def y0(self, y0): check_type('y0 coefficient', y0, Real) - self._coeffs['y0'] = y0 + self._coefficients['y0'] = y0 @z0.setter def z0(self, z0): check_type('z0 coefficient', z0, Real) - self._coeffs['z0'] = z0 + self._coefficients['z0'] = z0 @r2.setter def r2(self, R2): check_type('R^2 coefficient', R2, Real) - self._coeffs['R2'] = R2 + self._coefficients['R2'] = R2 class XCone(Cone): @@ -1153,14 +1158,14 @@ class XCone(Cone): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -1209,14 +1214,14 @@ class YCone(Cone): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -1265,14 +1270,14 @@ class ZCone(Cone): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -1309,14 +1314,14 @@ class Quadric(Surface): boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'} Boundary condition that defines the behavior for particles hitting the surface. - coeffs : dict + coefficients : dict Dictionary of surface coefficients id : int Unique identifier for the surface name : str Name of the surface type : str - Type of the surface, e.g. 'x-plane' + Type of the surface """ @@ -1340,93 +1345,93 @@ class Quadric(Surface): @property def a(self): - return self.coeffs['a'] + return self.coefficients['a'] @property def b(self): - return self.coeffs['b'] + return self.coefficients['b'] @property def c(self): - return self.coeffs['c'] + return self.coefficients['c'] @property def d(self): - return self.coeffs['d'] + return self.coefficients['d'] @property def e(self): - return self.coeffs['e'] + return self.coefficients['e'] @property def f(self): - return self.coeffs['f'] + return self.coefficients['f'] @property def g(self): - return self.coeffs['g'] + return self.coefficients['g'] @property def h(self): - return self.coeffs['h'] + return self.coefficients['h'] @property def j(self): - return self.coeffs['j'] + return self.coefficients['j'] @property def k(self): - return self.coeffs['k'] + return self.coefficients['k'] @a.setter def a(self, a): check_type('a coefficient', a, Real) - self._coeffs['a'] = a + self._coefficients['a'] = a @b.setter def b(self, b): check_type('b coefficient', b, Real) - self._coeffs['b'] = b + self._coefficients['b'] = b @c.setter def c(self, c): check_type('c coefficient', c, Real) - self._coeffs['c'] = c + self._coefficients['c'] = c @d.setter def d(self, d): check_type('d coefficient', d, Real) - self._coeffs['d'] = d + self._coefficients['d'] = d @e.setter def e(self, e): check_type('e coefficient', e, Real) - self._coeffs['e'] = e + self._coefficients['e'] = e @f.setter def f(self, f): check_type('f coefficient', f, Real) - self._coeffs['f'] = f + self._coefficients['f'] = f @g.setter def g(self, g): check_type('g coefficient', g, Real) - self._coeffs['g'] = g + self._coefficients['g'] = g @h.setter def h(self, h): check_type('h coefficient', h, Real) - self._coeffs['h'] = h + self._coefficients['h'] = h @j.setter def j(self, j): check_type('j coefficient', j, Real) - self._coeffs['j'] = j + self._coefficients['j'] = j @k.setter def k(self, k): check_type('k coefficient', k, Real) - self._coeffs['k'] = k + self._coefficients['k'] = k class Halfspace(Region): diff --git a/openmc/tallies.py b/openmc/tallies.py index 1af3b12bc7..90b09f5828 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -3420,8 +3420,8 @@ class Tally(object): class Tallies(object): - """Tallies file used for an OpenMC simulation. Corresponds directly to the - tallies.xml input file. + """Collection of Tallies used for an OpenMC simulation. Corresponds directly to + the tallies.xml input file. """