.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\05-Q3D\Q3D_Example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_examples_05-Q3D_Q3D_Example.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_05-Q3D_Q3D_Example.py: Q3D Extractor: busbar analysis ------------------------------ This example shows how you can use PyAEDT to create a busbar design in Q3D Extractor and run a simulation. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-15 .. code-block:: Python import os import pyaedt .. GENERATED FROM PYTHON SOURCE LINES 16-19 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: Python aedt_version = "2024.1" .. GENERATED FROM PYTHON SOURCE LINES 23-27 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 31-35 Set debugger mode ~~~~~~~~~~~~~~~~~ PyAEDT allows to enable a debug logger which logs all methods called and argument passed. This example shows how to enable it. .. GENERATED FROM PYTHON SOURCE LINES 35-41 .. code-block:: Python pyaedt.settings.enable_debug_logger = True pyaedt.settings.enable_debug_methods_argument_logger = True pyaedt.settings.enable_debug_internal_methods_logger = False .. GENERATED FROM PYTHON SOURCE LINES 42-46 Launch AEDT and Q3D Extractor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Launch AEDT 2023 R2 in graphical mode and launch Q3D Extractor. This example uses SI units. .. GENERATED FROM PYTHON SOURCE LINES 46-52 .. code-block:: Python q = pyaedt.Q3d(projectname=pyaedt.generate_unique_project_name(), specified_version=aedt_version, non_graphical=non_graphical, new_desktop_session=True) .. rst-class:: sphx-glr-script-out .. code-block:: none C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 10652 is still running _warn("subprocess %s is still running" % self.pid, C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\pyaedt\generic\settings.py:383: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys.log' mode='a' encoding='cp1252'> self._logger = val .. GENERATED FROM PYTHON SOURCE LINES 53-56 Create primitives ~~~~~~~~~~~~~~~~~ Create polylines for three busbars and a box for the substrate. .. GENERATED FROM PYTHON SOURCE LINES 56-75 .. code-block:: Python b1 = q.modeler.create_polyline([[0, 0, 0], [-100, 0, 0]], name="Bar1", material="copper", xsection_type="Rectangle", xsection_width="5mm", xsection_height="1mm") q.modeler["Bar1"].color = (255, 0, 0) q.modeler.create_polyline([[0, -15, 0], [-150, -15, 0]], name="Bar2", material="aluminum", xsection_type="Rectangle", xsection_width="5mm", xsection_height="1mm") q.modeler["Bar2"].color = (0, 255, 0) q.modeler.create_polyline([[0, -30, 0], [-175, -30, 0], [-175, -10, 0]], name="Bar3", material="copper", xsection_type="Rectangle", xsection_width="5mm", xsection_height="1mm") q.modeler["Bar3"].color = (0, 0, 255) q.modeler.create_box([50, 30, -0.5], [-250, -100, -3], name="substrate", material="FR4_epoxy") q.modeler["substrate"].color = (128, 128, 128) q.modeler["substrate"].transparency = 0.8 q.plot(show=False, export_path=os.path.join(q.working_directory, "Q3D.jpg"), plot_air_objects=False) .. image-sg:: /examples/05-Q3D/images/sphx_glr_Q3D_Example_001.png :alt: Q3D Example :srcset: /examples/05-Q3D/images/sphx_glr_Q3D_Example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none <pyaedt.generic.plot.ModelPlotter object at 0x000002265F92A800> .. GENERATED FROM PYTHON SOURCE LINES 76-80 Set up boundaries ~~~~~~~~~~~~~~~~~ Identify nets and assign sources and sinks to all nets. There is a source and sink for each busbar. .. GENERATED FROM PYTHON SOURCE LINES 80-92 .. code-block:: Python q.auto_identify_nets() q.source("Bar1", direction=q.AxisDir.XPos, name="Source1") q.sink("Bar1", direction=q.AxisDir.XNeg, name="Sink1") q.source("Bar2", direction=q.AxisDir.XPos, name="Source2") q.sink("Bar2", direction=q.AxisDir.XNeg, name="Sink2") q.source("Bar3", direction=q.AxisDir.XPos, name="Source3") bar3_sink = q.sink("Bar3", direction=q.AxisDir.YPos) bar3_sink.name = "Sink3" .. GENERATED FROM PYTHON SOURCE LINES 93-96 Print information ~~~~~~~~~~~~~~~~~ Use the different methods available to print net and terminal information. .. GENERATED FROM PYTHON SOURCE LINES 96-105 .. code-block:: Python print(q.nets) print(q.net_sinks("Bar1")) print(q.net_sinks("Bar2")) print(q.net_sinks("Bar3")) print(q.net_sources("Bar1")) print(q.net_sources("Bar2")) print(q.net_sources("Bar3")) .. rst-class:: sphx-glr-script-out .. code-block:: none ['Bar1', 'Bar2', 'Bar3'] ['Sink1'] ['Sink2'] ['Sink3'] ['Source1'] ['Source2'] ['Source3'] .. GENERATED FROM PYTHON SOURCE LINES 106-110 Create setup ~~~~~~~~~~~~ Create a setup for Q3D Extractor and add a sweep that defines the adaptive frequency value. .. GENERATED FROM PYTHON SOURCE LINES 110-118 .. code-block:: Python setup1 = q.create_setup(props={"AdaptiveFreq": "100MHz"}) sw1 = setup1.add_sweep() sw1.props["RangeStart"] = "1MHz" sw1.props["RangeEnd"] = "100MHz" sw1.props["RangeStep"] = "5MHz" sw1.update() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 119-122 Get curves to plot ~~~~~~~~~~~~~~~~~~ Get the curves to plot. The following code simplifies the way to get curves. .. GENERATED FROM PYTHON SOURCE LINES 122-126 .. code-block:: Python data_plot_self = q.matrices[0].get_sources_for_plot(get_self_terms=True, get_mutual_terms=False) data_plot_mutual = q.get_traces_for_plot(get_self_terms=False, get_mutual_terms=True, category="C") .. GENERATED FROM PYTHON SOURCE LINES 127-130 Create rectangular plot ~~~~~~~~~~~~~~~~~~~~~~~ Create a rectangular plot and a data table. .. GENERATED FROM PYTHON SOURCE LINES 130-134 .. code-block:: Python q.post.create_report(expressions=data_plot_self) q.post.create_report(expressions=data_plot_mutual, plot_type="Data Table", context="Original") .. rst-class:: sphx-glr-script-out .. code-block:: none <pyaedt.modules.report_templates.Standard object at 0x000002265F711030> .. GENERATED FROM PYTHON SOURCE LINES 135-138 Solve setup ~~~~~~~~~~~ Solve the setup. .. GENERATED FROM PYTHON SOURCE LINES 138-142 .. code-block:: Python q.analyze() q.save_project() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 143-146 Get report data ~~~~~~~~~~~~~~~ Get the report data into a data structure that allows you to manipulate it. .. GENERATED FROM PYTHON SOURCE LINES 146-150 .. code-block:: Python a = q.post.get_solution_data(expressions=data_plot_self, context="Original") a.plot() .. image-sg:: /examples/05-Q3D/images/sphx_glr_Q3D_Example_002.png :alt: Simulation Results Plot :srcset: /examples/05-Q3D/images/sphx_glr_Q3D_Example_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument. <Figure size 2000x1000 with 1 Axes> .. GENERATED FROM PYTHON SOURCE LINES 151-155 Close AEDT ~~~~~~~~~~ After the simulation completes, you can close AEDT or release it using the ``release_desktop`` method. All methods provide for saving projects before closing. .. GENERATED FROM PYTHON SOURCE LINES 155-159 .. code-block:: Python pyaedt.settings.enable_debug_logger = False pyaedt.settings.enable_debug_methods_argument_logger = False q.release_desktop(close_projects=True, close_desktop=True) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 0.602 seconds) .. _sphx_glr_download_examples_05-Q3D_Q3D_Example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Q3D_Example.ipynb <Q3D_Example.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Q3D_Example.py <Q3D_Example.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_