.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\02-HFSS\Create_3d_Component_and_use_it.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_Create_3d_Component_and_use_it.py: Create a 3D Component and reuse it ---------------------------------- Summary of the workflow 1. Create an antenna using PyAEDT and HFSS 3D Modeler (same can be done with EDB and HFSS 3D Layout) 2. Store the object as a 3D Component on the disk 3. Reuse the 3D component in another project 4. Parametrize and optimize target design .. GENERATED FROM PYTHON SOURCE LINES 12-15 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python import os import tempfile from pyaedt import Hfss from pyaedt.generic.general_methods import generate_unique_name .. GENERATED FROM PYTHON SOURCE LINES 21-24 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python aedt_version = "2024.1" .. GENERATED FROM PYTHON SOURCE LINES 28-32 Launch HFSS ~~~~~~~~~~~ PyAEDT can initialize a new session of Electronics Desktop or connect to an existing one. Once Desktop is connected, a new HFSS session is started and a design is created. .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python hfss = Hfss(specified_version=aedt_version, new_desktop_session=True, close_on_exit=True) .. GENERATED FROM PYTHON SOURCE LINES 36-39 Variables ~~~~~~~~~ PyAEDT can create and store all variables available in AEDT (Design, Project, Post Processing) .. GENERATED FROM PYTHON SOURCE LINES 39-43 .. code-block:: Python hfss["thick"] = "0.1mm" hfss["width"] = "1mm" .. GENERATED FROM PYTHON SOURCE LINES 44-49 Modeler ~~~~~~~~ PyAEDT supports all modeler functionalities available in the Desktop. Objects can be created, deleted and modified using all available boolean operations. History is also fully accessible to PyAEDT. .. GENERATED FROM PYTHON SOURCE LINES 49-61 .. code-block:: Python substrate = hfss.modeler.create_box(["-width", "-width", "-thick"], ["2*width", "2*width", "thick"], name="sub", material="FR4_epoxy") patch = hfss.modeler.create_rectangle("XY",["-width/2","-width/2","0mm"],["width","width"], name="patch1") via1 = hfss.modeler.create_cylinder(2, ["-width/8", "-width/4", "-thick"], "0.01mm", "thick", name="via_inner", material="copper") via_outer = hfss.modeler.create_cylinder(2, ["-width/8", "-width/4", "-thick"], "0.025mm", "thick", name="via_teflon", material="Teflon_based") .. GENERATED FROM PYTHON SOURCE LINES 62-67 Boundaries ~~~~~~~~~~ Most of HFSS boundaries and excitations are already available in PyAEDT. User can assign easily a boundary to a face or to an object by taking benefits of Object-Oriented Programming (OOP) available in PyAEDT. .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python hfss.assign_perfecte_to_sheets(patch) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 71-75 Advanced Modeler functions ~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks to Python capabilities a lot of additional functionalities have been added to the Modeler of PyAEDT. in this example there is a property to retrieve automatically top and bottom faces of an objects. .. GENERATED FROM PYTHON SOURCE LINES 75-81 .. code-block:: Python side_face = [i for i in via_outer.faces if i.id not in [via_outer.top_face_z.id, via_outer.bottom_face_z.id]] hfss.assign_perfecte_to_sheets(side_face) hfss.assign_perfecte_to_sheets(substrate.bottom_face_z) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 82-85 Create Wave Port ~~~~~~~~~~~~~~~~ Wave port can be assigned to a sheet or to a face of an object. .. GENERATED FROM PYTHON SOURCE LINES 85-88 .. code-block:: Python hfss.wave_port(via_outer.bottom_face_z, name="P1") .. rst-class:: sphx-glr-script-out .. code-block:: none False .. GENERATED FROM PYTHON SOURCE LINES 89-94 Create 3D Component ~~~~~~~~~~~~~~~~~~~ Once the model is ready a 3D Component can be created. Multiple options are available to partially select objects, cs, boundaries and mesh operations. Furthermore, encrypted 3d comp can be created too. .. GENERATED FROM PYTHON SOURCE LINES 94-98 .. code-block:: Python component_path = os.path.join(tempfile.gettempdir(), generate_unique_name("component_test")+".aedbcomp") hfss.modeler.create_3dcomponent(component_path, "patch_antenna") .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 99-102 Multiple project management ~~~~~~~~~~~~~~~~~~~~~~~~~~~ PyAEDT allows to control multiple projects, design and solution type at the same time. .. GENERATED FROM PYTHON SOURCE LINES 102-105 .. code-block:: Python hfss2 = Hfss(projectname="new_project", designname="new_design") .. GENERATED FROM PYTHON SOURCE LINES 106-110 Insert of 3d component ~~~~~~~~~~~~~~~~~~~~~~ The 3d component can be inserted without any additional info. All needed info will be read from the file itself. .. GENERATED FROM PYTHON SOURCE LINES 110-113 .. code-block:: Python hfss2.modeler.insert_3d_component(component_path) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 114-117 3D Component Parameters ~~~~~~~~~~~~~~~~~~~~~~~ All 3d Component parameters are available and can be parametrized. .. GENERATED FROM PYTHON SOURCE LINES 117-124 .. code-block:: Python hfss2.modeler.user_defined_components["patch_antenna1"].parameters hfss2["p_thick"] = "1mm" hfss2.modeler.user_defined_components["patch_antenna1"].parameters["thick"]="p_thick" .. GENERATED FROM PYTHON SOURCE LINES 125-129 Multiple 3d Components ~~~~~~~~~~~~~~~~~~~~~~ There is no limit to the number of 3D components that can be added on the same design. They can be the same or linked to different files. .. GENERATED FROM PYTHON SOURCE LINES 129-134 .. code-block:: Python hfss2.modeler.create_coordinate_system(origin=[20, 20, 10], name="Second_antenna") ant2 = hfss2.modeler.insert_3d_component(component_path, coordinate_system="Second_antenna") .. GENERATED FROM PYTHON SOURCE LINES 135-138 Move components ~~~~~~~~~~~~~~~ The component can be moved by changing is position or moving the relative coordinate system. .. GENERATED FROM PYTHON SOURCE LINES 138-141 .. code-block:: Python hfss2.modeler.coordinate_systems[0].origin = [10, 10, 3] .. GENERATED FROM PYTHON SOURCE LINES 142-146 Boundaries ~~~~~~~~~~ Most of HFSS boundaries and excitations are already available in PyAEDT. User can assign easily a boundary to a face or to an object by taking benefits of .. GENERATED FROM PYTHON SOURCE LINES 146-158 .. code-block:: Python hfss2.modeler.create_air_region(30, 30, 30, 30, 30, 30) hfss2.assign_radiation_boundary_to_faces(hfss2.modeler["Region"].faces) # Create Setup and Optimetrics # Once project is ready to be solved, a setup and parametrics analysis can be created with PyAEDT. # All setup parameters can be edited. setup1 = hfss2.create_setup() optim = hfss2.parametrics.add("p_thick", "0.2mm", "1.5mm", step=14) .. GENERATED FROM PYTHON SOURCE LINES 159-162 Save project ~~~~~~~~~~~~ Save the project. .. GENERATED FROM PYTHON SOURCE LINES 162-166 .. code-block:: Python hfss2.modeler.fit_all() hfss2.plot(show=False, export_path=os.path.join(hfss.working_directory, "Image.jpg"), plot_air_objects=True) .. image-sg:: /examples/02-HFSS/images/sphx_glr_Create_3d_Component_and_use_it_001.png :alt: Create 3d Component and use it :srcset: /examples/02-HFSS/images/sphx_glr_Create_3d_Component_and_use_it_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 167-172 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 AEDT. .. GENERATED FROM PYTHON SOURCE LINES 172-175 .. code-block:: Python hfss2.save_project(os.path.join(tempfile.gettempdir(), generate_unique_name("parametrized")+".aedt")) hfss2.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 1.983 seconds) .. _sphx_glr_download_examples_02-HFSS_Create_3d_Component_and_use_it.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Create_3d_Component_and_use_it.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Create_3d_Component_and_use_it.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_