.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\02-HFSS\HFSS_Spiral.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_Spiral.py: HFSS: spiral inductor --------------------- This example shows how you can use PyAEDT to create a spiral inductor, solve it, and plot results. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-17 .. code-block:: default import os import pyaedt project_name = pyaedt.generate_unique_project_name(project_name="spiral") .. GENERATED FROM PYTHON SOURCE LINES 18-22 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: default non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 26-30 Launch HFSS ~~~~~~~~~~~ Launch HFSS 2023 R2 in non-graphical mode and change the units to microns. .. GENERATED FROM PYTHON SOURCE LINES 30-35 .. code-block:: default hfss = pyaedt.Hfss(specified_version="2023.2", non_graphical=non_graphical, designname="A1", new_desktop_session=True) hfss.modeler.model_units = "um" p = hfss.modeler .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! .. GENERATED FROM PYTHON SOURCE LINES 36-40 Define variables ~~~~~~~~~~~~~~~~ Define input variables. You can use the values that follow or edit them. .. GENERATED FROM PYTHON SOURCE LINES 40-50 .. code-block:: default rin = 10 width = 2 spacing = 1 thickness = 1 Np = 8 Nr = 10 gap = 3 hfss["Tsub"] = "6" + hfss.modeler.model_units .. GENERATED FROM PYTHON SOURCE LINES 51-55 Standardize polyline ~~~~~~~~~~~~~~~~~~~~ Standardize the polyline using the ``create_line`` method to fix the width, thickness, and material. .. GENERATED FROM PYTHON SOURCE LINES 55-60 .. code-block:: default def create_line(pts): p.create_polyline(pts, xsection_type="Rectangle", xsection_width=width, xsection_height=thickness, matname="copper") .. GENERATED FROM PYTHON SOURCE LINES 61-65 Create spiral inductor ~~~~~~~~~~~~~~~~~~~~~~ Create the spiral inductor. This spiral inductor is not parametric, but you could parametrize it later. .. GENERATED FROM PYTHON SOURCE LINES 65-78 .. code-block:: default ind = hfss.modeler.create_spiral( internal_radius=rin, width=width, spacing=spacing, turns=Nr, faces=Np, thickness=thickness, material="copper", name="Inductor1", ) .. GENERATED FROM PYTHON SOURCE LINES 79-82 Center return path ~~~~~~~~~~~~~~~~~~ Center the return path. .. GENERATED FROM PYTHON SOURCE LINES 82-90 .. code-block:: default x0, y0, z0 = ind.points[0] x1, y1, z1 = ind.points[-1] create_line([(x0 - width / 2, y0, -gap), (abs(x1) + 5, y0, -gap)]) p.create_box([x0 - width / 2, y0 - width / 2, -gap - thickness / 2], [width, width, gap + thickness], matname="copper") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 91-94 Create port 1 ~~~~~~~~~~~~~ Create port 1. .. GENERATED FROM PYTHON SOURCE LINES 94-102 .. code-block:: default p.create_rectangle(csPlane=pyaedt.constants.PLANE.YZ, position=[abs(x1) + 5, y0 - width / 2, -gap - thickness / 2], dimension_list=[width, "Tsub+{}{}".format(gap, hfss.modeler.model_units)], name="port1" ) hfss.lumped_port(signal="port1", integration_line=pyaedt.constants.AXIS.Z) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 103-106 Create port 2 ~~~~~~~~~~~~~ Create port 2. .. GENERATED FROM PYTHON SOURCE LINES 106-113 .. code-block:: default create_line([(x1 + width / 2, y1, 0), (x1 - 5, y1, 0)]) p.create_rectangle(pyaedt.constants.PLANE.YZ, [x1 - 5, y1 - width / 2, -thickness / 2], [width, "-Tsub"], name="port2") hfss.lumped_port(signal="port2", integration_line=pyaedt.constants.AXIS.Z) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 114-117 Create silicon substrate and ground plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create the silicon substrate and the ground plane. .. GENERATED FROM PYTHON SOURCE LINES 117-126 .. code-block:: default p.create_box([x1 - 20, x1 - 20, "-Tsub-{}{}/2".format(thickness, hfss.modeler.model_units)], [-2 * x1 + 40, -2 * x1 + 40, "Tsub"], matname="silicon") p.create_box([x1 - 20, x1 - 20, "-Tsub-{}{}/2".format(thickness, hfss.modeler.model_units)], [-2 * x1 + 40, -2 * x1 + 40, -0.1], matname="PEC") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 127-130 Assign airbox and radiation ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign the airbox and the radiation. .. GENERATED FROM PYTHON SOURCE LINES 130-140 .. code-block:: default box = p.create_box( [x1 - 20, x1 - 20, "-Tsub-{}{}/2 - 0.1{}".format(thickness, hfss.modeler.model_units, hfss.modeler.model_units)], [-2 * x1 + 40, -2 * x1 + 40, 100], name="airbox", matname="air" ) hfss.assign_radiation_boundary_to_objects("airbox") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 141-145 Assign material override ~~~~~~~~~~~~~~~~~~~~~~~~ Assign a material override so that the validation check does not fail. .. GENERATED FROM PYTHON SOURCE LINES 145-148 .. code-block:: default hfss.change_material_override() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 149-152 Plot model ~~~~~~~~~~ Plot the model. .. GENERATED FROM PYTHON SOURCE LINES 152-155 .. code-block:: default hfss.plot(show=False, export_path=os.path.join(hfss.working_directory, "Image.jpg"), plot_air_objects=False) .. image-sg:: /examples/02-HFSS/images/sphx_glr_HFSS_Spiral_001.png :alt: HFSS Spiral :srcset: /examples/02-HFSS/images/sphx_glr_HFSS_Spiral_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 156-159 Create setup ~~~~~~~~~~~~ Create the setup and define a frequency sweep to solve the project. .. GENERATED FROM PYTHON SOURCE LINES 159-167 .. code-block:: default setup1 = hfss.create_setup(setupname="setup1") setup1.props["Frequency"] = "10GHz" hfss.create_linear_count_sweep(setupname="setup1", unit="GHz", freqstart=1e-3, freqstop=50, num_of_freq_points=451, sweep_type="Interpolating") hfss.save_project() hfss.analyze() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 168-172 Get report data ~~~~~~~~~~~~~~~ Get report data and use the following formulas to calculate the inductance and quality factor. .. GENERATED FROM PYTHON SOURCE LINES 172-176 .. code-block:: default L_formula = "1e9*im(1/Y(1,1))/(2*pi*freq)" Q_formula = "im(Y(1,1))/re(Y(1,1))" .. GENERATED FROM PYTHON SOURCE LINES 177-180 Create output variable ~~~~~~~~~~~~~~~~~~~~~~ Create output variable .. GENERATED FROM PYTHON SOURCE LINES 180-182 .. code-block:: default hfss.create_output_variable("L", L_formula, solution="setup1 : LastAdaptive") .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 183-186 Plot calculated values in Matplotlib ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Plot the calculated values in Matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 186-190 .. code-block:: default data = hfss.post.get_solution_data([L_formula, Q_formula]) data.plot(curves=[L_formula, Q_formula], math_formula="re", xlabel="Freq", ylabel="L and Q") .. image-sg:: /examples/02-HFSS/images/sphx_glr_HFSS_Spiral_002.png :alt: Simulation Results Plot :srcset: /examples/02-HFSS/images/sphx_glr_HFSS_Spiral_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 191-194 Export results to csv file ~~~~~~~~~~~~~~~~~~~~~~~~~~ Export results to csv file .. GENERATED FROM PYTHON SOURCE LINES 194-196 .. code-block:: default data.export_data_to_csv(os.path.join(hfss.toolkit_directory,"output.csv")) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 197-200 Save project and close AEDT ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Save the project and close AEDT. .. GENERATED FROM PYTHON SOURCE LINES 200-203 .. code-block:: default hfss.save_project(project_name) hfss.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 49.490 seconds) .. _sphx_glr_download_examples_02-HFSS_HFSS_Spiral.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: HFSS_Spiral.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: HFSS_Spiral.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_