{ "cells": [ { "cell_type": "markdown", "id": "009f98c3", "metadata": {}, "source": [ "# HFSS to EMIT Coupling\n", "\n", "This example shows how to link an HFSS design\n", "to EMIT and model RF interference among various components.\n", "\n", "\n", "\n", "> **Note:** This example uses the ``Cell Phone RFI Desense``\n", "> project that is available with the AEDT installation in the\n", "> ``\\Examples\\EMIT\\`` directory.\n", "\n", "Keywords: **EMIT**, **Coupling**." ] }, { "cell_type": "markdown", "id": "20f2ad86", "metadata": {}, "source": [ "## Prerequisites\n", "\n", "### Perform imports" ] }, { "cell_type": "code", "execution_count": null, "id": "490fa070", "metadata": {}, "outputs": [], "source": [ "import os\n", "import shutil\n", "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "from ansys.aedt.core.emit_core.emit_constants import ResultType, TxRxMode\n" ] }, { "cell_type": "markdown", "id": "e61f59f8", "metadata": {}, "source": [ "### Define constants\n", "Constants help ensure consistency and avoid repetition throughout the example." ] }, { "cell_type": "code", "execution_count": null, "id": "bff8e694", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2026.1\"\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "928443a5", "metadata": {}, "source": [ "### Create temporary directory\n", "\n", "Create a temporary working directory.\n", "The name of the working folder is stored in ``temp_folder.name``.\n", "\n", "> **Note:** The final cell in the notebook cleans up the temporary folder. If you want to\n", "> retrieve the AEDT project and data, do so before executing the final cell in the notebook." ] }, { "cell_type": "code", "execution_count": null, "id": "88d68df7", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "b944b769", "metadata": {}, "source": [ "### Launch application\n", "\n", "Launch AEDT with EMIT. The ``Desktop`` class initializes AEDT and starts it\n", "on the specified version and in the specified graphical mode." ] }, { "cell_type": "code", "execution_count": null, "id": "8fd6dc2d", "metadata": {}, "outputs": [], "source": [ "d = ansys.aedt.core.launch_desktop(version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True)" ] }, { "cell_type": "markdown", "id": "c759e420", "metadata": {}, "source": [ "## Model Preparation\n", "\n", "### Copy example files\n", "\n", "Copy the ``Cell Phone RFI Desense`` example data from the\n", "installed ``Examples`` directory to the temporary working\n", "directory.\n", "\n", "> **Note:** The HFSS design from the installed example\n", "> used to model the RF environment\n", "> has been pre-solved. Hence, the results folder is copied and\n", "> the RF interference between transceivers is calculated in EMIT using\n", "> results from the linked HFSS design." ] }, { "cell_type": "code", "execution_count": null, "id": "2e2d2521", "metadata": {}, "outputs": [], "source": [ "file_name = lambda s: s + \".aedt\"\n", "results_name = lambda s: s + \".aedtresults\"\n", "pdf_name = lambda s: s + \" Example.pdf\"" ] }, { "cell_type": "code", "execution_count": null, "id": "c0040edd", "metadata": {}, "outputs": [], "source": [ "example = \"Cell Phone RFI Desense\"\n", "example_dir = os.path.join(d.install_path, \"Examples\\\\EMIT\")\n", "example_project = os.path.join(example_dir, file_name(example))\n", "example_results_folder = os.path.join(example_dir, results_name(example))\n", "example_pdf = os.path.join(example_dir, pdf_name(example))" ] }, { "cell_type": "code", "execution_count": null, "id": "227dd456", "metadata": {}, "outputs": [], "source": [ "project_name = shutil.copyfile(example_project, os.path.join(temp_folder.name, file_name(example)))\n", "results_folder = shutil.copytree(example_results_folder, os.path.join(temp_folder.name, results_name(example)))\n", "project_pdf = shutil.copyfile(example_pdf, os.path.join(temp_folder.name, pdf_name(example)))" ] }, { "cell_type": "markdown", "id": "dd0cbe30", "metadata": {}, "source": [ "Open the project in the working directory." ] }, { "cell_type": "code", "execution_count": null, "id": "ff4d5306", "metadata": {}, "outputs": [], "source": [ "aedtapp = ansys.aedt.core.Emit(project_name, version=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "7f9c6e21", "metadata": {}, "source": [ "### Create and connect EMIT components\n", "\n", "Create two radios with antennas connected to each one." ] }, { "cell_type": "code", "execution_count": null, "id": "d0899de5", "metadata": {}, "outputs": [], "source": [ "rad1, ant1 = aedtapp.schematic.create_radio_antenna(\"Bluetooth Low Energy (LE)\")\n", "rad2, ant2 = aedtapp.schematic.create_radio_antenna(\"Bluetooth Low Energy (LE)\")" ] }, { "cell_type": "markdown", "id": "e2a69fa2", "metadata": {}, "source": [ "### Define coupling among RF systems\n", "\n", "Link and update coupling among the RF systems." ] }, { "cell_type": "code", "execution_count": null, "id": "3758b48c", "metadata": {}, "outputs": [], "source": [ "for link in aedtapp.couplings.linkable_design_names:\n", " aedtapp.couplings.add_link(link)\n", " print('linked \"' + link + '\".')" ] }, { "cell_type": "code", "execution_count": null, "id": "3623a266", "metadata": {}, "outputs": [], "source": [ "for link in aedtapp.couplings.coupling_names:\n", " aedtapp.couplings.update_link(link)\n", " print('linked \"' + link + '\".')" ] }, { "cell_type": "markdown", "id": "17173050", "metadata": {}, "source": [ "### Run analysis\n", "\n", "Run the EMIT simulation to calculate RF interference." ] }, { "cell_type": "code", "execution_count": null, "id": "94905f28", "metadata": {}, "outputs": [], "source": [ "if AEDT_VERSION > \"2023.1\":\n", " rev = aedtapp.results.analyze()" ] }, { "cell_type": "markdown", "id": "c647598b", "metadata": {}, "source": [ "## Postprocess\n", "\n", "Evaluate the worst-case EMI between the two Bluetooth radios." ] }, { "cell_type": "code", "execution_count": null, "id": "fb3cf946", "metadata": {}, "outputs": [], "source": [ "if AEDT_VERSION > \"2023.1\":\n", " rx_bands = rev.get_band_names(radio_node=rad1, tx_rx_mode=TxRxMode.RX)\n", " tx_bands = rev.get_band_names(radio_node=rad2, tx_rx_mode=TxRxMode.TX)\n", " domain = aedtapp.results.interaction_domain()\n", " domain.set_receiver(rad1.name, rx_bands[0], -1)\n", " domain.set_interferer(rad2.name, tx_bands[0])\n", " interaction = rev.run(domain)\n", " worst = interaction.get_worst_instance(ResultType.EMI)\n", " if worst.has_valid_values():\n", " emi = worst.get_value(ResultType.EMI)\n", " print(\"Worst case interference is: {} dB\".format(emi))" ] }, { "cell_type": "markdown", "id": "60db185b", "metadata": {}, "source": [ "## Finish\n", "\n", "### Save the project" ] }, { "cell_type": "code", "execution_count": null, "id": "4a4db581", "metadata": {}, "outputs": [], "source": [ "aedtapp.save_project()\n", "aedtapp.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": "e966c76b", "metadata": {}, "source": [ "### Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``.\n", "If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell\n", "removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "564e3e86", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }