Download this example

Download this example as a Jupyter Notebook or as a Python script.


Import Setup AC#

This example shows how to import SIwave, HFSS setups for AC analysis. In this example, we are going to

  • Download an example board

  • Create a configuration file

    • add setups

  • Import the configuration file

Perform imports and define constants#

Perform required imports.

[1]:
import json
import tempfile
import time
from pathlib import Path

import toml
from ansys.aedt.core.examples.downloads import download_file
from pyedb import Edb

Define constants.

[2]:
AEDT_VERSION = "2026.1"
NG_MODE = False

Download the example PCB data.

[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = download_file(source="pyaedt/edb/ANSYS-HSD_V1.aedb", local_path=temp_folder.name)

Load example layout.#

[4]:
edbapp = Edb(edbpath=file_edb, version=AEDT_VERSION)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\design_types.py:375: UserWarning: You are using PyEDB with grpc, which is currently in beta. Some feature might be missing or not working as expected. Please report any issue you find to the PyEDB team.
  warnings.warn(GRPC_BETA_WARNING, UserWarning)
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.0
PyEDB INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyEDB INFO: Using PyEDB with gRPC as Beta until ANSYS 2027R1 official release.
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.0
PyEDB INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyEDB INFO: Grpc session started
PyEDB INFO: Grpc session started: pid=5496
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Database ANSYS-HSD_V1.aedb Opened in 2026.1
PyEDB INFO: Cell main Opened
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: Builder was initialized.
PyEDB INFO: EDB initialized.

Create an empty dictionary to host all configurations.#

[5]:
cfg = dict()

Create an SIwave SYZ setup#

Keywords

  • name. Name of the setup.

  • type. Type of the analysis setup. Supported types are ‘siwave_ac’, ‘siwave_dc’, ‘hfss’.

  • pi_slider_position. PI slider position. Supported values are from ‘0’, ‘1’, ‘2’. 0:speed, 1:balanced, 2:accuracy.

  • freq_sweep. List of frequency sweeps.

    • name. Name of the sweep.

    • type. Type of the sweep. Supported types are ‘interpolation’, ‘discrete’, ‘broadband’.

    • frequencies. Frequency distribution.

      • distribution. Supported distributions are ‘linear_count’, ‘linear_scale’, ‘log_scale’.

      • start. Start frequency. Example, 1e6, “1MHz”.

      • stop. Stop frequency. Example, 1e9, “1GHz”.

      • increment.

[6]:
siwave_setup = {
    "name": "siwave_1",
    "type": "siwave_ac",
    "pi_slider_position": 1,
    "freq_sweep": [
        {
            "name": "Sweep1",
            "type": "interpolation",
            "frequencies": [{"distribution": "log_scale", "start": 1e6, "stop": 1e9, "increment": 20}],
        }
    ],
}

Create a HFSS setup#

Keywords

  • name. Name of the setup.

  • type. Type of the analysis setup. Supported types are ‘siwave_ac’, ‘siwave_dc’, ‘hfss’.

  • f_adapt. Adaptive frequency.

  • max_num_passes. Maximum number of passes.

  • max_mag_delta_s. Convergence criteria delta S.

  • mesh_operations. Mesh operations.

    • name. Name of the mesh operation.

    • type. Type of the mesh operation. The supported types are ‘base’, ‘length’, ‘skin_depth’.

    • max_length. Maximum length of elements.

    • restrict_length. Whether to restrict length of elements.

    • refine_inside. Whether to turn on refine inside objects.

    • nets_layers_list. {‘layer_name’:[‘net_name_1’, ‘net_name_2’]}

  • freq_sweep. List of frequency sweeps.

    • name. Name of the sweep.

    • type. Type of the sweep. Supported types are ‘interpolation’, ‘discrete’, ‘broadband’.

    • frequencies. Frequency distribution.

      • distribution. Supported distributions are ‘linear_count’, ‘linear_scale’, ‘log_scale’.

      • start. Start frequency. Example, 1e6, “1MHz”.

      • stop. Stop frequency. Example, 1e9, “1GHz”.

      • increment.

[7]:
hfss_setup = {
    "name": "hfss_1",
    "type": "hfss",
    "f_adapt": "5GHz",
    "max_num_passes": 10,
    "max_mag_delta_s": 0.02,
    "mesh_operations": [
        {
            "name": "mop_1",
            "type": "length",
            "max_length": "3mm",
            "restrict_length": True,
            "refine_inside": False,
            "nets_layers_list": {"GND": ["1_Top", "16_Bottom"]},
        }
    ],
    "freq_sweep": [
        {
            "name": "Sweep1",
            "type": "interpolation",
            "frequencies": [{"distribution": "log_scale", "start": 1e6, "stop": 1e9, "increment": 20}],
        }
    ],
}

Add setups in configuration#

[8]:
cfg["setups"] = [siwave_setup, hfss_setup]

Write configuration into as json file#

[9]:
file_json = Path(temp_folder.name) / "edb_configuration.json"
with open(file_json, "w") as f:
    json.dump(cfg, f, indent=4, ensure_ascii=False)

Equivalent toml file looks like below

[10]:
toml_string = toml.dumps(cfg)
print(toml_string)
[[setups]]
name = "siwave_1"
type = "siwave_ac"
pi_slider_position = 1
[[setups.freq_sweep]]
name = "Sweep1"
type = "interpolation"
[[setups.freq_sweep.frequencies]]
distribution = "log_scale"
start = 1000000.0
stop = 1000000000.0
increment = 20



[[setups]]
name = "hfss_1"
type = "hfss"
f_adapt = "5GHz"
max_num_passes = 10
max_mag_delta_s = 0.02
[[setups.mesh_operations]]
name = "mop_1"
type = "length"
max_length = "3mm"
restrict_length = true
refine_inside = false

[setups.mesh_operations.nets_layers_list]
GND = [ "1_Top", "16_Bottom",]
[[setups.freq_sweep]]
name = "Sweep1"
type = "interpolation"
[[setups.freq_sweep.frequencies]]
distribution = "log_scale"
start = 1000000.0
stop = 1000000000.0
increment = 20




Import configuration into example layout#

[11]:
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
PyEDB INFO: Updating nets finished. Time lapse 0:00:00
PyEDB INFO: Updating components finished. Time lapse 0:00:00
PyEDB INFO: Creating pin groups finished. Time lapse 0:00:00
PyEDB INFO: Placing sources finished. Time lapse 0:00:00
PyEDB INFO: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.1753 seconds.
PyEDB INFO: Applying S-parameters finished. Time lapse 0:00:00
PyEDB INFO: Applying package definitions finished. Time lapse 0:00:00
PyEDB INFO: Applying modeler finished. Time lapse 0:00:00
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing terminals completed in 0.0000 seconds.
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations completed in 0.0000 seconds.
PyEDB INFO: SIWave setup siwave_1 created.
PyEDB INFO: Frequency sweep frequency_sweep added to simulation setup siwave_1.
PyEDB INFO: HFSS setup hfss_1 created.
PyEDB INFO: Applying setups completed in 0.1134 seconds.
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\configuration\configuration.py:272: FutureWarning: Call to deprecated function create_siwave_syz_setup. Use simulation_setups.create_siwave_setup() instead.
  edb_setup = self._pedb.create_siwave_syz_setup(name=setup.name)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\configuration\configuration.py:211: FutureWarning: Accessing deprecated property adaptive_settings. use settings.general property instead
  edb_setup.adaptive_settings.adapt_type = FAdaptTypeMapper.get(
[11]:
True

Review#

[12]:
edbapp.setups
[12]:
{'hfss_1': <pyedb.grpc.database.simulation_setup.hfss_simulation_setup.HfssSimulationSetup at 0x2c08311a470>,
 'siwave_1': <pyedb.grpc.database.simulation_setup.siwave_simulation_setup.SiwaveSimulationSetup at 0x2c0804abd30>}

Save and close Edb#

The temporary folder will be deleted once the execution of this script is finished. Replace edbapp.save() with edbapp.save_as(“C:/example.aedb”) to keep the example project.

[13]:
edbapp.save()
edbapp.close()
PyEDB INFO: RPC session released (open databases: 0)
[13]:
True
[14]:
# Wait 3 seconds before cleaning the temporary directory.
time.sleep(3)

Clean up#

All project files are saved in the folder temp_folder.name. If you’ve run this example as a Jupyter notebook, you can retrieve those project files. The following cell removes all temporary files, including the project folder.

[15]:
temp_folder.cleanup()

Download this example

Download this example as a Jupyter Notebook or as a Python script.