Skip to content
Extraits de code Groupes Projets
playing_with_edo.py 1,03 ko
Newer Older
  • Learn to ignore specific revisions
  • Martin Delcourt's avatar
    Martin Delcourt a validé
    from edosolver import RK4Solver, EulerSolver
    from math import pi
    def free_fall_acceleration(t,y):
        # y = [x,v]
        dv = - 9.81 - 0.00315 * abs(y[1]) * y[1]
        dx = y[1]
        
        return [dx,dv]
        
    def oscillation(t,y):
        return[y[1],-y[0]]
    
    
    
    start    = 0
    stop     = 30
    dt       = 0.01
    dt_store = 0.1
    
    
    
    
    solution_oscillation_euler = EulerSolver(oscillation,[1,0],start,stop,dt,dt_store)
    solution_oscillation_euler.solve()
    solution_oscillation_euler.draw()
    
    solution_oscillation_rk4 = RK4Solver(oscillation,[1,0],start,stop,dt,dt_store)
    solution_oscillation_rk4.solve()
    solution_oscillation_rk4.draw()
    
    solution_oscillation_rk4.draw_diff(solution_oscillation_euler)
    
    
    
    solution_free_fall_euler = EulerSolver(free_fall_acceleration,[0,0], start, stop, dt,dt_store)
    solution_free_fall_euler.solve()
    solution_free_fall_euler.draw()
    
    
    solution_free_fall_rk4 = RK4Solver(free_fall_acceleration,[0,0], start, stop, dt,dt_store)
    solution_free_fall_rk4.solve()
    solution_free_fall_rk4.draw()
    
    solution_free_fall_rk4.draw_diff(solution_free_fall_euler)