Skip to content

Commit

Permalink
Add some pyaedt emit documentation (#4485)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com>
Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 11, 2024
1 parent 5b9c195 commit 1ee0d5c
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 11 deletions.
156 changes: 156 additions & 0 deletions doc/source/User_guide/emit_modeler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
EMIT modeler
============
The ``EMIT Modeling`` module includes several classes to enable
modeling in EMIT:


* ``modeler`` to return the schematic modeler for an EMIT design.
* ``couplings`` to return a list of all linked couplings within an EMIT design.
* ``version`` to provide the EMIT version information.
* ``set_units`` to set the units globally for the EMIT design.
* ``get_units`` to get the value of the current EMIT design global units.

EMIT version check and set units example:

.. code:: python
import pyaedt
from pyaedt import Emit
emit = Emit(pyaedt.generate_unique_project_name(),
specified_version="2024.1", non_graphical=False,
new_desktop_session=True, close_on_exit=True)
# This call returns detailed version info for EMIT
ver = emit.version(detailed=True)
# This call sets the global units for EMIT
unit_types = ["Power", "Frequency", "Length", "Time"]
unit_vals = ["kW", "kHz", "meter", "ns"]
emit.set_units(unit_types, unit_vals)
# This call gets all the global units for the EMIT design
all_units = emit.get_units()
# This call gets the global Frequency units for the EMIT design
freq_units = emit.get_units("Frequency")
# Close AEDT
emit.release_desktop(close_projects=True, close_desktop=True)
EMIT-HFSS link creation example:

.. code:: python
import os
import pyaedt
from pyaedt import Emit
from pyaedt.generic.filesystem import Scratch
scratch_path = pyaedt.generate_unique_folder_name()
temp_folder = os.path.join(scratch_path, ("EmitHFSSExample"))
if not os.path.exists(temp_folder):
os.mkdir(temp_folder)
# Launch AEDT
aedtapp = pyaedt.launch_desktop(specified_version="2024.1", non_graphical=False,
new_desktop_session=True, close_on_exit=True)
# Verify the ``Cell Phone RFT Defense`` example exists
example_name = "Cell Phone RFI Desense"
example_aedt = example_name + ".aedt"
example_results = example_name + ".aedtresults"
example_lock = example_aedt + ".lock"
example_pdf_file = example_name + " Example.pdf"
example_dir = os.path.join(aedtapp.install_path, "Examples\\EMIT")
example_project = os.path.join(example_dir, example_aedt)
example_results_folder = os.path.join(example_dir, example_results)
example_pdf = os.path.join(example_dir, example_pdf_file)
# If the ``Cell Phone RFT Defense`` example is not
# in the installation directory, exit from this example.
if not os.path.exists(example_project):
exit()
# Copy the project to a temp directory
my_project = os.path.join(temp_folder, example_aedt)
my_results_folder = os.path.join(temp_folder, example_results)
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):
os.remove(my_project)
if os.path.exists(my_project_lock):
os.remove(my_project_lock)
with Scratch(scratch_path) as local_scratch:
local_scratch.copyfile(example_project, my_project)
local_scratch.copyfolder(example_results_folder, my_results_folder)
if os.path.exists(example_pdf):
local_scratch.copyfile(example_pdf, my_project_pdf)
emit = Emit(my_project)
# Remove all existing links
for link in emit.couplings.coupling_names:
emit.couplings.delete_link(link)
# Add the HFSS design as a coupling in EMIT
for link in emit.couplings.linkable_design_names:
emit.couplings.add_link(link)
# Get all the antennas in the EMIT design
antennas = emit.couplings.antenna_nodes
for ant in antennas:
print(ant)
# Close AEDT
emit.release_desktop(close_projects=True, close_desktop=True)
Create and Analyze an EMIT project:

