Skip to content

Commit

Permalink
Added Methods in Q3d: (#813)
Browse files Browse the repository at this point in the history
* Added Methods in Q3d:
- nets (property) : list of all nets of the project
- net_sources (method).: list of sources that belongs to that net
- net_sinks (method). list of sinks that belongs to that net
- assign_net (method) : assign a net to a list of object.

* Added Methods in Q3d:
- nets (property) : list of all nets of the project
- net_sources (method).: list of sources that belongs to that net
- net_sinks (method). list of sinks that belongs to that net
- assign_net (method) : assign a net to a list of object.

* Added Methods in Q3d:
- nets (property) : list of all nets of the project
- net_sources (method).: list of sources that belongs to that net
- net_sinks (method). list of sinks that belongs to that net
- assign_net (method) : assign a net to a list of object.

* Added Methods in Q3d:
- nets (property) : list of all nets of the project
- net_sources (method).: list of sources that belongs to that net
- net_sinks (method). list of sinks that belongs to that net
- assign_net (method) : assign a net to a list of object.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.

* Added property initial_mesh_settings which return a MeshOperation and can be edited.
  • Loading branch information
maxcapodi78 authored Feb 3, 2022
1 parent dc9f9ab commit 87df976
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 84 deletions.
4 changes: 4 additions & 0 deletions _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def test_03_FacePrimitive(self):
assert non_planar_face.move_with_offset(1)
assert isclose(non_planar_face.area, 314.1592653589793)
assert not non_planar_face.normal
o_box2 = self.aedtapp.modeler.create_box([300, 300, 300], [10, 10, 5], "BoxBounding", "Copper")
for face in o_box2.faces:
assert isinstance(face.is_on_bounding(), bool)
assert len(o_box2.faces_on_bounding_box) == 3

def test_04_object_material_property_invalid(self):
o_box = self.create_copper_box("Invalid1")
Expand Down
34 changes: 23 additions & 11 deletions _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def test_03_2_assign_material(self):
def test_04_assign_coating(self, object_name, kwargs):
id = self.aedtapp.modeler.primitives.get_obj_id(object_name)
coat = self.aedtapp.assign_coating([id], **kwargs)
coat.name = "Coating1" + object_name
assert coat.update()
material = coat.props.get("Material", "")
assert material == kwargs.get("mat", "")

Expand Down Expand Up @@ -278,13 +280,12 @@ def test_08_create_circuit_port_from_edges(self):
).name
== "port20"
)
assert (
self.aedtapp.create_circuit_port_from_edges(
e1, e2, port_name="port21", port_impedance="50.1", renormalize=True
).name
== "port21"
bound = self.aedtapp.create_circuit_port_from_edges(
e1, e2, port_name="port32", port_impedance="50.1", renormalize=True
)

assert bound
bound.name = "port21"
assert bound.update()
self.aedtapp.solution_type = "Modal"

def test_09_create_waveport_on_objects(self):
Expand Down Expand Up @@ -320,15 +321,17 @@ def test_10_create_lumped_on_objects(self):
box2 = self.aedtapp.modeler.primitives.create_box([0, 0, 60], [10, 10, 5], "BoxLumped2")
box2.material_name = "Copper"
port = self.aedtapp.create_lumped_port_between_objects(
"BoxLumped1", "BoxLumped2", self.aedtapp.AxisDir.XNeg, 50, "Lump1", True, False
"BoxLumped1", "BoxLumped2", self.aedtapp.AxisDir.XNeg, 50, "Lump1xx", True, False
)
assert not self.aedtapp.create_lumped_port_between_objects(
"BoxLumped1111", "BoxLumped2", self.aedtapp.AxisDir.XNeg, 50, "Lump1", True, False
)
assert self.aedtapp.create_lumped_port_between_objects(
"BoxLumped1", "BoxLumped2", self.aedtapp.AxisDir.XPos, 50
)
assert port.name == "Lump1"
assert port.name == "Lump1xx"
port.name = "Lump1"
assert port.update()

def test_11_create_circuit_on_objects(self):
box1 = self.aedtapp.modeler.primitives.create_box([0, 0, 80], [10, 10, 5], "BoxCircuit1", "Copper")
Expand Down Expand Up @@ -537,7 +540,9 @@ def test_35_set_export_touchstone(self):

def test_36_assign_radiation_to_objects(self):
self.aedtapp.modeler.primitives.create_box([-100, -100, -100], [200, 200, 200], name="Rad_box")
assert self.aedtapp.assign_radiation_boundary_to_objects("Rad_box")
rad = self.aedtapp.assign_radiation_boundary_to_objects("Rad_box")
rad.name = "Radiation1"
assert rad.update()

def test_37_assign_radiation_to_objects(self):
self.aedtapp.modeler.primitives.create_box([-100, -100, -100], [200, 200, 200], name="Rad_box2")
Expand Down Expand Up @@ -576,7 +581,10 @@ def test_42_floquet_port(self):
sheet = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.XY, [-100, -100, -100], [200, 200], name="RectangleForSource", matname="Copper"
)
assert self.aedtapp.create_floquet_port(sheet, deembed_dist=1, nummodes=4, reporter_filter=False)
bound = self.aedtapp.create_floquet_port(sheet, deembed_dist=1, nummodes=4, reporter_filter=False)
assert bound
bound.name = "Floquet1"
assert bound.update()

