Skip to content

Commit c070fe3

Browse files
maxcapodi78maxcapodi78
authored andcommitted
Merge branch 'main' into release/0.4
2 parents a7d86de + a9bf1b4 commit c070fe3

20 files changed

+1055
-31
lines changed

_unittest/test_00_grpc.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from _unittest.conftest import BasisTest
2+
from _unittest.conftest import config
3+
from pyaedt import Desktop
4+
from pyaedt.generic.general_methods import grpc_active_sessions
5+
6+
try:
7+
import pytest # noqa: F401
8+
except ImportError:
9+
import _unittest_ironpython.conf_unittest as pytest # noqa: F401
10+
11+
from pyaedt.generic.general_methods import is_ironpython
12+
from pyaedt import settings
13+
14+
test_project_name = "Coax_HFSS"
15+
16+
if not is_ironpython and config["desktopVersion"] >= "2022.2":
17+
18+
class TestClass(BasisTest, object):
19+
def setup_class(self):
20+
settings.use_grpc_api = True
21+
22+
def teardown_class(self):
23+
settings.use_grpc_api = config["use_grpc"]
24+
25+
def test_00_destkop(self):
26+
d = Desktop(specified_version="2022.2", new_desktop_session=True)
27+
assert d.port in grpc_active_sessions()
28+
d.release_desktop(False, False)
29+
30+
def test_01_destkop_existing(self):
31+
d = Desktop(specified_version="2022.2", new_desktop_session=False)
32+
assert d.port in grpc_active_sessions()
33+
d.release_desktop(False, False)
34+
35+
def test_02_destkop_new(self):
36+
d = Desktop(specified_version="2022.2", new_desktop_session=True)
37+
assert d.port in grpc_active_sessions()
38+
d.release_desktop(False, False)
39+
40+
def test_03_destkop_release(self):
41+
d = Desktop(specified_version="2022.2", new_desktop_session=False)
42+
assert d.port in grpc_active_sessions()
43+
d.release_desktop()
44+
d = Desktop(specified_version="2022.2", new_desktop_session=False)
45+
assert d.port in grpc_active_sessions()
46+
d.release_desktop()

_unittest/test_02_3D_modeler.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Setup paths for module imports
22
from _unittest.conftest import BasisTest
3+
from pyaedt.generic.general_methods import is_ironpython
34
from pyaedt.modeler.Modeler import FaceCoordinateSystem
45
from pyaedt.modeler.Primitives import PolylineSegment
56

@@ -616,3 +617,17 @@ def test_51_imprint_projection(self):
616617
rect = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.XY, [0, 10, 10], [20, 20], "imprintn3")
617618
box1 = self.aedtapp.modeler.create_box([-10, -10, -10], [20, 20, 20], "imprintn3")
618619
assert self.aedtapp.modeler.imprint_vector_projection([rect, box1], [3, 2, -5], 1)
620+
621+
def test_52_objects_in_bounding_box(self):
622+
bounding_box = [100, 200, 100, -100, -300, -200]
623+
objects_in_bounding_box = self.aedtapp.modeler.objects_in_bounding_box(bounding_box)
624+
assert type(objects_in_bounding_box) is list
625+
626+
bounding_box = [0, 0, 0, 0, 0, 0]
627+
objects_in_bounding_box = self.aedtapp.modeler.objects_in_bounding_box(bounding_box)
628+
assert len(objects_in_bounding_box) == 0
629+
630+
if not is_ironpython:
631+
with pytest.raises(ValueError):
632+
bounding_box = [100, 200, 100, -100, -300]
633+
self.aedtapp.modeler.objects_in_bounding_box(bounding_box)

_unittest/test_07_Object3D.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_24_filter_faces_by_area(self):
429429

