.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "nesc_test_cases/nesc_case13p4.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_case13p4.py>`
        to download the full example code.

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

.. _sphx_glr_nesc_test_cases_nesc_case13p4.py:


=========================================================
Case 13.4: Lateral offset manuever 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=20s, 2000-ft lateral course offset.
==============  ===============

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-67

.. code-block:: Python



    from simupy import systems
    import numpy as np
    from scipy import interpolate

    from nesc_testcase_helper import plot_nesc_comparisons, plot_F16_controls, benchmark
    from nesc_case11 import (
        int_opts,
        F16ControllerBlock,
        BD,
        spec_ic_args,
        opt_ctrl,
        dim_feedback,
        earth,
        baseChiCmdBlock,
        latOffsetStateEquation,
        latOffsetOutputEquation,
    )


    def latOffsetOutputEquationShift(t, x):
        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] = F16ControllerBlock(*opt_ctrl, sasOn=True, apOn=True, event_t=20.)
    BD.connect(baseChiCmdBlock, latOffsetBlock, inputs=[0])
    BD.connect(
        earth, latOffsetBlock, outputs=[earth.V_N_idx, earth.V_E_idx], inputs=[1, 2]
    )

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





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

 .. code-block:: none

    time to simulate: 65.614 s




.. GENERATED FROM PYTHON SOURCE LINES 68-71

.. code-block:: Python


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



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


    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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






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

   **Total running time of the script:** (1 minutes 11.238 seconds)


.. _sphx_glr_download_nesc_test_cases_nesc_case13p4.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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