From 758d9b45d508170f297015851c3268b54c07c20e Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 7 Mar 2019 22:20:50 -0600 Subject: [PATCH 1/2] Adding functools partial to model.funcs. Adding a quick test for the hexagonal prism. --- openmc/model/funcs.py | 1 + tests/unit_tests/test_geometry.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py index e974f93b1b..60fbbee907 100644 --- a/openmc/model/funcs.py +++ b/openmc/model/funcs.py @@ -2,6 +2,7 @@ from collections import OrderedDict from collections.abc import Iterable from math import sqrt from numbers import Real +from functools import partial from openmc import XPlane, YPlane, Plane, ZCylinder from openmc.checkvalue import check_type, check_value diff --git a/tests/unit_tests/test_geometry.py b/tests/unit_tests/test_geometry.py index b5d6076bb3..2c9306cb90 100644 --- a/tests/unit_tests/test_geometry.py +++ b/tests/unit_tests/test_geometry.py @@ -203,6 +203,19 @@ def test_get_by_name(): assert not univs +def test_hex_prism(): + hex_prism = openmc.model.get_hexagonal_prism(edge_length=5.0, + origin=(0.0, 0.0), + boundary_type='reflective', + orientation='y', + corner_radius=0.10) + + hex_prism = openmc.model.get_hexagonal_prism(edge_length=5.0, + origin=(0.0, 0.0), + boundary_type='reflective', + orientation='y') + + def test_get_lattice_by_name(cell_with_lattice): cells, _, _, lattice = cell_with_lattice geom = openmc.Geometry([cells[-1]]) @@ -245,6 +258,7 @@ def test_determine_paths(cell_with_lattice): assert geom.get_instances(cells[0].paths[i]) == i assert geom.get_instances(mats[-1].paths[i]) == i + def test_from_xml(run_in_tmpdir, mixed_lattice_model): # Export model mixed_lattice_model.export_to_xml() From e1aa836ea6e301da54bb68a73382d61845796bf9 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 8 Mar 2019 14:45:33 -0600 Subject: [PATCH 2/2] Adding some point checks for the hex prism test and removing import from surfae.py. --- openmc/surface.py | 1 - tests/unit_tests/test_geometry.py | 25 ++++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/openmc/surface.py b/openmc/surface.py index c861880c56..1776fc10cf 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -1,7 +1,6 @@ from abc import ABCMeta from collections import OrderedDict from copy import deepcopy -from functools import partial from numbers import Real, Integral from xml.etree import ElementTree as ET diff --git a/tests/unit_tests/test_geometry.py b/tests/unit_tests/test_geometry.py index 2c9306cb90..2068c9883f 100644 --- a/tests/unit_tests/test_geometry.py +++ b/tests/unit_tests/test_geometry.py @@ -206,14 +206,25 @@ 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), - boundary_type='reflective', - orientation='y', - corner_radius=0.10) - - hex_prism = openmc.model.get_hexagonal_prism(edge_length=5.0, - origin=(0.0, 0.0), - boundary_type='reflective', 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 + # edge checks + 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) + + # clear checks + assert (0.0, 0.0, 0.0) in rounded_hex_prism + assert (10.0, 10.0, 10.0) not in rounded_hex_prism + # edge checks + assert (0.0, 5.01, 0.0) not in rounded_hex_prism + assert (0.0, 4.99, 0.0) not in rounded_hex_prism def test_get_lattice_by_name(cell_with_lattice):