Skip to content

Commit 434825c

Browse files
authored
Enhancement/q2d (#830)
* First Implementation of new methods for Q2D * Added UnitTests * Added UnitTests * Added UnitTests * Added UnitTests * Added UnitTests * Added UnitTests
1 parent 99b469d commit 434825c

File tree

5 files changed

+84
-17
lines changed

5 files changed

+84
-17
lines changed

_unittest/test_30_Q2D.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@ def test_06a_create_setup(self):
4545
def test_07_single_signal_line(self):
4646
udp = self.aedtapp.modeler.Position(0, 0, 0)
4747
o = self.aedtapp.modeler.primitives.create_rectangle(udp, [5, 3], name="Rectangle1")
48-
self.aedtapp.assign_single_conductor(target_objects=o, solve_option="SolveOnBoundary")
48+
assert self.aedtapp.assign_single_conductor(target_objects=o, solve_option="SolveOnBoundary")
4949

5050
def test_08_assign_huray_finitecond_to_edges(self):
5151
o = self.aedtapp.create_rectangle([6, 6], [5, 3], name="Rectangle1", matname="Copper")
5252
self.aedtapp.assign_single_conductor(target_objects=o, solve_option="SolveOnBoundary")
5353
assert self.aedtapp.assign_huray_finitecond_to_edges(o.edges, radius=0.5, ratio=2.9)
54+
55+
def test_09_auto_assign(self):
56+
self.aedtapp.insert_design("test_auto")
57+
o = self.aedtapp.create_rectangle([6, 6], [5, 3], name="Rectangle1", matname="Copper")
58+
o = self.aedtapp.create_rectangle([0, 0], [5, 3], name="Rectangle2", matname="Copper")
59+
assert self.aedtapp.auto_assign_conductors()
60+
assert len(self.aedtapp.boundaries) == 2
61+
62+
def test_10_toggle_condcutor(self):
63+
assert self.aedtapp.toggle_conductor_type("Rectangle1", "ReferenceGround")
64+
assert not self.aedtapp.toggle_conductor_type("Rectangle3", "ReferenceGround")
65+
assert not self.aedtapp.toggle_conductor_type("Rectangle2", "ReferenceggGround")

_unittest/test_98_Icepak.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ def test_39_import_idf(self):
373373
def test_40_create_fan(self):
374374
fan = self.aedtapp.create_fan(origin=[5, 21, 1])
375375
assert fan
376-
assert (
377-
self.aedtapp.modeler.oeditor.Get3DComponentInstanceNames(fan.component_name)[0] == fan.component_name + "1"
378-
)
376+
assert fan.component_name in self.aedtapp.modeler.oeditor.Get3DComponentInstanceNames(fan.component_name)[0]
379377

380378
def test_88_create_heat_sink(self):
381379
self.aedtapp.insert_design("HS")

pyaedt/application/Analysis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ def export_results(self, analyze=False, export_folder=None):
592592
setups = self.oanalysis.GetSetups()
593593
if self.solution_type == "HFSS3DLayout" or self.solution_type == "HFSS 3D Layout Design":
594594
excitations = len(self.oexcitation.GetAllPortsList())
595+
elif self.design_type == "2D Extractor":
596+
excitations = self.oboundary.GetNumExcitations("SignalLine")
595597
else:
596598
excitations = self.oboundary.GetNumExcitations()
597599
reportnames = self.post.oreportsetup.GetAllReportNames()

pyaedt/modules/Boundary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ def create(self):
383383
self._app.oboundary.AssignGroundNet(self._get_args())
384384
elif self.type == "FloatingNet":
385385
self._app.oboundary.AssignFloatingNet(self._get_args())
386+
elif self.type == "SignalLine":
387+
self._app.oboundary.AssignSingleSignalLine(self._get_args())
388+
elif self.type == "ReferenceGround":
389+
self._app.oboundary.AssignSingleReferenceGround(self._get_args())
386390
elif self.type == "CircuitPort":
387391
self._app.oboundary.AssignCircuitPort(self._get_args())
388392
elif self.type == "LumpedPort":

pyaedt/q3d.py

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pyaedt.generic.general_methods import aedt_exception_handler, generate_unique_name
77
from collections import OrderedDict
88
from pyaedt.modules.Boundary import BoundaryObject
9-
from pyaedt.generic.DataHandlers import _dict2arg
109
import os
1110
import warnings
1211

@@ -718,6 +717,7 @@ def __init__(
718717
student_version,
719718
)
720719

720+
@aedt_exception_handler
721721
def create_rectangle(self, position, dimension_list, name="", matname=""):
722722
"""
723723
Create a rectangle.
@@ -748,6 +748,7 @@ def create_rectangle(self, position, dimension_list, name="", matname=""):
748748
position, dimension_list=dimension_list, name=name, matname=matname
749749
)
750750

751+
@aedt_exception_handler
751752
def assign_single_signal_line(self, target_objects, name="", solve_option="SolveInside", thickness=None, unit="um"):
752753
"""Assign conductor type to sheets.
753754
@@ -779,6 +780,7 @@ def assign_single_signal_line(self, target_objects, name="", solve_option="Solve
779780
)
780781
self.assign_single_conductor(target_objects, name, "SignalLine", solve_option, thickness, unit)
781782

783+
@aedt_exception_handler
782784
def assign_single_conductor(
783785
self,
784786
target_objects,
@@ -808,10 +810,11 @@ def assign_single_conductor(
808810
thickness is used.
809811
unit : str, optional
810812
Thickness unit. The default is ``"um"``.
813+
811814
Returns
812815
-------
813-
bool
814-
``True`` when successful, ``False`` when failed.
816+
:class:`pyaedt.modules.Boundary.BoundaryObject`
817+
Source object.
815818
816819
References
817820
----------
@@ -840,17 +843,13 @@ def assign_single_conductor(
840843

841844
props = OrderedDict({"Objects": obj_names, "SolveOption": solve_option, "Thickness": str(thickness) + unit})
842845

843-
arg = ["NAME:" + name]
844-
_dict2arg(props, arg)
845-
if conductor_type == "SignalLine":
846-
self.oboundary.AssignSingleSignalLine(arg)
847-
elif conductor_type == "ReferenceGround":
848-
self.oboundary.AssignSingleReferenceGround(arg)
849-
else:
850-
return False
851-
852-
return True
846+
bound = BoundaryObject(self, name, props, conductor_type)
847+
if bound.create():
848+
self.boundaries.append(bound)
849+
return bound
850+
return False
853851

852+
@aedt_exception_handler
854853
def assign_huray_finitecond_to_edges(self, edges, radius, ratio, unit="um", name=""):
855854
"""
856855
Assign Huray surface roughness model to edges.
@@ -891,3 +890,55 @@ def assign_huray_finitecond_to_edges(self, edges, radius, ratio, unit="um", name
891890
self.boundaries.append(bound)
892891
return bound
893892
return False
893+
894+
@aedt_exception_handler
895+
def auto_assign_conductors(self):
896+
"""Auto Assign Conductors to Signal Lines.
897+
898+
Returns
899+
-------
900+
bool
901+
"""
902+
original_nets = list(self.oboundary.GetExcitations())
903+
self.oboundary.AutoAssignSignals()
904+
new_nets = [i for i in list(self.oboundary.GetExcitations()) if i not in original_nets]
905+
i = 0
906+
while i < len(new_nets):
907+
objects = self.modeler.convert_to_selections(
908+
[int(k) for k in list(self.oboundary.GetExcitationAssignment(new_nets[i]))], True
909+
)
910+
props = OrderedDict({"Objects": objects})
911+
bound = BoundaryObject(self, new_nets[i], props, new_nets[i + 1])
912+
self.boundaries.append(bound)
913+
i += 2
914+
if new_nets:
915+
self.logger.info("{} Nets have been identified: {}".format(len(new_nets), ", ".join(new_nets)))
916+
else:
917+
self.logger.info("No new nets identified")
918+
return True
919+
920+
@aedt_exception_handler
921+
def toggle_conductor_type(self, conductor_name, new_type):
922+
"""Change the conductor type.
923+
924+
Parameters
925+
----------
926+
conductor_name : str
927+
Name of the conductor to update.
928+
new_type : str
929+
New conductor type.
930+
931+
Returns
932+
-------
933+
bool
934+
"""
935+
try:
936+
self.oboundary.ToggleConductor(conductor_name, new_type)
937+
for bound in self.boundaries:
938+
if bound.name == conductor_name:
939+
bound.type = new_type
940+
self.logger.info("Conductor type correctly updated")
941+
return True
942+
except:
943+
self.logger.error("Error in updating conductor type")
944+
return False

0 commit comments

Comments
 (0)