{ "cells": [ { "cell_type": "markdown", "id": "86b4b44f", "metadata": {}, "source": [ "# Circuit Netlist to Schematic\n", "\n", "This example shows how to create components\n", "in the circuit schematic editor from a netlist file.\n", "\n", "Note that HSPICE files are fully supported and that broad coverage is provided for many other formats.\n", "\n", "Keywords: **Circuit**, **netlist**." ] }, { "cell_type": "markdown", "id": "bfa4f0d6", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Import the required packages." ] }, { "cell_type": "code", "execution_count": null, "id": "92346b20", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "from ansys.aedt.core.examples.downloads import download_netlist" ] }, { "cell_type": "markdown", "id": "a5a77f65", "metadata": {}, "source": [ "## Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "9681bb4a", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "bc033983", "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": "bfd56d62", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "58753271", "metadata": {}, "source": [ "## Launch AEDT with Circuit\n", "\n", "Launch AEDT with Circuit. The `ansys.aedt.core.Desktop` class initializes AEDT\n", "and starts it on the specified version in the specified graphical mode." ] }, { "cell_type": "code", "execution_count": null, "id": "40315ba6", "metadata": {}, "outputs": [], "source": [ "netlist = download_netlist(local_path=temp_folder.name)\n", "circuit = ansys.aedt.core.Circuit(\n", " project=os.path.join(temp_folder.name, \"NetlistExample\"),\n", " version=AEDT_VERSION,\n", " non_graphical=NG_MODE,\n", " new_desktop=True,\n", ")" ] }, { "cell_type": "markdown", "id": "2449f50c", "metadata": {}, "source": [ "## Define a parameter\n", "\n", "Specify the voltage as a parameter." ] }, { "cell_type": "code", "execution_count": null, "id": "f0c5a963", "metadata": {}, "outputs": [], "source": [ "circuit[\"Voltage\"] = \"5\"" ] }, { "cell_type": "markdown", "id": "4b3bff27", "metadata": {}, "source": [ "## Create schematic from netlist file\n", "\n", "Create a schematic from a netlist file. The ``create_schematic_from_netlist()``\n", "method reads the netlist file and parses it. All components are parsed,\n", "but only these categories are mapped: R, L, C, Q, U, J, V, and I." ] }, { "cell_type": "code", "execution_count": null, "id": "58e5e84a", "metadata": {}, "outputs": [], "source": [ "circuit.create_schematic_from_netlist(netlist)" ] }, { "cell_type": "markdown", "id": "656e219e", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "2bb985fe", "metadata": {}, "outputs": [], "source": [ "circuit.save_project()\n", "circuit.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": "2db20dc2", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``. If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "97237387", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }