EMIT: Hfss Coupling Example#

This tutorial shows how you can use PyAEDT to open an AEDT project with an HFSS design, create an EMIT design in the project, then link the HFSS design as a coupling link in the EMIT design.

# sphinx_gallery_thumbnail_path = 'Resources/emit.png'
import os
import tempfile

# Import required modules
from pyaedt.generic.filesystem import Scratch

from pyaedt import Emit
from pyaedt import Desktop

Initialization Settings#

Change NonGraphical Boolean to False to open AEDT in graphical mode With NewThread = False, an existing instance of AEDT will be used, if available. This example will use AEDT 2022.2 However this example is supposed to work on AEDT 2022R2 and on.

non_graphical = os.getenv("PYAEDT_NON_GRAPHICAL", "False").lower() in ("true", "1", "t")
NewThread = True
desktop_version = "2022.2"
scratch_path = tempfile.gettempdir()

Launch AEDT and EMIT Design#

Desktop class initializes AEDT and starts it on specified version and specified graphical mode. NewThread Boolean variable defines if a user wants to create a new instance of AEDT or try to connect to existing instance of it.

d = Desktop(desktop_version, non_graphical, NewThread)

temp_folder = os.path.join(scratch_path, ("EmitHFSSExample"))
if not os.path.exists(temp_folder):

example_name = "Cell Phone RFI Desense"
example_aedt = example_name + ".aedt"
example_lock = example_aedt + ".lock"
example_pdf_file = example_name + " Example.pdf"

example_dir = os.path.join(d.install_path, "Examples\\EMIT")
example_project = os.path.join(example_dir, example_aedt)
example_pdf = os.path.join(example_dir, example_pdf_file)

# If the Cell phone example is not in the install dir, exit from this example.
if not os.path.exists(example_project):
    msg = """
        Cell phone RFT Desense example file is not in the
         Examples/EMIT directory under the EDT installation. You can not run this example.
    d.release_desktop(True, True)

my_project = os.path.join(temp_folder, example_aedt)
my_project_lock = os.path.join(temp_folder, example_lock)
my_project_pdf = os.path.join(temp_folder, example_pdf_file)

if os.path.exists(my_project):

if os.path.exists(my_project_lock):

with Scratch(scratch_path) as local_scratch:
    local_scratch.copyfile(example_project, my_project)
    if os.path.exists(example_pdf):
        local_scratch.copyfile(example_pdf, my_project_pdf)

aedtapp = Emit(my_project)


pyaedt info: Logger Started
pyaedt info: Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet
pyaedt info: AEDT installation Path C:\Program Files\AnsysEM\v222\Win64.
pyaedt info: Launching AEDT with module Pythonnet.
pyaedt info: Ansoft.ElectronicsDesktop.2022.2 Started with process ID 5160.
pyaedt info: Logger file D:\Temp\pyaedt20220624_103520.log in use.
pyaedt info: pyaedt v0.4.87
pyaedt info: Python version 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
pyaedt info: Project Cell Phone RFI Desense has been opened.
pyaedt info: Active Design set to EMIT Design1
# Create and Connect EMIT Components
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create 3 radios and connect an antenna to each.
rad1 = aedtapp.modeler.components.create_component("UE - Handheld")
ant1 = aedtapp.modeler.components.create_component("Antenna")
if rad1 and ant1:

rad2 = aedtapp.modeler.components.create_component("GPS Receiver")
ant2 = aedtapp.modeler.components.create_component("Antenna")
if rad2 and ant2:

Define Coupling Among the RF Systems#

for link in aedtapp.couplings.linkable_design_names:

for link in aedtapp.couplings.coupling_names:

Run the EMIT Simulation#

This portion of the EMIT API is not yet implemented.

Close Desktop#

After the simulaton is completed user can close the desktop or release it (using release_desktop method). All methods give possibility to save projects before exit.

aedtapp.release_desktop(close_projects=True, close_desktop=True)


pyaedt info: Project Cell Phone RFI Desense Saved correctly


Total running time of the script: ( 0 minutes 15.562 seconds)

Gallery generated by Sphinx-Gallery