{ "cells": [ { "cell_type": "markdown", "id": "438b98d2", "metadata": {}, "source": [ "# Import Ports\n", "This example shows how to import operations. In this example, we are going to\n", "\n", "- Download an example board\n", "- Create a configuration file\n", " - Add a cutout operation\n", "- Import the configuration file" ] }, { "cell_type": "markdown", "id": "5b9e66af", "metadata": {}, "source": [ "## Import the required packages" ] }, { "cell_type": "code", "execution_count": null, "id": "98d2862e", "metadata": {}, "outputs": [], "source": [ "import json\n", "from pathlib import Path\n", "import tempfile\n", "\n", "from ansys.aedt.core.examples.downloads import download_file\n", "\n", "from pyedb import Edb\n", "\n", "AEDT_VERSION = \"2025.1\"\n", "NG_MODE = False\n" ] }, { "cell_type": "markdown", "id": "50addec9", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "b0c79751", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "2e8e11d0", "metadata": {}, "source": [ "## Load example layout and place ports" ] }, { "cell_type": "code", "execution_count": null, "id": "0ffb3e89", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)\n", "ports = [\n", " {\n", " \"name\": \"Port_U1_P\",\n", " \"reference_designator\": \"U1\",\n", " \"positive_terminal\": {\n", " \"net\": \"PCIe_Gen4_TX3_CAP_P\"\n", " },\n", " \"negative_terminal\": {\n", " \"net\": \"GND\"\n", " },\n", " \"type\": \"circuit\"\n", " },\n", " {\n", " \"name\": \"Port_U1_N\",\n", " \"reference_designator\": \"U1\",\n", " \"positive_terminal\": {\n", " \"net\": \"PCIe_Gen4_TX3_CAP_N\"\n", " },\n", " \"negative_terminal\": {\n", " \"net\": \"GND\"\n", " },\n", " \"type\": \"circuit\"\n", " },\n", " {\n", " \"name\": \"Port_X1_P\",\n", " \"reference_designator\": \"X1\",\n", " \"positive_terminal\": {\n", " \"net\": \"PCIe_Gen4_TX3_P\"\n", " },\n", " \"negative_terminal\": {\n", " \"net\": \"GND\"\n", " },\n", " \"type\": \"circuit\"\n", " },\n", " {\n", " \"name\": \"Port_X1_N\",\n", " \"reference_designator\": \"X1\",\n", " \"positive_terminal\": {\n", " \"net\": \"PCIe_Gen4_TX3_N\"\n", " },\n", " \"negative_terminal\": {\n", " \"net\": \"GND\"\n", " },\n", " \"type\": \"circuit\"\n", " }\n", "]\n", "cfg_1 = {\"ports\": ports}" ] }, { "cell_type": "code", "execution_count": null, "id": "8db19e63", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(cfg_1)\n", "edbapp.configuration.run()\n", "edbapp.save()\n", "edb_path = edbapp.edbpath\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "6ed23e19", "metadata": {}, "source": [ "## Cutout by nets" ] }, { "cell_type": "markdown", "id": "0afe02f8", "metadata": {}, "source": [ "Keywords\n", "\n", "- **reference_list**. List of reference nets.\n", "- **Extent_type**. Supported types are `Conforming`, `ConvexHull`, and `Bounding`.\n", "- **signal_list**. List of signal nets to keep.\n", "- **expansion_size**. Expansion size ratio in meters. The default is ``0.002``.\n", "- **use_round_corner**. Whether to use round corners. Defaults to `False`.\n", "- **number_of_threads**. Number of threads to use. Defaults to `4`.\n", "- **extent_defeature**. Simplifies geometry before applying cutout to aid meshing. Only applies to Conforming bounding box. Defaults to `0` (disabled).\n", "- **remove_single_pin_components**. Removes all single-pin RLCs after cutout. Defaults to `False`.\n", "- **custom_extent**. List of points defining the custom cutout shape. Overrides the `extent_type` setting.\n", "- **custom_extent_units**. Units of the custom extent points. Defaults to `\"mm\"`. Only valid if `custom_extent` is provided.\n", "- **include_partial_instances**. Includes padstacks with bounding boxes intersecting the custom shape. May slow down export. Only valid with `custom_extent` and `use_pyaedt_cutout`.\n", "- **keep_voids**. Whether to keep voids intersecting the cutout polygon. Defaults to `True`. Valid only if `custom_extent` is provided.\n", "- **check_terminals**. Expands extent to include reference terminals of components with associated models.\n", "- **include_pingroups**. Includes terminals of pingroups. Requires `check_terminals` to be `True`.\n", "- **expansion_factor**. Computes the maximum between dielectric thickness and trace width (for nets with ports) multiplied by this factor. Defaults to `0` (disabled). Works only with `use_pyaedt_cutout`.\n", "- **maximum_iterations**. Maximum number of iterations allowed for cutout search. Defaults to `10`.\n", "- **preserve_components_with_model**. Preserves all pins of components with associated models (Spice or NPort). Only applicable for PyAEDT cutouts (excluding point list).\n", "- **simple_pad_check**. Uses pad center for intersection detection instead of bounding box. Defaults to `True`. Bounding box method is slower and disables multithreading.\n", "- **keep_lines_as_path**. Keeps lines as `Path` instead of converting to `PolygonData`. Only works in Electronics Desktop (3D Layout). May cause issues in SiWave. Defaults to `False`.\n", "- **include_voids_in_extents**. Includes voids in the computed extent (for Conforming only). May affect performance. Defaults to `False`." ] }, { "cell_type": "code", "execution_count": null, "id": "237eea59", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "1e8a462d", "metadata": {}, "outputs": [], "source": [ "cutout = {\n", " \"reference_list\": [\"GND\"],\n", " \"extent_type\": \"ConvexHull\",\n", " \"signal_list\": [\n", " \"PCIe_Gen4_TX3_CAP_P\",\n", " \"PCIe_Gen4_TX3_CAP_N\",\n", " \"PCIe_Gen4_TX3_P\",\n", " \"PCIe_Gen4_TX3_N\"\n", " ]\n", "}\n", "operations = {\"cutout\": cutout}\n", "cfg = {\"operations\": operations}" ] }, { "cell_type": "markdown", "id": "9cf68fef", "metadata": {}, "source": [ "Write configuration into as json file" ] }, { "cell_type": "code", "execution_count": null, "id": "0282ec83", "metadata": {}, "outputs": [], "source": [ "file_json = Path(temp_folder.name) / \"cutout_1.json\"\n", "with open(file_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "23d9c23d", "metadata": {}, "source": [ "Apply cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "8906a15b", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(edb_path, edbversion=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=file_json)\n", "edbapp.configuration.run()\n", "edbapp.nets.plot()\n", "edbapp.close()" ] }, { "cell_type": "markdown", "id": "a517cd78", "metadata": {}, "source": [ "## Cutout with auto net identification" ] }, { "cell_type": "markdown", "id": "85d0fe87", "metadata": {}, "source": [ "Keywords\n", "\n", "- **auto_identify_nets**. Identify nets connected to ports\n", " - **enabled**. Resistance threshold. Resistor with value below this threshold is considered as short circuit\n", " - **resistor_below**. Resistance threshold. Resistor with value below this threshold is considered as short circuit\n", " - **inductor_below**. Inductor threshold. Inductor with value below this threshold is considered as short circuit\n", " - **capacitor_above**. Capacitor threshold. Capacitor with value below this threshold is considered as short circuit" ] }, { "cell_type": "code", "execution_count": null, "id": "3ff1a66a", "metadata": {}, "outputs": [], "source": [ "cutout = {\n", " \"auto_identify_nets\": {\n", " \"enabled\": True,\n", " \"resistor_below\": 100,\n", " \"inductor_below\": 1,\n", " \"capacitor_above\": 1\n", " },\n", " \"reference_list\": [\"GND\"],\n", " \"extent_type\": \"ConvexHull\"\n", "}\n", "operations = {\"cutout\": cutout}\n", "cfg = {\"operations\": operations}" ] }, { "cell_type": "markdown", "id": "801325a2", "metadata": {}, "source": [ "Write configuration into as json file" ] }, { "cell_type": "code", "execution_count": null, "id": "f2c29b83", "metadata": {}, "outputs": [], "source": [ "file_json = Path(temp_folder.name) / \"cutout_2.json\"\n", "with open(file_json, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "4e1701be", "metadata": {}, "source": [ "Apply cutout" ] }, { "cell_type": "code", "execution_count": null, "id": "63b7aa5b", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(edb_path, edbversion=AEDT_VERSION)\n", "edbapp.configuration.load(config_file=file_json)\n", "edbapp.configuration.run()\n", "edbapp.nets.plot()\n", "edbapp.close()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }