def test_doublet_wrong_not_scalar_offset(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones_like(time) offset = var with pytest.raises(TypeError) as excinfo: doublet(t_init, T, A, time, offset=offset)
def test_ramp_wrong_size_var(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones([10]) with pytest.raises(ValueError) as excinfo: doublet(t_init, T, A, time, offset=0, var=var) assert ("ValueError: var and time must have the same size" in excinfo.exconly())
def test_doublet_bounds_not_included(): t_init = 0.1 T = 4.8 A = 3. time = np.linspace(0, 10, 11) expected_input = np.zeros([11]) expected_input[1:3] = A/2 expected_input[3:5] = -A/2 doublet_input = doublet(t_init, T, A, time, offset=0, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet(): t_init = 0 T = 5. A = 3. time = np.linspace(0, 10, 11) expected_input = np.zeros([11]) expected_input[0:3] = A / 2 expected_input[3:6] = -A / 2 doublet_input = doublet(t_init, T, A, time, offset=0, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet_bounds_not_included(): t_init = 0.1 T = 4.8 A = 3. time = np.linspace(0, 10, 11) expected_input = np.zeros([11]) expected_input[1:3] = A / 2 expected_input[3:5] = -A / 2 doublet_input = doublet(t_init, T, A, time, offset=0, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet(): t_init = 0 T = 5. A = 3. time = np.linspace(0, 10, 11) expected_input = np.zeros([11]) expected_input[0:3] = A/2 expected_input[3:6] = -A/2 doublet_input = doublet(t_init, T, A, time, offset=0, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet_offset(): t_init = 0 T = 5 A = 1.5 time = np.linspace(0, 10, 11) offset = 2.6 expected_input = np.zeros([11]) + offset expected_input[0:3] += A/2 expected_input[3:6] += -A/2 doublet_input = doublet(t_init, T, A, time, offset=offset, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet_offset(): t_init = 0 T = 5 A = 1.5 time = np.linspace(0, 10, 11) offset = 2.6 expected_input = np.zeros([11]) + offset expected_input[0:3] += A / 2 expected_input[3:6] += -A / 2 doublet_input = doublet(t_init, T, A, time, offset=offset, var=None) assert_almost_equal(doublet_input, expected_input)
def test_doublet_var(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones_like(time) var[0::2] = -1 expected_input = var.copy() expected_input[0:3] += A / 2 expected_input[3:6] += -A / 2 doublet_input = doublet(t_init, T, A, time, offset=0, var=var) assert_almost_equal(doublet_input, expected_input)
def test_doublet_var(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones_like(time) var[0::2] = -1 expected_input = var.copy() expected_input[0:3] += A/2 expected_input[3:6] += -A/2 doublet_input = doublet(t_init, T, A, time, offset=0, var=var) assert_almost_equal(doublet_input, expected_input)
def test_doublet_var_and_offset(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) offset = 2.6 var = np.ones_like(time) var[0::2] = -1 expected_input = var expected_input[0:3] += A/2 + offset expected_input[3:6] += -A/2 + offset doublet_input = doublet(t_init, T, A, time, offset=offset, var=var) assert_almost_equal(doublet_input, expected_input)
def test_doublet_var_and_offset(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) offset = 2.6 var = np.ones_like(time) var[0::2] = -1 expected_input = var expected_input[0:3] += A / 2 + offset expected_input[3:6] += -A / 2 + offset doublet_input = doublet(t_init, T, A, time, offset=offset, var=var) assert_almost_equal(doublet_input, expected_input)
tfin = 20 # seconds N = tfin * 100 + 1 time = np.linspace(0, tfin, N) initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in initial_controls.items(): controls[control_name] = np.ones_like(time) * control_value # Aileron doublet # Aileron max travel: +20º/-15º amplitude = np.deg2rad(15) controls['delta_aileron'] = doublet(t_init=2, T=1, A=amplitude, time=time, offset=np.deg2rad(0)) my_simulation.set_controls(time, controls) par_list = ['x_earth', 'y_earth', 'height', 'psi', 'theta', 'phi', 'u', 'v', 'w', 'v_north', 'v_east', 'v_down', 'p', 'q', 'r', 'alpha', 'beta', 'TAS', 'F_xb', 'F_yb', 'F_zb', 'M_xb', 'M_yb', 'M_zb'] my_simulation.set_par_dict(par_list)
tfin = 10 # seconds N = tfin * 100 + 1 time = np.linspace(0, tfin, N) initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in initial_controls.items(): controls[control_name] = np.ones_like(time) * control_value # Elevator doublet # Elevator max travel: +28º/-26º amplitude = np.deg2rad(20) controls['delta_elevator'] = doublet(t_init=2, T=1, A=amplitude, time=time, offset=initial_controls['delta_elevator']) my_simulation.set_controls(time, controls) par_list = ['x_earth', 'y_earth', 'height', 'psi', 'theta', 'phi', 'u', 'v', 'w', 'v_north', 'v_east', 'v_down', 'p', 'q', 'r', 'alpha', 'beta', 'TAS', 'F_xb', 'F_yb', 'F_zb', 'M_xb', 'M_yb', 'M_zb'] my_simulation.set_par_dict(par_list)
tfin = 20 # seconds N = tfin * 100 + 1 time = np.linspace(0, tfin, N) initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in list(initial_controls.items()): controls[control_name] = np.ones_like(time) * control_value # Aileron doublet # Aileron max travel: +20º/-15º amplitude = np.deg2rad(15) controls['delta_aileron'] = doublet(t_init=2, T=1, A=amplitude, time=time, offset=np.deg2rad(0)) my_simulation.set_controls(time, controls) par_list = ['x_earth', 'y_earth', 'height', 'psi', 'theta', 'phi', 'u', 'v', 'w', 'v_north', 'v_east', 'v_down', 'p', 'q', 'r', 'alpha', 'beta', 'TAS', 'F_xb', 'F_yb', 'F_zb', 'M_xb', 'M_yb', 'M_zb'] my_simulation.set_par_dict(par_list)
tfin = 20 # seconds N = tfin * 100 + 1 time = np.linspace(0, tfin, N) initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in initial_controls.items(): controls[control_name] = np.ones_like(time) * control_value # Rudder doublet # Rudder max travel: +16º/-16º amplitude = np.deg2rad(32) controls['delta_rudder'] = doublet(t_init=2, T=2, A=amplitude, time=time, offset=np.deg2rad(0.0)) my_simulation.set_controls(time, controls) par_list = ['x_earth', 'y_earth', 'height', 'psi', 'theta', 'phi', 'u', 'v', 'w', 'v_north', 'v_east', 'v_down', 'p', 'q', 'r', 'alpha', 'beta', 'TAS', 'F_xb', 'F_yb', 'F_zb', 'M_xb', 'M_yb', 'M_zb'] my_simulation.set_par_dict(par_list)
tfin = 20 # seconds N = tfin * 100 + 1 time = np.linspace(0, tfin, N) initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in initial_controls.items(): controls[control_name] = np.ones_like(time) * control_value # Rudder doublet # Rudder max travel: +16º/-16º amplitude = np.deg2rad(32) controls['delta_rudder'] = doublet(t_init=2, T=2, A=amplitude, time=time, offset=np.deg2rad(0.0)) my_simulation.set_controls(time, controls) par_list = [ 'x_earth', 'y_earth', 'height', 'psi', 'theta', 'phi', 'u', 'v', 'w', 'v_north', 'v_east', 'v_down', 'p', 'q', 'r', 'alpha', 'beta', 'TAS', 'F_xb', 'F_yb', 'F_zb', 'M_xb', 'M_yb', 'M_zb' ] my_simulation.set_par_dict(par_list) my_simulation.run_simulation() # print(my_simulation.par_dict)
initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in initial_controls.items(): controls[control_name] = np.ones_like(time) * control_value # Elevator, aileron and rudder doublets # Elevator max travel: +28º/-26º # Aileron max travel: +20º/-15º # Rudder max travel: +16º/-16º amplitude_elev = np.deg2rad(26) controls['delta_elevator'] = initial_controls['delta_elevator'] + \ doublet(t_init=2, T=2, A=amplitude_elev, time=time, offset=np.deg2rad(0.0)) amplitude_aile = np.deg2rad(15) controls['delta_aileron'] = doublet(t_init=5, T=2, A=amplitude_aile, time=time, offset=np.deg2rad(0.0)) amplitude_rud = np.deg2rad(32) controls['delta_rudder'] = doublet(t_init=10, T=2, A=amplitude_rud, time=time,
initial_controls = trimmed_ac.controls controls = {} for control_name, control_value in list(initial_controls.items()): controls[control_name] = np.ones_like(time) * control_value # Elevator, aileron and rudder doublets # Elevator max travel: +28º/-26º # Aileron max travel: +20º/-15º # Rudder max travel: +16º/-16º amplitude_elev = np.deg2rad(26) controls['delta_elevator'] = initial_controls['delta_elevator'] + \ doublet(t_init=2, T=2, A=amplitude_elev, time=time, offset=np.deg2rad(0.0)) amplitude_aile = np.deg2rad(15) controls['delta_aileron'] = doublet(t_init=5, T=2, A=amplitude_aile, time=time, offset=np.deg2rad(0.0)) amplitude_rud = np.deg2rad(32) controls['delta_rudder'] = doublet(t_init=10, T=2, A=amplitude_rud, time=time,