{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plane Velocity Example\n", "\n", "This example demonstrates how to use flight-mech to compute the velocity of a plane in several conditions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Python imports\n", "import os\n", "import sys\n", "sys.path.append(\"..\")\n", "\n", "# Additional imports\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# Flight-Mech imports\n", "from flight_mech.plane import Plane" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plane definition\n", "\n", "You can define a plane simply by calling its name if it is already defined in the database. Once the plane instance is created, you can easily compute essential quantities such as glide ratio and lift coefficient at maximum glide ratio." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fmax 12.909944487358056\n", "C_L_f_max 0.7745966692414834\n" ] } ], "source": [ "# Load the plane\n", "plane = Plane(\"cessna_172\")\n", "\n", "# Compute the fmax and CL at fmax\n", "print(\"fmax\", plane.f_max)\n", "print(\"C_L_f_max\", plane.C_L_f_max)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is also possible to change some plane characteristics directly. In this case, you might need to update the values of the variables." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Change the amount of fuel\n", "plane.m_fuel = 136.26 # kg\n", "plane.update_variables(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Velocity interval at 8000 meters\n", "\n", "You can compute some specific velocities deduced from the plane characteristics at a given altitude such as the reference altitude, the velocity interval (i.e. the interval of velocities that is available with the thrust of the plane) and the stall velocity." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "reference speed at 8000m [m.s-1] 56.25034304495441\n", "speed interval at 8000m [m.s-1] (22.573885291918142, 140.16643797724348)\n", "stall speed at 8000m [m.s-1] 41.82955138380646\n" ] } ], "source": [ "# Compute the speed interval at 8000 meters\n", "print(\"reference speed at 8000m [m.s-1]\", plane.compute_reference_speed(8000))\n", "print(\"speed interval at 8000m [m.s-1]\",\n", " plane.compute_velocity_interval_for_fixed_thrust(8000))\n", "print(\"stall speed at 8000m [m.s-1]\",\n", " plane.compute_stall_speed(8000, C_L_max=1.5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ascension velocity and slope\n", "\n", "You can also compute the velocity in a non-horizontal flight conditions." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "max ascension speed [m.s-1] 32.89702949399428\n", "reference speed at 0m [m.s-1] 34.52424312519015\n", "max slope at 0m [rad] 0.5695767110104357\n" ] } ], "source": [ "# Consider that the tank is almost empty\n", "plane.m_fuel = 0 # kg\n", "plane.update_variables(True)\n", "\n", "# Compute the ascension speed and slope at sea level\n", "print(\"max ascension speed [m.s-1]\", plane.compute_max_ascension_speed(z=0))\n", "print(\"reference speed at 0m [m.s-1]\", plane.compute_reference_speed(z=0))\n", "print(\"max slope at 0m [rad]\", plane.compute_max_ascension_slope(z=0))" ] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" } }, "nbformat": 4, "nbformat_minor": 2 }