Exemple #1
0
                                     longStk_ic=0.0,
                                     allow_roll=False)

    trimmed_flight_condition = planet.ic_from_planetodetic(**opt_args)

    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]
Exemple #2
0
                                 throttle_ic=0.0,
                                 longStk_ic=0.0,
                                 allow_roll=False)

trimmed_flight_condition = planet.ic_from_planetodetic(**opt_args)

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
int_opts['nsteps'] = 5_000

planet.initial_condition = trimmed_flight_condition

controller_block = systems.SystemFromCallable(
    get_controller_function(*opt_ctrl), dim_feedback + 4, 4)

keasCmdOutput = np.array([trimmed_KEAS])
keasCmdBlock = systems.SystemFromCallable(lambda *args: keasCmdOutput, 0, 1)

altCmdOutput = np.array([spec_ic_args['h'] * ft_per_m])
altCmdBlock = systems.SystemFromCallable(lambda *args: altCmdOutput, 0, 1)


def latOffsetStateEquation(t, x, u):
    chi_cmd, V_N, V_E = u
    V_ground_magnitude = np.sqrt(V_N**2 + V_E**2)
    V_ground_heading = np.arctan2(V_E, V_N)
    return V_ground_magnitude * np.sin(V_ground_heading -
                                       chi_cmd * np.pi / 180)
Exemple #3
0
    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')
Exemple #4
0
from simupy import systems
import os
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')
Exemple #5
0
from simupy import systems
from scipy import interpolate

from nesc_testcase_helper import plot_nesc_comparisons, plot_F16_controls, benchmark
from nesc_case11 import int_opts, get_controller_function, BD, opt_ctrl, dim_feedback, trimmed_KEAS

keasCmdBlock = systems.SystemFromCallable(
    interpolate.make_interp_spline([0, 5], [trimmed_KEAS, trimmed_KEAS - 5.0],
                                   k=0), 0, 1)

BD.systems[-4] = keasCmdBlock
BD.systems[2] = systems.SystemFromCallable(
    get_controller_function(*opt_ctrl, sasOn=True, apOn=True),
    dim_feedback + 4, 4)

with benchmark() as b:
    res = BD.simulate(20, integrator_options=int_opts)
    b.tfinal = res.t[-1]

plot_nesc_comparisons(res, '13p2')
plot_F16_controls(res, '13p2')
Exemple #6
0
# run_trimmer(get_ic_from_spec(), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=False, rudder_ic=None, aileron_ic=None)
# run_trimmer(get_ic_from_baseline(5), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=0., aileron_ic=0.0)

# opt_args, opt_ctrl = run_trimmer(get_ic_args_from_spec(), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=False, rudder_ic=None, aileron_ic=None)

# run_trimmer(get_ic_args_from_spec(), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=None, aileron_ic=None)
# run_trimmer(get_ic_from_baseline(5), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=0., aileron_ic=0.0)
# run_trimmer(get_ic_from_baseline(5), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=None, aileron_ic=None)
# ESD_cond = update_flight_condition(get_ic_from_spec(), psi=0., theta=0., phi=0.,)
##

int_opts['nsteps'] = 5_000
# int_opts['max_step'] = 2**-5

controller_block = systems.SystemFromCallable(
    get_controller_function(opt_ctrl[-1] / 100., opt_ctrl[0] / -25.),
    dim_feedback, 4)

flight_condition = planet.ic_from_planetodetic(**opt_args)

planet.initial_condition = flight_condition

BD = BlockDiagram(planet, F16_vehicle, controller_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(controller_block,
           F16_vehicle,
           inputs=np.arange(planet.dim_output, planet.dim_output + 4))

with benchmark() as b:
    res = BD.simulate(180, integrator_options=int_opts)
Exemple #7
0
from simupy import systems
from scipy import interpolate

from nesc_testcase_helper import plot_nesc_comparisons, plot_F16_controls, benchmark
from nesc_testcase_helper import ft_per_m
from nesc_case11 import int_opts, get_controller_function, BD, spec_ic_args, opt_ctrl, dim_feedback

int_opts['max_step'] = 0.0  #2**-4
int_opts['name'] = 'dop853'

altCmdBlock = systems.SystemFromCallable(
    interpolate.make_interp_spline(
        [0, 5],
        [spec_ic_args['h'] * ft_per_m, spec_ic_args['h'] * ft_per_m + 100.0],
        k=0), 0, 1)

BD.systems[-3] = altCmdBlock
BD.systems[2] = systems.SystemFromCallable(
    get_controller_function(*opt_ctrl, sasOn=True, apOn=True),
    dim_feedback + 4, 4)

with benchmark() as b:
    res = BD.simulate(20, integrator_options=int_opts)
    b.tfinal = res.t[-1]

plot_nesc_comparisons(res, '13p1')
plot_F16_controls(res, '13p1')
Exemple #8
0
# run_trimmer(get_ic_args_from_spec(), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=None, aileron_ic=None)
# run_trimmer(get_ic_from_baseline(5), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=0., aileron_ic=0.0)
# run_trimmer(get_ic_from_baseline(5), throttle_ic=13.9, elevator_ic=-3.241, allow_roll=True, rudder_ic=None, aileron_ic=None)
# ESD_cond = update_flight_condition(get_ic_from_spec(), psi=0., theta=0., phi=0.,)
##

int_opts['nsteps'] = 5_000
# int_opts['max_step'] = 2**-5

flight_condition = planet.ic_from_planetodetic(**opt_args)

planet.initial_condition = flight_condition

trim_ctrl_func = lambda t: opt_ctrl
trim_ctrl_block = systems.SystemFromCallable(trim_ctrl_func, 0, 4)

BD = BlockDiagram(planet, F16_vehicle, trim_ctrl_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(trim_ctrl_block,
           F16_vehicle,
           inputs=np.arange(planet.dim_output, planet.dim_output + 4))

import cProfile
cProfile.run('res = BD.simulate(180, integrator_options=int_opts)')

import time
tstart = time.time()
res = BD.simulate(180, integrator_options=int_opts)
tend = time.time()