Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @classmethod
- def step(cls, func , t : np.float , u : np.float , dt):
- def f(ti,ui):
- return np.array([function(ti,ui) for function in func])
- if cls.first_startup:
- cls.um3 = u.copy()
- unext = rungekutta.RK4.step(func,t,cls.um3,dt)
- t += dt
- cls.first_startup = False
- elif cls.second_startup:
- cls.um2 = u.copy()
- unext = rungekutta.RK4.step(func,t,cls.um2,dt)
- t+= dt
- cls.second_startup = False
- elif cls.third_startup:
- cls.um1 = u.copy()
- unext = rungekutta.RK4.step(func,t,cls.um1,dt)
- t += dt
- cls.third_step = False
- else: # compute AB 4th order
- unext = u + dt/24.* ( 55.*f(t,u) - 59.*f(t-dt,cls.um1) + 37.*f(t-dt-dt,cls.um2)
- - 9.*f(t-dt-dt,cls.um3 ))
- cls.um3 = cls.um2.copy()
- cls.um2 = cls.um1.copy()
- cls.um1 = u.copy()
- return unext
Add Comment
Please, Sign In to add comment