430430
faces_greater_equal = []
431431
for obj in self.aedtapp.modeler.object_list:
432-
if obj.faces_by_area(100):
432+
if obj.faces_by_area(100, ">="):
433433
faces_greater_equal.append(obj.faces_by_area(100, ">="))
434434
if faces_greater_equal:
435435
for face_object in faces_greater_equal:
@@ -438,7 +438,7 @@ def test_24_filter_faces_by_area(self):
438438

439439
faces_smaller_equal = []
440440
for obj in self.aedtapp.modeler.object_list:
441-
if obj.faces_by_area(100):
441+
if obj.faces_by_area(100, "<="):
442442
faces_smaller_equal.append(obj.faces_by_area(100, "<="))
443443
if faces_smaller_equal:
444444
for face_object in faces_smaller_equal:
@@ -447,7 +447,7 @@ def test_24_filter_faces_by_area(self):
447447

448448
faces_greater = []
449449
for obj in self.aedtapp.modeler.object_list:
450-
if obj.faces_by_area(99):
450+
if obj.faces_by_area(99, ">"):
451451
faces_greater.append(obj.faces_by_area(99, ">"))
452452
if faces_greater:
453453
for face_object in faces_greater:
@@ -456,7 +456,7 @@ def test_24_filter_faces_by_area(self):
456456

457457
faces_smaller = []
458458
for obj in self.aedtapp.modeler.object_list:
459-
if obj.faces_by_area(105):
459+
if obj.faces_by_area(105, "<"):
460460
faces_smaller.append(obj.faces_by_area(105, "<"))
461461
if faces_smaller:
462462
for face_object in faces_smaller:
@@ -466,3 +466,53 @@ def test_24_filter_faces_by_area(self):
466466
if not is_ironpython:
467467
with pytest.raises(ValueError):
468468
self.aedtapp.modeler.object_list[0].faces_by_area(100, "<<")
469+
470+
def test_25_edges_by_length(self):
471+
edges_equal = []
472+
for obj in self.aedtapp.modeler.object_list:
473+
if obj.edges_by_length(10):
474+
edges_equal.append(obj.edges_by_length(10))
475+
if edges_equal:
476+
for edge_object in edges_equal:
477+
for edge in edge_object:
478+
assert abs(edge.length - 10) < 1e-12
479+
480+
edges_greater_equal = []
481+
for obj in self.aedtapp.modeler.object_list:
482+
if obj.edges_by_length(10, ">="):
483+
edges_greater_equal.append(obj.edges_by_length(10, ">="))
484+
if edges_greater_equal:
485+
for edge_object in edges_greater_equal:
486+
for edge in edge_object:
487+
assert (edge.length - 10) >= -1e-12
488+
489+
edges_smaller_equal = []
490+
for obj in self.aedtapp.modeler.object_list:
491+
if obj.edges_by_length(10, "<="):
492+
edges_smaller_equal.append(obj.edges_by_length(10, "<="))
493+
if edges_smaller_equal:
494+
for edge_object in edges_smaller_equal:
495+
for edge in edge_object:
496+
assert (edge.length - 10) <= 1e-12
497+
498+
edges_greater = []
499+
for obj in self.aedtapp.modeler.object_list:
500+
if obj.edges_by_length(9, ">"):
501+
edges_greater.append(obj.edges_by_length(9, ">"))
502+
if edges_greater:
503+
for edge_object in edges_greater:
504+
for edge in edge_object:
505+
assert (edge.length - 9) > 0
506+
507+
edges_smaller = []
508+
for obj in self.aedtapp.modeler.object_list:
509+
if obj.edges_by_length(15, "<"):
510+
edges_smaller.append(obj.edges_by_length(15, "<"))
511+
if edges_smaller:
512+
for edge_object in edges_smaller:
513+
for edge in edge_object:
514+
assert (edge.length - 15) < 0
515+
516+
if not is_ironpython:
517+
with pytest.raises(ValueError):
518+
self.aedtapp.modeler.object_list[0].edges_by_length(10, "<<")

