{ "cells": [ { "cell_type": "markdown", "id": "9d7f837c", "metadata": {}, "source": [ "# DC IR analysis\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": "81f7e396", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "705c2653", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "01770acd", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core\n", "from ansys.aedt.core.downloads import download_file\n", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "276667ae", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "f46ff7f3", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "7a416549", "metadata": {}, "source": [ "Download example board." ] }, { "cell_type": "code", "execution_count": null, "id": "94738cfc", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "aedb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder.name)\n", "download_file(\n", " source=\"spice\", name=\"ferrite_bead_BLM15BX750SZ1.mod\", destination=temp_folder.name\n", ")" ] }, { "cell_type": "markdown", "id": "5c4e247a", "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": "3fa70a7e", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "479ed456", "metadata": {}, "source": [ "Define model library paths." ] }, { "cell_type": "code", "execution_count": null, "id": "6a1149fd", "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": "32c72724", "metadata": {}, "source": [ "### Change via hole size and plating thickness" ] }, { "cell_type": "code", "execution_count": null, "id": "5e506310", "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": "e08bc81f", "metadata": {}, "source": [ "### Assign SPICE models" ] }, { "cell_type": "code", "execution_count": null, "id": "47c479c9", "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": "9ba2fde6", "metadata": {}, "source": [ "### Create voltage source\n", "Create a voltage source from a net." ] }, { "cell_type": "code", "execution_count": null, "id": "19b0e517", "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": "25ffc5e2", "metadata": {}, "source": [ "### Create current sources\n", "Create current sources between the net and pin group." ] }, { "cell_type": "code", "execution_count": null, "id": "4cdb93ba", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [{\"name\": \"J5_GND\", \"reference_designator\": \"J5\", \"net\": \"GND\"}]" ] }, { "cell_type": "code", "execution_count": null, "id": "d619cbbf", "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": "b7b1d5ef", "metadata": {}, "source": [ "### Create SIwave DC analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "3bd67556", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [{\"name\": \"siwave_dc\", \"type\": \"siwave_dc\", \"dc_slider_position\": 0}]" ] }, { "cell_type": "markdown", "id": "3bb90233", "metadata": {}, "source": [ "### Define cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "547047ef", "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": "0747f8b3", "metadata": {}, "source": [ "### Save configuration as a JSON file" ] }, { "cell_type": "code", "execution_count": null, "id": "1a150ea7", "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": "b2e15407", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "0a95dc58", "metadata": {}, "source": [ "Load the configuration from the JSON file into EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "03eb296c", "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": "998c340b", "metadata": {}, "outputs": [], "source": [ "# # Load configuration into EDB\n", "edbapp.nets.plot(None, None, color_by_net=True)" ] }, { "cell_type": "markdown", "id": "cee6d86c", "metadata": {}, "source": [ "## Save and close EDB" ] }, { "cell_type": "code", "execution_count": null, "id": "b0e0ffc9", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "a13ab6d5", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "42c3cfe5", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "b118f357", "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": "cc536a97", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "bb38067c", "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": "f9d5b325", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "e4809450", "metadata": {}, "outputs": [], "source": [ "siw.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "28d9abaf", "metadata": {}, "source": [ "### Get DC IR results" ] }, { "cell_type": "code", "execution_count": null, "id": "7275118f", "metadata": {}, "outputs": [], "source": [ "siw.get_dcir_element_data_current_source(\"siwave_dc\")" ] }, { "cell_type": "markdown", "id": "3041918e", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "5ae95bb2", "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": "2abffb4e", "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": "8d0e77eb", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }