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:

79992ba2c3084fe49dfd74986f395447

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\tmprcr8q4x4.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:55: 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:301: 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:09:45.597869
INFO:Edb:Star initializing Edb 04:09:45.597869
PyEDB INFO: Edb version 2025.2
INFO:Edb:Edb version 2025.2
PyEDB INFO: Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
INFO:Edb:Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
PyEDB INFO: legacy v0.61.0
INFO:Edb:legacy v0.61.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)]
INFO:Edb: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
INFO:Edb:Database ANSYS-HSD_V1.aedb Opened in 2025.2
PyEDB INFO: Cell main Opened
INFO:Edb:Cell main Opened
PyEDB INFO: Builder was initialized.
INFO:Edb:Builder was initialized.
PyEDB INFO: open_edb completed in 9.0626 seconds.
INFO:Edb:open_edb completed in 9.0626 seconds.
PyEDB INFO: EDB initialization completed in 9.1579 seconds.
INFO:Edb:EDB initialization completed in 9.1579 seconds.
AEDB file is located in C:\Users\ansys\AppData\Local\Temp\tmprcr8q4x4.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.
INFO:Edb:Building simulation project.
PyEDB INFO: Cutting out using method: 1
INFO:Edb:Cutting out using method: 1
PyEDB INFO: Cutting out using method: 1
INFO:Edb:Cutting out using method: 1
PyEDB INFO: -----------------------------------------
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:55: UserWarning: Argument `signal_list` is deprecated for method `cutout`; use `signal_nets` instead.
  warnings.warn(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:55: UserWarning: Argument `reference_list` is deprecated for method `cutout`; use `reference_nets` instead.
  warnings.warn(
INFO:Edb:-----------------------------------------
PyEDB INFO: Trying cutout with (0.001)*(1000.0)mm expansion size
INFO:Edb:Trying cutout with (0.001)*(1000.0)mm expansion size
PyEDB INFO: -----------------------------------------
INFO:Edb:-----------------------------------------
PyEDB INFO: Cutout Multithread started.
INFO:Edb:Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 1sec
INFO:Edb:Net clean up Elapsed time: 0m 1sec
PyEDB INFO: Correctly computed Extension at first iteration.
INFO:Edb:Correctly computed Extension at first iteration.
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
INFO:Edb:Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 2022 Padstack Instances deleted. Elapsed time: 0m 1sec
INFO:Edb:2022 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 446 Primitives deleted. Elapsed time: 0m 3sec
INFO:Edb:446 Primitives deleted. Elapsed time: 0m 3sec
PyEDB INFO: 1010 components deleted
INFO:Edb:1010 components deleted
PyEDB INFO: Deleted 472 components
INFO:Edb:Deleted 472 components
PyEDB INFO: Single Pins components deleted Elapsed time: 0m 0sec
INFO:Edb:Single Pins components deleted Elapsed time: 0m 0sec
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
INFO:Edb:Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: EDB file save completed in 0.0592 seconds.
INFO:Edb:EDB file save completed in 0.0592 seconds.
PyEDB INFO: Cutout completed in 1 iterations with expansion size of (0.001)*(1000.0)mm Elapsed time: 0m 5sec
INFO:Edb:Cutout completed in 1 iterations with expansion size of (0.001)*(1000.0)mm Elapsed time: 0m 5sec
PyEDB INFO: Cutout processed.
INFO:Edb:Cutout processed.
PyEDB INFO: Deleting existing ports.
INFO:Edb:Deleting existing ports.
PyEDB INFO: Creating HFSS ports for signal nets.
INFO:Edb:Creating HFSS ports for signal nets.
PyEDB INFO: Number of ports: 8
INFO:Edb:Number of ports: 8
PyEDB INFO: Configure HFSS extents.
INFO:Edb:Configure HFSS extents.
PyEDB INFO: Adding frequency sweep
INFO:Edb:Adding frequency sweep
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Padstack definition with zero plating ratio, defaulting to 20%
INFO:Edb:Padstack definition with zero plating ratio, defaulting to 20%
PyEDB INFO: Save Edb file completed in 0.0476 seconds.
INFO:Edb:Save Edb file completed in 0.0476 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.0471 seconds.
INFO:Edb:Save Edb file completed in 0.0471 seconds.
PyEDB INFO: Close Edb file completed in 0.0788 seconds.
INFO:Edb:Close Edb file completed in 0.0788 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.
WARNING:Global:Argument `projectname` is deprecated for method `__init__`; use `project` instead.
PyAEDT WARNING: Argument `specified_version` is deprecated for method `__init__`; use `version` instead.
WARNING:Global: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.
WARNING:Global: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)].
INFO:Global: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.22.dev0.
INFO:Global:PyAEDT version 0.22.dev0.
PyAEDT INFO: Initializing new Desktop session.
INFO:Global:Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
INFO:Global:Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_04f8675c-1859-4880-9721-f2b1dddb8024.log is enabled.
INFO:Global:Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_04f8675c-1859-4880-9721-f2b1dddb8024.log is enabled.
PyAEDT INFO: Log on AEDT is disabled.
INFO:Global:Log on AEDT is disabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
INFO:Global:Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
INFO:Global:Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 57744.
INFO:Global:New AEDT session is starting on gRPC port 57744.
PyAEDT INFO: Electronics Desktop started on gRPC port: 57744 after 10.628596544265747 seconds.
INFO:Global:Electronics Desktop started on gRPC port: 57744 after 10.628596544265747 seconds.
PyAEDT INFO: AEDT installation Path C:\Program Files\ANSYS Inc\v252\AnsysEM
INFO:Global:AEDT installation Path C:\Program Files\ANSYS Inc\v252\AnsysEM
PyAEDT INFO: Ansoft.ElectronicsDesktop.2025.2 version started with process ID 5576.
INFO:Global:Ansoft.ElectronicsDesktop.2025.2 version started with process ID 5576.
PyAEDT INFO: EDB folder C:\Users\ansys\AppData\Local\Temp\tmprcr8q4x4.ansys\edb/ANSYS-HSD_V1.aedb has been imported to project ANSYS-HSD_V1
INFO:Global:EDB folder C:\Users\ansys\AppData\Local\Temp\tmprcr8q4x4.ansys\edb/ANSYS-HSD_V1.aedb has been imported to project ANSYS-HSD_V1
PyAEDT INFO: Active Design set to 0;main
INFO:Global:Active Design set to 0;main
PyAEDT INFO: Active Design set to 0;main
INFO:Global:Active Design set to 0;main
PyAEDT INFO: Aedt Objects correctly read
INFO:Global: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###
INFO:Global:#### Design Validation Checks###
PyAEDT INFO: **** Validation Completed Correctly
INFO:Global:**** Validation Completed Correctly
PyAEDT INFO: Ports Requested: None
INFO:Global:Ports Requested: None
PyAEDT INFO: Ports Defined: 8
INFO:Global:Ports Defined: 8
PyAEDT INFO: Excitation name: U1.AN26.PCIe_Gen4_RX0_N
INFO:Global:Excitation name: U1.AN26.PCIe_Gen4_RX0_N
PyAEDT INFO: Excitation name: U1.AP25.PCIe_Gen4_RX1_N
INFO:Global:Excitation name: U1.AP25.PCIe_Gen4_RX1_N
PyAEDT INFO: Excitation name: U1.AP26.PCIe_Gen4_RX0_P
INFO:Global:Excitation name: U1.AP26.PCIe_Gen4_RX0_P
PyAEDT INFO: Excitation name: U1.AR25.PCIe_Gen4_RX1_P
INFO:Global:Excitation name: U1.AR25.PCIe_Gen4_RX1_P
PyAEDT INFO: Excitation name: X1.A2.PCIe_Gen4_RX0_P
INFO:Global:Excitation name: X1.A2.PCIe_Gen4_RX0_P
PyAEDT INFO: Excitation name: X1.A3.PCIe_Gen4_RX0_N
INFO:Global:Excitation name: X1.A3.PCIe_Gen4_RX0_N
PyAEDT INFO: Excitation name: X1.A5.PCIe_Gen4_RX1_P
INFO:Global:Excitation name: X1.A5.PCIe_Gen4_RX1_P
PyAEDT INFO: Excitation name: X1.A6.PCIe_Gen4_RX1_N
INFO:Global: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.
INFO:Global:Desktop has been released and closed.

Download this example

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