Example #1
0
def test_slope(force_recompute=False,
               filename='/tmp/glider_opty_4d_slope.npz'):
    atm = go_u.AtmosphereRidgeSym(winf=4.)
    _p = go4.Planner(_obj_fun=go4.obj_sum_z,
                     _obj_grad=go4.obj_grad_sum_z,
                     _atm=atm,
                     _n_constraint=(-50, 10),
                     _e_constraint=(-50, 50),
                     x0=10,
                     y0=0,
                     z0=-25,
                     psi0=np.pi,
                     duration=60,
                     hz=50.,
                     obj_scale=1.)
    go4.compute_or_load(atm,
                        _p,
                        force_recompute,
                        filename,
                        tol=1e-5,
                        max_iter=1500)
    plot_all(_p,
             n0=-40,
             n1=50,
             dn=5.,
             e0=-40,
             e1=40,
             de=5,
             h0=0.,
             h1=70,
             dh=2.5)
Example #2
0
def test_thermal(force_recompute=False,
                 filename='/tmp/glider_opty_4d_thermal.npz'):
    atm = go_u.AtmosphereWharingtonSym(radius=40., strength=-1, cst=[4, 0, 0])
    _p = go4.Planner(_obj_fun=go4.obj_final_z,
                     _obj_grad=go4.obj_grad_final_z,
                     _atm=atm,
                     _n_constraint=(-40, 40),
                     _e_constraint=(-40, 40),
                     x0=40,
                     y0=0,
                     z0=-1,
                     psi0=np.pi,
                     duration=50,
                     hz=50.,
                     obj_scale=1.)
    go4.compute_or_load(atm,
                        _p,
                        force_recompute,
                        filename,
                        tol=1e-5,
                        max_iter=1000)
    plot_all(_p,
             n0=-40,
             n1=50,
             dn=5.,
             e0=-40,
             e1=40,
             de=5,
             h0=0.,
             h1=70,
             dh=2.5)
Example #3
0
def test_thermal_dual(force_recompute=False,
                      filename='/tmp/glider_opty_4d_thermal_dual.npz'):
    atm = go_u.atm2()
    _p = go4.Planner(_obj_fun=go4.obj_final_z,
                     _obj_grad=go4.obj_grad_final_z,
                     _atm=atm,
                     _phi_constraint=(-np.deg2rad(40.), np.deg2rad(40.)),
                     _v_constraint=(8., 20.),
                     _n_constraint=(-40, 40),
                     _e_constraint=(-40, 40),
                     x0=40,
                     y0=0,
                     z0=-1,
                     psi0=np.pi,
                     duration=50,
                     hz=50.,
                     obj_scale=1.)
    go4.compute_or_load(atm,
                        _p,
                        force_recompute,
                        filename,
                        tol=1e-5,
                        max_iter=1000)
    plot_all(_p,
             n0=-40,
             n1=50,
             dn=5.,
             e0=-40,
             e1=40,
             de=5,
             h0=0.,
             h1=70,
             dh=2.5)