.. code:: python
import pyaedt
from pyaedt import Emit
from pyaedt.emit_core.emit_constants import TxRxMode, ResultType
emit = Emit(pyaedt.generate_unique_project_name(),
specified_version="2024.1", non_graphical=False,
new_desktop_session=True, close_on_exit=True)
# Create a radio and connect an antenna to it
rad1 = emit.modeler.components.create_component("New Radio")
ant1 = emit.modeler.components.create_component("Antenna")
if rad1 and ant1:
ant1.move_and_connect_to(rad1)
# Quickly create 2 more radios with antennas automatically
# connected to them
rad2, ant2 = emit.modeler.components.create_radio_antenna("GPS Receiver")
rad3, ant3 = emit.modeler.components.create_radio_antenna("Bluetooth Low Energy (LE)", "Bluetooth")
# Create a new ``Revision``
rev = emit.results.analyze()
# Get the receive bands enabled for the GPS Rx
rx_bands = rev.get_band_names(rad2.name, TxRxMode.RX)
# Get the transmit bands enabled for the Bluetooth radio
tx_bands = rev.get_band_names(rad3.name, TxRxMode.TX)
# Configure the interaction domain that will be analyzed
domain = emit.results.interaction_domain()
domain.set_receiver(rad2.name, rx_bands[0], -1)
domain.set_interferer(rad3.name,tx_bands[0])
# Analzye the domain and get the worst case interference
interaction = rev.run(domain)
worst = interaction.get_worst_instance(ResultType.EMI)
emi = worst.get_value(ResultType.EMI)
print("Worst case interference is: {} dB".format(emi))
# Close AEDT
emit.release_desktop(close_projects=True, close_desktop=True)
8 changes: 8 additions & 0 deletions doc/source/User_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ For additional practical demonstrations, see

How to generate reports, images, and PDF files.

.. grid-item-card:: EMIT Modeler
:link: emit_modeler
:link-type: doc
:margin: 2 2 0 0

How to create and analyze EMIT designs.

.. toctree::
:hidden:
:maxdepth: 2
Expand All @@ -72,3 +79,4 @@ For additional practical demonstrations, see
variables
files
postprocessing
emit_modeler
2 changes: 1 addition & 1 deletion examples/07-EMIT/EMIT_HFSS_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
###############################################################################
# Run EMIT simulation
# ~~~~~~~~~~~~~~~~~~~
# Run the EMIT simulation. This portion of the EMIT API is not yet implemented.
# Run the EMIT simulation.
#
# This part of the example requires Ansys AEDT 2023 R2.

Expand Down
12 changes: 6 additions & 6 deletions pyaedt/emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ class Emit(Design, object):
Once the schematic is generated, the ``Emit`` object can be analyzed to generate
a revision. Each revision is added as an element of the ``Emit`` object member's
revisions_list.
``Results.revisions`` list.
>>> aedtapp.analyze()
>>> revision = aedtapp.results.analyze()
A revision within PyAEDT is analogous to a revision in AEDT. An interaction domain must
be defined and then used as the input to the run command used on that revision.
>>> domain = aedtapp.interaction_domain()
>>> domain = aedtapp.results.interaction_domain()
>>> domain.rx_radio_name = "UE - HandHeld"
>>> interaction = aedtapp.revisions_list[0].run(domain)
>>> interaction = revision.run(domain)
The output of the run command is an ``interaction`` object. This object summarizes the interaction data
that is defined in the interaction domain.
Expand Down Expand Up @@ -215,7 +215,7 @@ def version(self, detailed=False):

@pyaedt_function_handler()
def set_units(self, unit_type, unit_value):
"""Set units for the component.
"""Set units for the EMIT design.
Parameters
----------
Expand Down Expand Up @@ -277,7 +277,7 @@ def set_units(self, unit_type, unit_value):

@pyaedt_function_handler()
def get_units(self, unit_type=""):
"""Get units for the component.
"""Get units for the EMIT design.
Parameters
----------
Expand Down
6 changes: 2 additions & 4 deletions pyaedt/emit_core/results/revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,7 @@ def interference_type_classification(self, domain, use_filter=False, filter_list
# should just be skipped
continue
else:
tx_prob = (
instance.get_largest_problem_type(ResultType.EMI).replace(" ", "").split(":")[1]
)
tx_prob = instance.get_largest_emi_problem_type().replace(" ", "").split(":")[1]
power = instance.get_value(ResultType.EMI)
if (
rx_start_freq - rx_channel_bandwidth / 2
Expand All @@ -521,7 +519,7 @@ def interference_type_classification(self, domain, use_filter=False, filter_list
if power > max_power and in_filters:
max_power = power
largest_rx_prob = rx_prob
prob = instance.get_largest_problem_type(ResultType.EMI)
prob = instance.get_largest_emi_problem_type()
largest_tx_prob = prob.replace(" ", "").split(":")

if max_power > -200:
Expand Down

0 comments on commit 1ee0d5c

Please sign in to comment.