def test_43_autoassign_pairs(self):
self.aedtapp.insert_design("lattice")
Expand All @@ -587,9 +595,13 @@ def test_43_autoassign_pairs(self):
assert self.aedtapp.assign_lattice_pair([box1.faces[2], box1.faces[4]])
primary = self.aedtapp.assign_primary(box1.faces[1], [100, -100, -100], [100, 100, -100])
assert primary
assert self.aedtapp.assign_secondary(
primary.name = "Prim1"
assert primary.update()
sec = self.aedtapp.assign_secondary(
box1.faces[0], primary.name, [100, -100, 100], [100, 100, 100], reverse_v=True
)
sec.name = "Sec1"
assert sec.update()

def test_44_create_infinite_sphere(self):
self.aedtapp.insert_design("InfSphere")
Expand Down
34 changes: 29 additions & 5 deletions _unittest/test_31_Q3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def test_06b_create_setup(self):
assert sweep2
assert sweep2.props["RangeEnd"] == "4GHz"

def test_06c_autoidentify(self):
assert self.aedtapp.auto_identify_nets()
pass

def test_07_create_source_sinks(self):
source = self.aedtapp.assign_source_to_objectface("MyCylinder", axisdir=0, source_name="Source1")
sink = self.aedtapp.assign_sink_to_objectface("MyCylinder", axisdir=3, sink_name="Sink1")
Expand All @@ -84,6 +88,14 @@ def test_07B_create_source_tosheet(self):
sink = self.aedtapp.assign_sink_to_sheet("Sink1", netname="GND", objectname="Cylinder1")
assert source
assert sink
sink.name = "My_new_name"
assert sink.update()
assert sink.name == "My_new_name"
assert len(self.aedtapp.nets) > 0
assert len(self.aedtapp.net_sources("GND")) > 0
assert len(self.aedtapp.net_sinks("GND")) > 0
assert len(self.aedtapp.net_sources("PGND")) == 0
assert len(self.aedtapp.net_sinks("PGND")) == 0

def test_08_create_faceted_bondwire(self):
self.aedtapp.load_project(self.test_project, close_active_proj=True)
Expand All @@ -93,16 +105,28 @@ def test_08_create_faceted_bondwire(self):
assert test
pass

def test_09_autoidentify(self):
assert self.aedtapp.auto_identify_nets()
pass

def test_10_q2d(self):
q2d = Q2d()
assert q2d
assert q2d.dim == "2D"
pass

def test_11_mesh_settings(self):
def test_11_assign_net(self):
box = self.aedtapp.modeler.create_box([30, 30, 30], [10, 10, 10], name="mybox")
net_name = "my_net"
net = self.aedtapp.assign_net(box, net_name)
assert net
assert net.name == net_name
box = self.aedtapp.modeler.create_box([40, 30, 30], [10, 10, 10], name="mybox2")
net = self.aedtapp.assign_net(box, None, "Ground")
assert net
box = self.aedtapp.modeler.create_box([60, 30, 30], [10, 10, 10], name="mybox3")
net = self.aedtapp.assign_net(box, None, "Floating")
assert net
net.name = "new_net_name"
assert net.update()
assert net.name == "new_net_name"

def test_12_mesh_settings(self):
assert self.aedtapp.mesh.initial_mesh_settings
assert self.aedtapp.mesh.initial_mesh_settings.props
6 changes: 5 additions & 1 deletion _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def test_12_AssignMeshOperation(self):

def test_13a_assign_openings(self):
airfaces = [self.aedtapp.modeler.primitives["Region"].top_face_x.id]
assert self.aedtapp.assign_openings(airfaces)
openings = self.aedtapp.assign_openings(airfaces)
openings.name = "Test_Opening"
assert openings.update()

def test_13b_assign_grille(self):
airfaces = [self.aedtapp.modeler.primitives["Region"].top_face_y.id]
Expand All @@ -214,6 +216,8 @@ def test_13b_assign_grille(self):
)
assert grille2.props["X"] == ["0", "3", "5"]
assert grille2.props["Y"] == ["0", "2", "3"]
grille2.name = "Grille_test"
assert grille2.update()

