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

create port, probe enhancement #3833

Merged
merged 15 commits into from
Nov 8, 2023
10 changes: 9 additions & 1 deletion _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_003_create_coax_port_on_component(self):
coax_port.radial_extent_factor = 3
assert coax_port.radial_extent_factor == 3
assert coax_port.component
assert self.edbapp.components["U6"].pins["R3"].terminal
assert self.edbapp.components["U6"].pins["R3"].get_terminal()
assert self.edbapp.components["U6"].pins["R3"].id
assert self.edbapp.terminals
assert self.edbapp.ports
Expand Down Expand Up @@ -494,6 +494,10 @@ def test_041_create_voltage_source(self):
assert list(self.edbapp.sources.values())[0].magnitude == 3.3
list(self.edbapp.sources.values())[0].phase = 1
assert list(self.edbapp.sources.values())[0].phase == 1
u6 = self.edbapp.components["U6"]
self.edbapp.create_voltage_source(
u6.pins["F2"].get_terminal(create_new_terminal=True), u6.pins["F1"].get_terminal(create_new_terminal=True)
)

def test_042_create_current_source(self):
assert self.edbapp.siwave.create_current_source_on_net("U1", "USB3_D_N", "U1", "GND", 0.1, 0) != ""
Expand Down Expand Up @@ -524,6 +528,10 @@ def test_042_create_current_source(self):
ref_term.location = [0, 0]
assert ref_term.layer
ref_term.layer = "1_Top"
u6 = self.edbapp.components["U6"]
self.edbapp.create_current_source(
u6.pins["H8"].get_terminal(create_new_terminal=True), u6.pins["G9"].get_terminal(create_new_terminal=True)
)

def test_043_create_dc_terminal(self):
assert self.edbapp.siwave.create_dc_terminal("U1", "DDR4_DQ40", "dc_terminal1") == "dc_terminal1"
Expand Down
162 changes: 132 additions & 30 deletions pyaedt/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@
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 PadstackInstanceTerminal
from pyaedt.edb_core.edb_data.terminals import PinGroupTerminal
from pyaedt.edb_core.edb_data.terminals import Terminal
from pyaedt.edb_core.edb_data.variables import Variable
from pyaedt.edb_core.general import BoundaryType
from pyaedt.edb_core.general import LayoutObjType
from pyaedt.edb_core.general import Primitives
from pyaedt.edb_core.general import TerminalType
from pyaedt.edb_core.general import convert_py_list_to_net_list
from pyaedt.edb_core.hfss import EdbHfss
from pyaedt.edb_core.ipc2581.ipc2581 import Ipc2581
Expand Down Expand Up @@ -358,18 +352,10 @@
def terminals(self):
"""Get terminals belonging to active layout."""
temp = {}
terminal_mapping = Terminal(self)._terminal_mapping
for i in self.layout.terminals:
terminal_type = i.ToString().split(".")[-1]
if terminal_type == TerminalType.EdgeTerminal.name:
ter = EdgeTerminal(self, i)
elif terminal_type == TerminalType.BundleTerminal.name:
ter = BundleTerminal(self, i)
elif terminal_type == TerminalType.PadstackInstanceTerminal.name:
ter = PadstackInstanceTerminal(self, i)
elif terminal_type == TerminalType.PinGroupTerminal.name:
ter = PinGroupTerminal(self, i)
else:
ter = Terminal(self, i)
ter = terminal_mapping[terminal_type](self, i)
temp[ter.name] = ter

return temp
Expand Down Expand Up @@ -401,15 +387,18 @@
ports = {}
for t in temp:
t2 = Terminal(self, t)
if not t2.boundary_type == "PortBoundary":
continue

Check warning on line 391 in pyaedt/edb.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb.py#L391

Added line #L391 was not covered by tests

if t2.is_circuit_port:
port = CircuitPort(self, t)
ports[port.name] = port
elif t2.terminal_type == TerminalType.BundleTerminal.name:
elif t2.terminal_type == "BundleTerminal":
port = BundleWavePort(self, t)
ports[port.name] = port
elif t2.hfss_type == "Wave":
ports[t2.name] = WavePort(self, t)
elif t2.terminal_type == TerminalType.PadstackInstanceTerminal.name:
elif t2.terminal_type == "PadstackInstanceTerminal":
ports[t2.name] = CoaxPort(self, t)
else:
ports[t2.name] = GapPort(self, t)
Expand All @@ -433,7 +422,7 @@
"""Get all layout sources."""
temp = {}
for name, val in self.terminals.items():
if val.boundary_type == BoundaryType.kVoltageProbe.name:
if val.boundary_type == "kVoltageProbe":
if not val.is_reference_terminal:
temp[name] = val
return temp
Expand Down Expand Up @@ -3646,7 +3635,7 @@

@pyaedt_function_handler
def create_port(self, terminal, ref_terminal=None, is_circuit_port=False):
"""Create a port between two terminals.
"""Create a port.

Parameters
----------
Expand All @@ -3668,13 +3657,126 @@
-------

"""
if not ref_terminal:
port = CoaxPort(self, terminal._edb_object)
else:
if is_circuit_port:
port = CircuitPort(self, terminal._edb_object)
else:
port = GapPort(self, terminal._edb_object)
port.ref_terminal = ref_terminal
port.is_circuit_port = is_circuit_port
return port

terminal.boundary_type = "PortBoundary"
terminal.is_circuit_port = is_circuit_port

if ref_terminal:
ref_terminal.boundary_type = "PortBoundary"
terminal.ref_terminal = ref_terminal

return self.ports[terminal.name]

@pyaedt_function_handler
def create_voltage_probe(self, terminal, ref_terminal):
svandenb-dev marked this conversation as resolved.
Show resolved Hide resolved
"""Create a voltage probe.

Parameters
----------
terminal : :class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Positive terminal of the port.
ref_terminal : :class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Negative terminal of the probe.

Returns
-------

"""
term = Terminal(self, terminal._edb_object)
term.boundary_type = "kVoltageProbe"

ref_term = Terminal(self, ref_terminal._edb_object)
ref_term.boundary_type = "kVoltageProbe"

term.ref_terminal = ref_terminal
return self.probes[term.name]

@pyaedt_function_handler
def create_voltage_source(self, terminal, ref_terminal):
svandenb-dev marked this conversation as resolved.
Show resolved Hide resolved
"""Create a voltage source.

Parameters
----------
terminal : :class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Positive terminal of the port.
ref_terminal : class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Negative terminal of the source.

Returns
-------
class:`pyaedt.edb_core.edb_data.ports.ExcitationSources`
"""
term = Terminal(self, terminal._edb_object)
term.boundary_type = "kVoltageSource"

ref_term = Terminal(self, ref_terminal._edb_object)
ref_term.boundary_type = "kVoltageProbe"

term.ref_terminal = ref_terminal
return self.sources[term.name]

@pyaedt_function_handler
def create_current_source(self, terminal, ref_terminal):
svandenb-dev marked this conversation as resolved.
Show resolved Hide resolved
"""Create a current source.

Parameters
----------
terminal : :class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Positive terminal of the port.
ref_terminal : class:`pyaedt.edb_core.edb_data.terminals.EdgeTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PadstackInstanceTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`,
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`,
Negative terminal of the source.

Returns
-------
:class:`pyaedt.edb_core.edb_data.ports.ExcitationSources`
"""
term = Terminal(self, terminal._edb_object)
term.boundary_type = "kCurrentSource"

ref_term = Terminal(self, ref_terminal._edb_object)
ref_term.boundary_type = "kCurrentSource"

term.ref_terminal = ref_terminal
return self.sources[term.name]

@pyaedt_function_handler
def get_point_terminal(self, name, net_name, location, layer):
svandenb-dev marked this conversation as resolved.
Show resolved Hide resolved
"""Place a voltage probe between two points.

Parameters
----------
name : str,
Name of the terminal.
net_name : str
Name of the net.
location : list
Location of the terminal.
layer : str,
Layer of the terminal.

Returns
-------
:class:`pyaedt.edb_core.edb_data.terminals.PointTerminal`
"""
hui-zhou-a marked this conversation as resolved.
Show resolved Hide resolved
from pyaedt.edb_core.edb_data.terminals import PointTerminal

point_terminal = PointTerminal(self)
return point_terminal.create(name, net_name, location, layer)
27 changes: 22 additions & 5 deletions pyaedt/edb_core/edb_data/padstacks_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,12 +998,29 @@ def __init__(self, edb_padstackinstance, _pedb):
self._position = []
self._pdef = None

@property
def terminal(self):
"""Return PadstackInstanceTerminal object."""
from pyaedt.edb_core.edb_data.terminals import PadstackInstanceTerminal
@pyaedt_function_handler
def get_terminal(self, name=None, create_new_terminal=False):
"""Return PadstackInstanceTerminal object.

term = PadstackInstanceTerminal(self._pedb, self._edb_object.GetPadstackInstanceTerminal())
Parameters
----------
name : str, optional
Name of the terminal. Only applicable when create_new_terminal is True.
create_new_terminal : bool, optional
Whether to create a new terminal.

Returns
-------
:class:`pyaedt.edb_core.edb_data.terminals`

"""

if create_new_terminal:
term = self._create_terminal(name)
else:
from pyaedt.edb_core.edb_data.terminals import PadstackInstanceTerminal

term = PadstackInstanceTerminal(self._pedb, self._edb_object.GetPadstackInstanceTerminal())
if not term.is_null:
return term

Expand Down
31 changes: 18 additions & 13 deletions pyaedt/edb_core/edb_data/sources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pyaedt
from pyaedt import pyaedt_function_handler
from pyaedt.generic.constants import NodeType
from pyaedt.generic.constants import SourceType
Expand Down Expand Up @@ -275,12 +276,16 @@
def net_name(self):
return self._edb_pin_group.GetNet().GetName()

@property
def terminal(self):
@pyaedt_function_handler
def get_terminal(self, name=None, create_new_terminal=False):
"""Terminal."""
from pyaedt.edb_core.edb_data.terminals import PinGroupTerminal

term = PinGroupTerminal(self._pedb, self._edb_pin_group.GetPinGroupTerminal())
if create_new_terminal:
term = self._create_terminal(name)

Check warning on line 284 in pyaedt/edb_core/edb_data/sources.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb_core/edb_data/sources.py#L284

Added line #L284 was not covered by tests
else:
from pyaedt.edb_core.edb_data.terminals import PinGroupTerminal

term = PinGroupTerminal(self._pedb, self._edb_pin_group.GetPinGroupTerminal())
return term if not term.is_null else None

@pyaedt_function_handler()
Expand All @@ -297,19 +302,19 @@
-------
:class:`pyaedt.edb_core.edb_data.terminals.PinGroupTerminal`
"""
pg_term = self.terminal
terminal = self.get_terminal()
if terminal:
return terminal

if not name:
name = self.name
name = pyaedt.generate_unique_name(self.name)

if pg_term:
return pg_term
else:
from pyaedt.edb_core.edb_data.terminals import PinGroupTerminal
from pyaedt.edb_core.edb_data.terminals import PinGroupTerminal

term = PinGroupTerminal(self._pedb)
term = PinGroupTerminal(self._pedb)

term = term.create(name, self.net_name, self.name)
return term
term = term.create(name, self.net_name, self.name)
return term

@pyaedt_function_handler()
def create_current_source_terminal(self, magnitude=1, phase=0):
Expand Down
Loading
Loading