{ "cells": [ { "cell_type": "markdown", "id": "cae73b44", "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": "84e52780", "metadata": {}, "source": [ "## Import the required packages" ] }, { "cell_type": "code", "execution_count": null, "id": "43a32335", "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.downloads import download_file\n", "\n", "from pyedb import Edb\n", "\n", "AEDT_VERSION = \"2024.2\"\n", "NG_MODE = False\n" ] }, { "cell_type": "markdown", "id": "466cb1e5", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "46aa5d05", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "f12f8a18", "metadata": {}, "source": [ "## Load example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "921d28e3", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "c56c137f", "metadata": {}, "source": [ "## Create an empty dictionary to host all configurations" ] }, { "cell_type": "code", "execution_count": null, "id": "c5711bd4", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"sources\"] = []" ] }, { "cell_type": "markdown", "id": "8022fad8", "metadata": {}, "source": [ "## Update stackup" ] }, { "cell_type": "code", "execution_count": null, "id": "0cae3431", "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": "bcbae3d0", "metadata": {}, "source": [ "## Define voltage source" ] }, { "cell_type": "code", "execution_count": null, "id": "59d3dbb0", "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": "413c7093", "metadata": {}, "source": [ "## Define current source" ] }, { "cell_type": "code", "execution_count": null, "id": "3d98771e", "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": "cf0296dc", "metadata": {}, "source": [ "## Define SIwave DC IR analysis setup" ] }, { "cell_type": "code", "execution_count": null, "id": "07a85fdc", "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": "39fbcbab", "metadata": {}, "source": [ "## Define Cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "e7bc1cbc", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\"signal_list\": [\"1V0\"], \"reference_list\": [\"GND\"], \"extent_type\": \"ConvexHull\", \"expansion_size\": \"20mm\"}\n", "}" ] }, { "cell_type": "markdown", "id": "577b2e50", "metadata": {}, "source": [ "## Define package for thermal analysis (optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "d9964f04", "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": "f7e44c23", "metadata": {}, "source": [ "## Write configuration into a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "8f88a527", "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": "fb162747", "metadata": {}, "source": [ "## Import configuration into example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "21a1e879", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(config_file=file_json)" ] }, { "cell_type": "markdown", "id": "5e9ee464", "metadata": {}, "source": [ "Apply configuration to EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "b50ba6e7", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.run()" ] }, { "cell_type": "markdown", "id": "457f8c59", "metadata": {}, "source": [ "Save and close EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "a37acad7", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "65e59979", "metadata": {}, "source": [ "The configured EDB file is saved in a temp folder." ] }, { "cell_type": "code", "execution_count": null, "id": "4a68035e", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "753d8a20", "metadata": {}, "source": [ "## Load edb into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "84eacec6", "metadata": {}, "outputs": [], "source": [ "h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "91a7685e", "metadata": {}, "source": [ "## Prepare for electro-thermal analysis in Icepak (Optional)" ] }, { "cell_type": "code", "execution_count": null, "id": "7283306c", "metadata": {}, "outputs": [], "source": [ "h3d.modeler.set_temperature_dependence(include_temperature_dependence=True, enable_feedback=True, ambient_temp=22)" ] }, { "cell_type": "markdown", "id": "1354866a", "metadata": {}, "source": [ "## Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "a8b699a4", "metadata": {}, "outputs": [], "source": [ "h3d.analyze()" ] }, { "cell_type": "markdown", "id": "7fdec105", "metadata": {}, "source": [ "## Plot DC voltage" ] }, { "cell_type": "code", "execution_count": null, "id": "aca36cfe", "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": "265300d2", "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": "3ea1c8dd", "metadata": {}, "source": [ "## Plot power density" ] }, { "cell_type": "code", "execution_count": null, "id": "24bb525c", "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": "77cc76d9", "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": "be8b226f", "metadata": {}, "source": [ "## Save HFSS 3D Layout project" ] }, { "cell_type": "code", "execution_count": null, "id": "9ca047fb", "metadata": {}, "outputs": [], "source": [ "h3d.save_project()" ] }, { "cell_type": "markdown", "id": "a391dce5", "metadata": {}, "source": [ "## Create an Icepak design" ] }, { "cell_type": "code", "execution_count": null, "id": "91c2fbda", "metadata": {}, "outputs": [], "source": [ "ipk = Icepak(version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=False)" ] }, { "cell_type": "markdown", "id": "75229859", "metadata": {}, "source": [ "## Create PCB" ] }, { "cell_type": "code", "execution_count": null, "id": "49419573", "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": "0c5f3fce", "metadata": {}, "source": [ "## Include pckage definition from Edb" ] }, { "cell_type": "code", "execution_count": null, "id": "28303f80", "metadata": {}, "outputs": [], "source": [ "pcb.included_parts = \"Device\"" ] }, { "cell_type": "markdown", "id": "7f8a13cd", "metadata": {}, "source": [ "## Adjust air region" ] }, { "cell_type": "code", "execution_count": null, "id": "0f32541a", "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": "d2cf010a", "metadata": {}, "source": [ "## Setup mesh" ] }, { "cell_type": "code", "execution_count": null, "id": "ae9040ba", "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": "ffbee511", "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": "bb426e03", "metadata": {}, "outputs": [], "source": [ "glob_msh.update()" ] }, { "cell_type": "markdown", "id": "42fbc7da", "metadata": {}, "source": [ "## Place monitor" ] }, { "cell_type": "code", "execution_count": null, "id": "9a93f8bf", "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": "b3d10089", "metadata": {}, "source": [ "## Create Icepak setup" ] }, { "cell_type": "code", "execution_count": null, "id": "b9f2d426", "metadata": {}, "outputs": [], "source": [ "setup1 = ipk.create_setup(MaxIterations=10)" ] }, { "cell_type": "markdown", "id": "055be717", "metadata": {}, "source": [ "Add 2-way coupling to the setup" ] }, { "cell_type": "code", "execution_count": null, "id": "0e3079c6", "metadata": {}, "outputs": [], "source": [ "ipk.assign_2way_coupling(number_of_iterations=1)" ] }, { "cell_type": "markdown", "id": "4735eb7e", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": null, "id": "078fa882", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()" ] }, { "cell_type": "markdown", "id": "0c09c86c", "metadata": {}, "source": [ "## Shut Down Electronics Desktop" ] }, { "cell_type": "code", "execution_count": null, "id": "29d7d64b", "metadata": {}, "outputs": [], "source": [ "ipk.release_desktop()" ] }, { "cell_type": "markdown", "id": "ea39bbab", "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 }