Download this example

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


Create a simple transmission line#

Perform imports and define constants#

Perform required imports.

[1]:
import json
import os
import tempfile
import time

from pyedb import Edb

Define constants.

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

Create an empty design#

[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
edb_path = os.path.join(temp_folder.name, "simple_transmission_line.aedb")
edbapp = Edb(edbpath=edb_path, 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=5364
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: EDB C:\Users\ansys\AppData\Local\Temp\tmpk07xha_2.ansys\simple_transmission_line.aedb created correctly.
PyEDB INFO: EDB initialized.
[4]:
# Create a default 2-layer stackup
edbapp.stackup.create_symmetric_stackup(layer_count=2, soldermask=False)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:135: FutureWarning: Argument `fillMaterial` is deprecated for method `add_layer`; use `filling_material` instead.
  warnings.warn(
[4]:
True

Create config file#

[5]:
cfg = {"stackup": {}, "modeler": {}, "variables": {}}

cfg["variables"] = [{"name": "trace_width", "value": "0.2mm"}]

cfg["stackup"]["materials"] = [
    {"name": "copper", "permittivity": 1, "conductivity": 58000000.0},
    {"name": "fr4", "permittivity": 3.77, "dielectric_loss_tangent": 0.005},
    {"name": "solder_resist", "permittivity": 3.0, "dielectric_loss_tangent": 0.035},
]

cfg["stackup"]["layers"] = [
    {"name": "TOP", "type": "signal", "material": "copper", "fill_material": "solder_resist", "thickness": "0.035mm"},
    {"name": "DE", "type": "dielectric", "material": "fr4", "fill_material": "", "thickness": "0.5mm"},
    {
        "name": "BOTTOM",
        "type": "signal",
        "material": "copper",
        "fill_material": "solder_resist",
        "thickness": "0.035mm",
    },
]

cfg["modeler"]["traces"] = [
    {
        "name": "trace_1",
        "layer": "TOP",
        "width": "trace_width",
        "path": [[0, 0], [0, "3mm"]],
        "net_name": "SIG",
        "start_cap_style": "flat",
        "end_cap_style": "flat",
    },
    {
        "name": "trace_1_void",
        "layer": "TOP",
        "width": "trace_width+0.3mm",
        "path": [[0, 0], [0, "3mm"]],
        "net_name": "GND",
    },
]
cfg["modeler"]["planes"] = [
    {
        "type": "rectangle",
        "name": "GND_TOP",
        "layer": "TOP",
        "net_name": "GND",
        "lower_left_point": ["-2mm", 0],
        "upper_right_point": ["2mm", "3mm"],
        "voids": ["trace_1_void"],
    },
    {
        "type": "rectangle",
        "name": "GND_BOTTOM",
        "layer": "BOTTOM",
        "net_name": "GND",
        "lower_left_point": ["-2mm", 0],
        "upper_right_point": ["2mm", "3mm"],
    },
]

cfg["modeler"]["padstack_definitions"] = [
    {
        "name": "via",
        "hole_plating_thickness": "0.025mm",
        "material": "copper",
        "pad_parameters": {
            "regular_pad": [
                {
                    "layer_name": "TOP",
                    "shape": "circle",
                    "diameter": "0.5mm",
                },
                {
                    "layer_name": "BOTTOM",
                    "shape": "circle",
                    "diameter": "0.5mm",
                },
            ],
        },
        "hole_range": "through",
        "hole_parameters": {
            "shape": "circle",
            "diameter": "0.25mm",
        },
    }
]

cfg["modeler"]["padstack_instances"] = [
    {
        "name": "gvia_l_1",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["-1mm", "0.5mm"],
        "net_name": "GND",
    },
    {
        "name": "gvia_l_2",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["-1mm", "1.5mm"],
        "net_name": "GND",
    },
    {
        "name": "gvia_l_3",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["-1mm", "2.5mm"],
        "net_name": "GND",
    },
    {
        "name": "gvia_r_1",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["1mm", "0.5mm"],
        "net_name": "GND",
    },
    {
        "name": "gvia_r_2",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["1mm", "1.5mm"],
        "net_name": "GND",
    },
    {
        "name": "gvia_r_3",
        "definition": "via",
        "layer_range": ["TOP", "BOTTOM"],
        "position": ["1mm", "2.5mm"],
        "net_name": "GND",
    },
]

cfg["ports"] = [
    {
        "name": "wport_1",
        "type": "wave_port",
        "primitive_name": "trace_1",
        "point_on_edge": [0, 0],
        "horizontal_extent_factor": 10,
        "vertical_extent_factor": 2,
        "pec_launch_width": "0,2mm",
    },
    {
        "name": "wport_2",
        "type": "wave_port",
        "primitive_name": "trace_1",
        "point_on_edge": [0, "3mm"],
        "horizontal_extent_factor": 10,
        "vertical_extent_factor": 2,
        "pec_launch_width": "0,2mm",
    },
]

Create the config file.

[6]:
file_json = os.path.join(temp_folder.name, "cfg.json")
with open(file_json, "w") as f:
    json.dump(cfg, f, indent=4, ensure_ascii=False)

Apply configuration to the example layout

[7]:
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.048004
PyEDB INFO: Applying padstack definitions and instances completed in 0.0000 seconds.
PyEDB INFO: Applying S-parameters finished. Time lapse 0:00:00
PyEDB INFO: Applying package definitions finished. Time lapse 0:00:00.011611
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\configuration\configuration.py:599: FutureWarning: Call to deprecated function delete_material. use delete method instead
  self._pedb.materials.delete_material(materials_in_db[mat_in_cfg.name.lower()])
PyEDB INFO: Padstack via successfully created.
PyEDB INFO: Applying modeler finished. Time lapse 0:00:00.639442
PyEDB INFO: Placing ports finished. Time lapse 0:00:00.079673
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: Applying setups completed in 0.0000 seconds.
[7]:
True

Save and close EDB.

[8]:
edbapp.save()
edbapp.close()
PyEDB INFO: RPC session released (open databases: 0)
[8]:
True

Uncomment to load edb into HFSS 3D Layout.#

h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)

[9]:
# 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.

[10]:
temp_folder.cleanup()

Download this example

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