Import Stackup#
This example shows how to import stackup file.
Import the required packages#
[1]:
import json
from pathlib import Path
import tempfile
from IPython.display import display
import pandas as pd
from pyaedt.downloads import download_file
from pyedb import Edb
AEDT_VERSION = "2024.1"
NG_MODE = False
Download the example PCB data.
[2]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = download_file(source="edb/ANSYS-HSD_V1.aedb", destination=temp_folder.name)
Load example layout.#
[3]:
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
PyAEDT INFO: Logger is initialized in EDB.
PyAEDT INFO: legacy v0.21.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 2024.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()
[4]:
data_cfg = edbapp.configuration.get_data_from_db(stackup=True)
PyAEDT INFO: Getting data from layout database.
[5]:
df = pd.DataFrame(data=data_cfg["stackup"]["layers"])
display(df)
name | type | material | fill_material | thickness | |
---|---|---|---|---|---|
0 | 1_Top | signal | copper | Solder Resist | 0.000035 |
1 | DE1 | dielectric | Megtron4 | 0.000100 | |
2 | Inner1(GND1) | signal | copper | Megtron4_2 | 0.000017 |
3 | DE2 | dielectric | Megtron4_2 | 0.000088 | |
4 | Inner2(PWR1) | signal | copper | Megtron4_2 | 0.000017 |
5 | DE3 | dielectric | Megtron4 | 0.000100 | |
6 | Inner3(Sig1) | signal | copper | Megtron4_3 | 0.000017 |
7 | Megtron4-1mm | dielectric | Megtron4_3 | 0.001000 | |
8 | Inner4(Sig2) | signal | copper | Megtron4_3 | 0.000017 |
9 | DE5 | dielectric | Megtron4 | 0.000100 | |
10 | Inner5(PWR2) | signal | copper | Megtron4_2 | 0.000017 |
11 | DE6 | dielectric | Megtron4_2 | 0.000088 | |
12 | Inner6(GND2) | signal | copper | Megtron4_2 | 0.000017 |
13 | DE7 | dielectric | Megtron4 | 0.000100 | |
14 | 16_Bottom | signal | copper | Solder Resist | 0.000035 |
15 | Measures | measure | NaN | NaN | NaN |
16 | SIwave Regions | siwavehfsssolverregions | NaN | NaN | NaN |
17 | Top Overlay | silkscreen | NaN | NaN | NaN |
18 | Top Solder | soldermask | NaN | NaN | NaN |
19 | Bottom Solder | soldermask | NaN | NaN | NaN |
20 | Bottom Overlay | silkscreen | NaN | NaN | NaN |
21 | Outline | outline | NaN | NaN | NaN |
22 | Rats | airlines | NaN | NaN | NaN |
23 | Errors | errors | NaN | NaN | NaN |
24 | Symbols | symbol | NaN | NaN | NaN |
25 | Postprocessing | postprocessing | NaN | NaN | NaN |
Modify stackup#
Modify top layer thickness
[6]:
data_cfg["stackup"]["layers"][0]["thickness"] = 0.00005
Add a solder mask layer
[7]:
data_cfg["stackup"]["layers"].insert(
0, {"name": "soler_mask", "type": "dielectric", "material": "Megtron4", "fill_material": "", "thickness": 0.00002}
)
Review modified stackup
[8]:
df = pd.DataFrame(data=data_cfg["stackup"]["layers"])
display(df.head(3))
name | type | material | fill_material | thickness | |
---|---|---|---|---|---|
0 | soler_mask | dielectric | Megtron4 | 0.00002 | |
1 | 1_Top | signal | copper | Solder Resist | 0.00005 |
2 | DE1 | dielectric | Megtron4 | 0.00010 |
Write stackup definition into a json file
[9]:
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)
Load stackup from json configuration file#
[10]:
edbapp.configuration.load(file_cfg, apply_file=True)
[10]:
<pyedb.configuration.cfg_data.CfgData at 0x27558b5f3b0>
Plot stackup
[11]:
edbapp.stackup.plot()
C:\actions-runner\_work\pyedb\pyedb\.venv\lib\site-packages\pyedb\dotnet\edb_core\stackup.py:2884: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
[11]:
<module 'matplotlib.pyplot' from 'C:\\actions-runner\\_work\\pyedb\\pyedb\\.venv\\lib\\site-packages\\matplotlib\\pyplot.py'>
Check top layer thickness
[12]:
edbapp.stackup["1_Top"].thickness
[12]:
5e-05
Cleanup#
[13]:
edbapp.close()
[13]:
True