
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/plot_2kw_im_diode_vhz.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_2kw_im_diode_vhz.py>`
        to download the full example code.

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

.. _sphx_glr_examples_plot_2kw_im_diode_vhz.py:


2.2-kW IM, diode bridge, V/Hz control
=====================================

This example simulates pure open-loop V/Hz control of a 2.2-kW induction machine (IM)
drive natively. The system is that of the *motulator* example
:doc:`motulator:drive_examples/vhz/plot_2kw_im_diode_vhz`: a diode bridge, a stiff
three-phase grid, and a DC link are modeled, the load torque is quadratic, and the
converter uses carrier comparison.

.. GENERATED FROM PYTHON SOURCE LINES 14-21

.. code-block:: Python

    from math import inf, pi

    import motulator.drive.control.im as control
    from motulator.drive import model, utils

    from motulator_export import native








.. GENERATED FROM PYTHON SOURCE LINES 22-23

Compute base values based on the nominal values.

.. GENERATED FROM PYTHON SOURCE LINES 23-27

.. code-block:: Python


    nom = utils.NominalValues(U=400, I=5, f=50, P=2.2e3, tau=14.6)
    base = utils.BaseValues.from_nominal(nom, n_p=2)








.. GENERATED FROM PYTHON SOURCE LINES 28-29

Configure the system model.

.. GENERATED FROM PYTHON SOURCE LINES 29-42

.. code-block:: Python


    par = model.InductionMachineInvGammaPars(
        n_p=2, R_s=3.7, R_R=2.1, L_sgm=0.021, L_M=0.224
    )
    machine = model.InductionMachine(par)
    k = 1.1 * nom.tau / base.w_M**2  # Quadratic load torque profile
    mechanics = model.MechanicalSystem(J=0.015, B_L=lambda w_M: k * abs(w_M))
    converter = model.VoltageSourceConverter()
    dc_bus = model.DiodeBridgeDCBus(
        C_dc=235e-6, L_dc=2e-3, U_g=nom.U, f_g=nom.f, converters=[converter]
    )
    mdl = model.Drive(machine, mechanics, converter, pwm=True, dc_bus=dc_bus)








.. GENERATED FROM PYTHON SOURCE LINES 43-45

Configure the control system. The open-loop V/Hz control is the observer-based V/Hz
control with the machine model `L_M = inf` and zero gains.

.. GENERATED FROM PYTHON SOURCE LINES 45-53

.. code-block:: Python


    est_par = control.InductionMachineInvGammaPars(n_p=2, R_s=0, R_R=0, L_sgm=0, L_M=inf)
    cfg = control.ObserverBasedVHzControllerCfg(
        psi_s_nom=base.psi, i_s_max=inf, alpha_f=0, alpha_tau=0, alpha_psi=0
    )
    vhz_ctrl = control.ObserverBasedVHzController(est_par, cfg)
    ctrl = control.VHzControlSystem(vhz_ctrl, slew_rate=2 * pi * 60)








.. GENERATED FROM PYTHON SOURCE LINES 54-55

Set the speed reference and the external load torque.

.. GENERATED FROM PYTHON SOURCE LINES 55-59

.. code-block:: Python


    ctrl.set_speed_ref(lambda t: (t > 0.2) * base.w_M)
    mdl.mechanics.set_external_load_torque(lambda t: (t > 1) * 0.2 * nom.tau)








.. GENERATED FROM PYTHON SOURCE LINES 60-61

Simulate natively and plot the results.

.. GENERATED FROM PYTHON SOURCE LINES 61-67

.. code-block:: Python


    sim = native.Simulation(mdl, ctrl)
    res = sim.simulate(t_stop=1.4)
    utils.plot(res, base)
    utils.plot_stator_waveforms(res, base, t_lims=(1.1, 1.125))
    utils.plot_dc_bus_waveforms(res, base, t_lims=(1.1, 1.125))



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


    *

      .. image-sg:: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_001.png
         :alt: plot 2kw im diode vhz
         :srcset: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_002.png
         :alt: plot 2kw im diode vhz
         :srcset: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_002.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_003.png
         :alt: plot 2kw im diode vhz
         :srcset: /examples/images/sphx_glr_plot_2kw_im_diode_vhz_003.png
         :class: sphx-glr-multi-img






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

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


.. _sphx_glr_download_examples_plot_2kw_im_diode_vhz.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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