{ "cells": [ { "cell_type": "markdown", "id": "7bcbe069", "metadata": {}, "source": [ "# Antenna\n", "\n", "This example shows how to create a project in EMIT for\n", "the simulation of an antenna using HFSS.\n", "\n", "\n", "\n", "Keywords: **EMIT**, **Antenna**." ] }, { "cell_type": "markdown", "id": "d355fc44", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "77410b5e", "metadata": {}, "outputs": [], "source": [ "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "\n", "from ansys.aedt.core.emit_core.emit_constants import ResultType, TxRxMode\n", "from ansys.aedt.core.emit_core.nodes.generated import AntennaNode, RadioNode" ] }, { "cell_type": "markdown", "id": "311ec505", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "0f76cf25", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.2\"\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "c793e1f2", "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": "9cc4174f", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "0a06f606", "metadata": {}, "source": [ "## Launch AEDT with EMIT\n", "\n", "Launch AEDT with EMIT. The ``launch_desktop()`` method initializes AEDT\n", "using the specified version. The second argument can be set to ``True`` to\n", "run AEDT in non-graphical mode." ] }, { "cell_type": "code", "execution_count": null, "id": "c2e5dbc0", "metadata": {}, "outputs": [], "source": [ "project_name = ansys.aedt.core.generate_unique_project_name(root_name=temp_folder.name, project_name=\"antenna_cosite\")\n", "d = ansys.aedt.core.launch_desktop(AEDT_VERSION, NG_MODE, new_desktop=True)\n", "aedtapp = ansys.aedt.core.Emit(project_name, version=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "ea6c14f8", "metadata": {}, "source": [ "## Create and connect EMIT components\n", "\n", "Create three radios and connect an antenna to each one." ] }, { "cell_type": "code", "execution_count": null, "id": "5b0b9b9c", "metadata": {}, "outputs": [], "source": [ "rad1: RadioNode = aedtapp.schematic.create_component(\"New Radio\")\n", "ant1: AntennaNode = aedtapp.schematic.create_component(\"Antenna\")\n", "if rad1 and ant1:\n", " aedtapp.schematic.connect_components(rad1.name, ant1.name)" ] }, { "cell_type": "markdown", "id": "1fb64a78", "metadata": {}, "source": [ "## Place radio/antenna pair\n", "\n", "Use the ``create_radio_antenna()`` method to place the radio/antenna pair. The first\n", "argument is the type of radio. The second argument is the name to\n", "assign to the radio." ] }, { "cell_type": "code", "execution_count": null, "id": "148e3db6", "metadata": {}, "outputs": [], "source": [ "rad2, ant2 = aedtapp.schematic.create_radio_antenna(\"GPS Receiver\")\n", "rad3, ant3 = aedtapp.schematic.create_radio_antenna(\"Bluetooth Low Energy (LE)\", \"Bluetooth\")" ] }, { "cell_type": "markdown", "id": "3d6e8859", "metadata": { "lines_to_next_cell": 2 }, "source": [ "## Define the RF environment\n", "\n", "Specify the RF coupling among antennas.\n", "This functionality is not yet implemented in the API, but it can be entered from the UI.\n", "\n", "" ] }, { "cell_type": "markdown", "id": "0121048b", "metadata": {}, "source": [ "## Run EMIT simulation\n", "\n", "Run the EMIT simulation.\n", "\n", "This part of the example requires Ansys AEDT 2023 R2." ] }, { "cell_type": "code", "execution_count": null, "id": "b7d3eec5", "metadata": {}, "outputs": [], "source": [ "# > **Note:** You can uncomment the following code.\n", "#\n", "if AEDT_VERSION > \"2023.1\":\n", " rev = aedtapp.results.analyze()\n", " rx_bands = rev.get_band_names(radio_name=rad2.name, tx_rx_mode=TxRxMode.RX)\n", " tx_bands = rev.get_band_names(radio_name=rad3.name, tx_rx_mode=TxRxMode.TX)\n", " domain = aedtapp.results.interaction_domain()\n", " domain.set_receiver(rad2.name, rx_bands[0], -1)\n", " domain.set_interferer(rad3.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": "1d91ba2a", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "0c56678e", "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": "31195f84", "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": "c47e6d1d", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }