{ "cells": [ { "cell_type": "markdown", "id": "dc38863d", "metadata": {}, "source": [ "# Multi-zone simulation with SIwave\n", "\n", "This example shows how to simulate multiple zones with SIwave.\n", "\n", "Keywords: **Circuit**, **multi-zone**." ] }, { "cell_type": "markdown", "id": "c8e1bca8", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports, which includes importing a section." ] }, { "cell_type": "code", "execution_count": null, "id": "bf095289", "metadata": {}, "outputs": [], "source": [ "import os.path\n", "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "from ansys.aedt.core import Circuit, Edb\n" ] }, { "cell_type": "markdown", "id": "c16456c4", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "f8287b3e", "metadata": {}, "outputs": [], "source": [ "EDB_VERSION = \"2024.2\"" ] }, { "cell_type": "markdown", "id": "76676566", "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": "77caeda1", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "a69338e4", "metadata": {}, "source": [ "## Download EDB folder" ] }, { "cell_type": "code", "execution_count": null, "id": "cea338e7", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "edb_file = ansys.aedt.core.downloads.download_file(\n", " directory=\"edb/siwave_multi_zones.aedb\", destination=temp_folder.name\n", ")\n", "work_folder = os.path.join(temp_folder.name, \"work\")\n", "aedt_file = os.path.splitext(edb_file)[0] + \".aedt\"\n", "circuit_project_file = os.path.join(temp_folder.name, \"multizone_clipped_circuit.aedt\")\n", "print(edb_file)" ] }, { "cell_type": "markdown", "id": "b984fe5a", "metadata": { "lines_to_next_cell": 2 }, "source": [ "## Set AEDT version" ] }, { "cell_type": "code", "execution_count": null, "id": "d47dfc9c", "metadata": {}, "outputs": [], "source": [ "edb_version = EDB_VERSION" ] }, { "cell_type": "markdown", "id": "7a610439", "metadata": {}, "source": [ "## Define ground net\n", "\n", "Define the common reference net used across all subdesigns, which is mandatory for this workflow." ] }, { "cell_type": "code", "execution_count": null, "id": "a775d1e7", "metadata": {}, "outputs": [], "source": [ "common_reference_net = \"GND\"" ] }, { "cell_type": "markdown", "id": "9a0fc467", "metadata": {}, "source": [ "## Load project\n", "\n", "Check if the AEDT file exists and remove it to allow EDB loading. Then, load the initial EDB file." ] }, { "cell_type": "code", "execution_count": null, "id": "557045f9", "metadata": {}, "outputs": [], "source": [ "if os.path.isfile(aedt_file):\n", " os.remove(aedt_file)\n", "edb = Edb(edbversion=edb_version, edbpath=edb_file)" ] }, { "cell_type": "markdown", "id": "9136a7d2", "metadata": {}, "source": [ "## Copy project zones\n", "\n", "Copy project zone into the subproject." ] }, { "cell_type": "code", "execution_count": null, "id": "ca8b6b79", "metadata": {}, "outputs": [], "source": [ "edb_zones = edb.copy_zones(working_directory=work_folder)" ] }, { "cell_type": "markdown", "id": "70a89796", "metadata": {}, "source": [ "## Split zones\n", "\n", "Clip subdesigns along with corresponding zone definitions\n", "and create a port of clipped signal traces." ] }, { "cell_type": "code", "execution_count": null, "id": "0eff59e3", "metadata": {}, "outputs": [], "source": [ "defined_ports, project_connexions = edb.cutout_multizone_layout(\n", " edb_zones, common_reference_net\n", ")" ] }, { "cell_type": "markdown", "id": "c907284f", "metadata": {}, "source": [ "## Create circuit\n", "\n", "Create circuit design, import all subprojects as EM models, and connect\n", "all corresponding pins in the circuit." ] }, { "cell_type": "code", "execution_count": null, "id": "40186a09", "metadata": {}, "outputs": [], "source": [ "circuit = Circuit(version=edb_version, project=circuit_project_file)\n", "circuit.connect_circuit_models_from_multi_zone_cutout(\n", " project_connections=project_connexions,\n", " edb_zones_dict=edb_zones,\n", " ports=defined_ports,\n", " model_inc=70,\n", ")" ] }, { "cell_type": "markdown", "id": "7e0493bb", "metadata": {}, "source": [ "## Set up simulation\n", "\n", "Add Nexxim LNA simulation setup." ] }, { "cell_type": "code", "execution_count": null, "id": "718299a3", "metadata": {}, "outputs": [], "source": [ "circuit_setup = circuit.create_setup(\"Pyedt_LNA\")" ] }, { "cell_type": "markdown", "id": "627a9a81", "metadata": {}, "source": [ "## Add frequency sweep\n", "\n", "Add a frequency sweep from 0 GHt to 20 GHz with a 10 NHz frequency step." ] }, { "cell_type": "code", "execution_count": null, "id": "b287a8e4", "metadata": {}, "outputs": [], "source": [ "circuit_setup.props[\"SweepDefinition\"][\"Data\"] = \"LIN {} {} {}\".format(\n", " \"0GHz\", \"20GHz\", \"10MHz\"\n", ")" ] }, { "cell_type": "markdown", "id": "46cb451c", "metadata": {}, "source": [ "## Start simulation\n", "\n", "Analyze all SIwave projects and solve the circuit." ] }, { "cell_type": "code", "execution_count": null, "id": "70a80500", "metadata": {}, "outputs": [], "source": [ "circuit.analyze()" ] }, { "cell_type": "markdown", "id": "6e498f17", "metadata": {}, "source": [ "Define differential pairs" ] }, { "cell_type": "code", "execution_count": null, "id": "6a33044b", "metadata": {}, "outputs": [], "source": [ "circuit.set_differential_pair(\n", " differential_mode=\"U0\",\n", " assignment=\"U0.via_38.B2B_SIGP\",\n", " reference=\"U0.via_39.B2B_SIGN\",\n", ")\n", "circuit.set_differential_pair(\n", " differential_mode=\"U1\",\n", " assignment=\"U1.via_32.B2B_SIGP\",\n", " reference=\"U1.via_33.B2B_SIGN\",\n", ")" ] }, { "cell_type": "markdown", "id": "46b8922b", "metadata": {}, "source": [ "Plot results." ] }, { "cell_type": "code", "execution_count": null, "id": "2e1770de", "metadata": {}, "outputs": [], "source": [ "circuit.post.create_report(\n", " expressions=[\"dB(S(U0,U0))\", \"dB(S(U1,U0))\"], context=\"Differential Pairs\"\n", ")" ] }, { "cell_type": "markdown", "id": "b6a1aad0", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "185bd3e6", "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": "cefe9a23", "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": "0543ded1", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }