pyedb 0.15.dev0__py3-none-any.whl → 0.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyedb might be problematic. Click here for more details.

@@ -0,0 +1,386 @@
1
+ # Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ import warnings
24
+
25
+ from pyedb.dotnet.edb_core.sim_setup_data.data.mesh_operation import (
26
+ LengthMeshOperation,
27
+ SkinDepthMeshOperation,
28
+ )
29
+ from pyedb.dotnet.edb_core.sim_setup_data.data.settings import (
30
+ AdaptiveSettings,
31
+ AdvancedMeshSettings,
32
+ CurveApproxSettings,
33
+ DcrSettings,
34
+ DefeatureSettings,
35
+ HfssPortSettings,
36
+ HfssSolverSettings,
37
+ ViaSettings,
38
+ )
39
+ from pyedb.dotnet.edb_core.sim_setup_data.data.sim_setup_info import SimSetupInfo
40
+ from pyedb.dotnet.edb_core.utilities.simulation_setup import SimulationSetup
41
+ from pyedb.generic.general_methods import generate_unique_name
42
+
43
+
44
+ class HfssSimulationSetup(SimulationSetup):
45
+ """Manages EDB methods for HFSS simulation setup."""
46
+
47
+ def __init__(self, pedb, edb_object=None, name: str = None):
48
+ super().__init__(pedb, edb_object)
49
+ self._simulation_setup_builder = self._pedb._edb.Utility.HFSSSimulationSetup
50
+ if edb_object is None:
51
+ self._name = name
52
+
53
+ sim_setup_info = SimSetupInfo(self._pedb, sim_setup=self, setup_type="kHFSS", name=name)
54
+ self._edb_object = self._simulation_setup_builder(sim_setup_info._edb_object)
55
+ self._update_setup()
56
+
57
+ @property
58
+ def get_sim_setup_info(self):
59
+ """Get simulation setup information."""
60
+ warnings.warn("Use new property :func:`sim_setup_info` instead.", DeprecationWarning)
61
+ return self.sim_setup_info._edb_object
62
+
63
+ @property
64
+ def solver_slider_type(self):
65
+ """Solver slider type.
66
+ Options are:
67
+ 1 - ``kFast``.
68
+ 2 - ``kMedium``.
69
+ 3 - ``kAccurate``.
70
+ 4 - ``kNumSliderTypes``.
71
+
72
+ Returns
73
+ -------
74
+ str
75
+ """
76
+ return self.get_sim_setup_info.SimulationSettings.TSolveSliderType.ToString()
77
+
78
+ @solver_slider_type.setter
79
+ def solver_slider_type(self, value):
80
+ """Set solver slider type."""
81
+ solver_types = {
82
+ "kFast": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaWirebond,
83
+ "kMedium": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaRibbon,
84
+ "kAccurate": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaMesh,
85
+ "kNumSliderTypes": self.get_sim_setup_info.SimulationSettings.TSolveSliderType.k25DViaField,
86
+ }
87
+ self.get_sim_setup_info.SimulationSettings.TSolveSliderType = solver_types[value]
88
+ self._update_setup()
89
+
90
+ @property
91
+ def is_auto_setup(self):
92
+ """Flag indicating if automatic setup is enabled."""
93
+ return self.get_sim_setup_info.SimulationSettings.IsAutoSetup
94
+
95
+ @is_auto_setup.setter
96
+ def is_auto_setup(self, value):
97
+ self.get_sim_setup_info.SimulationSettings.IsAutoSetup = value
98
+ self._update_setup()
99
+
100
+ @property
101
+ def hfss_solver_settings(self):
102
+ """Manages EDB methods for HFSS solver settings.
103
+
104
+ Returns
105
+ -------
106
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.HfssSolverSettings`
107
+
108
+ """
109
+ return HfssSolverSettings(self)
110
+
111
+ @property
112
+ def adaptive_settings(self):
113
+ """Adaptive Settings Class.
114
+
115
+ Returns
116
+ -------
117
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.AdaptiveSettings`
118
+
119
+ """
120
+ return AdaptiveSettings(self)
121
+
122
+ @property
123
+ def defeature_settings(self):
124
+ """Defeature settings Class.
125
+
126
+ Returns
127
+ -------
128
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.DefeatureSettings`
129
+
130
+ """
131
+ return DefeatureSettings(self)
132
+
133
+ @property
134
+ def via_settings(self):
135
+ """Via settings Class.
136
+
137
+ Returns
138
+ -------
139
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.ViaSettings`
140
+
141
+ """
142
+ return ViaSettings(self)
143
+
144
+ @property
145
+ def advanced_mesh_settings(self):
146
+ """Advanced mesh settings Class.
147
+
148
+ Returns
149
+ -------
150
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.AdvancedMeshSettings`
151
+
152
+ """
153
+ return AdvancedMeshSettings(self)
154
+
155
+ @property
156
+ def curve_approx_settings(self):
157
+ """Curve approximation settings Class.
158
+
159
+ Returns
160
+ -------
161
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.CurveApproxSettings`
162
+
163
+ """
164
+ return CurveApproxSettings(self)
165
+
166
+ @property
167
+ def dcr_settings(self):
168
+ """Dcr settings Class.
169
+
170
+ Returns
171
+ -------
172
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.DcrSettings`
173
+
174
+ """
175
+ return DcrSettings(self)
176
+
177
+ @property
178
+ def hfss_port_settings(self):
179
+ """HFSS port settings Class.
180
+
181
+ Returns
182
+ -------
183
+ :class:`pyedb.dotnet.edb_core.edb_data.hfss_simulation_setup_data.HfssPortSettings`
184
+
185
+ """
186
+ return HfssPortSettings(self)
187
+
188
+ @property
189
+ def mesh_operations(self):
190
+ """Mesh operations settings Class.
191
+
192
+ Returns
193
+ -------
194
+ List of :class:`dotnet.edb_core.edb_data.hfss_simulation_setup_data.MeshOperation`
195
+
196
+ """
197
+ settings = self.sim_setup_info.simulation_settings.MeshOperations
198
+ mesh_operations = {}
199
+ for i in list(settings):
200
+ if i.MeshOpType == i.TMeshOpType.kMeshSetupLength:
201
+ mesh_operations[i.Name] = LengthMeshOperation(self, i)
202
+ elif i.MeshOpType == i.TMeshOpType.kMeshSetupSkinDepth:
203
+ mesh_operations[i.Name] = SkinDepthMeshOperation(self, i)
204
+ elif i.MeshOpType == i.TMeshOpType.kMeshSetupBase:
205
+ mesh_operations[i.Name] = SkinDepthMeshOperation(self, i)
206
+
207
+ return mesh_operations
208
+
209
+ def add_length_mesh_operation(
210
+ self,
211
+ net_layer_list,
212
+ name=None,
213
+ max_elements=1000,
214
+ max_length="1mm",
215
+ restrict_elements=True,
216
+ restrict_length=True,
217
+ refine_inside=False,
218
+ mesh_region=None,
219
+ ):
220
+ """Add a mesh operation to the setup.
221
+
222
+ Parameters
223
+ ----------
224
+ net_layer_list : dict
225
+ Dictionary containing nets and layers on which enable Mesh operation. Example ``{"A0_N": ["TOP", "PWR"]}``.
226
+ name : str, optional
227
+ Mesh operation name.
228
+ max_elements : int, optional
229
+ Maximum number of elements. Default is ``1000``.
230
+ max_length : str, optional
231
+ Maximum length of elements. Default is ``1mm``.
232
+ restrict_elements : bool, optional
233
+ Whether to restrict number of elements. Default is ``True``.
234
+ restrict_length : bool, optional
235
+ Whether to restrict length of elements. Default is ``True``.
236
+ mesh_region : str, optional
237
+ Mesh region name.
238
+ refine_inside : bool, optional
239
+ Whether to refine inside or not. Default is ``False``.
240
+
241
+ Returns
242
+ -------
243
+ :class:`dotnet.edb_core.edb_data.hfss_simulation_setup_data.LengthMeshOperation`
244
+ """
245
+ if not name:
246
+ name = generate_unique_name("skin")
247
+ mop = LengthMeshOperation(self, self._pedb.simsetupdata.LengthMeshOperation())
248
+ mop.mesh_region = mesh_region
249
+ mop.name = name
250
+ mop.nets_layers_list = net_layer_list
251
+ mop.refine_inside = refine_inside
252
+ mop.max_elements = max_elements
253
+ mop.max_length = max_length
254
+ mop.restrict_length = restrict_length
255
+ mop.restrict_max_elements = restrict_elements
256
+ self.sim_setup_info.simulation_settings.MeshOperations.Add(mop._edb_object)
257
+ self._update_setup()
258
+ return mop
259
+
260
+ def add_skin_depth_mesh_operation(
261
+ self,
262
+ net_layer_list,
263
+ name=None,
264
+ max_elements=1000,
265
+ skin_depth="1um",
266
+ restrict_elements=True,
267
+ surface_triangle_length="1mm",
268
+ number_of_layers=2,
269
+ refine_inside=False,
270
+ mesh_region=None,
271
+ ):
272
+ """Add a mesh operation to the setup.
273
+
274
+ Parameters
275
+ ----------
276
+ net_layer_list : dict
277
+ Dictionary containing nets and layers on which enable Mesh operation. Example ``{"A0_N": ["TOP", "PWR"]}``.
278
+ name : str, optional
279
+ Mesh operation name.
280
+ max_elements : int, optional
281
+ Maximum number of elements. Default is ``1000``.
282
+ skin_depth : str, optional
283
+ Skin Depth. Default is ``1um``.
284
+ restrict_elements : bool, optional
285
+ Whether to restrict number of elements. Default is ``True``.
286
+ surface_triangle_length : bool, optional
287
+ Surface Triangle length. Default is ``1mm``.
288
+ number_of_layers : int, str, optional
289
+ Number of layers. Default is ``2``.
290
+ mesh_region : str, optional
291
+ Mesh region name.
292
+ refine_inside : bool, optional
293
+ Whether to refine inside or not. Default is ``False``.
294
+
295
+ Returns
296
+ -------
297
+ :class:`dotnet.edb_core.edb_data.hfss_simulation_setup_data.LengthMeshOperation`
298
+ """
299
+ if not name:
300
+ name = generate_unique_name("length")
301
+ mesh_operation = SkinDepthMeshOperation(self, self._pedb.simsetupdata.SkinDepthMeshOperation())
302
+ mesh_operation.mesh_region = mesh_region
303
+ mesh_operation.name = name
304
+ mesh_operation.nets_layers_list = net_layer_list
305
+ mesh_operation.refine_inside = refine_inside
306
+ mesh_operation.max_elements = max_elements
307
+ mesh_operation.skin_depth = skin_depth
308
+ mesh_operation.number_of_layer_elements = number_of_layers
309
+ mesh_operation.surface_triangle_length = surface_triangle_length
310
+ mesh_operation.restrict_max_elements = restrict_elements
311
+ self.sim_setup_info.simulation_settings.MeshOperations.Add(mesh_operation._edb_object)
312
+ self._update_setup()
313
+ return mesh_operation
314
+
315
+ def set_solution_single_frequency(self, frequency="5GHz", max_num_passes=10, max_delta_s=0.02):
316
+ """Set single-frequency solution.
317
+
318
+ Parameters
319
+ ----------
320
+ frequency : str, float, optional
321
+ Adaptive frequency. The default is ``5GHz``.
322
+ max_num_passes : int, optional
323
+ Maximum number of passes. The default is ``10``.
324
+ max_delta_s : float, optional
325
+ Maximum delta S. The default is ``0.02``.
326
+
327
+ Returns
328
+ -------
329
+ bool
330
+
331
+ """
332
+ self.adaptive_settings.adapt_type = "kSingle"
333
+ self.adaptive_settings.adaptive_settings.AdaptiveFrequencyDataList.Clear()
334
+ return self.adaptive_settings.add_adaptive_frequency_data(frequency, max_num_passes, max_delta_s)
335
+
336
+ def set_solution_multi_frequencies(self, frequencies=("5GHz", "10GHz"), max_num_passes=10, max_delta_s="0.02"):
337
+ """Set multi-frequency solution.
338
+
339
+ Parameters
340
+ ----------
341
+ frequencies : list, tuple, optional
342
+ List or tuple of adaptive frequencies. The default is ``5GHz``.
343
+ max_num_passes : int, optional
344
+ Maximum number of passes. Default is ``10``.
345
+ max_delta_s : float, optional
346
+ Maximum delta S. The default is ``0.02``.
347
+
348
+ Returns
349
+ -------
350
+ bool
351
+
352
+ """
353
+ self.adaptive_settings.adapt_type = "kMultiFrequencies"
354
+ self.adaptive_settings.adaptive_settings.AdaptiveFrequencyDataList.Clear()
355
+ for i in frequencies:
356
+ if not self.adaptive_settings.add_adaptive_frequency_data(i, max_num_passes, max_delta_s):
357
+ return False
358
+ return True
359
+
360
+ def set_solution_broadband(
361
+ self, low_frequency="5GHz", high_frequency="10GHz", max_num_passes=10, max_delta_s="0.02"
362
+ ):
363
+ """Set broadband solution.
364
+
365
+ Parameters
366
+ ----------
367
+ low_frequency : str, float, optional
368
+ Low frequency. The default is ``5GHz``.
369
+ high_frequency : str, float, optional
370
+ High frequency. The default is ``10GHz``.
371
+ max_num_passes : int, optional
372
+ Maximum number of passes. The default is ``10``.
373
+ max_delta_s : float, optional
374
+ Maximum Delta S. Default is ``0.02``.
375
+
376
+ Returns
377
+ -------
378
+ bool
379
+ """
380
+ self.adaptive_settings.adapt_type = "kBroadband"
381
+ self.adaptive_settings.adaptive_settings.AdaptiveFrequencyDataList.Clear()
382
+ if not self.adaptive_settings.add_broadband_adaptive_frequency_data(
383
+ low_frequency, high_frequency, max_num_passes, max_delta_s
384
+ ): # pragma no cover
385
+ return False
386
+ return True