.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples\02-SBR+\SBR_Time_Plot.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_02-SBR+_SBR_Time_Plot.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_02-SBR+_SBR_Time_Plot.py:


SBR+: HFSS to SBR+ time animation
---------------------------------
This example shows how you can use PyAEDT to create an SBR+ time animation
and save it to a GIF file. This example works only on CPython.

.. GENERATED FROM PYTHON SOURCE LINES 9-12

Perform required imports.
~~~~~~~~~~~~~~~~~~~~~~~~~
Perform required imports.

.. GENERATED FROM PYTHON SOURCE LINES 12-16

.. code-block:: Python


    import os
    from pyaedt import Hfss, downloads








.. GENERATED FROM PYTHON SOURCE LINES 17-20

Set AEDT version
~~~~~~~~~~~~~~~~
Set AEDT version.

.. GENERATED FROM PYTHON SOURCE LINES 20-23

.. code-block:: Python


    aedt_version = "2024.1"








.. GENERATED FROM PYTHON SOURCE LINES 24-28

Set non-graphical mode
~~~~~~~~~~~~~~~~~~~~~~
Set non-graphical mode. 
You can set ``non_graphical`` either to ``True`` or ``False``.

.. GENERATED FROM PYTHON SOURCE LINES 28-31

.. code-block:: Python


    non_graphical = False








.. GENERATED FROM PYTHON SOURCE LINES 32-35

Launch AEDT and load project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Launch AEDT and load the project.

.. GENERATED FROM PYTHON SOURCE LINES 35-42

.. code-block:: Python


    project_file = downloads.download_sbr_time()

    hfss = Hfss(projectname=project_file, specified_version=aedt_version, non_graphical=non_graphical, new_desktop_session=True)

    hfss.analyze()





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 12028 is still running
      _warn("subprocess %s is still running" % self.pid,
    C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\pyaedt\generic\settings.py:383: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys.log' mode='a' encoding='cp1252'>
      self._logger = val

    True



.. GENERATED FROM PYTHON SOURCE LINES 43-47

Get solution data
~~~~~~~~~~~~~~~~~
Get solution data. After simulation is performed, you can load solutions
in the ``solution_data`` object.

.. GENERATED FROM PYTHON SOURCE LINES 47-53

.. code-block:: Python


    solution_data = hfss.post.get_solution_data(expressions=["NearEX", "NearEY", "NearEZ"],
                                                variations={"_u": ["All"], "_v": ["All"], "Freq": ["All"]},
                                                context="Near_Field",
                                                report_category="Near Fields")








.. GENERATED FROM PYTHON SOURCE LINES 54-57

Compute IFFT
~~~~~~~~~~~~
Compute IFFT (Inverse Fast Fourier Transform).

.. GENERATED FROM PYTHON SOURCE LINES 57-61

.. code-block:: Python


    t_matrix = solution_data.ifft("NearE", window=True)









.. GENERATED FROM PYTHON SOURCE LINES 62-65

Export IFFT to CSV file
~~~~~~~~~~~~~~~~~~~~~~~~
Export IFFT to a CSV file.

.. GENERATED FROM PYTHON SOURCE LINES 65-69

.. code-block:: Python


    frames_list_file = solution_data.ifft_to_file(coord_system_center=[-0.15, 0, 0], db_val=True,
                                                  csv_path=os.path.join(hfss.working_directory, "csv"))








.. GENERATED FROM PYTHON SOURCE LINES 70-73

Plot scene
~~~~~~~~~~
Plot the scene to create the time plot animation

.. GENERATED FROM PYTHON SOURCE LINES 73-78

.. code-block:: Python


    hfss.post.plot_scene(frames=frames_list_file, gif_path=os.path.join(hfss.working_directory, "animation.gif"),
                         norm_index=15, dy_rng=35, show=False, view="xy", zoom=1)

    hfss.release_desktop()



.. image-sg:: /examples/02-SBR+/images/sphx_glr_SBR_Time_Plot_001.gif
   :alt: SBR Time Plot
   :srcset: /examples/02-SBR+/images/sphx_glr_SBR_Time_Plot_001.gif
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\pyvista\plotting\plotter.py:4644: PyVistaDeprecationWarning: This method is deprecated and will be removed in a future version of PyVista. Directly modify the scalars of a mesh in-place instead.
      warnings.warn(

    True




.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (2 minutes 22.510 seconds)


.. _sphx_glr_download_examples_02-SBR+_SBR_Time_Plot.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: SBR_Time_Plot.ipynb <SBR_Time_Plot.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: SBR_Time_Plot.py <SBR_Time_Plot.py>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_