Skip to content

Commit

Permalink
Merge pull request #55 from ansys-internal/create_siwave_syz_setup
Browse files Browse the repository at this point in the history
Create siwave syz setup
  • Loading branch information
svandenb-dev authored Nov 8, 2023
2 parents f967c3a + f117226 commit c35094f
Show file tree
Hide file tree
Showing 10 changed files with 720 additions and 360 deletions.
26 changes: 14 additions & 12 deletions src/pyedb/grpc/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ def create_port_on_component(
if reference_net in net_list:
net_list.remove(reference_net)
cmp_pins = [
p for p in list(component.layout_objs) if int(p.obj_type) == 1 and p.net.name in net_list
]
p for p in list(component.members) if not p.net.is_null and p.layout_obj_type.value == 1
and p.net.name in net_list]
for p in cmp_pins: # pragma no cover
if not p.is_layout_pin:
p.is_layout_pin = True
Expand All @@ -846,10 +846,8 @@ def create_port_on_component(

elif port_type == SourceType.CircPort: # pragma no cover
ref_pins = [
p
for p in list(component.layout_objs)
if int(p.obj_type) == 1 and p.net.name in reference_net
]
p for p in list(component.members) if not p.net.is_null and p.layout_obj_type.value == 1
and p.net.name in reference_net]
for p in ref_pins:
if not p.is_layout_pin:
p.is_layout_pin = True
Expand All @@ -860,7 +858,7 @@ def create_port_on_component(
ref_pin_group_term = self._create_terminal(ref_pins[0])
else:
ref_pin_group = self.create_pingroup_from_pins(ref_pins)
if not ref_pin_group:
if not ref_pin_group or ref_pin_group.is_null:
return False
ref_pin_group_term = self._create_pin_group_terminal(ref_pin_group, isref=True)
if not ref_pin_group_term:
Expand All @@ -874,7 +872,7 @@ def create_port_on_component(
pin_term.reference_terminal = ref_pin_group_term
else:
pin_group = self.create_pingroup_from_pins(pins)
if not pin_group:
if not pin_group or pin_group.is_null:
return False
pin_group_term = self._create_pin_group_terminal(pin_group)
if pin_group_term:
Expand Down Expand Up @@ -1179,12 +1177,16 @@ def _create_pin_group_terminal(self, pingroup, isref=False):
-------
Edb pin group terminal.
"""
pin = list(pingroup.pins)[0]
term_name = "{}.{}.{}".format(pin.GetComponent().name, pin.component.name, pin.net.name)
for t in list(self._pedb.active_layout.terminals):
pin = pingroup.pins[0]
term_name = "{}.{}.{}".format(pin.component.name, pin.component.name, pin.net.name)
for t in self._pedb.active_layout.terminals:
if t.name == term_name:
return t
pingroup_term = terminal.PinGroupTerminal.create(self._active_layout, pingroup.net, term_name, pingroup, isref)
pingroup_term = terminal.PinGroupTerminal.create(layout=self._pedb.active_layout,
net_ref=pingroup.net,
name=term_name,
pin_group=pingroup,
is_ref=isref)
return pingroup_term

@pyedb_function_handler()
Expand Down
86 changes: 36 additions & 50 deletions src/pyedb/grpc/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import ansys.edb.database as database
import ansys.edb.layout_instance as layout_instance
import pyedb.generic as generic
import ansys.edb.utility as utility
import ansys.edb.terminal as terminal
import ansys.edb.simulation_setup as simulation_setup

from pyedb.grpc.components import Components
from pyedb.grpc.edb_core.edb_data.control_file import ControlFile
Expand Down Expand Up @@ -392,7 +394,7 @@ def ports(self):
@property
def excitations_nets(self):
"""Get all excitations net names."""
names = list(set([i.GetNet().GetName() for i in self.layout.terminals]))
names = list(set([i.net.name for i in self.layout.terminals]))
names = [i for i in names if i]
return names

Expand Down Expand Up @@ -609,7 +611,7 @@ def active_layout(self):
-------
Instance of EDB API Layout Class.
"""
return self.layout._layout
return self.layout

@property
def layout_instance(self):
Expand Down Expand Up @@ -851,17 +853,6 @@ def differential_pairs(self):
else: # pragma: no cover
return


# class Boundaries:
# """Boundaries Enumerator.
#
# Returns
# -------
# int
# """
#
# (Port, Pec, RLC, CurrentSource, VoltageSource, NexximGround, NexximPort, DcTerminal, VoltageProbe) = range(0, 9)
#
@pyedb_function_handler()
def point_3d(self, x, y, z=0.0):
"""Compute the Edb 3d Point Data.
Expand All @@ -879,7 +870,7 @@ def point_3d(self, x, y, z=0.0):
-------
``Geometry.Point3DData``.
"""
return self.edb_api.geometry.point3d_data(x, y, z)
return geometry.Point3DData(utility.Value(x), utility.Value(y), utility.Value(z))

@pyedb_function_handler()
def point_data(self, x, y=None):
Expand All @@ -898,9 +889,9 @@ def point_data(self, x, y=None):
``Geometry.PointData``.
"""
if y is None:
return self.edb_api.geometry.point_data(x)
return geometry.PointData(utility.Value(x))
else:
return self.edb_api.geometry.point_data(x, y)
return geometry.PointData(utility.Value(x), utility.Value(y))

@pyedb_function_handler()
def _is_file_existing_and_released(self, filename):
Expand Down Expand Up @@ -1017,10 +1008,8 @@ def save_edb_as(self, fname):
self._logger = self._global_logger

self.log_name = os.path.join(
os.path.dirname(fname), "pyaedt_" + os.path.splitext(os.path.split(fname)[-1])[0] + ".log"
os.path.dirname(fname), "pyedb_" + os.path.splitext(os.path.split(fname)[-1])[0] + ".log"
)
if settings.enable_local_log_file:
self._logger = self._global_logger.add_file_logger(self.log_name, "Edb")
return True

@pyedb_function_handler()
Expand Down Expand Up @@ -2561,24 +2550,14 @@ def variable_exists(self, variable_name):
Returns
-------
tuple of bool and VaribleServer
It returns a booleand to check if the variable exists and the variable
It returns a boole and to check if the variable exists and the variable
server that should contain the variable.
"""
if "$" in variable_name:
if variable_name.index("$") == 0:
var_server = self.active_db.GetVariableServer()

else:
var_server = self.active_cell.GetVariableServer()

else:
var_server = self.active_cell.GetVariableServer()

variables = var_server.GetAllVariableNames()
if variable_name in list(variables):
return True, var_server
return False, var_server

if variable_name in self.active_db.get_all_variable_names():
return True
if variable_name in self.active_cell.get_all_variable_names():
return True
return False
@pyedb_function_handler()
def get_variable(self, variable_name):
"""Return Variable Value if variable exists.
Expand Down Expand Up @@ -2629,7 +2608,11 @@ def add_project_variable(self, variable_name, variable_value):
"""
if not variable_name.startswith("$"):
variable_name = "${}".format(variable_name)
return self.add_design_variable(variable_name=variable_name, variable_value=variable_value)
if self.variable_exists(variable_name):
self.logger.error("Variable %s already exists.", variable_name)
return False
self.active_db.add_variable(variable_name, utility.Value(variable_value))
return self.active_db.create_value(variable_name)

@pyedb_function_handler()
def add_design_variable(self, variable_name, variable_value, is_parameter=False):
Expand Down Expand Up @@ -2667,12 +2650,15 @@ def add_design_variable(self, variable_name, variable_value, is_parameter=False)
"""
var_server = self.variable_exists(variable_name)
if not var_server[0]:
var_server[1].AddVariable(variable_name, self.edb_value(variable_value), is_parameter)
return True, var_server[1]
self.logger.error("Variable %s already exists.", variable_name)
return False, var_server[1]
if self.variable_exists(variable_name):
self.logger.error("Variable %s already exists.", variable_name)
return False
if variable_name.startswith("$"):
self.active_db.add_variable(variable_name, utility.Value(variable_value), is_parameter)
return self.active_db.create_value(variable_name)
else:
self.active_cell.add_variable(variable_name, utility.Value(variable_value), is_parameter)
return self.active_cell.create_value(variable_name)

@pyedb_function_handler()
def change_design_variable_value(self, variable_name, variable_value):
Expand Down Expand Up @@ -3012,14 +2998,14 @@ def setups(self):
Dict[str, :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveSYZSimulationSetup`]
"""
for i in list(self.active_cell.SimulationSetups):
if i.GetName() not in self._setups:
if i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kHFSS:
self._setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWave:
self._setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i.GetName(), i)
elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWaveDCIR:
self._setups[i.GetName()] = SiwaveDCSimulationSetup(self, i.GetName(), i)
for i in self.active_cell.simulation_setups:
if i.name not in self._setups:
if i.type == simulation_setup.SimulationSetupType.HFSS:
self._setups[i.name] = HfssSimulationSetup(self, i.name, i)
elif i.type == simulation_setup.SimulationSetupType.SI_WAVE:
self._setups[i.name] = SiwaveSYZSimulationSetup(self, i.name, i)
elif i.type == simulation_setup.SimulationSetupType.SI_WAVE_DCIR:
self._setups[i.name] = SiwaveDCSimulationSetup(self, i.name, i)
return self._setups

@property
Expand Down
22 changes: 12 additions & 10 deletions src/pyedb/grpc/edb_core/edb_data/hfss_simulation_setup_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from pyedb.generic.general_methods import generate_unique_name
from pyedb.generic.general_methods import pyedb_function_handler
from ansys.edb.simulation_setup import SweepData
from ansys.edb.utility.value import Value
from ansys.edb.simulation_setup.hfss_simulation_settings import HFSSSimulationSettings
from ansys.edb.simulation_setup.hfss_simulation_setup import HfssSimulationSetup
import ansys.edb.utility as utility
#from ansys.edb.utility.value import Value
import ansys.edb.simulation_setup as simulation_setup
#from ansys.edb.simulation_setup.hfss_simulation_settings import HFSSSimulationSettings
#from ansys.edb.simulation_setup.hfss_simulation_setup import HfssSimulationSetup

class EdbFrequencySweep(object):
"""Manages EDB methods for frequency sweep."""
Expand Down Expand Up @@ -1182,9 +1184,9 @@ def add_adaptive_frequency_data(self, frequency=0, max_num_passes=10, max_delta_
``True`` if method is successful, ``False`` otherwise.
"""
low_freq_adapt_data = AdaptiveFrequencyData()
low_freq_adapt_data.max_delta = Value(max_delta_s)
low_freq_adapt_data.max_delta = utility.Value(max_delta_s)
low_freq_adapt_data.max_passes = max_num_passes
low_freq_adapt_data.adaptive_frequency = Value(frequency)
low_freq_adapt_data.adaptive_frequency = utility.Value(frequency)
self.adaptive_settings.adaptive_frequency_data = ""
self.adaptive_settings.adaptive_frequency_data = low_freq_adapt_data
return self._parent._update_setup()
Expand Down Expand Up @@ -1212,13 +1214,13 @@ def add_broadband_adaptive_frequency_data(
``True`` if method is successful, ``False`` otherwise.
"""
low_freq_adapt_data = self._parent._edb.simsetupdata.AdaptiveFrequencyData()
low_freq_adapt_data.max_delta = Value(max_delta_s)
low_freq_adapt_data.max_delta = utility.Value(max_delta_s)
low_freq_adapt_data.max_passes = max_num_passes
low_freq_adapt_data.adaptive_frequency = Value(low_frequency)
low_freq_adapt_data.adaptive_frequency = utility.Value(low_frequency)
high_freq_adapt_data = self._parent._edb.simsetupdata.AdaptiveFrequencyData()
high_freq_adapt_data.max_delta = Value(max_delta_s)
high_freq_adapt_data.max_delta = utility.Value(max_delta_s)
high_freq_adapt_data.may_passes = max_num_passes
high_freq_adapt_data.adaptive_fFrequency = Value(high_frequency)
high_freq_adapt_data.adaptive_fFrequency = utility.Value(high_frequency)
self.adaptive_settings.adaptive_frequency_data = ""
self.adaptive_settings.adaptive_frequency_data = [low_freq_adapt_data, high_freq_adapt_data]
return self._parent._update_setup()
Expand Down Expand Up @@ -1713,7 +1715,7 @@ def __init__(self, edb, name=None, edb_hfss_sim_setup=None):
self._edb_sim_setup_info = edb_hfss_sim_setup.GetSimSetupInfo()
self._name = edb_hfss_sim_setup.name
else:
self._edb_sim_setup_info = HFSSSimulationSettings()
self._edb_sim_setup_info = simulation_setup.HfssSimulationSetup().create().settings
if not name:
self._edb_sim_setup_info.Name = generate_unique_name("hfss")
else:
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/grpc/edb_core/edb_data/nets_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_smallest_trace_width(self):
current_value = 1e10
for prim in self.net_object.primitives:
if prim.primitive_type == PrimitiveType.PATH:
width = prim.GetWidth()
width = prim.width.value
if width < current_value:
current_value = width
return current_value
Expand Down
8 changes: 6 additions & 2 deletions src/pyedb/grpc/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def type(self):

@property
def net(self):
return self._app.nets.nets[self.net_name]
if self.net_name:
return self._app.nets.nets[self.net_name]
return False

@net.setter
def net(self, value):
Expand All @@ -118,7 +120,9 @@ def net_name(self):
-------
str
"""
return self.net.name
if not self.primitive_object.net.is_null:
return self.primitive_object.net.name
return False

@net_name.setter
def net_name(self, name):
Expand Down
Loading

0 comments on commit c35094f

Please sign in to comment.