From d3b429ac4a04ed3feb6175219cae92918d617c85 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 1 Nov 2023 15:46:15 +0100 Subject: [PATCH 01/61] fix --- pyaedt/edb_core/edb_data/sim_setup_info.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pyaedt/edb_core/edb_data/sim_setup_info.py diff --git a/pyaedt/edb_core/edb_data/sim_setup_info.py b/pyaedt/edb_core/edb_data/sim_setup_info.py new file mode 100644 index 00000000000..4a23cc87fa8 --- /dev/null +++ b/pyaedt/edb_core/edb_data/sim_setup_info.py @@ -0,0 +1,14 @@ +from pyaedt.generic.general_methods import generate_unique_name +from pyaedt.generic.general_methods import pyaedt_function_handler + + +class SimSetupInfo: + + def __init__(self, pedb, edb_object=None): + self._pedb = pedb + self._edb_object = edb_object + + @property + def type(self): + return self._edb_object.SimSetupType + From ea7e89c5f0b7bd32d13e67783a1fbe37764b4555 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 1 Nov 2023 16:58:40 +0100 Subject: [PATCH 02/61] fix --- pyaedt/edb.py | 19 +-- .../edb_data/hfss_simulation_setup_data.py | 66 +++++----- pyaedt/edb_core/edb_data/sim_setup_info.py | 23 +++- .../edb_data/siwave_simulation_setup_data.py | 123 +++++++----------- 4 files changed, 112 insertions(+), 119 deletions(-) diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 3613c80450e..574995dfbe8 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3324,15 +3324,16 @@ 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.GetName() not in self._setups: if i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kHFSS: - self._setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i) + 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) + 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) - return self._setups + setups[i.GetName()] = SiwaveDCSimulationSetup(self, i.GetName(), i) + return setups @property def hfss_setups(self): @@ -3414,11 +3415,11 @@ def create_siwave_syz_setup(self, name=None): name = generate_unique_name("Siwave_SYZ") if name in self.setups: return False - setup = SiwaveSYZSimulationSetup(self, name) - setup.si_slider_postion = 1 - setup.pi_slider_postion = 1 - self._setups[name] = setup - return setup + setup_info = SiwaveSYZSimulationSetup(self).create(name) + setup = self.edb_api.utility.utility.SIWaveSimulationSetup(setup_info._edb_object) + self.layout.cell.AddSimulationSetup(setup) + print(self.setups) + return setup_info @pyaedt_function_handler() def create_siwave_dc_setup(self, name=None): diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index 76e9cc8e6da..ad4ca77040c 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -24,10 +24,10 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No @pyaedt_function_handler() def _update_sweep(self): """Update sweep.""" - self._sim_setup._edb_sim_setup_info.SweepDataList.Clear() + self._sim_setup._edb_object.SweepDataList.Clear() for el in list(self._sim_setup.frequency_sweeps.values()): - self._sim_setup._edb_sim_setup_info.SweepDataList.Add(el._edb_sweep_data) - self._sim_setup._edb_sim_setup_info.SweepDataList.Add(self._edb_sweep_data) + self._sim_setup._edb_object.SweepDataList.Add(el._edb_sweep_data) + self._sim_setup._edb_object.SweepDataList.Add(self._edb_sweep_data) return self._sim_setup._update_setup() @property @@ -752,7 +752,7 @@ def __init__(self, parent): @property def _hfss_port_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.HFSSPortSettings + return self._parent._edb_object.SimulationSettings.HFSSPortSettings @property def max_delta_z0(self): @@ -824,7 +824,7 @@ def __init__(self, parent): @property def _hfss_solver_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.HFSSSolverSettings + return self._parent._edb_object.SimulationSettings.HFSSSolverSettings @property def enhanced_low_freq_accuracy(self): @@ -993,7 +993,7 @@ def adaptive_settings(self): ------- :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.AdaptiveSettings` """ - return self._parent._edb_sim_setup_info.SimulationSettings.AdaptiveSettings + return self._parent._edb_object.SimulationSettings.AdaptiveSettings @property def adaptive_frequency_data_list(self): @@ -1233,7 +1233,7 @@ def __init__(self, parent): @property def _defeature_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.DefeatureSettings + return self._parent._edb_object.SimulationSettings.DefeatureSettings @property def defeature_abs_length(self): @@ -1401,7 +1401,7 @@ def __init__( @property def _via_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.ViaSettings + return self._parent._edb_object.SimulationSettings.ViaSettings @property def via_density(self): @@ -1478,7 +1478,7 @@ def __init__(self, parent): @property def _advanced_mesh_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.AdvancedMeshSettings + return self._parent._edb_object.SimulationSettings.AdvancedMeshSettings @property def layer_snap_tol(self): @@ -1537,7 +1537,7 @@ def __init__(self, parent): @property def _curve_approx_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.CurveApproxSettings + return self._parent._edb_object.SimulationSettings.CurveApproxSettings @property def arc_angle(self): @@ -1623,7 +1623,7 @@ def __init__(self, parent): @property def _dcr_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.DCRSettings + return self._parent._edb_object.SimulationSettings.DCRSettings @property def conduction_max_passes(self): @@ -1711,35 +1711,35 @@ 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._edb_object = edb_hfss_sim_setup.GetSimSetupInfo() self._name = edb_hfss_sim_setup.GetName() else: - self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[ + self._edb_object = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.HFSSSimulationSettings ]() if not name: - self._edb_sim_setup_info.Name = generate_unique_name("hfss") + self._edb_object.Name = generate_unique_name("hfss") else: - self._edb_sim_setup_info.Name = name + self._edb_object.Name = name self._name = name self.hfss_solver_settings.order_basis = "mixed" - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) + self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_object) self._update_setup() @property def edb_sim_setup_info(self): """EDB internal simulation setup object.""" - return self._edb_sim_setup_info + return self._edb_object @pyaedt_function_handler() def _update_setup(self): - mesh_operations = self._edb_sim_setup_info.SimulationSettings.MeshOperations + mesh_operations = self._edb_object.SimulationSettings.MeshOperations mesh_operations.Clear() for mop in self.mesh_operations.values(): mesh_operations.Add(mop.mesh_operation) - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) + self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_object) if self._name in self._edb.setups: self._edb.active_cell.DeleteSimulationSetup(self._name) @@ -1747,7 +1747,7 @@ def _update_setup(self): self._edb.active_cell.AddSimulationSetup(self._edb_sim_setup) for i in list(self._edb.active_cell.SimulationSetups): if i.GetSimSetupInfo().Name == self._name: - self._edb_sim_setup_info = i.GetSimSetupInfo() + self._edb_object = i.GetSimSetupInfo() return True return False @@ -1760,19 +1760,19 @@ def frequency_sweeps(self): List of :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.EdbFrequencySweep` """ sweep_data_list = {} - for i in list(self._edb_sim_setup_info.SweepDataList): + for i in list(self._edb_object.SweepDataList): sweep_data_list[i.Name] = EdbFrequencySweep(self, None, i.Name, i) return sweep_data_list @property def name(self): """Name of the setup.""" - return self._edb_sim_setup_info.Name + return self._edb_object.Name @name.setter def name(self, value): legacy_name = self._name - self._edb_sim_setup_info.Name = value + self._edb_object.Name = value self._update_setup() if legacy_name in self._edb.setups: del self._edb._setups[legacy_name] @@ -1791,34 +1791,34 @@ def solver_slider_type(self): ------- str """ - return self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.ToString() + return self._edb_object.SimulationSettings.TSolveSliderType.ToString() @solver_slider_type.setter def solver_slider_type(self, value): """Set solver slider type.""" solver_types = { - "kFast": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaWirebond, - "kMedium": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaRibbon, - "kAccurate": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaMesh, - "kNumSliderTypes": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaField, + "kFast": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaWirebond, + "kMedium": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaRibbon, + "kAccurate": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaMesh, + "kNumSliderTypes": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaField, } - self._edb_sim_setup_info.SimulationSettings.TSolveSliderType = solver_types[value] + self._edb_object.SimulationSettings.TSolveSliderType = solver_types[value] self._update_setup() @property def is_auto_setup(self): """Whether if auto setup is enabled.""" - return self._edb_sim_setup_info.SimulationSettings.IsAutoSetup + return self._edb_object.SimulationSettings.IsAutoSetup @is_auto_setup.setter def is_auto_setup(self, value): - self._edb_sim_setup_info.SimulationSettings.IsAutoSetup = value + self._edb_object.SimulationSettings.IsAutoSetup = value self._update_setup() @property def setup_type(self): """Setup type.""" - return self._edb_sim_setup_info.SimulationSettings.SetupType + return self._edb_object.SimulationSettings.SetupType @property def hfss_solver_settings(self): @@ -1919,7 +1919,7 @@ def mesh_operations(self): """ if self._mesh_operations: return self._mesh_operations - settings = self._edb_sim_setup_info.SimulationSettings.MeshOperations + settings = self._edb_object.SimulationSettings.MeshOperations self._mesh_operations = {} for i in list(settings): if i.MeshOpType == i.TMeshOpType.kMeshSetupLength: diff --git a/pyaedt/edb_core/edb_data/sim_setup_info.py b/pyaedt/edb_core/edb_data/sim_setup_info.py index 4a23cc87fa8..b6c90f56f06 100644 --- a/pyaedt/edb_core/edb_data/sim_setup_info.py +++ b/pyaedt/edb_core/edb_data/sim_setup_info.py @@ -1,14 +1,31 @@ -from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler +from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import EdbFrequencySweep -class SimSetupInfo: +class SimSetupInfo(object): def __init__(self, pedb, edb_object=None): self._pedb = pedb self._edb_object = edb_object + self._name = "" @property - def type(self): + def name(self): + return self._edb_object.Name + + @name.setter + def name(self, value): + self._edb_object.Name = value + self._name = value + + @property + def setup_type(self): return self._edb_object.SimSetupType + @property + def frequency_sweeps(self): + """Get frequency sweep list.""" + temp = {} + for i in list(self._edb_object.SweepDataList): + temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) + return temp diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 71e10479425..54556b1f00b 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -4,6 +4,7 @@ from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import is_linux from pyaedt.generic.general_methods import pyaedt_function_handler +from pyaedt.edb_core.edb_data.sim_setup_info import SimSetupInfo class SiwaveAdvancedSettings(object): @@ -13,7 +14,7 @@ def __init__(self, parent): @property def sim_setup_info(self): """EDB internal simulation setup object.""" - return self._parent._edb_sim_setup_info + return self._parent._edb_object @property def include_inter_plane_coupling(self): @@ -365,7 +366,7 @@ def __init__(self, parent): def sim_setup_info(self): """EDB internal simulation setup object.""" - return self._parent._edb_sim_setup_info + return self._parent._edb_object @property def min_void_area(self): @@ -684,34 +685,33 @@ def refine_vias(self, value): self._parent._update_setup() -class SiwaveSYZSimulationSetup(SiwaveAdvancedSettings, object): +class SiwaveSYZSimulationSetup(SimSetupInfo, SiwaveAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" - 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: - _get_edb_setup_info(edb_siwave_sim_setup, self._edb_sim_setup_info) - else: - if not name: - self._edb_sim_setup_info.Name = generate_unique_name("siwave") - else: - self._edb_sim_setup_info.Name = name - self._update_setup() - self.setup_type = "kSIWave" + def __init__(self, pedb, edb_object=None): + super().__init__(pedb, edb_object) + self._edb = self._pedb + #self._sweep_data_list = {} + + if edb_object: + _get_edb_setup_info(edb_object, self._edb_object) + SiwaveAdvancedSettings.__init__(self, self) - @property - def edb_sim_setup_info(self): - """EDB internal simulation setup object.""" - return self._edb_sim_setup_info + @pyaedt_function_handler() + def create(self, name=None): + edb_object = self._edb.simsetupdata.SimSetupInfo[self._edb.simsetupdata.SIwave.SIWSimulationSettings]() + setup_info = SiwaveSYZSimulationSetup(self._pedb, edb_object) + if not name: + self._name = generate_unique_name(name) + setup_info.name = self._name + setup_info.si_slider_postion = 1 + setup_info.pi_slider_postion = 1 + return setup_info @pyaedt_function_handler() def _update_setup(self): - self._edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveSimulationSetup(self._edb_sim_setup_info) + self._edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveSimulationSetup(self._edb_object) if self.name in self._edb.setups: self._edb.layout.cell.DeleteSimulationSetup(self.name) self._edb.layout.cell.AddSimulationSetup(self._edb_sim_setup) @@ -727,44 +727,20 @@ def dc_settings(self): """ return SiwaveDCAdvancedSettings(self) - @property - def frequency_sweeps(self): - """Get frequency sweep list.""" - if self._sweep_data_list: - return self._sweep_data_list - self._sweep_data_list = {} - for i in list(self._edb_sim_setup_info.SweepDataList): - self._sweep_data_list[i.Name] = EdbFrequencySweep(self, None, i.Name, i) - return self._sweep_data_list - - @property - def name(self): - """Setup name.""" - return self._edb_sim_setup_info.Name - - @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): """Whether the setup is enabled.""" - return self._edb_sim_setup_info.SimulationSettings.Enabled + return self._edb_object.SimulationSettings.Enabled @enabled.setter def enabled(self, value): - self._edb_sim_setup_info.SimulationSettings.Enabled = value + self._edb_object.SimulationSettings.Enabled = value self._update_setup() @property def pi_slider_postion(self): """PI solider position. Values are from ``1`` to ``3``.""" - return self._edb_sim_setup_info.SimulationSettings.PISliderPos + return self._edb_object.SimulationSettings.PISliderPos @pi_slider_postion.setter def pi_slider_postion(self, value): @@ -789,14 +765,14 @@ def pi_slider_postion(self, value): self.include_fringe_coupling = True self.include_trace_coupling = True self.max_coupled_lines = 40 - self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_sim_setup_info.SimulationSettings.PISliderPos = value + self._edb_object.SimulationSettings.UseCustomSettings = False + self._edb_object.SimulationSettings.PISliderPos = value self._update_setup() @property def si_slider_postion(self): """SI solider position. Values are from ``1`` to ``3``.""" - return self._edb_sim_setup_info.SimulationSettings.SISliderPos + return self._edb_object.SimulationSettings.SISliderPos @si_slider_postion.setter def si_slider_postion(self, value): @@ -824,8 +800,8 @@ def si_slider_postion(self, value): self.include_trace_coupling = True self.max_coupled_lines = 40 self.return_current_distribution = True - self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_sim_setup_info.SimulationSettings.SISliderPos = value + self._edb_object.SimulationSettings.UseCustomSettings = False + self._edb_object.SimulationSettings.SISliderPos = value self._update_setup() @property @@ -836,11 +812,11 @@ def use_custom_settings(self): ------- bool """ - return self._edb_sim_setup_info.SimulationSettings.UseCustomSettings + return self._edb_object.SimulationSettings.UseCustomSettings @use_custom_settings.setter def use_custom_settings(self, value): - self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = value + self._edb_object.SimulationSettings.UseCustomSettings = value self._update_setup() @property @@ -851,12 +827,12 @@ def use_si_settings(self): ------- bool """ - return self._edb_sim_setup_info.SimulationSettings.UseSISettings + return self._edb_object.SimulationSettings.UseSISettings @use_si_settings.setter def use_si_settings(self, value): - self._edb_sim_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_sim_setup_info.SimulationSettings.UseSISettings = value + self._edb_object.SimulationSettings.UseCustomSettings = False + self._edb_object.SimulationSettings.UseSISettings = value self._update_setup() @pyaedt_function_handler() @@ -888,7 +864,6 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): if not name: name = generate_unique_name("sweep") sweep = EdbFrequencySweep(self, frequency_sweep, name) - self._sweep_data_list[name] = sweep return sweep @@ -977,17 +952,17 @@ class SiwaveDCSimulationSetup(SiwaveDCAdvancedSettings, object): 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_object = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings ]() if edb_siwave_sim_setup: - _get_edb_setup_info(edb_siwave_sim_setup, self._edb_sim_setup_info) + _get_edb_setup_info(edb_siwave_sim_setup, self._edb_object) else: if not name: - self._edb_sim_setup_info.Name = generate_unique_name("siwave") + self._edb_object.Name = generate_unique_name("siwave") else: - self._edb_sim_setup_info.Name = name + self._edb_object.Name = name self._update_setup() self.setup_type = "kSIWaveDCIR" @@ -996,11 +971,11 @@ def __init__(self, edb, name=None, edb_siwave_sim_setup=None): @property def edb_sim_setup_info(self): """EDB internal simulation setup object.""" - return self._edb_sim_setup_info + return self._edb_object @pyaedt_function_handler() def _update_setup(self): - edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveDCIRSimulationSetup(self._edb_sim_setup_info) + edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveDCIRSimulationSetup(self._edb_object) if self.name in self._edb.setups: self._edb.layout.cell.DeleteSimulationSetup(self.name) self._edb.active_cell.AddSimulationSetup(edb_sim_setup) @@ -1009,13 +984,13 @@ def _update_setup(self): @property def name(self): """Setup name.""" - return self._edb_sim_setup_info.Name + return self._edb_object.Name @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 + legacy_name = self._edb_object.Name + self._edb_object.Name = value self._update_setup() if legacy_name in self._edb.setups: del self._edb._setups[legacy_name] @@ -1023,11 +998,11 @@ def name(self, value): @property def enabled(self): """Whether setup is enabled.""" - return self._edb_sim_setup_info.SimulationSettings.Enabled + return self._edb_object.SimulationSettings.Enabled @enabled.setter def enabled(self, value): - self._edb_sim_setup_info.SimulationSettings.Enabled = value + self._edb_object.SimulationSettings.Enabled = value self._update_setup() @property @@ -1040,7 +1015,7 @@ def source_terms_to_ground(self): {str, int}, keys is source name, value int 0 unspecified, 1 negative node, 2 positive one. """ - return convert_netdict_to_pydict(self._edb_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround) + return convert_netdict_to_pydict(self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround) @pyaedt_function_handler() def add_source_terminal_to_ground(self, source_name, terminal=0): @@ -1064,7 +1039,7 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): """ terminals = self.source_terms_to_ground terminals[source_name] = terminal - self._edb_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict( + self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict( terminals ) return self._update_setup() From fd8cbd410995dfa88e1ecee4ba685314193870ca Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 09:18:59 +0100 Subject: [PATCH 03/61] fix --- pyaedt/edb.py | 7 +- pyaedt/edb_core/edb_data/sim_setup_info.py | 31 --- pyaedt/edb_core/edb_data/simulation_setup.py | 201 ++++++++++++++++++ .../edb_data/siwave_simulation_setup_data.py | 185 +++------------- 4 files changed, 228 insertions(+), 196 deletions(-) delete mode 100644 pyaedt/edb_core/edb_data/sim_setup_info.py create mode 100644 pyaedt/edb_core/edb_data/simulation_setup.py diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 574995dfbe8..7118beff6df 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3330,9 +3330,9 @@ def setups(self): if i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kHFSS: setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i) elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWave: - setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i.GetName(), i) + setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i) elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWaveDCIR: - setups[i.GetName()] = SiwaveDCSimulationSetup(self, i.GetName(), i) + setups[i.GetName()] = SiwaveDCSimulationSetup(self, i) return setups @property @@ -3416,9 +3416,6 @@ def create_siwave_syz_setup(self, name=None): if name in self.setups: return False setup_info = SiwaveSYZSimulationSetup(self).create(name) - setup = self.edb_api.utility.utility.SIWaveSimulationSetup(setup_info._edb_object) - self.layout.cell.AddSimulationSetup(setup) - print(self.setups) return setup_info @pyaedt_function_handler() diff --git a/pyaedt/edb_core/edb_data/sim_setup_info.py b/pyaedt/edb_core/edb_data/sim_setup_info.py deleted file mode 100644 index b6c90f56f06..00000000000 --- a/pyaedt/edb_core/edb_data/sim_setup_info.py +++ /dev/null @@ -1,31 +0,0 @@ -from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import EdbFrequencySweep - - -class SimSetupInfo(object): - - def __init__(self, pedb, edb_object=None): - self._pedb = pedb - self._edb_object = edb_object - self._name = "" - - @property - def name(self): - return self._edb_object.Name - - @name.setter - def name(self, value): - self._edb_object.Name = value - self._name = value - - @property - def setup_type(self): - return self._edb_object.SimSetupType - - @property - def frequency_sweeps(self): - """Get frequency sweep list.""" - temp = {} - for i in list(self._edb_object.SweepDataList): - temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) - return temp diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py new file mode 100644 index 00000000000..9c831084e6f --- /dev/null +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -0,0 +1,201 @@ +from pyaedt.generic.general_methods import pyaedt_function_handler +from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import EdbFrequencySweep +from pyaedt.generic.general_methods import generate_unique_name +from pyaedt.generic.general_methods import is_linux +from pyaedt.edb_core.general import convert_netdict_to_pydict +from pyaedt.edb_core.general import convert_pydict_to_netdict + + +def _parse_value(v): + """ + + Parameters + ---------- + v : + + + Returns + ------- + + """ + # duck typing parse of the value 'v' + if v is None or v == "": + 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: + if isinstance(v, str) and v[0] == v[-1] == "'": + pv = v[1:-1] + else: + pv = v + return pv + + +class BaseSimulationSetup(object): + def __init__(self, pedb, edb_setup=None): + self._pedb = pedb + self._setup_type = None + if edb_setup: + self._edb_object = self._get_edb_setup_info(edb_setup) + else: + self._edb_object = None + self._name = "" + self._setup_type_mapping = { + "kHFSS": self._pedb.simsetupdata.HFSSSimulationSettings, + "kPEM": None, + "kSIwave": self._pedb.simsetupdata.SIwave.SIWSimulationSettings, + "kLNA": None, + "kTransient": None, + "kQEye": None, + "kVEye": None, + "kAMI": None, + "kAnalysisOption": None, + "kSIwaveDCIR": self._pedb.simsetupdata.SIwave.SIWDCIRSimulationSettings, + "kSIwaveEMI": None, + "kHFSSPI": None, + "kDDRwizard": None, + "kQ3D": None, + "kNumSetupTypes": None, + } + + + @pyaedt_function_handler() + def _get_edb_setup_info(self, edb_setup): + + if self._setup_type == "kSIwave": + edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self.setup_type]]() + + string = edb_setup.ToString().replace("\t", "").split("\r\n") + if is_linux: + string = string[0].split("\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 + return edb_sim_setup_info + elif self._setup_type == "kHFSS": + return edb_setup.GetSimSetupInfo() + + @property + def enabled(self): + """Whether the setup is enabled.""" + return self._edb_object.SimulationSettings.Enabled + + @enabled.setter + def enabled(self, value): + self._edb_object.SimulationSettings.Enabled = value + self._update_setup() + + @property + def name(self): + return self._edb_object.Name + + @name.setter + def name(self, value): + self._edb_object.Name = value + self._name = value + + @property + def position(self): + return self._edb_object.Position + + @position.setter + def position(self, value): + self._edb_object.Position = value + + @property + def setup_type(self): + return self._edb_object.SimSetupType.ToString() + + @property + def frequency_sweeps(self): + """Get frequency sweep list.""" + temp = {} + for i in list(self._edb_object.SweepDataList): + temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) + return temp + + @pyaedt_function_handler + def _create(self, name=None): + if not name: + name = generate_unique_name(self.setup_type) + self._name = name + + if self._edb_object: + self._setup_type = self.setup_type + + self._edb_object = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() + self._edb_object.Name = name + self._update_setup() + + @pyaedt_function_handler + def _generate_edb_setup(self): + setup_type_mapping = { + "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, + "kPEM": None, + "kSIwave": self._pedb.edb_api.utility.utility.SIWaveSimulationSetup, + "kLNA": None, + "kTransient": None, + "kQEye": None, + "kVEye": None, + "kAMI": None, + "kAnalysisOption": None, + "kSIwaveDCIR": self._pedb.edb_api.utility.utility.SIWaveDCIRSimulationSetup, + "kSIwaveEMI": None, + "kHFSSPI": None, + "kDDRwizard": None, + "kQ3D": None, + "kNumSetupTypes": None, + } + return setup_type_mapping[self.setup_type](self._edb_object) + + @pyaedt_function_handler() + def _update_setup(self): + edb_setup = self._generate_edb_setup() + if self.name in self._pedb.setups: + self._pedb.layout.cell.DeleteSimulationSetup(self.name) + self._pedb.layout.cell.AddSimulationSetup(edb_setup) + return True \ No newline at end of file diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 54556b1f00b..08721436e49 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -2,9 +2,8 @@ from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name -from pyaedt.generic.general_methods import is_linux from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.edb_core.edb_data.sim_setup_info import SimSetupInfo +from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup class SiwaveAdvancedSettings(object): @@ -685,37 +684,29 @@ def refine_vias(self, value): self._parent._update_setup() -class SiwaveSYZSimulationSetup(SimSetupInfo, SiwaveAdvancedSettings): +class SiwaveSYZSimulationSetup(BaseSimulationSetup, SiwaveAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" - def __init__(self, pedb, edb_object=None): - super().__init__(pedb, edb_object) + def __init__(self, pedb, edb_setup=None): + super().__init__(pedb, edb_setup) + self._setup_type = "kSIwave" self._edb = self._pedb #self._sweep_data_list = {} - if edb_object: - _get_edb_setup_info(edb_object, self._edb_object) SiwaveAdvancedSettings.__init__(self, self) @pyaedt_function_handler() def create(self, name=None): - edb_object = self._edb.simsetupdata.SimSetupInfo[self._edb.simsetupdata.SIwave.SIWSimulationSettings]() - setup_info = SiwaveSYZSimulationSetup(self._pedb, edb_object) - if not name: - self._name = generate_unique_name(name) - setup_info.name = self._name - setup_info.si_slider_postion = 1 - setup_info.pi_slider_postion = 1 - return setup_info + self._create(name) - @pyaedt_function_handler() - def _update_setup(self): - self._edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveSimulationSetup(self._edb_object) - if self.name in self._edb.setups: - self._edb.layout.cell.DeleteSimulationSetup(self.name) - self._edb.layout.cell.AddSimulationSetup(self._edb_sim_setup) - return True + self.restore_default() + self.use_si_settings = True + return self + + def restore_default(self): + self.si_slider_postion = 1 + self.pi_slider_postion = 1 @property def dc_settings(self): @@ -727,16 +718,6 @@ def dc_settings(self): """ return SiwaveDCAdvancedSettings(self) - @property - def enabled(self): - """Whether the setup is enabled.""" - return self._edb_object.SimulationSettings.Enabled - - @enabled.setter - def enabled(self, value): - self._edb_object.SimulationSettings.Enabled = value - self._update_setup() - @property def pi_slider_postion(self): """PI solider position. Values are from ``1`` to ``3``.""" @@ -867,143 +848,27 @@ 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 or v == "": - 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: - if isinstance(v, str) and v[0] == v[-1] == "'": - pv = v[1:-1] - else: - 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") - if is_linux: - string = string[0].split("\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): + + + +class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup, SiwaveDCAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" - def __init__(self, edb, name=None, edb_siwave_sim_setup=None): - self._edb = edb + def __init__(self, pedb, edb_object=None): + super().__init__(pedb, edb_object) + self._edb = pedb self._mesh_operations = {} self._edb_object = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings ]() - if edb_siwave_sim_setup: - _get_edb_setup_info(edb_siwave_sim_setup, self._edb_object) - - else: - if not name: - self._edb_object.Name = generate_unique_name("siwave") - else: - self._edb_object.Name = name - self._update_setup() - self.setup_type = "kSIWaveDCIR" SiwaveDCAdvancedSettings.__init__(self, self) - @property - def edb_sim_setup_info(self): - """EDB internal simulation setup object.""" - return self._edb_object - - @pyaedt_function_handler() - def _update_setup(self): - edb_sim_setup = self._edb.edb_api.utility.utility.SIWaveDCIRSimulationSetup(self._edb_object) - if self.name in self._edb.setups: - self._edb.layout.cell.DeleteSimulationSetup(self.name) - self._edb.active_cell.AddSimulationSetup(edb_sim_setup) - return True - - @property - def name(self): - """Setup name.""" - return self._edb_object.Name - - @name.setter - def name(self, value): - """Set name of the setup.""" - legacy_name = self._edb_object.Name - self._edb_object.Name = value - self._update_setup() - if legacy_name in self._edb.setups: - del self._edb._setups[legacy_name] - - @property - def enabled(self): - """Whether setup is enabled.""" - return self._edb_object.SimulationSettings.Enabled - - @enabled.setter - def enabled(self, value): - self._edb_object.SimulationSettings.Enabled = value - self._update_setup() + def create(self, name=None): + self._create(name) + self.restore_default() + self.use_si_settings = False + return self @property def source_terms_to_ground(self): From 153bfe2c555f07889909325a23d72e925f72ac49 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 09:22:55 +0100 Subject: [PATCH 04/61] fix --- .../edb_data/hfss_simulation_setup_data.py | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index ad4ca77040c..76e9cc8e6da 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -24,10 +24,10 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No @pyaedt_function_handler() def _update_sweep(self): """Update sweep.""" - self._sim_setup._edb_object.SweepDataList.Clear() + self._sim_setup._edb_sim_setup_info.SweepDataList.Clear() for el in list(self._sim_setup.frequency_sweeps.values()): - self._sim_setup._edb_object.SweepDataList.Add(el._edb_sweep_data) - self._sim_setup._edb_object.SweepDataList.Add(self._edb_sweep_data) + self._sim_setup._edb_sim_setup_info.SweepDataList.Add(el._edb_sweep_data) + self._sim_setup._edb_sim_setup_info.SweepDataList.Add(self._edb_sweep_data) return self._sim_setup._update_setup() @property @@ -752,7 +752,7 @@ def __init__(self, parent): @property def _hfss_port_settings(self): - return self._parent._edb_object.SimulationSettings.HFSSPortSettings + return self._parent._edb_sim_setup_info.SimulationSettings.HFSSPortSettings @property def max_delta_z0(self): @@ -824,7 +824,7 @@ def __init__(self, parent): @property def _hfss_solver_settings(self): - return self._parent._edb_object.SimulationSettings.HFSSSolverSettings + return self._parent._edb_sim_setup_info.SimulationSettings.HFSSSolverSettings @property def enhanced_low_freq_accuracy(self): @@ -993,7 +993,7 @@ def adaptive_settings(self): ------- :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.AdaptiveSettings` """ - return self._parent._edb_object.SimulationSettings.AdaptiveSettings + return self._parent._edb_sim_setup_info.SimulationSettings.AdaptiveSettings @property def adaptive_frequency_data_list(self): @@ -1233,7 +1233,7 @@ def __init__(self, parent): @property def _defeature_settings(self): - return self._parent._edb_object.SimulationSettings.DefeatureSettings + return self._parent._edb_sim_setup_info.SimulationSettings.DefeatureSettings @property def defeature_abs_length(self): @@ -1401,7 +1401,7 @@ def __init__( @property def _via_settings(self): - return self._parent._edb_object.SimulationSettings.ViaSettings + return self._parent._edb_sim_setup_info.SimulationSettings.ViaSettings @property def via_density(self): @@ -1478,7 +1478,7 @@ def __init__(self, parent): @property def _advanced_mesh_settings(self): - return self._parent._edb_object.SimulationSettings.AdvancedMeshSettings + return self._parent._edb_sim_setup_info.SimulationSettings.AdvancedMeshSettings @property def layer_snap_tol(self): @@ -1537,7 +1537,7 @@ def __init__(self, parent): @property def _curve_approx_settings(self): - return self._parent._edb_object.SimulationSettings.CurveApproxSettings + return self._parent._edb_sim_setup_info.SimulationSettings.CurveApproxSettings @property def arc_angle(self): @@ -1623,7 +1623,7 @@ def __init__(self, parent): @property def _dcr_settings(self): - return self._parent._edb_object.SimulationSettings.DCRSettings + return self._parent._edb_sim_setup_info.SimulationSettings.DCRSettings @property def conduction_max_passes(self): @@ -1711,35 +1711,35 @@ 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_object = edb_hfss_sim_setup.GetSimSetupInfo() + self._edb_sim_setup_info = edb_hfss_sim_setup.GetSimSetupInfo() self._name = edb_hfss_sim_setup.GetName() else: - self._edb_object = self._edb.simsetupdata.SimSetupInfo[ + self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.HFSSSimulationSettings ]() if not name: - self._edb_object.Name = generate_unique_name("hfss") + self._edb_sim_setup_info.Name = generate_unique_name("hfss") else: - self._edb_object.Name = name + self._edb_sim_setup_info.Name = name self._name = name self.hfss_solver_settings.order_basis = "mixed" - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_object) + self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) self._update_setup() @property def edb_sim_setup_info(self): """EDB internal simulation setup object.""" - return self._edb_object + return self._edb_sim_setup_info @pyaedt_function_handler() def _update_setup(self): - mesh_operations = self._edb_object.SimulationSettings.MeshOperations + mesh_operations = self._edb_sim_setup_info.SimulationSettings.MeshOperations mesh_operations.Clear() for mop in self.mesh_operations.values(): mesh_operations.Add(mop.mesh_operation) - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_object) + self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) if self._name in self._edb.setups: self._edb.active_cell.DeleteSimulationSetup(self._name) @@ -1747,7 +1747,7 @@ def _update_setup(self): self._edb.active_cell.AddSimulationSetup(self._edb_sim_setup) for i in list(self._edb.active_cell.SimulationSetups): if i.GetSimSetupInfo().Name == self._name: - self._edb_object = i.GetSimSetupInfo() + self._edb_sim_setup_info = i.GetSimSetupInfo() return True return False @@ -1760,19 +1760,19 @@ def frequency_sweeps(self): List of :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.EdbFrequencySweep` """ sweep_data_list = {} - for i in list(self._edb_object.SweepDataList): + for i in list(self._edb_sim_setup_info.SweepDataList): sweep_data_list[i.Name] = EdbFrequencySweep(self, None, i.Name, i) return sweep_data_list @property def name(self): """Name of the setup.""" - return self._edb_object.Name + return self._edb_sim_setup_info.Name @name.setter def name(self, value): legacy_name = self._name - self._edb_object.Name = value + self._edb_sim_setup_info.Name = value self._update_setup() if legacy_name in self._edb.setups: del self._edb._setups[legacy_name] @@ -1791,34 +1791,34 @@ def solver_slider_type(self): ------- str """ - return self._edb_object.SimulationSettings.TSolveSliderType.ToString() + return self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.ToString() @solver_slider_type.setter def solver_slider_type(self, value): """Set solver slider type.""" solver_types = { - "kFast": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaWirebond, - "kMedium": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaRibbon, - "kAccurate": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaMesh, - "kNumSliderTypes": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaField, + "kFast": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaWirebond, + "kMedium": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaRibbon, + "kAccurate": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaMesh, + "kNumSliderTypes": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaField, } - self._edb_object.SimulationSettings.TSolveSliderType = solver_types[value] + self._edb_sim_setup_info.SimulationSettings.TSolveSliderType = solver_types[value] self._update_setup() @property def is_auto_setup(self): """Whether if auto setup is enabled.""" - return self._edb_object.SimulationSettings.IsAutoSetup + return self._edb_sim_setup_info.SimulationSettings.IsAutoSetup @is_auto_setup.setter def is_auto_setup(self, value): - self._edb_object.SimulationSettings.IsAutoSetup = value + self._edb_sim_setup_info.SimulationSettings.IsAutoSetup = value self._update_setup() @property def setup_type(self): """Setup type.""" - return self._edb_object.SimulationSettings.SetupType + return self._edb_sim_setup_info.SimulationSettings.SetupType @property def hfss_solver_settings(self): @@ -1919,7 +1919,7 @@ def mesh_operations(self): """ if self._mesh_operations: return self._mesh_operations - settings = self._edb_object.SimulationSettings.MeshOperations + settings = self._edb_sim_setup_info.SimulationSettings.MeshOperations self._mesh_operations = {} for i in list(settings): if i.MeshOpType == i.TMeshOpType.kMeshSetupLength: From 0e96de36bd3781e67b8e67ec9f20952922b65b41 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 09:36:30 +0100 Subject: [PATCH 05/61] fix --- pyaedt/edb.py | 16 ++++++---------- .../edb_data/siwave_simulation_setup_data.py | 3 --- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 7118beff6df..1409dd19952 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -274,7 +274,6 @@ def _clean_variables(self): self._siwave = None self._hfss = None self._nets = None - self._setups = {} self._layout_instance = None self._variables = None self._active_cell = None @@ -3326,13 +3325,12 @@ def setups(self): """ setups = {} 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: - setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i) - elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWave: - setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i) - elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWaveDCIR: - setups[i.GetName()] = SiwaveDCSimulationSetup(self, i) + if i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kHFSS: + setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i) + elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWave: + setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i) + elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWaveDCIR: + setups[i.GetName()] = SiwaveDCSimulationSetup(self, i) return setups @property @@ -3386,7 +3384,6 @@ def create_hfss_setup(self, name=None): if name in self.setups: return False setup = HfssSimulationSetup(self, name) - self._setups[name] = setup return setup @pyaedt_function_handler() @@ -3442,7 +3439,6 @@ def create_siwave_dc_setup(self, name=None): if name in self.setups: return False setup = SiwaveDCSimulationSetup(self, name) - self._setups[name] = setup return setup @pyaedt_function_handler() diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 08721436e49..3bd3013beb7 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -848,9 +848,6 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): return sweep - - - class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup, SiwaveDCAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" From d40a99ec648c257902fabf3aa205807b76a4b071 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 11:37:20 +0100 Subject: [PATCH 06/61] fix --- _unittest/test_00_EDB.py | 1 + pyaedt/edb.py | 6 +- .../edb_data/hfss_simulation_setup_data.py | 624 ++---------------- pyaedt/edb_core/edb_data/simulation_setup.py | 509 +++++++++++++- .../edb_data/siwave_simulation_setup_data.py | 6 +- 5 files changed, 546 insertions(+), 600 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index b50a3c43315..75df2636845 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2001,6 +2001,7 @@ def test_129_hfss_simulation_setup(self): setup1.hfss_solver_settings.relative_residual = 0.0002 setup1.hfss_solver_settings.use_shell_elements = True + setup1b = edbapp.setups["setup1"] hfss_solver_settings = edbapp.setups["setup1"].hfss_solver_settings assert hfss_solver_settings.order_basis == "first" assert hfss_solver_settings.relative_residual == 0.0002 diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 1409dd19952..d2e2233ca7e 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3326,7 +3326,7 @@ def setups(self): setups = {} for i in list(self.active_cell.SimulationSetups): if i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kHFSS: - setups[i.GetName()] = HfssSimulationSetup(self, i.GetName(), i) + setups[i.GetName()] = HfssSimulationSetup(self, i) elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWave: setups[i.GetName()] = SiwaveSYZSimulationSetup(self, i) elif i.GetType() == self.edb_api.utility.utility.SimulationSetupType.kSIWaveDCIR: @@ -3383,7 +3383,7 @@ def create_hfss_setup(self, name=None): """ if name in self.setups: return False - setup = HfssSimulationSetup(self, name) + setup = HfssSimulationSetup(self).create(name) return setup @pyaedt_function_handler() @@ -3438,7 +3438,7 @@ def create_siwave_dc_setup(self, name=None): name = generate_unique_name("Siwave_DC") if name in self.setups: return False - setup = SiwaveDCSimulationSetup(self, name) + setup = SiwaveDCSimulationSetup(self).create(name) return setup @pyaedt_function_handler() diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index 76e9cc8e6da..1d7001fe6e5 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -2,484 +2,8 @@ from pyaedt.generic.clr_module import Tuple from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler - - -class EdbFrequencySweep(object): - """Manages EDB methods for frequency sweep.""" - - def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=None): - self._sim_setup = sim_setup - - if edb_sweep_data: - self._edb_sweep_data = edb_sweep_data - self._name = self._edb_sweep_data.Name - else: - if not name: - self._name = generate_unique_name("sweep") - else: - self._name = name - self._edb_sweep_data = self._sim_setup._edb.simsetupdata.SweepData(self._name) - self.set_frequencies(frequency_sweep) - - @pyaedt_function_handler() - def _update_sweep(self): - """Update sweep.""" - self._sim_setup._edb_sim_setup_info.SweepDataList.Clear() - for el in list(self._sim_setup.frequency_sweeps.values()): - self._sim_setup._edb_sim_setup_info.SweepDataList.Add(el._edb_sweep_data) - self._sim_setup._edb_sim_setup_info.SweepDataList.Add(self._edb_sweep_data) - return self._sim_setup._update_setup() - - @property - def name(self): - """Name of the sweep.""" - return self._edb_sweep_data.Name - - @name.setter - def name(self, value): - """Set name of this sweep""" - self._edb_sweep_data.Name = value - self._update_sweep() - - @property - def sweep_type(self): - """Sweep type.""" - return - - @property - def frequencies(self): - """List of frequencies points.""" - return list(self._edb_sweep_data.Frequencies) - - @property - def adaptive_sampling(self): - """Whether adaptive sampling is used. - - Returns - ------- - bool - ``True`` if adaptive sampling is used, ``False`` otherwise. - """ - return self._edb_sweep_data.AdaptiveSampling - - @property - def adv_dc_extrapolation(self): - """Whether to turn on advanced DC Extrapolation. - - Returns - ------- - bool - ``True`` if advanced DC Extrapolation is used, ``False`` otherwise. - - """ - return self._edb_sweep_data.AdvDCExtrapolation - - @property - def auto_s_mat_only_solve(self): - """Whether to turn on Auto/Manual SMatrix only solve. - - Returns - ------- - bool - ``True`` if Auto/Manual SMatrix only solve is used, ``False`` otherwise. - """ - return self._edb_sweep_data.AutoSMatOnlySolve - - @property - def enforce_causality(self): - """Whether to enforce causality during interpolating sweep. - - Returns - ------- - bool - ``True`` if enforce causality is used, ``False`` otherwise. - """ - return self._edb_sweep_data.EnforceCausality - - @property - def enforce_dc_and_causality(self): - """Whether to enforce DC point and causality. - - Returns - ------- - bool - ``True`` if enforce dc point and causality is used, ``False`` otherwise. - - """ - return self._edb_sweep_data.EnforceDCAndCausality - - @property - def enforce_passivity(self): - """Whether to enforce passivity during interpolating sweep. - - Returns - ------- - bool - ``True`` if enforce passivity is used, ``False`` otherwise. - """ - return self._edb_sweep_data.EnforcePassivity - - @property - def freq_sweep_type(self): - """Sweep type. - Options are: - - ``kInterpolatingSweep``. - - ``kDiscreteSweep``. - - ``kBroadbandFastSweep``. - - Returns - ------- - str - """ - return self._edb_sweep_data.FreqSweepType.ToString() - - @property - def interp_use_full_basis(self): - """Whether to use Full basis elements. - - Returns - ------- - bool - ``True`` if full basis interpolation is used, ``False`` otherwise. - """ - return self._edb_sweep_data.InterpUseFullBasis - - @property - def interp_use_port_impedance(self): - """Whether to turn on the port impedance interpolation. - - Returns - ------- - bool - ``True`` if port impedance is used, ``False`` otherwise. - """ - return self._edb_sweep_data.InterpUsePortImpedance - - @property - def interp_use_prop_const(self): - """Whether to use propagation constants. - - Returns - ------- - bool - ``True`` if propagation constants are used, ``False`` otherwise. - """ - return self._edb_sweep_data.InterpUsePropConst - - @property - def interp_use_s_matrix(self): - """Whether to use S matrix. - - Returns - ------- - bool - ``True`` if S matrix are used, ``False`` otherwise. - """ - return self._edb_sweep_data.InterpUseSMatrix - - @property - def max_solutions(self): - """Number of aximum solutions. - - Returns - ------- - int - """ - return self._edb_sweep_data.MaxSolutions - - @property - def min_freq_s_mat_only_solve(self): - """Minimum frequency SMatrix only solve. - - Returns - ------- - str - Frequency with units. - """ - return self._edb_sweep_data.MinFreqSMatOnlySolve - - @property - def min_solved_freq(self): - """Minimum solved frequency. - - Returns - ------- - str - Frequency with units. - """ - return self._edb_sweep_data.MinSolvedFreq - - @property - def passivity_tolerance(self): - """Tolerance for passivity enforcement. - - Returns - ------- - float - """ - return self._edb_sweep_data.PassivityTolerance - - @property - def relative_s_error(self): - """Specify S-parameter error tolerance for interpolating sweep. - - Returns - ------- - float - """ - return self._edb_sweep_data.RelativeSError - - @property - def save_fields(self): - """Whether to turn on or off the extraction of surface current data. - - Returns - ------- - bool - ``True`` if save fields is enabled, ``False`` otherwise. - """ - return self._edb_sweep_data.SaveFields - - @property - def save_rad_fields_only(self): - """Whether to turn on save radiated fields only. - - Returns - ------- - bool - ``True`` if save radiated field only is used, ``False`` otherwise. - - """ - return self._edb_sweep_data.SaveRadFieldsOnly - - @property - def use_q3d_for_dc(self): - """Whether to enable Q3D solver for DC point extraction . - - Returns - ------- - bool - ``True`` if Q3d for DC point is used, ``False`` otherwise. - """ - return self._edb_sweep_data.UseQ3DForDC - - @adaptive_sampling.setter - def adaptive_sampling(self, value): - self._edb_sweep_data.AdaptiveSampling = value - self._update_sweep() - - @adv_dc_extrapolation.setter - def adv_dc_extrapolation(self, value): - self._edb_sweep_data.AdvDCExtrapolation = value - self._update_sweep() - - @auto_s_mat_only_solve.setter - def auto_s_mat_only_solve(self, value): - self._edb_sweep_data.AutoSMatOnlySolve = value - self._update_sweep() - - @enforce_causality.setter - def enforce_causality(self, value): - self._edb_sweep_data.EnforceCausality = value - self._update_sweep() - - @enforce_dc_and_causality.setter - def enforce_dc_and_causality(self, value): - self._edb_sweep_data.EnforceDCAndCausality = value - self._update_sweep() - - @enforce_passivity.setter - def enforce_passivity(self, value): - self._edb_sweep_data.EnforcePassivity = value - self._update_sweep() - - @freq_sweep_type.setter - def freq_sweep_type(self, value): - edb_freq_sweep_type = self._edb_sweep_data.TFreqSweepType - if value in [0, "kInterpolatingSweep"]: - self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kInterpolatingSweep - elif value in [1, "kDiscreteSweep"]: - self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kDiscreteSweep - elif value in [2, "kBroadbandFastSweep"]: - self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kBroadbandFastSweep - elif value in [3, "kNumSweepTypes"]: - self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kNumSweepTypes - self._edb_sweep_data.FreqSweepType.ToString() - - @interp_use_full_basis.setter - def interp_use_full_basis(self, value): - self._edb_sweep_data.InterpUseFullBasis = value - self._update_sweep() - - @interp_use_port_impedance.setter - def interp_use_port_impedance(self, value): - self._edb_sweep_data.InterpUsePortImpedance = value - self._update_sweep() - - @interp_use_prop_const.setter - def interp_use_prop_const(self, value): - self._edb_sweep_data.InterpUsePropConst = value - self._update_sweep() - - @interp_use_s_matrix.setter - def interp_use_s_matrix(self, value): - self._edb_sweep_data.InterpUseSMatrix = value - self._update_sweep() - - @max_solutions.setter - def max_solutions(self, value): - self._edb_sweep_data.MaxSolutions = value - self._update_sweep() - - @min_freq_s_mat_only_solve.setter - def min_freq_s_mat_only_solve(self, value): - self._edb_sweep_data.MinFreqSMatOnlySolve = value - self._update_sweep() - - @min_solved_freq.setter - def min_solved_freq(self, value): - self._edb_sweep_data.MinSolvedFreq = value - self._update_sweep() - - @passivity_tolerance.setter - def passivity_tolerance(self, value): - self._edb_sweep_data.PassivityTolerance = value - self._update_sweep() - - @relative_s_error.setter - def relative_s_error(self, value): - self._edb_sweep_data.RelativeSError = value - self._update_sweep() - - @save_fields.setter - def save_fields(self, value): - self._edb_sweep_data.SaveFields = value - self._update_sweep() - - @save_rad_fields_only.setter - def save_rad_fields_only(self, value): - self._edb_sweep_data.SaveRadFieldsOnly = value - self._update_sweep() - - @use_q3d_for_dc.setter - def use_q3d_for_dc(self, value): - self._edb_sweep_data.UseQ3DForDC = value - self._update_sweep() - - @pyaedt_function_handler() - def _set_frequencies(self, freq_sweep_string="Linear Step: 0GHz to 20GHz, step=0.05GHz"): - self._edb_sweep_data.SetFrequencies(freq_sweep_string) - self._update_sweep() - - @pyaedt_function_handler() - def set_frequencies_linear_scale(self, start="0.1GHz", stop="20GHz", step="50MHz"): - """Set a linear scale frequency sweep. - - Parameters - ---------- - start : str, float - Start frequency. - stop : str, float - Stop frequency. - step : str, float - Step frequency. - - Returns - ------- - bool - ``True`` if correctly executed, ``False`` otherwise. - - """ - self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetFrequencies(start, stop, step) - return self._update_sweep() - - @pyaedt_function_handler() - def set_frequencies_linear_count(self, start="1kHz", stop="0.1GHz", count=10): - """Set a linear count frequency sweep. - - Parameters - ---------- - start : str, float - Start frequency. - stop : str, float - Stop frequency. - count : int - Step frequency. - - Returns - ------- - bool - ``True`` if correctly executed, ``False`` otherwise. - - """ - start = self._sim_setup._edb.arg_to_dim(start, "Hz") - stop = self._sim_setup._edb.arg_to_dim(stop, "Hz") - self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetFrequencies(start, stop, count) - return self._update_sweep() - - @pyaedt_function_handler() - def set_frequencies_log_scale(self, start="1kHz", stop="0.1GHz", samples=10): - """Set a log count frequency sweep. - - Parameters - ---------- - start : str, float - Start frequency. - stop : str, float - Stop frequency. - samples : int - Step frequency. - - Returns - ------- - bool - ``True`` if correctly executed, ``False`` otherwise. - """ - start = self._sim_setup._edb.arg_to_dim(start, "Hz") - stop = self._sim_setup._edb.arg_to_dim(stop, "Hz") - self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetLogFrequencies(start, stop, samples) - return self._update_sweep() - - @pyaedt_function_handler() - def set_frequencies(self, frequency_list=None): - """Set frequency list to the sweep frequencies. - - Parameters - ---------- - frequency_list : list, optional - List of lists with four elements. Each list must contain: - - 1- frequency type (``"linear count"``, ``"log scale"`` or ``"linear scale"``) - 2- start frequency - 3- stop frequency - 4- step frequency or count - - Returns - ------- - bool - ``True`` if correctly executed, ``False`` otherwise. - - """ - if not frequency_list: - frequency_list = [ - ["linear count", "0", "1kHz", 1], - ["log scale", "1kHz", "0.1GHz", 10], - ["linear scale", "0.1GHz", "10GHz", "0.1GHz"], - ] - temp = [] - for i in frequency_list: - if i[0] == "linear count": - temp.extend(list(self._edb_sweep_data.SetFrequencies(i[1], i[2], i[3]))) - elif i[0] == "linear scale": - temp.extend(list(self._edb_sweep_data.SetFrequencies(i[1], i[2], i[3]))) - elif i[0] == "log scale": - temp.extend(list(self._edb_sweep_data.SetLogFrequencies(i[1], i[2], i[3]))) - else: - return False - self._edb_sweep_data.Frequencies.Clear() - for i in temp: - self._edb_sweep_data.Frequencies.Add(i) - return self._update_sweep() +from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep +from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup class MeshOperation(object): @@ -752,7 +276,7 @@ def __init__(self, parent): @property def _hfss_port_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.HFSSPortSettings + return self._parent._edb_object.SimulationSettings.HFSSPortSettings @property def max_delta_z0(self): @@ -819,12 +343,12 @@ def enable_set_triangles_wave_port(self, value): class HfssSolverSettings(object): """Manages EDB methods for HFSS solver settings.""" - def __init__(self, parent): - self._parent = parent + def __init__(self, sim_setup): + self._parent = sim_setup @property def _hfss_solver_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.HFSSSolverSettings + return self._parent._edb_object.SimulationSettings.HFSSSolverSettings @property def enhanced_low_freq_accuracy(self): @@ -993,7 +517,7 @@ def adaptive_settings(self): ------- :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.AdaptiveSettings` """ - return self._parent._edb_sim_setup_info.SimulationSettings.AdaptiveSettings + return self._parent._edb_object.SimulationSettings.AdaptiveSettings @property def adaptive_frequency_data_list(self): @@ -1181,10 +705,10 @@ def add_adaptive_frequency_data(self, frequency=0, max_num_passes=10, max_delta_ bool ``True`` if method is successful, ``False`` otherwise. """ - low_freq_adapt_data = self._parent._edb.simsetupdata.AdaptiveFrequencyData() - low_freq_adapt_data.MaxDelta = self._parent._edb.edb_value(max_delta_s).ToString() + low_freq_adapt_data = self._parent._pedb.simsetupdata.AdaptiveFrequencyData() + low_freq_adapt_data.MaxDelta = self._parent._pedb.edb_value(max_delta_s).ToString() low_freq_adapt_data.MaxPasses = max_num_passes - low_freq_adapt_data.AdaptiveFrequency = self._parent._edb.edb_value(frequency).ToString() + low_freq_adapt_data.AdaptiveFrequency = self._parent._pedb.edb_value(frequency).ToString() self.adaptive_settings.AdaptiveFrequencyDataList.Clear() self.adaptive_settings.AdaptiveFrequencyDataList.Add(low_freq_adapt_data) return self._parent._update_setup() @@ -1211,14 +735,14 @@ def add_broadband_adaptive_frequency_data( bool ``True`` if method is successful, ``False`` otherwise. """ - low_freq_adapt_data = self._parent._edb.simsetupdata.AdaptiveFrequencyData() - low_freq_adapt_data.MaxDelta = self._parent._edb.edb_value(max_delta_s).ToString() + low_freq_adapt_data = self._parent._pedb.simsetupdata.AdaptiveFrequencyData() + low_freq_adapt_data.MaxDelta = self._parent._pedb.edb_value(max_delta_s).ToString() low_freq_adapt_data.MaxPasses = max_num_passes - low_freq_adapt_data.AdaptiveFrequency = self._parent._edb.edb_value(low_frequency).ToString() - high_freq_adapt_data = self._parent._edb.simsetupdata.AdaptiveFrequencyData() - high_freq_adapt_data.MaxDelta = self._parent._edb.edb_value(max_delta_s).ToString() + low_freq_adapt_data.AdaptiveFrequency = self._parent._pedb.edb_value(low_frequency).ToString() + high_freq_adapt_data = self._parent._pedb.simsetupdata.AdaptiveFrequencyData() + high_freq_adapt_data.MaxDelta = self._parent._pedb.edb_value(max_delta_s).ToString() high_freq_adapt_data.MaxPasses = max_num_passes - high_freq_adapt_data.AdaptiveFrequency = self._parent._edb.edb_value(high_frequency).ToString() + high_freq_adapt_data.AdaptiveFrequency = self._parent._pedb.edb_value(high_frequency).ToString() self.adaptive_settings.AdaptiveFrequencyDataList.Clear() self.adaptive_settings.AdaptiveFrequencyDataList.Add(low_freq_adapt_data) self.adaptive_settings.AdaptiveFrequencyDataList.Add(high_freq_adapt_data) @@ -1233,7 +757,7 @@ def __init__(self, parent): @property def _defeature_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.DefeatureSettings + return self._parent._edb_object.SimulationSettings.DefeatureSettings @property def defeature_abs_length(self): @@ -1401,7 +925,7 @@ def __init__( @property def _via_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.ViaSettings + return self._parent._edb_object.SimulationSettings.ViaSettings @property def via_density(self): @@ -1478,7 +1002,7 @@ def __init__(self, parent): @property def _advanced_mesh_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.AdvancedMeshSettings + return self._parent._edb_object.SimulationSettings.AdvancedMeshSettings @property def layer_snap_tol(self): @@ -1537,7 +1061,7 @@ def __init__(self, parent): @property def _curve_approx_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.CurveApproxSettings + return self._parent._edb_object.SimulationSettings.CurveApproxSettings @property def arc_angle(self): @@ -1623,7 +1147,7 @@ def __init__(self, parent): @property def _dcr_settings(self): - return self._parent._edb_sim_setup_info.SimulationSettings.DCRSettings + return self._parent._edb_object.SimulationSettings.DCRSettings @property def conduction_max_passes(self): @@ -1701,82 +1225,19 @@ def conduction_per_refine(self, value): self._parent._update_setup() -class HfssSimulationSetup(object): +class HfssSimulationSetup(BaseSimulationSetup): """Manages EDB methods for HFSS simulation setup.""" - def __init__(self, edb, name=None, edb_hfss_sim_setup=None): - self._edb = edb - self._name = None - self._mesh_operations = {} + def __init__(self, pedb, edb_object=None): + self._setup_type = "kHFSS" + super().__init__(pedb, edb_object) - 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.GetName() - else: - self._edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[ - self._edb.simsetupdata.HFSSSimulationSettings - ]() - if not name: - self._edb_sim_setup_info.Name = generate_unique_name("hfss") - else: - self._edb_sim_setup_info.Name = name - self._name = name - self.hfss_solver_settings.order_basis = "mixed" - - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) - self._update_setup() - - @property - def edb_sim_setup_info(self): - """EDB internal simulation setup object.""" - return self._edb_sim_setup_info + self._mesh_operations = {} @pyaedt_function_handler() - def _update_setup(self): - mesh_operations = self._edb_sim_setup_info.SimulationSettings.MeshOperations - mesh_operations.Clear() - for mop in self.mesh_operations.values(): - mesh_operations.Add(mop.mesh_operation) - - self._edb_sim_setup = self._edb.edb_api.utility.utility.HFSSSimulationSetup(self._edb_sim_setup_info) - - if self._name in self._edb.setups: - self._edb.active_cell.DeleteSimulationSetup(self._name) - self._name = self.name - self._edb.active_cell.AddSimulationSetup(self._edb_sim_setup) - for i in list(self._edb.active_cell.SimulationSetups): - if i.GetSimSetupInfo().Name == self._name: - self._edb_sim_setup_info = i.GetSimSetupInfo() - return True - return False - - @property - def frequency_sweeps(self): - """Frequency sweep list. - - Returns - ------- - List of :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.EdbFrequencySweep` - """ - sweep_data_list = {} - for i in list(self._edb_sim_setup_info.SweepDataList): - sweep_data_list[i.Name] = EdbFrequencySweep(self, None, i.Name, i) - return sweep_data_list - - @property - def name(self): - """Name of the setup.""" - return self._edb_sim_setup_info.Name - - @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 + def create(self, name=None): + self._create(name) + return self @property def solver_slider_type(self): @@ -1791,35 +1252,30 @@ def solver_slider_type(self): ------- str """ - return self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.ToString() + return self._edb_object.SimulationSettings.TSolveSliderType.ToString() @solver_slider_type.setter def solver_slider_type(self, value): """Set solver slider type.""" solver_types = { - "kFast": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaWirebond, - "kMedium": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaRibbon, - "kAccurate": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaMesh, - "kNumSliderTypes": self._edb_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaField, + "kFast": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaWirebond, + "kMedium": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaRibbon, + "kAccurate": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaMesh, + "kNumSliderTypes": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaField, } - self._edb_sim_setup_info.SimulationSettings.TSolveSliderType = solver_types[value] + self._edb_object.SimulationSettings.TSolveSliderType = solver_types[value] self._update_setup() @property def is_auto_setup(self): """Whether if auto setup is enabled.""" - return self._edb_sim_setup_info.SimulationSettings.IsAutoSetup + return self._edb_object.SimulationSettings.IsAutoSetup @is_auto_setup.setter def is_auto_setup(self, value): - self._edb_sim_setup_info.SimulationSettings.IsAutoSetup = value + self._edb_object.SimulationSettings.IsAutoSetup = value self._update_setup() - @property - def setup_type(self): - """Setup type.""" - return self._edb_sim_setup_info.SimulationSettings.SetupType - @property def hfss_solver_settings(self): """Manages EDB methods for HFSS solver settings. @@ -1919,7 +1375,7 @@ def mesh_operations(self): """ if self._mesh_operations: return self._mesh_operations - settings = self._edb_sim_setup_info.SimulationSettings.MeshOperations + settings = self._edb_object.SimulationSettings.MeshOperations self._mesh_operations = {} for i in list(settings): if i.MeshOpType == i.TMeshOpType.kMeshSetupLength: @@ -1970,7 +1426,7 @@ def add_length_mesh_operation( """ if not name: name = generate_unique_name("skin") - mesh_operation = MeshOperationLength(self, self._edb.simsetupdata.LengthMeshOperation()) + mesh_operation = MeshOperationLength(self, self._pedb.simsetupdata.LengthMeshOperation()) mesh_operation.mesh_region = mesh_region mesh_operation.name = name mesh_operation.nets_layers_list = net_layer_list @@ -2024,7 +1480,7 @@ def add_skin_depth_mesh_operation( """ if not name: name = generate_unique_name("length") - mesh_operation = MeshOperationSkinDepth(self, self._edb.simsetupdata.SkinDepthMeshOperation()) + mesh_operation = MeshOperationSkinDepth(self, self._pedb.simsetupdata.SkinDepthMeshOperation()) mesh_operation.mesh_region = mesh_region mesh_operation.name = name mesh_operation.nets_layers_list = net_layer_list diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 9c831084e6f..4305f8dbaa7 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,5 +1,4 @@ from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import EdbFrequencySweep from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import is_linux from pyaedt.edb_core.general import convert_netdict_to_pydict @@ -42,12 +41,7 @@ def _parse_value(v): class BaseSimulationSetup(object): def __init__(self, pedb, edb_setup=None): self._pedb = pedb - self._setup_type = None - if edb_setup: - self._edb_object = self._get_edb_setup_info(edb_setup) - else: - self._edb_object = None - self._name = "" + self._setup_type_mapping = { "kHFSS": self._pedb.simsetupdata.HFSSSimulationSettings, "kPEM": None, @@ -66,12 +60,19 @@ def __init__(self, pedb, edb_setup=None): "kNumSetupTypes": None, } + if edb_setup: + self._edb_object = self._get_edb_setup_info(edb_setup) + else: + self._edb_object = None + self._name = "" + + @pyaedt_function_handler() def _get_edb_setup_info(self, edb_setup): if self._setup_type == "kSIwave": - edb_sim_setup_info = self._edb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self.setup_type]]() + edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() string = edb_setup.ToString().replace("\t", "").split("\r\n") if is_linux: @@ -135,8 +136,10 @@ def name(self): @name.setter def name(self, value): + self._pedb.layout.cell.DeleteSimulationSetup(self.name) self._edb_object.Name = value self._name = value + self._update_setup() @property def position(self): @@ -194,8 +197,496 @@ def _generate_edb_setup(self): @pyaedt_function_handler() def _update_setup(self): + if self._setup_type == "kHFSS": + mesh_operations = self._edb_object.SimulationSettings.MeshOperations + mesh_operations.Clear() + for mop in self.mesh_operations.values(): + mesh_operations.Add(mop.mesh_operation) + edb_setup = self._generate_edb_setup() if self.name in self._pedb.setups: self._pedb.layout.cell.DeleteSimulationSetup(self.name) self._pedb.layout.cell.AddSimulationSetup(edb_setup) - return True \ No newline at end of file + return True + + +class EdbFrequencySweep(object): + """Manages EDB methods for frequency sweep.""" + + def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=None): + self._sim_setup = sim_setup + + if edb_sweep_data: + self._edb_sweep_data = edb_sweep_data + self._name = self._edb_sweep_data.Name + else: + if not name: + self._name = generate_unique_name("sweep") + else: + self._name = name + self._edb_sweep_data = self._pedb.simsetupdata.SweepData(self._name) + self.set_frequencies(frequency_sweep) + + @property + def _pedb(self): + return self._sim_setup._pedb + + @pyaedt_function_handler() + def _update_sweep(self): + """Update sweep.""" + self._sim_setup._edb_object.SweepDataList.Clear() + for el in list(self._sim_setup.frequency_sweeps.values()): + self._sim_setup._edb_object.SweepDataList.Add(el._edb_sweep_data) + self._sim_setup._edb_object.SweepDataList.Add(self._edb_sweep_data) + return self._sim_setup._update_setup() + + @property + def name(self): + """Name of the sweep.""" + return self._edb_sweep_data.Name + + @name.setter + def name(self, value): + """Set name of this sweep""" + self._edb_sweep_data.Name = value + self._update_sweep() + + @property + def sweep_type(self): + """Sweep type.""" + return + + @property + def frequencies(self): + """List of frequencies points.""" + return list(self._edb_sweep_data.Frequencies) + + @property + def adaptive_sampling(self): + """Whether adaptive sampling is used. + + Returns + ------- + bool + ``True`` if adaptive sampling is used, ``False`` otherwise. + """ + return self._edb_sweep_data.AdaptiveSampling + + @property + def adv_dc_extrapolation(self): + """Whether to turn on advanced DC Extrapolation. + + Returns + ------- + bool + ``True`` if advanced DC Extrapolation is used, ``False`` otherwise. + + """ + return self._edb_sweep_data.AdvDCExtrapolation + + @property + def auto_s_mat_only_solve(self): + """Whether to turn on Auto/Manual SMatrix only solve. + + Returns + ------- + bool + ``True`` if Auto/Manual SMatrix only solve is used, ``False`` otherwise. + """ + return self._edb_sweep_data.AutoSMatOnlySolve + + @property + def enforce_causality(self): + """Whether to enforce causality during interpolating sweep. + + Returns + ------- + bool + ``True`` if enforce causality is used, ``False`` otherwise. + """ + return self._edb_sweep_data.EnforceCausality + + @property + def enforce_dc_and_causality(self): + """Whether to enforce DC point and causality. + + Returns + ------- + bool + ``True`` if enforce dc point and causality is used, ``False`` otherwise. + + """ + return self._edb_sweep_data.EnforceDCAndCausality + + @property + def enforce_passivity(self): + """Whether to enforce passivity during interpolating sweep. + + Returns + ------- + bool + ``True`` if enforce passivity is used, ``False`` otherwise. + """ + return self._edb_sweep_data.EnforcePassivity + + @property + def freq_sweep_type(self): + """Sweep type. + Options are: + - ``kInterpolatingSweep``. + - ``kDiscreteSweep``. + - ``kBroadbandFastSweep``. + + Returns + ------- + str + """ + return self._edb_sweep_data.FreqSweepType.ToString() + + @property + def interp_use_full_basis(self): + """Whether to use Full basis elements. + + Returns + ------- + bool + ``True`` if full basis interpolation is used, ``False`` otherwise. + """ + return self._edb_sweep_data.InterpUseFullBasis + + @property + def interp_use_port_impedance(self): + """Whether to turn on the port impedance interpolation. + + Returns + ------- + bool + ``True`` if port impedance is used, ``False`` otherwise. + """ + return self._edb_sweep_data.InterpUsePortImpedance + + @property + def interp_use_prop_const(self): + """Whether to use propagation constants. + + Returns + ------- + bool + ``True`` if propagation constants are used, ``False`` otherwise. + """ + return self._edb_sweep_data.InterpUsePropConst + + @property + def interp_use_s_matrix(self): + """Whether to use S matrix. + + Returns + ------- + bool + ``True`` if S matrix are used, ``False`` otherwise. + """ + return self._edb_sweep_data.InterpUseSMatrix + + @property + def max_solutions(self): + """Number of aximum solutions. + + Returns + ------- + int + """ + return self._edb_sweep_data.MaxSolutions + + @property + def min_freq_s_mat_only_solve(self): + """Minimum frequency SMatrix only solve. + + Returns + ------- + str + Frequency with units. + """ + return self._edb_sweep_data.MinFreqSMatOnlySolve + + @property + def min_solved_freq(self): + """Minimum solved frequency. + + Returns + ------- + str + Frequency with units. + """ + return self._edb_sweep_data.MinSolvedFreq + + @property + def passivity_tolerance(self): + """Tolerance for passivity enforcement. + + Returns + ------- + float + """ + return self._edb_sweep_data.PassivityTolerance + + @property + def relative_s_error(self): + """Specify S-parameter error tolerance for interpolating sweep. + + Returns + ------- + float + """ + return self._edb_sweep_data.RelativeSError + + @property + def save_fields(self): + """Whether to turn on or off the extraction of surface current data. + + Returns + ------- + bool + ``True`` if save fields is enabled, ``False`` otherwise. + """ + return self._edb_sweep_data.SaveFields + + @property + def save_rad_fields_only(self): + """Whether to turn on save radiated fields only. + + Returns + ------- + bool + ``True`` if save radiated field only is used, ``False`` otherwise. + + """ + return self._edb_sweep_data.SaveRadFieldsOnly + + @property + def use_q3d_for_dc(self): + """Whether to enable Q3D solver for DC point extraction . + + Returns + ------- + bool + ``True`` if Q3d for DC point is used, ``False`` otherwise. + """ + return self._edb_sweep_data.UseQ3DForDC + + @adaptive_sampling.setter + def adaptive_sampling(self, value): + self._edb_sweep_data.AdaptiveSampling = value + self._update_sweep() + + @adv_dc_extrapolation.setter + def adv_dc_extrapolation(self, value): + self._edb_sweep_data.AdvDCExtrapolation = value + self._update_sweep() + + @auto_s_mat_only_solve.setter + def auto_s_mat_only_solve(self, value): + self._edb_sweep_data.AutoSMatOnlySolve = value + self._update_sweep() + + @enforce_causality.setter + def enforce_causality(self, value): + self._edb_sweep_data.EnforceCausality = value + self._update_sweep() + + @enforce_dc_and_causality.setter + def enforce_dc_and_causality(self, value): + self._edb_sweep_data.EnforceDCAndCausality = value + self._update_sweep() + + @enforce_passivity.setter + def enforce_passivity(self, value): + self._edb_sweep_data.EnforcePassivity = value + self._update_sweep() + + @freq_sweep_type.setter + def freq_sweep_type(self, value): + edb_freq_sweep_type = self._edb_sweep_data.TFreqSweepType + if value in [0, "kInterpolatingSweep"]: + self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kInterpolatingSweep + elif value in [1, "kDiscreteSweep"]: + self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kDiscreteSweep + elif value in [2, "kBroadbandFastSweep"]: + self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kBroadbandFastSweep + elif value in [3, "kNumSweepTypes"]: + self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kNumSweepTypes + self._edb_sweep_data.FreqSweepType.ToString() + + @interp_use_full_basis.setter + def interp_use_full_basis(self, value): + self._edb_sweep_data.InterpUseFullBasis = value + self._update_sweep() + + @interp_use_port_impedance.setter + def interp_use_port_impedance(self, value): + self._edb_sweep_data.InterpUsePortImpedance = value + self._update_sweep() + + @interp_use_prop_const.setter + def interp_use_prop_const(self, value): + self._edb_sweep_data.InterpUsePropConst = value + self._update_sweep() + + @interp_use_s_matrix.setter + def interp_use_s_matrix(self, value): + self._edb_sweep_data.InterpUseSMatrix = value + self._update_sweep() + + @max_solutions.setter + def max_solutions(self, value): + self._edb_sweep_data.MaxSolutions = value + self._update_sweep() + + @min_freq_s_mat_only_solve.setter + def min_freq_s_mat_only_solve(self, value): + self._edb_sweep_data.MinFreqSMatOnlySolve = value + self._update_sweep() + + @min_solved_freq.setter + def min_solved_freq(self, value): + self._edb_sweep_data.MinSolvedFreq = value + self._update_sweep() + + @passivity_tolerance.setter + def passivity_tolerance(self, value): + self._edb_sweep_data.PassivityTolerance = value + self._update_sweep() + + @relative_s_error.setter + def relative_s_error(self, value): + self._edb_sweep_data.RelativeSError = value + self._update_sweep() + + @save_fields.setter + def save_fields(self, value): + self._edb_sweep_data.SaveFields = value + self._update_sweep() + + @save_rad_fields_only.setter + def save_rad_fields_only(self, value): + self._edb_sweep_data.SaveRadFieldsOnly = value + self._update_sweep() + + @use_q3d_for_dc.setter + def use_q3d_for_dc(self, value): + self._edb_sweep_data.UseQ3DForDC = value + self._update_sweep() + + @pyaedt_function_handler() + def _set_frequencies(self, freq_sweep_string="Linear Step: 0GHz to 20GHz, step=0.05GHz"): + self._edb_sweep_data.SetFrequencies(freq_sweep_string) + self._update_sweep() + + @pyaedt_function_handler() + def set_frequencies_linear_scale(self, start="0.1GHz", stop="20GHz", step="50MHz"): + """Set a linear scale frequency sweep. + + Parameters + ---------- + start : str, float + Start frequency. + stop : str, float + Stop frequency. + step : str, float + Step frequency. + + Returns + ------- + bool + ``True`` if correctly executed, ``False`` otherwise. + + """ + self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetFrequencies(start, stop, step) + return self._update_sweep() + + @pyaedt_function_handler() + def set_frequencies_linear_count(self, start="1kHz", stop="0.1GHz", count=10): + """Set a linear count frequency sweep. + + Parameters + ---------- + start : str, float + Start frequency. + stop : str, float + Stop frequency. + count : int + Step frequency. + + Returns + ------- + bool + ``True`` if correctly executed, ``False`` otherwise. + + """ + start = self._sim_setup._pedb.arg_to_dim(start, "Hz") + stop = self._sim_setup._pedb.arg_to_dim(stop, "Hz") + self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetFrequencies(start, stop, count) + return self._update_sweep() + + @pyaedt_function_handler() + def set_frequencies_log_scale(self, start="1kHz", stop="0.1GHz", samples=10): + """Set a log count frequency sweep. + + Parameters + ---------- + start : str, float + Start frequency. + stop : str, float + Stop frequency. + samples : int + Step frequency. + + Returns + ------- + bool + ``True`` if correctly executed, ``False`` otherwise. + """ + start = self._sim_setup._pedb.arg_to_dim(start, "Hz") + stop = self._sim_setup._pedb.arg_to_dim(stop, "Hz") + self._edb_sweep_data.Frequencies = self._edb_sweep_data.SetLogFrequencies(start, stop, samples) + return self._update_sweep() + + @pyaedt_function_handler() + def set_frequencies(self, frequency_list=None): + """Set frequency list to the sweep frequencies. + + Parameters + ---------- + frequency_list : list, optional + List of lists with four elements. Each list must contain: + + 1- frequency type (``"linear count"``, ``"log scale"`` or ``"linear scale"``) + 2- start frequency + 3- stop frequency + 4- step frequency or count + + Returns + ------- + bool + ``True`` if correctly executed, ``False`` otherwise. + + """ + if not frequency_list: + frequency_list = [ + ["linear count", "0", "1kHz", 1], + ["log scale", "1kHz", "0.1GHz", 10], + ["linear scale", "0.1GHz", "10GHz", "0.1GHz"], + ] + temp = [] + for i in frequency_list: + if i[0] == "linear count": + temp.extend(list(self._edb_sweep_data.SetFrequencies(i[1], i[2], i[3]))) + elif i[0] == "linear scale": + temp.extend(list(self._edb_sweep_data.SetFrequencies(i[1], i[2], i[3]))) + elif i[0] == "log scale": + temp.extend(list(self._edb_sweep_data.SetLogFrequencies(i[1], i[2], i[3]))) + else: + return False + self._edb_sweep_data.Frequencies.Clear() + for i in temp: + self._edb_sweep_data.Frequencies.Add(i) + return self._update_sweep() diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 3bd3013beb7..6a5606c7876 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1,4 +1,4 @@ -from pyaedt.edb_core.edb_data.hfss_simulation_setup_data import EdbFrequencySweep +from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name @@ -688,11 +688,9 @@ class SiwaveSYZSimulationSetup(BaseSimulationSetup, SiwaveAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" def __init__(self, pedb, edb_setup=None): - super().__init__(pedb, edb_setup) self._setup_type = "kSIwave" + super().__init__(pedb, edb_setup) self._edb = self._pedb - #self._sweep_data_list = {} - SiwaveAdvancedSettings.__init__(self, self) From 3d1092b5a44e52033f620abac2d3182df93be633 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 12:06:22 +0100 Subject: [PATCH 07/61] fix --- _unittest/test_00_EDB.py | 2 +- .../edb_data/siwave_simulation_setup_data.py | 21 +++++++++++++++++-- pyaedt/edb_core/siwave.py | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 75df2636845..6c6caf663c2 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2180,7 +2180,7 @@ def test_130_siwave_dc_simulation_setup(self): assert setup1.mesh_bondwires assert setup1.mesh_vias assert setup1.min_plane_area == "0.25mm2" - assert setup1.min_void_area == "0.01mm2" + assert setup1.dc_min_void_area_to_mesh == "0.01mm2" assert setup1.num_bondwire_sides == 8 assert setup1.num_via_sides == 8 assert setup1.percent_local_refinement == 20.0 diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 6a5606c7876..f2971621f10 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1,3 +1,5 @@ +import warnings + from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict @@ -371,6 +373,17 @@ def sim_setup_info(self): def min_void_area(self): """Minimum area below which voids are ignored. + Returns + ------- + float + """ + warnings.warn("`min_void_area` is deprecated. Use `dc_min_void_area` property instead.", DeprecationWarning) + return self.dc_min_void_area_to_mesh + + @property + def dc_min_void_area_to_mesh(self): + """Minimum area below which voids are ignored. + Returns ------- float @@ -597,11 +610,15 @@ def use_dc_custom_settings(self, value): self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = value self._parent._update_setup() - @min_void_area.setter - def min_void_area(self, value): + @dc_min_void_area_to_mesh.setter + def dc_min_void_area_to_mesh(self, value): self.sim_setup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = value self._parent._update_setup() + @min_void_area.setter + def min_void_area(self, value): + self.dc_min_void_area_to_mesh = value + @min_plane_area.setter def min_plane_area(self, value): self.sim_setup_info.SimulationSettings.DCAdvancedSettings.DcMinPlaneAreaToMesh = value diff --git a/pyaedt/edb_core/siwave.py b/pyaedt/edb_core/siwave.py index 8d6b65c0ced..f8585e31a77 100644 --- a/pyaedt/edb_core/siwave.py +++ b/pyaedt/edb_core/siwave.py @@ -1038,8 +1038,8 @@ def configure_siw_analysis_setup(self, simulation_setup=None, delete_existing_se simsetup_info.SimulationSettings.AdvancedSettings.IgnoreNonFunctionalPads = ( simulation_setup.ignore_non_functional_pads ) - if simulation_setup.min_void_area: # pragma: no cover - simsetup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = simulation_setup.min_void_area + if simulation_setup.dc_min_void_area: # pragma: no cover + simsetup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = simulation_setup.dc_min_void_area try: if simulation_setup.add_frequency_sweep: self._logger.info("Adding frequency sweep") From 14ca27a2f409139e10a958006300371742e5f91e Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 13:52:19 +0100 Subject: [PATCH 08/61] fix --- pyaedt/edb.py | 4 ++-- pyaedt/edb_core/siwave.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyaedt/edb.py b/pyaedt/edb.py index d2e2233ca7e..79e6e44db43 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3352,7 +3352,7 @@ def siwave_dc_setups(self): ------- Dict[str, :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveDCSimulationSetup`] """ - return {name: i for name, i in self.setups.items() if i.setup_type == "kSIWaveDCIR"} + return {name: i for name, i in self.setups.items() if isinstance(i, SiwaveDCSimulationSetup)} @property def siwave_ac_setups(self): @@ -3362,7 +3362,7 @@ def siwave_ac_setups(self): ------- Dict[str, :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveSYZSimulationSetup`] """ - return {name: i for name, i in self.setups.items() if i.setup_type == "kSIWave"} + return {name: i for name, i in self.setups.items() if isinstance(i, SiwaveSYZSimulationSetup)} def create_hfss_setup(self, name=None): """Create a setup from a template. diff --git a/pyaedt/edb_core/siwave.py b/pyaedt/edb_core/siwave.py index f8585e31a77..8d6b65c0ced 100644 --- a/pyaedt/edb_core/siwave.py +++ b/pyaedt/edb_core/siwave.py @@ -1038,8 +1038,8 @@ def configure_siw_analysis_setup(self, simulation_setup=None, delete_existing_se simsetup_info.SimulationSettings.AdvancedSettings.IgnoreNonFunctionalPads = ( simulation_setup.ignore_non_functional_pads ) - if simulation_setup.dc_min_void_area: # pragma: no cover - simsetup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = simulation_setup.dc_min_void_area + if simulation_setup.min_void_area: # pragma: no cover + simsetup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = simulation_setup.min_void_area try: if simulation_setup.add_frequency_sweep: self._logger.info("Adding frequency sweep") From 9e4b9465d3e26854017e10e0fff87c4026b1afd6 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 15:06:30 +0100 Subject: [PATCH 09/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 12 +++++++++++- .../edb_data/siwave_simulation_setup_data.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 4305f8dbaa7..91b5d48a8a7 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -39,6 +39,8 @@ def _parse_value(v): class BaseSimulationSetup(object): + """Ansys.Ansoft.SimSetupData.Data.BaseSimulationSettings.""" + def __init__(self, pedb, edb_setup=None): self._pedb = pedb @@ -70,6 +72,7 @@ def __init__(self, pedb, edb_setup=None): @pyaedt_function_handler() def _get_edb_setup_info(self, edb_setup): + """Read simulation information from setup.""" if self._setup_type == "kSIwave": edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() @@ -132,6 +135,7 @@ def enabled(self, value): @property def name(self): + """Name of the Setup.""" return self._edb_object.Name @name.setter @@ -143,6 +147,7 @@ def name(self, value): @property def position(self): + """Position in the setup list.""" return self._edb_object.Position @position.setter @@ -151,11 +156,12 @@ def position(self, value): @property def setup_type(self): + """Type of the setup.""" return self._edb_object.SimSetupType.ToString() @property def frequency_sweeps(self): - """Get frequency sweep list.""" + """list of frequency sweep.""" temp = {} for i in list(self._edb_object.SweepDataList): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) @@ -163,6 +169,7 @@ def frequency_sweeps(self): @pyaedt_function_handler def _create(self, name=None): + """Create a new setup.""" if not name: name = generate_unique_name(self.setup_type) self._name = name @@ -176,6 +183,7 @@ def _create(self, name=None): @pyaedt_function_handler def _generate_edb_setup(self): + """Generate convert simulation setup information into the format Edb can import.""" setup_type_mapping = { "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, "kPEM": None, @@ -197,6 +205,7 @@ def _generate_edb_setup(self): @pyaedt_function_handler() def _update_setup(self): + """Update setup into Edb.""" if self._setup_type == "kHFSS": mesh_operations = self._edb_object.SimulationSettings.MeshOperations mesh_operations.Clear() @@ -229,6 +238,7 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No @property def _pedb(self): + """Edb.""" return self._sim_setup._pedb @pyaedt_function_handler() diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index f2971621f10..c1986bb074e 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -702,7 +702,7 @@ def refine_vias(self, value): class SiwaveSYZSimulationSetup(BaseSimulationSetup, SiwaveAdvancedSettings): - """Manages EDB methods for HFSS simulation setup.""" + """Manages EDB methods for SIwave simulation setup.""" def __init__(self, pedb, edb_setup=None): self._setup_type = "kSIwave" From a55af55501350c1aaffe48cf634e990baa05a361 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:09:07 +0000 Subject: [PATCH 10/61] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../edb_core/edb_data/hfss_simulation_setup_data.py | 4 ++-- pyaedt/edb_core/edb_data/simulation_setup.py | 12 ++++++------ .../edb_data/siwave_simulation_setup_data.py | 6 ++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index 1d7001fe6e5..d096f8b3d1e 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -1,9 +1,9 @@ +from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup +from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep from pyaedt.edb_core.general import convert_py_list_to_net_list from pyaedt.generic.clr_module import Tuple from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep -from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup class MeshOperation(object): diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 91b5d48a8a7..c4051be4b78 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,8 +1,8 @@ -from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.generic.general_methods import generate_unique_name -from pyaedt.generic.general_methods import is_linux from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict +from pyaedt.generic.general_methods import generate_unique_name +from pyaedt.generic.general_methods import is_linux +from pyaedt.generic.general_methods import pyaedt_function_handler def _parse_value(v): @@ -68,8 +68,6 @@ def __init__(self, pedb, edb_setup=None): self._edb_object = None self._name = "" - - @pyaedt_function_handler() def _get_edb_setup_info(self, edb_setup): """Read simulation information from setup.""" @@ -91,7 +89,9 @@ def _get_edb_setup_info(self, edb_setup): for v in val: source = v.split("=") sources[source[0]] = source[1] - edb_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(sources) + edb_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict( + sources + ) break for k in keys: value = _parse_value(values[keys.index(k)]) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index c1986bb074e..7abd92a5f87 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1,11 +1,11 @@ import warnings +from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler -from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup class SiwaveAdvancedSettings(object): @@ -916,7 +916,5 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): """ terminals = self.source_terms_to_ground terminals[source_name] = terminal - self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict( - terminals - ) + self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) return self._update_setup() From de15d37d9f81fa845db34189471ef190867ea0ec Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Thu, 2 Nov 2023 15:22:55 +0100 Subject: [PATCH 11/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index c4051be4b78..5bbce1adff5 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,4 +1,3 @@ -from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import is_linux From cb52d94b684b896449ddf2a480de60d2a5d5ec98 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Fri, 3 Nov 2023 09:53:28 +0100 Subject: [PATCH 12/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 75 ++++++++++++++++--- .../edb_data/siwave_simulation_setup_data.py | 31 -------- 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 5bbce1adff5..39a9d713f1b 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -166,6 +166,59 @@ def frequency_sweeps(self): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) return temp + @pyaedt_function_handler + def _add_frequency_sweep(self, sweep_data): + self._edb_object.SweepDataList.Add(sweep_data._edb_object) + + @pyaedt_function_handler + def delete_frequency_sweep(self, name): + fsweep = [] + for k, val in self.frequency_sweeps.items(): + if not k == name: + fsweep.append(val) + self._edb_object.SweepDataList.Clear() + for i in fsweep: + self._edb_object.SweepDataList.Add(i._edb_object) + self._update_setup() + return True if name in self.frequency_sweeps else False + + @pyaedt_function_handler() + def add_frequency_sweep(self, name=None, frequency_sweep=None): + """Add frequency sweep. + + Parameters + ---------- + name : str, optional + Name of the frequency sweep. + frequency_sweep : list, optional + List of frequency points. + + Returns + ------- + :class:`pyaedt.edb_core.edb_data.simulation_setup_data.EdbFrequencySweep` + + Examples + -------- + >>> setup1 = edbapp.create_siwave_syz_setup("setup1") + >>> setup1.add_frequency_sweep(frequency_sweep=[ + ... ["linear count", "0", "1kHz", 1], + ... ["log scale", "1kHz", "0.1GHz", 10], + ... ["linear scale", "0.1GHz", "10GHz", "0.1GHz"], + ... ]) + """ + if name in self.frequency_sweeps: + return False + + if not frequency_sweep: + frequency_sweep = [["linear scale", "0.1GHz", "10GHz", "0.1GHz"]] + + if not name: + name = generate_unique_name("sweep") + sweep = EdbFrequencySweep(self, frequency_sweep, name) + self._add_frequency_sweep(sweep) + self._update_setup() + return sweep + @pyaedt_function_handler def _create(self, name=None): """Create a new setup.""" @@ -214,8 +267,7 @@ def _update_setup(self): edb_setup = self._generate_edb_setup() if self.name in self._pedb.setups: self._pedb.layout.cell.DeleteSimulationSetup(self.name) - self._pedb.layout.cell.AddSimulationSetup(edb_setup) - return True + return self._pedb.layout.cell.AddSimulationSetup(edb_setup) class EdbFrequencySweep(object): @@ -233,7 +285,11 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No else: self._name = name self._edb_sweep_data = self._pedb.simsetupdata.SweepData(self._name) - self.set_frequencies(frequency_sweep) + self.set_frequencies(frequency_sweep, False) + + @property + def _edb_object(self): + return self._edb_sweep_data @property def _pedb(self): @@ -243,11 +299,9 @@ def _pedb(self): @pyaedt_function_handler() def _update_sweep(self): """Update sweep.""" - self._sim_setup._edb_object.SweepDataList.Clear() - for el in list(self._sim_setup.frequency_sweeps.values()): - self._sim_setup._edb_object.SweepDataList.Add(el._edb_sweep_data) - self._sim_setup._edb_object.SweepDataList.Add(self._edb_sweep_data) - return self._sim_setup._update_setup() + self._sim_setup.delete_frequency_sweep(self) + self._sim_setup._add_frequency_sweep(self) + return @property def name(self): @@ -660,7 +714,7 @@ def set_frequencies_log_scale(self, start="1kHz", stop="0.1GHz", samples=10): return self._update_sweep() @pyaedt_function_handler() - def set_frequencies(self, frequency_list=None): + def set_frequencies(self, frequency_list=None, update=True): """Set frequency list to the sweep frequencies. Parameters @@ -698,4 +752,5 @@ def set_frequencies(self, frequency_list=None): self._edb_sweep_data.Frequencies.Clear() for i in temp: self._edb_sweep_data.Frequencies.Add(i) - return self._update_sweep() + if update: + return self._update_sweep() diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 7abd92a5f87..7f7500db4a8 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -831,37 +831,6 @@ def use_si_settings(self, value): self._edb_object.SimulationSettings.UseSISettings = value self._update_setup() - @pyaedt_function_handler() - def add_frequency_sweep(self, name=None, frequency_sweep=None): - """Add frequency sweep. - - Parameters - ---------- - name : str, optional - Name of the frequency sweep. - frequency_sweep : list, optional - List of frequency points. - - Returns - ------- - :class:`pyaedt.edb_core.edb_data.simulation_setup_data.EdbFrequencySweep` - - Examples - -------- - >>> setup1 = edbapp.create_siwave_syz_setup("setup1") - >>> setup1.add_frequency_sweep(frequency_sweep=[ - ... ["linear count", "0", "1kHz", 1], - ... ["log scale", "1kHz", "0.1GHz", 10], - ... ["linear scale", "0.1GHz", "10GHz", "0.1GHz"], - ... ]) - """ - if name in self.frequency_sweeps: - return False - if not name: - name = generate_unique_name("sweep") - sweep = EdbFrequencySweep(self, frequency_sweep, name) - return sweep - class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup, SiwaveDCAdvancedSettings): """Manages EDB methods for HFSS simulation setup.""" From 233e3c3b0a559e994f737257b7bef6fd6a238f4f Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Fri, 3 Nov 2023 12:30:19 +0100 Subject: [PATCH 13/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 134 +++++++++---------- 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 39a9d713f1b..6147bf73510 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -42,6 +42,7 @@ class BaseSimulationSetup(object): def __init__(self, pedb, edb_setup=None): self._pedb = pedb + self._edb_setup = edb_setup self._setup_type_mapping = { "kHFSS": self._pedb.simsetupdata.HFSSSimulationSettings, @@ -60,16 +61,25 @@ def __init__(self, pedb, edb_setup=None): "kQ3D": None, "kNumSetupTypes": None, } + if self._edb_setup: + self._name = self._edb_setup.GetName() - if edb_setup: - self._edb_object = self._get_edb_setup_info(edb_setup) - else: - self._edb_object = None - self._name = "" + @pyaedt_function_handler + def _create(self, name=None): + """Create a new setup.""" + if not name: + name = generate_unique_name(self.setup_type) + self._name = name - @pyaedt_function_handler() - def _get_edb_setup_info(self, edb_setup): + edb_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() + self._update_edb_setup(edb_setup_info) + self._edb_setup_info.Name = name + self._update_setup() + + @property + def _edb_setup_info(self): """Read simulation information from setup.""" + edb_setup = self._edb_setup if self._setup_type == "kSIwave": edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() @@ -122,53 +132,91 @@ def _get_edb_setup_info(self, edb_setup): elif self._setup_type == "kHFSS": return edb_setup.GetSimSetupInfo() + @pyaedt_function_handler + def _update_edb_setup(self, edb_setup_info): + setup_type_mapping = { + "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, + "kPEM": None, + "kSIwave": self._pedb.edb_api.utility.utility.SIWaveSimulationSetup, + "kLNA": None, + "kTransient": None, + "kQEye": None, + "kVEye": None, + "kAMI": None, + "kAnalysisOption": None, + "kSIwaveDCIR": self._pedb.edb_api.utility.utility.SIWaveDCIRSimulationSetup, + "kSIwaveEMI": None, + "kHFSSPI": None, + "kDDRwizard": None, + "kQ3D": None, + "kNumSetupTypes": None} + self._edb_setup = setup_type_mapping[self._setup_type](edb_setup_info) + + @pyaedt_function_handler() + def _update_setup(self): + """Update setup into Edb.""" + if self._setup_type == "kHFSS": + mesh_operations = self._edb_setup_info.SimulationSettings.MeshOperations + mesh_operations.Clear() + for mop in self.mesh_operations.values(): + mesh_operations.Add(mop.mesh_operation) + + if self.name in self._pedb.setups: + self._pedb.layout.cell.DeleteSimulationSetup(self.name) + return self._pedb.layout.cell.AddSimulationSetup(self._edb_setup) + @property def enabled(self): """Whether the setup is enabled.""" - return self._edb_object.SimulationSettings.Enabled + return self._edb_setup_info.SimulationSettings.Enabled @enabled.setter def enabled(self, value): - self._edb_object.SimulationSettings.Enabled = value + edb_setup_info = self._edb_setup_info.SimulationSettings + edb_setup_info.Enabled = value + self._update_edb_setup(edb_setup_info) self._update_setup() @property def name(self): """Name of the Setup.""" - return self._edb_object.Name + return self._edb_setup.GetName() @name.setter def name(self, value): self._pedb.layout.cell.DeleteSimulationSetup(self.name) - self._edb_object.Name = value + self._edb_setup_info.Name = value self._name = value self._update_setup() @property def position(self): """Position in the setup list.""" - return self._edb_object.Position + return self._edb_setup_info.Position @position.setter def position(self, value): - self._edb_object.Position = value + edb_setup_info = self._edb_setup_info.SimulationSettings + edb_setup_info.Position = value + self._update_edb_setup(edb_setup_info) + self._update_setup() @property def setup_type(self): """Type of the setup.""" - return self._edb_object.SimSetupType.ToString() + return self._edb_setup_info.SimSetupType.ToString() @property def frequency_sweeps(self): """list of frequency sweep.""" temp = {} - for i in list(self._edb_object.SweepDataList): + for i in list(self._edb_setup_info.SweepDataList): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) return temp @pyaedt_function_handler def _add_frequency_sweep(self, sweep_data): - self._edb_object.SweepDataList.Add(sweep_data._edb_object) + self._edb_setup_info.SweepDataList.Add(sweep_data._edb_setup_info) @pyaedt_function_handler def delete_frequency_sweep(self, name): @@ -176,9 +224,9 @@ def delete_frequency_sweep(self, name): for k, val in self.frequency_sweeps.items(): if not k == name: fsweep.append(val) - self._edb_object.SweepDataList.Clear() + self._edb_setup_info.SweepDataList.Clear() for i in fsweep: - self._edb_object.SweepDataList.Add(i._edb_object) + self._edb_setup_info.SweepDataList.Add(i._edb_setup_info) self._update_setup() return True if name in self.frequency_sweeps else False @@ -219,56 +267,6 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): self._update_setup() return sweep - @pyaedt_function_handler - def _create(self, name=None): - """Create a new setup.""" - if not name: - name = generate_unique_name(self.setup_type) - self._name = name - - if self._edb_object: - self._setup_type = self.setup_type - - self._edb_object = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() - self._edb_object.Name = name - self._update_setup() - - @pyaedt_function_handler - def _generate_edb_setup(self): - """Generate convert simulation setup information into the format Edb can import.""" - setup_type_mapping = { - "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, - "kPEM": None, - "kSIwave": self._pedb.edb_api.utility.utility.SIWaveSimulationSetup, - "kLNA": None, - "kTransient": None, - "kQEye": None, - "kVEye": None, - "kAMI": None, - "kAnalysisOption": None, - "kSIwaveDCIR": self._pedb.edb_api.utility.utility.SIWaveDCIRSimulationSetup, - "kSIwaveEMI": None, - "kHFSSPI": None, - "kDDRwizard": None, - "kQ3D": None, - "kNumSetupTypes": None, - } - return setup_type_mapping[self.setup_type](self._edb_object) - - @pyaedt_function_handler() - def _update_setup(self): - """Update setup into Edb.""" - if self._setup_type == "kHFSS": - mesh_operations = self._edb_object.SimulationSettings.MeshOperations - mesh_operations.Clear() - for mop in self.mesh_operations.values(): - mesh_operations.Add(mop.mesh_operation) - - edb_setup = self._generate_edb_setup() - if self.name in self._pedb.setups: - self._pedb.layout.cell.DeleteSimulationSetup(self.name) - return self._pedb.layout.cell.AddSimulationSetup(edb_setup) - class EdbFrequencySweep(object): """Manages EDB methods for frequency sweep.""" From 119cc20cd275e4f232198c3ea6295927e27700c0 Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:26:47 +0000 Subject: [PATCH 14/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 5bbce1adff5..06aee0d2c6a 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -204,7 +204,7 @@ def _generate_edb_setup(self): @pyaedt_function_handler() def _update_setup(self): - """Update setup into Edb.""" + """Update setup in EDB.""" if self._setup_type == "kHFSS": mesh_operations = self._edb_object.SimulationSettings.MeshOperations mesh_operations.Clear() From c9fa1a5541402aa43d52f0288898f52960509e0a Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Fri, 3 Nov 2023 14:51:03 +0100 Subject: [PATCH 15/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 24 ++++++++------- .../edb_data/siwave_simulation_setup_data.py | 30 +++++++++---------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 6147bf73510..ea889b142fa 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -42,7 +42,7 @@ class BaseSimulationSetup(object): def __init__(self, pedb, edb_setup=None): self._pedb = pedb - self._edb_setup = edb_setup + self._edb_object = edb_setup self._setup_type_mapping = { "kHFSS": self._pedb.simsetupdata.HFSSSimulationSettings, @@ -61,8 +61,8 @@ def __init__(self, pedb, edb_setup=None): "kQ3D": None, "kNumSetupTypes": None, } - if self._edb_setup: - self._name = self._edb_setup.GetName() + if self._edb_object: + self._name = self._edb_object.GetName() @pyaedt_function_handler def _create(self, name=None): @@ -72,14 +72,14 @@ def _create(self, name=None): self._name = name edb_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() + edb_setup_info.Name = name self._update_edb_setup(edb_setup_info) - self._edb_setup_info.Name = name self._update_setup() @property def _edb_setup_info(self): """Read simulation information from setup.""" - edb_setup = self._edb_setup + edb_setup = self._edb_object if self._setup_type == "kSIwave": edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() @@ -150,7 +150,7 @@ def _update_edb_setup(self, edb_setup_info): "kDDRwizard": None, "kQ3D": None, "kNumSetupTypes": None} - self._edb_setup = setup_type_mapping[self._setup_type](edb_setup_info) + self._edb_object = setup_type_mapping[self._setup_type](edb_setup_info) @pyaedt_function_handler() def _update_setup(self): @@ -163,7 +163,7 @@ def _update_setup(self): if self.name in self._pedb.setups: self._pedb.layout.cell.DeleteSimulationSetup(self.name) - return self._pedb.layout.cell.AddSimulationSetup(self._edb_setup) + return self._pedb.layout.cell.AddSimulationSetup(self._edb_object) @property def enabled(self): @@ -172,15 +172,15 @@ def enabled(self): @enabled.setter def enabled(self, value): - edb_setup_info = self._edb_setup_info.SimulationSettings - edb_setup_info.Enabled = value + edb_setup_info = self._edb_setup_info + edb_setup_info.SimulationSettings.Enabled = value self._update_edb_setup(edb_setup_info) self._update_setup() @property def name(self): """Name of the Setup.""" - return self._edb_setup.GetName() + return self._edb_object.GetName() @name.setter def name(self, value): @@ -216,7 +216,9 @@ def frequency_sweeps(self): @pyaedt_function_handler def _add_frequency_sweep(self, sweep_data): - self._edb_setup_info.SweepDataList.Add(sweep_data._edb_setup_info) + edb_setup_info = self._edb_setup_info + edb_setup_info.SweepDataList.Add(sweep_data._edb_object) + self._update_edb_setup(edb_setup_info) @pyaedt_function_handler def delete_frequency_sweep(self, name): diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 7f7500db4a8..e946c555db3 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -15,7 +15,7 @@ def __init__(self, parent): @property def sim_setup_info(self): """EDB internal simulation setup object.""" - return self._parent._edb_object + return self._parent._edb_setup_info @property def include_inter_plane_coupling(self): @@ -367,7 +367,7 @@ def __init__(self, parent): def sim_setup_info(self): """EDB internal simulation setup object.""" - return self._parent._edb_object + return self._parent._edb_setup_info @property def min_void_area(self): @@ -761,14 +761,14 @@ def pi_slider_postion(self, value): self.include_fringe_coupling = True self.include_trace_coupling = True self.max_coupled_lines = 40 - self._edb_object.SimulationSettings.UseCustomSettings = False - self._edb_object.SimulationSettings.PISliderPos = value + self._edb_setup_info.SimulationSettings.UseCustomSettings = False + self._edb_setup_info.SimulationSettings.PISliderPos = value self._update_setup() @property def si_slider_postion(self): """SI solider position. Values are from ``1`` to ``3``.""" - return self._edb_object.SimulationSettings.SISliderPos + return self._edb_setup_info.SimulationSettings.SISliderPos @si_slider_postion.setter def si_slider_postion(self, value): @@ -796,8 +796,8 @@ def si_slider_postion(self, value): self.include_trace_coupling = True self.max_coupled_lines = 40 self.return_current_distribution = True - self._edb_object.SimulationSettings.UseCustomSettings = False - self._edb_object.SimulationSettings.SISliderPos = value + self._edb_setup_info.SimulationSettings.UseCustomSettings = False + self._edb_setup_info.SimulationSettings.SISliderPos = value self._update_setup() @property @@ -808,11 +808,11 @@ def use_custom_settings(self): ------- bool """ - return self._edb_object.SimulationSettings.UseCustomSettings + return self._edb_setup_info.SimulationSettings.UseCustomSettings @use_custom_settings.setter def use_custom_settings(self, value): - self._edb_object.SimulationSettings.UseCustomSettings = value + self._edb_setup_info.SimulationSettings.UseCustomSettings = value self._update_setup() @property @@ -823,12 +823,12 @@ def use_si_settings(self): ------- bool """ - return self._edb_object.SimulationSettings.UseSISettings + return self._edb_setup_info.SimulationSettings.UseSISettings @use_si_settings.setter def use_si_settings(self, value): - self._edb_object.SimulationSettings.UseCustomSettings = False - self._edb_object.SimulationSettings.UseSISettings = value + self._edb_setup_info.SimulationSettings.UseCustomSettings = False + self._edb_setup_info.SimulationSettings.UseSISettings = value self._update_setup() @@ -839,7 +839,7 @@ def __init__(self, pedb, edb_object=None): super().__init__(pedb, edb_object) self._edb = pedb self._mesh_operations = {} - self._edb_object = self._edb.simsetupdata.SimSetupInfo[ + self._edb_setup_info = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings ]() @@ -861,7 +861,7 @@ def source_terms_to_ground(self): {str, int}, keys is source name, value int 0 unspecified, 1 negative node, 2 positive one. """ - return convert_netdict_to_pydict(self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround) + return convert_netdict_to_pydict(self._edb_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround) @pyaedt_function_handler() def add_source_terminal_to_ground(self, source_name, terminal=0): @@ -885,5 +885,5 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): """ terminals = self.source_terms_to_ground terminals[source_name] = terminal - self._edb_object.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) + self._edb_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) return self._update_setup() From eb5f49f5b0ee4b212fbb2afb607a60ed844565dc Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 01:21:19 +0100 Subject: [PATCH 16/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index ea889b142fa..98c59da6ed1 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -71,7 +71,8 @@ def _create(self, name=None): name = generate_unique_name(self.setup_type) self._name = name - edb_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() + setup_type = self._setup_type_mapping[self._setup_type] + edb_setup_info = self._pedb.simsetupdata.SimSetupInfo[setup_type]() edb_setup_info.Name = name self._update_edb_setup(edb_setup_info) self._update_setup() @@ -264,10 +265,20 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): if not name: name = generate_unique_name("sweep") - sweep = EdbFrequencySweep(self, frequency_sweep, name) - self._add_frequency_sweep(sweep) + #sweep = EdbFrequencySweep(self, frequency_sweep, name) + self._edb_object.ToString() + + #self._add_frequency_sweep(sweep) + edb_sweep_data = self._pedb.simsetupdata.SweepData(name) + edb_sweep_data.Frequencies.Clear() + edb_sweep_data.Frequencies.Add("1") + #edb_sweep_data.Frequencies.Add("2e9") + edb_setup_info = self._edb_setup_info + #edb_setup_info.SweepDataList.Add(edb_sweep_data) + self._edb_object = self._pedb.edb_api.utility.utility.SIWaveSimulationSetup(edb_setup_info) + self._edb_object.ToString() self._update_setup() - return sweep + return class EdbFrequencySweep(object): @@ -285,7 +296,7 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No else: self._name = name self._edb_sweep_data = self._pedb.simsetupdata.SweepData(self._name) - self.set_frequencies(frequency_sweep, False) + self.set_frequencies(frequency_sweep, True) @property def _edb_object(self): From fa5a38e90ae16826c166a306ad12aaf04c4c99dc Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 21:46:56 +0100 Subject: [PATCH 17/61] fix --- _unittest/test_00_EDB.py | 167 +--- examples/00-EDB/01_edb_example.py | 2 +- pyaedt/edb.py | 6 +- .../edb_data/hfss_simulation_setup_data.py | 42 +- pyaedt/edb_core/edb_data/simulation_setup.py | 157 +--- .../edb_data/siwave_simulation_setup_data.py | 742 ++++++++++++------ pyaedt/edb_core/siwave.py | 2 +- 7 files changed, 577 insertions(+), 541 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 6c6caf663c2..c2a0233da36 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2169,71 +2169,37 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") assert setup1.name == "DC1" - assert not setup1.compute_inductance - assert setup1.contact_radius == "0.1mm" - assert setup1.dc_slider_position == 1 - assert setup1.enabled - assert setup1.energy_error == 3.0 - assert setup1.max_init_mesh_edge_length == "2.5mm" - assert setup1.max_num_pass == 5 - assert setup1.min_num_pass == 1 - assert setup1.mesh_bondwires - assert setup1.mesh_vias - assert setup1.min_plane_area == "0.25mm2" - assert setup1.dc_min_void_area_to_mesh == "0.01mm2" - assert setup1.num_bondwire_sides == 8 - assert setup1.num_via_sides == 8 - assert setup1.percent_local_refinement == 20.0 - assert setup1.perform_adaptive_refinement - assert setup1.plot_jv - assert not setup1.refine_bondwires - assert not setup1.refine_vias - setup1.name = "DC2" - setup1.compute_inductance = True - setup1.contact_radius = "0.2mm" - setup1.dc_slider_position = 2 - setup1.energy_error = 2.0 - setup1.max_init_mesh_edge_length = "5.5mm" - setup1.max_num_pass = 3 - setup1.min_num_pass = 2 - setup1.mesh_bondwires = False - setup1.mesh_vias = False - assert not setup1.mesh_bondwires - assert not setup1.mesh_vias - setup1.min_plane_area = "0.5mm2" - setup1.min_void_area = "0.021mm2" - setup1.num_bondwire_sides = 6 - setup1.num_via_sides = 10 - setup1.percent_local_refinement = 10.0 - setup1.perform_adaptive_refinement = False - setup1.plot_jv = False - setup1.refine_bondwires = True - setup1.refine_vias = True - - assert setup1.name == "DC2" - assert setup1.compute_inductance - assert setup1.contact_radius == "0.2mm" - assert setup1.dc_slider_position == 2 - assert setup1.energy_error == 2.0 - assert setup1.max_init_mesh_edge_length == "5.5mm" - assert setup1.max_num_pass == 3 - assert setup1.min_num_pass == 2 - assert setup1.mesh_bondwires - assert setup1.mesh_vias - assert setup1.min_plane_area == "0.5mm2" - assert setup1.min_void_area == "0.021mm2" - assert setup1.num_bondwire_sides == 6 - assert setup1.num_via_sides == 10 - assert setup1.percent_local_refinement == 10.0 - assert not setup1.perform_adaptive_refinement - assert not setup1.plot_jv - assert setup1.refine_bondwires - assert setup1.refine_vias + + for p in [0, 1, 2]: + setup1.set_dc_slider(p) + settings = self.edbapp.setups["DC1"].get_dict() + for k, v in setup1.dc_settings.defaults.items(): + print(k) + assert settings["dc_settings"][k] == v[p] + + for k, v in setup1.dc_advanced_settings.defaults.items(): + print(k) + assert settings["dc_advanced_settings"][k] == v[p] + + def test_131_siwave_ac_simulation_setup(self): setup1 = self.edbapp.create_siwave_syz_setup("AC1") assert setup1.name == "AC1" assert setup1.enabled + + for p in [0, 1, 2]: + setup1.set_si_slider(p) + settings = self.edbapp.setups["AC1"].get_dict() + for k, v in setup1.advanced_settings.si_defaults.items(): + assert settings["advanced_settings"][k] == v[p] + + for p in [0, 1, 2]: + setup1.set_pi_slider(p) + settings = self.edbapp.setups["AC1"].get_dict() + for k, v in setup1.advanced_settings.pi_defaults.items(): + assert settings["advanced_settings"][k] == v[p] + sweep = setup1.add_frequency_sweep( "sweep1", frequency_sweep=[ @@ -2242,7 +2208,6 @@ def test_131_siwave_ac_simulation_setup(self): ["linear scale", "0.1GHz", "10GHz", "0.1GHz"], ], ) - assert "sweep1" in setup1.frequency_sweeps assert "0" in sweep.frequencies assert not sweep.adaptive_sampling assert not sweep.adv_dc_extrapolation @@ -2301,84 +2266,6 @@ def test_131_siwave_ac_simulation_setup(self): assert sweep.save_rad_fields_only assert sweep.use_q3d_for_dc - setup1.pi_slider_postion = 0 - setup1.pi_slider_postion = 1 - setup1.pi_slider_postion = 2 - setup1.si_slider_postion = 0 - setup1.si_slider_postion = 1 - setup1.si_slider_postion = 2 - assert setup1.automatic_mesh - assert setup1.enabled - assert setup1.dc_settings - assert setup1.ignore_non_functional_pads - assert setup1.include_coplane_coupling - assert setup1.include_fringe_coupling - assert not setup1.include_infinite_ground - assert not setup1.include_inter_plane_coupling - assert setup1.include_split_plane_coupling - assert setup1.include_trace_coupling - assert not setup1.include_vi_sources - assert setup1.infinite_ground_location == "0" - assert setup1.max_coupled_lines == 40 - assert setup1.mesh_frequency == "4GHz" - assert setup1.min_pad_area_to_mesh == "1mm2" - assert setup1.min_plane_area_to_mesh == "6.25e-6mm2" - assert setup1.min_void_area == "2mm2" - assert setup1.name == "AC1" - assert setup1.perform_erc - assert setup1.return_current_distribution - assert setup1.snap_length_threshold == "2.5um" - assert setup1.use_si_settings - assert setup1.use_custom_settings - assert setup1.xtalk_threshold == "-34" - - setup1.automatic_mesh = False - setup1.enabled = False - setup1.ignore_non_functional_pads = False - setup1.include_coplane_coupling = False - setup1.include_fringe_coupling = False - setup1.include_infinite_ground = True - setup1.include_inter_plane_coupling = True - setup1.include_split_plane_coupling = False - setup1.include_trace_coupling = False - assert setup1.use_custom_settings - setup1.include_vi_sources = True - setup1.infinite_ground_location = "0.1" - setup1.max_coupled_lines = 10 - setup1.mesh_frequency = "3GHz" - setup1.min_pad_area_to_mesh = "2mm2" - setup1.min_plane_area_to_mesh = "5.25e-6mm2" - setup1.min_void_area = "1mm2" - setup1.name = "AC2" - setup1.perform_erc = False - setup1.return_current_distribution = True - setup1.snap_length_threshold = "3.5um" - setup1.use_si_settings = False - assert not setup1.use_custom_settings - setup1.xtalk_threshold = "-44" - - assert not setup1.automatic_mesh - assert not setup1.enabled - assert not setup1.ignore_non_functional_pads - assert not setup1.include_coplane_coupling - assert not setup1.include_fringe_coupling - assert setup1.include_infinite_ground - assert setup1.include_inter_plane_coupling - assert not setup1.include_split_plane_coupling - assert not setup1.include_trace_coupling - assert setup1.include_vi_sources - assert setup1.infinite_ground_location == "0.1" - assert setup1.max_coupled_lines == 10 - assert setup1.mesh_frequency == "3GHz" - assert setup1.min_pad_area_to_mesh == "2mm2" - assert setup1.min_plane_area_to_mesh == "5.25e-6mm2" - assert setup1.min_void_area == "1mm2" - assert setup1.name == "AC2" - assert not setup1.perform_erc - assert setup1.return_current_distribution - assert setup1.snap_length_threshold == "3.5um" - assert not setup1.use_si_settings - assert setup1.xtalk_threshold == "-44" def test_132_via_plating_ratio_check(self): assert self.edbapp.padstacks.check_and_fix_via_plating() @@ -2392,7 +2279,7 @@ def test_133_siwave_build_ac_prject(self): simconfig.solver_type = SolverType.SiwaveSYZ simconfig.mesh_freq = "40.25GHz" edbapp.build_simulation_project(simconfig) - assert edbapp.siwave_ac_setups[simconfig.setup_name].mesh_frequency == simconfig.mesh_freq + assert edbapp.siwave_ac_setups[simconfig.setup_name].advanced_settings.mesh_frequency == simconfig.mesh_freq edbapp.close() def test_134_create_port_between_pin_and_layer(self): diff --git a/examples/00-EDB/01_edb_example.py b/examples/00-EDB/01_edb_example.py index 6df7a797c2d..c2b71e1b18d 100644 --- a/examples/00-EDB/01_edb_example.py +++ b/examples/00-EDB/01_edb_example.py @@ -130,7 +130,7 @@ edb.siwave.create_current_source_on_net("IC2", "NetD3_2", "IC2", "GND", 1.0, 0, "I1") setup = edb.siwave.add_siwave_dc_analysis("myDCIR_4") setup.use_dc_custom_settings = True -setup.dc_slider_position = 0 +setup.set_dc_slider = 0 setup.add_source_terminal_to_ground("V1", 1) diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 79e6e44db43..aafe5615881 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3194,7 +3194,7 @@ def build_simulation_project(self, simulation_setup): self.edbpath = legacy_name self.open_edb() return True - except: # pragma: no cover + except: return False @pyaedt_function_handler() @@ -3412,8 +3412,8 @@ def create_siwave_syz_setup(self, name=None): name = generate_unique_name("Siwave_SYZ") if name in self.setups: return False - setup_info = SiwaveSYZSimulationSetup(self).create(name) - return setup_info + SiwaveSYZSimulationSetup(self).create(name) + return self.setups[name] @pyaedt_function_handler() def create_siwave_dc_setup(self, name=None): diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index d096f8b3d1e..dcf14a1bccc 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -276,7 +276,7 @@ def __init__(self, parent): @property def _hfss_port_settings(self): - return self._parent._edb_object.SimulationSettings.HFSSPortSettings + return self._parent.get_sim_setup_info.SimulationSettings.HFSSPortSettings @property def max_delta_z0(self): @@ -348,7 +348,7 @@ def __init__(self, sim_setup): @property def _hfss_solver_settings(self): - return self._parent._edb_object.SimulationSettings.HFSSSolverSettings + return self._parent.get_sim_setup_info.SimulationSettings.HFSSSolverSettings @property def enhanced_low_freq_accuracy(self): @@ -517,7 +517,7 @@ def adaptive_settings(self): ------- :class:`pyaedt.edb_core.edb_data.hfss_simulation_setup_data.AdaptiveSettings` """ - return self._parent._edb_object.SimulationSettings.AdaptiveSettings + return self._parent.get_sim_setup_info.SimulationSettings.AdaptiveSettings @property def adaptive_frequency_data_list(self): @@ -757,7 +757,7 @@ def __init__(self, parent): @property def _defeature_settings(self): - return self._parent._edb_object.SimulationSettings.DefeatureSettings + return self._parent.get_sim_setup_info.SimulationSettings.DefeatureSettings @property def defeature_abs_length(self): @@ -925,7 +925,7 @@ def __init__( @property def _via_settings(self): - return self._parent._edb_object.SimulationSettings.ViaSettings + return self._parent.get_sim_setup_info.SimulationSettings.ViaSettings @property def via_density(self): @@ -1002,7 +1002,7 @@ def __init__(self, parent): @property def _advanced_mesh_settings(self): - return self._parent._edb_object.SimulationSettings.AdvancedMeshSettings + return self._parent.get_sim_setup_info.SimulationSettings.AdvancedMeshSettings @property def layer_snap_tol(self): @@ -1061,7 +1061,7 @@ def __init__(self, parent): @property def _curve_approx_settings(self): - return self._parent._edb_object.SimulationSettings.CurveApproxSettings + return self._parent.get_sim_setup_info.SimulationSettings.CurveApproxSettings @property def arc_angle(self): @@ -1147,7 +1147,7 @@ def __init__(self, parent): @property def _dcr_settings(self): - return self._parent._edb_object.SimulationSettings.DCRSettings + return self._parent.get_sim_setup_info.SimulationSettings.DCRSettings @property def conduction_max_passes(self): @@ -1229,16 +1229,20 @@ class HfssSimulationSetup(BaseSimulationSetup): """Manages EDB methods for HFSS simulation setup.""" def __init__(self, pedb, edb_object=None): - self._setup_type = "kHFSS" super().__init__(pedb, edb_object) - + self._setup_type = "kHFSS" self._mesh_operations = {} @pyaedt_function_handler() def create(self, name=None): + self._name = name self._create(name) return self + @property + def get_sim_setup_info(self): + return self._edb_object.GetSimSetupInfo() + @property def solver_slider_type(self): """Solver slider type. @@ -1252,28 +1256,28 @@ def solver_slider_type(self): ------- str """ - return self._edb_object.SimulationSettings.TSolveSliderType.ToString() + return self.get_sim_setup_info.SimulationSettings.TSolveSliderType.ToString() @solver_slider_type.setter def solver_slider_type(self, value): """Set solver slider type.""" solver_types = { - "kFast": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaWirebond, - "kMedium": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaRibbon, - "kAccurate": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaMesh, - "kNumSliderTypes": self._edb_object.SimulationSettings.TSolveSliderType.k25DViaField, + "kFast": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaWirebond, + "kMedium": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaRibbon, + "kAccurate": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaMesh, + "kNumSliderTypes": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaField, } - self._edb_object.SimulationSettings.TSolveSliderType = solver_types[value] + self.get_sim_setup_info.SimulationSettings.TSolveSliderType = solver_types[value] self._update_setup() @property def is_auto_setup(self): """Whether if auto setup is enabled.""" - return self._edb_object.SimulationSettings.IsAutoSetup + return self.get_sim_setup_info.SimulationSettings.IsAutoSetup @is_auto_setup.setter def is_auto_setup(self, value): - self._edb_object.SimulationSettings.IsAutoSetup = value + self.get_sim_setup_info.SimulationSettings.IsAutoSetup = value self._update_setup() @property @@ -1375,7 +1379,7 @@ def mesh_operations(self): """ if self._mesh_operations: return self._mesh_operations - settings = self._edb_object.SimulationSettings.MeshOperations + settings = self.get_sim_setup_info.SimulationSettings.MeshOperations self._mesh_operations = {} for i in list(settings): if i.MeshOpType == i.TMeshOpType.kMeshSetupLength: diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 98c59da6ed1..befefbc1c13 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,49 +1,16 @@ +import re from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name -from pyaedt.generic.general_methods import is_linux from pyaedt.generic.general_methods import pyaedt_function_handler -def _parse_value(v): - """ - - Parameters - ---------- - v : - - - Returns - ------- - - """ - # duck typing parse of the value 'v' - if v is None or v == "": - 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: - if isinstance(v, str) and v[0] == v[-1] == "'": - pv = v[1:-1] - else: - pv = v - return pv - - class BaseSimulationSetup(object): """Ansys.Ansoft.SimSetupData.Data.BaseSimulationSettings.""" def __init__(self, pedb, edb_setup=None): self._pedb = pedb self._edb_object = edb_setup - + self._setup_type = "" self._setup_type_mapping = { "kHFSS": self._pedb.simsetupdata.HFSSSimulationSettings, "kPEM": None, @@ -74,67 +41,11 @@ def _create(self, name=None): setup_type = self._setup_type_mapping[self._setup_type] edb_setup_info = self._pedb.simsetupdata.SimSetupInfo[setup_type]() edb_setup_info.Name = name - self._update_edb_setup(edb_setup_info) + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() - @property - def _edb_setup_info(self): - """Read simulation information from setup.""" - edb_setup = self._edb_object - - if self._setup_type == "kSIwave": - edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() - - string = edb_setup.ToString().replace("\t", "").split("\r\n") - if is_linux: - string = string[0].split("\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 - return edb_sim_setup_info - elif self._setup_type == "kHFSS": - return edb_setup.GetSimSetupInfo() - @pyaedt_function_handler - def _update_edb_setup(self, edb_setup_info): + def _set_edb_setup_info(self, edb_setup_info): setup_type_mapping = { "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, "kPEM": None, @@ -151,31 +62,34 @@ def _update_edb_setup(self, edb_setup_info): "kDDRwizard": None, "kQ3D": None, "kNumSetupTypes": None} - self._edb_object = setup_type_mapping[self._setup_type](edb_setup_info) + return setup_type_mapping[self._setup_type](edb_setup_info) @pyaedt_function_handler() def _update_setup(self): """Update setup into Edb.""" if self._setup_type == "kHFSS": - mesh_operations = self._edb_setup_info.SimulationSettings.MeshOperations + mesh_operations = self.get_sim_setup_info.SimulationSettings.MeshOperations mesh_operations.Clear() for mop in self.mesh_operations.values(): mesh_operations.Add(mop.mesh_operation) - if self.name in self._pedb.setups: - self._pedb.layout.cell.DeleteSimulationSetup(self.name) - return self._pedb.layout.cell.AddSimulationSetup(self._edb_object) + if self._name in self._pedb.setups: + self._pedb.layout.cell.DeleteSimulationSetup(self._name) + if not self._pedb.layout.cell.AddSimulationSetup(self._edb_object): + raise Exception("Updating setup {} failed.".format(self._name)) + else: + return True @property def enabled(self): """Whether the setup is enabled.""" - return self._edb_setup_info.SimulationSettings.Enabled + return self.get_sim_setup_info.SimulationSettings.Enabled @enabled.setter def enabled(self, value): - edb_setup_info = self._edb_setup_info + edb_setup_info = self.get_sim_setup_info edb_setup_info.SimulationSettings.Enabled = value - self._update_edb_setup(edb_setup_info) + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @property @@ -186,40 +100,43 @@ def name(self): @name.setter def name(self, value): self._pedb.layout.cell.DeleteSimulationSetup(self.name) - self._edb_setup_info.Name = value + edb_setup_info = self.get_sim_setup_info + edb_setup_info.Name = value self._name = value + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @property def position(self): """Position in the setup list.""" - return self._edb_setup_info.Position + return self.get_sim_setup_info.Position @position.setter def position(self, value): - edb_setup_info = self._edb_setup_info.SimulationSettings + edb_setup_info = self.get_sim_setup_info.SimulationSettings edb_setup_info.Position = value - self._update_edb_setup(edb_setup_info) + self._set_edb_setup_info(edb_setup_info) self._update_setup() @property def setup_type(self): """Type of the setup.""" - return self._edb_setup_info.SimSetupType.ToString() + return self.get_sim_setup_info.SimSetupType.ToString() @property def frequency_sweeps(self): """list of frequency sweep.""" temp = {} - for i in list(self._edb_setup_info.SweepDataList): + for i in list(self.get_sim_setup_info.SweepDataList): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) return temp @pyaedt_function_handler def _add_frequency_sweep(self, sweep_data): - edb_setup_info = self._edb_setup_info + edb_setup_info = self.get_sim_setup_info edb_setup_info.SweepDataList.Add(sweep_data._edb_object) - self._update_edb_setup(edb_setup_info) + self._edb_object = self._set_edb_setup_info(edb_setup_info) + self._update_setup() @pyaedt_function_handler def delete_frequency_sweep(self, name): @@ -227,9 +144,9 @@ def delete_frequency_sweep(self, name): for k, val in self.frequency_sweeps.items(): if not k == name: fsweep.append(val) - self._edb_setup_info.SweepDataList.Clear() + self.get_sim_setup_info.SweepDataList.Clear() for i in fsweep: - self._edb_setup_info.SweepDataList.Add(i._edb_setup_info) + self.get_sim_setup_info.SweepDataList.Add(i._edb_object) self._update_setup() return True if name in self.frequency_sweeps else False @@ -265,20 +182,10 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): if not name: name = generate_unique_name("sweep") - #sweep = EdbFrequencySweep(self, frequency_sweep, name) - self._edb_object.ToString() - - #self._add_frequency_sweep(sweep) - edb_sweep_data = self._pedb.simsetupdata.SweepData(name) - edb_sweep_data.Frequencies.Clear() - edb_sweep_data.Frequencies.Add("1") - #edb_sweep_data.Frequencies.Add("2e9") - edb_setup_info = self._edb_setup_info - #edb_setup_info.SweepDataList.Add(edb_sweep_data) - self._edb_object = self._pedb.edb_api.utility.utility.SIWaveSimulationSetup(edb_setup_info) - self._edb_object.ToString() + sweep = EdbFrequencySweep(self, frequency_sweep, name) + self._add_frequency_sweep(sweep) self._update_setup() - return + return sweep class EdbFrequencySweep(object): @@ -296,7 +203,7 @@ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=No else: self._name = name self._edb_sweep_data = self._pedb.simsetupdata.SweepData(self._name) - self.set_frequencies(frequency_sweep, True) + self.set_frequencies(frequency_sweep) @property def _edb_object(self): diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index e946c555db3..731cc3cb5f9 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -5,17 +5,131 @@ from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name +from pyaedt.generic.general_methods import is_linux from pyaedt.generic.general_methods import pyaedt_function_handler -class SiwaveAdvancedSettings(object): +def _parse_value(v): + """ + + Parameters + ---------- + v : + + + Returns + ------- + + """ + # duck typing parse of the value 'v' + if v is None or v == "": + 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: + if isinstance(v, str) and v[0] == v[-1] == "'": + pv = v[1:-1] + else: + pv = v + return pv + + +class SettingsBase(object): + @property + def sim_setup_info(self): + """EDB internal simulation setup object.""" + + return self._parent.get_sim_setup_info + + @pyaedt_function_handler + def get_dict(self): + temp = {} + attrs_list = [i for i in dir(self) if not i.startswith("_")] + attrs_list = [ + i + for i in attrs_list + if i not in ["get_dict", "sim_setup_info", "defaults", "si_defaults", "pi_defaults", "set_dc_slider", + "set_si_slider", "set_pi_slider"] + ] + for i in attrs_list: + temp[i] = self.__getattribute__(i) + return temp + + @pyaedt_function_handler + def set_dc_slider(self, value): + for k, val in self.defaults.items(): + self.__setattr__(k, val[value]) + + @pyaedt_function_handler + def set_si_slider(self, value): + for k, val in self.si_defaults.items(): + self.__setattr__(k, val[value]) + + @pyaedt_function_handler + def set_pi_slider(self, value): + for k, val in self.pi_defaults.items(): + self.__setattr__(k, val[value]) + + +class AdvancedSettings(SettingsBase): def __init__(self, parent): self._parent = parent + self.si_defaults = { + "automatic_mesh": [True, True, True], + "ignore_non_functional_pads": [True, True, True], + "include_coplane_coupling": [False, True, True], + "include_fringe_coupling": [False, True, True], + "include_infinite_ground": [False, False, False], + "include_inter_plane_coupling": [False, False, False], + "include_split_plane_coupling": [False, True, True], + "include_trace_coupling": [True, True, True], + "include_vi_sources": [False, False, False], + "infinite_ground_location": ["0", "0", "0"], + "max_coupled_lines": [12, 12, 40], + "mesh_frequency": ["4GHz", "4GHz", "4GHz"], + "min_pad_area_to_mesh": ["28mm2", "28mm2", "28mm2"], + #"min_plane_area_to_mesh": ["5e-5mm2", "5e-5mm2", "5e-5mm2"], + "min_void_area": ["2mm2", "2mm2", "2mm2"], + "perform_erc": [False, False, False], + "return_current_distribution": [False, False, True], + "snap_length_threshold": ["2.5um", "2.5um", "2.5um"], + "xtalk_threshold": ["-34", "-34", "-34"], + } + + self.pi_defaults = { + "automatic_mesh": [True, True, True], + "ignore_non_functional_pads": [True, True, True], + "include_coplane_coupling": [False, False, True], + "include_fringe_coupling": [False, True, True], + "include_infinite_ground": [False, False, False], + "include_inter_plane_coupling": [False, False, False], + "include_split_plane_coupling": [False, False, True], + "include_trace_coupling": [False, False, True], + "include_vi_sources": [False, False, False], + "infinite_ground_location": ["0", "0", "0"], + "max_coupled_lines": [12, 12, 40], + "mesh_frequency": ["4GHz", "4GHz", "4GHz"], + "min_pad_area_to_mesh": ["28mm2", "28mm2", "28mm2"], + #"min_plane_area_to_mesh": ["5e-5mm2", "5e-5mm2", "5e-5mm2"], + "min_void_area": ["2mm2", "2mm2", "2mm2"], + "perform_erc": [False, False, False], + "return_current_distribution": [False, False, False], + "snap_length_threshold": ["2.5um", "2.5um", "2.5um"], + "xtalk_threshold": ["-34", "-34", "-34"], + } @property def sim_setup_info(self): """EDB internal simulation setup object.""" - return self._parent._edb_setup_info + return self._parent.get_sim_setup_info @property def include_inter_plane_coupling(self): @@ -248,137 +362,282 @@ def mesh_frequency(self): ------- str """ - self.sim_setup_info.SimulationSettings.UseCustomSettings = True return self.sim_setup_info.SimulationSettings.AdvancedSettings.MeshFrequency @include_inter_plane_coupling.setter def include_inter_plane_coupling(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeInterPlaneCoupling = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeInterPlaneCoupling = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @xtalk_threshold.setter def xtalk_threshold(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.XtalkThreshold = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.XtalkThreshold = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @min_void_area.setter def min_void_area(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.MinVoidArea = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.MinVoidArea = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @min_pad_area_to_mesh.setter def min_pad_area_to_mesh(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.MinPadAreaToMesh = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.MinPadAreaToMesh = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @min_plane_area_to_mesh.setter def min_plane_area_to_mesh(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.MinPlaneAreaToMesh = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.MinPlaneAreaToMesh = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @snap_length_threshold.setter def snap_length_threshold(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.SnapLengthThreshold = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.SnapLengthThreshold = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @return_current_distribution.setter def return_current_distribution(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.ReturnCurrentDistribution = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.ReturnCurrentDistribution = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @ignore_non_functional_pads.setter def ignore_non_functional_pads(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.IgnoreNonFunctionalPads = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.IgnoreNonFunctionalPads = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_coplane_coupling.setter def include_coplane_coupling(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeCoPlaneCoupling = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeCoPlaneCoupling = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_fringe_coupling.setter def include_fringe_coupling(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeFringeCoupling = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeFringeCoupling = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_split_plane_coupling.setter def include_split_plane_coupling(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeSplitPlaneCoupling = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeSplitPlaneCoupling = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_infinite_ground.setter def include_infinite_ground(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeInfGnd = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeInfGnd = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_trace_coupling.setter def include_trace_coupling(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeTraceCoupling = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeTraceCoupling = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @include_vi_sources.setter def include_vi_sources(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.IncludeVISources = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.IncludeVISources = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @infinite_ground_location.setter def infinite_ground_location(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.InfGndLocation = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.InfGndLocation = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @max_coupled_lines.setter def max_coupled_lines(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.MaxCoupledLines = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.MaxCoupledLines = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @automatic_mesh.setter def automatic_mesh(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.MeshAutoMatic = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.MeshAutoMatic = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @perform_erc.setter def perform_erc(self, value): - self.sim_setup_info.SimulationSettings.AdvancedSettings.PerformERC = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.AdvancedSettings.PerformERC = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @mesh_frequency.setter def mesh_frequency(self, value): - self.sim_setup_info.SimulationSettings.UseCustomSettings = True - self.sim_setup_info.SimulationSettings.AdvancedSettings.MeshFrequency = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.AdvancedSettings.MeshFrequency = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() -class SiwaveDCAdvancedSettings(object): +class DCSettings(SettingsBase): def __init__(self, parent): self._parent = parent + self.defaults = { + #"compute_inductance": [False, False, False], + "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], + "dc_slider_position": [0, 1, 2], + #"use_dc_custom_settings": [False, False, False], + "plot_jv": [True, True, True], + } @property - def sim_setup_info(self): - """EDB internal simulation setup object.""" + def compute_inductance(self): + """Whether to compute Inductance. + + Returns + ------- + bool + ``True`` if inductances will be computed, ``False`` otherwise. + """ + return self.sim_setup_info.SimulationSettings.DCSettings.ComputeInductance - return self._parent._edb_setup_info + @compute_inductance.setter + def compute_inductance(self, value): + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCSettings.ComputeInductance = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) + self._parent._update_setup() @property - def min_void_area(self): - """Minimum area below which voids are ignored. + def contact_radius(self): + """Circuit element contact radius. Returns ------- - float + str """ - warnings.warn("`min_void_area` is deprecated. Use `dc_min_void_area` property instead.", DeprecationWarning) - return self.dc_min_void_area_to_mesh + return self.sim_setup_info.SimulationSettings.DCSettings.ContactRadius + + @contact_radius.setter + def contact_radius(self, value): + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCSettings.ContactRadius = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) + self._parent._update_setup() + + @property + def dc_slider_position(self): + """Slider position for DC. + + Returns + ------- + int + """ + return self.sim_setup_info.SimulationSettings.DCSettings.DCSliderPos + + @dc_slider_position.setter + def dc_slider_position(self, value): + """DC simulation accuracy level slider position. + Options: + 0- ``optimal speed`` + 1- ``balanced`` + 2- ``optimal accuracy``. + """ + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCSettings.DCSliderPos = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) + self._parent._update_setup() + + @property + def use_dc_custom_settings(self): + """Whether to use DC custom settings. + This setting is automatically enabled by other properties when needed. + + Returns + ------- + bool + ``True`` if custom dc settings are used, ``False`` otherwise. + """ + return self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings + + @use_dc_custom_settings.setter + def use_dc_custom_settings(self, value): + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = value + self._parent._update_setup() + + @property + def plot_jv(self): + """Plot current and voltage distributions. + + Returns + ------- + bool + ``True`` if plot JV is used, ``False`` otherwise. + """ + return self.sim_setup_info.SimulationSettings.DCSettings.PlotJV + + @plot_jv.setter + def plot_jv(self, value): + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCSettings.PlotJV = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) + self._parent._update_setup() + + +class DCAdvancedSettings(SettingsBase): + def __init__(self, parent): + self._parent = parent + self.defaults = { + "dc_min_void_area_to_mesh": ["0.001mm2", "0.001mm2", "0.001mm2"], + "energy_error": [2, 2, 1], + "max_init_mesh_edge_length": ["5mm", "5mm", "5mm"], + "max_num_pass": [5, 5, 10], + "mesh_bondwires": [False, True, True], + "mesh_vias": [False, True, True], + "min_num_pass": [1, 1, 3], + "dc_min_plane_area_to_mesh": ["1.5mm2", "1.5mm2", "1.5mm2"], + "num_bondwire_sides": [8, 8, 8], + "num_via_sides": [8, 8, 8], + "percent_local_refinement": [20.0, 20.0, 20.0], + "perform_adaptive_refinement": [False, True, True], + "refine_bondwires": [False, False, True], + "refine_vias": [False, False, True], + } + + @property + def sim_setup_info(self): + """EDB internal simulation setup object.""" + + return self._parent.get_sim_setup_info @property def dc_min_void_area_to_mesh(self): @@ -391,7 +650,7 @@ def dc_min_void_area_to_mesh(self): return self.sim_setup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh @property - def min_plane_area(self): + def dc_min_plane_area_to_mesh(self): """Minimum area below which geometry is ignored. Returns @@ -524,280 +783,233 @@ def refine_vias(self): """ return self.sim_setup_info.SimulationSettings.DCAdvancedSettings.RefineVias - @property - def compute_inductance(self): - """Whether to compute Inductance. - - Returns - ------- - bool - ``True`` if inductances will be computed, ``False`` otherwise. - """ - return self.sim_setup_info.SimulationSettings.DCSettings.ComputeInductance - - @property - def contact_radius(self): - """Circuit element contact radius. - - Returns - ------- - str - """ - return self.sim_setup_info.SimulationSettings.DCSettings.ContactRadius - - @property - def dc_slider_position(self): - """Slider position for DC. - - Returns - ------- - int - """ - return self.sim_setup_info.SimulationSettings.DCSettings.DCSliderPos - - @property - def use_dc_custom_settings(self): - """Whether to use DC custom settings. - This setting is automatically enabled by other properties when needed. - - Returns - ------- - bool - ``True`` if custom dc settings are used, ``False`` otherwise. - """ - return self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings - - @property - def plot_jv(self): - """Plot JV. - - Returns - ------- - bool - ``True`` if plot JV is used, ``False`` otherwise. - """ - return self.sim_setup_info.SimulationSettings.DCSettings.PlotJV - - @plot_jv.setter - def plot_jv(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.PlotJV = value - self._parent._update_setup() - - @compute_inductance.setter - def compute_inductance(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.ComputeInductance = value - self._parent._update_setup() - - @contact_radius.setter - def contact_radius(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.ContactRadius = value - self._parent._update_setup() - - @dc_slider_position.setter - def dc_slider_position(self, value): - """DC simulation accuracy level slider position. - Options: - 0- ``optimal speed`` - 1- ``balanced`` - 2- ``optimal accuracy``. - """ - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = False - self.sim_setup_info.SimulationSettings.DCSettings.DCSliderPos = value - self._parent._update_setup() - - @use_dc_custom_settings.setter - def use_dc_custom_settings(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = value - self._parent._update_setup() - @dc_min_void_area_to_mesh.setter def dc_min_void_area_to_mesh(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.DcMinVoidAreaToMesh = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() - @min_void_area.setter - def min_void_area(self, value): - self.dc_min_void_area_to_mesh = value - - @min_plane_area.setter - def min_plane_area(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.DcMinPlaneAreaToMesh = value + @dc_min_plane_area_to_mesh.setter + def dc_min_plane_area_to_mesh(self, value): + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.DcMinPlaneAreaToMesh = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @energy_error.setter def energy_error(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.EnergyError = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.EnergyError = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @max_init_mesh_edge_length.setter def max_init_mesh_edge_length(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MaxInitMeshEdgeLength = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.MaxInitMeshEdgeLength = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @max_num_pass.setter def max_num_pass(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MaxNumPasses = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.MaxNumPasses = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @min_num_pass.setter def min_num_pass(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MinNumPasses = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.MinNumPasses = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @mesh_bondwires.setter def mesh_bondwires(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshBws = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.MeshBws = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @mesh_vias.setter def mesh_vias(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshVias = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.MeshVias = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @num_bondwire_sides.setter def num_bondwire_sides(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshBws = True - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.NumBwSides = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.NumBwSides = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @num_via_sides.setter def num_via_sides(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshVias = True - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.NumViaSides = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.NumViaSides = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @percent_local_refinement.setter def percent_local_refinement(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.PercentLocalRefinement = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.PercentLocalRefinement = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @perform_adaptive_refinement.setter def perform_adaptive_refinement(self, value): - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.PerformAdaptiveRefinement = value + edb_setup_info = self.sim_setup_info + + edb_setup_info.SimulationSettings.DCAdvancedSettings.PerformAdaptiveRefinement = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @refine_bondwires.setter def refine_bondwires(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshBws = True - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.RefineBws = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.RefineBws = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @refine_vias.setter def refine_vias(self, value): - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.MeshVias = True - self.sim_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = True - self.sim_setup_info.SimulationSettings.DCAdvancedSettings.RefineVias = value + edb_setup_info = self.sim_setup_info + edb_setup_info.SimulationSettings.DCAdvancedSettings.RefineVias = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() -class SiwaveSYZSimulationSetup(BaseSimulationSetup, SiwaveAdvancedSettings): +class SiwaveSYZSimulationSetup(BaseSimulationSetup): """Manages EDB methods for SIwave simulation setup.""" def __init__(self, pedb, edb_setup=None): - self._setup_type = "kSIwave" super().__init__(pedb, edb_setup) self._edb = self._pedb - - SiwaveAdvancedSettings.__init__(self, self) + self._setup_type = "kSIwave" @pyaedt_function_handler() def create(self, name=None): + self._name = name self._create(name) - - self.restore_default() - self.use_si_settings = True + self.set_si_slider(1) return self - def restore_default(self): - self.si_slider_postion = 1 - self.pi_slider_postion = 1 + @pyaedt_function_handler + def get_dict(self): + return { + "pi_slider_postion": self.pi_slider_position, + "si_slider_postion": self.si_slider_position, + "use_custom_settings" : self.use_si_settings, + "use_si_settings": self.use_si_settings, + "advanced_settings": self.advanced_settings.get_dict(), + } @property - def dc_settings(self): - """Siwave DC settings. + def advanced_settings(self): + return AdvancedSettings(self) - Returns - ------- - :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveDCAdvancedSettings` - """ - return SiwaveDCAdvancedSettings(self) + @property + def get_sim_setup_info(self): + """Read simulation information from setup.""" + edb_setup = self._edb_object + + edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() + edb_sim_setup_info.Name = edb_setup.GetName() + + string = edb_setup.ToString().replace("\t", "").split("\r\n") + + if is_linux: + string = string[0].split("\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 + + return edb_sim_setup_info + + @pyaedt_function_handler + def set_pi_slider(self, value): + self.use_si_settings = False + self.use_custom_settings = False + self.pi_slider_position = value + self.advanced_settings.set_pi_slider(value) + + @pyaedt_function_handler + def set_si_slider(self, value): + self.use_si_settings = True + self.use_custom_settings = False + self.si_slider_position = value + self.advanced_settings.set_si_slider(value) @property - def pi_slider_postion(self): + def pi_slider_position(self): """PI solider position. Values are from ``1`` to ``3``.""" - return self._edb_object.SimulationSettings.PISliderPos - - @pi_slider_postion.setter - def pi_slider_postion(self, value): - if value == 0: - self.include_coplane_coupling = False - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = False - self.include_fringe_coupling = False - self.include_trace_coupling = False - self.max_coupled_lines = 12 - elif value == 1: - self.include_coplane_coupling = False - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = False - self.include_fringe_coupling = True - self.include_trace_coupling = False - self.max_coupled_lines = 12 - else: - self.include_coplane_coupling = True - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = True - self.include_fringe_coupling = True - self.include_trace_coupling = True - self.max_coupled_lines = 40 - self._edb_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_setup_info.SimulationSettings.PISliderPos = value + return self.get_sim_setup_info.SimulationSettings.PISliderPos + + @pi_slider_position.setter + def pi_slider_position(self, value): + edb_setup_info = self.get_sim_setup_info + edb_setup_info.SimulationSettings.PISliderPos = value + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @property - def si_slider_postion(self): + def si_slider_position(self): """SI solider position. Values are from ``1`` to ``3``.""" - return self._edb_setup_info.SimulationSettings.SISliderPos - - @si_slider_postion.setter - def si_slider_postion(self, value): - if value == 0: - self.include_coplane_coupling = False - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = False - self.include_fringe_coupling = False - self.include_trace_coupling = True - self.max_coupled_lines = 12 - self.return_current_distribution = False - elif value == 1: - self.include_coplane_coupling = True - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = True - self.include_fringe_coupling = True - self.include_trace_coupling = True - self.max_coupled_lines = 12 - self.return_current_distribution = False - else: - self.include_coplane_coupling = True - self.include_inter_plane_coupling = False - self.include_split_plane_coupling = True - self.include_fringe_coupling = True - self.include_trace_coupling = True - self.max_coupled_lines = 40 - self.return_current_distribution = True - self._edb_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_setup_info.SimulationSettings.SISliderPos = value + return self.get_sim_setup_info.SimulationSettings.SISliderPos + + @si_slider_position.setter + def si_slider_position(self, value): + edb_setup_info = self.get_sim_setup_info + edb_setup_info.SimulationSettings.SISliderPos = value + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @property @@ -808,11 +1020,11 @@ def use_custom_settings(self): ------- bool """ - return self._edb_setup_info.SimulationSettings.UseCustomSettings + return self.get_sim_setup_info.SimulationSettings.UseCustomSettings @use_custom_settings.setter def use_custom_settings(self, value): - self._edb_setup_info.SimulationSettings.UseCustomSettings = value + self.get_sim_setup_info.SimulationSettings.UseCustomSettings = value self._update_setup() @property @@ -823,34 +1035,60 @@ def use_si_settings(self): ------- bool """ - return self._edb_setup_info.SimulationSettings.UseSISettings + return self.get_sim_setup_info.SimulationSettings.UseSISettings @use_si_settings.setter def use_si_settings(self, value): - self._edb_setup_info.SimulationSettings.UseCustomSettings = False - self._edb_setup_info.SimulationSettings.UseSISettings = value + edb_setup_info = self.get_sim_setup_info + edb_setup_info.SimulationSettings.UseSISettings = value + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() -class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup, SiwaveDCAdvancedSettings): +class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup): """Manages EDB methods for HFSS simulation setup.""" def __init__(self, pedb, edb_object=None): super().__init__(pedb, edb_object) + self._setup_type = "kSIwaveDCIR" self._edb = pedb self._mesh_operations = {} self._edb_setup_info = self._edb.simsetupdata.SimSetupInfo[ self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings ]() - SiwaveDCAdvancedSettings.__init__(self, self) - def create(self, name=None): + self._name = name self._create(name) - self.restore_default() - self.use_si_settings = False + self.dc_settings.set_dc_slider(1) return self + @pyaedt_function_handler + def get_dict(self): + return { + "dc_settings": self.dc_settings.get_dict(), + "dc_advanced_settings": self.dc_advanced_settings.get_dict(), + } + + @pyaedt_function_handler + def set_dc_slider(self, value): + self.dc_settings.set_dc_slider(value) + self.dc_advanced_settings.set_dc_slider(value) + + @property + def dc_settings(self): + return DCSettings(self) + + @property + def dc_advanced_settings(self): + """Siwave DC settings. + + Returns + ------- + :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveDCAdvancedSettings` + """ + return DCAdvancedSettings(self) + @property def source_terms_to_ground(self): """Dictionary of grounded terminals. diff --git a/pyaedt/edb_core/siwave.py b/pyaedt/edb_core/siwave.py index 8d6b65c0ced..708a905a6d2 100644 --- a/pyaedt/edb_core/siwave.py +++ b/pyaedt/edb_core/siwave.py @@ -838,7 +838,7 @@ def add_siwave_syz_analysis( third_arg = int(decade_count) if sweeptype == 0: third_arg = self._pedb.number_with_units(step_freq, "Hz") - setup.si_slider_postion = int(accuracy_level) + setup.si_slider_position = int(accuracy_level) sweep = setup.add_frequency_sweep( frequency_sweep=[ [sweep, start_freq, stop_freq, third_arg], From 4e86b432f7e0f7b38e2da5dde40198ead346ad59 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 21:52:54 +0100 Subject: [PATCH 18/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 731cc3cb5f9..729b0230cb6 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -514,7 +514,7 @@ def __init__(self, parent): #"compute_inductance": [False, False, False], "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], "dc_slider_position": [0, 1, 2], - #"use_dc_custom_settings": [False, False, False], + "use_dc_custom_settings": [False, False, False], "plot_jv": [True, True, True], } @@ -592,6 +592,7 @@ def use_dc_custom_settings(self): def use_dc_custom_settings(self, value): edb_setup_info = self.sim_setup_info edb_setup_info.SimulationSettings.DCSettings.UseDCCustomSettings = value + self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) self._parent._update_setup() @property From 443c79ea6742b911dc8157b6d903d0a408c47f19 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 22:15:20 +0100 Subject: [PATCH 19/61] fix --- _unittest/test_00_EDB.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index c2a0233da36..0073cf8616e 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2169,6 +2169,7 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") assert setup1.name == "DC1" + self.edbapp.setups["DC1"].dc_settings.compute_inductance = True for p in [0, 1, 2]: setup1.set_dc_slider(p) From fb9810ea901afda2bca831eb72e7884fc066e055 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 22:46:32 +0100 Subject: [PATCH 20/61] fix --- _unittest/test_00_EDB.py | 2 -- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 0073cf8616e..cf1bd77a12d 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2168,8 +2168,6 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") - assert setup1.name == "DC1" - self.edbapp.setups["DC1"].dc_settings.compute_inductance = True for p in [0, 1, 2]: setup1.set_dc_slider(p) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 729b0230cb6..3fa5c52ce5e 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -511,11 +511,11 @@ class DCSettings(SettingsBase): def __init__(self, parent): self._parent = parent self.defaults = { - #"compute_inductance": [False, False, False], + "compute_inductance": [False, False, False], "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], "dc_slider_position": [0, 1, 2], "use_dc_custom_settings": [False, False, False], - "plot_jv": [True, True, True], + #"plot_jv": [True, True, True], } @property @@ -1073,6 +1073,7 @@ def get_dict(self): @pyaedt_function_handler def set_dc_slider(self, value): + self.use_custom_settings = False self.dc_settings.set_dc_slider(value) self.dc_advanced_settings.set_dc_slider(value) From 8fe918e43f1aac292a75e525b1fd23c4c5c65375 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 22:56:57 +0100 Subject: [PATCH 21/61] fix --- _unittest/test_00_EDB.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index cf1bd77a12d..748d102b8ad 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2168,6 +2168,7 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") + setup1.dc_settings.compute_inductance = False for p in [0, 1, 2]: setup1.set_dc_slider(p) From ce23745f3426f430b2c6d99824be5de1dfb4eef5 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 4 Nov 2023 23:44:05 +0100 Subject: [PATCH 22/61] fix --- _unittest/test_00_EDB.py | 2 +- .../edb_data/siwave_simulation_setup_data.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 748d102b8ad..4bf8ebcd24f 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2168,7 +2168,7 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") - setup1.dc_settings.compute_inductance = False + self.edbapp.setups["DC1"].dc_settings.use_custom_settings = True for p in [0, 1, 2]: setup1.set_dc_slider(p) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 3fa5c52ce5e..eeff54c1b96 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -515,7 +515,7 @@ def __init__(self, parent): "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], "dc_slider_position": [0, 1, 2], "use_dc_custom_settings": [False, False, False], - #"plot_jv": [True, True, True], + "plot_jv": [True, True, True], } @property @@ -897,6 +897,7 @@ def __init__(self, pedb, edb_setup=None): super().__init__(pedb, edb_setup) self._edb = self._pedb self._setup_type = "kSIwave" + self._sim_setup_info = None @pyaedt_function_handler() def create(self, name=None): @@ -922,8 +923,10 @@ def advanced_settings(self): @property def get_sim_setup_info(self): """Read simulation information from setup.""" - edb_setup = self._edb_object + if self._sim_setup_info: + return self._sim_setup_info + edb_setup = self._edb_object edb_sim_setup_info = self._pedb.simsetupdata.SimSetupInfo[self._setup_type_mapping[self._setup_type]]() edb_sim_setup_info.Name = edb_setup.GetName() @@ -1054,14 +1057,11 @@ def __init__(self, pedb, edb_object=None): self._setup_type = "kSIwaveDCIR" self._edb = pedb self._mesh_operations = {} - self._edb_setup_info = self._edb.simsetupdata.SimSetupInfo[ - self._edb.simsetupdata.SIwave.SIWDCIRSimulationSettings - ]() def create(self, name=None): self._name = name self._create(name) - self.dc_settings.set_dc_slider(1) + self.set_dc_slider(1) return self @pyaedt_function_handler @@ -1101,7 +1101,7 @@ def source_terms_to_ground(self): {str, int}, keys is source name, value int 0 unspecified, 1 negative node, 2 positive one. """ - return convert_netdict_to_pydict(self._edb_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround) + return convert_netdict_to_pydict(self.get_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround) @pyaedt_function_handler() def add_source_terminal_to_ground(self, source_name, terminal=0): @@ -1125,5 +1125,5 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): """ terminals = self.source_terms_to_ground terminals[source_name] = terminal - self._edb_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) + self.get_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) return self._update_setup() From c9c974cc30d58526a69451eea9c571a3e65367d8 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 08:51:13 +0100 Subject: [PATCH 23/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index eeff54c1b96..e9f79cce6e5 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -511,11 +511,11 @@ class DCSettings(SettingsBase): def __init__(self, parent): self._parent = parent self.defaults = { - "compute_inductance": [False, False, False], + #"compute_inductance": [False, False, False], "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], "dc_slider_position": [0, 1, 2], "use_dc_custom_settings": [False, False, False], - "plot_jv": [True, True, True], + #"plot_jv": [True, True, True], } @property @@ -1028,7 +1028,9 @@ def use_custom_settings(self): @use_custom_settings.setter def use_custom_settings(self, value): - self.get_sim_setup_info.SimulationSettings.UseCustomSettings = value + edb_setup_info = self.get_sim_setup_info + edb_setup_info.SimulationSettings.UseCustomSettings = value + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @property From b864ed8307a14532a3966ffe3d8e97e92e4eeb4a Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 12:15:18 +0100 Subject: [PATCH 24/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 01886367763..5d88df45d62 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -46,17 +46,18 @@ def _create(self, name=None): @pyaedt_function_handler def _set_edb_setup_info(self, edb_setup_info): + utility = self._pedb._edb.Utility setup_type_mapping = { - "kHFSS": self._pedb.edb_api.utility.utility.HFSSSimulationSetup, + "kHFSS": utility.HFSSSimulationSetup, "kPEM": None, - "kSIwave": self._pedb.edb_api.utility.utility.SIWaveSimulationSetup, + "kSIwave": utility.SIWaveSimulationSetup, "kLNA": None, "kTransient": None, "kQEye": None, "kVEye": None, "kAMI": None, "kAnalysisOption": None, - "kSIwaveDCIR": self._pedb.edb_api.utility.utility.SIWaveDCIRSimulationSetup, + "kSIwaveDCIR": utility.SIWaveDCIRSimulationSetup, "kSIwaveEMI": None, "kHFSSPI": None, "kDDRwizard": None, From 8bb833c82fe183f8e395f0cc573c80756ede7324 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 14:56:38 +0100 Subject: [PATCH 25/61] fix --- _unittest/test_00_EDB.py | 25 ++++- .../edb_data/siwave_simulation_setup_data.py | 106 +++++++++--------- 2 files changed, 78 insertions(+), 53 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 4bf8ebcd24f..95b47023336 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2168,16 +2168,28 @@ def test_129_hfss_simulation_setup(self): def test_130_siwave_dc_simulation_setup(self): setup1 = self.edbapp.create_siwave_dc_setup("DC1") - self.edbapp.setups["DC1"].dc_settings.use_custom_settings = True + setup1.dc_settings.restore_default() + setup1.dc_advanced_settings.restore_default() + + settings = self.edbapp.setups["DC1"].get_dict() + for k, v in setup1.dc_settings.defaults.items(): + if k in ["compute_inductance", "plot_jv"]: + continue + print(k) + assert settings["dc_settings"][k] == v + + for k, v in setup1.dc_advanced_settings.defaults.items(): + print(k) + assert settings["dc_advanced_settings"][k] == v for p in [0, 1, 2]: setup1.set_dc_slider(p) settings = self.edbapp.setups["DC1"].get_dict() - for k, v in setup1.dc_settings.defaults.items(): + for k, v in setup1.dc_settings.dc_defaults.items(): print(k) assert settings["dc_settings"][k] == v[p] - for k, v in setup1.dc_advanced_settings.defaults.items(): + for k, v in setup1.dc_advanced_settings.dc_defaults.items(): print(k) assert settings["dc_advanced_settings"][k] == v[p] @@ -2187,6 +2199,13 @@ def test_131_siwave_ac_simulation_setup(self): setup1 = self.edbapp.create_siwave_syz_setup("AC1") assert setup1.name == "AC1" assert setup1.enabled + setup1.advanced_settings.restore_default() + + settings = self.edbapp.setups["AC1"].get_dict() + for k, v in setup1.advanced_settings.defaults.items(): + if k in ["min_plane_area_to_mesh"]: + continue + assert settings["advanced_settings"][k] == v for p in [0, 1, 2]: setup1.set_si_slider(p) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index e9f79cce6e5..dddba729e07 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -64,68 +64,63 @@ def get_dict(self): return temp @pyaedt_function_handler - def set_dc_slider(self, value): + def restore_default(self): for k, val in self.defaults.items(): - self.__setattr__(k, val[value]) - - @pyaedt_function_handler - def set_si_slider(self, value): - for k, val in self.si_defaults.items(): - self.__setattr__(k, val[value]) - - @pyaedt_function_handler - def set_pi_slider(self, value): - for k, val in self.pi_defaults.items(): - self.__setattr__(k, val[value]) + self.__setattr__(k, val) class AdvancedSettings(SettingsBase): def __init__(self, parent): self._parent = parent + self.defaults = { + "automatic_mesh": True, + "ignore_non_functional_pads": True, + "include_coplane_coupling": True, + "include_fringe_coupling": True, + "include_infinite_ground": False, + "include_inter_plane_coupling": False, + "include_split_plane_coupling": True, + "include_trace_coupling": True, + "include_vi_sources": False, + "infinite_ground_location": "0", + "max_coupled_lines": 12, + "mesh_frequency": "4GHz", + "min_pad_area_to_mesh": "28mm2", + "min_plane_area_to_mesh": "5e-5mm2", + "min_void_area": "2mm2", + "perform_erc": False, + "return_current_distribution": False, + "snap_length_threshold": "2.5um", + "xtalk_threshold": "-34", + } + self.si_defaults = { - "automatic_mesh": [True, True, True], - "ignore_non_functional_pads": [True, True, True], "include_coplane_coupling": [False, True, True], "include_fringe_coupling": [False, True, True], - "include_infinite_ground": [False, False, False], "include_inter_plane_coupling": [False, False, False], "include_split_plane_coupling": [False, True, True], - "include_trace_coupling": [True, True, True], - "include_vi_sources": [False, False, False], - "infinite_ground_location": ["0", "0", "0"], "max_coupled_lines": [12, 12, 40], - "mesh_frequency": ["4GHz", "4GHz", "4GHz"], - "min_pad_area_to_mesh": ["28mm2", "28mm2", "28mm2"], - #"min_plane_area_to_mesh": ["5e-5mm2", "5e-5mm2", "5e-5mm2"], - "min_void_area": ["2mm2", "2mm2", "2mm2"], - "perform_erc": [False, False, False], "return_current_distribution": [False, False, True], - "snap_length_threshold": ["2.5um", "2.5um", "2.5um"], - "xtalk_threshold": ["-34", "-34", "-34"], } self.pi_defaults = { - "automatic_mesh": [True, True, True], - "ignore_non_functional_pads": [True, True, True], "include_coplane_coupling": [False, False, True], "include_fringe_coupling": [False, True, True], - "include_infinite_ground": [False, False, False], - "include_inter_plane_coupling": [False, False, False], "include_split_plane_coupling": [False, False, True], "include_trace_coupling": [False, False, True], - "include_vi_sources": [False, False, False], - "infinite_ground_location": ["0", "0", "0"], "max_coupled_lines": [12, 12, 40], - "mesh_frequency": ["4GHz", "4GHz", "4GHz"], - "min_pad_area_to_mesh": ["28mm2", "28mm2", "28mm2"], - #"min_plane_area_to_mesh": ["5e-5mm2", "5e-5mm2", "5e-5mm2"], - "min_void_area": ["2mm2", "2mm2", "2mm2"], - "perform_erc": [False, False, False], - "return_current_distribution": [False, False, False], - "snap_length_threshold": ["2.5um", "2.5um", "2.5um"], - "xtalk_threshold": ["-34", "-34", "-34"], } + @pyaedt_function_handler + def set_si_slider(self, value): + for k, val in self.si_defaults.items(): + self.__setattr__(k, val[value]) + + @pyaedt_function_handler + def set_pi_slider(self, value): + for k, val in self.pi_defaults.items(): + self.__setattr__(k, val[value]) + @property def sim_setup_info(self): """EDB internal simulation setup object.""" @@ -511,11 +506,13 @@ class DCSettings(SettingsBase): def __init__(self, parent): self._parent = parent self.defaults = { - #"compute_inductance": [False, False, False], - "contact_radius": ["0.1mm", "0.1mm", "0.1mm"], + "compute_inductance": False, + "contact_radius": "0.1mm", + "use_dc_custom_settings":False, + "plot_jv": True, + } + self.dc_defaults = { "dc_slider_position": [0, 1, 2], - "use_dc_custom_settings": [False, False, False], - #"plot_jv": [True, True, True], } @property @@ -527,6 +524,7 @@ def compute_inductance(self): bool ``True`` if inductances will be computed, ``False`` otherwise. """ + return self.sim_setup_info.SimulationSettings.DCSettings.ComputeInductance @compute_inductance.setter @@ -618,22 +616,29 @@ class DCAdvancedSettings(SettingsBase): def __init__(self, parent): self._parent = parent self.defaults = { - "dc_min_void_area_to_mesh": ["0.001mm2", "0.001mm2", "0.001mm2"], + "dc_min_void_area_to_mesh": "0.001mm2", + "max_init_mesh_edge_length": "5mm", + "dc_min_plane_area_to_mesh": "1.5mm2", + "num_bondwire_sides": 8, + "num_via_sides": 8, + "percent_local_refinement": 20.0, + } + self.dc_defaults = { "energy_error": [2, 2, 1], - "max_init_mesh_edge_length": ["5mm", "5mm", "5mm"], "max_num_pass": [5, 5, 10], "mesh_bondwires": [False, True, True], "mesh_vias": [False, True, True], "min_num_pass": [1, 1, 3], - "dc_min_plane_area_to_mesh": ["1.5mm2", "1.5mm2", "1.5mm2"], - "num_bondwire_sides": [8, 8, 8], - "num_via_sides": [8, 8, 8], - "percent_local_refinement": [20.0, 20.0, 20.0], "perform_adaptive_refinement": [False, True, True], "refine_bondwires": [False, False, True], "refine_vias": [False, False, True], } + @pyaedt_function_handler + def set_dc_slider(self, value): + for k, val in self.dc_defaults.items(): + self.__setattr__(k, val[value]) + @property def sim_setup_info(self): """EDB internal simulation setup object.""" @@ -904,6 +909,7 @@ def create(self, name=None): self._name = name self._create(name) self.set_si_slider(1) + return self @pyaedt_function_handler @@ -1076,7 +1082,7 @@ def get_dict(self): @pyaedt_function_handler def set_dc_slider(self, value): self.use_custom_settings = False - self.dc_settings.set_dc_slider(value) + self.dc_settings.dc_slider_position = value self.dc_advanced_settings.set_dc_slider(value) @property From 5e6c28dae843469f07d855a833a5b0bd838f32fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 13:59:11 +0000 Subject: [PATCH 26/61] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- _unittest/test_00_EDB.py | 15 ++++++------- pyaedt/edb_core/edb_data/simulation_setup.py | 4 +++- .../edb_data/siwave_simulation_setup_data.py | 21 ++++++++++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 512ae885124..3a838bf49ec 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2236,7 +2236,7 @@ def test_130_siwave_dc_simulation_setup(self): continue print(k) assert settings["dc_settings"][k] == v - + for k, v in setup1.dc_advanced_settings.defaults.items(): print(k) assert settings["dc_advanced_settings"][k] == v @@ -2246,13 +2246,11 @@ def test_130_siwave_dc_simulation_setup(self): settings = self.edbapp.setups["DC1"].get_dict() for k, v in setup1.dc_settings.dc_defaults.items(): print(k) - assert settings["dc_settings"][k] == v[p] + assert settings["dc_settings"][k] == v[p] for k, v in setup1.dc_advanced_settings.dc_defaults.items(): print(k) - assert settings["dc_advanced_settings"][k] == v[p] - - + assert settings["dc_advanced_settings"][k] == v[p] def test_131_siwave_ac_simulation_setup(self): setup1 = self.edbapp.create_siwave_syz_setup("AC1") @@ -2264,19 +2262,19 @@ def test_131_siwave_ac_simulation_setup(self): for k, v in setup1.advanced_settings.defaults.items(): if k in ["min_plane_area_to_mesh"]: continue - assert settings["advanced_settings"][k] == v + assert settings["advanced_settings"][k] == v for p in [0, 1, 2]: setup1.set_si_slider(p) settings = self.edbapp.setups["AC1"].get_dict() for k, v in setup1.advanced_settings.si_defaults.items(): - assert settings["advanced_settings"][k] == v[p] + assert settings["advanced_settings"][k] == v[p] for p in [0, 1, 2]: setup1.set_pi_slider(p) settings = self.edbapp.setups["AC1"].get_dict() for k, v in setup1.advanced_settings.pi_defaults.items(): - assert settings["advanced_settings"][k] == v[p] + assert settings["advanced_settings"][k] == v[p] sweep = setup1.add_frequency_sweep( "sweep1", @@ -2344,7 +2342,6 @@ def test_131_siwave_ac_simulation_setup(self): assert sweep.save_rad_fields_only assert sweep.use_q3d_for_dc - def test_132_via_plating_ratio_check(self): assert self.edbapp.padstacks.check_and_fix_via_plating() diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 5d88df45d62..fc9235ecc5f 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,4 +1,5 @@ import re + from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler @@ -62,7 +63,8 @@ def _set_edb_setup_info(self, edb_setup_info): "kHFSSPI": None, "kDDRwizard": None, "kQ3D": None, - "kNumSetupTypes": None} + "kNumSetupTypes": None, + } return setup_type_mapping[self._setup_type](edb_setup_info) @pyaedt_function_handler() diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index dddba729e07..b90a1a49d45 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -56,8 +56,17 @@ def get_dict(self): attrs_list = [ i for i in attrs_list - if i not in ["get_dict", "sim_setup_info", "defaults", "si_defaults", "pi_defaults", "set_dc_slider", - "set_si_slider", "set_pi_slider"] + if i + not in [ + "get_dict", + "sim_setup_info", + "defaults", + "si_defaults", + "pi_defaults", + "set_dc_slider", + "set_si_slider", + "set_pi_slider", + ] ] for i in attrs_list: temp[i] = self.__getattribute__(i) @@ -508,7 +517,7 @@ def __init__(self, parent): self.defaults = { "compute_inductance": False, "contact_radius": "0.1mm", - "use_dc_custom_settings":False, + "use_dc_custom_settings": False, "plot_jv": True, } self.dc_defaults = { @@ -917,7 +926,7 @@ def get_dict(self): return { "pi_slider_postion": self.pi_slider_position, "si_slider_postion": self.si_slider_position, - "use_custom_settings" : self.use_si_settings, + "use_custom_settings": self.use_si_settings, "use_si_settings": self.use_si_settings, "advanced_settings": self.advanced_settings.get_dict(), } @@ -1133,5 +1142,7 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): """ terminals = self.source_terms_to_ground terminals[source_name] = terminal - self.get_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) + self.get_sim_setup_info.SimulationSettings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict( + terminals + ) return self._update_setup() From 856608aa5d2073c8bc33d37ea4704908a364da58 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 15:28:52 +0100 Subject: [PATCH 27/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 86 +++++++++++-------- .../edb_data/siwave_simulation_setup_data.py | 39 +++++---- pyaedt/generic/LoadAEDTFile.py | 12 +-- 3 files changed, 73 insertions(+), 64 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index fc9235ecc5f..15d289477ff 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -6,7 +6,17 @@ class BaseSimulationSetup(object): - """Ansys.Ansoft.SimSetupData.Data.BaseSimulationSettings.""" + """Provide base simulation setup. + + Parameters + ---------- + pedb : :class:`pyaedt.edb.Edb` + Inherited AEDT object. + edb_object : :class:`Ansys.Ansoft.Edb.Utility.SIWaveSimulationSetup`, + :class:`Ansys.Ansoft.Edb.Utility.SIWDCIRSimulationSettings`, + :class:`Ansys.Ansoft.Edb.Utility.HFSSSimulationSettings` + Edb object. + """ def __init__(self, pedb, edb_setup=None): self._pedb = pedb @@ -34,7 +44,7 @@ def __init__(self, pedb, edb_setup=None): @pyaedt_function_handler def _create(self, name=None): - """Create a new setup.""" + """Create a setup.""" if not name: name = generate_unique_name(self.setup_type) self._name = name @@ -97,7 +107,7 @@ def enabled(self, value): @property def name(self): - """Name of the Setup.""" + """Name of the setup.""" return self._edb_object.GetName() @name.setter @@ -128,7 +138,7 @@ def setup_type(self): @property def frequency_sweeps(self): - """list of frequency sweep.""" + """list of frequency sweeps.""" temp = {} for i in list(self.get_sim_setup_info.SweepDataList): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) @@ -192,7 +202,16 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): class EdbFrequencySweep(object): - """Manages EDB methods for frequency sweep.""" + """Manages EDB methods for frequency sweep. + + Parameters + ---------- + sim_setup : :class:`pyaedt.edb_core.edb_data.siwave_simulation_setup_data.SiwaveSYZSimulationSetup` + name : str, optional + Name of the frequency sweep. + edb_sweep_data : :class:`Ansys.Ansoft.Edb.Utility.SIWDCIRSimulationSettings`, optional + Edb object. + """ def __init__(self, sim_setup, frequency_sweep=None, name=None, edb_sweep_data=None): self._sim_setup = sim_setup @@ -214,7 +233,7 @@ def _edb_object(self): @property def _pedb(self): - """Edb.""" + """EDB.""" return self._sim_setup._pedb @pyaedt_function_handler() @@ -231,7 +250,6 @@ def name(self): @name.setter def name(self, value): - """Set name of this sweep""" self._edb_sweep_data.Name = value self._update_sweep() @@ -242,7 +260,7 @@ def sweep_type(self): @property def frequencies(self): - """List of frequencies points.""" + """List of frequency points.""" return list(self._edb_sweep_data.Frequencies) @property @@ -258,7 +276,7 @@ def adaptive_sampling(self): @property def adv_dc_extrapolation(self): - """Whether to turn on advanced DC Extrapolation. + """Flag indicating if advanced DC extrapolation is turned on. Returns ------- @@ -292,7 +310,7 @@ def enforce_causality(self): @property def enforce_dc_and_causality(self): - """Whether to enforce DC point and causality. + """Flag indicating if DC point and causality are enforced. Returns ------- @@ -351,7 +369,7 @@ def interp_use_port_impedance(self): @property def interp_use_prop_const(self): - """Whether to use propagation constants. + """Flag indicating if propagation constants are used. Returns ------- @@ -362,7 +380,7 @@ def interp_use_prop_const(self): @property def interp_use_s_matrix(self): - """Whether to use S matrix. + """Flag indicating if the S matrix is used. Returns ------- @@ -415,7 +433,7 @@ def passivity_tolerance(self): @property def relative_s_error(self): - """Specify S-parameter error tolerance for interpolating sweep. + """S-parameter error tolerance for the interpolating sweep. Returns ------- @@ -425,7 +443,7 @@ def relative_s_error(self): @property def save_fields(self): - """Whether to turn on or off the extraction of surface current data. + """Flag indicating if the extraction of surface current data is turned on. Returns ------- @@ -448,7 +466,7 @@ def save_rad_fields_only(self): @property def use_q3d_for_dc(self): - """Whether to enable Q3D solver for DC point extraction . + """Flag indicating if The Q3D solver is enabled for DC point extraction. Returns ------- @@ -571,12 +589,12 @@ def set_frequencies_linear_scale(self, start="0.1GHz", stop="20GHz", step="50MHz Parameters ---------- - start : str, float - Start frequency. - stop : str, float - Stop frequency. - step : str, float - Step frequency. + start : str, float, optional + Start frequency. The default is ``"0.1GHz"``. + stop : str, float, optional + Stop frequency. The default is ``"20GHz"``. + step : str, float, optional + Step frequency. The default is ``"50MHz"``. Returns ------- @@ -613,16 +631,15 @@ def set_frequencies_linear_count(self, start="1kHz", stop="0.1GHz", count=10): @pyaedt_function_handler() def set_frequencies_log_scale(self, start="1kHz", stop="0.1GHz", samples=10): - """Set a log count frequency sweep. - + """Set a log-count frequency sweep. Parameters ---------- - start : str, float - Start frequency. - stop : str, float - Stop frequency. - samples : int - Step frequency. + start : str, float, optional + Start frequency. The default is ``"1kHz"``. + stop : str, float, optional + Stop frequency. The default is ``"0.1GHz"``. + samples : int, optional + Step frequency. The default is ``10``. Returns ------- @@ -641,12 +658,11 @@ def set_frequencies(self, frequency_list=None, update=True): Parameters ---------- frequency_list : list, optional - List of lists with four elements. Each list must contain: - - 1- frequency type (``"linear count"``, ``"log scale"`` or ``"linear scale"``) - 2- start frequency - 3- stop frequency - 4- step frequency or count + List of lists with four elements. The default is ``None``. If provided, each list must contain: + 1 - frequency type (``"linear count"``, ``"log scale"``, or ``"linear scale"``) + 2 - start frequency + 3 - stop frequency + 4 - step frequency or count Returns ------- diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index b90a1a49d45..0db84ba4755 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1,26 +1,12 @@ -import warnings - from pyaedt.edb_core.edb_data.simulation_setup import BaseSimulationSetup -from pyaedt.edb_core.edb_data.simulation_setup import EdbFrequencySweep from pyaedt.edb_core.general import convert_netdict_to_pydict from pyaedt.edb_core.general import convert_pydict_to_netdict -from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import is_linux from pyaedt.generic.general_methods import pyaedt_function_handler def _parse_value(v): - """ - - Parameters - ---------- - v : - - - Returns - ------- - - """ + """Parse value in C sharp format.""" # duck typing parse of the value 'v' if v is None or v == "": pv = v @@ -43,6 +29,7 @@ def _parse_value(v): class SettingsBase(object): + """Provide base settings.""" @property def sim_setup_info(self): """EDB internal simulation setup object.""" @@ -656,7 +643,7 @@ def sim_setup_info(self): @property def dc_min_void_area_to_mesh(self): - """Minimum area below which voids are ignored. + """DC minimum area below which voids are ignored. Returns ------- @@ -905,7 +892,15 @@ def refine_vias(self, value): class SiwaveSYZSimulationSetup(BaseSimulationSetup): - """Manages EDB methods for SIwave simulation setup.""" + """Manages EDB methods for SIwave simulation setup. + + Parameters + ---------- + pedb : :class:`pyaedt.edb.Edb` + Inherited AEDT object. + edb_setup : :class:`Ansys.Ansoft.Edb.Utility.SIWaveSimulationSetup` + Edb object. + """ def __init__(self, pedb, edb_setup=None): super().__init__(pedb, edb_setup) @@ -1067,7 +1062,15 @@ def use_si_settings(self, value): class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup): - """Manages EDB methods for HFSS simulation setup.""" + """Manages EDB methods for SIwave DC simulation setup. + + Parameters + ---------- + pedb : :class:`pyaedt.edb.Edb` + Inherited AEDT object. + edb_setup : Ansys.Ansoft.Edb.Utility.SIWDCIRSimulationSettings + Edb object. + """ def __init__(self, pedb, edb_object=None): super().__init__(pedb, edb_object) diff --git a/pyaedt/generic/LoadAEDTFile.py b/pyaedt/generic/LoadAEDTFile.py index fb669773701..0d4cc6a9a76 100644 --- a/pyaedt/generic/LoadAEDTFile.py +++ b/pyaedt/generic/LoadAEDTFile.py @@ -80,17 +80,7 @@ def load_keyword_in_aedt_file(filename, keyword): def _parse_value(v): - """ - - Parameters - ---------- - v : - - - Returns - ------- - - """ + """Parse value in C sharp format.""" # duck typing parse of the value 'v' if v is None: pv = v From 0988ccb2d7a2843f46a5b1c312a54ea8ada437e9 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 15:30:27 +0100 Subject: [PATCH 28/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 15d289477ff..4f6eeadc709 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -1,6 +1,3 @@ -import re - -from pyaedt.edb_core.general import convert_pydict_to_netdict from pyaedt.generic.general_methods import generate_unique_name from pyaedt.generic.general_methods import pyaedt_function_handler From 2df4eb0c199096835b9befa5ef4a55d1f81c150e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:08:11 +0000 Subject: [PATCH 29/61] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 0db84ba4755..9b26f0892f3 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -30,6 +30,7 @@ def _parse_value(v): class SettingsBase(object): """Provide base settings.""" + @property def sim_setup_info(self): """EDB internal simulation setup object.""" From c8e6fa0f875a199139dcff44545769f720fdcfb3 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sun, 5 Nov 2023 23:56:59 +0100 Subject: [PATCH 30/61] fix --- .../edb_data/hfss_simulation_setup_data.py | 2 + pyaedt/edb_core/edb_data/padstacks_data.py | 4 -- pyaedt/edb_core/edb_data/simulation_setup.py | 31 +++++++++- .../edb_data/siwave_simulation_setup_data.py | 61 +++++++++++++++---- 4 files changed, 79 insertions(+), 19 deletions(-) diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index dcf14a1bccc..35b3cb7eb05 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -1235,12 +1235,14 @@ def __init__(self, pedb, edb_object=None): @pyaedt_function_handler() def create(self, name=None): + """Create a HFSS setup.""" self._name = name self._create(name) return self @property def get_sim_setup_info(self): + """Get simulation setup information.""" return self._edb_object.GetSimSetupInfo() @property diff --git a/pyaedt/edb_core/edb_data/padstacks_data.py b/pyaedt/edb_core/edb_data/padstacks_data.py index ed25ff69b08..4c654868c4d 100644 --- a/pyaedt/edb_core/edb_data/padstacks_data.py +++ b/pyaedt/edb_core/edb_data/padstacks_data.py @@ -1037,10 +1037,6 @@ def create_port(self, name=None, reference=None, is_circuit_port=False): Negative terminal of the port. is_circuit_port : bool, optional Whether it is a circuit port. - - Returns - ------- - """ terminal = self._create_terminal(name) if reference: diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 4f6eeadc709..a84f5a77ab9 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -39,6 +39,8 @@ def __init__(self, pedb, edb_setup=None): if self._edb_object: self._name = self._edb_object.GetName() + self._sweep_list = {} + @pyaedt_function_handler def _create(self, name=None): """Create a setup.""" @@ -135,7 +137,7 @@ def setup_type(self): @property def frequency_sweeps(self): - """list of frequency sweeps.""" + """List of frequency sweeps.""" temp = {} for i in list(self.get_sim_setup_info.SweepDataList): temp[i.Name] = EdbFrequencySweep(self, None, i.Name, i) @@ -143,13 +145,35 @@ def frequency_sweeps(self): @pyaedt_function_handler def _add_frequency_sweep(self, sweep_data): + """Add a frequency sweep. + + Parameters + ---------- + sweep_data: EdbFrequencySweep + """ + self._sweep_list[sweep_data.name] = sweep_data edb_setup_info = self.get_sim_setup_info - edb_setup_info.SweepDataList.Add(sweep_data._edb_object) + + if self._setup_type == "kSIwave": + for k, v in self._sweep_list.items(): + edb_setup_info.SweepDataList.Add(v._edb_object) + self._edb_object = self._set_edb_setup_info(edb_setup_info) self._update_setup() @pyaedt_function_handler - def delete_frequency_sweep(self, name): + def delete_frequency_sweep(self, sweep_data): + """Delete a frequency sweep. + + Parameters + ---------- + sweep_data: EdbFrequencySweep + """ + name = sweep_data.name + if name in self._sweep_list: + self._sweep_list.pop(name) + + fsweep = [] for k, val in self.frequency_sweeps.items(): if not k == name: @@ -629,6 +653,7 @@ def set_frequencies_linear_count(self, start="1kHz", stop="0.1GHz", count=10): @pyaedt_function_handler() def set_frequencies_log_scale(self, start="1kHz", stop="0.1GHz", samples=10): """Set a log-count frequency sweep. + Parameters ---------- start : str, float, optional diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 0db84ba4755..873e819903f 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -549,22 +549,17 @@ def contact_radius(self, value): @property def dc_slider_position(self): - """Slider position for DC. + """DC simulation accuracy level slider position. This property only change slider position. - Returns - ------- - int - """ - return self.sim_setup_info.SimulationSettings.DCSettings.DCSliderPos - - @dc_slider_position.setter - def dc_slider_position(self, value): - """DC simulation accuracy level slider position. Options: 0- ``optimal speed`` 1- ``balanced`` 2- ``optimal accuracy``. """ + return self.sim_setup_info.SimulationSettings.DCSettings.DCSliderPos + + @dc_slider_position.setter + def dc_slider_position(self, value): edb_setup_info = self.sim_setup_info edb_setup_info.SimulationSettings.DCSettings.DCSliderPos = value self._parent._edb_object = self._parent._set_edb_setup_info(edb_setup_info) @@ -910,6 +905,12 @@ def __init__(self, pedb, edb_setup=None): @pyaedt_function_handler() def create(self, name=None): + """Create a SIwave SYZ setup. + + Returns + ------- + :class:`SiwaveDCSimulationSetup` + """ self._name = name self._create(name) self.set_si_slider(1) @@ -928,6 +929,7 @@ def get_dict(self): @property def advanced_settings(self): + """SIwave advanced settings class.""" return AdvancedSettings(self) @property @@ -990,6 +992,13 @@ def get_sim_setup_info(self): @pyaedt_function_handler def set_pi_slider(self, value): + """Set SIwave PI simulation accuracy level. + + Options: + 0- ``optimal speed`` + 1- ``balanced`` + 2- ``optimal accuracy``. + """ self.use_si_settings = False self.use_custom_settings = False self.pi_slider_position = value @@ -997,6 +1006,13 @@ def set_pi_slider(self, value): @pyaedt_function_handler def set_si_slider(self, value): + """Set SIwave SI simulation accuracy level. + + Options: + 0- ``optimal speed`` + 1- ``balanced`` + 2- ``optimal accuracy``. + """ self.use_si_settings = True self.use_custom_settings = False self.si_slider_position = value @@ -1028,7 +1044,7 @@ def si_slider_position(self, value): @property def use_custom_settings(self): - """Whether to use custom settings. + """Flag indicating if custom settings is turned on. Returns ------- @@ -1079,6 +1095,13 @@ def __init__(self, pedb, edb_object=None): self._mesh_operations = {} def create(self, name=None): + """Create a SIwave DCIR setup. + + + Returns + ------- + :class:`SiwaveDCSimulationSetup` + """ self._name = name self._create(name) self.set_dc_slider(1) @@ -1086,6 +1109,12 @@ def create(self, name=None): @pyaedt_function_handler def get_dict(self): + """Get settings. + + Returns + ------- + dict + """ return { "dc_settings": self.dc_settings.get_dict(), "dc_advanced_settings": self.dc_advanced_settings.get_dict(), @@ -1093,17 +1122,25 @@ def get_dict(self): @pyaedt_function_handler def set_dc_slider(self, value): + """Set DC simulation accuracy level. + + Options: + 0- ``optimal speed`` + 1- ``balanced`` + 2- ``optimal accuracy``. + """ self.use_custom_settings = False self.dc_settings.dc_slider_position = value self.dc_advanced_settings.set_dc_slider(value) @property def dc_settings(self): + """SIwave DC setting class.""" return DCSettings(self) @property def dc_advanced_settings(self): - """Siwave DC settings. + """Siwave DC advanced settings class. Returns ------- From f4ff1243c79c585418497589d40f78bea85556dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 22:58:26 +0000 Subject: [PATCH 31/61] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/edb_core/edb_data/simulation_setup.py | 1 - pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index a84f5a77ab9..401df71db5a 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -173,7 +173,6 @@ def delete_frequency_sweep(self, sweep_data): if name in self._sweep_list: self._sweep_list.pop(name) - fsweep = [] for k, val in self.frequency_sweeps.items(): if not k == name: diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index cb7be81a1a9..8265241ef8f 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1008,7 +1008,7 @@ def set_pi_slider(self, value): @pyaedt_function_handler def set_si_slider(self, value): """Set SIwave SI simulation accuracy level. - + Options: 0- ``optimal speed`` 1- ``balanced`` From 093b79b25888e90fc76820c93f047f3a729f3e71 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 00:17:29 +0100 Subject: [PATCH 32/61] fix --- .../edb_data/hfss_simulation_setup_data.py | 2 +- pyaedt/edb_core/edb_data/simulation_setup.py | 8 +++++--- .../edb_data/siwave_simulation_setup_data.py | 17 ++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py index 35b3cb7eb05..d7e6afecf7b 100644 --- a/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/hfss_simulation_setup_data.py @@ -639,7 +639,7 @@ def save_fields(self, value): @property def save_rad_field_only(self): - """Whether to turn on save radiated fields only. + """Flag indicating if the saving of only radiated fields is turned on. Returns ------- diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index a84f5a77ab9..89b65a2019c 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -56,6 +56,7 @@ def _create(self, name=None): @pyaedt_function_handler def _set_edb_setup_info(self, edb_setup_info): + """Create a setup object from setup information object.""" utility = self._pedb._edb.Utility setup_type_mapping = { "kHFSS": utility.HFSSSimulationSetup, @@ -74,7 +75,8 @@ def _set_edb_setup_info(self, edb_setup_info): "kQ3D": None, "kNumSetupTypes": None, } - return setup_type_mapping[self._setup_type](edb_setup_info) + setup_utility = setup_type_mapping[self._setup_type] + return setup_utility(edb_setup_info) @pyaedt_function_handler() def _update_setup(self): @@ -154,7 +156,7 @@ def _add_frequency_sweep(self, sweep_data): self._sweep_list[sweep_data.name] = sweep_data edb_setup_info = self.get_sim_setup_info - if self._setup_type == "kSIwave": + if self._setup_type in ["kSIwave", "kHFSS"]: for k, v in self._sweep_list.items(): edb_setup_info.SweepDataList.Add(v._edb_object) @@ -475,7 +477,7 @@ def save_fields(self): @property def save_rad_fields_only(self): - """Whether to turn on save radiated fields only. + """Flag indicating if the saving of only radiated fields is turned on. Returns ------- diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index cb7be81a1a9..665d66e06d1 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -39,6 +39,12 @@ def sim_setup_info(self): @pyaedt_function_handler def get_dict(self): + """Get all attributes. + + Returns + ------- + dict + """ temp = {} attrs_list = [i for i in dir(self) if not i.startswith("_")] attrs_list = [ @@ -118,11 +124,6 @@ def set_pi_slider(self, value): for k, val in self.pi_defaults.items(): self.__setattr__(k, val[value]) - @property - def sim_setup_info(self): - """EDB internal simulation setup object.""" - return self._parent.get_sim_setup_info - @property def include_inter_plane_coupling(self): """Whether to turn on InterPlane Coupling. @@ -631,12 +632,6 @@ def set_dc_slider(self, value): for k, val in self.dc_defaults.items(): self.__setattr__(k, val[value]) - @property - def sim_setup_info(self): - """EDB internal simulation setup object.""" - - return self._parent.get_sim_setup_info - @property def dc_min_void_area_to_mesh(self): """DC minimum area below which voids are ignored. From 8d33dc4171bfdd9ba4a6d3cbaaedc457c77f2652 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 00:20:33 +0100 Subject: [PATCH 33/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 6bba086b3c5..f64f6a5365c 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -30,6 +30,8 @@ def _parse_value(v): class SettingsBase(object): """Provide base settings.""" + def __init__(self, parent): + self._parent = parent @property def sim_setup_info(self): @@ -74,7 +76,7 @@ def restore_default(self): class AdvancedSettings(SettingsBase): def __init__(self, parent): - self._parent = parent + super().__init__(parent) self.defaults = { "automatic_mesh": True, "ignore_non_functional_pads": True, @@ -502,7 +504,7 @@ def mesh_frequency(self, value): class DCSettings(SettingsBase): def __init__(self, parent): - self._parent = parent + super().__init__(parent) self.defaults = { "compute_inductance": False, "contact_radius": "0.1mm", @@ -607,7 +609,7 @@ def plot_jv(self, value): class DCAdvancedSettings(SettingsBase): def __init__(self, parent): - self._parent = parent + super().__init__(parent) self.defaults = { "dc_min_void_area_to_mesh": "0.001mm2", "max_init_mesh_edge_length": "5mm", From 69160bdbe17fd07255f9ddfc98ed7b310119d84c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 23:23:13 +0000 Subject: [PATCH 34/61] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index f64f6a5365c..c795df3ef70 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -30,6 +30,7 @@ def _parse_value(v): class SettingsBase(object): """Provide base settings.""" + def __init__(self, parent): self._parent = parent From 5763bdde290164b1b191516e1b2d55255f81d1be Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 15:00:12 +0100 Subject: [PATCH 35/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index eaa513855d4..010d33f4534 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -169,7 +169,7 @@ def delete_frequency_sweep(self, sweep_data): Parameters ---------- - sweep_data: EdbFrequencySweep + sweep_data : EdbFrequencySweep """ name = sweep_data.name if name in self._sweep_list: From fb460e907755dfc32d4e01b01406c4271495c138 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 15:01:04 +0100 Subject: [PATCH 36/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 010d33f4534..9412d42997b 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -157,7 +157,7 @@ def _add_frequency_sweep(self, sweep_data): edb_setup_info = self.get_sim_setup_info if self._setup_type in ["kSIwave", "kHFSS"]: - for k, v in self._sweep_list.items(): + for _, v in self._sweep_list.items(): edb_setup_info.SweepDataList.Add(v._edb_object) self._edb_object = self._set_edb_setup_info(edb_setup_info) From 4f9c69de5eb804b7934916c466640f3efc8ec901 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 15:11:05 +0100 Subject: [PATCH 37/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 9412d42997b..1ad84afb81b 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -260,7 +260,7 @@ def _pedb(self): @pyaedt_function_handler() def _update_sweep(self): - """Update sweep.""" + """Update the sweep.""" self._sim_setup.delete_frequency_sweep(self) self._sim_setup._add_frequency_sweep(self) return @@ -310,13 +310,7 @@ def adv_dc_extrapolation(self): @property def auto_s_mat_only_solve(self): - """Whether to turn on Auto/Manual SMatrix only solve. - - Returns - ------- - bool - ``True`` if Auto/Manual SMatrix only solve is used, ``False`` otherwise. - """ + """Flag indication if Auto SMatrix only solve is turned on.""" return self._edb_sweep_data.AutoSMatOnlySolve @property @@ -355,8 +349,8 @@ def enforce_passivity(self): @property def freq_sweep_type(self): - """Sweep type. - Options are: + """Sweep type. Options are: + - ``kInterpolatingSweep``. - ``kDiscreteSweep``. - ``kBroadbandFastSweep``. From 132cb9c6f799f47db088927dded3522b5cc554c1 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 17:07:23 +0100 Subject: [PATCH 38/61] fix --- _unittest/test_00_EDB.py | 10 +++++----- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- .../edb_data/siwave_simulation_setup_data.py | 20 ++++++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 3a838bf49ec..12cfa9383ef 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2230,7 +2230,7 @@ def test_130_siwave_dc_simulation_setup(self): setup1.dc_settings.restore_default() setup1.dc_advanced_settings.restore_default() - settings = self.edbapp.setups["DC1"].get_dict() + settings = self.edbapp.setups["DC1"].get_configurations() for k, v in setup1.dc_settings.defaults.items(): if k in ["compute_inductance", "plot_jv"]: continue @@ -2243,7 +2243,7 @@ def test_130_siwave_dc_simulation_setup(self): for p in [0, 1, 2]: setup1.set_dc_slider(p) - settings = self.edbapp.setups["DC1"].get_dict() + settings = self.edbapp.setups["DC1"].get_configurations() for k, v in setup1.dc_settings.dc_defaults.items(): print(k) assert settings["dc_settings"][k] == v[p] @@ -2258,7 +2258,7 @@ def test_131_siwave_ac_simulation_setup(self): assert setup1.enabled setup1.advanced_settings.restore_default() - settings = self.edbapp.setups["AC1"].get_dict() + settings = self.edbapp.setups["AC1"].get_configurations() for k, v in setup1.advanced_settings.defaults.items(): if k in ["min_plane_area_to_mesh"]: continue @@ -2266,13 +2266,13 @@ def test_131_siwave_ac_simulation_setup(self): for p in [0, 1, 2]: setup1.set_si_slider(p) - settings = self.edbapp.setups["AC1"].get_dict() + settings = self.edbapp.setups["AC1"].get_configurations() for k, v in setup1.advanced_settings.si_defaults.items(): assert settings["advanced_settings"][k] == v[p] for p in [0, 1, 2]: setup1.set_pi_slider(p) - settings = self.edbapp.setups["AC1"].get_dict() + settings = self.edbapp.setups["AC1"].get_configurations() for k, v in setup1.advanced_settings.pi_defaults.items(): assert settings["advanced_settings"][k] == v[p] diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 1ad84afb81b..bf9dfb36c1d 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -349,7 +349,7 @@ def enforce_passivity(self): @property def freq_sweep_type(self): - """Sweep type. Options are: + """Sweep type. Options are. - ``kInterpolatingSweep``. - ``kDiscreteSweep``. diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index c795df3ef70..f2de878d701 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -41,7 +41,7 @@ def sim_setup_info(self): return self._parent.get_sim_setup_info @pyaedt_function_handler - def get_dict(self): + def get_configurations(self): """Get all attributes. Returns @@ -55,7 +55,7 @@ def get_dict(self): for i in attrs_list if i not in [ - "get_dict", + "get_configurations", "sim_setup_info", "defaults", "si_defaults", @@ -917,13 +917,19 @@ def create(self, name=None): return self @pyaedt_function_handler - def get_dict(self): + def get_configurations(self): + """Get SIwave configurations. + + Returns + ------- + dict + """ return { "pi_slider_postion": self.pi_slider_position, "si_slider_postion": self.si_slider_position, "use_custom_settings": self.use_si_settings, "use_si_settings": self.use_si_settings, - "advanced_settings": self.advanced_settings.get_dict(), + "advanced_settings": self.advanced_settings.get_configurations(), } @property @@ -1107,7 +1113,7 @@ def create(self, name=None): return self @pyaedt_function_handler - def get_dict(self): + def get_configurations(self): """Get settings. Returns @@ -1115,8 +1121,8 @@ def get_dict(self): dict """ return { - "dc_settings": self.dc_settings.get_dict(), - "dc_advanced_settings": self.dc_advanced_settings.get_dict(), + "dc_settings": self.dc_settings.get_configurations(), + "dc_advanced_settings": self.dc_advanced_settings.get_configurations(), } @pyaedt_function_handler From 6fbf3da7574aabeab90230d2d59afe2dc6ce77f3 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 17:30:34 +0100 Subject: [PATCH 39/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index f2de878d701..4e3126504f2 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -918,7 +918,7 @@ def create(self, name=None): @pyaedt_function_handler def get_configurations(self): - """Get SIwave configurations. + """Get SIwave SYZ simulation settings. Returns ------- @@ -1114,7 +1114,7 @@ def create(self, name=None): @pyaedt_function_handler def get_configurations(self): - """Get settings. + """Get SIwave DC simulation settings. Returns ------- From 769b987e2330b5f67d790ce4386b99d480a2db26 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 17:37:23 +0100 Subject: [PATCH 40/61] fix --- _unittest/test_00_EDB.py | 2 ++ pyaedt/edb_core/edb_data/simulation_setup.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index 12cfa9383ef..ed80e4eebd3 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2306,6 +2306,7 @@ def test_131_siwave_ac_simulation_setup(self): sweep.adaptive_sampling = True sweep.adv_dc_extrapolation = True + sweep.compute_dc_point = True sweep.auto_s_mat_only_solve = False sweep.enforce_causality = True sweep.enforce_dc_and_causality = True @@ -2325,6 +2326,7 @@ def test_131_siwave_ac_simulation_setup(self): assert sweep.adaptive_sampling assert sweep.adv_dc_extrapolation + assert sweep.compute_dc_point assert not sweep.auto_s_mat_only_solve assert sweep.enforce_causality assert sweep.enforce_dc_and_causality diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index bf9dfb36c1d..7de5ca02f4b 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -308,6 +308,16 @@ def adv_dc_extrapolation(self): """ return self._edb_sweep_data.AdvDCExtrapolation + @property + def compute_dc_point(self): + """Flag indication if compute exact dc point is turned on.""" + return self._edb_sweep_data.ComputeDCPoint + + @compute_dc_point.setter + def compute_dc_point(self, value): + self._edb_sweep_data.ComputeDCPoint = value + self._update_sweep() + @property def auto_s_mat_only_solve(self): """Flag indication if Auto SMatrix only solve is turned on.""" From fdde29045c7df8db1549e5dd24891272388bca29 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:14:00 +0100 Subject: [PATCH 41/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 7de5ca02f4b..65274f7a74a 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -372,7 +372,7 @@ def freq_sweep_type(self): return self._edb_sweep_data.FreqSweepType.ToString() @property - def interp_use_full_basis(self): + def interpolation_use_full_basis(self): """Whether to use Full basis elements. Returns From a7b52c1a274e949a35d129b479f1b763e7a0202f Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:14:12 +0100 Subject: [PATCH 42/61] Update pyaedt/generic/LoadAEDTFile.py Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- pyaedt/generic/LoadAEDTFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/generic/LoadAEDTFile.py b/pyaedt/generic/LoadAEDTFile.py index 0d4cc6a9a76..584dba38708 100644 --- a/pyaedt/generic/LoadAEDTFile.py +++ b/pyaedt/generic/LoadAEDTFile.py @@ -80,7 +80,7 @@ def load_keyword_in_aedt_file(filename, keyword): def _parse_value(v): - """Parse value in C sharp format.""" + """Parse value in C# format.""" # duck typing parse of the value 'v' if v is None: pv = v From 835df9a4c610000353410251798572607beb817c Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:14:27 +0100 Subject: [PATCH 43/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 4e3126504f2..e483cd00c0b 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1145,7 +1145,7 @@ def dc_settings(self): @property def dc_advanced_settings(self): - """Siwave DC advanced settings class. + """Siwave DC advanced settings. Returns ------- From bd5d2546ffe9854bbefd2ed8bb696dbb329d3724 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:14:56 +0100 Subject: [PATCH 44/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index e483cd00c0b..fc3c7a18118 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1129,10 +1129,11 @@ def get_configurations(self): def set_dc_slider(self, value): """Set DC simulation accuracy level. - Options: - 0- ``optimal speed`` - 1- ``balanced`` - 2- ``optimal accuracy``. + Options are: + + - ``0``: Optimal speed + - ``1``: Balanced + - ``2``: Optimal accuracy """ self.use_custom_settings = False self.dc_settings.dc_slider_position = value From 2ff38fd538a826e8d1cc55178d36c0476ef895fa Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:15:18 +0100 Subject: [PATCH 45/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index fc3c7a18118..5b569816465 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1119,6 +1119,7 @@ def get_configurations(self): Returns ------- dict + Dictionary of SIwave DC simulation settings. """ return { "dc_settings": self.dc_settings.get_configurations(), From c240b0c36ddc24b5c2d783f04abf12cc4441cec6 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:15:39 +0100 Subject: [PATCH 46/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 5b569816465..b10cc9932cb 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1090,7 +1090,7 @@ class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup): pedb : :class:`pyaedt.edb.Edb` Inherited AEDT object. edb_setup : Ansys.Ansoft.Edb.Utility.SIWDCIRSimulationSettings - Edb object. + EDB object. The default is ``None``. """ def __init__(self, pedb, edb_object=None): From 9df3bba9218d99cb916012035862121501a4a6d6 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:16:13 +0100 Subject: [PATCH 47/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index b10cc9932cb..3af0f125148 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1049,7 +1049,7 @@ def si_slider_position(self, value): @property def use_custom_settings(self): - """Flag indicating if custom settings is turned on. + """Custom settings to use. Returns ------- From 9503e675c057ad96f994576be3cbc415919eae9b Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:16:22 +0100 Subject: [PATCH 48/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 3af0f125148..7e904038bde 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1013,10 +1013,11 @@ def set_pi_slider(self, value): def set_si_slider(self, value): """Set SIwave SI simulation accuracy level. - Options: - 0- ``optimal speed`` - 1- ``balanced`` - 2- ``optimal accuracy``. + Options are: + + - ``0``: Optimal speed + - ``1``: Balanced + - ``2``: Optimal accuracy``` """ self.use_si_settings = True self.use_custom_settings = False From 26e7012b7489748d51e5ce03e8e5f8a7ed9aeaf0 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:16:31 +0100 Subject: [PATCH 49/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 65274f7a74a..2fdf9259f87 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -368,6 +368,7 @@ def freq_sweep_type(self): Returns ------- str + Sweep type. """ return self._edb_sweep_data.FreqSweepType.ToString() From cd3b323955d773710f49abbddb7815400542acdd Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:16:43 +0100 Subject: [PATCH 50/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 2fdf9259f87..2a9096713ce 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -361,9 +361,9 @@ def enforce_passivity(self): def freq_sweep_type(self): """Sweep type. Options are. - - ``kInterpolatingSweep``. - - ``kDiscreteSweep``. - - ``kBroadbandFastSweep``. + - ``"kInterpolatingSweep"`` + - ``"kDiscreteSweep"`` + - ``"kBroadbandFastSweep"`` Returns ------- From 9f243dc555cbcf91d1f344a367cf8bb0ef2b4f1e Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:16:53 +0100 Subject: [PATCH 51/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 2a9096713ce..bdb3d299471 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -359,7 +359,7 @@ def enforce_passivity(self): @property def freq_sweep_type(self): - """Sweep type. Options are. + """Sweep type. Options are: - ``"kInterpolatingSweep"`` - ``"kDiscreteSweep"`` From e671e1af24ee895fa2187cb3b95eace472502b37 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:17:02 +0100 Subject: [PATCH 52/61] Update pyaedt/edb_core/edb_data/simulation_setup.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index bdb3d299471..8ae538d7eec 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -224,7 +224,7 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): class EdbFrequencySweep(object): - """Manages EDB methods for frequency sweep. + """Manages EDB methods for a frequency sweep. Parameters ---------- From 7446c161389896757cb451a7459ee74cbccfbdaf Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:17:14 +0100 Subject: [PATCH 53/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 7e904038bde..797446fda63 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -999,10 +999,11 @@ def get_sim_setup_info(self): def set_pi_slider(self, value): """Set SIwave PI simulation accuracy level. - Options: - 0- ``optimal speed`` - 1- ``balanced`` - 2- ``optimal accuracy``. + Options are: + + - ``0``: Optimal speed + - ``1``: Balanced + - ``2``: Optimal accuracy """ self.use_si_settings = False self.use_custom_settings = False From a4e5bfb1ff91a9ec0e808c4aeedb46a2938ea43b Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:17:25 +0100 Subject: [PATCH 54/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 797446fda63..2369a40c5cc 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -923,6 +923,7 @@ def get_configurations(self): Returns ------- dict + Dictionary of SIwave SYZ simulation settings. """ return { "pi_slider_postion": self.pi_slider_position, From bd3c3410514891ac5ad54528a4c2a1f295dbc54c Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 21:18:27 +0100 Subject: [PATCH 55/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index 2369a40c5cc..a6d732a9e23 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -935,7 +935,7 @@ def get_configurations(self): @property def advanced_settings(self): - """SIwave advanced settings class.""" + """SIwave advanced settings.""" return AdvancedSettings(self) @property From faf1b9897226501f65eea22b2e992a7f619df4e7 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 6 Nov 2023 21:19:07 +0100 Subject: [PATCH 56/61] Update pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index a6d732a9e23..c20160f27fd 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -940,7 +940,7 @@ def advanced_settings(self): @property def get_sim_setup_info(self): - """Read simulation information from setup.""" + """Get simulation information from the setup.""" if self._sim_setup_info: return self._sim_setup_info From dc7d54e274790641b970eeb69e2f11816d5ffd10 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 21:19:43 +0100 Subject: [PATCH 57/61] fix --- pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py index a6d732a9e23..aa6bef4ace2 100644 --- a/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py +++ b/pyaedt/edb_core/edb_data/siwave_simulation_setup_data.py @@ -1145,7 +1145,7 @@ def set_dc_slider(self, value): @property def dc_settings(self): - """SIwave DC setting class.""" + """SIwave DC setting.""" return DCSettings(self) @property From 665daf3633d0a5a47f022a08f7c749256fdd8592 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Mon, 6 Nov 2023 21:46:57 +0100 Subject: [PATCH 58/61] fix --- _unittest/test_00_EDB.py | 18 ++++++++-------- pyaedt/edb_core/edb_data/simulation_setup.py | 22 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/_unittest/test_00_EDB.py b/_unittest/test_00_EDB.py index ed80e4eebd3..b3df33be11d 100644 --- a/_unittest/test_00_EDB.py +++ b/_unittest/test_00_EDB.py @@ -2292,9 +2292,9 @@ def test_131_siwave_ac_simulation_setup(self): assert not sweep.enforce_dc_and_causality assert sweep.enforce_passivity assert sweep.freq_sweep_type == "kInterpolatingSweep" - assert sweep.interp_use_full_basis - assert sweep.interp_use_port_impedance - assert sweep.interp_use_prop_const + assert sweep.interpolation_use_full_basis + assert sweep.interpolation_use_port_impedance + assert sweep.interpolation_use_prop_const assert sweep.max_solutions == 250 assert sweep.min_freq_s_mat_only_solve == "1MHz" assert not sweep.min_solved_freq @@ -2312,9 +2312,9 @@ def test_131_siwave_ac_simulation_setup(self): sweep.enforce_dc_and_causality = True sweep.enforce_passivity = False sweep.freq_sweep_type = "kDiscreteSweep" - sweep.interp_use_full_basis = False - sweep.interp_use_port_impedance = False - sweep.interp_use_prop_const = False + sweep.interpolation_use_full_basis = False + sweep.interpolation_use_port_impedance = False + sweep.interpolation_use_prop_const = False sweep.max_solutions = 200 sweep.min_freq_s_mat_only_solve = "2MHz" sweep.min_solved_freq = "1Hz" @@ -2332,9 +2332,9 @@ def test_131_siwave_ac_simulation_setup(self): assert sweep.enforce_dc_and_causality assert not sweep.enforce_passivity assert sweep.freq_sweep_type == "kDiscreteSweep" - assert not sweep.interp_use_full_basis - assert not sweep.interp_use_port_impedance - assert not sweep.interp_use_prop_const + assert not sweep.interpolation_use_full_basis + assert not sweep.interpolation_use_port_impedance + assert not sweep.interpolation_use_prop_const assert sweep.max_solutions == 200 assert sweep.min_freq_s_mat_only_solve == "2MHz" assert sweep.min_solved_freq == "1Hz" diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 8ae538d7eec..6e5f33dac95 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -384,7 +384,7 @@ def interpolation_use_full_basis(self): return self._edb_sweep_data.InterpUseFullBasis @property - def interp_use_port_impedance(self): + def interpolation_use_port_impedance(self): """Whether to turn on the port impedance interpolation. Returns @@ -395,7 +395,7 @@ def interp_use_port_impedance(self): return self._edb_sweep_data.InterpUsePortImpedance @property - def interp_use_prop_const(self): + def interpolation_use_prop_const(self): """Flag indicating if propagation constants are used. Returns @@ -406,7 +406,7 @@ def interp_use_prop_const(self): return self._edb_sweep_data.InterpUsePropConst @property - def interp_use_s_matrix(self): + def interpolation_use_s_matrix(self): """Flag indicating if the S matrix is used. Returns @@ -545,23 +545,23 @@ def freq_sweep_type(self, value): self._edb_sweep_data.FreqSweepType = edb_freq_sweep_type.kNumSweepTypes self._edb_sweep_data.FreqSweepType.ToString() - @interp_use_full_basis.setter - def interp_use_full_basis(self, value): + @interpolation_use_full_basis.setter + def interpolation_use_full_basis(self, value): self._edb_sweep_data.InterpUseFullBasis = value self._update_sweep() - @interp_use_port_impedance.setter - def interp_use_port_impedance(self, value): + @interpolation_use_port_impedance.setter + def interpolation_use_port_impedance(self, value): self._edb_sweep_data.InterpUsePortImpedance = value self._update_sweep() - @interp_use_prop_const.setter - def interp_use_prop_const(self, value): + @interpolation_use_prop_const.setter + def interpolation_use_prop_const(self, value): self._edb_sweep_data.InterpUsePropConst = value self._update_sweep() - @interp_use_s_matrix.setter - def interp_use_s_matrix(self, value): + @interpolation_use_s_matrix.setter + def interpolation_use_s_matrix(self, value): self._edb_sweep_data.InterpUseSMatrix = value self._update_sweep() From 76614e9a8413253efb4317bebe40ce7f3f0cc76f Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Tue, 7 Nov 2023 17:33:12 +0100 Subject: [PATCH 59/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 6e5f33dac95..1fe695f616f 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -359,7 +359,7 @@ def enforce_passivity(self): @property def freq_sweep_type(self): - """Sweep type. Options are: + """Sweep type. Options are. - ``"kInterpolatingSweep"`` - ``"kDiscreteSweep"`` From bc4bbd7f31277377cbe3bc08b6037d021005f6ce Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 8 Nov 2023 09:03:27 +0100 Subject: [PATCH 60/61] fix --- pyaedt/edb_core/edb_data/simulation_setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyaedt/edb_core/edb_data/simulation_setup.py b/pyaedt/edb_core/edb_data/simulation_setup.py index 1fe695f616f..adfe33d7562 100644 --- a/pyaedt/edb_core/edb_data/simulation_setup.py +++ b/pyaedt/edb_core/edb_data/simulation_setup.py @@ -214,6 +214,8 @@ def add_frequency_sweep(self, name=None, frequency_sweep=None): if not frequency_sweep: frequency_sweep = [["linear scale", "0.1GHz", "10GHz", "0.1GHz"]] + elif not isinstance(frequency_sweep[0], list): + frequency_sweep = [frequency_sweep] if not name: name = generate_unique_name("sweep") From bd8e2c734374bf4e058c5cc3f1b877dac1f26d53 Mon Sep 17 00:00:00 2001 From: svandenb-dev <74993647+svandenb-dev@users.noreply.github.com> Date: Wed, 8 Nov 2023 09:18:32 +0100 Subject: [PATCH 61/61] Update pyaedt/edb.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- pyaedt/edb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/edb.py b/pyaedt/edb.py index aafe5615881..8e8f33f380b 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -3365,7 +3365,7 @@ def siwave_ac_setups(self): return {name: i for name, i in self.setups.items() if isinstance(i, SiwaveSYZSimulationSetup)} def create_hfss_setup(self, name=None): - """Create a setup from a template. + """Create an HFSS simulation setup from a template. Parameters ----------