{ "cells": [ { "cell_type": "markdown", "id": "97771df1", "metadata": {}, "source": [ "# Set up EDB for Power Distribution Network Analysis\n", "This example shows how to set up the electronics database (EDB) for power integrity analysis from a single\n", "configuration file." ] }, { "cell_type": "markdown", "id": "da09f032", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "d387e10a", "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "import tempfile\n", "\n", "from ansys.aedt.core import Hfss3dLayout\n", "from ansys.aedt.core.examples.downloads import download_file\n", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "0821e236", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "8f0760d6", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "NG_MODE = False" ] }, { "cell_type": "markdown", "id": "d2b8cb3a", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "8633570b", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "download_file(source=\"touchstone\", name=\"GRM32_DC0V_25degC_series.s2p\", local_path=temp_folder.name)\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "3fb3c737", "metadata": {}, "source": [ "## Load example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "2cdfc80e", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "4b7eb9ad", "metadata": {}, "source": [ "## Create an empty dictionary to host all configurations" ] }, { "cell_type": "code", "execution_count": null, "id": "e15576d8", "metadata": {}, "outputs": [], "source": [ "cfg = dict()" ] }, { "cell_type": "markdown", "id": "4e7749f0", "metadata": {}, "source": [ "## Assign S-parameter model to capactitors." ] }, { "cell_type": "markdown", "id": "6915b166", "metadata": {}, "source": [ "Set S-parameter library path." ] }, { "cell_type": "code", "execution_count": null, "id": "fbb252c5", "metadata": {}, "outputs": [], "source": [ "cfg[\"general\"] = {\"s_parameter_library\": os.path.join(temp_folder.name, \"touchstone\")}" ] }, { "cell_type": "markdown", "id": "7f624be0", "metadata": {}, "source": [ "Assign the S-parameter model.\n", "\n", "Keywords\n", "\n", "- **name**. Name of the S-parameter model in AEDT.\n", "- **component**_definition. Known as component part number of part name.\n", "- **file_path**. Touchstone file or full path to the touchstone file.\n", "- **apply_to_all**. When set to True, assign the S-parameter model to all components share the same\n", "component_definition. When set to False, Only components in \"components\" are assigned.\n", "- **components**. when apply_to_all=False, components in the list are assigned an S-parameter model.\n", "When apply_to_all=False, components in the list are NOT assigned.\n", "- **reference_net**. Reference net of the S-parameter model." ] }, { "cell_type": "code", "execution_count": null, "id": "f3e66222", "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", " }\n", "]" ] }, { "cell_type": "markdown", "id": "d70724e9", "metadata": {}, "source": [ "## Define ports\n", "Create a circuit port between power and ground nets.\n", "\n", "Keywords\n", "\n", "- **name**. Name of the port.\n", "- **reference_desinator**.\n", "- **type**. Type of the port. Supported types are 'ciruict', 'coax'.\n", "- **positive_terminal**. Positive terminal of the port. Supported types are 'net', 'pin', 'pin_group', 'coordinates'.\n", "- **negative_terminal**. Positive terminal of the port. Supported types are 'net', 'pin', 'pin_group', 'coordinates'." ] }, { "cell_type": "code", "execution_count": null, "id": "da192ddd", "metadata": {}, "outputs": [], "source": [ "cfg[\"ports\"] = [\n", " {\n", " \"name\": \"port1\",\n", " \"reference_designator\": \"U1\",\n", " \"type\": \"circuit\",\n", " \"positive_terminal\": {\"net\": \"1V0\"},\n", " \"negative_terminal\": {\"net\": \"GND\"},\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "2866ae19", "metadata": {}, "source": [ "## Define SIwave SYZ analysis setup\n", "\n", "Keywords\n", "\n", "- **name**. Name of the setup.\n", "- **type**. Type of the analysis setup. Supported types are 'siwave_ac', 'siwave_dc', 'hfss'.\n", "- **pi_slider_position**. PI slider position. Supported values are from '0', '1', '2'. 0:speed, 1:balanced,\n", "2:accuracy.\n", "- **freq_sweep**. List of frequency sweeps.\n", " - **name**. Name of the sweep.\n", " - **type**. Type of the sweep. Supported types are 'interpolation', 'discrete', 'broadband'.\n", " - **frequencies**. Frequency distribution.\n", " - **distribution**. Supported distributions are 'linear_count', 'linear_scale', 'log_scale'.\n", " - **start**. Start frequency. Example, 1e6, \"1MHz\".\n", " - **stop**. Stop frequency. Example, 1e9, \"1GHz\".\n", " - **increment**." ] }, { "cell_type": "code", "execution_count": null, "id": "e4b49f9c", "metadata": {}, "outputs": [], "source": [ "cfg[\"setups\"] = [\n", " {\n", " \"name\": \"siwave_syz\",\n", " \"type\": \"siwave_ac\",\n", " \"pi_slider_position\": 1,\n", " \"freq_sweep\": [\n", " {\n", " \"name\": \"Sweep1\",\n", " \"type\": \"interpolation\",\n", " \"frequencies\": [{\"distribution\": \"log_scale\", \"start\": 1e6, \"stop\": 1e9, \"increment\": 20}],\n", " }\n", " ],\n", " }\n", "]" ] }, { "cell_type": "markdown", "id": "7062ddb9", "metadata": {}, "source": [ "## Define Cutout\n", "\n", "Keywords\n", "\n", "- **signal_list**. List of nets to be kept after cutout.\n", "- **reference_list**. List of nets as reference planes.\n", "- **extent_type**. Supported extend types are 'Conforming', 'ConvexHull', 'Bounding'.\n", "For optional input arguments, refer to method pyedb.Edb.cutout()" ] }, { "cell_type": "code", "execution_count": null, "id": "73a50316", "metadata": {}, "outputs": [], "source": [ "cfg[\"operations\"] = {\n", " \"cutout\": {\n", " \"signal_list\": [\"1V0\"],\n", " \"reference_list\": [\"GND\"],\n", " \"extent_type\": \"ConvexHull\",\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "d40ea67e", "metadata": {}, "source": [ "## Write configuration into as json file" ] }, { "cell_type": "code", "execution_count": null, "id": "c2781005", "metadata": {}, "outputs": [], "source": [ "file_json = os.path.join(temp_folder.name, \"edb_configuration.json\")\n", "with open(file_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "4487b08e", "metadata": {}, "source": [ "## Import configuration into example layout" ] }, { "cell_type": "code", "execution_count": null, "id": "f6f8ea4a", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(config_file=file_json)" ] }, { "cell_type": "markdown", "id": "50c0642a", "metadata": {}, "source": [ "Apply configuration to EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "97b55276", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.run()" ] }, { "cell_type": "markdown", "id": "6207325c", "metadata": {}, "source": [ "Save and close EDB." ] }, { "cell_type": "code", "execution_count": null, "id": "584203e8", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "c31d2558", "metadata": {}, "source": [ "The configured EDB file is saved in a temp folder." ] }, { "cell_type": "code", "execution_count": null, "id": "9d17886b", "metadata": {}, "outputs": [], "source": [ "print(temp_folder.name)" ] }, { "cell_type": "markdown", "id": "2863adf3", "metadata": {}, "source": [ "## Load edb into HFSS 3D Layout." ] }, { "cell_type": "code", "execution_count": null, "id": "44eeb521", "metadata": {}, "outputs": [], "source": [ "h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "bfa0b175", "metadata": {}, "source": [ "## Analyze" ] }, { "cell_type": "code", "execution_count": null, "id": "f2c0be34", "metadata": {}, "outputs": [], "source": [ "h3d.analyze()" ] }, { "cell_type": "markdown", "id": "500ba029", "metadata": {}, "source": [ "## Plot impedance" ] }, { "cell_type": "code", "execution_count": null, "id": "ded435a8", "metadata": {}, "outputs": [], "source": [ "solutions = h3d.post.get_solution_data(expressions=\"Z(port1,port1)\")\n", "solutions.plot()" ] }, { "cell_type": "markdown", "id": "00b66390", "metadata": {}, "source": [ "## Shut Down Electronics Desktop" ] }, { "cell_type": "code", "execution_count": null, "id": "0e9539e9", "metadata": {}, "outputs": [], "source": [ "h3d.close_desktop()" ] }, { "cell_type": "markdown", "id": "69c7d79c", "metadata": {}, "source": [ "All project files are saved in the folder ``temp_file.dir``. If you've run this example as a Jupyter notebook you\n", "can retrieve those project files." ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }