.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\02-HFSS\HFSS_FSS_unitcell.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_HFSS_FSS_unitcell.py: HFSS: FSS Unitcell Simulation -------------------- This example shows how you can use PyAEDT to create a FSS unitcell simulations in HFSS and postprocess results. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-17 .. code-block:: Python import os import pyaedt project_name = pyaedt.generate_unique_project_name(project_name="FSS") .. 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 Launch AEDT ~~~~~~~~~~~ Launch AEDT 2023 R2 in graphical mode. .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: Python d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop_session=True) .. GENERATED FROM PYTHON SOURCE LINES 40-43 Launch HFSS ~~~~~~~~~~~ Launch HFSS 2023 R2 in graphical mode. .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python hfss = pyaedt.Hfss(projectname=project_name, solution_type="Modal") .. GENERATED FROM PYTHON SOURCE LINES 47-50 Define variable ~~~~~~~~~~~~~~~ Define a variable for the 3D-component. .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python hfss["patch_dim"] = "10mm" .. GENERATED FROM PYTHON SOURCE LINES 54-57 Insert 3D component from system library ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Download the 3D component from the example data and insert the 3D Component. .. GENERATED FROM PYTHON SOURCE LINES 57-63 .. code-block:: Python unitcell_3d_component_path = pyaedt.downloads.download_FSS_3dcomponent() unitcell_path = os.path.join(unitcell_3d_component_path, "FSS_unitcell_23R2.a3dcomp") comp = hfss.modeler.insert_3d_component(unitcell_path) .. GENERATED FROM PYTHON SOURCE LINES 64-67 Assign design parameter to 3D Component parameter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign parameter. .. GENERATED FROM PYTHON SOURCE LINES 67-71 .. code-block:: Python component_name = hfss.modeler.user_defined_component_names comp.parameters["a"] = "patch_dim" .. GENERATED FROM PYTHON SOURCE LINES 72-75 Create air region ~~~~~~~~~~~~~~~~~ Create an open region along +Z direction for unitcell analysis. .. GENERATED FROM PYTHON SOURCE LINES 75-88 .. code-block:: Python bounding_dimensions = hfss.modeler.get_bounding_dimension() periodicity_x = bounding_dimensions[0] periodicity_y = bounding_dimensions[1] region = hfss.modeler.create_air_region( z_pos=10 * bounding_dimensions[2], is_percentage=False, ) [x_min, y_min, z_min, x_max, y_max, z_max] = region.bounding_box .. GENERATED FROM PYTHON SOURCE LINES 89-92 Assign Lattice pair boundary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assigning lattice pair boundary automatically detected. .. GENERATED FROM PYTHON SOURCE LINES 92-95 .. code-block:: Python hfss.auto_assign_lattice_pairs(assignment=region.name) .. rst-class:: sphx-glr-script-out .. code-block:: none ['LatticePair1', 'LatticePair2'] .. GENERATED FROM PYTHON SOURCE LINES 96-99 Assign Floquet port excitation along +Z direction ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign Floquet port. .. GENERATED FROM PYTHON SOURCE LINES 99-105 .. code-block:: Python id_z_pos = region.top_face_z hfss.create_floquet_port(id_z_pos, [0, 0, z_max], [0, y_max, z_max], [x_max, 0, z_max], name='port_z_max', deembed_distance=10 * bounding_dimensions[2]) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 106-109 Create setup ~~~~~~~~~~~~ Create a setup with a sweep to run the simulation. .. GENERATED FROM PYTHON SOURCE LINES 109-117 .. code-block:: Python setup = hfss.create_setup("MySetup") setup.props["Frequency"] = "10GHz" setup.props["MaximumPasses"] = 10 hfss.create_linear_count_sweep(setup=setup.name, units="GHz", start_frequency=6, stop_frequency=15, num_of_freq_points=51, name="sweep1", save_fields=False, sweep_type="Interpolating", interpolation_tol=6) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 118-121 Create S-parameter report using report objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create S-parameter reports using create report. .. GENERATED FROM PYTHON SOURCE LINES 121-135 .. code-block:: Python all_quantities = hfss.post.available_report_quantities() str_mag = [] str_ang = [] variation = {"Freq": ["All"]} for i in all_quantities: str_mag.append("mag(" + i + ")") str_ang.append("ang_deg(" + i + ")") hfss.post.create_report(expressions=str_mag, variations=variation, plot_name="magnitude_plot") hfss.post.create_report(expressions=str_ang, variations=variation, plot_name="phase_plot") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 136-139 Save and run simulation ~~~~~~~~~~~~~~~~~~~~~~~ Save and run the simulation. Uncomment the line following line to run the analysis. .. GENERATED FROM PYTHON SOURCE LINES 139-142 .. code-block:: Python # hfss.analyze() .. GENERATED FROM PYTHON SOURCE LINES 143-148 Close AEDT ~~~~~~~~~~ After the simulation completes, you can close AEDT or release it using the :func:`pyaedt.Desktop.release_desktop` method. All methods provide for saving the project before closing. .. GENERATED FROM PYTHON SOURCE LINES 148-150 .. code-block:: Python hfss.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 55.628 seconds) .. _sphx_glr_download_examples_02-HFSS_HFSS_FSS_unitcell.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: HFSS_FSS_unitcell.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: HFSS_FSS_unitcell.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_