0
votes

I am running a simulation that contains among other things a subsystem (or referenced model) that is a simulation by itself and that needs to be run fully at certain times before resuming the main simulation.

Basically, at time t the main simulation needs the outputs of the subsystem. The subsystem is then triggered and runs a simulation for 6 seconds (the subsystem simulation is time dependent). Then the main simulation uses the outputs of the subsystem. The problem here is that when the main simulation resumes, it should resume at time t+ts (sampling time) and not t+6s... So the subsystem should run on a kind of virtual clock.

Is this somehow possible? If not, what are the alternatives?

Thanks in advance for your help!!!

Fabien

1
When does the subsystem stop? Can it be done using a for loop sub-system?Navan
Hi Navan, thanks for your help! The subsystem is triggered at certain times in the main simulation and runs then for 6 seconds in a row before stopping. The problem when using a for loop is that if the subsystem is triggered to start running at time t, it will stop running at time t + 6 seconds while the main simulation would need the outputs of the subsystem to be delivered at time t + ts (ts being the sampling time). So I am looking for a solution that would trick the system into thinking that ts/6 seconds in the main simulation correspond to 1 second simulation in the subsystem...Fabien
(...) both the "main" simulation and the subsystem perform time-dependent calculation and this is what makes it tricky. The subsystem really needs to believe it is running for 6 seconds, otherwise I could just run it at a faster sampling rate than the main simulation.Fabien
I do not think it is possible to run two different time lines or change simulation time within a model. You may need to make the sub-system independent of current time.Navan
That's what I fear... thanks a lot for your input, it's much appreciated. I'm wondering if I could solve this by replacing my subsystem by a Matlab Function block that would run the referenced model as a simulation model independent of the main simulation. I'm not sure it's possible to do so, never tried before, but I'll give it a try now.Fabien

1 Answers

2
votes

I realize that I never gave feedback about my attempts. I'll do it now: the solution I found was to replace my simulation subsystem by a Matlab Function block that runs/calls the referenced model as a simulation independent of the main simulation. This works perfectly fine!