Combined Discrete-Continuous Simulation In SIMULINK

8 views (last 30 days)
I am not even sure if that is the right title for this question.
Here's the question:
How to implement the following dynamic system in Simulink?
Here's the problem:
Time points are used to establish a uniform time grid on the interval , where the constant step size is . The solver is assumed to be at the beginning of the time step , where the state at the current time , is known, and the objective is to compute the next state through the relation , where F is described as follows:
  1. is first transformed to through some algebraic functions,
  2. an IVP is set up with its initial condition set to . This IVP is then solved using a variable step ODE solver from to ,
  3. the solution at time , is then mapped to the next state by some other algebraic mappings.
blk-diagram
The following figure shows how the state is propagated thorugh time, in a single step:
timeline
In the output, I need the intermediate solutions (denoted by x) in each step, as well as the state variables .This can be easily done in a script, but I am looking for a way to do it in Simulink; which may be trivial problem, but I am really confused at this moment and I can't really find a way to do it.
In some ways, in each step, the continuous-time subsystem waits for the input to be available, and once it is there, the external solver "waits" for the continuous-time subsystem to locally solve the continuous-time dynamical equations using an adaptive step-size solver, then the external solver receives this subsystem's output and continuous to perform the remaining functions to produce . I feel like this should be logical workflow of the simulation, but I am not sure how Simulink treats problems of this type.

Answers (1)

Paul
Paul on 3 Aug 2024
Edited: Paul on 3 Aug 2024
Hi Sajjad,
It sounds like you want to use the feature of the Integrator block for Resetting the State. At every t_i, you can reset the state to z_1 using the External Initial Condition.
  3 Comments
Paul
Paul on 6 Aug 2024
It sounds like the current approach does not implement the block diagram shown in the question. For that system as shown, there's no need to use the state port, and the corresponding Simulink model would satisfy the relation z2(t_i) = z1(t_i).
If the delay from q(t_i+1) to q(t_i) is removed, then I think you get into the situation of the "self resetting integrator," in which case the state port is needed. But again, that doesn't match the block diagram as shown.
Having said that, what you have now sounds like it's what you want; happy to hear that you achieved a solution.
Sajjad Monfared
Sajjad Monfared on 6 Aug 2024
Now that you mention it, this block diagram might not actually be a correct representation of the system dyanmics. I constructed it from the description I gave earlier of how the system is supposed to behave. But the diagram that comes after it clearly shows how I actually want the variables to change over time.
With reference to the second diagram, I realized that I should let the solver do its job (integration of the grayed continuous-time subsystem using a variable-step method) while I only intervene at times to manually change the state by applying necessary functions (, ) to the current state which is available in the state port.
Below is the output of the simulation (annotated by some arrows).

Sign in to comment.

Categories

Find more on Configure Simulation Conditions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!