{ "cells": [ { "cell_type": "markdown", "id": "2a01d174", "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": "f7bafa43", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "86fe5071", "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": "381ad952", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "2c5aea29", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "NG_MODE = False" ] }, { "cell_type": "markdown", "id": "a078a3f2", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "68baf6a5", "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": "718c6db5", "metadata": {}, "source": [ "## Load example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "f6a41a56", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "8df0bdb4", "metadata": {}, "source": [ "## Create an empty dictionary to host all configurations" ] }, { "cell_type": "code", "execution_count": null, "id": "1200e690", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"sources\"] = []" ] }, { "cell_type": "markdown", "id": "b2499109", "metadata": {}, "source": [ "## Update stackup" ] }, { "cell_type": "code", "execution_count": null, "id": "71f995ec", "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": "daeffac6", "metadata": {}, "source": [ "## Define voltage source" ] }, { "cell_type": "code", "execution_count": null, "id": "9ade98c6", "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": "098e6b95", "metadata": {}, "source": [ "## Define current source" ] }, { "cell_type": "code", "execution_count": null, "id": "45341846", "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": "5a4a2a37", "metadata": {}, "source": [ "## Define SIwave DC IR analysis setup" ] }, { "cell_type": "code", "execution_count": null, "id": "06f251a5", "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": "580ef8aa", "metadata": {}, "source": [ "## Define Cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "762d2a7c", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\"signal_list\": [\"1V0\"], \"reference_list\": [\"GND\"], \"extent_type\": \"ConvexHull\", \"expansion_size\": \"20mm\"}\n", "}" ] }, { "cell_type": "markdown", "id": "f130da58", "metadata": {}, "source": [ "## Define package for thermal analysis (optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "188b7f48", "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": "670a95b3", "metadata": {}, "source": [ "## Write configuration into a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "49eff6cf", "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": "c11154ad", "metadata": {}, "source": [ "## Import configuration into example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "5f317fdd", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(config_file=file_json)" ] }, { "cell_type": "markdown", "id": "9d381056", "metadata": {}, "source": [ "Apply configuration to EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "fb5dcb57", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.run()" ] }, { "cell_type": "markdown", "id": "74d6ad94", "metadata": {}, "source": [ "Save and close EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "15772998", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "aca99bcf", "metadata": {}, "source": [ "The configured EDB file is saved in a temp folder." ] }, { "cell_type": "code", "execution_count": null, "id": "3d27546f", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "dc0b0ec0", "metadata": {}, "source": [ "## Load edb into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "af333b5d", "metadata": {}, "outputs": [], "source": [ "h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "a5c73a84", "metadata": {}, "source": [ "## Prepare for electro-thermal analysis in Icepak (Optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "c39b9209", "metadata": {}, "outputs": [], "source": [ "h3d.modeler.set_temperature_dependence(include_temperature_dependence=True, enable_feedback=True, ambient_temp=22)" ] }, { "cell_type": "markdown", "id": "a6170708", "metadata": {}, "source": [ "## Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "400958b4", "metadata": {}, "outputs": [], "source": [ "h3d.analyze()" ] }, { "cell_type": "markdown", "id": "9e174847", "metadata": {}, "source": [ "## Plot DC voltage" ] }, { "cell_type": "code", "execution_count": null, "id": "b470f786", "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": "98afef86", "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": "82d6a7f3", "metadata": {}, "source": [ "## Plot power density" ] }, { "cell_type": "code", "execution_count": null, "id": "b599e4aa", "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": "ffa1bef5", "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": "f819421c", "metadata": {}, "source": [ "## Save HFSS 3D Layout project" ] }, { "cell_type": "code", "execution_count": null, "id": "20f2651f", "metadata": {}, "outputs": [], "source": [ "h3d.save_project()" ] }, { "cell_type": "markdown", "id": "13419565", "metadata": {}, "source": [ "## Create an Icepak design" ] }, { "cell_type": "code", "execution_count": null, "id": "c8168e8f", "metadata": {}, "outputs": [], "source": [ "ipk = Icepak(version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=False)" ] }, { "cell_type": "markdown", "id": "1203863a", "metadata": {}, "source": [ "## Create PCB" ] }, { "cell_type": "code", "execution_count": null, "id": "37bfaedc", "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": "225e16e5", "metadata": {}, "source": [ "## Include pckage definition from Edb" ] }, { "cell_type": "code", "execution_count": null, "id": "994c5dc8", "metadata": {}, "outputs": [], "source": [ "pcb.included_parts = \"Device\"" ] }, { "cell_type": "markdown", "id": "8007ea59", "metadata": {}, "source": [ "## Adjust air region" ] }, { "cell_type": "code", "execution_count": null, "id": "8eef65c5", "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": "c2554026", "metadata": {}, "source": [ "## Setup mesh" ] }, { "cell_type": "code", "execution_count": null, "id": "325ed732", "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": "957bece1", "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": "37118ea8", "metadata": {}, "outputs": [], "source": [ "glob_msh.update()" ] }, { "cell_type": "markdown", "id": "454b97ec", "metadata": {}, "source": [ "## Place monitor" ] }, { "cell_type": "code", "execution_count": null, "id": "13254354", "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": "77ff0664", "metadata": {}, "source": [ "## Create Icepak setup" ] }, { "cell_type": "code", "execution_count": null, "id": "eeb27d1d", "metadata": {}, "outputs": [], "source": [ "setup1 = ipk.create_setup(MaxIterations=10)" ] }, { "cell_type": "markdown", "id": "4b1b796d", "metadata": {}, "source": [ "Add 2-way coupling to the setup" ] }, { "cell_type": "code", "execution_count": null, "id": "5413ca51", "metadata": {}, "outputs": [], "source": [ "ipk.assign_2way_coupling(number_of_iterations=1)" ] }, { "cell_type": "markdown", "id": "08bff029", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": null, "id": "5d084b85", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()" ] }, { "cell_type": "markdown", "id": "e947dc30", "metadata": {}, "source": [ "## Shut Down Electronics Desktop" ] }, { "cell_type": "code", "execution_count": null, "id": "2d48715b", "metadata": {}, "outputs": [], "source": [ "ipk.release_desktop()" ] }, { "cell_type": "markdown", "id": "77b32a37", "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 }