.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "nesc_test_cases/nesc_case13p1.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_nesc_test_cases_nesc_case13p1.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_nesc_test_cases_nesc_case13p1.py:


===================================================
Case 13.1: Altitude change of a subsonic aircraft
===================================================

==============  ===============
Verifies        Multidimensional table look-up
Gravitation     J2
Geodesy         WGS-84 rotating
Atmosphere      US 1976 STD
Winds           still air
Vehicle         F-16 with simple auto-pilot
Notes           Initially straight & level. t=5s, command altitude 100-ft increase
==============  ===============

For the manuevering examples, the BlockDiagram from case 11 is modified to replace the
controller with the auto-pilot configuration and generate the appropriate command
signals.

.. GENERATED FROM PYTHON SOURCE LINES 20-51

.. code-block:: Python


    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,
        F16ControllerBlock,
        BD,
        spec_ic_args,
        opt_ctrl,
        dim_feedback,
    )

    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] = F16ControllerBlock(*opt_ctrl, sasOn=True, apOn=True, event_t=5.)

    with benchmark() as b:
        res = BD.simulate(20, integrator_options=int_opts)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Optimization terminated successfully.
             Current function value: 0.006500
             Iterations: 291
             Function evaluations: 554
    pitch: 2.6351e+00  roll: 0.0000e+00  longStk: 12.9236  throttle: 13.7561
    accelerations:
     [[-4.59609832e-03  4.59610301e-03  2.09229079e-09]
     [-2.98437663e-09 -1.70643291e-09  2.12618714e-09]]
    time to simulate: 20.365 s




.. GENERATED FROM PYTHON SOURCE LINES 52-55

.. code-block:: Python


    plot_nesc_comparisons(res, "13p1")
    plot_F16_controls(res, "13p1")



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_001.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_002.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_002.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_003.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_003.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_004.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_004.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_005.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_005.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_006.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_006.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_007.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_007.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_008.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_008.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_009.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_009.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_010.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_010.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /nesc_test_cases/images/sphx_glr_nesc_case13p1_011.png
         :alt: nesc case13p1
         :srcset: /nesc_test_cases/images/sphx_glr_nesc_case13p1_011.png
         :class: sphx-glr-multi-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 26.229 seconds)


.. _sphx_glr_download_nesc_test_cases_nesc_case13p1.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: nesc_case13p1.ipynb <nesc_case13p1.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: nesc_case13p1.py <nesc_case13p1.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: nesc_case13p1.zip <nesc_case13p1.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_