.. 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-17 .. code-block:: default # sphinx_gallery_thumbnail_path = 'Resources/circuit.png' import pyaedt import os .. GENERATED FROM PYTHON SOURCE LINES 18-21 Launch AEDT ~~~~~~~~~~~ Launch AEDT 2023 R2 in graphical mode. This example uses SI units. .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: default desktop_version = "2023.2" .. GENERATED FROM PYTHON SOURCE LINES 25-31 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 31-35 .. code-block:: default non_graphical = False new_thread = True .. GENERATED FROM PYTHON SOURCE LINES 36-40 Launch AEDT and Circuit ~~~~~~~~~~~~~~~~~~~~~~~ Launch AEDT and Circuit. The :class:`pyaedt.Desktop` class initializes AEDT and starts the specified version in the specified mode. .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: default desktop = pyaedt.launch_desktop(desktop_version, non_graphical, new_thread) aedt_app = pyaedt.Circuit(projectname=pyaedt.generate_unique_project_name()) aedt_app.modeler.schematic.schematic_units = "mil" .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! Returning found desktop with PID 9076! .. GENERATED FROM PYTHON SOURCE LINES 45-48 Create circuit setup ~~~~~~~~~~~~~~~~~~~~ Create and customize an LNA (linear network analysis) setup. .. GENERATED FROM PYTHON SOURCE LINES 48-52 .. code-block:: default setup1 = aedt_app.create_setup("MyLNA") setup1.props["SweepDefinition"]["Data"] = "LINC 0GHz 4GHz 10001" .. GENERATED FROM PYTHON SOURCE LINES 53-56 Create components ~~~~~~~~~~~~~~~~~ Create components, such as an inductor, resistor, and capacitor. .. GENERATED FROM PYTHON SOURCE LINES 56-61 .. code-block:: default inductor = aedt_app.modeler.schematic.create_inductor(compname="L1", value=1e-9, location=[0, 0]) resistor = aedt_app.modeler.schematic.create_resistor(compname="R1", value=50, location=[500, 0]) capacitor = aedt_app.modeler.schematic.create_capacitor(compname="C1", value=1e-12, location=[1000, 0]) .. GENERATED FROM PYTHON SOURCE LINES 62-65 Get all pins ~~~~~~~~~~~~ Get all pins of a specified component. .. GENERATED FROM PYTHON SOURCE LINES 65-68 .. code-block:: default pins_resistor = resistor.pins .. GENERATED FROM PYTHON SOURCE LINES 69-72 Create port and ground ~~~~~~~~~~~~~~~~~~~~~~ Create a port and a ground, which are needed for the circuit analysis. .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: default 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 77-80 Connect components ~~~~~~~~~~~~~~~~~~ Connect components with wires. .. GENERATED FROM PYTHON SOURCE LINES 80-86 .. code-block:: default port.pins[0].connect_to_component(component_pin=inductor.pins[0], use_wire=True) inductor.pins[1].connect_to_component(component_pin=resistor.pins[1], use_wire=True) resistor.pins[0].connect_to_component(component_pin=capacitor.pins[0], use_wire=True) capacitor.pins[1].connect_to_component(component_pin=gnd.pins[0], use_wire=True) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 87-90 Create transient setup ~~~~~~~~~~~~~~~~~~~~~~ Create a transient setup. .. GENERATED FROM PYTHON SOURCE LINES 90-95 .. code-block:: default setup2 = aedt_app.create_setup(setupname="MyTransient", setuptype=aedt_app.SETUPS.NexximTransient) setup2.props["TransientData"] = ["0.01ns", "200ns"] setup3 = aedt_app.create_setup(setupname="MyDC", setuptype=aedt_app.SETUPS.NexximDC) .. GENERATED FROM PYTHON SOURCE LINES 96-99 Solve transient setup ~~~~~~~~~~~~~~~~~~~~~ Solve the transient setup. .. GENERATED FROM PYTHON SOURCE LINES 99-103 .. code-block:: default aedt_app.analyze_setup("MyLNA") aedt_app.export_fullwave_spice() .. rst-class:: sphx-glr-script-out .. code-block:: none 'D:/Temp/pyaedt_prj_J4J/Project_9MZ.pyaedt\\Circuit_Design_B01\\Circuit Design_B01.sp' .. GENERATED FROM PYTHON SOURCE LINES 104-107 Create report ~~~~~~~~~~~~~ Create a report that plots solution data. .. GENERATED FROM PYTHON SOURCE LINES 107-115 .. code-block:: default 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 116-119 Plot data ~~~~~~~~~ Create a plot based on solution data. .. GENERATED FROM PYTHON SOURCE LINES 119-122 .. code-block:: default 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 123-128 Close AEDT ~~~~~~~~~~ After the simulation completes, you can close AEDT or release it using the :func:`pyaedt.Desktop.force_close_desktop` method. All methods provide for saving the project before closing. .. GENERATED FROM PYTHON SOURCE LINES 128-130 .. code-block:: default desktop.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 51.879 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-python :download:`Download Python source code: Circuit_Example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Circuit_Example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_