latOffset = latOffsetOutputEquation(t, x) if t < 20: return latOffset else: return latOffset - 2000 latOffsetBlock = systems.DynamicalSystem( state_equation_function=latOffsetStateEquation, output_equation_function=latOffsetOutputEquationShift, dim_state=1, dim_input=3, dim_output=1) BD.systems[-2] = latOffsetBlock BD.systems[2] = systems.SystemFromCallable( get_controller_function(*opt_ctrl, sasOn=True, apOn=True), dim_feedback + 4, 4) BD.connect(baseChiCmdBlock, latOffsetBlock, inputs=[0]) BD.connect(planet, latOffsetBlock, outputs=[planet.V_N_idx, planet.V_E_idx], inputs=[1, 2]) with benchmark() as b: res = BD.simulate(60, integrator_options=int_opts) b.tfinal = res.t[-1] plot_nesc_comparisons(res, '13p4') plot_F16_controls(res, '13p4')
trimmed_KEAS = planet.output_equation_function( 0, trimmed_flight_condition)[planet.V_T_idx] * np.sqrt( planet.output_equation_function( 0, trimmed_flight_condition)[planet.rho_idx] / rho_0) * knots_per_mps planet.initial_condition = trimmed_flight_condition gnc_block = systems.SystemFromCallable( get_gnc_function( *opt_ctrl, keasCmd=trimmed_KEAS, ), dim_feedback, 4) BD = BlockDiagram(planet, F16_vehicle, gnc_block) BD.connect(planet, F16_vehicle, inputs=np.arange(planet.dim_output)) BD.connect(F16_vehicle, planet, inputs=np.arange(F16_vehicle.dim_output)) BD.connect(gnc_block, F16_vehicle, inputs=np.arange(planet.dim_output, planet.dim_output + 4)) BD.connect(planet, gnc_block, outputs=planet_output_for_gnc_select) with benchmark() as b: res = BD.simulate(180, integrator_options=int_opts) b.tfinal = res.t[-1] plot_nesc_comparisons(res, '15') plot_F16_controls(res, '15', y_idx_offset=0) def xy_for_north_pole_ground_track(lat, long): xx = (90 - lat * 180 / np.pi) * np.cos(long)
import numpy as np from scipy import interpolate from nesc_testcase_helper import plot_nesc_comparisons, plot_F16_controls, data_relative_path from nesc_case11 import int_opts, get_controller_function, BD, spec_ic_args, opt_ctrl, dim_feedback glob_path = os.path.join(data_relative_path, 'Atmospheric_checkcases', 'Atmos_13p3_SubsonicHeadingChangeF16', 'Atmos_13p3_sim_*.csv') baseChiCmdBlock = systems.SystemFromCallable( interpolate.make_interp_spline([0, 15], [ spec_ic_args['psi'] * 180 / np.pi, spec_ic_args['psi'] * 180 / np.pi + 15.0 ], k=0), 0, 1) BD.systems[-1] = baseChiCmdBlock BD.systems[2] = systems.SystemFromCallable( get_controller_function(*opt_ctrl, sasOn=True, apOn=True), dim_feedback + 4, 4) import time tstart = time.time() res = BD.simulate(30, integrator_options=int_opts) tend = time.time() tdelta = tend - tstart print("time to simulate: %f eval time to run time: %f" % (tdelta, res.t[-1] / tdelta)) plot_nesc_comparisons(res, glob_path, '13p3') plot_F16_controls(res, '13p3')