From 2d57da695612320eff81832539a4595b2b3b4679 Mon Sep 17 00:00:00 2001 From: chenchienjacklin <104948990+chenchienjacklin@users.noreply.github.com> Date: Tue, 6 May 2025 11:12:15 -0700 Subject: [PATCH] Publish pyedb-core v0.1.10 (#544) --- doc/source/api/simulation_setup.rst | 2 + pyproject.toml | 2 +- .../core/simulation_setup/simulation_setup.py | 118 ++++++++++++------ .../integration_tests/test_spiral_inductor.py | 8 +- 4 files changed, 86 insertions(+), 44 deletions(-) diff --git a/doc/source/api/simulation_setup.rst b/doc/source/api/simulation_setup.rst index a34fa93cd8..ad105a1f39 100644 --- a/doc/source/api/simulation_setup.rst +++ b/doc/source/api/simulation_setup.rst @@ -36,6 +36,7 @@ Classes simulation_setup.FreqSweepType simulation_setup.HFSSRegionComputeResource simulation_setup.InterpolatingSweepData + simulation_setup.FrequencyData raptor_x_simulation_settings.RaptorXSimulationSettings raptor_x_simulation_settings.RaptorXGeneralSettings raptor_x_simulation_settings.RaptorXAdvancedSettings @@ -57,6 +58,7 @@ Enums :toctree: _autosummary simulation_setup.SimulationSetupType + simulation_setup.Distribution hfss_simulation_settings.AdaptType hfss_simulation_settings.BasisFunctionOrder hfss_simulation_settings.SolverType diff --git a/pyproject.toml b/pyproject.toml index f9cd16bd8a..0c99a27d82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi" [project] # Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections name = "ansys-edb-core" -version = "0.1.9" +version = "0.1.10" description = "A python wrapper for Ansys Edb service" readme = "README.rst" requires-python = ">=3.8" diff --git a/src/ansys/edb/core/simulation_setup/simulation_setup.py b/src/ansys/edb/core/simulation_setup/simulation_setup.py index 9a2221ff88..5ac8bbca9f 100644 --- a/src/ansys/edb/core/simulation_setup/simulation_setup.py +++ b/src/ansys/edb/core/simulation_setup/simulation_setup.py @@ -1,6 +1,7 @@ """Simulation Setup.""" from enum import Enum +from typing import List, Union from ansys.api.edb.v1 import edb_defs_pb2 from ansys.api.edb.v1.simulation_setup_pb2 import ( @@ -36,6 +37,16 @@ class FreqSweepType(Enum): BROADBAND_SWEEP = edb_defs_pb2.BROADBAND_SWEEP +class Distribution(Enum): + """Enum representing frequency distribution types.""" + + LIN = "LIN" + LINC = "LINC" + ESTP = "ESTP" + DEC = "DEC" + OCT = "OCT" + + class HFSSRegionComputeResource: """Class representing HFSS region computation resources. @@ -112,21 +123,64 @@ def __init__(self): self.min_solutions = 0 -class SweepData: - r"""Class representing a sweep data setting. +class FrequencyData: + r"""Class representing a frequency setting. Attributes ---------- - name : str - Name of this sweep. - distribution : str + distribution : .Distribution Sweep distribution type (see table below). start_f : str Start frequency is number with optional frequency units. end_f : str End frequency is number with optional frequency units. step : str - Step is either frequency with optional frequency units or an integer when a count is needed. + Step is either frequency with optional frequency units or an integer + + Notes + ----- + Here are the choices for the distribution parameter: + + .. list-table:: Values for distribution parameter + :widths: 20 45 25 + :header-rows: 1 + + * - Distribution + - Description + - Example + * - LIN + - linear (start, stop, step) + - LIN 2GHz 4GHz 100MHz or LIN 1dBm 10dBm 1dB + * - LINC + - linear (start, stop, count) + - LINC 2GHz 4GHz 11 + * - ESTP + - Exponential step (start, stop, count) + - ESTP 2MHz 10MHz 3 + * - DEC + - decade (start, stop, number of decades) + - DEC 10KHz 10GHz 6 + * - OCT + - octave (start, stop, number of octaves) + - OCT 10MHz 160MHz 5 + + """ + + def __init__(self, distribution: Distribution, start_f: str, end_f: str, step: str): + """Initialize a frequency setting.""" + self.distribution = distribution + self.start_f = start_f + self.end_f = end_f + self.step = step + + +class SweepData: + r"""Class representing a sweep data setting. + + Attributes + ---------- + name : str + Name of this sweep. enabled : bool True if this is enabled. type : FreqSweepType @@ -171,43 +225,14 @@ class SweepData: Stop meshing frequency. interpolation_data : InterpolatingSweepData Data for interpolating frequency sweeps. - - Notes - ----- - Here are the choices for the distribution parameter: - - .. list-table:: Values for distribution parameter - :widths: 20 45 25 - :header-rows: 1 - - * - Distribution - - Description - - Example - * - LIN - - linear (start, stop, step) - - LIN 2GHz 4GHz 100MHz or LIN 1dBm 10dBm 1dB - * - LINC - - linear (start, stop, count) - - LINC 2GHz 4GHz 11 - * - ESTP - - Exponential step (start, stop, count) - - ESTP 2MHz 10MHz 3 - * - DEC - - decade (start, stop, number of decades) - - DEC 10KHz 10GHz 6 - * - OCT - - octave (start, stop, number of octaves) - - OCT 10MHz 160MHz 5 + frequency_data : .FrequencyData or list of .FrequencyData + List of frequency data. """ - def __init__(self, name, distribution, start_f, end_f, step): + def __init__(self, name: str, frequency_data: Union[FrequencyData, List[FrequencyData]]): """Initialize a sweep data setting.""" self.name = name - self.distribution = distribution - self.start_f = start_f - self.end_f = end_f - self.step = step self.enabled = True self.type = FreqSweepType.INTERPOLATING_SWEEP self.use_q3d_for_dc = False @@ -230,11 +255,24 @@ def __init__(self, name, distribution, start_f, end_f, step): self.mesh_freq_range_start = "-1.0" self.mesh_freq_range_stop = "-1.0" self.interpolation_data = InterpolatingSweepData() + self.frequency_data = frequency_data @property def frequency_string(self): - """:obj:`str`: String representing the frequency sweep data.""" - return self.distribution + " " + self.start_f + " " + self.end_f + " " + self.step + """:obj:`str`: String representing the frequency sweep data. + + This property is read-only. + """ + frequencies = [] + if isinstance(self.frequency_data, FrequencyData): + frequencies.append(self.frequency_data) + elif isinstance(self.frequency_data, list): + frequencies = self.frequency_data + + freq_str = "" + for freq in frequencies: + freq_str += f"{freq.distribution.value} {freq.start_f} {freq.end_f} {freq.step}\t\n" + return freq_str def _hfss_region_compute_resource_message(res): diff --git a/tests/e2e/integration_tests/test_spiral_inductor.py b/tests/e2e/integration_tests/test_spiral_inductor.py index ce85e92d6a..cf247f32b2 100644 --- a/tests/e2e/integration_tests/test_spiral_inductor.py +++ b/tests/e2e/integration_tests/test_spiral_inductor.py @@ -26,8 +26,8 @@ from ansys.edb.core.simulation_setup.adaptive_solutions import SingleFrequencyAdaptiveSolution from ansys.edb.core.simulation_setup.hfss_simulation_setup import HfssSimulationSetup from ansys.edb.core.simulation_setup.mesh_operation import SkinDepthMeshOperation -from ansys.edb.core.simulation_setup.simulation_setup import SweepData -from ansys.edb.core.terminal.terminals import PointTerminal +from ansys.edb.core.simulation_setup.simulation_setup import Distribution, FrequencyData, SweepData +from ansys.edb.core.terminal.point_terminal import PointTerminal # Wrapper class over Database # This will ensure clean entry and exit from database @@ -416,7 +416,9 @@ def create_adaptive_settings(self): name="SPIRAL_M9", net_layer_info=[("SPIRAL", "M9", False)], num_layers="3" ) ] - sweep_data = SweepData("Sweep 1", "LIN", "0GHz", "30GHz", "0.01GHz") + sweep_data = SweepData( + "Sweep 1", FrequencyData(Distribution.LIN, "0GHz", "30GHz", "0.01GHz") + ) sweep_data.interpolation_data.fast_sweep = True setup.sweep_data = [sweep_data]