Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @classmethod
  2. def step(cls, func , t : np.float , u : np.float , dt):
  3.  
  4. def f(ti,ui):
  5. return np.array([function(ti,ui) for function in func])
  6.  
  7. if cls.first_startup:
  8. cls.um3 = u.copy()
  9. unext = rungekutta.RK4.step(func,t,cls.um3,dt)
  10. t += dt
  11. cls.first_startup = False
  12. elif cls.second_startup:
  13. cls.um2 = u.copy()
  14. unext = rungekutta.RK4.step(func,t,cls.um2,dt)
  15. t+= dt
  16. cls.second_startup = False
  17. elif cls.third_startup:
  18. cls.um1 = u.copy()
  19. unext = rungekutta.RK4.step(func,t,cls.um1,dt)
  20. t += dt
  21. cls.third_step = False
  22. else: # compute AB 4th order
  23. unext = u + dt/24.* ( 55.*f(t,u) - 59.*f(t-dt,cls.um1) + 37.*f(t-dt-dt,cls.um2)
  24. - 9.*f(t-dt-dt,cls.um3 ))
  25. cls.um3 = cls.um2.copy()
  26. cls.um2 = cls.um1.copy()
  27. cls.um1 = u.copy()
  28. return unext
Add Comment
Please, Sign In to add comment