Esempio n. 1
0
def run_satellite_demo_noevents():
    #Brute force could work well, but with a small step size...
    system = SatelliteDemo()
    #sol = lyapunov.Solver(system)
    t_in = numpy.linspace(0.0, 3.0, 31)
    record = lyapunov.Recorder(system)
    stepper = lyapunov.runge_kutta4(system, t_in)
    print "\nNo Events, No Sliding - satellite control"
    print "initial state", system.state
    start = time.clock()
    #record = sol.simulate(t_in)
    for t, events in stepper:
        record.log()
    print "time elapsed", time.clock() - start
    plot_satellite(record)
Esempio n. 2
0
def run_satellite_demo_events():
    #With events and sliding is more accurate, and faster than brute force.
    system = SatelliteDemo()
    system.events = [system.s]
    system.u = lambda: -1 #replaces u_naive
    t_in = numpy.linspace(0.0, 3.0, 31)
    record = lyapunov.Recorder(system)
    stepper = lyapunov.runge_kutta4(system, t_in)
    print "\nWith Events and Sliding - satellite control"
    start = time.clock()
    for t, events in stepper:
        record.log(events)
        if len(events) > 0:
            if system.s in events and system.u_margin() > 0:
                system.u = system.u_effective
                system.events = [system.u_margin]
            else:
                stepper.step_through()
                system.u = (lambda: 1) if system.u_effective() > 1 else (lambda: -1)
                system.events = [system.s]
    print "time elapsed ", time.clock() - start
    plot_satellite(record)