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

.. only:: html

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

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

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

.. _sphx_glr_grid_examples_identification_plot_13kva_do_gfm_identification.py:


12.5-kVA, DO-GFM, converter output admittance identification
============================================================

This example demonstrates converter output admittance identification using a 12.5-kVA
disturbance-observer-based grid-forming (DO-GFM) converter.

.. GENERATED FROM PYTHON SOURCE LINES 11-13

.. code-block:: Python

    from motulator.grid import control, model, utils








.. GENERATED FROM PYTHON SOURCE LINES 14-15

Compute base values based on the nominal values.

.. GENERATED FROM PYTHON SOURCE LINES 15-19

.. code-block:: Python


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








.. GENERATED FROM PYTHON SOURCE LINES 20-21

Configure the identification.

.. GENERATED FROM PYTHON SOURCE LINES 21-33

.. code-block:: Python


    identification_cfg = utils.IdentificationCfg(
        abs_u_e=0.01 * base.u,
        f_start=1,
        f_stop=10e3,
        n_freqs=100,
        T_s=1 / 10e3,
        # Uncomment the row below to save identification results in "project root"/data
        # filename="do-gfm_admittance",
        filetype="csv",
    )








.. GENERATED FROM PYTHON SOURCE LINES 34-35

Configure the system model.

.. GENERATED FROM PYTHON SOURCE LINES 35-41

.. code-block:: Python


    ac_filter = model.LFilter(L_f=0.15 * base.L, R_f=0.05 * base.Z, L_g=0.74 * base.L)
    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 42-43

Configure the control system.

.. GENERATED FROM PYTHON SOURCE LINES 43-58

.. code-block:: Python


    inner_ctrl = control.ObserverBasedGridFormingController(
        i_max=1.3 * base.i,
        L=0.35 * base.L,
        R=0.05 * base.Z,
        R_a=0.2 * base.Z,
        u_nom=base.u,
        w_nom=base.w,
        T_s=identification_cfg.T_s,
    )
    ctrl = control.GridConverterControlSystem(inner_ctrl)

    ctrl.set_power_ref(0.5 * base.p)
    ctrl.set_ac_voltage_ref(base.u)








.. GENERATED FROM PYTHON SOURCE LINES 59-60

Run the identification and plot results.

.. GENERATED FROM PYTHON SOURCE LINES 60-64

.. code-block:: Python


    res = utils.run_identification(identification_cfg, mdl, ctrl)
    utils.plot_identification(res, plot_style="re_im")
    utils.plot_vector_identification(res, base)



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


    *

      .. image-sg:: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_001.png
         :alt: plot 13kva do gfm identification
         :srcset: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_002.png
         :alt: plot 13kva do gfm identification
         :srcset: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_002.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_003.png
         :alt: plot 13kva do gfm identification
         :srcset: /grid_examples/identification/images/sphx_glr_plot_13kva_do_gfm_identification_003.png
         :class: sphx-glr-multi-img






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

   **Total running time of the script:** (5 minutes 29.133 seconds)


.. _sphx_glr_download_grid_examples_identification_plot_13kva_do_gfm_identification.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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