
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/plot_10kva_lcl_gfl.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_plot_10kva_lcl_gfl.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_plot_10kva_lcl_gfl.py:


10-kVA, LCL filter, GFL
=======================

This example simulates grid-following (GFL) current-vector control of a 10-kVA grid
converter, connected to the grid through an LCL filter, natively. The system is that
of the *motulator* example
:doc:`motulator:grid_examples/grid_following/plot_10kva_lcl_gfl`.

.. GENERATED FROM PYTHON SOURCE LINES 13-17

.. code-block:: Python

    from motulator.grid import control, model, utils

    from motulator_export import native








.. GENERATED FROM PYTHON SOURCE LINES 18-19

Compute base values based on the nominal values.

.. GENERATED FROM PYTHON SOURCE LINES 19-23

.. code-block:: Python


    nom = utils.NominalValues(U=400, I=14.5, f=50, P=10e3)
    base = utils.BaseValues.from_nominal(nom)








.. GENERATED FROM PYTHON SOURCE LINES 24-25

Configure the system model.

.. GENERATED FROM PYTHON SOURCE LINES 25-33

.. code-block:: Python


    ac_filter = model.LCLFilter(
        L_fc=0.073 * base.L, L_fg=0.073 * base.L, C_f=0.043 * base.C, u_f0_ab=base.u
    )
    ac_source = model.ThreePhaseSource(w_g=base.w, e_g=base.u)
    converter = model.VoltageSourceConverter(u_dc=650)
    mdl = model.GridConverterSystem(converter, ac_filter, ac_source)








.. GENERATED FROM PYTHON SOURCE LINES 34-35

Configure the control system.

.. GENERATED FROM PYTHON SOURCE LINES 35-42

.. code-block:: Python


    cfg = control.CurrentVectorControllerCfg(
        i_max=1.5 * base.i, L=0.073 * base.L, T_s=100e-6
    )
    inner_ctrl = control.CurrentVectorController(cfg)
    ctrl = control.GridConverterControlSystem(inner_ctrl)








.. GENERATED FROM PYTHON SOURCE LINES 43-44

Set the references for the converter output power.

.. GENERATED FROM PYTHON SOURCE LINES 44-48

.. code-block:: Python


    ctrl.set_power_ref(lambda t: (t > 0.02) * 5e3)
    ctrl.set_reactive_power_ref(lambda t: (t > 0.04) * 4e3)








.. GENERATED FROM PYTHON SOURCE LINES 49-50

Simulate natively and plot the results.

.. GENERATED FROM PYTHON SOURCE LINES 50-55

.. code-block:: Python


    sim = native.Simulation(mdl, ctrl)
    res = sim.simulate(t_stop=0.08)
    utils.plot_control_signals(res, base)
    utils.plot_grid_waveforms(res, base)



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /examples/images/sphx_glr_plot_10kva_lcl_gfl_001.png
         :alt: plot 10kva lcl gfl
         :srcset: /examples/images/sphx_glr_plot_10kva_lcl_gfl_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /examples/images/sphx_glr_plot_10kva_lcl_gfl_002.png
         :alt: plot 10kva lcl gfl
         :srcset: /examples/images/sphx_glr_plot_10kva_lcl_gfl_002.png
         :class: sphx-glr-multi-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.231 seconds)


.. _sphx_glr_download_examples_plot_10kva_lcl_gfl.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_10kva_lcl_gfl.ipynb <plot_10kva_lcl_gfl.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_10kva_lcl_gfl.py <plot_10kva_lcl_gfl.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_10kva_lcl_gfl.zip <plot_10kva_lcl_gfl.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
