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

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

.. _sphx_glr_examples_plot_1kw_triple_three_phase_spmsm_cvc.py:


1.1-kW triple-three-phase SPMSM, CVC
====================================

This example simulates current-vector control (CVC) of a nine-phase surface-mounted
permanent-magnet synchronous machine (SPMSM) with three three-phase sets. The sets are
displaced by 15°, which differs from the standard 20° of asymmetrical nine-phase
machines. The machine parameters are from [#Rub2021]_. The common mode (CM) of the sets
is controlled using the current-vector controller of motulator, parametrized with the
parallel-connected equivalent machine, and the differential modes (DMs) are
current-controlled. The current sharing between the sets is changed during the
simulation.

.. GENERATED FROM PYTHON SOURCE LINES 17-24

.. 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 25-30

Configure the system model. In the multi-stator model of [#Rub2021]_, the flux
linkage of the set k is `psi_k = L_ls*i_k + M*sum(i_z) + psi_f`. When all sets carry
equal currents, the inductance of a set is `L_ls + n_sets*M`, which is used here.
The model assumes identical sets, so the stator resistance and the leakage
inductance of the sets 1 and 3 are used (the set 2 has 7.9 Ω and 10.3 mH).

.. GENERATED FROM PYTHON SOURCE LINES 30-44

.. code-block:: Python


    n_sets = 3
    R_s, L_ls, M, psi_f = 8.2, 18.5e-3, 10.5e-3, 0.265
    L_s = L_ls + n_sets * M
    par = model.SynchronousMachinePars(n_p=3, R_s=R_s, L_d=L_s, L_q=L_s, psi_f=psi_f)
    theta_sets = np.radians([0, 15, 30])
    machine = model.MultiThreePhaseMachine(
        par, L_ls=L_ls, n_sets=n_sets, theta_sets=theta_sets
    )
    mechanics = model.MechanicalSystem(J=0.0133)
    converter = model.MultiThreePhaseConverter(u_dc=450, n_sets=n_sets)
    sensors = model.DriveSensors(theta_M=model.Sensor())  # Sensored control
    mdl = model.MultiThreePhaseDrive(machine, mechanics, converter, sensors=sensors)








.. GENERATED FROM PYTHON SOURCE LINES 45-47

Configure the control system. The current amplitude of each set is limited to 3.5 A,
as in [#Rub2021]_.

.. GENERATED FROM PYTHON SOURCE LINES 47-57

.. code-block:: Python


    est_par = utils.to_parallel(par, n_sets)
    cfg = sm_control.CurrentVectorControllerCfg(i_s_max=n_sets * 3.5, sensorless=False)
    vector_ctrl = sm_control.CurrentVectorController(est_par, cfg)
    dm_ctrl = control.DifferentialModeController(L_ls, n_sets=n_sets)
    speed_ctrl = sm_control.SpeedController(J=0.0133, alpha_s=2 * pi * 4)
    ctrl = control.MultiThreePhaseControlSystem(
        vector_ctrl, dm_ctrl, speed_ctrl, theta_sets=theta_sets
    )








.. GENERATED FROM PYTHON SOURCE LINES 58-61

Set the speed reference, the rated load torque of 7.1 Nm, and the current sharing.
The rated current is 1.4 A (rms) per set. In the end, the sets carry 50%, 30%, and
20% of the total current.

.. GENERATED FROM PYTHON SOURCE LINES 61-66

.. code-block:: Python


    ctrl.set_speed_ref(lambda t: (t > 0.1) * 2 * pi * 1000 / 60)
    mdl.mechanics.set_external_load_torque(lambda t: (t > 0.5) * 7.1)
    ctrl.set_current_sharing(lambda t: [1.5, 0.9, 0.6] if t > 0.8 else n_sets * [1.0])








.. GENERATED FROM PYTHON SOURCE LINES 67-70

Simulate and plot the results. The first figure shows the CM quantities, where the
current is the sum of the set currents, and the second one the currents of the sets
and the DMs.

.. GENERATED FROM PYTHON SOURCE LINES 70-76

.. code-block:: Python


    sim = model.Simulation(mdl, ctrl)
    res = sim.simulate(t_stop=1.2)
    utils.plot(res)
    utils.plot_sets(res)




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


    *

      .. image-sg:: /examples/images/sphx_glr_plot_1kw_triple_three_phase_spmsm_cvc_001.png
         :alt: plot 1kw triple three phase spmsm cvc
         :srcset: /examples/images/sphx_glr_plot_1kw_triple_three_phase_spmsm_cvc_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /examples/images/sphx_glr_plot_1kw_triple_three_phase_spmsm_cvc_002.png
         :alt: plot 1kw triple three phase spmsm cvc
         :srcset: /examples/images/sphx_glr_plot_1kw_triple_three_phase_spmsm_cvc_002.png
         :class: sphx-glr-multi-img





.. GENERATED FROM PYTHON SOURCE LINES 77-82

.. 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 12.059 seconds)


.. _sphx_glr_download_examples_plot_1kw_triple_three_phase_spmsm_cvc.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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