{ "cells": [ { "cell_type": "markdown", "id": "135c776a", "metadata": {}, "source": [ "# Import Component Definitions\n", "This example shows how to import component definitions. It includes\n", "\n", "- Download an example board\n", "- Create a config file with component RLC and solder ball information\n", "- Apply the config file to the example board" ] }, { "cell_type": "markdown", "id": "79bf3540", "metadata": {}, "source": [ "## Import the required packages" ] }, { "cell_type": "code", "execution_count": null, "id": "d1f027d4", "metadata": {}, "outputs": [], "source": [ "import json\n", "from pathlib import Path\n", "import tempfile\n", "\n", "from IPython.display import display\n", "from ansys.aedt.core.downloads import download_file\n", "import pandas as pd\n", "\n", "from pyedb import Edb\n", "\n", "AEDT_VERSION = \"2024.2\"\n" ] }, { "cell_type": "markdown", "id": "fbdac3da", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "4236476d", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\").name\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", destination=temp_folder)" ] }, { "cell_type": "markdown", "id": "6eac6ae4", "metadata": {}, "source": [ "## Load example layout." ] }, { "cell_type": "code", "execution_count": null, "id": "f02d644e", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "dfb45238", "metadata": {}, "source": [ "## Create a config file with component information" ] }, { "cell_type": "markdown", "id": "7bd123d1", "metadata": {}, "source": [ "Keywords\n", "\n", "- **reference_designator**. Reference designator of the component.\n", "- **part_type**. Part type of the component. Supported types are 'resistor', 'inductor', 'capacitor', 'ic', 'io',\n", "'other'.\n", "- **enabled**. Only available for RLC components.\n", "- **solder_ball_properties**.\n", " - **shape**. Supported types are 'cylinder', 'spheroid', 'none'.\n", " - **diameter**.\n", " - **mid_diameter**.\n", " - **height**.\n", " - **material**.\n", "- **port_properties**.\n", " - **reference_offset**.\n", " - **reference_size_auto**.\n", " - **reference_size_x**.\n", " - **reference_size_y**.\n", "- **pin_pair_model**. RLC network. Multiple pin pairs are supported.\n", " - **first_pin**. First pin of the pin pair.\n", " - **second_pin**. Second pin of the pin pair.\n", " - **is_parallel**.\n", " - **resistance**.\n", " - **resistance_enabled**.\n", " - **inductance**.\n", " - **inductance_enabled**.\n", " - **capacitance**.\n", " - **capacitance_enabled**." ] }, { "cell_type": "code", "execution_count": null, "id": "ce5defda", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"components\"] = [\n", " {\n", " \"reference_designator\": \"U1\",\n", " \"part_type\": \"io\",\n", " \"solder_ball_properties\": {\n", " \"shape\": \"spheroid\",\n", " \"diameter\": \"244um\",\n", " \"mid_diameter\": \"400um\",\n", " \"height\": \"300um\",\n", " \"material\": \"air\",\n", " },\n", " \"port_properties\": {\n", " \"reference_offset\": \"0.1mm\",\n", " \"reference_size_auto\": True,\n", " \"reference_size_x\": 0,\n", " \"reference_size_y\": 0,\n", " },\n", " },\n", " {\n", " \"reference_designator\": \"C375\",\n", " \"enabled\": False,\n", " \"pin_pair_model\": [\n", " {\n", " \"first_pin\": \"1\",\n", " \"second_pin\": \"2\",\n", " \"is_parallel\": False,\n", " \"resistance\": \"10ohm\",\n", " \"resistance_enabled\": True,\n", " \"inductance\": \"1nH\",\n", " \"inductance_enabled\": False,\n", " \"capacitance\": \"10nF\",\n", " \"capacitance_enabled\": True,\n", " }\n", " ],\n", " },\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "8e771812", "metadata": {}, "outputs": [], "source": [ "display(pd.DataFrame(data=[cfg[\"components\"][0][\"solder_ball_properties\"]]))" ] }, { "cell_type": "code", "execution_count": null, "id": "66e05305", "metadata": {}, "outputs": [], "source": [ "display(pd.DataFrame(data=[cfg[\"components\"][0][\"port_properties\"]]))" ] }, { "cell_type": "code", "execution_count": null, "id": "dbfc98fb", "metadata": {}, "outputs": [], "source": [ "display(pd.DataFrame(data=cfg[\"components\"][1][\"pin_pair_model\"]))" ] }, { "cell_type": "code", "execution_count": null, "id": "8a91005d", "metadata": {}, "outputs": [], "source": [ "cfg_file_path = Path(temp_folder) / \"cfg.json\"\n", "with open(cfg_file_path, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "789a896b", "metadata": {}, "source": [ "Load config file" ] }, { "cell_type": "code", "execution_count": null, "id": "52e73c42", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(cfg_file_path, apply_file=True)" ] }, { "cell_type": "markdown", "id": "52460cfd", "metadata": {}, "source": [ "## Save and close Edb\n", "The temporary folder will be deleted once the execution of this script is finished. Replace **edbapp.save()** with\n", "**edbapp.save_as(\"C:/example.aedb\")** to keep the example project." ] }, { "cell_type": "code", "execution_count": null, "id": "c05db3d7", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }