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

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

.. _sphx_glr_nesc_test_cases_nesc_case01.py:


===================================================
Case 1: Dropped sphere with no drag
===================================================

==============  ===============
Verifies        Gravitation, translational EOM
Gravitation     J2
Geodesy         WGS-84 rotating
Atmosphere      US 1976 STD
Winds           still air
Vehicle         Dragless sphere
Notes           Drag coefficient set to zero
==============  ===============

.. GENERATED FROM PYTHON SOURCE LINES 16-24

.. code-block:: Python


    from simupy.block_diagram import BlockDiagram
    import simupy_flight
    import numpy as np

    from nesc_testcase_helper import plot_nesc_comparisons, int_opts, benchmark
    from nesc_testcase_helper import ft_per_m








.. GENERATED FROM PYTHON SOURCE LINES 25-27

Construct the Planet model according to the
configuration listed above

.. GENERATED FROM PYTHON SOURCE LINES 27-39

.. code-block:: Python


    planet = simupy_flight.Planet(
        gravity=simupy_flight.earth_J2_gravity,
        winds=simupy_flight.get_constant_winds(),
        atmosphere=simupy_flight.get_constant_atmosphere(),
        planetodetics=simupy_flight.Planetodetic(
            a=simupy_flight.earth_equitorial_radius,
            omega_p=simupy_flight.earth_rotation_rate,
            f=simupy_flight.earth_f,
        ),
    )








.. GENERATED FROM PYTHON SOURCE LINES 40-43

Since there is no dynamics model (aerodynamic drag is set to zero)
there is no need to define a Vehicle model. So we construct the
BlockDiagram with just the planet object

.. GENERATED FROM PYTHON SOURCE LINES 43-46

.. code-block:: Python


    BD = BlockDiagram(planet)








.. GENERATED FROM PYTHON SOURCE LINES 47-50

List the planetodetic initial conditions and use the
`ic_from_planetodetic` method to transform it to the inertial
coordinate system needed for the initial condition

.. GENERATED FROM PYTHON SOURCE LINES 50-69

.. code-block:: Python


    lat_ic = 0.0 * np.pi / 180
    long_ic = 0.0 * np.pi / 180
    h_ic = 30_000 / ft_per_m
    V_N_ic = 0.0
    V_E_ic = 0.0
    V_D_ic = 0.0
    psi_ic = 0.0 * np.pi / 180
    theta_ic = 0.0 * np.pi / 180
    phi_ic = 0.0 * np.pi / 180
    omega_X_ic = 0.0
    omega_Y_ic = 0.0
    omega_Z_ic = 0.0

    planet.initial_condition = planet.ic_from_planetodetic(
        long_ic, lat_ic, h_ic, V_N_ic, V_E_ic, V_D_ic, psi_ic, theta_ic, phi_ic
    )
    planet.initial_condition[-3:] = omega_X_ic, omega_Y_ic, omega_Z_ic








.. GENERATED FROM PYTHON SOURCE LINES 70-76

Simulate the dropped sphere

.. note::

   The generated code performs a divide by zero if the velocity is zero, generating
   ``RuntimeWarning``\s. However, this condition is checked and handled correctly

.. GENERATED FROM PYTHON SOURCE LINES 76-80

.. code-block:: Python


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





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

 .. code-block:: none

    /home/runner/work/simupy-flight/simupy-flight/simupy_flight/kinematics.py:198: RuntimeWarning: invalid value encountered in scalar divide
      x60 = x6*(2*x26*x54 + x58*(-x13 + x14) + x59*(x33 + x55))/x53
    time to simulate: 1.094 s




.. GENERATED FROM PYTHON SOURCE LINES 81-82

Plot the results of the simulation

.. GENERATED FROM PYTHON SOURCE LINES 82-84

.. code-block:: Python


    plot_nesc_comparisons(res, "01")



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


    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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

    *

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






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

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


.. _sphx_glr_download_nesc_test_cases_nesc_case01.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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