{ "cells": [ { "cell_type": "markdown", "id": "65059904", "metadata": {}, "source": [ "# Set up EDB for PCB DC IR Analysis\n", "This example shows how to set up the electronics database (EDB) for DC IR analysis from a single\n", "configuration file." ] }, { "cell_type": "markdown", "id": "1a7364d4", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "2ff21cc7", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "\n", "from ansys.aedt.core import Hfss3dLayout, Icepak\n", "from ansys.aedt.core.examples.downloads import download_file\n", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "67c69522", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "a6766308", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.2\"\n", "NG_MODE = False" ] }, { "cell_type": "markdown", "id": "4cead3c0", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "f81776d1", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "a2924f62", "metadata": {}, "source": [ "## Load example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "5c62ac3a", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "5139271c", "metadata": {}, "source": [ "## Create an empty dictionary to host all configurations" ] }, { "cell_type": "code", "execution_count": null, "id": "70f783fc", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"sources\"] = []" ] }, { "cell_type": "markdown", "id": "14a1ba00", "metadata": {}, "source": [ "## Update stackup" ] }, { "cell_type": "code", "execution_count": null, "id": "d4a37d98", "metadata": {}, "outputs": [], "source": [ "cfg[\"stackup\"] = {\n", " \"layers\": [\n", " {\"name\": \"Top\", \"type\": \"signal\", \"material\": \"copper\", \"fill_material\": \"FR4_epoxy\", \"thickness\": \"0.035mm\"},\n", " {\"name\": \"DE1\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.1mm\"},\n", " {\n", " \"name\": \"Inner1\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\"name\": \"DE2\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.088mm\"},\n", " {\n", " \"name\": \"Inner2\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\"name\": \"DE3\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.1mm\"},\n", " {\n", " \"name\": \"Inner3\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\n", " \"name\": \"FR4_epoxy-1mm\",\n", " \"type\": \"dielectric\",\n", " \"material\": \"FR4_epoxy\",\n", " \"fill_material\": \"\",\n", " \"thickness\": \"1mm\",\n", " },\n", " {\n", " \"name\": \"Inner4\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\"name\": \"DE5\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.1mm\"},\n", " {\n", " \"name\": \"Inner5\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\"name\": \"DE6\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.088mm\"},\n", " {\n", " \"name\": \"Inner6\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.017mm\",\n", " },\n", " {\"name\": \"DE7\", \"type\": \"dielectric\", \"material\": \"FR4_epoxy\", \"fill_material\": \"\", \"thickness\": \"0.1mm\"},\n", " {\n", " \"name\": \"Bottom\",\n", " \"type\": \"signal\",\n", " \"material\": \"copper\",\n", " \"fill_material\": \"FR4_epoxy\",\n", " \"thickness\": \"0.035mm\",\n", " },\n", " ]\n", "}" ] }, { "cell_type": "markdown", "id": "8e2a6e82", "metadata": {}, "source": [ "## Define voltage source" ] }, { "cell_type": "code", "execution_count": null, "id": "5fb1f947", "metadata": {}, "outputs": [], "source": [ "cfg[\"sources\"].append(\n", " {\n", " \"name\": \"vrm\",\n", " \"reference_designator\": \"U2\",\n", " \"type\": \"voltage\",\n", " \"magnitude\": 1,\n", " \"positive_terminal\": {\"net\": \"1V0\"},\n", " \"negative_terminal\": {\"net\": \"GND\"},\n", " }\n", ")" ] }, { "cell_type": "markdown", "id": "76114836", "metadata": {}, "source": [ "## Define current source" ] }, { "cell_type": "code", "execution_count": null, "id": "3115266c", "metadata": {}, "outputs": [], "source": [ "cfg[\"sources\"].append(\n", " {\n", " \"name\": \"U1_1V0\",\n", " \"reference_designator\": \"U1\",\n", " \"type\": \"current\",\n", " \"magnitude\": 10,\n", " \"positive_terminal\": {\"net\": \"1V0\"},\n", " \"negative_terminal\": {\"net\": \"GND\"},\n", " }\n", ")" ] }, { "cell_type": "markdown", "id": "ada502aa", "metadata": {}, "source": [ "## Define SIwave DC IR analysis setup" ] }, { "cell_type": "code", "execution_count": null, "id": "79cfed4d", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [\n", " {\n", " \"name\": \"siwave_1\",\n", " \"type\": \"siwave_dc\",\n", " \"dc_slider_position\": 1,\n", " \"dc_ir_settings\": {\"export_dc_thermal_data\": True},\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "e1384a9d", "metadata": {}, "source": [ "## Define Cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "9a2f65c8", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\"signal_list\": [\"1V0\"], \"reference_list\": [\"GND\"], \"extent_type\": \"ConvexHull\", \"expansion_size\": 0.02}\n", "}" ] }, { "cell_type": "markdown", "id": "c6564762", "metadata": {}, "source": [ "## Define package for thermal analysis (optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "60bd2238", "metadata": {}, "outputs": [], "source": [ "cfg[\"package_definitions\"] = [\n", " {\n", " \"name\": \"package_1\",\n", " \"component_definition\": \"ALTR-FBGA1517-Ansys\",\n", " \"maximum_power\": 0.5,\n", " \"therm_cond\": 2,\n", " \"theta_jb\": 3,\n", " \"theta_jc\": 4,\n", " \"height\": \"1mm\",\n", " \"apply_to_all\": False,\n", " \"components\": [\"U1\"],\n", " },\n", "]" ] }, { "cell_type": "markdown", "id": "3bb51b28", "metadata": {}, "source": [ "## Write configuration into a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "489e8800", "metadata": {}, "outputs": [], "source": [ "file_json = os.path.join(temp_folder.name, \"edb_configuration.json\")\n", "with open(file_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "91207ac0", "metadata": {}, "source": [ "## Import configuration into example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "d159f6b7", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(config_file=file_json)" ] }, { "cell_type": "markdown", "id": "d9281222", "metadata": {}, "source": [ "Apply configuration to EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "dbd8a4e2", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.run()" ] }, { "cell_type": "markdown", "id": "7f8fa18b", "metadata": {}, "source": [ "Save and close EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "5f0a5b0f", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "6be858c3", "metadata": {}, "source": [ "The configured EDB file is saved in a temp folder." ] }, { "cell_type": "code", "execution_count": null, "id": "6361bb04", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "1f0d76b0", "metadata": {}, "source": [ "## Load edb into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "74770602", "metadata": {}, "outputs": [], "source": [ "h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "21d56c3f", "metadata": {}, "source": [ "## Prepare for electro-thermal analysis in Icepak (Optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "1fe5aab6", "metadata": {}, "outputs": [], "source": [ "h3d.modeler.set_temperature_dependence(include_temperature_dependence=True, enable_feedback=True, ambient_temp=22)" ] }, { "cell_type": "markdown", "id": "8047643e", "metadata": {}, "source": [ "## Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "4ee93e11", "metadata": {}, "outputs": [], "source": [ "h3d.analyze()" ] }, { "cell_type": "markdown", "id": "edc1592a", "metadata": {}, "source": [ "## Plot DC voltage" ] }, { "cell_type": "code", "execution_count": null, "id": "17e8974f", "metadata": {}, "outputs": [], "source": [ "voltage = h3d.post.create_fieldplot_layers_nets(\n", " layers_nets=[\n", " [\"Inner2\", \"1V0\"],\n", " ],\n", " quantity=\"Voltage\",\n", " setup=\"siwave_1\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "a4e97661", "metadata": {}, "outputs": [], "source": [ "file_path_image = os.path.join(temp_folder.name, \"voltage.jpg\")\n", "voltage.export_image(\n", " full_path=file_path_image,\n", " width=640,\n", " height=480,\n", " orientation=\"isometric\",\n", " display_wireframe=True,\n", " selections=None,\n", " show_region=True,\n", " show_axis=True,\n", " show_grid=True,\n", " show_ruler=True,\n", ")" ] }, { "cell_type": "markdown", "id": "0fb67c28", "metadata": {}, "source": [ "## Plot power density" ] }, { "cell_type": "code", "execution_count": null, "id": "8ff9ae22", "metadata": {}, "outputs": [], "source": [ "power_density = h3d.post.create_fieldplot_layers_nets(\n", " layers_nets=[\n", " [\"Inner2\", \"no-net\"],\n", " ],\n", " quantity=\"Power Density\",\n", " setup=\"siwave_1\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "de5d7497", "metadata": {}, "outputs": [], "source": [ "file_path_image = os.path.join(temp_folder.name, \"power_density.jpg\")\n", "power_density.export_image(\n", " full_path=file_path_image,\n", " width=640,\n", " height=480,\n", " orientation=\"isometric\",\n", " display_wireframe=True,\n", " selections=None,\n", " show_region=True,\n", " show_axis=True,\n", " show_grid=True,\n", " show_ruler=True,\n", ")" ] }, { "cell_type": "markdown", "id": "a550a10d", "metadata": {}, "source": [ "## Save HFSS 3D Layout project" ] }, { "cell_type": "code", "execution_count": null, "id": "058dcad2", "metadata": {}, "outputs": [], "source": [ "h3d.save_project()" ] }, { "cell_type": "markdown", "id": "5878a264", "metadata": {}, "source": [ "## Create an Icepak design" ] }, { "cell_type": "code", "execution_count": null, "id": "3360a7ce", "metadata": {}, "outputs": [], "source": [ "ipk = Icepak(version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=False)" ] }, { "cell_type": "markdown", "id": "1e0a6bac", "metadata": {}, "source": [ "## Create PCB" ] }, { "cell_type": "code", "execution_count": null, "id": "179a1608", "metadata": {}, "outputs": [], "source": [ "pcb = ipk.create_ipk_3dcomponent_pcb(\n", " compName=\"PCB_pyAEDT\",\n", " setupLinkInfo=[h3d.project_file, h3d.design_name, \"siwave_1\", True, True],\n", " solutionFreq=None,\n", " resolution=0,\n", " extent_type=\"Bounding Box\",\n", " powerin=\"0\",\n", ")" ] }, { "cell_type": "markdown", "id": "11a2b8c3", "metadata": {}, "source": [ "## Include pckage definition from Edb" ] }, { "cell_type": "code", "execution_count": null, "id": "c0ff263c", "metadata": {}, "outputs": [], "source": [ "pcb.included_parts = \"Device\"" ] }, { "cell_type": "markdown", "id": "01363219", "metadata": {}, "source": [ "## Adjust air region" ] }, { "cell_type": "code", "execution_count": null, "id": "5ed1a6d4", "metadata": {}, "outputs": [], "source": [ "region = ipk.modeler[\"Region\"]\n", "faces = [f.id for f in region.faces]\n", "ipk.assign_pressure_free_opening(assignment=faces, boundary_name=\"Outlet\")" ] }, { "cell_type": "markdown", "id": "faa4b8ad", "metadata": {}, "source": [ "## Setup mesh" ] }, { "cell_type": "code", "execution_count": null, "id": "7e73c3dd", "metadata": {}, "outputs": [], "source": [ "glob_msh = ipk.mesh.global_mesh_region\n", "glob_msh.global_region.positive_z_padding_type = \"Absolute Offset\"\n", "glob_msh.global_region.positive_z_padding = \"50 mm\"\n", "glob_msh.global_region.negative_z_padding_type = \"Absolute Offset\"\n", "glob_msh.global_region.negative_z_padding = \"80 mm\"" ] }, { "cell_type": "code", "execution_count": null, "id": "a746426b", "metadata": {}, "outputs": [], "source": [ "glob_msh = ipk.mesh.global_mesh_region\n", "glob_msh.manual_settings = True\n", "glob_msh.settings[\"EnableMLM\"] = True\n", "glob_msh.settings[\"EnforeMLMType\"] = \"2D\"\n", "glob_msh.settings[\"2DMLMType\"] = \"Auto\"\n", "glob_msh.settings[\"MaxElementSizeY\"] = \"2mm\"\n", "glob_msh.settings[\"MaxElementSizeX\"] = \"2mm\"\n", "glob_msh.settings[\"MaxElementSizeZ\"] = \"3mm\"\n", "glob_msh.settings[\"MaxLevels\"] = \"2\"" ] }, { "cell_type": "code", "execution_count": null, "id": "96f58a97", "metadata": {}, "outputs": [], "source": [ "glob_msh.update()" ] }, { "cell_type": "markdown", "id": "65e6753d", "metadata": {}, "source": [ "## Place monitor" ] }, { "cell_type": "code", "execution_count": null, "id": "31459ca3", "metadata": {}, "outputs": [], "source": [ "cpu = ipk.modeler[\"PCB_pyAEDT_U1_device\"]\n", "m1 = ipk.monitor.assign_face_monitor(\n", " face_id=cpu.top_face_z.id,\n", " monitor_quantity=\"Temperature\",\n", " monitor_name=\"TemperatureMonitor1\",\n", ")" ] }, { "cell_type": "markdown", "id": "fdc460fd", "metadata": {}, "source": [ "## Create Icepak setup" ] }, { "cell_type": "code", "execution_count": null, "id": "014c2d8d", "metadata": {}, "outputs": [], "source": [ "setup1 = ipk.create_setup(MaxIterations=10)" ] }, { "cell_type": "markdown", "id": "5d70e653", "metadata": {}, "source": [ "Add 2-way coupling to the setup" ] }, { "cell_type": "code", "execution_count": null, "id": "aa734fa6", "metadata": {}, "outputs": [], "source": [ "ipk.assign_2way_coupling(number_of_iterations=1)" ] }, { "cell_type": "markdown", "id": "8dcdd54e", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": null, "id": "fe7738ac", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()" ] }, { "cell_type": "markdown", "id": "b0958145", "metadata": {}, "source": [ "## Shut Down Electronics Desktop" ] }, { "cell_type": "code", "execution_count": null, "id": "0a35787e", "metadata": {}, "outputs": [], "source": [ "ipk.release_desktop()" ] }, { "cell_type": "markdown", "id": "0fa68d1d", "metadata": {}, "source": [ "All project files are saved in the folder ``temp_file.dir``. If you've run this example as a Jupyter notebook you\n", "can retrieve those project files." ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }