Simulation Scripting with PLECS Standalone

This tutorial video provides the viewer with an overview of writing simulation scripts with PLECS Standalone. The highlights of the video are using the internal scripting environment of PLECS Standalone to set up a parameterization sweep and view multiple waveform traces related to a system with different operating conditions in a PLECS Scope. After, the capability of controlling PLECS Standalone from an external scripting environment is demonstrated as the same functionality already shown is then executed from Python code.

Scripting in PLECS Blockset is done from the MATLAB command line or using .m file scripts. See the demo model "Buck Converter with Parameter Sweep" in both PLECS Blockset and PLECS Standalone for example scripts and instructions on how to get started with using scripts to execute simulations.

The internal simulation script that was shown in PLECS Standalone in this tutorial video using the "Boost" demo model is provided below:

mdl = plecs('get', '', 'CurrentCircuit');
scopepath = [mdl '/Scope'];

loadStructure = struct('varR', 4);
varStructure = struct('ModelVars', loadStructure);
plecs('scope', scopepath, 'ClearTraces');

RVals = [3, 4, 5];

for ix = 1:length(RVals)
  varStructure.ModelVars.varR = RVals(ix);
  plecs('simulate', varStructure);
  plecs('scope', scopepath, 'HoldTrace', ['R = ' mat2str(RVals(ix)) ' ohms']);
end

The Python code that was executed to control PLECS Standalone externally can be downloaded here. Be sure to set the proper path to the model file and the model file name in the script (for example, use the "Boost" demo model provided with PLECS).

Englisch