motulator_export.plecs

motulator_export.plecs#

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.

Functions#

simulate(path, t_eval, mdl, ctrl)

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

write_model(path, mdl, ctrl, t_stop[, outputs])

Write a PLECS model of the system.

Package Contents#

motulator_export.plecs.simulate(path, t_eval, mdl, ctrl)[source]#

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

Parameters:
  • path (str | Path) – Path of the model file.

  • t_eval (ndarray) – Output times (s).

  • mdl (Drive | GridConverterSystem) – Continuous-time system model of the written model.

  • ctrl (VectorControlSystem | VHzControlSystem | GridConverterControlSystem) – Discrete-time control system of the written model, which defines the monitored signals.

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”.

Return type:

tuple[dict[str, numpy.ndarray], dict[str, numpy.ndarray]]

motulator_export.plecs.write_model(path, mdl, ctrl, t_stop, outputs=False)[source]#

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.

Parameters:
  • path (str | 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.

  • mdl (Drive | GridConverterSystem) – Continuous-time system model.

  • ctrl (VectorControlSystem | VHzControlSystem | GridConverterControlSystem) – Discrete-time control system.

  • t_stop (float) – Simulation stop time (s).

  • outputs (bool, optional) – Add the output ports “mdl” and “ctrl” for simulate, defaults to False.

Returns:

Path of the written model file.

Return type:

Path