_unittest/test_16_3d_stackup.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class TestClass(BasisTest, object):
88
def setup_class(self):
99
BasisTest.my_setup(self)
10-
self.aedtapp = BasisTest.add_app(self, "Test_20")
10+
self.aedtapp = BasisTest.add_app(self, "Test_16")
1111
self.st = self.aedtapp.add_stackup_3d()
1212

1313
def teardown_class(self):
@@ -51,12 +51,11 @@ def test_02_line(self):
5151
assert line2._added_length_calcul
5252
assert line2.frequency.numeric_value == 1e9
5353
assert line2.substrate_thickness.numeric_value == 1.2
54-
assert line1.width.numeric_value == 3.0
54+
assert abs(line1.width.numeric_value - 3.0) < 1e-9
5555
assert line2.permittivity.numeric_value == 4.4
5656
assert line2._permittivity_calcul
5757

5858
def test_03_padstackline(self):
59-
6059
p1 = self.st.add_padstack("Massimo", material="aluminum")
6160
p1.plating_ratio = 0.7
6261
p1.set_start_layer("lay1")
@@ -71,14 +70,18 @@ def test_03_padstackline(self):
7170

7271
def test_04_patch(self):
7372
top = self.st.stackup_layers["top"]
73+
gnd = self.st.stackup_layers["gnd1"]
7474
line1 = self.st.objects_by_layer["top"][0]
75-
top.add_patch(
75+
patch = top.add_patch(
7676
1e9,
7777
patch_width=22,
7878
patch_length=10,
7979
patch_position_x=line1.position_x.numeric_value + line1.length.numeric_value,
8080
patch_position_y=line1.position_y.numeric_value,
8181
)
82+
assert patch.width.numeric_value == 22
83+
assert self.st.resize_around_element(patch)
84+
assert patch.create_lumped_port(gnd)
8285

8386
def test_05_polygon(self):
8487
lay1 = self.st.stackup_layers["top"]
@@ -110,3 +113,11 @@ def test_06_hide_variables(self):
110113
assert self.st.dielectric_x_position.read_only_variable()
111114
assert self.st.dielectric_x_position.hide_variable(False)
112115
assert self.st.dielectric_x_position.read_only_variable(False)
116+
117+
def test_07_ml_patch(self):
118+
top = self.st.stackup_layers["top"]
119+
gnd = self.st.stackup_layers["gnd1"]
120+
width = 1e3 * 3e8 / (2 * 1e9 * ((2.2 + 1) / 2) ** (1 / 2))
121+
patch2 = top.ml_patch(1e9, patch_width=width, patch_position_x=0, patch_position_y=0)
122+
patch2.create_lumped_port(gnd, opposite_side=True)
123+
assert self.st.resize_around_element(patch2)

_unittest/test_21_Circuit.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ def test_11_export_fullwave(self):
149149
assert output
150150

151151
def test_12_connect_components(self):
152-
153152
myind = self.aedtapp.modeler.schematic.create_inductor("L100", 1e-9)
154153
myres = self.aedtapp.modeler.schematic.create_resistor("R100", 50)
155154
mycap = self.aedtapp.modeler.schematic.create_capacitor("C100", 1e-12)
@@ -167,6 +166,14 @@ def test_12_connect_components(self):
167166
for pin in L1_pins:
168167
L1_pin2location[pin.name] = pin.location
169168

169+
def test_12a_connect_components(self):
170+
myind = self.aedtapp.modeler.schematic.create_inductor("L101", 1e-9)
171+
myres = self.aedtapp.modeler.schematic.create_resistor("R101", 50)
172+
self.aedtapp.modeler.schematic.create_interface_port("Port2")
173+
assert "Port2" in self.aedtapp.modeler.schematic.nets
174+
assert myind.pins[1].connect_to_component(myres.pins[1], "port_name_test")
175+
assert "port_name_test" in self.aedtapp.modeler.schematic.nets
176+
170177
def test_13_properties(self):
171178
assert self.aedtapp.modeler.model_units
172179

0 commit comments

Comments
 (0)