Update ODE45 in realtime
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am using the ODE45 solver to simulate the dynamic behaviour of a valve. I am facing a problem, I wish to alter some of the values within the script passed to ODE45 after a certain condition. When the valve opens to a certain value I would like to close off the force that holding it open. The opening height is part of the output vector of the ODE script, it is a value in the script id like to change. This would be easily done with a IF loop however as the script refreshes every cycle the loop is not really effective in this sense.
My question is, the value of the ODE script output (in this case the valve opening) is stored as part of a array, is there anyway to access this in real time so I can update my script once a certain threshold value has been reached in the output array?
I'm not sure if that is well enough explained but any help would be much appreciated!
Kind regards
Steven.
1 comentario
Jan
el 27 de Ag. de 2017
Note: There are no "IF loops" in any programming language I know. In consequence I cannot imagine, how this could be applied "easily".
Respuestas (1)
Walter Roberson
el 27 de Ag. de 2017
No, you cannot do that. But it would not be a good idea if you could do it.
The ode*() routines will miscalculate if your function is not continuously differentiable twice more than you code. If your function is not continuously differentiable once more than what you code, then usually the function will detect that and spend a lot of time trying to find the exact boundary under the hypothesis that it is differentiable but that the algorithm is just having numeric problems. If your function is once continuously differentiable but not twice continuously differentiable then it might not notice the discontinuity but you will typically just get wrong answer.
When you turn off a force abruptly then your function is not continuously differentiable there, and the ode*() routines will often notice and fail at that point.
So, what you need to do is to create an event function that detects that condition under which the force is to be turned off and signals that the ode*() is to be terminated. Then you examine the outputs to get the boundary conditions and time values, and you call ode*() again to start from that point, this time with the force turned off.
2 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!