Note
Go to the end to download the full example code.
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.
Perform required imports.#
Perform required imports.
import os
from ansys.aedt.core import Hfss, downloads
Set AEDT version#
Set AEDT version.
aedt_version = "2024.2"
Set non-graphical mode#
Set non-graphical mode.
You can set non_graphical
either to True
or False
.
non_graphical = False
Launch AEDT and load project#
Launch AEDT and load the project.
project_file = downloads.download_sbr_time()
hfss = Hfss(project=project_file, version=aedt_version, non_graphical=non_graphical, new_desktop=True)
hfss.analyze()
C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 4396 is still running
_warn("subprocess %s is still running" % self.pid,
C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\ansys\aedt\core\generic\settings.py:231: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys_0bf9f20b-53ab-4ce4-97b2-0987472c9727.log' mode='a' encoding='cp1252'>
self.__logger = val
True
Get solution data#
Get solution data. After simulation is performed, you can load solutions
in the solution_data
object.
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")
Compute IFFT#
Compute IFFT (Inverse Fast Fourier Transform).
t_matrix = solution_data.ifft("NearE", window=True)
Export IFFT to CSV file#
Export IFFT to a CSV file.
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"))
Plot scene#
Plot the scene to create the time plot animation
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()
C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\pyvista\plotting\plotter.py:4796: 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
Total running time of the script: (2 minutes 38.944 seconds)