motulator_export.plecs
======================

.. py:module:: motulator_export.plecs

.. autoapi-nested-parse::

   
   Export motulator systems to PLECS.

   `write_model` writes a PLECS Standalone model of a system built in motulator, and
   `simulate` runs the model via the RPC interface of PLECS Standalone.















   ..
       !! processed by numpydoc !!


Functions
---------

.. autoapisummary::

   motulator_export.plecs.simulate
   motulator_export.plecs.write_model


Package Contents
----------------

.. py:function:: simulate(path, t_eval, mdl, ctrl)

   
   Simulate the PLECS model of the system via the RPC interface of PLECS Standalone.

   The model must have the output ports (`write_model` with ``outputs=True``).

   :param path: Path of the model file.
   :type path: str | Path
   :param t_eval: Output times (s).
   :type t_eval: ndarray
   :param mdl: Continuous-time system model of the written model.
   :type mdl: Drive | GridConverterSystem
   :param ctrl: Discrete-time control system of the written model, which defines the
                monitored signals.
   :type ctrl: VectorControlSystem | VHzControlSystem | GridConverterControlSystem

   :returns: * **mdl** (*dict[str, ndarray]*) -- Signals of the system model (the output port "mdl") and the time "t".
             * **ctrl** (*dict[str, ndarray]*) -- Monitored signals of the control system (the output port "ctrl") and the time
               "t".















   ..
       !! processed by numpydoc !!

.. py:function:: write_model(path, mdl, ctrl, t_stop, outputs = False)

   
   Write a PLECS model of the system.

   The references of the control system (e.g., `set_speed_ref`), the external load
   torque (`set_external_load_torque`), and the gate enable (`set_enable`) are read
   from `ctrl` and `mdl`, each a constant or a `StepSignal`. The model starts from
   the state of `mdl`, e.g., its initial speed. A system that is not supported
   raises `NotImplementedError`, and an invalid argument `ValueError`, before any
   file is written.

   :param path: Path of the model file (.plecs). The model refers to the C sources of the
                package by a path relative to the model file.
   :type path: str | Path
   :param mdl: Continuous-time system model.
   :type mdl: Drive | GridConverterSystem
   :param ctrl: Discrete-time control system.
   :type ctrl: VectorControlSystem | VHzControlSystem | GridConverterControlSystem
   :param t_stop: Simulation stop time (s).
   :type t_stop: float
   :param outputs: Add the output ports "mdl" and "ctrl" for `simulate`, defaults to False.
   :type outputs: bool, optional

   :returns: Path of the written model file.
   :rtype: Path















   ..
       !! processed by numpydoc !!

