Download this example

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


EDB: parameterized design#

This example shows how to

  1. Set up an HFSS project using SimulationConfiguration class.

  2. Create automatically parametrized design.

This image shows the layout created in this example:

2e370f9f7d2e43bdb4fa97de71ec83d5

Perform imports#

Perform required imports.

[1]:
import tempfile

import ansys.aedt.core
import pyedb
from pyedb.misc.downloads import download_file

Create an instance of a pyedb.Edb object.#

[2]:
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
target_aedb = download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name)
print("Project is located in ", target_aedb)

# Select EDB version (change it manually if needed, e.g. "2025.1")
edb_version = "2025.2"
print(f"EDB version: {edb_version}")

edb = pyedb.Edb(edbpath=target_aedb, edbversion=edb_version)
print("AEDB file is located in {}".format(target_aedb))
Project is located in  C:\Users\ansys\AppData\Local\Temp\tmp6t_wy9zd.ansys\edb/ANSYS-HSD_V1.aedb
EDB version: 2025.2
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:33: UserWarning: Argument `edbversion` is deprecated for method `Edb`; use `version` instead.
  warnings.warn(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\design_types.py:327: UserWarning: Your ANSYS AEDT version is eligible to gRPC version.You might consider switching to that version for better user experience.For more information please check this link: https://edb.docs.pyansys.com/version/dev/grpc_api/index.html
  warnings.warn(GRPC_GENERAL_WARNING, UserWarning)
PyEDB INFO: Star initializing Edb 04:00:51.177624
PyEDB INFO: Edb version 2025.2
PyEDB INFO: Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
PyEDB INFO: legacy v0.56.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: Database ANSYS-HSD_V1.aedb Opened in 2025.2
PyEDB INFO: Cell main Opened
PyEDB INFO: Builder was initialized.
PyEDB INFO: open_edb completed in 7.4850 seconds.
PyEDB INFO: EDB initialization completed in 7.5485 seconds.
AEDB file is located in C:\Users\ansys\AppData\Local\Temp\tmp6t_wy9zd.ansys\edb/ANSYS-HSD_V1.aedb

Prepare the layout for the simulation#

The new_simulation_configuration() method creates an instance of the SimulationConfiguration class. This class helps define all preprocessing steps required to set up the PCB for simulation. After the simulation configuration has been defined, they are applied to the EDB using the Edb.build_simulation() method.

[3]:
simulation_configuration = edb.new_simulation_configuration()
simulation_configuration.signal_nets = [
    "PCIe_Gen4_RX0_P",
    "PCIe_Gen4_RX0_N",
    "PCIe_Gen4_RX1_P",
    "PCIe_Gen4_RX1_N",
]
simulation_configuration.power_nets = ["GND"]
simulation_configuration.components = ["X1", "U1"]
simulation_configuration.do_cutout_subdesign = True
simulation_configuration.start_freq = "OGHz"
simulation_configuration.stop_freq = "20GHz"
simulation_configuration.step_freq = "10MHz"

Now apply the simulation setup to the EDB.

[4]:
edb.build_simulation_project(simulation_configuration)
PyEDB INFO: Building simulation project.
PyEDB INFO: Cutting out using method: 1
PyEDB INFO: Cutting out using method: 1
PyEDB INFO: Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 1sec
PyEDB INFO: Correctly computed Extension at first iteration.
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 2022 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 446 Primitives deleted. Elapsed time: 0m 3sec
PyEDB INFO: 1010 components deleted
PyEDB INFO: Deleted 472 components
PyEDB INFO: Single Pins components deleted Elapsed time: 0m 0sec
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: Cutout processed.
PyEDB INFO: Deleting existing ports.
PyEDB INFO: Creating HFSS ports for signal nets.
PyEDB INFO: Number of ports: 8
PyEDB INFO: Configure HFSS extents.
PyEDB INFO: Adding frequency sweep
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Save Edb file completed in 0.0334 seconds.
[4]:
True

Parameterize#

The layout can automatically be set up to enable parametric studies. For example, the impact of antipad diameter or trace width on signal integrity performance may be invested parametrically.

[5]:
edb.auto_parametrize_design(layers=True, materials=True, via_holes=True, pads=True, antipads=True, traces=True)
edb.save_edb()
edb.close_edb()
PyEDB INFO: Save Edb file completed in 0.0477 seconds.
PyEDB INFO: Close Edb file completed in 0.0897 seconds.
[5]:
True

Open project in AEDT#

All manipulations thus far have been executed using the EDB API, which provides fast, streamlined processing of layout data in non-graphical mode. The layout and simulation setup can be visualized by opening it using the 3D Layout editor in AEDT.

Note that there may be some delay while AEDT is being launched.

[6]:
hfss = ansys.aedt.core.Hfss3dLayout(
    projectname=target_aedb,
    specified_version=edb_version,
    non_graphical=False,
    new_desktop_session=True,
)
PyAEDT WARNING: Argument `projectname` is deprecated for method `__init__`; use `project` instead.
PyAEDT WARNING: Argument `specified_version` is deprecated for method `__init__`; use `version` instead.
PyAEDT WARNING: Argument `new_desktop_session` is deprecated for method `__init__`; use `new_desktop` instead.
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.20.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_67deb257-1fad-4a9e-9e22-3bb4e88763a5.log is enabled.
PyAEDT INFO: Log on AEDT is disabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 57199.
PyAEDT INFO: Electronics Desktop started on gRPC port: 57199 after 11.822115182876587 seconds.
PyAEDT INFO: AEDT installation Path C:\Program Files\ANSYS Inc\v252\AnsysEM
PyAEDT INFO: Ansoft.ElectronicsDesktop.2025.2 version started with process ID 10344.
PyAEDT INFO: EDB folder C:\Users\ansys\AppData\Local\Temp\tmp6t_wy9zd.ansys\edb/ANSYS-HSD_V1.aedb has been imported to project ANSYS-HSD_V1
PyAEDT INFO: Active Design set to 0;main
PyAEDT INFO: Active Design set to 0;main
PyAEDT INFO: Aedt Objects correctly read

The following cell can be used to ensure that the design is valid for simulation.

[7]:
validation_info = hfss.validate_full_design()
is_ready_to_simulate = True
PyAEDT INFO: #### Design Validation Checks###
PyAEDT ERROR: **** ERRORS Present - please check and confirm
PyAEDT INFO: Ports Requested: None
PyAEDT INFO: Ports Defined: 8
PyAEDT INFO: Excitation name: U1.AN26.PCIe_Gen4_RX0_N
PyAEDT INFO: Excitation name: U1.AP25.PCIe_Gen4_RX1_N
PyAEDT INFO: Excitation name: U1.AP26.PCIe_Gen4_RX0_P
PyAEDT INFO: Excitation name: U1.AR25.PCIe_Gen4_RX1_P
PyAEDT INFO: Excitation name: X1.A2.PCIe_Gen4_RX0_P
PyAEDT INFO: Excitation name: X1.A3.PCIe_Gen4_RX0_N
PyAEDT INFO: Excitation name: X1.A5.PCIe_Gen4_RX1_P
PyAEDT INFO: Excitation name: X1.A6.PCIe_Gen4_RX1_N
[8]:
for s in validation_info[0]:
    if "error" in s:
        print(s)
        is_ready_to_simulate = False

if is_ready_to_simulate:
    print("The model is ready for simulation.")
else:
    print("There are errors in the model that must be fixed.")
The model is ready for simulation.

Release the application from the Python kernel#

It is important to release the application from the Python kernel after execution of the script. The default behavior of the release_desktop() method closes all open projects and closes the application.

If you want to continue working on the project in graphical mode after script execution, call the following method with both arguments set to False.

[9]:
hfss.release_desktop(close_projects=True, close_desktop=True)
temp_dir.cleanup()  # Remove the temporary folder and files. All data will be removd!
PyAEDT INFO: Desktop has been released and closed.

Download this example

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