.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\07-EMIT\EMIT_Example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_07-EMIT_EMIT_Example.py: EMIT: antenna --------------------- This example shows how you can use PyAEDT to create a project in EMIT for the simulation of an antenna. .. GENERATED FROM PYTHON SOURCE LINES 8-13 Perform required inputs ~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. sphinx_gallery_thumbnail_path = "Resources/emit_simple_cosite.png" .. GENERATED FROM PYTHON SOURCE LINES 13-19 .. code-block:: default import os import pyaedt from pyaedt.emit_core.emit_constants import TxRxMode, ResultType .. GENERATED FROM PYTHON SOURCE LINES 20-26 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. The ``NewThread`` Boolean variable defines whether to create a new instance of AEDT or try to connect to existing instance of it if one is available. .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: default non_graphical = False NewThread = True desktop_version = "2023.2" .. GENERATED FROM PYTHON SOURCE LINES 33-37 Launch AEDT with EMIT ~~~~~~~~~~~~~~~~~~~~~ Launch AEDT with EMIT. The ``Desktop`` class initializes AEDT and starts it on the specified version and in the specified graphical mode. .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: default d = pyaedt.launch_desktop(desktop_version, non_graphical, NewThread) aedtapp = pyaedt.Emit(pyaedt.generate_unique_project_name()) .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! C:\actions-runner\_work\_tool\Python\3.10.5\x64\lib\subprocess.py:1070: ResourceWarning: subprocess 12960 is still running _warn("subprocess %s is still running" % self.pid, Returning found desktop with PID 12960! .. GENERATED FROM PYTHON SOURCE LINES 43-46 Create and connect EMIT components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create three radios and connect an antenna to each one. .. GENERATED FROM PYTHON SOURCE LINES 46-56 .. code-block:: default rad1 = aedtapp.modeler.components.create_component("New Radio") ant1 = aedtapp.modeler.components.create_component("Antenna") if rad1 and ant1: ant1.move_and_connect_to(rad1) # Convenience method to create a radio and antenna connected together rad2, ant2 = aedtapp.modeler.components.create_radio_antenna("GPS Receiver") rad3, ant3 = aedtapp.modeler.components.create_radio_antenna("Bluetooth Low Energy (LE)", "Bluetooth") .. GENERATED FROM PYTHON SOURCE LINES 57-61 Define coupling among RF systems ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Define the coupling among the RF systems. This portion of the EMIT API is not yet implemented. .. GENERATED FROM PYTHON SOURCE LINES 64-69 Run EMIT simulation ~~~~~~~~~~~~~~~~~~~ Run the EMIT simulation. This part of the example requires Ansys AEDT 2023 R2. .. GENERATED FROM PYTHON SOURCE LINES 69-83 .. code-block:: default if desktop_version > "2023.1" and os.getenv("PYAEDT_DOC_GENERATION", "False") != "1": rev = aedtapp.results.analyze() rx_bands = rev.get_band_names(rad2.name, TxRxMode.RX) tx_bands = rev.get_band_names(rad3.name, TxRxMode.TX) domain = aedtapp.results.interaction_domain() domain.set_receiver(rad2.name, rx_bands[0], -1) domain.set_interferer(rad3.name,tx_bands[0]) interaction = rev.run(domain) worst = interaction.get_worst_instance(ResultType.EMI) if worst.has_valid_values(): emi = worst.get_value(ResultType.EMI) print("Worst case interference is: {} dB".format(emi)) .. GENERATED FROM PYTHON SOURCE LINES 84-89 Save project and close AEDT ~~~~~~~~~~~~~~~~~~~~~~~~~~~ After the simulation completes, you can close AEDT or release it using the :func:`pyaedt.Desktop.force_close_desktop` method. All methods provide for saving the project before closing. .. GENERATED FROM PYTHON SOURCE LINES 89-92 .. code-block:: default aedtapp.save_project() aedtapp.release_desktop(close_projects=True, close_desktop=True) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 37.554 seconds) .. _sphx_glr_download_examples_07-EMIT_EMIT_Example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: EMIT_Example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: EMIT_Example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_