{ "cells": [ { "cell_type": "markdown", "id": "25ed6b5a", "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": "a32ee07a", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "cce39a87", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "17361661", "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": "9e7b75df", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "29bd30f3", "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": "09f2775c", "metadata": {}, "source": [ "Download example board." ] }, { "cell_type": "code", "execution_count": null, "id": "5ee64c59", "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": "34b37a8a", "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": "a0948b4b", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "78269c4d", "metadata": {}, "source": [ "Define model library paths." ] }, { "cell_type": "code", "execution_count": null, "id": "3d5c4688", "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": "070f833c", "metadata": {}, "source": [ "### Change via hole size and plating thickness" ] }, { "cell_type": "code", "execution_count": null, "id": "7572c235", "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": "55642438", "metadata": {}, "source": [ "### Assign SPICE models" ] }, { "cell_type": "code", "execution_count": null, "id": "1ca548b9", "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": "2fd3dae2", "metadata": {}, "source": [ "### Create voltage source\n", "Create a voltage source from a net." ] }, { "cell_type": "code", "execution_count": null, "id": "52d2f6d2", "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": "d10baf86", "metadata": {}, "source": [ "### Create current sources\n", "Create current sources between the net and pin group." ] }, { "cell_type": "code", "execution_count": null, "id": "a266e7f5", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "code", "execution_count": null, "id": "6d7f783f", "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": "d13eb9f9", "metadata": {}, "source": [ "### Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "af7acb65", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [{\"name\": \"siwave_dc\", \"type\": \"siwave_dc\", \"dc_slider_position\": 0}]" ] }, { "cell_type": "markdown", "id": "fe3b66e8", "metadata": {}, "source": [ "### Define cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "f7632bd8", "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": "6dde787d", "metadata": {}, "source": [ "### Save configuration as a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "ddafc494", "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": "bebbb40b", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "9ee88b03", "metadata": {}, "source": [ "Load the configuration from the JSON file into EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "4f24fbcd", "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": "e7182c9b", "metadata": {}, "outputs": [], "source": [ "# # Load configuration into EDB\n", "edbapp.nets.plot(None, None, color_by_net=True)" ] }, { "cell_type": "markdown", "id": "28bd74c7", "metadata": {}, "source": [ "## Save and close EDB" ] }, { "cell_type": "code", "execution_count": null, "id": "4d2ae26e", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "2201ce2c", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "185e284f", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "4dd65aff", "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": "3733c0ee", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "1389b1c8", "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": "cdd41a7a", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "ba9646a6", "metadata": {}, "outputs": [], "source": [ "siw.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "f4597782", "metadata": {}, "source": [ "### Get DC IR results" ] }, { "cell_type": "code", "execution_count": null, "id": "40fc4944", "metadata": {}, "outputs": [], "source": [ "siw.get_dcir_element_data_current_source(\"siwave_dc\")" ] }, { "cell_type": "markdown", "id": "fee1ec32", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "88bf4446", "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": "acee1b2e", "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": "2f9b1e78", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }