How the example works:
- First, the functions that generate the symbolic DAE system are called. They return a vector of equations, and in addition vectors of initial values.
- Then, an ODE system is created from these vectors.
- Then the system is symbolically simplified (might take 30-60s)
- Now the init! function is called on the ODE system to find the initial state
- Now, in a loop for each timestep:
- first, the system is simulated for one timestep of the control system
- then the controller is called
- the system parameters are updated from the controller output
- this repeats until the final simulation time is reached.
In reality, it is a bit more complex, but first you have to understand this simple scheme.
Is it clear now?
In the given example, the controller is operating at 20 Hz, it uses a fixed time step of 50ms. The continues time model of the physical system is using a varying time step solver, in average about 100 iterations are needed to converge for simulating the 50ms time span of the outer loop.
To clarify: I am not using MTK to implement the controller, only to implement the model of the physical system.