{ "cells": [ { "cell_type": "markdown", "id": "55e83b4b", "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": "265f2edf", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "137f3c98", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "4bea2f58", "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": "b4bc7a8f", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "014ace8b", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "5d6592b1", "metadata": {}, "source": [ "Download example board." ] }, { "cell_type": "code", "execution_count": null, "id": "0c8a2696", "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(\n", " source=\"spice\", name=\"ferrite_bead_BLM15BX750SZ1.mod\", local_path=temp_folder.name\n", ")" ] }, { "cell_type": "markdown", "id": "61b2cafd", "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": "73315de2", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "fcf8252e", "metadata": {}, "source": [ "Define model library paths." ] }, { "cell_type": "code", "execution_count": null, "id": "3ebc1882", "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": "9f092832", "metadata": {}, "source": [ "### Change via hole size and plating thickness" ] }, { "cell_type": "code", "execution_count": null, "id": "3743ca3b", "metadata": {}, "outputs": [], "source": [ "cfg[\"padstacks\"] = {\n", " \"definitions\": [\n", " {\"name\": \"v40h15-3\", \"hole_diameter\": \"0.2mm\", \"hole_plating_thickness\": \"25um\"}\n", " ],\n", "}" ] }, { "cell_type": "markdown", "id": "69d3e9f1", "metadata": {}, "source": [ "### Assign SPICE models" ] }, { "cell_type": "code", "execution_count": null, "id": "e12728fd", "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": "b01dabd5", "metadata": {}, "source": [ "### Create voltage source\n", "Create a voltage source from a net." ] }, { "cell_type": "code", "execution_count": null, "id": "f28e8bb4", "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": "38d77eaf", "metadata": {}, "source": [ "### Create current sources\n", "Create current sources between the net and pin group." ] }, { "cell_type": "code", "execution_count": null, "id": "c14aa3e6", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "code", "execution_count": null, "id": "d283f7be", "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\": {\n", " \"pin_group\": \"J5_GND\" # Defined in \"pin_groups\" section.\n", " },\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\": {\n", " \"pin_group\": \"J5_GND\" # Defined in \"pin_groups\" section.\n", " },\n", " }\n", ")" ] }, { "cell_type": "markdown", "id": "b9759005", "metadata": {}, "source": [ "### Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "c913af11", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [{\"name\": \"siwave_dc\", \"type\": \"siwave_dc\", \"dc_slider_position\": 0}]" ] }, { "cell_type": "markdown", "id": "a1692679", "metadata": {}, "source": [ "### Define cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "88a400e8", "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": "b8a32564", "metadata": {}, "source": [ "### Save configuration as a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "ef751a3e", "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": "94859d8a", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "40a93998", "metadata": {}, "source": [ "Load the configuration from the JSON file into EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "5b96ac2e", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(aedb, edbversion=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=pi_json)\n", "edbapp.configuration.run()" ] }, { "cell_type": "code", "execution_count": null, "id": "2c7d07c7", "metadata": {}, "outputs": [], "source": [ "# # Load configuration into EDB\n", "edbapp.nets.plot(None, None, color_by_net=True)" ] }, { "cell_type": "markdown", "id": "d20a9685", "metadata": {}, "source": [ "## Save and close EDB" ] }, { "cell_type": "code", "execution_count": null, "id": "4d44d305", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "cb55999c", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "019437aa", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "fd727877", "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": "9841fab8", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "67a6f234", "metadata": {}, "outputs": [], "source": [ "siw = ansys.aedt.core.Hfss3dLayout(\n", " aedb, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True\n", ")" ] }, { "cell_type": "markdown", "id": "bc778d4e", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "8e0a5b40", "metadata": {}, "outputs": [], "source": [ "siw.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "7a074930", "metadata": {}, "source": [ "### Get DC IR results" ] }, { "cell_type": "code", "execution_count": null, "id": "7cd5d625", "metadata": {}, "outputs": [], "source": [ "siw.get_dcir_element_data_current_source(\"siwave_dc\")" ] }, { "cell_type": "markdown", "id": "e906a5f4", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "aa0598d1", "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": "b806483f", "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": "27471369", "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 }