.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\01-Modeling-Setup\Optimetrics.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_01-Modeling-Setup_Optimetrics.py: General: optimetrics setup -------------------------- This example shows how you can use PyAEDT to create a project in HFSS and create all optimetrics setups. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default import pyaedt import os .. GENERATED FROM PYTHON SOURCE LINES 17-20 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: default 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:: default non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 32-36 Initialize object and create variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Initialize the ``Hfss`` object and create two needed design variables, ``w1`` and ``w2``. .. GENERATED FROM PYTHON SOURCE LINES 36-41 .. code-block:: default hfss = pyaedt.Hfss(specified_version=aedt_version, new_desktop_session=True, non_graphical=non_graphical) hfss["w1"] = "1mm" hfss["w2"] = "100mm" .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! .. GENERATED FROM PYTHON SOURCE LINES 42-46 Create waveguide with sheets on it ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create one of the standard waveguide structures and parametrize it. You can also create rectangles of waveguide openings and assign ports later. .. GENERATED FROM PYTHON SOURCE LINES 46-61 .. code-block:: default wg1, p1, p2 = hfss.modeler.create_waveguide( [0, 0, 0], hfss.AXIS.Y, "WG17", wg_thickness="w1", wg_length="w2", create_sheets_on_openings=True, ) model = hfss.plot(show=False) model.show_grid = False model.plot(os.path.join(hfss.working_directory, "Image.jpg")) .. image-sg:: /examples/01-Modeling-Setup/images/sphx_glr_Optimetrics_001.png :alt: Optimetrics :srcset: /examples/01-Modeling-Setup/images/sphx_glr_Optimetrics_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 62-65 Create wave ports on sheets ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create two wave ports on the sheets. .. GENERATED FROM PYTHON SOURCE LINES 65-69 .. code-block:: default hfss.wave_port(p1, integration_line=hfss.AxisDir.ZPos, name="1") hfss.wave_port(p2, integration_line=hfss.AxisDir.ZPos, name="2") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 70-74 Create setup and frequency sweep ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a setup and a frequency sweep to use as the base for optimetrics setups. .. GENERATED FROM PYTHON SOURCE LINES 74-80 .. code-block:: default setup = hfss.create_setup() hfss.create_linear_step_sweep( setupname=setup.name, unit="GHz", freqstart=1, freqstop=5, step_size=0.1, sweepname="Sweep1", save_fields=True ) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 81-86 Optimetrics analysis ---------------------- Create parametrics analysis ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a simple optimetrics parametrics analysis with output calculations. .. GENERATED FROM PYTHON SOURCE LINES 86-92 .. code-block:: default sweep = hfss.parametrics.add("w2", 90, 200, 5) sweep.add_variation("w1", 0.1, 2, 10) sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}) sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"}) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 93-96 Create sensitivity analysis ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an optimetrics sensitivity analysis with output calculations. .. GENERATED FROM PYTHON SOURCE LINES 96-101 .. code-block:: default sweep2 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Sensitivity") sweep2.add_variation("w1", 0.1, 3, 0.5) sweep2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"}) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 102-105 Create optimization based on goals and calculations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an optimization analysis based on goals and calculations. .. GENERATED FROM PYTHON SOURCE LINES 105-116 .. code-block:: default sweep3 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}) sweep3.add_variation("w1", 0.1, 3, 0.5) sweep3.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"}) sweep3.add_goal(calculation="dB(S(1,1))", ranges={"Freq": ("2.6GHz", "5GHz")}) sweep3.add_goal( calculation="dB(S(1,1))", ranges={"Freq": ("2.6GHz", "5GHz")}, condition="Maximize", ) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 117-120 Create DX optimization based on a goal and calculation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a DX (DesignXplorer) optimization based on a goal and a calculation. .. GENERATED FROM PYTHON SOURCE LINES 120-124 .. code-block:: default sweep4 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DesignExplorer") sweep4.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"}) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 125-128 Create DOE based on a goal and calculation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a DOE (Design of Experiments) based on a goal and a calculation. .. GENERATED FROM PYTHON SOURCE LINES 128-131 .. code-block:: default sweep5 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DXDOE") .. GENERATED FROM PYTHON SOURCE LINES 132-135 Create DOE based on a goal and calculation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a DOE based on a goal and a calculation. .. GENERATED FROM PYTHON SOURCE LINES 135-146 .. code-block:: default region = hfss.modeler.create_region() hfss.assign_radiation_boundary_to_objects(region) hfss.insert_infinite_sphere(name="Infinite_1") sweep6 = hfss.optimizations.add( calculation="RealizedGainTotal", solution=hfss.nominal_adaptive, ranges={"Freq": "5GHz", "Theta": ["0deg", "10deg", "20deg"], "Phi": "0deg"}, context="Infinite_1", ) .. GENERATED FROM PYTHON SOURCE LINES 147-152 Close AEDT ---------- After the simulaton 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 152-154 .. code-block:: default 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 44.761 seconds) .. _sphx_glr_download_examples_01-Modeling-Setup_Optimetrics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Optimetrics.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Optimetrics.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_