Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/7668.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Specify terminals
131 changes: 76 additions & 55 deletions src/ansys/aedt/core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def _create_port_terminal(
iswaveport: bool = False,
impedance: float | None = None,
terminals_rename: bool = True,
specify_terminals: list = [],
) -> NearFieldSetup:
ref_conductors = self.modeler.convert_to_selections(int_line_stop, True)
props = {}
Expand All @@ -473,64 +474,80 @@ def _create_port_terminal(
ports = list(self.oboundary.GetExcitationsOfType("Terminal"))
boundary = self._create_boundary(port_name, props, "AutoIdentify")
if boundary:
new_ports = list(self.oboundary.GetExcitationsOfType("Terminal"))
terminals = [i for i in new_ports if i not in ports]
for count, terminal in enumerate(terminals, start=1):
props_terminal = {}
props_terminal["TerminalResistance"] = "50ohm"
props_terminal["ParentBndID"] = boundary.name
terminal_name = terminal

if impedance:
props_terminal["TerminalResistance"] = str(impedance) + "ohm"
properties = [
"NAME:AllTabs",
[
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + terminal],
if specify_terminals:
if isinstance(specify_terminals, int):
specify_terminals = [specify_terminals]
for count, custom_terminal in enumerate(specify_terminals, start=1):
props_custom_terminal = []
new_name = port_name + "_T" + str(count)
props_custom_terminal.append("Name:" + new_name)
props_custom_terminal.append("Faces:=")
props_custom_terminal.append(specify_terminals)
props_custom_terminal.append("ParentBndID:=")
props_custom_terminal.append(port_name)
props_custom_terminal.append("ImpedanceType:=")
props_custom_terminal.append("Impedance")
props_custom_terminal.append("TerminalResistance:=")
props_custom_terminal.append(str(impedance) + "ohm")
self.oboundary.AssignTerminal(props_custom_terminal)
else:
new_ports = list(self.oboundary.GetExcitationsOfType("Terminal"))
terminals = [i for i in new_ports if i not in ports]
for count, terminal in enumerate(terminals, start=1):
props_terminal = {}
props_terminal["TerminalResistance"] = "50ohm"
props_terminal["ParentBndID"] = boundary.name
terminal_name = terminal
if impedance:
props_terminal["TerminalResistance"] = str(impedance) + "ohm"
properties = [
"NAME:AllTabs",
[
"NAME:ChangedProps",
["NAME:Terminal Renormalizing Impedance", "Value:=", str(impedance) + "ohm"],
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + terminal],
[
"NAME:ChangedProps",
["NAME:Terminal Renormalizing Impedance", "Value:=", str(impedance) + "ohm"],
],
],
],
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning("Failed to change terminal impedance.")
if not renorm:
properties = [
"NAME:AllTabs",
[
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + boundary.name],
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning("Failed to change terminal impedance.")
if not renorm:
properties = [
"NAME:AllTabs",
[
"NAME:ChangedProps",
["NAME:Renorm All Terminals", "Value:=", False],
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + boundary.name],
[
"NAME:ChangedProps",
["NAME:Renorm All Terminals", "Value:=", False],
],
],
],
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning("Failed to change normalization.")
if terminals_rename:
new_name = port_name + "_T" + str(count)
terminal_name = new_name
properties = [
"NAME:AllTabs",
[
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + terminal],
["NAME:ChangedProps", ["NAME:Name", "Value:=", new_name]],
],
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning(f"Failed to rename terminal {terminal}.")
bound = BoundaryObject(self, terminal_name, props_terminal, "Terminal")
self._boundaries[terminal_name] = bound
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning("Failed to change normalization.")
if terminals_rename:
new_name = port_name + "_T" + str(count)
terminal_name = new_name
properties = [
"NAME:AllTabs",
[
"NAME:HfssTab",
["NAME:PropServers", "BoundarySetup:" + terminal],
["NAME:ChangedProps", ["NAME:Name", "Value:=", new_name]],
],
]
try:
self.odesign.ChangeProperty(properties)
except Exception: # pragma: no cover
self.logger.warning(f"Failed to rename terminal {terminal}.")
bound = BoundaryObject(self, terminal_name, props_terminal, "Terminal")
self._boundaries[terminal_name] = bound

if iswaveport:
boundary.type = "Wave Port"
Expand Down Expand Up @@ -6587,6 +6604,7 @@ def wave_port(
hfactor: int | None = 5,
terminals_rename: bool | None = True,
characteristic_impedance: str | list | None = "Zpi",
specify_terminals: int | list[int] | None = [],
) -> BoundaryObject:
"""Create a waveport from a sheet (``start_object``) or taking the closest edges of two objects.

Expand Down Expand Up @@ -6635,6 +6653,8 @@ def wave_port(
characteristic_impedance : str or list, optional
Characteristic impedance for each mode. Available options are `"Zpi"``,`"Zpv"``, `"Zvi"``, and `"Zwave"``.
The default is ``"Zpi"``.
specify_terminals : list[int], optional
Faces ID in which wave port terminals will be created.

Returns
-------
Expand Down Expand Up @@ -6773,7 +6793,7 @@ def wave_port(
else:
deembed = deembed

# Draw terminal lumped port between two objects.
# Draw terminal wave port between two objects.
return self._create_port_terminal(
faces[0],
reference,
Expand All @@ -6783,6 +6803,7 @@ def wave_port(
iswaveport=True,
impedance=impedance,
terminals_rename=terminals_rename,
specify_terminals=specify_terminals,
)

else: # pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions tests/system/general/test_hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def test_create_wave_port_from_sheets_terminal(aedt_app):
renormalize=False,
deembed=5,
terminals_rename=False,
specify_terminals=8,
)

assert port.properties
Expand Down
Loading