Running a JSON-RPC simulations and save only a portion of signal in steady state

Hi all,

I´m running a bunch of simulations in PLECS standalone via the RPC service in MATLAB following the material provided by plexim. This feature works very well for my research purposes. However I found some difficulties what I cannot figure out how to solve. Let me explain well

Imagine that my set of simulation is 200 and I only need to analice voltage and currents of the converter after reaching steady state (for example a couple of fundamental periods). In this way, using the RPC service I get back voltage and currents of whole simulation (for example 1 second) for each simulation results. Is there any option to save just a portion of the signal (like in the scope) for sending back to the MATLAB environment?

On the other hand, If I set up the RPC service for a large simulation batch, is there any functionality to recover the simulated data when available or I need to wait for finish the whole set? Should I make this simulation batch partition manually?

See the OutputTimes and OutputTimesOption solver options in the PLECS manual. With these variables you can control the simulation times that are included in the result of a scripted simulation. I’ll also note this is for a transient simulation called via plecs('simulate',opts) vs Steady-State Analysis, which has a different set of options.

You can use the callback functionality which can post-process the data as it is returned from the simulation engine, but you cannot interact dynamically with the data as it returns back to your console, as the callback function is static. The callback syntax is described for Python and PLECS Standalone simulation scripts in the “Buck Converter with Parameter Sweep” demo model as well as the PLECS documentation.

In addition to batching your scripts, you could use a “To File” block if you would like to take a peek at your data as it is generated, say using another script.

Thank you very much for the proposal, I´ll take a look carefully.

all the best

Glad to hear. I’ll note the “To File” block captures all data at the defined sample time. Since you’re only interested in a portion of your simulation run, you can place the “To File” block inside of an “Enabled Subsystem” and then enable the subsystem for the interval you would like to record your data.

Selecting the proper OutputTimes vector in the RPC calling plecs returns the data I need for analize. So it can be considered solved.

Now I´m dealing about how to use a callback function by the json-rpc matlab version. I try to follow the octave example written in the demo model without success. Do you have some example about how to use callbacks from matlab via json-rpc protocol?

all the best