{ "cells": [ { "cell_type": "markdown", "id": "aa3ff839", "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": "17deece3", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "8e3adb51", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "c4577c19", "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": "14880305", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "4dc6439e", "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": "5fe6a5c0", "metadata": {}, "source": [ "Download example board." ] }, { "cell_type": "code", "execution_count": null, "id": "561f2105", "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": "2070a12f", "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": "9e9dbac1", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "8f94d4cc", "metadata": {}, "source": [ "Define model library paths." ] }, { "cell_type": "code", "execution_count": null, "id": "f4ff6c05", "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": "a5763a84", "metadata": {}, "source": [ "### Change via hole size and plating thickness" ] }, { "cell_type": "code", "execution_count": null, "id": "e0bc91e6", "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": "cad934bc", "metadata": {}, "source": [ "### Assign SPICE models" ] }, { "cell_type": "code", "execution_count": null, "id": "7f662bd4", "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": "8da4e1ed", "metadata": {}, "source": [ "### Create voltage source\n", "Create a voltage source from a net." ] }, { "cell_type": "code", "execution_count": null, "id": "18bbbd01", "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": "c130514f", "metadata": {}, "source": [ "### Create current sources\n", "Create current sources between the net and pin group." ] }, { "cell_type": "code", "execution_count": null, "id": "f6729387", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "code", "execution_count": null, "id": "fa5831a2", "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": "7ab95ab4", "metadata": {}, "source": [ "### Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "b5d3b6bd", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [{\"name\": \"siwave_dc\", \"type\": \"siwave_dc\", \"dc_slider_position\": 0}]" ] }, { "cell_type": "markdown", "id": "1ed99151", "metadata": {}, "source": [ "### Define cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "290a2b5f", "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": "674f93a5", "metadata": {}, "source": [ "### Save configuration as a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "ac4e0193", "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": "d226b309", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "b6522185", "metadata": {}, "source": [ "Load the configuration from the JSON file into EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "7a92720f", "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": "b21880a7", "metadata": {}, "outputs": [], "source": [ "# # Load configuration into EDB\n", "edbapp.nets.plot(None, None, color_by_net=True)" ] }, { "cell_type": "markdown", "id": "60ba71c2", "metadata": {}, "source": [ "## Save and close EDB" ] }, { "cell_type": "code", "execution_count": null, "id": "fa4aeb3d", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "6e8c0ae6", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "5562186e", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "c2a23974", "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": "3a46288c", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "4cc4b4ed", "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": "79f0a794", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "4342d699", "metadata": {}, "outputs": [], "source": [ "siw.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "d1dcf416", "metadata": {}, "source": [ "### Get DC IR results" ] }, { "cell_type": "code", "execution_count": null, "id": "692b934d", "metadata": {}, "outputs": [], "source": [ "siw.get_dcir_element_data_current_source(\"siwave_dc\")" ] }, { "cell_type": "markdown", "id": "d3b7921a", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "927930d5", "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": "7ed38b13", "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": "207744eb", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }