.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\00-EDB\03_5G_antenna_example.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_00-EDB_03_5G_antenna_example.py: EDB: 5G linear array antenna ---------------------------- This example shows how you can use HFSS 3D Layout to create and solve a 5G linear array antenna. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default import tempfile import pyaedt import os .. GENERATED FROM PYTHON SOURCE LINES 17-20 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. The default is ``False``. .. GENERATED FROM PYTHON SOURCE LINES 20-78 .. code-block:: default non_graphical = False class Patch: def __init__(self, width=0.0, height=0.0, position=0.0): self.width = width self.height = height self.position = position @property def points(self): return [ [self.position, -self.height / 2], [self.position + self.width, -self.height / 2], [self.position + self.width, self.height / 2], [self.position, self.height / 2], ] class Line: def __init__(self, length=0.0, width=0.0, position=0.0): self.length = length self.width = width self.position = position @property def points(self): return [ [self.position, -self.width / 2], [self.position + self.length, -self.width / 2], [self.position + self.length, self.width / 2], [self.position, self.width / 2], ] class LinearArray: def __init__(self, nb_patch=1, array_length=10e-3, array_width=5e-3): self.nbpatch = nb_patch self.length = array_length self.width = array_width @property def points(self): return [ [-1e-3, -self.width / 2 - 1e-3], [self.length + 1e-3, -self.width / 2 - 1e-3], [self.length + 1e-3, self.width / 2 + 1e-3], [-1e-3, self.width / 2 + 1e-3], ] tmpfold = tempfile.gettempdir() aedb_path = os.path.join(tmpfold, pyaedt.generate_unique_name("pcb") + ".aedb") print(aedb_path) edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") .. rst-class:: sphx-glr-script-out .. code-block:: none D:\Temp\pcb_SQ922L.aedb .. GENERATED FROM PYTHON SOURCE LINES 79-83 Add stackup layers ~~~~~~~~~~~~~~~~~~ Add the stackup layers. .. GENERATED FROM PYTHON SOURCE LINES 83-90 .. code-block:: default if edb: edb.stackup.add_layer("Virt_GND") edb.stackup.add_layer("Gap", "Virt_GND", layer_type="dielectric", thickness="0.05mm", material="Air") edb.stackup.add_layer("GND", "Gap") edb.stackup.add_layer("Substrat", "GND", layer_type="dielectric", thickness="0.5mm", material="Duroid (tm)") edb.stackup.add_layer("TOP", "Substrat") .. rst-class:: sphx-glr-script-out .. code-block:: none Duroid (tm) does not exist in material library .. GENERATED FROM PYTHON SOURCE LINES 91-94 Create linear array ~~~~~~~~~~~~~~~~~~~ Create the first patch of the linear array. .. GENERATED FROM PYTHON SOURCE LINES 94-101 .. code-block:: default first_patch = Patch(width=1.4e-3, height=1.2e-3, position=0.0) edb.modeler.create_polygon(first_patch.points, "TOP", net_name="Array_antenna") # First line first_line = Line(length=2.4e-3, width=0.3e-3, position=first_patch.width) edb.modeler.create_polygon(first_line.points, "TOP", net_name="Array_antenna") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 102-105 Patch linear array ~~~~~~~~~~~~~~~~~~ Patch the linear array. .. GENERATED FROM PYTHON SOURCE LINES 105-126 .. code-block:: default patch = Patch(width=2.29e-3, height=3.3e-3) line = Line(length=1.9e-3, width=0.2e-3) linear_array = LinearArray(nb_patch=8, array_width=patch.height) current_patch = 1 current_position = first_line.position + first_line.length while current_patch <= linear_array.nbpatch: patch.position = current_position edb.modeler.create_polygon(patch.points, "TOP", net_name="Array_antenna") current_position += patch.width if current_patch < linear_array.nbpatch: line.position = current_position edb.modeler.create_polygon(line.points, "TOP", net_name="Array_antenna") current_position += line.length current_patch += 1 linear_array.length = current_position .. GENERATED FROM PYTHON SOURCE LINES 127-130 Add ground ~~~~~~~~~~ Add a ground. .. GENERATED FROM PYTHON SOURCE LINES 130-134 .. code-block:: default edb.modeler.create_polygon(linear_array.points, "GND", net_name="GND") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 135-138 Add connector pin ~~~~~~~~~~~~~~~~~ Add a central connector pin. .. GENERATED FROM PYTHON SOURCE LINES 138-150 .. code-block:: default edb.padstacks.create(padstackname="Connector_pin", holediam="100um", paddiam="0", antipaddiam="200um") con_pin = edb.padstacks.place( [first_patch.width / 4, 0], "Connector_pin", net_name="Array_antenna", fromlayer="TOP", tolayer="GND", via_name="coax", ) .. GENERATED FROM PYTHON SOURCE LINES 151-154 Add connector ground ~~~~~~~~~~~~~~~~~~~~ Add a connector ground. .. GENERATED FROM PYTHON SOURCE LINES 154-187 .. code-block:: default edb.modeler.create_polygon(first_patch.points, "Virt_GND", net_name="GND") edb.padstacks.create("gnd_via", "100um", "0", "0") con_ref1 = edb.padstacks.place( [first_patch.points[0][0] + 0.2e-3, first_patch.points[0][1] + 0.2e-3], "gnd_via", fromlayer="GND", tolayer="Virt_GND", net_name="GND", ) con_ref2 = edb.padstacks.place( [first_patch.points[1][0] - 0.2e-3, first_patch.points[1][1] + 0.2e-3], "gnd_via", fromlayer="GND", tolayer="Virt_GND", net_name="GND", ) con_ref3 = edb.padstacks.place( [first_patch.points[2][0] - 0.2e-3, first_patch.points[2][1] - 0.2e-3], "gnd_via", fromlayer="GND", tolayer="Virt_GND", net_name="GND", ) con_ref4 = edb.padstacks.place( [first_patch.points[3][0] + 0.2e-3, first_patch.points[3][1] - 0.2e-3], "gnd_via", fromlayer="GND", tolayer="Virt_GND", net_name="GND", ) .. GENERATED FROM PYTHON SOURCE LINES 188-191 Add excitation port ~~~~~~~~~~~~~~~~~~~ Add an excitation port. .. GENERATED FROM PYTHON SOURCE LINES 191-196 .. code-block:: default edb.padstacks.set_solderball(con_pin, "Virt_GND", isTopPlaced=False, ballDiam=0.1e-3) port_name = edb.padstacks.create_coax_port(con_pin) .. GENERATED FROM PYTHON SOURCE LINES 197-200 Plot geometry ~~~~~~~~~~~~~ Plot the geometry. .. GENERATED FROM PYTHON SOURCE LINES 200-203 .. code-block:: default edb.nets.plot(None) .. image-sg:: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_001.png :alt: Cell_01K4KT :srcset: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 204-207 Save and close Edb instance prior to opening it in Electronics Desktop. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Save EDB. .. GENERATED FROM PYTHON SOURCE LINES 207-211 .. code-block:: default edb.save_edb() edb.close_edb() print("EDB saved correctly to {}. You can import in AEDT.".format(aedb_path)) .. rst-class:: sphx-glr-script-out .. code-block:: none EDB saved correctly to D:\Temp\pcb_SQ922L.aedb. You can import in AEDT. .. GENERATED FROM PYTHON SOURCE LINES 212-215 Launch HFSS 3D Layout and open EDB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Launch HFSS 3D Layout and open EDB. .. GENERATED FROM PYTHON SOURCE LINES 215-219 .. code-block:: default h3d = pyaedt.Hfss3dLayout(projectname=aedb_path, specified_version="2023.2", new_desktop_session=True, non_graphical=non_graphical) .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! .. GENERATED FROM PYTHON SOURCE LINES 220-223 Plot geometry ~~~~~~~~~~~~~~~~~ Plot the geometry. The EDB methods are also accessible from the ``Hfss3dlayout`` class. .. GENERATED FROM PYTHON SOURCE LINES 223-226 .. code-block:: default h3d.modeler.edb.nets.plot(None) .. image-sg:: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_002.png :alt: Cell_01K4KT :srcset: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 227-236 Create setup and sweeps ~~~~~~~~~~~~~~~~~~~~~~~ Getters and setters facilitate the settings on the nested property dictionary. Previously, you had to use these commands: - ``setup.props["AdaptiveSettings"]["SingleFrequencyDataList"]["AdaptiveFrequencyData"]["AdaptiveFrequency"] = "20GHz"`` - ``setup.props["AdaptiveSettings"]["SingleFrequencyDataList"]["AdaptiveFrequencyData"]["MaxPasses"] = 4`` You can now use the simpler approach that follows. .. GENERATED FROM PYTHON SOURCE LINES 236-256 .. code-block:: default setup = h3d.create_setup() setup["AdaptiveFrequency"] = "20GHz" setup["AdaptiveSettings/SingleFrequencyDataList/AdaptiveFrequencyData/MaxPasses"] = 4 h3d.create_linear_count_sweep( setupname=setup.name, unit="GHz", freqstart=20, freqstop=50, num_of_freq_points=1001, sweepname="sweep1", sweep_type="Interpolating", interpolation_tol_percent=1, interpolation_max_solutions=255, save_fields=False, use_q3d_for_dc=False, ) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 257-260 Solve setup and create report ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Solve the project and create a report. .. GENERATED FROM PYTHON SOURCE LINES 260-265 .. code-block:: default h3d.analyze() h3d.post.create_report(["db(S({0},{1}))".format(port_name, port_name)]) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 266-269 Plot results outside AEDT ~~~~~~~~~~~~~~~~~~~~~~~~~ Plot results using Matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 269-273 .. code-block:: default solution = h3d.post.get_solution_data(["S({0},{1})".format(port_name, port_name)]) solution.plot() .. image-sg:: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_003.png :alt: Simulation Results Plot :srcset: /examples/00-EDB/images/sphx_glr_03_5G_antenna_example_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 274-279 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 279-282 .. code-block:: default h3d.save_project() h3d.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 12.025 seconds) .. _sphx_glr_download_examples_00-EDB_03_5G_antenna_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 03_5G_antenna_example.py <03_5G_antenna_example.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 03_5G_antenna_example.ipynb <03_5G_antenna_example.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_