def test_14_edit_design_settings(self):
assert self.aedtapp.edit_design_settings(gravityDir=1)
Expand Down
18 changes: 15 additions & 3 deletions examples/05-Q3D/Q3D_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,26 @@
q.auto_identify_nets()

q.assign_source_to_objectface("Bar1", axisdir=q.AxisDir.XPos, source_name="Source1")

q.assign_sink_to_objectface("Bar1", axisdir=q.AxisDir.XNeg, sink_name="Sink1")

q.assign_source_to_objectface("Bar2", axisdir=q.AxisDir.XPos, source_name="Source2")
q.assign_sink_to_objectface("Bar2", axisdir=q.AxisDir.XNeg, sink_name="Sink2")
q.assign_source_to_objectface("Bar3", axisdir=q.AxisDir.XPos, source_name="Source3")
q.assign_sink_to_objectface("Bar3", axisdir=q.AxisDir.YPos, sink_name="Sink3")
bar3_sink = q.assign_sink_to_objectface("Bar3", axisdir=q.AxisDir.YPos)
bar3_sink.name = "Sink3"
bar3_sink.update()

###############################################################################
# Print Infos
# ~~~~~~~~~~~
# There are different methods to print nets and terminal informations.
print(q.nets)
print(q.net_sinks("Bar1"))
print(q.net_sinks("Bar2"))
print(q.net_sinks("Bar3"))
print(q.net_sources("Bar1"))
print(q.net_sources("Bar2"))
print(q.net_sources("Bar3"))

###############################################################################
# Add a Q3D Setup
Expand Down Expand Up @@ -127,4 +139,4 @@
# `release_desktop` method.
# All methods provide for saving projects before exiting.
if os.name != "posix":
q.release_desktop(close_projects=True, close_on_exit=True)
q.release_desktop(close_projects=True, close_desktop=True)
9 changes: 1 addition & 8 deletions pyaedt/modeler/Modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2169,14 +2169,7 @@ def section(self, object_list, plane, create_new=True, section_cross_object=Fals
>>> oEditor.Section
"""
plane_ids = [0, 1, 2]
plane_str = ["XY", "YZ", "ZX"]
if plane in plane_ids:
section_plane = plane_str[plane]
elif plane in plane_str:
section_plane = plane
else:
return False
section_plane = GeometryOperators.cs_plane_to_plane_str(plane)

selections = self.convert_to_selections(object_list)

Expand Down
41 changes: 41 additions & 0 deletions pyaedt/modeler/Object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,33 @@ def area(self):
area = self._oeditor.GetFaceArea(self.id)
return area

@aedt_exception_handler
def is_on_bounding(self, tol=1e-9):
"""Check if the face is on bounding box or Not.
Parameters
----------
tolerance : float, optional
Tolerance of check between face center and bounding box.
Returns
-------
bool
`True` if the face is on bounding box. `False` otherwise.
"""
b = [float(i) for i in list(self._oeditor.GetModelBoundingBox())]
c = self.center
if (
abs(c[0] - b[0]) < tol
or abs(c[1] - b[1]) < tol
or abs(c[2] - b[2]) < tol
or abs(c[0] - b[3]) < tol
or abs(c[1] - b[4]) < tol
or abs(c[2] - b[5]) < tol
):
return True
return False

@aedt_exception_handler
def move_with_offset(self, offset=1.0):
"""Move the face along the normal.
Expand Down Expand Up @@ -944,6 +971,20 @@ def faces(self):
faces.append(FacePrimitive(self, face))
return faces

@property
def faces_on_bounding_box(self):
"""Return only the face ids of the faces touching the bounding box.
Returns
-------
list
"""
f_list = []
for face in self.faces:
if face.is_on_bounding():
f_list.append(face.id)
return f_list

@property
def top_face_z(self):
"""Top face in the Z direction of the object.
Expand Down
Loading

0 comments on commit 87df976

Please sign in to comment.