{ "cells": [ { "cell_type": "markdown", "id": "17394c58", "metadata": { "lines_to_next_cell": 2 }, "source": [ "# Electrothermal analysis\n", "\n", "This example shows how to use the EDB for DC IR analysis and\n", "electrothermal analysis. The EDB is loaded into SIwave for analysis and postprocessing.\n", "In the end, an Icepak project is exported from SIwave.\n", "\n", "- Set up EDB:\n", " - Assign package and heatsink model to components.\n", " - Create voltage and current sources.\n", " - Create SIwave DC analysis.\n", " - Define cutout.\n", "- Import EDB into SIwave:\n", " - Analyze DC IR.\n", " - Export Icepak project." ] }, { "cell_type": "markdown", "id": "d4a6f64f", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "df938425", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import sys\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "3d0e3c54", "metadata": {}, "outputs": [], "source": [ "from ansys.aedt.core.downloads import download_file\n", "from pyedb import Edb, Siwave" ] }, { "cell_type": "markdown", "id": "b174a1ac", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "921c5dbd", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NUM_CORES = 4\n", "NG_MODE = True # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "8d6d9536", "metadata": {}, "source": [ "Check if AEDT is launched in graphical mode." ] }, { "cell_type": "code", "execution_count": null, "id": "6db9a22c", "metadata": {}, "outputs": [], "source": [ "if not NG_MODE:\n", " print(\"Warning: this example requires graphical mode enabled.\")\n", " sys.exit()" ] }, { "cell_type": "markdown", "id": "98cf4385", "metadata": {}, "source": [ "## Create temporary directory and download files\n", "\n", "Create a temporary directory where downloaded data or\n", "dumped data can be stored.\n", "If you'd like to retrieve the project data for subsequent use,\n", "the temporary folder name is given by ``temp_folder.name``." ] }, { "cell_type": "code", "execution_count": null, "id": "72783dd2", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "5c37034c", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "9258489b", "metadata": {}, "outputs": [], "source": [ "aedb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "0aa01c93", "metadata": {}, "source": [ "## Create configuration file\n", "\n", "This example uses a configuration file to set up the layout for analysis.\n", "Create an empty dictionary to host all configurations." ] }, { "cell_type": "code", "execution_count": null, "id": "4f37e84f", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "0b442fa4", "metadata": {}, "source": [ "## Add component thermal information and heatsink definition" ] }, { "cell_type": "code", "execution_count": null, "id": "f5ece458", "metadata": {}, "outputs": [], "source": [ "cfg[\"package_definitions\"] = [\n", " {\n", " \"name\": \"package_1\",\n", " \"component_definition\": \"SMTC-MECT-110-01-M-D-RA1_V\",\n", " \"maximum_power\": 1,\n", " \"therm_cond\": 1,\n", " \"theta_jb\": 1,\n", " \"theta_jc\": 1,\n", " \"height\": \"2mm\",\n", " \"heatsink\": {\n", " \"fin_base_height\": \"2mm\",\n", " \"fin_height\": \"4mm\",\n", " \"fin_orientation\": \"x_oriented\",\n", " \"fin_spacing\": \"1mm\",\n", " \"fin_thickness\": \"1mm\",\n", " },\n", " \"apply_to_all\": False,\n", " \"components\": [\"J5\"],\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "470536c1", "metadata": {}, "source": [ "## Create pin groups\n", "\n", "Group all pins on the \"GND\" net on the ``J5`` component into one group.\n", "Pin groups are assigned by net name using the ``net`` key." ] }, { "cell_type": "code", "execution_count": null, "id": "2d6a0fe4", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "markdown", "id": "9b270514", "metadata": {}, "source": [ "## Create current sources\n", "\n", "Create two current sources on the ``J5`` component.\n", "A current source is placed between positive and negative terminals.\n", "When the ``net`` keyword is used, all pins on the specified net are grouped into a\n", "new pin group that is assigned as the positive terminal.\n", "\n", "Negative terminal can be assigned by pin group name by using the ``pin_group`` keyword.\n", "The two current sources share the same ``J5_GND`` pin group as the negative terminal." ] }, { "cell_type": "code", "execution_count": null, "id": "3dc9db66", "metadata": {}, "outputs": [], "source": [ "i_src_1 = {\n", " \"name\": \"J5_VCCR\",\n", " \"reference_designator\": \"J5\",\n", " \"type\": \"current\",\n", " \"magnitude\": 0.5,\n", " \"positive_terminal\": {\"net\": \"SFPA_VCCR\"},\n", " \"negative_terminal\": {\"pin_group\": \"J5_GND\"}, # Defined in \"pin_groups\" section.\n", "}\n", "i_src_2 = {\n", " \"name\": \"J5_VCCT\",\n", " \"reference_designator\": \"J5\",\n", " \"type\": \"current\",\n", " \"magnitude\": 0.5,\n", " \"positive_terminal\": {\"net\": \"SFPA_VCCT\"},\n", " \"negative_terminal\": {\"pin_group\": \"J5_GND\"}, # Defined in \"pin_groups\" section.\n", "}" ] }, { "cell_type": "markdown", "id": "99cadf50", "metadata": {}, "source": [ "## Create a voltage source\n", "\n", "Create a voltage source on the ``U4`` componebt between two nets using the ``net`` keyword." ] }, { "cell_type": "code", "execution_count": null, "id": "d9f9bf64", "metadata": {}, "outputs": [], "source": [ "v_src = {\n", " \"name\": \"VSOURCE_5V\",\n", " \"reference_designator\": \"U4\",\n", " \"type\": \"voltage\",\n", " \"magnitude\": 5,\n", " \"positive_terminal\": {\"net\": \"5V\"},\n", " \"negative_terminal\": {\"net\": \"GND\"},\n", "}\n", "\n", "cfg[\"sources\"] = [v_src, i_src_1, i_src_2]" ] }, { "cell_type": "markdown", "id": "77e96049", "metadata": {}, "source": [ "## Define cutout\n", "\n", "The following assignments define the region of the PCB to be cut out for analysis." ] }, { "cell_type": "code", "execution_count": null, "id": "725766c2", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\n", " \"signal_list\": [\"SFPA_VCCR\", \"SFPA_VCCT\", \"5V\"],\n", " \"reference_list\": [\"GND\"],\n", " \"extent_type\": \"Bounding\",\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "9a3a3324", "metadata": {}, "source": [ "## Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "e2ecb58c", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [\n", " {\n", " \"name\": \"siwave_dc\",\n", " \"type\": \"siwave_dc\",\n", " \"dc_slider_position\": 0,\n", " \"dc_ir_settings\": {\"export_dc_thermal_data\": True},\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "2b70bfae", "metadata": {}, "source": [ "## Save configuration to a JSON file\n", "\n", "The configuration file can be saved in JSON format and applied to layout data using the EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "bc1e2651", "metadata": {}, "outputs": [], "source": [ "pi_json = os.path.join(temp_folder.name, \"pi.json\")\n", "\n", "with open(pi_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "63792244", "metadata": {}, "source": [ "## Load configuration into EDB\n", "\n", "Load the configuration from the JSON file." ] }, { "cell_type": "code", "execution_count": null, "id": "248969b5", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(aedb, edbversion=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=pi_json)\n", "edbapp.configuration.run()\n", "edbapp.save()\n", "edbapp.close()\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "e762191f", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "689ce85b", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "9949216a", "metadata": {}, "source": [ "## Analyze in SIwave\n", "\n", "Load EDB into SIwave." ] }, { "cell_type": "code", "execution_count": null, "id": "cb30fa89", "metadata": {}, "outputs": [], "source": [ "siwave = Siwave(specified_version=AEDT_VERSION)\n", "time.sleep(10)\n", "siwave.open_project(proj_path=aedb)\n", "siwave.save_project(projectpath=temp_folder.name, projectName=\"ansys\")" ] }, { "cell_type": "markdown", "id": "96779201", "metadata": {}, "source": [ "## Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "4b729040", "metadata": {}, "outputs": [], "source": [ "siwave.run_dc_simulation()" ] }, { "cell_type": "markdown", "id": "250e0537", "metadata": {}, "source": [ "## Export Icepak project" ] }, { "cell_type": "code", "execution_count": null, "id": "aa257bd1", "metadata": {}, "outputs": [], "source": [ "siwave.export_icepak_project(\n", " os.path.join(temp_folder.name, \"from_siwave.aedt\"), \"siwave_dc\"\n", ")" ] }, { "cell_type": "markdown", "id": "cdbef9d6", "metadata": {}, "source": [ "## Close SIWave project" ] }, { "cell_type": "code", "execution_count": null, "id": "2eca2515", "metadata": {}, "outputs": [], "source": [ "siwave.close_project()" ] }, { "cell_type": "markdown", "id": "f5e6906c", "metadata": {}, "source": [ "## Shut down SIwave" ] }, { "cell_type": "code", "execution_count": null, "id": "0fd9e0e0", "metadata": {}, "outputs": [], "source": [ "siwave.quit_application()" ] }, { "cell_type": "markdown", "id": "1b4c4486", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.dir``. If you've run this example as a Jupyter notbook, you\n", "can retrieve those project files. The following cell removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "ac150e40", "metadata": {}, "outputs": [], "source": [ "time.sleep(3)\n", "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }