Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

scipy - ODE solver for python respecting periodicity

I want to integrate a control problem, i.e. an ODE of the form dx/dt = A.f(t), where x(t) is a function in R^3, f(t) is a function in R^4 and A is a matrix 3x4. In my special case, f(t) = F'(t), i.e. a time derivative of a function F. Furthermore, F is 1-periodic. Hence, integrating the ODE over the interval [0, 1] should yield the starting position again. However, methods like solve_ivp from scipy.integrate do not respect this periodicity at all (I have tried all the possible methods like RK45, Radau, DOP853, LSODA).

Is there a special ODE solver that respects such periodicity to a high degree of precision?

question from:https://stackoverflow.com/questions/65848198/ode-solver-for-python-respecting-periodicity

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

All algorithms will suffer from precision loss anyway, so you will most likely never achieve exact periodicity. Nonetheless, you can also try to increase the precision of the integration by using the parameters "atol" and "rtol", which, roughly, will keep the error of the integration below (atol + rtol*y) at each time step. You can typically go as low as atol=rtol=1e-14.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...