How to make 2 different models running in parallel to be executed at the same speed from the beginning to the end of the simulation.

2 views (last 30 days)
Hi everyone,
I have 2 Simulink models.
Both models run with Automatic solver selction and a solver of the Fixed step type and a Fixed-step size set to Auto.
Both models have the same simulation stop time equal to: 1050s.
The sample time used by Simulink with the 1st model when it is run separately is: 0.001s (so this model is executed very slowly).
The sample time used by Simulink with the 2nd model when it is run separately is: 21s (so this model is executed very quickly).
I managed to use Data Store Memory and MATLAB Function blocks to run the two models at the same time (in parallel) in order to exchange some variables calculated betweeen the two models.
The problem is that after starting both models at the same time the model with sample time equal to 21s executes very quickly and stops but the other model with sample time equal to 0.001s continues running.
I know that all this is normal given the different sample times of the two models but I am wondering whether there is a way to make the two models have the same length of the execution time (fast or slow) so that the data exchanged betweeen the two models is correct during the whole simulation time.
Note:
The 1st model can not run successfully when its sample time is set to 21s.
The 2nd model can not run successfully when its sample time is set to 0.001s.
Every little tip is welcome.
Many thanks to all the contributors of MATLAB Central.
  8 Comments
Archit Dhanani
Archit Dhanani on 25 Jul 2019
Hi Kamal,
The issue seems to be else where. Here is a similar model below. Const1 is set to sample time = 0.001 and Const2 = 21. You can check the legend to see the rates for all the blocks. I used the same solver settings. The model works fine. (The atomic subsystems just adds the two numbers.)
answers1.png
Raj
Raj on 26 Jul 2019
@ kamal kiki "all the values of the variables of the model reached very high values" - Since the model is running, it means the rate transition block is doing its job. Model becoming unstable maybe a sign of design issues. Individual systems can run perfectly without any issues but combining them creates a totally new system with its own characteristics.

Sign in to comment.

Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!