Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port and terminal refactor #3611

Merged
merged 7 commits into from
Sep 22, 2023
Merged
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
13 changes: 11 additions & 2 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,13 +1622,23 @@ def test_120_edb_create_port(self):
port_name="df_port",
)
assert edb.ports["df_port"]
assert not edb.are_port_reference_terminals_connected()
p, n = edb.ports["df_port"].terminals
assert edb.ports["df_port"].decouple()
p.couple_ports(n)

traces_id = [i.id for i in traces]
paths = [i[1] for i in trace_paths]
_, df_port = edb.hfss.create_bundle_wave_port(traces_id, paths)
assert df_port.name
assert df_port.terminals
df_port.horizontal_extent_factor = 10
df_port.vertical_extent_factor = 10
df_port.deembed = True
df_port.deembed_length = "1mm"
assert df_port.horizontal_extent_factor == 10
assert df_port.vertical_extent_factor == 10
assert df_port.deembed
assert df_port.deembed_length == 1e-3
edb.close()

def test_120b_edb_create_port(self):
Expand Down Expand Up @@ -1662,7 +1672,6 @@ def test_120b_edb_create_port(self):
trace_pathes[1][0],
horizontal_extent_factor=8,
)
assert not edb.are_port_reference_terminals_connected()

paths = [i[1] for i in trace_pathes]
assert edb.hfss.create_bundle_wave_port(traces, paths)
Expand Down
23 changes: 18 additions & 5 deletions pyaedt/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pyaedt.edb_core.edb_data.design_options import EdbDesignOptions
from pyaedt.edb_core.edb_data.edbvalue import EdbValue
from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import HfssSimulationSetup
from pyaedt.edb_core.edb_data.ports import ExcitationBundle
from pyaedt.edb_core.edb_data.ports import BundleWavePort
from pyaedt.edb_core.edb_data.ports import ExcitationProbes
from pyaedt.edb_core.edb_data.ports import ExcitationSources
from pyaedt.edb_core.edb_data.ports import GapPort
Expand All @@ -31,6 +31,8 @@
from pyaedt.edb_core.edb_data.siwave_simulation_setup_data import SiwaveDCSimulationSetup
from pyaedt.edb_core.edb_data.siwave_simulation_setup_data import SiwaveSYZSimulationSetup
from pyaedt.edb_core.edb_data.sources import SourceType
from pyaedt.edb_core.edb_data.terminals import BundleTerminal
from pyaedt.edb_core.edb_data.terminals import EdgeTerminal
from pyaedt.edb_core.edb_data.terminals import Terminal
from pyaedt.edb_core.edb_data.variables import Variable
from pyaedt.edb_core.general import TerminalType
Expand Down Expand Up @@ -344,7 +346,18 @@
@property
def terminals(self):
"""Get terminals belonging to active layout."""
return {i.GetName(): GapPort(self, i) for i in self.layout.terminals}
temp = {}
for i in self.layout.terminals:
terminal_type = i.ToString().split(".")[-1]
if terminal_type == TerminalType.EdgeTerminal.name:
ter = EdgeTerminal(self, i)

Check warning on line 353 in pyaedt/edb.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb.py#L353

Added line #L353 was not covered by tests
elif terminal_type == TerminalType.BundleTerminal.name:
ter = BundleTerminal(self, i)

Check warning on line 355 in pyaedt/edb.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb.py#L355

Added line #L355 was not covered by tests
else:
ter = Terminal(self, i)
temp[ter.name] = ter

return temp

@property
def excitations(self):
Expand All @@ -353,7 +366,7 @@
temp = {}
for ter in terms:
if "BundleTerminal" in ter.GetType().ToString():
temp[ter.GetName()] = ExcitationBundle(self, ter)
temp[ter.GetName()] = BundleWavePort(self, ter)
else:
temp[ter.GetName()] = GapPort(self, ter)
return temp
Expand All @@ -374,7 +387,7 @@
for t in temp:
t2 = Terminal(self, t)
if t2.terminal_type == TerminalType.BundleTerminal.name:
bundle_ter = ExcitationBundle(self, t)
bundle_ter = BundleWavePort(self, t)
ports[bundle_ter.name] = bundle_ter
elif t2.hfss_type == "Wave":
ports[t2.name] = WavePort(self, t)
Expand Down Expand Up @@ -3119,7 +3132,7 @@
>>> edb.cutout(["Net1"])
>>> assert edb.are_port_reference_terminals_connected()
"""
all_sources = [i for i in self.excitations.values() if not isinstance(i, (WavePort, GapPort))]
all_sources = [i for i in self.excitations.values() if not isinstance(i, (WavePort, GapPort, BundleWavePort))]
all_sources.extend([i for i in self.sources.values()])
if not all_sources:
return True
Expand Down
92 changes: 73 additions & 19 deletions pyaedt/edb_core/edb_data/ports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pyaedt.edb_core.edb_data.terminals import BundleTerminal
from pyaedt.edb_core.edb_data.terminals import EdgeTerminal
from pyaedt.edb_core.edb_data.terminals import Terminal

Expand Down Expand Up @@ -68,8 +69,7 @@

>>> from pyaedt import Edb
>>> edb = Edb("myaedb.aedb")
>>> exc = edb.excitations
>>> print(exc["Port1"].name)
>>> exc = edb.ports
"""

def __init__(self, pedb, edb_terminal):
Expand Down Expand Up @@ -124,11 +124,23 @@
"""Whether deembed is active."""
return self._edb_object.GetPortPostProcessingProp().DoDeembed

@deembed.setter
def deembed(self, value):
p = self._edb_object.GetPortPostProcessingProp()
p.DoDeembed = value
self._edb_object.SetPortPostProcessingProp(p)

@property
def deembed_length(self):
"""Deembed Length."""
return self._edb_object.GetPortPostProcessingProp().DeembedLength.ToDouble()

@deembed_length.setter
def deembed_length(self, value):
p = self._edb_object.GetPortPostProcessingProp()
p.DeembedLength = self._pedb.edb_value(value)
self._edb_object.SetPortPostProcessingProp(p)


class ExcitationSources(Terminal):
"""Manage sources properties.
Expand Down Expand Up @@ -198,29 +210,71 @@
Terminal.__init__(self, pedb, edb_terminal)


class ExcitationBundle:
"""Manages multi terminal excitation properties."""
class BundleWavePort(BundleTerminal):
"""Manages bundle wave port properties.

Parameters
----------
pedb : pyaedt.edb.Edb
EDB object from the ``Edblib`` library.
edb_object : Ansys.Ansoft.Edb.Cell.Terminal.BundleTerminal
BundleTerminal instance from EDB.

"""

def __init__(self, pedb, edb_object):
super().__init__(pedb, edb_object)

@property
def _wave_port(self):
return WavePort(self._pedb, self.terminals[0]._edb_object)

@property
def horizontal_extent_factor(self):
"""Horizontal extent factor."""
return self._wave_port.horizontal_extent_factor

@horizontal_extent_factor.setter
def horizontal_extent_factor(self, value):
self._wave_port.horizontal_extent_factor = value

@property
def vertical_extent_factor(self):
"""Vertical extent factor."""
return self._wave_port.vertical_extent_factor

def __init__(self, pedb, edb_bundle_terminal):
self._pedb = pedb
self._edb_bundle_terminal = edb_bundle_terminal
@vertical_extent_factor.setter
def vertical_extent_factor(self, value):
self._wave_port.vertical_extent_factor = value

@property
def name(self):
"""Port Name."""
return list(self.terminals.values())[0].name
def radial_extent_factor(self):
"""Radial extent factor."""
return self._wave_port.radial_extent_factor

Check warning on line 253 in pyaedt/edb_core/edb_data/ports.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb_core/edb_data/ports.py#L253

Added line #L253 was not covered by tests

@property
def edb(self): # pragma: no cover
"""Get edb."""
return self._pedb.edb_api
def pec_launch_width(self):
"""Launch width for the printed electronic component (PEC)."""
return self._wave_port.pec_launch_width

Check warning on line 258 in pyaedt/edb_core/edb_data/ports.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb_core/edb_data/ports.py#L258

Added line #L258 was not covered by tests

@pec_launch_width.setter
def pec_launch_width(self, value):
self._wave_port.pec_launch_width = value

Check warning on line 262 in pyaedt/edb_core/edb_data/ports.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb_core/edb_data/ports.py#L262

Added line #L262 was not covered by tests

@property
def terminals(self):
"""Get terminals belonging to this excitation."""
return {i.GetName(): GapPort(self._pedb, i) for i in list(self._edb_bundle_terminal.GetTerminals())}
def deembed(self):
"""Whether deembed is active."""
return self._wave_port.deembed

@deembed.setter
def deembed(self, value):
self._wave_port.deembed = value

@property
def reference_net_name(self):
"""Reference Name. Not applicable to Differential pairs."""
return
def deembed_length(self):
"""Deembed Length."""
return self._wave_port.deembed_length

@deembed_length.setter
def deembed_length(self, value):
self._wave_port.deembed_length = value
52 changes: 52 additions & 0 deletions pyaedt/edb_core/edb_data/terminals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pyaedt.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyaedt.edb_core.edb_data.primitives_data import cast
from pyaedt.edb_core.general import TerminalType
from pyaedt.edb_core.general import convert_py_list_to_net_list


class Terminal(Connectable):
Expand Down Expand Up @@ -352,3 +353,54 @@ def _get_closest_pin(self, ref_pin, pin_list, gnd_net=None):
class EdgeTerminal(Terminal):
def __init__(self, pedb, edb_object):
super().__init__(pedb, edb_object)

@pyaedt_function_handler
def couple_ports(self, port):
"""Create a bundle wave port.

Parameters
----------
port : :class:`pyaedt.edb_core.ports.WavePort`, :class:`pyaedt.edb_core.ports.GapPort`, list, optional
Ports to be added.

Returns
-------
:class:`pyaedt.edb_core.ports.BundleWavePort`

"""
if not isinstance(port, (list, tuple)):
port = [port]
temp = [self._edb_object]
temp.extend([i._edb_object for i in port])
edb_list = convert_py_list_to_net_list(temp, self._edb.cell.terminal.Terminal)
_edb_bundle_terminal = self._edb.cell.terminal.BundleTerminal.Create(edb_list)
return self._pedb.ports[self.name]


class BundleTerminal(Terminal):
"""Manages bundle terminal properties.

Parameters
----------
pedb : pyaedt.edb.Edb
EDB object from the ``Edblib`` library.
edb_object : Ansys.Ansoft.Edb.Cell.Terminal.BundleTerminal
BundleTerminal instance from EDB.
"""

def __init__(self, pedb, edb_object):
super().__init__(pedb, edb_object)

@property
def terminals(self):
"""Get terminals belonging to this excitation."""
return [EdgeTerminal(self._pedb, i) for i in list(self._edb_object.GetTerminals())]

@property
def name(self):
return self.terminals[0].name

@pyaedt_function_handler
def decouple(self):
"""Ungroup a bundle of terminals."""
return self._edb_object.Ungroup()
6 changes: 3 additions & 3 deletions pyaedt/edb_core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import math

from pyaedt.edb_core.edb_data.hfss_extent_info import HfssExtentInfo
from pyaedt.edb_core.edb_data.ports import ExcitationBundle
from pyaedt.edb_core.edb_data.ports import BundleWavePort
from pyaedt.edb_core.edb_data.ports import WavePort
from pyaedt.edb_core.edb_data.primitives_data import EDBPrimitives
from pyaedt.edb_core.edb_data.simulation_configuration import SimulationConfiguration
Expand Down Expand Up @@ -539,7 +539,7 @@ def create_differential_wave_port(
_edb_boundle_terminal = self._edb.cell.terminal.BundleTerminal.Create(edb_list)
# _edb_boundle_terminal.SetName("Wave_"+port_name)
pos_term._edb_object.SetName(port_name)
return port_name, ExcitationBundle(self._pedb, _edb_boundle_terminal)
return port_name, BundleWavePort(self._pedb, _edb_boundle_terminal)

@pyaedt_function_handler
def create_bundle_wave_port(
Expand Down Expand Up @@ -601,7 +601,7 @@ def create_bundle_wave_port(

edb_list = convert_py_list_to_net_list([i._edb_object for i in terminals], self._edb.cell.terminal.Terminal)
_edb_bundle_terminal = self._edb.cell.terminal.BundleTerminal.Create(edb_list)
return port_name, ExcitationBundle(self._pedb, _edb_bundle_terminal)
return port_name, BundleWavePort(self._pedb, _edb_bundle_terminal)

@pyaedt_function_handler()
def create_hfss_ports_on_padstack(self, pinpos, portname=None):
Expand Down
Loading