motulator_export.simulink#
Export motulator systems to Simulink.
write_model writes the MATLAB scripts that build a Simulink model of a system built in motulator, and simulate builds and runs the model via the MATLAB Engine API for Python.
Functions#
|
Simulate the Simulink model of the system via the MATLAB Engine API for Python. |
|
Write the MATLAB scripts that build the Simulink model of the system. |
Package Contents#
- motulator_export.simulink.simulate(path, t_eval, mdl, ctrl, build=True)[source]#
Simulate the Simulink model of the system via the MATLAB Engine API for Python.
- Parameters:
path (str | Path) – Path of the model (.slx), next to its scripts.
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.
build (bool, optional) – Run the build script build_<model>.m first, defaults to True.
- 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:
- motulator_export.simulink.write_model(path, mdl, ctrl, t_stop, code='c')[source]#
Write the MATLAB scripts that build the Simulink model of the system.
Running build_<model>.m in MATLAB builds the model and saves it in the same folder. The model runs init_<model>.m, which defines the parameters, after loading and at the start of each simulation. The references are read from mdl and ctrl as in plecs.write_model, but the gate enable must be 1, since the system model of Simulink does not block the gates.
- Parameters:
path (str | Path) – Path of the model (.slx). The scripts build_<model>.m and init_<model>.m are written in the same folder, with the sources of the S-functions (sfun_*.c) or the MATLAB functions (mfun_*.m) of the blocks.
mdl (Drive | GridConverterSystem) – Continuous-time system model.
ctrl (VectorControlSystem | VHzControlSystem | GridConverterControlSystem) – Discrete-time control system.
t_stop (float) – Simulation stop time (s).
code (str, optional) – Code of the blocks of the control system: “c” (the C port in S-functions, the default) or “matlab” (the MATLAB port in MATLAB Function blocks).
- Returns:
Path of the build script.
- Return type:
Path