From 148e01eec0c3b5d91fb5b1511fa28c8405a542b1 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 15 Jan 2016 06:29:41 -0600 Subject: [PATCH] Address more comments on pull request #556. --- .../pythonapi/examples/mgxs-part-i.ipynb | 4 +- .../pythonapi/examples/mgxs-part-ii.ipynb | 4 +- .../pythonapi/examples/mgxs-part-iii.ipynb | 4 +- .../examples/pandas-dataframes.ipynb | 4 +- .../pythonapi/examples/post-processing.ipynb | 4 +- .../pythonapi/examples/tally-arithmetic.ipynb | 4 +- docs/source/usersguide/input.rst | 2 +- examples/python/basic/build-xml.py | 4 +- examples/python/boxes/build-xml.py | 4 +- .../python/lattice/hexagonal/build-xml.py | 4 +- examples/python/lattice/nested/build-xml.py | 4 +- examples/python/lattice/simple/build-xml.py | 4 +- examples/python/pincell/build-xml.py | 4 +- examples/python/reflective/build-xml.py | 4 +- openmc/source.py | 4 +- openmc/stats/multivariate.py | 117 +++++------------- openmc/stats/univariate.py | 78 ++++-------- tests/input_set.py | 4 +- tests/test_distribmat/test_distribmat.py | 4 +- tests/test_source/test_source.py | 6 +- 20 files changed, 86 insertions(+), 181 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-i.ipynb b/docs/source/pythonapi/examples/mgxs-part-i.ipynb index 8b08fea2f..94deeec7b 100644 --- a/docs/source/pythonapi/examples/mgxs-part-i.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-i.ipynb @@ -147,7 +147,7 @@ "import openmc\n", "import openmc.mgxs as mgxs\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "\n", "%matplotlib inline" ] @@ -343,7 +343,7 @@ "settings_file.particles = particles\n", "settings_file.output = {'tallies': True, 'summary': True}\n", "bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n", - "settings_file.source = Source(space=SpatialBox(\n", + "settings_file.source = Source(space=Box(\n", " bounds[:3], bounds[3:], only_fissionable=True))\n", "\n", "# Export to \"settings.xml\"\n", diff --git a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb index 9677acf56..b41b32241 100644 --- a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb @@ -53,7 +53,7 @@ "import openmc\n", "import openmc.mgxs as mgxs\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "import openmoc\n", "from openmoc.compatible import get_openmoc_geometry\n", "import pyne.ace\n", @@ -288,7 +288,7 @@ "settings_file.particles = particles\n", "settings_file.output = {'tallies': True, 'summary': True}\n", "bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n", - "settings_file.source = Source(space=SpatialBox(\n", + "settings_file.source = Source(space=Box(\n", " bounds[:3], bounds[3:], only_fissionable=True))\n", "\n", "# Activate tally precision triggers\n", diff --git a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb index 8be69abda..119fd0b56 100644 --- a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb @@ -53,7 +53,7 @@ "from openmc.statepoint import StatePoint\n", "from openmc.summary import Summary\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "\n", "import openmoc\n", "import openmoc.process\n", @@ -394,7 +394,7 @@ "settings_file.particles = particles\n", "settings_file.output = {'tallies': False, 'summary': True}\n", "source_bounds = [-10.71, -10.71, -10, 10.71, 10.71, 10.]\n", - "settings_file.source = Source(SpatialBox(\n", + "settings_file.source = Source(Box(\n", " source_bounds[:3], source_bounds[3:], only_fissionable=True))\n", "\n", "# Export to \"settings.xml\"\n", diff --git a/docs/source/pythonapi/examples/pandas-dataframes.ipynb b/docs/source/pythonapi/examples/pandas-dataframes.ipynb index 70c00b339..60c2c1c40 100644 --- a/docs/source/pythonapi/examples/pandas-dataframes.ipynb +++ b/docs/source/pythonapi/examples/pandas-dataframes.ipynb @@ -27,7 +27,7 @@ "from openmc.statepoint import StatePoint\n", "from openmc.summary import Summary\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "\n", "%matplotlib inline" ] @@ -306,7 +306,7 @@ "settings_file.trigger_active = True\n", "settings_file.trigger_max_batches = max_batches\n", "source_bounds = [-10.71, -10.71, -10, 10.71, 10.71, 10.]\n", - "settings_file.source = Source(space=SpatialBox(\n", + "settings_file.source = Source(space=Box(\n", " source_bounds[:3], source_bounds[3:]))\n", "\n", "# Export to \"settings.xml\"\n", diff --git a/docs/source/pythonapi/examples/post-processing.ipynb b/docs/source/pythonapi/examples/post-processing.ipynb index a2e8ebd36..7fbca6864 100644 --- a/docs/source/pythonapi/examples/post-processing.ipynb +++ b/docs/source/pythonapi/examples/post-processing.ipynb @@ -22,7 +22,7 @@ "import openmc\n", "from openmc.statepoint import StatePoint\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "\n", "%matplotlib inline" ] @@ -274,7 +274,7 @@ "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", "source_bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n", - "settings_file.source = Source(space=SpatialBox(\n", + "settings_file.source = Source(space=Box(\n", " source_bounds[:3], source_bounds[3:]))\n", "\n", "# Export to \"settings.xml\"\n", diff --git a/docs/source/pythonapi/examples/tally-arithmetic.ipynb b/docs/source/pythonapi/examples/tally-arithmetic.ipynb index de6b3c6a5..87cdc9b66 100644 --- a/docs/source/pythonapi/examples/tally-arithmetic.ipynb +++ b/docs/source/pythonapi/examples/tally-arithmetic.ipynb @@ -37,7 +37,7 @@ "from openmc.statepoint import StatePoint\n", "from openmc.summary import Summary\n", "from openmc.source import Source\n", - "from openmc.stats import SpatialBox\n", + "from openmc.stats import Box\n", "\n", "%matplotlib inline" ] @@ -290,7 +290,7 @@ "settings_file.particles = particles\n", "settings_file.output = {'tallies': True, 'summary': True}\n", "source_bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n", - "settings_file.source = Source(space=SpatialBox(\n", + "settings_file.source = Source(space=Box(\n", " source_bounds[:3], source_bounds[3:]))\n", "\n", "# Export to \"settings.xml\"\n", diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 2c14cf7f8..2eb5262df 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -469,7 +469,7 @@ attributes/sub-elements: three real numbers which specify the (x,y,z) location of an isotropic point source. - For an "independent" distributoin, no parameters are specified. Instead, + For an "independent" distribution, no parameters are specified. Instead, the ``x``, ``y``, and ``z`` elements must be specified. *Default*: None diff --git a/examples/python/basic/build-xml.py b/examples/python/basic/build-xml.py index adb790268..97591c992 100644 --- a/examples/python/basic/build-xml.py +++ b/examples/python/basic/build-xml.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -94,7 +94,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox([-4, -4, -4], [4, 4, 4])) +settings_file.source = Source(space=Box([-4, -4, -4], [4, 4, 4])) settings_file.export_to_xml() diff --git a/examples/python/boxes/build-xml.py b/examples/python/boxes/build-xml.py index 7debc87a1..2ae3ee612 100644 --- a/examples/python/boxes/build-xml.py +++ b/examples/python/boxes/build-xml.py @@ -2,7 +2,7 @@ import numpy as np import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -119,7 +119,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox(*outer_cube.bounding_box)) +settings_file.source = Source(space=Box(*outer_cube.bounding_box)) settings_file.export_to_xml() ############################################################################### diff --git a/examples/python/lattice/hexagonal/build-xml.py b/examples/python/lattice/hexagonal/build-xml.py index 0dc8108b5..1125e8ce0 100644 --- a/examples/python/lattice/hexagonal/build-xml.py +++ b/examples/python/lattice/hexagonal/build-xml.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -126,7 +126,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox( +settings_file.source = Source(space=Box( [-1, -1, -1], [1, 1, 1])) settings_file.keff_trigger = {'type' : 'std_dev', 'threshold' : 5E-4} settings_file.trigger_active = True diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index b4a9d199d..389af8e9b 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -137,7 +137,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox( +settings_file.source = Source(space=Box( [-1, -1, -1], [1, 1, 1])) settings_file.export_to_xml() diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index 26c19e971..e648c3d5b 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -127,7 +127,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox( +settings_file.source = Source(space=Box( [-1, -1, -1], [1, 1, 1])) settings_file.trigger_active = True settings_file.trigger_max_batches = 100 diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index c08756ae5..ca71b04e5 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box ############################################################################### # Simulation Input File Parameters @@ -170,7 +170,7 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox( +settings_file.source = Source(space=Box( [-0.62992, -0.62992, -1], [0.62992, 0.62992, 1])) settings_file.entropy_lower_left = [-0.39218, -0.39218, -1.e50] settings_file.entropy_upper_right = [0.39218, 0.39218, 1.e50] diff --git a/examples/python/reflective/build-xml.py b/examples/python/reflective/build-xml.py index 73d07cbb6..7e4fd30be 100644 --- a/examples/python/reflective/build-xml.py +++ b/examples/python/reflective/build-xml.py @@ -1,7 +1,7 @@ import numpy as np import openmc -from openmc.stats import SpatialBox +from openmc.stats import Box from openmc.source import Source ############################################################################### @@ -86,5 +86,5 @@ settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles -settings_file.source = Source(space=SpatialBox(*cell.region.bounding_box)) +settings_file.source = Source(space=Box(*cell.region.bounding_box)) settings_file.export_to_xml() diff --git a/openmc/source.py b/openmc/source.py index 5e4d9e53d..36a36e594 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -95,8 +95,6 @@ class Source(object): @energy.setter def energy(self, energy): cv.check_type('energy distribution', energy, Univariate) - if energy.name is None: - energy.name = 'energy' self._energy = energy @strength.setter @@ -115,5 +113,5 @@ class Source(object): if self.angle is not None: element.append(self.angle.to_xml()) if self.energy is not None: - element.append(self.energy.to_xml()) + element.append(self.energy.to_xml('energy')) return element diff --git a/openmc/stats/multivariate.py b/openmc/stats/multivariate.py index ea02d7f3f..f7da5da3f 100644 --- a/openmc/stats/multivariate.py +++ b/openmc/stats/multivariate.py @@ -23,15 +23,11 @@ class UnitSphere(object): Parameters ---------- - name : str - Name of the distribution reference_uvw : Iterable of Real Direction from which polar angle is measured Attributes ---------- - name : str - Name of the distribution reference_uvw : Iterable of Real Direction from which polar angle is measured @@ -39,25 +35,15 @@ class UnitSphere(object): __metaclass__ = ABCMeta - def __init__(self, name, reference_uvw=None): - self.name = name + def __init__(self, reference_uvw=None): self._reference_uvw = None if reference_uvw is not None: self.reference_uvw = reference_uvw - @property - def name(self): - return self._name - @property def reference_uvw(self): return self._reference_uvw - @name.setter - def name(self, name): - cv.check_type('name', name, basestring) - self._name = name - @reference_uvw.setter def reference_uvw(self, uvw): cv.check_type('reference direction', uvw, Iterable, Real) @@ -81,8 +67,6 @@ class PolarAzimuthal(UnitSphere): Distribution of the cosine of the polar angle phi : openmc.stats.Univariate Distribution of the azimuthal angle in radians - name : str, optional - Name of the distribution. Defaults to 'angle'. reference_uvw : Iterable of Real Direction from which polar angle is measured. Defaults to the positive z-direction. @@ -96,9 +80,8 @@ class PolarAzimuthal(UnitSphere): """ - def __init__(self, mu=None, phi=None, name='angle', - reference_uvw=[0., 0., 1.]): - super(PolarAzimuthal, self).__init__(name, reference_uvw) + def __init__(self, mu=None, phi=None, reference_uvw=[0., 0., 1.]): + super(PolarAzimuthal, self).__init__(reference_uvw) if mu is not None: self.mu = mu else: @@ -120,42 +103,33 @@ class PolarAzimuthal(UnitSphere): @mu.setter def mu(self, mu): cv.check_type('cosine of polar angle', mu, Univariate) - if mu.name is None: - mu.name = 'mu' self._mu = mu @phi.setter def phi(self, phi): cv.check_type('azimuthal angle', phi, Univariate) - if phi.name is None: - phi.name = 'phi' self._phi = phi def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('angle') element.set("type", "mu-phi") if self.reference_uvw is not None: element.set("reference_uvw", ' '.join(map(str, self.reference_uvw))) - element.append(self.mu.to_xml()) - element.append(self.phi.to_xml()) + element.append(self.mu.to_xml('mu')) + element.append(self.phi.to_xml('phi')) return element class Isotropic(UnitSphere): """Isotropic angular distribution. - Parameters - ---------- - name : str, optional - Name of the distribution. Defaults to 'angle'. - """ - def __init__(self, name='angle'): - super(Isotropic, self).__init__(name) + def __init__(self): + super(Isotropic, self).__init__() def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('angle') element.set("type", "isotropic") return element @@ -169,8 +143,6 @@ class Monodirectional(UnitSphere): Parameters ---------- - name : str, optional - Name of the distribution. Defaults to 'angle'. reference_uvw : Iterable of Real Direction from which polar angle is measured. Defaults to the positive x-direction. @@ -178,11 +150,11 @@ class Monodirectional(UnitSphere): """ - def __init__(self, name='angle', reference_uvw=[1., 0., 0.]): - super(Monodirectional, self).__init__(name, reference_uvw) + def __init__(self, reference_uvw=[1., 0., 0.]): + super(Monodirectional, self).__init__(reference_uvw) def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('angle') element.set("type", "monodirectional") if self.reference_uvw is not None: element.set("reference_uvw", ' '.join(map(str, self.reference_uvw))) @@ -195,38 +167,19 @@ class Spatial(object): Classes derived from this abstract class can be used for spatial distributions of source sites. - Parameters - ---------- - name : str - Name of the distribution - - Attributes - ---------- - name : str - Name of the distribution - """ __metaclass__ = ABCMeta - def __init__(self, name): - self.name = name - - @property - def name(self): - return self._name - - @name.setter - def name(self, name): - cv.check_type('name', name, basestring) - self._name = name + def __init__(self): + pass @abstractmethod def to_xml(self): return '' -class SpatialIndependent(Spatial): +class CartesianIndependent(Spatial): """Spatial distribution with independent x, y, and z distributions. This distribution allows one to specify a coordinates whose x-, y-, and z- @@ -240,8 +193,6 @@ class SpatialIndependent(Spatial): Distribution of y-coordinates z : openmc.stats.Univariate Distribution of z-coordinates - name : str - Name of the distribution Attributes ---------- @@ -255,8 +206,8 @@ class SpatialIndependent(Spatial): """ - def __init__(self, x, y, z, name='space'): - super(SpatialIndependent, self).__init__(name) + def __init__(self, x, y, z): + super(CartesianIndependent, self).__init__() self.x = x self.y = y self.z = z @@ -276,34 +227,28 @@ class SpatialIndependent(Spatial): @x.setter def x(self, x): cv.check_type('x coordinate', x, Univariate) - if x.name is None: - x.name = 'x' self._x = x @y.setter def y(self, y): cv.check_type('y coordinate', y, Univariate) - if y.name is None: - y.name = 'y' self._y = y @z.setter def z(self, z): cv.check_type('z coordinate', z, Univariate) - if z.name is None: - z.name = 'z' self._z = z def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('space') element.set("type", "independent") - element.append(self.x.to_xml()) - element.append(self.y.to_xml()) - element.append(self.z.to_xml()) + element.append(self.x.to_xml('x')) + element.append(self.y.to_xml('y')) + element.append(self.z.to_xml('z')) return element -class SpatialBox(Spatial): +class Box(Spatial): """Uniform distribution of coordinates in a rectangular cuboid. Parameters @@ -312,8 +257,6 @@ class SpatialBox(Spatial): Lower-left coordinates of cuboid upper_right : Iterable of Real Upper-right coordinates of cuboid - name : str, optional - Name of the distribution only_fissionable : bool, optional Whether spatial sites should only be accepted if they occur in fissionable materials @@ -331,8 +274,8 @@ class SpatialBox(Spatial): """ - def __init__(self, lower_left, upper_right, name='space', only_fissionable=False): - super(SpatialBox, self).__init__(name) + def __init__(self, lower_left, upper_right, only_fissionable=False): + super(Box, self).__init__() self.lower_left = lower_left self.upper_right = upper_right self.only_fissionable = only_fissionable @@ -367,7 +310,7 @@ class SpatialBox(Spatial): self._only_fissionable = only_fissionable def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('space') if self.only_fissionable: element.set("type", "fission") else: @@ -378,7 +321,7 @@ class SpatialBox(Spatial): return element -class SpatialPoint(Spatial): +class Point(Spatial): """Delta function in three dimensions. This spatial distribution can be used for a point source where sites are @@ -388,8 +331,6 @@ class SpatialPoint(Spatial): ---------- xyz : Iterable of Real Cartesian coordinates of location - name : str, optional - Name of the distribution Attributes ---------- @@ -398,8 +339,8 @@ class SpatialPoint(Spatial): """ - def __init__(self, xyz, name='space'): - super(SpatialPoint, self).__init__(name) + def __init__(self, xyz): + super(Point, self).__init__() self.xyz = xyz @property @@ -413,7 +354,7 @@ class SpatialPoint(Spatial): self._xyz = xyz def to_xml(self): - element = ET.Element(self.name) + element = ET.Element('space') element.set("type", "point") params = ET.SubElement(element, "parameters") params.text = ' '.join(map(str, self.xyz)) diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index 01419420e..04e70bd00 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -16,33 +16,12 @@ class Univariate(object): The Univariate class is an abstract class that can be derived to implement a specific probability distribution. - Parameters - ---------- - name : str - Name of the distribution - - Attributes - ---------- - name : str - Name of the distributions - """ __metaclass__ = ABCMeta - def __init__(self, name=None): - self._name = None - if name is not None: - self.name = name - - @property - def name(self): - return self._name - - @name.setter - def name(self, name): - cv.check_type('name', name, basestring) - self._name = name + def __init__(self): + pass @abstractmethod def to_xml(self): @@ -72,8 +51,8 @@ class Discrete(Univariate): """ - def __init__(self, x, p, name=None): - super(Discrete, self).__init__(name) + def __init__(self, x, p): + super(Discrete, self).__init__() self.x = x self.p = p @@ -101,11 +80,8 @@ class Discrete(Univariate): cv.check_greater_than('discrete probability', pk, 0.0, True) self._p = p - def to_xml(self): - if self.name is not None: - element = ET.Element(self.name) - else: - element = ET.Element('distribution') + def to_xml(self, element_name): + element = ET.Element(element_name) element.set("type", "discrete") params = ET.SubElement(element, "parameters") @@ -133,8 +109,8 @@ class Uniform(Univariate): """ - def __init__(self, a=0.0, b=1.0, name=None): - super(Uniform, self).__init__(name) + def __init__(self, a=0.0, b=1.0): + super(Uniform, self).__init__() self.a = a self.b = b @@ -156,11 +132,8 @@ class Uniform(Univariate): cv.check_type('Uniform b', b, Real) self._b = b - def to_xml(self): - if self.name is not None: - element = ET.Element(self.name) - else: - element = ET.Element('distribution') + def to_xml(self, element_name): + element = ET.Element(element_name) element.set("type", "uniform") element.set("parameters", '{} {}'.format(self.a, self.b)) return element @@ -185,8 +158,8 @@ class Maxwell(Univariate): """ - def __init__(self, theta, name='energy'): - super(Maxwell, self).__init__(name) + def __init__(self, theta): + super(Maxwell, self).__init__() self.theta = theta @property @@ -199,8 +172,8 @@ class Maxwell(Univariate): cv.check_greater_than('Maxwell temperature', theta, 0.0) self._theta = theta - def to_xml(self): - element = ET.Element(self.name) + def to_xml(self, element_name): + element = ET.Element(element_name) element.set("type", "maxwell") element.set("parameters", str(self.theta)) return element @@ -219,8 +192,6 @@ class Watt(Univariate): First parameter of distribution b : float Second parameter of distribution - name : str, optional - Name of the distribution. Defaults to 'energy'. Attributes ---------- @@ -231,8 +202,8 @@ class Watt(Univariate): """ - def __init__(self, a=0.988, b=2.249, name='energy'): - super(Watt, self).__init__(name) + def __init__(self, a=0.988, b=2.249): + super(Watt, self).__init__() self.a = a self.b = b @@ -256,8 +227,8 @@ class Watt(Univariate): cv.check_greater_than('Watt b', b, 0.0) self._b = b - def to_xml(self): - element = ET.Element(self.name) + def to_xml(self, element_name): + element = ET.Element(element_name) element.set("type", "watt") element.set("parameters", '{} {}'.format(self.a, self.b)) return element @@ -272,8 +243,6 @@ class Tabular(Univariate): Parameters ---------- - name : str - Name of the distribution x : Iterable of Real Tabulated values of the random variable p : Iterable of Real @@ -294,8 +263,8 @@ class Tabular(Univariate): """ - def __init__(self, x, p, interpolation='linear-linear', name=None): - super(Tabular, self).__init__(name) + def __init__(self, x, p, interpolation='linear-linear'): + super(Tabular, self).__init__() self.x = x self.p = p self.interpolation = interpolation @@ -330,11 +299,8 @@ class Tabular(Univariate): ['linear-linear', 'histogram']) self._interpolation = interpolation - def to_xml(self): - if self.name is not None: - element = ET.Element(self.name) - else: - element = ET.Element('distribution') + def to_xml(self, element_name): + element = ET.Element(element_name) element.set("type", "tabular") element.set("interpolation", self.interpolation) diff --git a/tests/input_set.py b/tests/input_set.py index 46058f41b..c13a4f9cc 100644 --- a/tests/input_set.py +++ b/tests/input_set.py @@ -1,6 +1,6 @@ import openmc from openmc.source import Source -from openmc.stats import SpatialBox +from openmc.stats import Box class InputSet(object): @@ -560,7 +560,7 @@ class InputSet(object): self.settings.batches = 10 self.settings.inactive = 5 self.settings.particles = 100 - self.settings.source = Source(space=SpatialBox( + self.settings.source = Source(space=Box( [-160, -160, -183], [160, 160, 183])) def build_defualt_plots(self): diff --git a/tests/test_distribmat/test_distribmat.py b/tests/test_distribmat/test_distribmat.py index a4394745b..a0608c108 100644 --- a/tests/test_distribmat/test_distribmat.py +++ b/tests/test_distribmat/test_distribmat.py @@ -5,7 +5,7 @@ import sys sys.path.insert(0, os.pardir) from testing_harness import TestHarness, PyAPITestHarness import openmc -from openmc.stats import SpatialBox +from openmc.stats import Box from openmc.source import Source @@ -87,7 +87,7 @@ class DistribmatTestHarness(PyAPITestHarness): sets_file.batches = 5 sets_file.inactive = 0 sets_file.particles = 1000 - sets_file.source = Source(space=SpatialBox([-1, -1, -1], [1, 1, 1])) + sets_file.source = Source(space=Box([-1, -1, -1], [1, 1, 1])) sets_file.output = {'summary': True} sets_file.export_to_xml() diff --git a/tests/test_source/test_source.py b/tests/test_source/test_source.py index e2451ba3f..9d303b06b 100644 --- a/tests/test_source/test_source.py +++ b/tests/test_source/test_source.py @@ -39,9 +39,9 @@ class SourceTestHarness(PyAPITestHarness): x_dist = openmc.stats.Uniform(-3., 3.) y_dist = openmc.stats.Discrete([-4., -1., 3.], [0.2, 0.3, 0.5]) z_dist = openmc.stats.Tabular([-2., 0., 2.], [0.2, 0.3, 0.2]) - spatial1 = openmc.stats.SpatialIndependent(x_dist, y_dist, z_dist) - spatial2 = openmc.stats.SpatialBox([-4., -4., -4.], [4., 4., 4.]) - spatial3 = openmc.stats.SpatialPoint([1.2, -2.3, 0.781]) + spatial1 = openmc.stats.CartesianIndependent(x_dist, y_dist, z_dist) + spatial2 = openmc.stats.Box([-4., -4., -4.], [4., 4., 4.]) + spatial3 = openmc.stats.Point([1.2, -2.3, 0.781]) mu_dist = openmc.stats.Discrete([-1., 0., 1.], [0.5, 0.25, 0.25]) phi_dist = openmc.stats.Uniform(0., 6.28318530718)