.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\02-HFSS\Array.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_02-HFSS_Array.py: HFSS: component antenna array ----------------------------- This example shows how you can use PyAEDT to create an example using a 3D component file. It sets up the analysis, solves it, and uses postprocessing functions to create plots using Matplotlib and PyVista without opening the HFSS user interface. This examples runs only on Windows using CPython. .. GENERATED FROM PYTHON SOURCE LINES 9-12 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import os import pyaedt from pyaedt.modules.solutions import FfdSolutionData .. GENERATED FROM PYTHON SOURCE LINES 18-21 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: Python aedt_version = "2024.1" .. GENERATED FROM PYTHON SOURCE LINES 25-29 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 33-36 Download 3D component ~~~~~~~~~~~~~~~~~~~~~ Download the 3D component that is needed to run the example. .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: Python example_path = pyaedt.downloads.download_3dcomponent() .. GENERATED FROM PYTHON SOURCE LINES 39-42 Launch HFSS and save project ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Launch HFSS and save the project. .. GENERATED FROM PYTHON SOURCE LINES 42-51 .. code-block:: Python project_name = pyaedt.generate_unique_project_name(project_name="array") hfss = pyaedt.Hfss(projectname=project_name, specified_version=aedt_version, designname="Array_Simple", non_graphical=non_graphical, new_desktop_session=True) print("Project name " + project_name) .. rst-class:: sphx-glr-script-out .. code-block:: none Project name D:\Temp\pyaedt_prj_HO5\array.aedt .. GENERATED FROM PYTHON SOURCE LINES 52-61 Read array definition from JSON file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Read the array definition from a JSON file. A JSON file can contain all information needed to import and set up a full array in HFSS. If a 3D component is not available in the design, it is loaded into the dictionary from the path that you specify. The following code edits the dictionary to point to the location of the A3DCOMP file. .. GENERATED FROM PYTHON SOURCE LINES 61-67 .. code-block:: Python dict_in = pyaedt.general_methods.read_json(os.path.join(example_path, "array_simple.json")) dict_in["Circ_Patch_5GHz1"] = os.path.join(example_path, "Circ_Patch_5GHz.a3dcomp") dict_in["cells"][(3, 3)] = {"name": "Circ_Patch_5GHz1"} array = hfss.add_3d_component_array_from_json(dict_in) .. GENERATED FROM PYTHON SOURCE LINES 68-71 Modify cells ~~~~~~~~~~~~ Make center element passive and rotate corner elements. .. GENERATED FROM PYTHON SOURCE LINES 71-78 .. code-block:: Python array.cells[1][1].is_active = False array.cells[0][0].rotation = 90 array.cells[0][2].rotation = 90 array.cells[2][0].rotation = 90 array.cells[2][2].rotation = 90 .. GENERATED FROM PYTHON SOURCE LINES 79-82 Set up simulation ~~~~~~~~~~~~~~~~~ Set up a simulation and analyze it. .. GENERATED FROM PYTHON SOURCE LINES 82-89 .. code-block:: Python setup = hfss.create_setup() setup.props["Frequency"] = "5GHz" setup.props["MaximumPasses"] = 3 hfss.analyze(cores=4) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 90-94 Get far field data ~~~~~~~~~~~~~~~~~~ Get far field data. After the simulation completes, the far field data is generated port by port and stored in a data class. .. GENERATED FROM PYTHON SOURCE LINES 94-97 .. code-block:: Python ffdata = hfss.get_antenna_ffd_solution_data(frequencies=[5e9], setup=hfss.nominal_adaptive, sphere="Infinite Sphere1") .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_001.png :alt: Array :srcset: /examples/02-HFSS/images/sphx_glr_Array_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 98-102 Generate contour plot ~~~~~~~~~~~~~~~~~~~~~ Generate a contour plot. You can define the Theta scan and Phi scan. .. GENERATED FROM PYTHON SOURCE LINES 102-105 .. code-block:: Python ffdata.plot_farfield_contour(quantity='RealizedGain', title='Contour at {}Hz'.format(ffdata.frequency)) .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_002.png :alt: Contour at 5000000000.0Hz :srcset: /examples/02-HFSS/images/sphx_glr_Array_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 106-110 Release AEDT ~~~~~~~~~~~~ Release AEDT. Far field post-processing can be performed without AEDT because the data is stored. .. GENERATED FROM PYTHON SOURCE LINES 110-117 .. code-block:: Python eep_file = ffdata.eep_files frequencies = ffdata.frequencies working_directory = hfss.working_directory hfss.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 118-121 Load far field data ~~~~~~~~~~~~~~~~~~~ Load far field data stored. .. GENERATED FROM PYTHON SOURCE LINES 121-124 .. code-block:: Python ffdata = FfdSolutionData(frequencies=frequencies[0], eep_files=eep_file[0]) .. GENERATED FROM PYTHON SOURCE LINES 125-129 Generate contour plot ~~~~~~~~~~~~~~~~~~~~~ Generate a contour plot. You can define the Theta scan and Phi scan. .. GENERATED FROM PYTHON SOURCE LINES 129-132 .. code-block:: Python ffdata.plot_farfield_contour(quantity='RealizedGain', title='Contour at {}Hz'.format(ffdata.frequency)) .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_003.png :alt: Contour at 5000000000.0Hz :srcset: /examples/02-HFSS/images/sphx_glr_Array_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 133-137 Generate 2D cutout plots ~~~~~~~~~~~~~~~~~~~~~~~~ Generate 2D cutout plots. You can define the Theta scan and Phi scan. .. GENERATED FROM PYTHON SOURCE LINES 137-144 .. code-block:: Python ffdata.plot_2d_cut(quantity='RealizedGain', primary_sweep='theta', secondary_sweep_value=[-180, -75, 75], title='Azimuth at {}Hz'.format(ffdata.frequency), quantity_format="dB10") ffdata.plot_2d_cut(quantity='RealizedGain', primary_sweep="phi", secondary_sweep_value=30, title='Elevation', quantity_format="dB10") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_004.png :alt: Azimuth at 5000000000.0Hz :srcset: /examples/02-HFSS/images/sphx_glr_Array_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_005.png :alt: Elevation :srcset: /examples/02-HFSS/images/sphx_glr_Array_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument. No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
.. GENERATED FROM PYTHON SOURCE LINES 145-149 Generate 3D polar plots in Matplotlib ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate 3D polar plots in Matplotlib. You can define the Theta scan and Phi scan. .. GENERATED FROM PYTHON SOURCE LINES 149-151 .. code-block:: Python ffdata.polar_plot_3d(quantity='RealizedGain') .. image-sg:: /examples/02-HFSS/images/sphx_glr_Array_006.png :alt: 3D Plot :srcset: /examples/02-HFSS/images/sphx_glr_Array_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 42.876 seconds) .. _sphx_glr_download_examples_02-HFSS_Array.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Array.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Array.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_