Download this example

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


Import Stackup#

This example shows how to import stackup file.

Perform imports and define constants#

Perform required imports.

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

from IPython.display import display
from ansys.aedt.core.examples.downloads import download_file
import pandas as pd
from pyedb import Edb

Define constants.

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

Download the example PCB data.

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

Load example layout.#

[4]:
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
PyAEDT INFO: Logger is initialized in EDB.
PyAEDT INFO: legacy v0.50.1
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: Database ANSYS-HSD_V1.aedb Opened in 2025.1
PyAEDT INFO: Cell main Opened
PyAEDT INFO: Builder was initialized.
PyAEDT INFO: EDB initialized.

Review original stackup definition#

Get original stackup definition in a dictionary. Alternatively, stackup definition can be exported in a json file by edbapp.configuration.export()

[5]:
data_cfg = edbapp.configuration.get_data_from_db(stackup=True)
PyAEDT INFO: Getting data from layout database.
[6]:
df = pd.DataFrame(data=data_cfg["stackup"]["layers"])
display(df)
name type material fill_material thickness color etching roughness
0 1_Top signal copper Solder Resist 0.035mm [255, 0, 0] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
1 DE1 dielectric Megtron4 0.1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
2 Inner1(GND1) signal copper Megtron4_2 0.017mm [128, 128, 0] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
3 DE2 dielectric Megtron4_2 0.088mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
4 Inner2(PWR1) signal copper Megtron4_2 0.017mm [112, 219, 250] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
5 DE3 dielectric Megtron4 0.1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
6 Inner3(Sig1) signal copper Megtron4_3 0.017mm [255, 0, 255] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
7 Megtron4-1mm dielectric Megtron4_3 1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
8 Inner4(Sig2) signal copper Megtron4_3 0.017mm [128, 0, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
9 DE5 dielectric Megtron4 0.1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
10 Inner5(PWR2) signal copper Megtron4_2 0.017mm [0, 204, 102] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
11 DE6 dielectric Megtron4_2 0.088mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
12 Inner6(GND2) signal copper Megtron4_2 0.017mm [0, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
13 DE7 dielectric Megtron4 0.1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
14 16_Bottom signal copper Solder Resist 0.035mm [0, 0, 255] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
15 Measures measure NaN NaN NaN [63, 63, 63] NaN NaN
16 SIwave Regions siwavehfsssolverregions NaN NaN NaN [127, 127, 127] NaN NaN
17 Top Overlay silkscreen NaN NaN NaN [208, 145, 239] NaN NaN
18 Top Solder soldermask NaN NaN NaN [16, 115, 138] NaN NaN
19 Bottom Solder soldermask NaN NaN NaN [46, 67, 160] NaN NaN
20 Bottom Overlay silkscreen NaN NaN NaN [219, 116, 240] NaN NaN
21 Outline outline NaN NaN NaN [0, 0, 0] NaN NaN
22 Rats airlines NaN NaN NaN [0, 0, 255] NaN NaN
23 Errors errors NaN NaN NaN [255, 0, 0] NaN NaN
24 Symbols symbol NaN NaN NaN [127, 0, 127] NaN NaN
25 Postprocessing postprocessing NaN NaN NaN [40, 152, 137] NaN NaN

Modify stackup#

Modify top layer thickness

[7]:
data_cfg["stackup"]["layers"][0]["thickness"] = 0.00005

Add a solder mask layer

[8]:
data_cfg["stackup"]["layers"].insert(
    0, {"name": "soler_mask", "type": "dielectric", "material": "Megtron4", "fill_material": "", "thickness": 0.00002}
)

Review modified stackup

[9]:
df = pd.DataFrame(data=data_cfg["stackup"]["layers"])
display(df.head(3))
name type material fill_material thickness color etching roughness
0 soler_mask dielectric Megtron4 0.00002 NaN NaN NaN
1 1_Top signal copper Solder Resist 0.00005 [255, 0, 0] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...
2 DE1 dielectric Megtron4 0.1mm [128, 128, 128] {'factor': '0', 'enabled': False, 'etch_power_... {'top': {'model': 'huray', 'nodule_radius': '0...

Write stackup definition into a json file

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

Equivalent toml file looks like below

[11]:
toml_string = toml.dumps(data_cfg)
print(toml_string)
[stackup]
[[stackup.materials]]
name = "copper"
permittivity = 0.0
conductivity = 58000000.0
dielectric_loss_tangent = 0.0
magnetic_loss_tangent = 0.0
mass_density = 0.0
permeability = 0.0
poisson_ratio = 0.0
specific_heat = 0.0
thermal_conductivity = 0.0

[[stackup.materials]]
name = "FR4_epoxy"
permittivity = 4.4
conductivity = 0.0
dielectric_loss_tangent = 0.02
magnetic_loss_tangent = 0.0
mass_density = 1900.0
permeability = 0.0
poisson_ratio = 0.28
specific_heat = 1150.0
thermal_conductivity = 0.294

[[stackup.materials]]
name = "Megtron4"
permittivity = 3.77
conductivity = 0.0
dielectric_loss_tangent = 0.005
magnetic_loss_tangent = 0.0
mass_density = 0.0
permeability = 0.0
poisson_ratio = 0.0
specific_heat = 0.0
thermal_conductivity = 0.0

[[stackup.materials]]
name = "Megtron4_2"
permittivity = 3.47
conductivity = 0.0
dielectric_loss_tangent = 0.006
magnetic_loss_tangent = 0.0
mass_density = 0.0
permeability = 0.0
poisson_ratio = 0.0
specific_heat = 0.0
thermal_conductivity = 0.0

[[stackup.materials]]
name = "Megtron4_3"
permittivity = 4.2
conductivity = 0.0
dielectric_loss_tangent = 0.005
magnetic_loss_tangent = 0.0
mass_density = 0.0
permeability = 0.0
poisson_ratio = 0.0
specific_heat = 0.0
thermal_conductivity = 0.0

[[stackup.materials]]
name = "Solder Resist"
permittivity = 3.0
conductivity = 0.0
dielectric_loss_tangent = 0.0
magnetic_loss_tangent = 0.0
mass_density = 0.0
permeability = 0.0
poisson_ratio = 0.0
specific_heat = 0.0
thermal_conductivity = 0.0

[[stackup.layers]]
name = "soler_mask"
type = "dielectric"
material = "Megtron4"
fill_material = ""
thickness = 2e-5

[[stackup.layers]]
name = "1_Top"
type = "signal"
material = "copper"
fill_material = "Solder Resist"
thickness = 5e-5
color = [ 255, 0, 0,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE1"
type = "dielectric"
material = "Megtron4"
fill_material = ""
thickness = "0.1mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner1(GND1)"
type = "signal"
material = "copper"
fill_material = "Megtron4_2"
thickness = "0.017mm"
color = [ 128, 128, 0,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE2"
type = "dielectric"
material = "Megtron4_2"
fill_material = ""
thickness = "0.088mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner2(PWR1)"
type = "signal"
material = "copper"
fill_material = "Megtron4_2"
thickness = "0.017mm"
color = [ 112, 219, 250,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE3"
type = "dielectric"
material = "Megtron4"
fill_material = ""
thickness = "0.1mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner3(Sig1)"
type = "signal"
material = "copper"
fill_material = "Megtron4_3"
thickness = "0.017mm"
color = [ 255, 0, 255,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Megtron4-1mm"
type = "dielectric"
material = "Megtron4_3"
fill_material = ""
thickness = "1mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner4(Sig2)"
type = "signal"
material = "copper"
fill_material = "Megtron4_3"
thickness = "0.017mm"
color = [ 128, 0, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE5"
type = "dielectric"
material = "Megtron4"
fill_material = ""
thickness = "0.1mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner5(PWR2)"
type = "signal"
material = "copper"
fill_material = "Megtron4_2"
thickness = "0.017mm"
color = [ 0, 204, 102,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE6"
type = "dielectric"
material = "Megtron4_2"
fill_material = ""
thickness = "0.088mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Inner6(GND2)"
type = "signal"
material = "copper"
fill_material = "Megtron4_2"
thickness = "0.017mm"
color = [ 0, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "DE7"
type = "dielectric"
material = "Megtron4"
fill_material = ""
thickness = "0.1mm"
color = [ 128, 128, 128,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "16_Bottom"
type = "signal"
material = "copper"
fill_material = "Solder Resist"
thickness = "0.035mm"
color = [ 0, 0, 255,]

[stackup.layers.etching]
factor = "0"
enabled = false
etch_power_ground_nets = false
[stackup.layers.roughness]
enabled = false
[stackup.layers.roughness.top]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.bottom]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[stackup.layers.roughness.side]
model = "huray"
nodule_radius = "0"
surface_ratio = "0"
[[stackup.layers]]
name = "Measures"
type = "measure"
color = [ 63, 63, 63,]

[[stackup.layers]]
name = "SIwave Regions"
type = "siwavehfsssolverregions"
color = [ 127, 127, 127,]

[[stackup.layers]]
name = "Top Overlay"
type = "silkscreen"
color = [ 208, 145, 239,]

[[stackup.layers]]
name = "Top Solder"
type = "soldermask"
color = [ 16, 115, 138,]

[[stackup.layers]]
name = "Bottom Solder"
type = "soldermask"
color = [ 46, 67, 160,]

[[stackup.layers]]
name = "Bottom Overlay"
type = "silkscreen"
color = [ 219, 116, 240,]

[[stackup.layers]]
name = "Outline"
type = "outline"
color = [ 0, 0, 0,]

[[stackup.layers]]
name = "Rats"
type = "airlines"
color = [ 0, 0, 255,]

[[stackup.layers]]
name = "Errors"
type = "errors"
color = [ 255, 0, 0,]

[[stackup.layers]]
name = "Symbols"
type = "symbol"
color = [ 127, 0, 127,]

[[stackup.layers]]
name = "Postprocessing"
type = "postprocessing"
color = [ 40, 152, 137,]


Load stackup from json configuration file#

[12]:
edbapp.configuration.load(file_cfg, apply_file=True)
[12]:
<pyedb.configuration.cfg_data.CfgData at 0x2d2414fceb0>

Plot stackup

[13]:
edbapp.stackup.plot()
../../../_images/examples_00_edb_use_configuration_import_stackup_27_0.png
[13]:
<module 'matplotlib.pyplot' from 'C:\\actions-runner\\_work\\pyaedt-examples\\pyaedt-examples\\.venv\\lib\\site-packages\\matplotlib\\pyplot.py'>

Check top layer thickness

[14]:
edbapp.stackup["1_Top"].thickness
[14]:
5e-05

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.

[15]:
edbapp.save()
edbapp.close()
PyAEDT INFO: EDB file save time: 0.00ms
PyAEDT INFO: EDB file release time: 0.00ms
[15]:
True

Download this example

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