From da5f7440b12b538f8469516a1548ead72b04857c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 8 Jun 2019 07:48:26 -0500 Subject: [PATCH] Remove get_ from get_hexagonal_prism, get_rectangular_prism --- docs/source/pythonapi/model.rst | 4 +-- examples/jupyter/expansion-filters.ipynb | 2 +- examples/jupyter/pincell.ipynb | 4 +-- openmc/__init__.py | 2 +- openmc/model/funcs.py | 31 ++++++++++++++++--- .../lattice_hex_coincident/test.py | 8 ++--- tests/regression_tests/lattice_hex_x/test.py | 8 ++--- tests/unit_tests/test_filters.py | 2 +- tests/unit_tests/test_geometry.py | 14 ++++----- 9 files changed, 49 insertions(+), 26 deletions(-) diff --git a/docs/source/pythonapi/model.rst b/docs/source/pythonapi/model.rst index 14f4a4beb..ee038987b 100644 --- a/docs/source/pythonapi/model.rst +++ b/docs/source/pythonapi/model.rst @@ -12,8 +12,8 @@ Convenience Functions openmc.model.borated_water openmc.model.cylinder_from_points - openmc.model.get_hexagonal_prism - openmc.model.get_rectangular_prism + openmc.model.hexagonal_prism + openmc.model.rectangular_prism openmc.model.subdivide TRISO Fuel Modeling diff --git a/examples/jupyter/expansion-filters.ipynb b/examples/jupyter/expansion-filters.ipynb index 7870faffe..69d315e24 100644 --- a/examples/jupyter/expansion-filters.ipynb +++ b/examples/jupyter/expansion-filters.ipynb @@ -62,7 +62,7 @@ "source": [ "# Define surfaces used to construct regions\n", "zmin, zmax = -10., 10.\n", - "box = openmc.model.get_rectangular_prism(10., 10., boundary_type='reflective')\n", + "box = openmc.model.rectangular_prism(10., 10., boundary_type='reflective')\n", "bottom = openmc.ZPlane(z0=zmin, boundary_type='vacuum')\n", "boron_lower = openmc.ZPlane(z0=-0.5)\n", "boron_upper = openmc.ZPlane(z0=0.5)\n", diff --git a/examples/jupyter/pincell.ipynb b/examples/jupyter/pincell.ipynb index 72b65a265..f8641db13 100644 --- a/examples/jupyter/pincell.ipynb +++ b/examples/jupyter/pincell.ipynb @@ -903,8 +903,8 @@ } ], "source": [ - "box = openmc.get_rectangular_prism(width=pitch, height=pitch,\n", - " boundary_type='reflective')\n", + "box = openmc.rectangular_prism(width=pitch, height=pitch,\n", + " boundary_type='reflective')\n", "type(box)" ] }, diff --git a/openmc/__init__.py b/openmc/__init__.py index 715550302..1661c4ac4 100644 --- a/openmc/__init__.py +++ b/openmc/__init__.py @@ -32,6 +32,6 @@ from openmc.polynomial import * from . import examples # Import a few convencience functions that used to be here -from openmc.model import get_rectangular_prism, get_hexagonal_prism +from openmc.model import rectangular_prism, hexagonal_prism __version__ = '0.10.0' diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py index 5f2db4d30..143033eca 100644 --- a/openmc/model/funcs.py +++ b/openmc/model/funcs.py @@ -3,6 +3,7 @@ from collections.abc import Iterable from math import sqrt from numbers import Real from functools import partial +from warnings import warn from openmc import XPlane, YPlane, Plane, ZCylinder, Quadric from openmc.checkvalue import check_type, check_value @@ -101,10 +102,14 @@ def borated_water(boron_ppm, temperature=293., pressure=0.1013, temp_unit='K', return out -def get_rectangular_prism(width, height, axis='z', origin=(0., 0.), - boundary_type='transmission', corner_radius=0.): +def rectangular_prism(width, height, axis='z', origin=(0., 0.), + boundary_type='transmission', corner_radius=0.): """Get an infinite rectangular prism from four planar surfaces. + .. versionchanged:: 0.11 + This function was renamed from `get_rectangular_prism` to + `rectangular_prism`. + Parameters ---------- width: float @@ -202,10 +207,21 @@ def get_rectangular_prism(width, height, axis='z', origin=(0., 0.), return prism -def get_hexagonal_prism(edge_length=1., orientation='y', origin=(0., 0.), - boundary_type='transmission', corner_radius=0.): +def get_rectangular_prism(*args, **kwargs): + warn("get_rectangular_prism(...) has been renamed rectangular_prism(...). " + "Future versions of OpenMC will not accept get_rectangular_prism.", + FutureWarning) + return rectangular_prism(*args, **kwargs) + + +def hexagonal_prism(edge_length=1., orientation='y', origin=(0., 0.), + boundary_type='transmission', corner_radius=0.): """Create a hexagon region from six surface planes. + .. versionchanged:: 0.11 + This function was renamed from `get_hexagonal_prism` to + `hexagonal_prism`. + Parameters ---------- edge_length : float @@ -346,6 +362,13 @@ def get_hexagonal_prism(edge_length=1., orientation='y', origin=(0., 0.), return prism +def get_hexagonal_prism(*args, **kwargs): + warn("get_hexagonal_prism(...) has been renamed hexagonal_prism(...). " + "Future versions of OpenMC will not accept get_hexagonal_prism.", + FutureWarning) + return hexagonal_prism(*args, **kwargs) + + def cylinder_from_points(p1, p2, r, **kwargs): """Return cylinder defined by two points passing through its center. diff --git a/tests/regression_tests/lattice_hex_coincident/test.py b/tests/regression_tests/lattice_hex_coincident/test.py index eaea74b19..30bc470f2 100644 --- a/tests/regression_tests/lattice_hex_coincident/test.py +++ b/tests/regression_tests/lattice_hex_coincident/test.py @@ -103,10 +103,10 @@ class HexLatticeCoincidentTestHarness(PyAPITestHarness): inf_mat_univ = openmc.Universe(cells=[inf_mat,]) # a hex surface for the core to go inside of - hexprism = openmc.model.get_hexagonal_prism(edge_length=edge_length, - origin=(0.0, 0.0), - boundary_type = 'reflective', - orientation='x') + hexprism = openmc.model.hexagonal_prism(edge_length=edge_length, + origin=(0.0, 0.0), + boundary_type = 'reflective', + orientation='x') pincell_only_lattice = openmc.HexLattice(name="regular fuel assembly") pincell_only_lattice.center = (0., 0.) diff --git a/tests/regression_tests/lattice_hex_x/test.py b/tests/regression_tests/lattice_hex_x/test.py index 538f790da..ecb27c9c2 100644 --- a/tests/regression_tests/lattice_hex_x/test.py +++ b/tests/regression_tests/lattice_hex_x/test.py @@ -139,10 +139,10 @@ class HexLatticeOXTestHarness(PyAPITestHarness): # a hex surface for the core to go inside of - hexprism = openmc.model.get_hexagonal_prism(edge_length=edge_length, - origin=(0.0, 0.0), - boundary_type='reflective', - orientation='x') + hexprism = openmc.model.hexagonal_prism(edge_length=edge_length, + origin=(0.0, 0.0), + boundary_type='reflective', + orientation='x') region = hexprism & +fuel_bottom & -fuel_top inf_mat = openmc.Cell(cell_id=12) diff --git a/tests/unit_tests/test_filters.py b/tests/unit_tests/test_filters.py index 5817c4c3d..676ee452e 100644 --- a/tests/unit_tests/test_filters.py +++ b/tests/unit_tests/test_filters.py @@ -11,7 +11,7 @@ def box_model(): m.add_nuclide('U235', 1.0) m.set_density('g/cm3', 1.0) - box = openmc.model.get_rectangular_prism(10., 10., boundary_type='vacuum') + box = openmc.model.rectangular_prism(10., 10., boundary_type='vacuum') c = openmc.Cell(fill=m, region=box) model.geometry.root_universe = openmc.Universe(cells=[c]) diff --git a/tests/unit_tests/test_geometry.py b/tests/unit_tests/test_geometry.py index f3718630a..69211f72e 100644 --- a/tests/unit_tests/test_geometry.py +++ b/tests/unit_tests/test_geometry.py @@ -204,9 +204,9 @@ def test_get_by_name(): def test_hex_prism(): - hex_prism = openmc.model.get_hexagonal_prism(edge_length=5.0, - origin=(0.0, 0.0), - orientation='y') + hex_prism = openmc.model.hexagonal_prism(edge_length=5.0, + origin=(0.0, 0.0), + orientation='y') # clear checks assert (0.0, 0.0, 0.0) in hex_prism assert (10.0, 10.0, 10.0) not in hex_prism @@ -214,10 +214,10 @@ def test_hex_prism(): assert (0.0, 5.01, 0.0) not in hex_prism assert (0.0, 4.99, 0.0) in hex_prism - rounded_hex_prism = openmc.model.get_hexagonal_prism(edge_length=5.0, - origin=(0.0, 0.0), - orientation='y', - corner_radius=1.0) + rounded_hex_prism = openmc.model.hexagonal_prism(edge_length=5.0, + origin=(0.0, 0.0), + orientation='y', + corner_radius=1.0) # clear checks assert (0.0, 0.0, 0.0) in rounded_hex_prism