def test_trip(force_recompute=False, filename='/home/poine/tmp/glider_opty_4d_wp{}.npz', exp='0'):
    if   exp == '0': atm = go_u.AtmosphereCalmSym()
    elif exp == '1': atm = go_u.AtmosphereHorizFieldSym(-5.)
    else: atm = go_u.AtmosphereHorizFieldSym(-7.5)
    _p = sgo4d.Planner( #_obj_fun=sgo4d.obj_sum_z, _obj_grad=sgo4d.obj_grad_sum_z,
                        #_obj_fun=sgo4d.obj_final_z, _obj_grad=sgo4d.obj_grad_final_z,
                        _obj_fun=obj_wp, _obj_grad=obj_grad_wp,
                        #_obj_fun=obj_cc, _obj_grad=obj_grad_cc,
                        _atm=atm, e0=-50, n0=0, u0=25, psi0=0,
                        _v_constraint = (7., 12.),
                        _e_constraint = (-75, 175),
                        _n_constraint = (-50, 100),
                        #_u_constraint = (   25, 100),
                        duration=20, hz=50.)

    sgo4d.compute_or_load(atm, _p, force_recompute, filename.format(exp), tol=1e-5, max_iter=2000, initial_guess=None)

    dists_to_wp = np.linalg.norm(np.vstack((_p.sol_e, _p.sol_n)).T - [ewp, nwp], axis=1)
    arrival_idx = np.argmax(dists_to_wp<20)
    
    go_u.plot_solution_chronogram(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_wp{exp}_chrono.png')
    go_u.plot_solution_2D_en(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_wp{exp}_en.png')
    #go_u.plot_solution_2D_nu(_p, n0=-40, n1=50, dn=5., e0=0., h0=0., h1=70, dh=2.5)
    go_u.plot_solution_3D(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_wp{exp}_3D.png')
    plt.show()
Example #5
0
def test_thermal(force_recompute=False, filename='/home/poine/tmp/glider_opty_4d_thermal_{}.npz', exp_id='2'):
    if exp_id == '0':
        atm = go_u.AtmosphereWharingtonSym(radius=40., strength=-1)
    elif exp_id == '1':
        atm = go_u.AtmosphereWharingtonOval(radius=60., strength=-0.8)
    elif exp_id == '2':
        atm = go_u.atm2()
    #atm = go_u.AtmosphereArrayTest()

    _p = sgo4d.Planner( _obj_fun=sgo4d.obj_sum_z, _obj_grad=sgo4d.obj_grad_sum_z,
                        #_obj_fun=sgo4d.obj_final_z, _obj_grad=sgo4d.obj_grad_final_z,
                        _atm=atm, e0=-100, n0=0, u0=25, psi0=0,
                        _v_constraint = (7., 15.),
                        _e_constraint = (-120, 120),
                        _n_constraint = (-120, 120),
                        #_u_constraint = (   25, 100),
                        duration=40, hz=50., obj_scale=1.)

    #sgo4d.compute_or_load(atm, _p, force_recompute, filename, tol=1e-5, max_iter=4000, initial_guess=None)
    sgo4d.compute_or_load(atm, _p, force_recompute, filename.format(exp_id), tol=1e-4, max_iter=4000, initial_guess=None)
    print(f'last altitude {_p.sol_u[-1]} m')
    go_u.plot_solution_chronogram(_p); plt.savefig('plots/glider_4d_thermal_chrono.png')
    go_u.plot_solution_2D_en(_p); plt.savefig('plots/glider_4d_thermal_en.png')
    go_u.plot_solution_2D_nu(_p, n0=-40, n1=50, dn=5., e0=0., h0=0., h1=70, dh=2.5); plt.savefig('plots/glider_4d_thermal_nu.png')
    go_u.plot_solution_2D_eu(_p, contour_wz=True, e0=-40, e1=50, de=5., n0=0., h0=0., h1=70, dh=2.5); plt.savefig('plots/glider_4d_thermal_eu.png')
    go_u.plot_solution_3D(_p); plt.savefig('plots/glider_4d_thermal_3D.png')
    plt.show()
def test_cc(force_recompute=False, filename='/home/poine/tmp/glider_opty_4d_cc{}.npz', exp='0'):
     if exp == '0': atm = go_u.atm4(strengths=(-0.6, -1.4, -0.8, -1.9))
     else: atm = go_u.atm4(strengths=(-0.6, -1.4, -0.8, -0.6))
     _p = sgo4d.Planner(_obj_fun=obj_cc, _obj_grad=obj_grad_cc,
                        _atm=atm, e0=-100, n0=0, u0=25, psi0=0,
                        _v_constraint = (7., 15.),
                        _e_constraint = (-150, 300),
                        _n_constraint = (-100, 100),
                        _u_constraint = (   23, 100),
                        duration=60, hz=20.)
     #sgo4d.compute_or_load(atm, _p, force_recompute, filename, tol=1e-5, max_iter=2000, initial_guess=None)
     sgo4d.compute_or_load(atm, _p, force_recompute, filename.format(exp), tol=1e-4, max_iter=1500, initial_guess=None)
     dists_to_wp = np.linalg.norm(np.vstack((_p.sol_e, _p.sol_n)).T - [ccg_e, ccg_n], axis=1)
     arrival_idx = np.argmax(dists_to_wp<10)
     go_u.plot_solution_chronogram(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_cc{exp}_chrono.png')
     go_u.plot_solution_2D_en(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_cc{exp}_en.png')
     go_u.plot_solution_3D(_p, max_idx=arrival_idx); plt.savefig(f'plots/glider_4d_cc{exp}_3D.png')
     plt.show()
Example #7
0
def test_slope(force_recompute=False, filename='/home/poine/tmp/glider_opty_4d_slope.npz'):
    atm = go_u.AtmosphereRidgeSym()
    _p = sgo4d.Planner( #_obj_fun=sgo4d.obj_sum_z, _obj_grad=sgo4d.obj_grad_sum_z,
                        _obj_fun=sgo4d.obj_final_z, _obj_grad=sgo4d.obj_grad_final_z,
                        _atm=atm, e0=0, n0=0, u0=25, psi0=-np.pi/6,
                        _v_constraint = (7., 15.),
                        _n_constraint = (-100, 100),
                        _e_constraint = (-100, 100),
                        duration=50, hz=50.)
    sgo4d.compute_or_load(atm, _p, force_recompute, filename, tol=1e-4, max_iter=3000, initial_guess=None)
    #sgo4d.compute_or_load(atm, _p, force_recompute, filename, tol=1e-5, max_iter=2000, initial_guess=None)
    print(f'last altitude {_p.sol_u[-1]} m')
    go_u.plot_solution_chronogram(_p); plt.savefig('plots/glider_4d_slope_chrono.png')
    go_u.plot_solution_2D_en(_p, contour_wz=True) ; plt.savefig('plots/glider_4d_slope_en.png')#, n0=-40, n1=50, dn=5., e0=0., h0=0., h1=70, dh=2.5)
    go_u.plot_solution_2D_nu(_p, contour_wz=True, n0=-40, n1=50, dn=5., e0=0., h0=0., h1=70, dh=2.5); plt.savefig('plots/glider_4d_slope_nu.png')
    go_u.plot_solution_2D_eu(_p, contour_wz=True, e0=-40, e1=50, de=5., n0=0., h0=0., h1=70, dh=2.5); plt.savefig('plots/glider_4d_slope_eu.png')
    go_u.plot_solution_3D(_p); plt.savefig('plots/glider_4d_slope_3D.png') 
    plt.show()
Example #8
0
def test_cst_wind(force_recompute=False,
                  filename='/tmp/glider_opty_4d_cst_wind.npz'):
    atm = go_u.AtmosphereCstWindSym([4, 0, 0])
    #obj_f, obj_grad = obj_circle, obj_grad_circle
    #obj_f, obj_grad = obj_min_bank, obj_grad_min_bank
    obj_f, obj_grad = obj_sum_z, obj_grad_sum_z
    _p = go4.Planner(_obj_fun=obj_f,
                     _obj_grad=obj_grad,
                     _atm=atm,
                     _n_constraint=(-40, 40),
                     _e_constraint=(-40, 40),
                     x0=10,
                     y0=0,
                     z0=-25,
                     psi0=np.pi,
                     duration=30,
                     hz=50.,
                     obj_scale=100.)
    initial_guess = initial_guess_circle(_p)
    go4.compute_or_load(atm,
                        _p,
                        force_recompute,
                        filename,
                        tol=1e-5,
                        max_iter=500,
                        initial_guess=initial_guess)
    go_u.plot_solution_chronogram(_p)
    go_u.plot_solution_2D_en(_p)
    go_u.plot_solution_2D_nu(_p,
                             n0=-40,
                             n1=50,
                             dn=5.,
                             e0=0.,
                             h0=0.,
                             h1=70,
                             dh=2.5)
    go_u.plot_solution_3D(_p)