masfaraud / BMSpy

Python Block-Model Simulator. An alternative to simulink in python.
GNU Lesser General Public License v3.0
222 stars 36 forks source link

ODE solving #32

Closed jk987 closed 1 year ago

jk987 commented 2 years ago

Hi, I'm playing with your library and I'm lost in ODE.Evaluate and in DynamicSystem.Simulate. I guess the main reason is that we were doing it differently in our school. Could you please give me some link where I could read more about the method you used? Or at least give me the name of your solution.

Where am I aiming to: My favourite method of testing ODEs is solving move on a circle. dx/dt = -y dy/dt = x x[0] = 1 y[0] = 0 Ideal result should be: x = cos(t) y = sin(t) And the real result depends on size of time-step and also on the method used. With better method you can use longer time-step. In our school we were forced to use Runge-Kutta: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

masfaraud commented 1 year ago

Sorry for the delay. Solving is done through optimisation, ie finding values at the time steps that makes no residue in block evaluation. We cannot use time solving schema like runge-kutta because of potential loops in the graph. In case there is none, it could be implemented. I hope it is clear enough.