Skip to content

Commit

Permalink
FIX: GeometryModeler.create_air_region() (#4978)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin-Crawford authored Aug 1, 2024
1 parent d66d356 commit 797600b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
35 changes: 25 additions & 10 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# SOFTWARE.

import random
from sys import float_info

from _unittest.conftest import config
import pytest
Expand All @@ -39,7 +40,7 @@
else:
test_project_name = "Coax_HFSS_t02"

tol = 1e-12
small_number = float_info.epsilon * 10


@pytest.fixture(scope="class")
Expand Down Expand Up @@ -246,9 +247,9 @@ def test_17_unite(self):

def test_18_chamfer(self):
o1 = self.aedtapp.modeler["box_to_split"]
assert abs(o1.volume - 4000.0) < tol
assert abs(o1.volume - 4000.0) / 4000.0 < small_number
assert o1.top_edge_x.chamfer(1)
assert abs(o1.volume - 3990.0) < tol # Volume decreased
assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased

def test_19_clone(self):
self.restore_model()
Expand Down Expand Up @@ -301,8 +302,20 @@ def test_26_create_airbox(self):
assert o2.id > 0

def test_27_create_region(self):
x_pos = 20
y_pos = 21
z_pos = 32
x_neg = 49
y_neg = 50
z_neg = 100

bounding_dims_1 = self.aedtapp.modeler.get_bounding_dimension()
assert not self.aedtapp.modeler.create_air_region(*["20mm", 20, "30mm", "50", 50, 100])
assert self.aedtapp.modeler.create_air_region(20, 20, 30, 50, 50, 100, False)
assert self.aedtapp.modeler.create_air_region(x_pos, y_pos, z_pos, x_neg, y_neg, z_neg, False)
bounding_dims_2 = self.aedtapp.modeler.get_bounding_dimension()
assert abs(bounding_dims_2[0] - bounding_dims_1[0] - (x_pos + x_neg)) < small_number
assert abs(bounding_dims_2[1] - bounding_dims_1[1] - (y_pos + y_neg)) < small_number
assert abs(bounding_dims_2[2] - bounding_dims_1[2] - (z_pos + z_neg)) < small_number
self.aedtapp.modeler["Region"].delete()
self.aedtapp["region_param"] = "20mm"
assert self.aedtapp.modeler.create_air_region("region_param", 20, "30", "50", 50, 100, False)
Expand Down Expand Up @@ -879,8 +892,8 @@ def test_56_global_to_cs(self):
p1 = self.aedtapp.modeler.global_to_cs([0, 0, 0], "CS_Test1")
p2 = self.aedtapp.modeler.global_to_cs([0, 0, 0], "CS_Test2")
p3 = self.aedtapp.modeler.global_to_cs([0, 0, 0], cs2)
assert all(abs(p1[i] - s) < tol for i, s in enumerate([-2.5455844122716, 1.1313708498985, 1.0]))
assert all(abs(p2[i] - s) < tol for i, s in enumerate([2.2260086876588, -1.8068578500310, 9.0]))
assert all(abs(p1[i] - s) < small_number for i, s in enumerate([-2.5455844122716, 1.1313708498985, 1.0]))
assert all(abs(p2[i] - s) < small_number for i, s in enumerate([2.2260086876588, -1.8068578500310, 9.0]))
assert p2 == p3
assert self.aedtapp.modeler.global_to_cs([0, 0, 0], "Global") == [0, 0, 0]

Expand All @@ -901,8 +914,10 @@ def test_57_duplicate_coordinate_system_to_global(self):
assert self.aedtapp.modeler.duplicate_coordinate_system_to_global("CS_Test4")
assert self.aedtapp.modeler.duplicate_coordinate_system_to_global(cs4)
o, q = self.aedtapp.modeler.reference_cs_to_global("CS_Test4")
assert all(abs(o[i] - s) < tol for i, s in enumerate([1.82842712474619, 2.20832611206852, 9.0]))
assert all(abs(q[i] - s) < tol for i, s in enumerate([-0.0, -0.09853761796664, 0.99513332666807, 0.0]))
assert all(abs(o[i] - s) < 10 * small_number for i, s in enumerate([1.82842712474619, 2.20832611206852, 9.0]))
assert all(
abs(q[i] - s) < 10 * small_number for i, s in enumerate([-0.0, -0.09853761796664, 0.99513332666807, 0.0])
)
assert self.aedtapp.modeler.reference_cs_to_global(cs4)
box = self.aedtapp.modeler.create_box([0, 0, 0], [2, 2, 2])
face = box.faces[0]
Expand Down Expand Up @@ -1023,11 +1038,11 @@ def test_58_invert_cs(self):
o, q = self.aedtapp.modeler.invert_cs("CS_Test6", to_global=False)
res = o + q
sol = [3.716491314709036, -4.160251471689218, 8.0, 0.9570920264890529, -0.0, -0.0, -0.28978414868843005]
assert all(abs(res[i] - sol[i]) < tol for i in range(3))
assert all(abs(res[i] - sol[i]) < 10 * small_number for i in range(3))
o, q = self.aedtapp.modeler.invert_cs("CS_Test6", to_global=True)
res = o + q
sol = [2.2260086876588385, -1.8068578500310104, 9.0, 0, 0.09853761796664223, -0.9951333266680702, 0]
assert all(abs(res[i] - sol[i]) < tol for i in range(3))
assert all(abs(res[i] - sol[i]) < 10 * small_number for i in range(3))
assert self.aedtapp.modeler.invert_cs(cs6, to_global=True)

def test_59a_region_property(self):
Expand Down
6 changes: 4 additions & 2 deletions pyaedt/modeler/cad/Primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4094,7 +4094,7 @@ def create_air_region(self, x_pos=0, y_pos=0, z_pos=0, x_neg=0, y_neg=0, z_neg=0
>>> oEditor.CreateRegion
"""
return self.create_region(pad_percent=[x_pos, y_pos, z_pos, x_neg, y_neg, z_neg], is_percentage=is_percentage)
return self.create_region(pad_percent=[x_pos, x_neg, y_pos, y_neg, z_pos, z_neg], is_percentage=is_percentage)

@pyaedt_function_handler(listvalues="values")
def edit_region_dimensions(self, values):
Expand Down Expand Up @@ -4503,7 +4503,9 @@ def get_line_ids(self):

@pyaedt_function_handler()
def get_bounding_dimension(self):
"""Retrieve the dimension array of the bounding box.
"""Retrieve the x, y and z size of the bounding box for the model.
This method is called without arguments.
Returns
-------
Expand Down

0 comments on commit 797600b

Please sign in to comment.