{ "cells": [ { "cell_type": "markdown", "id": "9e4212df", "metadata": {}, "source": [ "# DC IR analysis\n", "\n", "This example shows how to configure EDB for DC IR analysis and load EDB into the HFSS 3D Layout UI for analysis and\n", "postprocessing.\n", "\n", "- Set up EDB:\n", "\n", " - Edit via padstack.\n", " - Assign SPICE model to components.\n", " - Create pin groups.\n", " - Create voltage and current sources.\n", " - Create SIwave DC analysis.\n", " - Create cutout.\n", "\n", "- Import EDB into HFSS 3D Layout:\n", "\n", " - Analyze.\n", " - Get DC IR analysis results.\n", "\n", "Keywords: **HFSS 3D Layout**, **DC IR**." ] }, { "cell_type": "markdown", "id": "7cf69061", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "d1ad9162", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "c8a9f31e", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core\n", "from ansys.aedt.core.examples.downloads import download_file\n", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "169ed783", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "f7141cbc", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "2b0cc242", "metadata": {}, "source": [ "Download example board." ] }, { "cell_type": "code", "execution_count": null, "id": "eeff2556", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "aedb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", local_path=temp_folder.name)\n", "_ = download_file(source=\"spice\", name=\"ferrite_bead_BLM15BX750SZ1.mod\", local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "7ee3d345", "metadata": {}, "source": [ "## Create configuration file\n", "This example uses a configuration file to set up the layout for analysis.\n", "Initialize and create an empty dictionary to host all configurations." ] }, { "cell_type": "code", "execution_count": null, "id": "3accd832", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "cb11242e", "metadata": {}, "source": [ "Define model library paths." ] }, { "cell_type": "code", "execution_count": null, "id": "afbaf0f9", "metadata": {}, "outputs": [], "source": [ "cfg[\"general\"] = {\n", " \"s_parameter_library\": os.path.join(temp_folder.name, \"touchstone\"),\n", " \"spice_model_library\": os.path.join(temp_folder.name, \"spice\"),\n", "}" ] }, { "cell_type": "markdown", "id": "e2c7a860", "metadata": {}, "source": [ "### Assign SPICE models" ] }, { "cell_type": "code", "execution_count": null, "id": "bb2c8c98", "metadata": {}, "outputs": [], "source": [ "cfg[\"spice_models\"] = [\n", " {\n", " \"name\": \"ferrite_bead_BLM15BX750SZ1\", # Give a name to the SPICE Mode.\n", " \"component_definition\": \"COIL-1008CS_V\", # Part name of the components\n", " \"file_path\": \"ferrite_bead_BLM15BX750SZ1.mod\", # File name or full file path to the SPICE file.\n", " \"sub_circuit_name\": \"BLM15BX750SZ1\",\n", " \"apply_to_all\": True, # If True, SPICE model is to be assigned to all components share the same part name.\n", " # If False, only assign SPICE model to components in \"components\".\n", " \"components\": [],\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "3e38e4b8", "metadata": {}, "source": [ "### Create voltage source\n", "Create a voltage source from a net." ] }, { "cell_type": "code", "execution_count": null, "id": "751afc46", "metadata": {}, "outputs": [], "source": [ "cfg[\"sources\"] = [\n", " {\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", "]" ] }, { "cell_type": "markdown", "id": "dca69220", "metadata": {}, "source": [ "### Create current sources\n", "Create current sources between the net and pin group." ] }, { "cell_type": "code", "execution_count": null, "id": "009cb649", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "code", "execution_count": null, "id": "6be85744", "metadata": {}, "outputs": [], "source": [ "cfg[\"sources\"].append(\n", " {\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", ")\n", "cfg[\"sources\"].append(\n", " {\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", " }\n", ")" ] }, { "cell_type": "markdown", "id": "4b0f42c9", "metadata": {}, "source": [ "### Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "7274e59d", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [{\"name\": \"siwave_dc\", \"type\": \"siwave_dc\", \"dc_slider_position\": 0}]" ] }, { "cell_type": "markdown", "id": "c15b918a", "metadata": {}, "source": [ "### Define cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "86f297cc", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\n", " \"signal_list\": [\"SFPA_VCCR\", \"SFPA_VCCT\", \"5V\"],\n", " \"reference_list\": [\"GND\"],\n", " \"extent_type\": \"ConvexHull\",\n", " \"expansion_size\": 0.002,\n", " \"use_round_corner\": False,\n", " \"output_aedb_path\": \"\",\n", " \"open_cutout_at_end\": True,\n", " \"use_pyaedt_cutout\": True,\n", " \"number_of_threads\": 4,\n", " \"use_pyaedt_extent_computing\": True,\n", " \"extent_defeature\": 0,\n", " \"remove_single_pin_components\": False,\n", " \"custom_extent\": \"\",\n", " \"custom_extent_units\": \"mm\",\n", " \"include_partial_instances\": False,\n", " \"keep_voids\": True,\n", " \"check_terminals\": False,\n", " \"include_pingroups\": False,\n", " \"expansion_factor\": 0,\n", " \"maximum_iterations\": 10,\n", " \"preserve_components_with_model\": False,\n", " \"simple_pad_check\": True,\n", " \"keep_lines_as_path\": False,\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "ea763376", "metadata": {}, "source": [ "### Save configuration as a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "0b704401", "metadata": {}, "outputs": [], "source": [ "pi_json = os.path.join(temp_folder.name, \"pi.json\")\n", "with open(pi_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "cf5e0186", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "bdd85219", "metadata": {}, "source": [ "Load the configuration from the JSON file into EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "f6466745", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(edbpath=aedb, version=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=pi_json)\n", "edbapp.configuration.run()" ] }, { "cell_type": "code", "execution_count": null, "id": "85149ee8", "metadata": {}, "outputs": [], "source": [ "# # Load configuration into EDB\n", "edbapp.nets.plot(None, None, color_by_net=True)" ] }, { "cell_type": "markdown", "id": "52d9e0b7", "metadata": {}, "source": [ "## Save and close EDB" ] }, { "cell_type": "code", "execution_count": null, "id": "85311dff", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "05e4f46b", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "70fee4dc", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "a054ccbb", "metadata": {}, "source": [ "## Analyze DCIR with SIwave\n", "\n", "The HFSS 3D Layout interface to SIwave is used to open the EDB and run the DCIR analysis\n", "using SIwave" ] }, { "cell_type": "markdown", "id": "839a9fcd", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "db1d6019", "metadata": {}, "outputs": [], "source": [ "siw = ansys.aedt.core.Hfss3dLayout(aedb, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "9aadb65f", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "ad350b0c", "metadata": {}, "outputs": [], "source": [ "siw.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "1ff7ba34", "metadata": {}, "source": [ "### Get DC IR results" ] }, { "cell_type": "code", "execution_count": null, "id": "95f9f921", "metadata": {}, "outputs": [], "source": [ "siw.get_dcir_element_data_current_source(\"siwave_dc\")" ] }, { "cell_type": "markdown", "id": "86a13119", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "dcb444a5", "metadata": {}, "outputs": [], "source": [ "siw.save_project()\n", "siw.release_desktop()\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "b3559b1e", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``.\n", "If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell\n", "removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "609af6f2", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }