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

Unittest iter2 #66

Merged
merged 4 commits into from
Nov 14, 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
33 changes: 16 additions & 17 deletions src/pyedb/grpc/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import warnings
import ansys.edb.definition as definition
import ansys.edb.geometry as geometry
import ansys.edb.hierarchy as hierarchy
import ansys.edb.layer as layer
import ansys.edb.terminal as terminal
Expand Down Expand Up @@ -833,12 +834,12 @@ def create_port_on_component(
pin_layers = cmp_pins[0].padstack_def.data.layer_names
if port_type == SourceType.CoaxPort:
pad_params = self._padstack.get_pad_parameters(pin=cmp_pins[0], layername=pin_layers[0], pad_type=0)
if not pad_params[0] == 7:
sball_diam = min([utility.Value(val).value for val in pad_params[1]])
solder_ball_height = 2 * sball_diam / 3
else:
bbox = pad_params[1]
sball_diam = min([abs(bbox[2] - bbox[0]), abs(bbox[3] - bbox[1])]) * 0.8
if isinstance(pad_params[0], definition.PadGeometryType):
sball_diam = min([utility.Value(val).value for val in pad_params[1]])
solder_ball_height = 2 * sball_diam / 3
elif isinstance(pad_params[0], geometry.PolygonData):
bbox = pad_params[0].bbox()
sball_diam = min([abs(bbox[1].x - bbox[0].x), abs(bbox[3] - bbox[1])]) * 0.8
solder_ball_height = 2 * sball_diam / 3
self.set_solder_ball(component, solder_ball_height, sball_diam)
for pin in cmp_pins:
Expand Down Expand Up @@ -1221,10 +1222,10 @@ def _is_top_component(self, cmp):
return False

@pyedb_function_handler()
def _getComponentDefinition(self, name, pins):
def _get_component_definition(self, name, pins):
component_definition = definition.ComponentDef.find(self._db, name)
if component_definition.is_null:
component_definition = definition.ComponentDef.create(self._db, name, None)
component_definition = definition.ComponentDef.create(db=self._db, comp_def_name=name, fp=None)
if component_definition.is_null:
self._logger.error("Failed to create component definition {}".format(name))
return None
Expand Down Expand Up @@ -1332,12 +1333,12 @@ def create(

"""
if component_part_name:
compdef = self._getComponentDefinition(component_part_name, pins)
compdef = self._get_component_definition(component_part_name, pins)
else:
compdef = self._getComponentDefinition(component_name, pins)
compdef = self._get_component_definition(component_name, pins)
if not compdef:
return False
new_cmp = hierarchy.ComponentGroup.create(self._active_layout, component_name, compdef.name)
new_cmp = hierarchy.ComponentGroup.create(self._layout, component_name, compdef.name)

if isinstance(pins[0], EDBPadstackInstance):
pins = [i._edb_padstackinstance for i in pins]
Expand Down Expand Up @@ -1698,7 +1699,8 @@ def set_solder_ball(
pad_params = self._padstack.get_pad_parameters(pin=pin1, layername=pin_layers[0], pad_type=0)
_sb_diam = min([utility.Value(val).value for val in pad_params[1]])
sball_diam = _sb_diam
sball_height = round(utility.Value(sball_diam).value, 9) / 2
if not sball_height:
sball_height = 2 * round(utility.Value(sball_diam).value, 9) / 3
if not sball_mid_diam:
sball_mid_diam = sball_diam

Expand All @@ -1709,20 +1711,17 @@ def set_solder_ball(

cmp_property = edb_cmp.component_property
if cmp_type == hierarchy.ComponentType.IC:
ic_die_prop = cmp_property.die_property
ic_die_prop = cmp_property.die_property.clone()
ic_die_prop.type = definition.DieType.FLIPCHIP
if chip_orientation.lower() == "chip_down":
ic_die_prop.orientation = definition.DieOrientation.CHIP_DOWN
if chip_orientation.lower() == "chip_up":
ic_die_prop.orientation = definition.DieOrientation.CHIP_UP
else:
ic_die_prop.orientation = definition.DieOrientation.CHIP_DOWN
cmp_property.die_property = ic_die_prop

solder_ball_prop = cmp_property.solder_ball_property
solder_ball_prop.diameter = (utility.Value(sball_diam), utility.Value(sball_mid_diam))
solder_ball_prop.set_diameter(utility.Value(sball_diam), utility.Value(sball_mid_diam))
solder_ball_prop.height = utility.Value(sball_height)

solder_ball_prop.shape = sball_shape
cmp_property.solder_ball_property = solder_ball_prop

Expand Down
59 changes: 32 additions & 27 deletions src/pyedb/grpc/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def open_edb(self):
try:
self._db = database.Database.open(self.edbpath, self.isreadonly)
except Exception as e:
self.logger.error("EDB Builder not Initialized.")
self.logger.error(e.args[0])
if not self.active_db:
self.logger.warning("Error Opening db")
self._active_cell = None
Expand Down Expand Up @@ -1133,7 +1133,7 @@ def _create_extent(
reference_list=[],
include_pingroups=True,
):
if extent_type in ["Conforming", self.edb_api.geometry.extent_type.Conforming, 1]:
if extent_type in ["Conforming", geometry.ExtentType.CONFORMING, 1]:
if use_pyaedt_extent:
_poly = self._create_conformal(
net_signals,
Expand All @@ -1148,15 +1148,15 @@ def _create_extent(
else:
_poly = self.layout.expanded_extent(
net_signals,
self.edb_api.geometry.extent_type.Conforming,
geometry.ExtentType.CONFORMING,
expansion_size,
False,
use_round_corner,
1,
)
elif extent_type in ["Bounding", self.edb_api.geometry.extent_type.BoundingBox, 0]:
elif extent_type in ["Bounding", geometry.ExtentType.BOUNDING_BOX, 0]:
_poly = self.layout.expanded_extent(
net_signals, self.edb_api.geometry.extent_type.BoundingBox, expansion_size, False, use_round_corner, 1
net_signals, geometry.ExtentType.BOUNDING_BOX, expansion_size, False, use_round_corner, 1
)
else:
if use_pyaedt_extent:
Expand All @@ -1173,14 +1173,14 @@ def _create_extent(
else:
_poly = self.layout.expanded_extent(
net_signals,
self.edb_api.geometry.extent_type.Conforming,
geometry.ExtentType.CONFORMING,
expansion_size,
False,
use_round_corner,
1,
)
_poly_list = convert_py_list_to_net_list([_poly])
_poly = self.edb_api.geometry.polygon_data.get_convex_hull_of_polygons(_poly_list)
_poly_list = [_poly]
_poly = geometry.PolygonData.convex_hull(_poly_list)
return _poly

@pyedb_function_handler()
Expand All @@ -1201,27 +1201,27 @@ def _create_conformal(
names.append(net.GetName())
for prim in self.modeler.primitives:
if prim is not None and prim.net_name in names:
obj_data = prim.primitive_object.GetPolygonData().Expand(
obj_data = prim.primitive_object.polygon_data.expand(
expansion_size, tolerance, round_corner, round_extension
)
if obj_data:
_polys.extend(list(obj_data))
if smart_cutout:
_polys.extend(self._smart_cut(net_signals, reference_list, include_pingroups))
_poly_unite = self.edb_api.geometry.polygon_data.unite(_polys)
_poly_unite = geometry.PolygonData.unite(_polys)
if len(_poly_unite) == 1:
return _poly_unite[0]
else:
areas = [i.Area() for i in _poly_unite]
areas = [i.area for i in _poly_unite]
return _poly_unite[areas.index(max(areas))]

@pyedb_function_handler()
def _smart_cut(self, net_signals, reference_list=[], include_pingroups=True):
_polys = []
terms = [term for term in self.layout.terminals if int(term.GetBoundaryType()) in [0, 3, 4, 7, 8]]
terms = [term for term in self.layout.terminals if term.boundary_type.value in [0, 3, 4, 7, 8]]
locations = []
for term in terms:
if term.GetTerminalType().ToString() == "PadstackInstanceTerminal":
if term.terminal_type == "PadstackInstanceTerminal":
if term.GetParameters()[1].GetNet().GetName() in reference_list:
locations.append(self.padstacks.instances[term.GetParameters()[1].GetId()].position)
elif term.GetTerminalType().ToString() == "PointTerminal" and term.GetNet().GetName() in reference_list:
Expand Down Expand Up @@ -1269,14 +1269,22 @@ def _create_convex_hull(
names = []
_polys = []
for net in net_signals:
names.append(net.GetName())
names.append(net.name)
for prim in self.modeler.primitives:
if prim is not None and prim.net_name in names:
_polys.append(prim.primitive_object.GetPolygonData())
if prim.type == "Path":
path_polygon_data = prim.primitive_object.polygon_data # missing in edb api
if path_polygon_data:
_polys.append(path_polygon_data)
else:
_polys.append(prim.primitive_object.polygon_data)
if smart_cut:
_polys.extend(self._smart_cut(net_signals, reference_list, include_pingroups))
_poly = self.edb_api.geometry.polygon_data.get_convex_hull_of_polygons(convert_py_list_to_net_list(_polys))
_poly = _poly.Expand(expansion_size, tolerance, round_corner, round_extension)[0]
_poly = geometry.PolygonData.convex_hull(_polys)
_poly = _poly.expand(offset=expansion_size,
tol=tolerance,
round_corner=round_corner,
max_corner_ext=round_extension)[0]
return _poly

@pyedb_function_handler()
Expand Down Expand Up @@ -1526,15 +1534,13 @@ def _create_cutout_legacy(
check_terminals=False,
include_pingroups=True,
):
expansion_size = self.edb_value(expansion_size).ToDouble()
expansion_size = utility.Value(expansion_size).value

# validate nets in layout
net_signals = [net.api_object for net in self.layout.nets if net.name in signal_list]
net_signals = [net for net in self.layout.nets if net.name in signal_list]

# validate references in layout
_netsClip = convert_py_list_to_net_list(
[net.api_object for net in self.layout.nets if net.name in reference_list]
)
_netsClip = [net for net in self.layout.nets if net.name in reference_list]

_poly = self._create_extent(
net_signals,
Expand All @@ -1549,9 +1555,8 @@ def _create_cutout_legacy(

# Create new cutout cell/design
included_nets_list = signal_list + reference_list
included_nets = convert_py_list_to_net_list(
[net.api_object for net in self.layout.nets if net.name in included_nets_list]
)
included_nets = [net for net in self.layout.nets if net.name in included_nets_list]

_cutout = self.active_cell.CutOut(included_nets, _netsClip, _poly, True)
# Analysis setups do not come over with the clipped design copy,
# so add the analysis setups from the original here.
Expand Down Expand Up @@ -2808,8 +2813,8 @@ def build_simulation_project(self, simulation_setup):
]
self.nets.delete(nets_to_remove)
self.logger.info("Deleting existing ports.")
map(lambda port: port.Delete(), self.layout.terminals)
map(lambda pg: pg.Delete(), self.layout.pin_groups)
map(lambda port: port.delete(), self.layout.terminals)
map(lambda pg: pg.delete(), self.layout.pin_groups)
if simulation_setup.solver_type == SolverType.Hfss3dLayout:
if simulation_setup.generate_excitations:
self.logger.info("Creating HFSS ports for signal nets.")
Expand Down
10 changes: 4 additions & 6 deletions src/pyedb/grpc/edb_core/edb_data/hfss_simulation_setup_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,18 +1712,16 @@ def __init__(self, edb, name=None, edb_hfss_sim_setup=None):

if edb_hfss_sim_setup:
self._edb_sim_setup = edb_hfss_sim_setup
self._edb_sim_setup_info = edb_hfss_sim_setup.GetSimSetupInfo()
self._name = edb_hfss_sim_setup.name
else:
self._edb_sim_setup_info = simulation_setup.HfssSimulationSetup().create().settings
if not name:
self._edb_sim_setup_info.Name = generate_unique_name("hfss")
self._name = generate_unique_name("hfss")
else:
self._edb_sim_setup_info.Name = name
self._name = name
self._name = name
edb_hfss_sim_setup = simulation_setup.HfssSimulationSetup.create(cell=self._edb.active_cell, name=self.name)
self.hfss_solver_settings.order_basis = "mixed"

self._edb_sim_setup = HfssSimulationSetup(self._edb_sim_setup_info)
self._edb_sim_setup = HfssSimulationSetup(edb_hfss_sim_setup)
self._update_setup()

@property
Expand Down
10 changes: 6 additions & 4 deletions src/pyedb/grpc/edb_core/edb_data/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from pyedb.grpc.edb_core.edb_data.terminals import EdgeTerminal
from pyedb.grpc.edb_core.edb_data.terminals import PadstackInstanceTerminal
from pyedb.grpc.edb_core.edb_data.terminals import Terminal
from ansys.edb.utility.value import Value
import ansys.edb.utility as utility
import ansys.edb.database as database


class GapPort(EdgeTerminal):
Expand Down Expand Up @@ -84,6 +85,7 @@ def horizontal_extent_factor(self):

@horizontal_extent_factor.setter
def horizontal_extent_factor(self, value):
self._edb_object.product_solver_names(database.ProductIdType.HFSS_3D_LAYOUT)
p = self._hfss_port_property
p["Horizontal Extent Factor"] = value
self._hfss_port_property = p
Expand Down Expand Up @@ -129,7 +131,7 @@ def deembed_length(self):
@deembed_length.setter
def deembed_length(self, value):
p = self._edb_object.port_post_processing_prop
p.deembed_length = Value(value)
p.deembed_length = utility.Value(value)
self._edb_object.port_post_processing_prop = p


Expand Down Expand Up @@ -165,7 +167,7 @@ def magnitude(self):

@magnitude.setter
def magnitude(self, value):
self._edb_object.source_amplitude = Value(value)
self._edb_object.source_amplitude = utility.Value(value)

@property
def phase(self):
Expand All @@ -174,7 +176,7 @@ def phase(self):

@phase.setter
def phase(self, value):
self._edb_object.source_phase = Value(value)
self._edb_object.source_phase = utility.Value(value)


class ExcitationProbes(Terminal):
Expand Down
4 changes: 4 additions & 0 deletions src/pyedb/grpc/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def type(self):
return f"{str_type[-1][0]}{str_type[-1][1:].lower()}"
return None

@property
def id(self):
return self.primitive_object.id

@property
def net(self):
if self.net_name:
Expand Down
3 changes: 1 addition & 2 deletions src/pyedb/grpc/edb_core/edb_data/simulation_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,7 +2232,6 @@ def __init__(self, filename=None, edb=None):
self._solver_type = SolverType.Hfss3dLayout
if self._filename and os.path.splitext(self._filename)[1] == ".json":
self.import_json(filename)
self._read_cfg()
self._pedb = edb
self.SOLVER_TYPE = SolverType

Expand Down Expand Up @@ -2395,7 +2394,7 @@ def _dict_to_json(self, dict_out, dict_in=None):
dict_out[k[1:]] = sources_out
elif k == "_dc_source_terms_to_ground":
dc_term_gnd = {}
for k2 in list(v.Keys): # pragma: no cover
for k2 in list(v.keys()): # pragma: no cover
dc_term_gnd[k2] = v[k2]
dict_out[k[1:]] = dc_term_gnd
else:
Expand Down
11 changes: 10 additions & 1 deletion src/pyedb/grpc/edb_core/edb_data/terminals.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def _hfss_port_property(self, value):
@property
def hfss_type(self):
"""HFSS port type."""
return self._hfss_port_property["HFSS Type"]
if self.type.name == "EDGE":
return "Gap"
elif self.type.name == "POINT":
return "Circuit"
elif self.type.name == "PADSTACK_INST":
return "Coax"
elif self.type.name == "BUNDLE":
return "Wave"
else:
return "Terminal"

@hfss_type.setter
def hfss_type(self, value):
Expand Down
Loading
Loading