{ "cells": [ { "cell_type": "markdown", "id": "76cb448f", "metadata": {}, "source": [ "# Power integrity analysis\n", "This example shows how to use the Ansys Electronics Database (EDB) for power integrity analysis. The\n", "EDB is loaded into HFSS 3D Layout for analysis and postprocessing.\n", "\n", "- Set up EDB consists of these steps:\n", "\n", " - Assign S-parameter model to components.\n", " - Create pin groups.\n", " - Create ports.\n", " - Create SIwave SYZ analysis.\n", " - Create cutout.\n", "\n", "- Import EDB into HFSS 3D Layout:\n", "\n", " - Analyze.\n", " - Plot ``$Z_{11}$``.\n", "\n", "Keywords: **HFSS 3D Layout**, **power integrity**." ] }, { "cell_type": "markdown", "id": "9abd2fd9", "metadata": {}, "source": [ "## Perform imports and define constants\n", "Import the required packages" ] }, { "cell_type": "code", "execution_count": null, "id": "4c46be1b", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "5de2837a", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core\n", "from ansys.aedt.core.downloads import download_file" ] }, { "cell_type": "markdown", "id": "1d1f4c90", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "5c9ae623", "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": "9ce45a38", "metadata": {}, "source": [ "## Create temporary directory\n", "\n", "Create a temporary directory where downloaded data or\n", "dumped data can be stored.\n", "If you'd like to retrieve the project data for subsequent use,\n", "the temporary folder name is given by ``temp_folder.name``." ] }, { "cell_type": "code", "execution_count": null, "id": "2daedaad", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "4467f97c", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "295c2858", "metadata": {}, "outputs": [], "source": [ "aedb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder.name)\n", "download_file(\n", " source=\"touchstone\",\n", " name=\"GRM32_DC0V_25degC_series.s2p\",\n", " destination=temp_folder.name,\n", ")" ] }, { "cell_type": "markdown", "id": "3ecd2b5a", "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": "31f95726", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "080dad98", "metadata": {}, "source": [ "Assigns S-parameter models to capacitors.\n", "The first step is to use the \"general\" key to specify where the S-parameter files can be found." ] }, { "cell_type": "code", "execution_count": null, "id": "0d6b0d4f", "metadata": {}, "outputs": [], "source": [ "cfg[\"general\"] = {\"s_parameter_library\": os.path.join(temp_folder.name, \"touchstone\")}" ] }, { "cell_type": "markdown", "id": "4c8f7918", "metadata": {}, "source": [ "## Assign model to capactitors\n", "The model ``GRM32_DC0V_25degC_series.s2p`` is assigned to capacitors C3 and C4, which share the same component part number.\n", "When \"apply_to_all\" is ``True``, all components having the part number \"CAPC3216X180X20ML20\" are assigned the S-parameter model." ] }, { "cell_type": "code", "execution_count": null, "id": "07e0fa83", "metadata": {}, "outputs": [], "source": [ "cfg[\"s_parameters\"] = [\n", " {\n", " \"name\": \"GRM32_DC0V_25degC_series\",\n", " \"component_definition\": \"CAPC0603X33X15LL03T05\",\n", " \"file_path\": \"GRM32_DC0V_25degC_series.s2p\",\n", " \"apply_to_all\": False,\n", " \"components\": [\"C110\", \"C206\"],\n", " \"reference_net\": \"GND\",\n", " \"reference_net_per_component\": {\"C110\": \"GND\"},\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "ef1ca808", "metadata": { "lines_to_next_cell": 2 }, "source": [ "## Create pin groups\n", "Pins can be grouped explicitly by the pin name, or pin groups can be assigned by net name using the ''net'' key.\n", "The following code combine the listed pins on component U2 into two pin groups using the ``net`` key." ] }, { "cell_type": "code", "execution_count": null, "id": "c050cea1", "metadata": {}, "outputs": [], "source": [ "cfg[\"pin_groups\"] = [\n", " {\n", " \"name\": \"PIN_GROUP_1\",\n", " \"reference_designator\": \"U1\",\n", " \"pins\": [\"AD14\", \"AD15\", \"AD16\", \"AD17\"],\n", " },\n", " {\"name\": \"PIN_GROUP_2\", \"reference_designator\": \"U1\", \"net\": \"GND\"},\n", "]" ] }, { "cell_type": "markdown", "id": "933a07ad", "metadata": {}, "source": [ "## Create ports\n", "Create a circuit port between the two pin groups just created." ] }, { "cell_type": "code", "execution_count": null, "id": "2817771c", "metadata": {}, "outputs": [], "source": [ "cfg[\"ports\"] = [\n", " {\n", " \"name\": \"port1\",\n", " \"reference_designator\": \"U1\",\n", " \"type\": \"circuit\",\n", " \"positive_terminal\": {\"pin_group\": \"PIN_GROUP_1\"},\n", " \"negative_terminal\": {\"pin_group\": \"PIN_GROUP_2\"},\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "65e82ea0", "metadata": {}, "source": [ "## Create SIwave SYZ analysis setup\n", "Both SIwave and HFSS can be used to run an analysis in the 3D Layout user interface." ] }, { "cell_type": "code", "execution_count": null, "id": "ed96e504", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [\n", " {\n", " \"name\": \"siwave_syz\",\n", " \"type\": \"siwave_syz\",\n", " \"pi_slider_position\": 1,\n", " \"freq_sweep\": [\n", " {\n", " \"name\": \"Sweep1\",\n", " \"type\": \"Interpolation\",\n", " \"frequencies\": [\n", " {\n", " \"distribution\": \"log scale\",\n", " \"start\": 1e6,\n", " \"stop\": 1e9,\n", " \"samples\": 20,\n", " }\n", " ],\n", " }\n", " ],\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "be0483eb", "metadata": {}, "source": [ "## Define cutout\n", "Define the region of the PCB to be cut out for analysis." ] }, { "cell_type": "code", "execution_count": null, "id": "226f938e", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\n", " \"signal_list\": [\"1V0\"],\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": "bd09db6b", "metadata": {}, "source": [ "## Save configuration\n", "\n", "Save the configuration file to a JSON file and apply it to layout data using the EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "30864509", "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": "bf64b22b", "metadata": {}, "source": [ "## Load configuration into EDB" ] }, { "cell_type": "markdown", "id": "309060ca", "metadata": {}, "source": [ "Load the configuration into EDB from the JSON file." ] }, { "cell_type": "code", "execution_count": null, "id": "87b5de73", "metadata": {}, "outputs": [], "source": [ "edbapp = ansys.aedt.core.Edb(aedb, edbversion=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=pi_json)\n", "edbapp.configuration.run()\n", "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "0bffb9d9", "metadata": {}, "source": [ "The configured EDB file is saved in the temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "1de46141", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "8084d7b7", "metadata": {}, "source": [ "## Analyze in HFSS 3D Layout" ] }, { "cell_type": "markdown", "id": "7a4160d6", "metadata": {}, "source": [ "### Load EDB into HFSS 3D Layout" ] }, { "cell_type": "code", "execution_count": null, "id": "7665cf28", "metadata": {}, "outputs": [], "source": [ "h3d = ansys.aedt.core.Hfss3dLayout(\n", " aedb, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True\n", ")" ] }, { "cell_type": "markdown", "id": "69625177", "metadata": {}, "source": [ "### Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "09179f43", "metadata": {}, "outputs": [], "source": [ "h3d.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "fe8379b8", "metadata": {}, "source": [ "### Plot impedance" ] }, { "cell_type": "code", "execution_count": null, "id": "3ab835cc", "metadata": {}, "outputs": [], "source": [ "solutions = h3d.post.get_solution_data(expressions=\"Z(port1,port1)\")\n", "solutions.plot()" ] }, { "cell_type": "markdown", "id": "2d4454a2", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "2d635c9a", "metadata": {}, "outputs": [], "source": [ "h3d.save_project()\n", "h3d.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": "41708c5f", "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": "9b1f3661", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }