Skip to content

Commit

Permalink
Merge branch 'main' into release/0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Dec 6, 2022
2 parents 4bf5734 + 069458f commit bee9927
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 32 deletions.
46 changes: 29 additions & 17 deletions pyaedt/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def _clean_variables(self):
self.edbutils = None
self.simSetup = None
self.simsetupdata = None
self._setups = {}
# time.sleep(2)
# gc.collect()

Expand Down Expand Up @@ -992,6 +993,7 @@ def import_gds_file(self, inputGDS, WorkDir=None, anstranslator_full_path="", us
else:
return False

@pyaedt_function_handler()
def _create_extent(
self,
net_signals,
Expand Down Expand Up @@ -1023,23 +1025,23 @@ def _create_extent(
_poly = self.edb.Geometry.PolygonData.GetConvexHullOfPolygons(_poly_list)
return _poly

@pyaedt_function_handler()
def _create_conformal(self, net_signals, expansion_size, tolerance, round_corner, round_extension):
names = []
_polys = []
for net in net_signals:
names.append(net.GetName())
for prim in self.core_primitives.primitives:
if prim.net_name in names:
_polys.extend(
list(
prim.primitive_object.GetPolygonData().Expand(
expansion_size, tolerance, round_corner, round_extension
)
)
obj_data = prim.primitive_object.GetPolygonData().Expand(
expansion_size, tolerance, round_corner, round_extension
)
if obj_data:
_polys.extend(list(obj_data))
_poly = self.edb.Geometry.PolygonData.Unite(convert_py_list_to_net_list(_polys))[0]
return _poly

@pyaedt_function_handler()
def _create_convex_hull(self, net_signals, expansion_size, tolerance, round_corner, round_extension):
names = []
_polys = []
Expand Down Expand Up @@ -2234,15 +2236,15 @@ def setups(self):
Dict[str, :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveSYZSimulationSetup`]
"""
_setups = {}
for i in list(self.active_cell.SimulationSetups):
if i.GetType() == self.edb.Utility.SimulationSetupType.kHFSS:
_setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb.Utility.SimulationSetupType.kSIWave:
_setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb.Utility.SimulationSetupType.kSIWaveDCIR:
_setups[i.GetName()] = SiwaveDCSimulationSetup(self, i.GetName(), i)
return _setups
if i.GetName() not in self._setups:
if i.GetType() == self.edb.Utility.SimulationSetupType.kHFSS:
self._setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb.Utility.SimulationSetupType.kSIWave:
self._setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb.Utility.SimulationSetupType.kSIWaveDCIR:
self._setups[i.GetName()] = SiwaveDCSimulationSetup(self, i.GetName(), i)
return self._setups

@property
def hfss_setups(self):
Expand Down Expand Up @@ -2294,7 +2296,9 @@ def create_hfss_setup(self, name=None):
"""
if name in self.setups:
return False
return HfssSimulationSetup(self, name)
setup = HfssSimulationSetup(self, name)
self._setups[name] = setup
return setup

def create_siwave_syz_setup(self, name=None):
"""Create a setup from a template.
Expand All @@ -2317,9 +2321,13 @@ def create_siwave_syz_setup(self, name=None):
... ["linear scale", "0.1GHz", "10GHz", "0.1GHz"],
... ])
"""
if not name:
name = generate_unique_name("Siwave_SYZ")
if name in self.setups:
return False
return SiwaveSYZSimulationSetup(self, name)
setup = SiwaveSYZSimulationSetup(self, name)
self._setups[name] = setup
return setup

def create_siwave_dc_setup(self, name=None):
"""Create a setup from a template.
Expand All @@ -2339,6 +2347,10 @@ def create_siwave_dc_setup(self, name=None):
>>> setup1.mesh_bondwires = True
"""
if not name:
name = generate_unique_name("Siwave_DC")
if name in self.setups:
return False
return SiwaveDCSimulationSetup(self, name)
setup = SiwaveDCSimulationSetup(self, name)
self._setups[name] = setup
return setup
3 changes: 3 additions & 0 deletions pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,8 +1721,11 @@ def name(self):

@name.setter
def name(self, value):
legacy_name = self._name
self._edb_sim_setup_info.Name = value
self._update_setup()
if legacy_name in self._edb.setups:
del self._edb._setups[legacy_name]
self._name = value

@property
Expand Down
101 changes: 92 additions & 9 deletions pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,12 @@ class SiwaveSYZSimulationSetup(SiwaveAdvancedSettings, object):
def __init__(self, edb, name=None, edb_siwave_sim_setup=None):
self._edb = edb
self._sweep_data_list = {}
self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[
self._edb.simsetupdata.SIwave.SIWSimulationSettings
]()
if edb_siwave_sim_setup:
self._edb_sim_setup_info = edb_siwave_sim_setup
self._edb_sim_setup_info = _get_edb_setup_info(edb_siwave_sim_setup, self._edb_sim_setup_info)
else:
self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[
self._edb.simsetupdata.SIwave.SIWSimulationSettings
]()
if not name:
self._edb_sim_setup_info.Name = generate_unique_name("siwave")
else:
Expand Down Expand Up @@ -742,8 +742,11 @@ def name(self):
@name.setter
def name(self, value):
"""Set name of the setup."""
legacy_name = self._edb_sim_setup_info.Name
self._edb_sim_setup_info.Name = value
self._update_setup()
if legacy_name in self._edb.setups:
del self._edb._setups[legacy_name]

@property
def enabled(self):
Expand Down Expand Up @@ -831,19 +834,96 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None):
return sweep


def _parse_value(v):
"""
Parameters
----------
v :
Returns
-------
"""
# duck typing parse of the value 'v'
if v is None:
pv = v
elif v == "true":
pv = True
elif v == "false":
pv = False
else:
try:
pv = int(v)
except ValueError:
try:
pv = float(v)
except ValueError:
pv = v
return pv


@pyaedt_function_handler()
def _get_edb_setup_info(edb_siwave_sim_setup, edb_sim_setup_info):
string = edb_siwave_sim_setup.ToString().replace("\t", "").split("\r\n")

keys = [i.split("=")[0] for i in string if len(i.split("=")) == 2 and "SourceTermsToGround" not in i]
values = [i.split("=")[1] for i in string if len(i.split("=")) == 2 and "SourceTermsToGround" not in i]
for val in string:
if "SourceTermsToGround()" in val:
break
elif "SourceTermsToGround" in val:
sources = {}
val = val.replace("SourceTermsToGround(", "").replace(")", "").split(",")
for v in val:
source = v.split("=")
sources[source[0]] = source[1]
edb_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(sources)
break
for k in keys:
value = _parse_value(values[keys.index(k)])
setter = None
if k in dir(edb_sim_setup_info.SimulationSettings):
setter = edb_sim_setup_info.SimulationSettings
elif k in dir(edb_sim_setup_info.SimulationSettings.AdvancedSettings):
setter = edb_sim_setup_info.SimulationSettings.AdvancedSettings

elif k in dir(edb_sim_setup_info.SimulationSettings.DCAdvancedSettings):
setter = edb_sim_setup_info.SimulationSettings.DCAdvancedSettings
elif "DCIRSettings" in dir(edb_sim_setup_info.SimulationSettings) and k in dir(
edb_sim_setup_info.SimulationSettings.DCIRSettings
):
setter = edb_sim_setup_info.SimulationSettings.DCIRSettings
elif k in dir(edb_sim_setup_info.SimulationSettings.DCSettings):
setter = edb_sim_setup_info.SimulationSettings.DCSettings
elif k in dir(edb_sim_setup_info.SimulationSettings.AdvancedSettings):
setter = edb_sim_setup_info.SimulationSettings.AdvancedSettings
if setter:
try:
setter.__setattr__(k, value)
except TypeError:
try:
setter.__setattr__(k, str(value))
except:
pass


class SiwaveDCSimulationSetup(SiwaveDCAdvancedSettings, object):
"""Manages EDB methods for HFSS simulation setup."""

def __init__(self, edb, name=None, edb_siwave_sim_setup=None):
self._edb = edb
self._mesh_operations = {}

self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[
self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings
]()
if edb_siwave_sim_setup:
self._edb_sim_setup_info = edb_siwave_sim_setup

self._edb_sim_setup_info = _get_edb_setup_info(edb_siwave_sim_setup, self._edb_sim_setup_info)

else:
self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[
self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings
]()

if not name:
self._edb_sim_setup_info.Name = generate_unique_name("siwave")
else:
Expand Down Expand Up @@ -872,8 +952,11 @@ def name(self):
@name.setter
def name(self, value):
"""Set name of the setup."""
legacy_name = self._edb_sim_setup_info.Name
self._edb_sim_setup_info.Name = value
self._update_setup()
if legacy_name in self._edb.setups:
del self._edb._setups[legacy_name]

@property
def enabled(self):
Expand Down
20 changes: 16 additions & 4 deletions pyaedt/edb_core/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ def get_plot_data(
layer_name = path.layer_name
if net_name not in nets or layer_name not in layers:
continue
x, y = path.points()
try:
x, y = path.points()
except ValueError:
x = None
if not x:
continue
create_label = False
Expand Down Expand Up @@ -965,19 +968,28 @@ def find_and_fix_disjoint_nets(self, net_list=None, keep_only_main_net=False, cl
for disjoints in sorted_list[1:]:
if keep_only_main_net:
for geo in disjoints:
obj_dict[geo].delete()
try:
obj_dict[geo].delete()
except KeyError:
pass
elif len(disjoints) == 1 and (
isinstance(obj_dict[disjoints[0]], EDBPadstackInstance)
or clean_disjoints_less_than
and obj_dict[disjoints[0]].area() < clean_disjoints_less_than
):
obj_dict[disjoints[0]].delete()
try:
obj_dict[disjoints[0]].delete()
except KeyError:
pass
else:
new_net_name = generate_unique_name(net, n=3)
if self.find_or_create_net(new_net_name):
new_nets.append(new_net_name)
for geo in disjoints:
obj_dict[geo].net_name = new_net_name
try:
obj_dict[geo].net_name = new_net_name
except KeyError:
pass
disjoints_objects.extend(disjoints)
self._logger.info_timer("Disjoint Cleanup Completed.")
self._logger.info("Found {} objects in {} new nets.".format(len(disjoints_objects), len(new_nets)))
Expand Down
2 changes: 1 addition & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ imageio-ffmpeg==0.4.7
ipython==8.7.0
ipywidgets==8.0.2
joblib==1.2.0
jupyterlab==3.5.0
jupyterlab==3.5.1
matplotlib==3.6.2
nbsphinx==0.8.10
numpydoc==1.5.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ openpyxl==3.0.10
pandas==1.5.2
pytest==7.2.0
pytest-cov==4.0.0
pytest-xdist==3.0.2
pytest-xdist==3.1.0
pyvista==0.37.0
scikit-learn==1.1.3
sklearn==0.0.post1

0 comments on commit bee9927

Please sign in to comment.