.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\07-Circuit\Circuit_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_07-Circuit_Circuit_Example.py: Circuit: schematic creation and analysis ---------------------------------------- This example shows how you can use PyAEDT to create a circuit design and run a Nexxim time-domain simulation. .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: Python # sphinx_gallery_thumbnail_path = 'Resources/circuit.png' import ansys.aedt.core .. GENERATED FROM PYTHON SOURCE LINES 17-20 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: Python aedt_version = "2024.2" .. GENERATED FROM PYTHON SOURCE LINES 24-30 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. The Boolean parameter ``new_thread`` defines whether to create a new instance of AEDT or try to connect to an existing instance of it. .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python non_graphical = False new_thread = True .. GENERATED FROM PYTHON SOURCE LINES 35-39 Launch AEDT and Circuit ~~~~~~~~~~~~~~~~~~~~~~~ Launch AEDT and Circuit. The :class:`ansys.aedt.core.Desktop` class initializes AEDT and starts the specified version in the specified mode. .. GENERATED FROM PYTHON SOURCE LINES 39-43 .. code-block:: Python desktop = ansys.aedt.core.launch_desktop(aedt_version, non_graphical, new_thread) aedt_app = ansys.aedt.core.Circuit(project=ansys.aedt.core.generate_unique_project_name()) aedt_app.modeler.schematic.schematic_units = "mil" .. 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 2324 is still running _warn("subprocess %s is still running" % self.pid, C:\actions-runner\_work\pyaedt\pyaedt\.venv\lib\site-packages\ansys\aedt\core\generic\settings.py:231: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys_0bf9f20b-53ab-4ce4-97b2-0987472c9727.log' mode='a' encoding='cp1252'> self.__logger = val .. GENERATED FROM PYTHON SOURCE LINES 44-47 Create circuit setup ~~~~~~~~~~~~~~~~~~~~ Create and customize an LNA (linear network analysis) setup. .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python setup1 = aedt_app.create_setup("MyLNA") setup1.props["SweepDefinition"]["Data"] = "LINC 0GHz 4GHz 10001" .. GENERATED FROM PYTHON SOURCE LINES 52-55 Create components ~~~~~~~~~~~~~~~~~ Create components, such as an inductor, resistor, and capacitor. .. GENERATED FROM PYTHON SOURCE LINES 55-60 .. code-block:: Python inductor = aedt_app.modeler.schematic.create_inductor(name="L1", value=1e-9, location=[0, 0]) resistor = aedt_app.modeler.schematic.create_resistor(name="R1", value=50, location=[500, 0]) capacitor = aedt_app.modeler.schematic.create_capacitor(name="C1", value=1e-12, location=[1000, 0]) .. GENERATED FROM PYTHON SOURCE LINES 61-64 Get all pins ~~~~~~~~~~~~ Get all pins of a specified component. .. GENERATED FROM PYTHON SOURCE LINES 64-67 .. code-block:: Python pins_resistor = resistor.pins .. GENERATED FROM PYTHON SOURCE LINES 68-71 Create port and ground ~~~~~~~~~~~~~~~~~~~~~~ Create a port and a ground, which are needed for the circuit analysis. .. GENERATED FROM PYTHON SOURCE LINES 71-75 .. code-block:: Python port = aedt_app.modeler.components.create_interface_port(name="myport", location=[-200, 0] ) gnd = aedt_app.modeler.components.create_gnd(location=[1200, -100]) .. GENERATED FROM PYTHON SOURCE LINES 76-79 Connect components ~~~~~~~~~~~~~~~~~~ Connect components with wires. .. GENERATED FROM PYTHON SOURCE LINES 79-85 .. code-block:: Python port.pins[0].connect_to_component(assignment=inductor.pins[0], use_wire=True) inductor.pins[1].connect_to_component(assignment=resistor.pins[1], use_wire=True) resistor.pins[0].connect_to_component(assignment=capacitor.pins[0], use_wire=True) capacitor.pins[1].connect_to_component(assignment=gnd.pins[0], use_wire=True) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 86-89 Create transient setup ~~~~~~~~~~~~~~~~~~~~~~ Create a transient setup. .. GENERATED FROM PYTHON SOURCE LINES 89-94 .. code-block:: Python setup2 = aedt_app.create_setup(name="MyTransient", setup_type=aedt_app.SETUPS.NexximTransient) setup2.props["TransientData"] = ["0.01ns", "200ns"] setup3 = aedt_app.create_setup(name="MyDC", setup_type=aedt_app.SETUPS.NexximDC) .. GENERATED FROM PYTHON SOURCE LINES 95-98 Solve transient setup ~~~~~~~~~~~~~~~~~~~~~ Solve the transient setup. .. GENERATED FROM PYTHON SOURCE LINES 98-102 .. code-block:: Python aedt_app.analyze_setup("MyLNA") aedt_app.export_fullwave_spice() .. rst-class:: sphx-glr-script-out .. code-block:: none 'D:\\Temp\\pyaedt_prj_C06\\Project_34I.pyaedt\\Circuit_Design_UJT\\Circuit Design_UJT.sp' .. GENERATED FROM PYTHON SOURCE LINES 103-106 Create report ~~~~~~~~~~~~~ Create a report that plots solution data. .. GENERATED FROM PYTHON SOURCE LINES 106-112 .. code-block:: Python solutions = aedt_app.post.get_solution_data(expressions=aedt_app.get_traces_for_plot(category="S")) solutions.enable_pandas_output = True real, imag = solutions.full_matrix_real_imag print(real) .. rst-class:: sphx-glr-script-out .. code-block:: none S(myport,myport) 0.0000 1.000000 0.0004 1.000000 0.0008 1.000000 0.0012 0.999999 0.0016 0.999999 ... ... 3.9984 0.021101 3.9988 0.021083 3.9992 0.021065 3.9996 0.021046 4.0000 0.021028 [10001 rows x 1 columns] .. GENERATED FROM PYTHON SOURCE LINES 113-116 Plot data ~~~~~~~~~ Create a plot based on solution data. .. GENERATED FROM PYTHON SOURCE LINES 116-119 .. code-block:: Python fig = solutions.plot() .. image-sg:: /examples/07-Circuit/images/sphx_glr_Circuit_Example_001.png :alt: Simulation Results Plot :srcset: /examples/07-Circuit/images/sphx_glr_Circuit_Example_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 120-125 Close AEDT ~~~~~~~~~~ After the simulation completes, you can close AEDT or release it using the :func:`ansys.aedt.core.Desktop.force_close_desktop` method. All methods provide for saving the project before closing. .. GENERATED FROM PYTHON SOURCE LINES 125-127 .. code-block:: Python desktop.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 12.316 seconds) .. _sphx_glr_download_examples_07-Circuit_Circuit_Example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Circuit_Example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Circuit_Example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Circuit_Example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_