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

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

.. _sphx_glr_examples_plot_4kw_dual_three_phase_ipmsm_fvc.py:


4.4-kW dual-three-phase IPMSM, FVC
==================================

This example simulates sensorless flux-vector control (FVC) of an asymmetrical
dual-three-phase interior permanent-magnet synchronous machine (IPMSM) drive. Each
three-phase set corresponds to the 2.2-kW IPMSM of the motulator examples, and the
sets are displaced by 30°. The common mode (CM) of the sets is controlled using the
flux-vector controller of motulator, parametrized with the parallel-connected
equivalent machine. The differential mode (DM) is current-controlled, and the current
sharing between the sets is changed during the simulation [#Rub2021]_.

.. GENERATED FROM PYTHON SOURCE LINES 16-23

.. code-block:: Python

    from math import pi

    import motulator.drive.control.sm as sm_control
    import numpy as np

    from motulator_multiphase import control, model, utils








.. GENERATED FROM PYTHON SOURCE LINES 24-25

Compute base values of the parallel-connected equivalent machine (just for figures).

.. GENERATED FROM PYTHON SOURCE LINES 25-30

.. code-block:: Python


    n_sets = 2
    nom = utils.NominalValues(U=370, I=2 * 4.3, f=75, P=2 * 2.2e3, tau=2 * 14)
    base = utils.BaseValues.from_nominal(nom, n_p=3)








.. GENERATED FROM PYTHON SOURCE LINES 31-34

Configure the system model. The parameters describe one three-phase set, when both
sets carry equal currents. The leakage inductance `L_ls` of a set is not coupled to
the other set, and it determines the DM dynamics.

.. GENERATED FROM PYTHON SOURCE LINES 34-42

.. code-block:: Python


    par = model.SynchronousMachinePars(n_p=3, R_s=3.6, L_d=0.036, L_q=0.051, psi_f=0.545)
    L_ls = 0.005
    machine = model.MultiThreePhaseMachine(par, L_ls=L_ls, n_sets=n_sets)
    mechanics = model.MechanicalSystem(J=2 * 0.015)
    converter = model.MultiThreePhaseConverter(u_dc=540, n_sets=n_sets)
    mdl = model.MultiThreePhaseDrive(machine, mechanics, converter)








.. GENERATED FROM PYTHON SOURCE LINES 43-45

Configure the control system. The flux-vector controller of motulator is used for
the CM.

.. GENERATED FROM PYTHON SOURCE LINES 45-53

.. code-block:: Python


    est_par = utils.to_parallel(par, n_sets)
    cfg = sm_control.FluxVectorControllerCfg(i_s_max=1.5 * base.i, sensorless=True)
    vector_ctrl = sm_control.FluxVectorController(est_par, cfg)
    dm_ctrl = control.DifferentialModeController(L_ls, n_sets=n_sets, alpha_c=2 * pi * 200)
    speed_ctrl = sm_control.SpeedController(J=2 * 0.015, alpha_s=2 * pi * 4)
    ctrl = control.MultiThreePhaseControlSystem(vector_ctrl, dm_ctrl, speed_ctrl)








.. GENERATED FROM PYTHON SOURCE LINES 54-56

Set the speed reference, the load torque, and the current-sharing coefficients. In
the end, the first set carries 75% of the total current.

.. GENERATED FROM PYTHON SOURCE LINES 56-61

.. code-block:: Python


    ctrl.set_speed_ref(lambda t: (t > 0.2) * base.w_M)
    mdl.mechanics.set_external_load_torque(lambda t: (t > 0.8) * nom.tau)
    ctrl.set_current_sharing(lambda t: [1.5, 0.5] if t > 1.2 else [1.0, 1.0])








.. GENERATED FROM PYTHON SOURCE LINES 62-64

Simulate and plot the results. The first figure shows the CM quantities in per-unit
values, and the second one the currents of the sets and the DM.

.. GENERATED FROM PYTHON SOURCE LINES 64-71

.. code-block:: Python


    sim = model.Simulation(mdl, ctrl)
    res = sim.simulate(t_stop=1.6)
    utils.plot(res, base)
    utils.plot_sets(res)
    print("Torque at the end (Nm):", np.round(res.mdl.machine.tau_M[-1], 2))




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


    *

      .. image-sg:: /examples/images/sphx_glr_plot_4kw_dual_three_phase_ipmsm_fvc_001.png
         :alt: plot 4kw dual three phase ipmsm fvc
         :srcset: /examples/images/sphx_glr_plot_4kw_dual_three_phase_ipmsm_fvc_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /examples/images/sphx_glr_plot_4kw_dual_three_phase_ipmsm_fvc_002.png
         :alt: plot 4kw dual three phase ipmsm fvc
         :srcset: /examples/images/sphx_glr_plot_4kw_dual_three_phase_ipmsm_fvc_002.png
         :class: sphx-glr-multi-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Torque at the end (Nm): 28.0




.. GENERATED FROM PYTHON SOURCE LINES 72-77

.. rubric:: References

.. [#Rub2021] Rubino, Dordevic, Armando, Bojoi, Levi, "A novel matrix transformation
   for decoupled control of modular multiphase PMSM drives," IEEE Trans. Power
   Electron., 2021, https://doi.org/10.1109/TPEL.2020.3043083


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

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


.. _sphx_glr_download_examples_plot_4kw_dual_three_phase_ipmsm_fvc.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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