Running two models simultaneously with jsonrpc

Hi,

I have two scripts in matlab to run models with jsonrpc from https://github.com/plexim/matlab-jsonrpc.

Independently they are able to run their respective models, but if ran simultaneously (e.g. with two instances of Matlab), one of them failes with the error like:

server responded with error -32500 when invoking ‘plecs.simulate’: method execution error: The server is busy executing the blocking command “simulate(‘TheTest’)”.

Is there any means to run several plecs models simultaneously with matlab?

I noted you reached out on both the PLECS Forum and through support@plexim.com. I’ll add the initial response below for other forum users to see, while you continue your conversation with our Applications Engineering Team.

“”"

As the error message indicates, the plecs.simulation method is a blocking command, which means that you are not able pass any other command until the current plecs.simulate has finished executing.

Could you give me a bit more details on the two PLECS models, and their specific differences? If, for example, you want to test different control strategies for the same overall application you could use the Configurable Subsystem block to store the two control algorithms in the same PLECS model, and then run a parallel parameter sweep between the two configurations. The same principle is applicable if the differences between the two models are just component values. You can find a detailed example on how you can achieve this in the ‘Buck Converter with Parameter Sweep’ demo model (PLECS Demo Models > Power Supplies > … ).

However, if the two PLECS models, are completely different applications (e.g., topology, control, etc.), you can run them in parallel, manually. You just need to open the two models in the same instance of PLECS Standalone, and click Simulation > Start on both models. This should be able to run both models in parallel, on different CPU cores.

“”"