Group Abstract Group Abstract

Message Boards Message Boards

0
|
9K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to stop a WSM simulation change variables and then continue?

4 Replies

Neil,

no there is no way to guarantee that, when the simulation runs in real-time (scaled or not), that's the only thing it cares about. It will pass in any input it gets during a time-step to be used for the next time step, but it won't wait for data.

As you say, the FMI co-simulation approach solves that problem (and removes the overhead of having to pass everything over TCP/IP.

The process would be something like: 1. Initialize simulation 2. Get outputs/set inputs 3. Advance time to tn 4. Repeat from 2.

So no, you wouldn't need to reinitialize the FMU (as long as what you want to change can be exposed as inputs).

Regards, Otto

POSTED BY: Otto Tronarp

Capabilities like this only exists today for real-time simulations, there you can provide inputs, pause the simulation etc. during a simulation. Please check out the Mathematica tutorial WSMLink/tutorial/Simulate#1436150622 to see if that could be suitable for your (it's possible to run in scaled real-time as well).

To get true step-wise progression of time in a simulation today (with the possibility to change inputs at each step) I would export my model as a co-simulation FMU (wsm:///ref/UserGuide/ModelCenterFMUExportAndImport.html) and write a small FMI co-simulator in Mathematica using LibraryLink.

Otto

POSTED BY: Otto Tronarp

Otto,

If you use the first approach and I want to send a command to the simulation every millisecond, you say that I can slow down real time and interact with the simulation, is there a way to guaranty that the commands always go into the input at every millisecond of simulation time? (make sure that inputs are not “lost” or doubled up). For example, can I use this approach to "control" a simulation by reading an output, calculate something in MMA and send a new input and guaranty that I do not miss an input?

The second approach seems to solve this problem. Will the FMU approach be controllable as described above? (Have the FMU send an output and then process it and return the new input and run the FMU again) Will there be any speed hit for using an FMU because the simulation must be reinitialized?

Regards,

Neil

POSTED BY: Neil Singer

Otto,

Indeed Co-Simulation looks like the way to go for gaming and probably also for state updating in filtering approaches. The flexibility of linking WSM and Mathematica unfortunately is promising and daunting at the same time. ;-)

Regards, Guido

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard