import%20marimo%0A%0A__generated_with%20%3D%20%220.13.15%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20rf%22%22%22%0A%20%20%20%20%23%20VTOL%20Take-off%20Failure%20Options%0A%0A%20%20%20%20Looking%20at%20some%20of%20the%20options%20in%20terms%20of%20engine%20failure(s)%20during%20a%20vertical%20take-off%20of%20an%20aircraft%20like%20the%20%5BPegasus%20Vertical%20Business%20Jet%20(VBJ)%5D(https%3A%2F%2Fpegasusua.com%2F).%0A%0A%20%20%20%20%7Bmo.image('public%2FPegasus%2FVBJ.png')%7D%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%20Vertical%20Descent%0A%0A%20%20%20%20Initially%20assume%20a%20purely%20vertical%20descent%20after%20a%20partial%20or%20complete%20engine%20failure%20to%20determine%20what%20the%20maximum%20height%20%0A%20%20%20%20is%20that%20the%20aircraft%20can%20descend%20from%20and%20land%20sucessfully%20based%20on%20the%20landing%20gear's%20rating.%0A%0A%20%20%20%20Basic%20kinematics.%0A%0A%20%20%20%20%24%5Clarge%20s%20%3D%20v_0%20%2B%20%5Cdfrac%7B1%7D%7B2%7Dat%5E2%24%0A%0A%20%20%20%20%24%5Clarge%20v%20%3D%20v_0%20%2B%20at%24%0A%0A%20%20%20%20Assuming%20%24v_0%24%20is%200%20then%20we%20can%20solve%20for%20the%20final%20velocity%20when%20hitting%20the%20ground%20from%20a%20starting%20height%20of%20%24s%24%20and%20ignoring%20any%20drag.%0A%0A%20%20%20%20%24%5Clarge%20t%20%3D%20%5Csqrt%7B%5Cdfrac%7B2s%7D%7Ba%7D%7D%24%0A%0A%20%20%20%20%24%5Clarge%20v%20%3D%20a%20%5Csqrt%7B%5Cdfrac%7B2s%7D%7Ba%7D%7D%24%0A%0A%20%20%20%20Or%20assuming%20a%20maximum%20%24v%24%20based%20on%20gear%20strength%20and%20a%20known%20acceleration%20%24a%24%20we%20can%20solve%20for%20%24s%24.%0A%0A%20%20%20%20%24%5Clarge%20s%20%3D%20%5Cdfrac%7Bv%5E2%7D%7B2a%7D%24%0A%0A%20%20%20%20%23%23%23%20Total%20Engine%20Failure%0A%0A%20%20%20%20Now%20assuming%20a%20maximum%20vertical%20speed%20of%20say%201%2C000fpm%20(5.1m%2Fs)%20in%20terms%20of%20what%20the%20landing%20gear%20are%20rated%20to%20and%20assuming%20a%20total%20engine%20failure%2C%20i.e.%20%24%20a%20%3D%20g%20%24.%0A%0A%20%20%20%20%24%5Clarge%20s%20%3D%20%5Cdfrac%7B5.1%5E2%7D%7B2%20%5C%2C%20%5Ctimes%20%5C%2C%209.81%7D%20%3D%201.3m%24%0A%0A%20%20%20%20So%20the%20aircraft%20can%20only%20handle%20a%20total%20engine%20failure%20from%201.3m%3F%0A%0A%20%20%20%20%23%23%23%20Partial%20Engine%20Failure%0A%0A%20%20%20%20For%20example%201%20of%20the%202%20engines%20failing.%20Let's%20assume%20the%20thrust%20to%20weight%20ratio%20with%20both%20engines%20at%20full%20thrust%20is%201.2%2C%20so%20%0A%20%20%20%20a%20thrust%20to%20weight%20ratio%20of%200.6%20with%20a%20single%20engine%20failure.%20So%20%24a%20%3D%20(1%20-%200.6)g%24%20in%20this%20case.%0A%0A%20%20%20%20%24%5Clarge%20s%20%3D%20%5Cdfrac%7B5.1%5E2%7D%7B2%20%5C%2C%20%5Ctimes%20%5C%2C%20(1%20%5C%2C%20%20-%20%5C%2C%200.6)%20%5C%2C%20%5Ctimes%20%5C%2C%209.81%7D%20%3D%203.3m%24%0A%0A%20%20%20%20Calculate%20and%20plot%20the%20safe%20height%20for%20partial%20engine%20failure%20versus%20the%20thrust%20to%20weight%20ratio%20available%20after%20the%20partial%20engine%20failure.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20plt)%3A%0A%20%20%20%20maxVS%20%3D%205.1%20%20%20%20%23%20Maxmimum%20safe%20vertical%20speed%20in%20m%2Fs%20given%20gear%20strength%20rating%0A%0A%20%20%20%20thrustToWeight%20%3D%20%5B%5D%0A%20%20%20%20height%20%3D%20%5B%5D%0A%0A%20%20%20%20for%20a%20in%20np.arange(0%2C%200.95%2C%200.01)%3A%0A%20%20%20%20%20%20%20%20s%20%3D%20maxVS**2%20%2F%20(2%20*%20(1%20-%20a)%20*%209.81)%0A%20%20%20%20%20%20%20%20thrustToWeight.append(a)%0A%20%20%20%20%20%20%20%20height.append(s)%0A%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(thrustToWeight%2C%20height)%0A%20%20%20%20plt.xlabel(%22Thrust%20to%20Weight%20Ratio%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.ylabel(%22Maximum%20Safe%20Height%20(m)%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.title(%22Height%20vs%20Thrust%20to%20Weight%20Ratio%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.show()%0A%20%20%20%20return%20(maxVS%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%20On%20a%20Wing...%0A%0A%20%20%20%20On%20the%20failure%20of%20the%20one%20engine%2C%20we%20assume%20there%20is%20enough%20pitch%20authority%20to%20pitch%20the%20nose%20down%20and%20to%20then%20target%20and%20%0A%20%20%20%20hold%20an%20alpha%20command%20equal%20to%20%24C_l%24%20max.%20The%20assumption%20is%20that%20all%20the%20thrust%20available%20on%20the%20working%20engine%20is%20directed%20to%20the%20lift%20fans.%20Could%20consider%20recovery%20procedures%20that%20split%20and%20vary%20the%20thrust%20between%20the%20lift%20fans%20and%20the%20engine%20aligned%20with%20the%20aircraft's%20x-axis%20if%20it%20improves%20the%20recovery%20procedure.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%23%20Aircraft%20Config%0A%0A%20%20%20%20The%20wing%20area%20has%20been%20configured%20in%20conjunction%20with%20the%20aero%20data%20to%20achieve%20level%20flight%20at%20100KIAS%20at%20an%20AoA%20of%205%20degrees.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20math%20import%20radians%2C%20degrees%2C%20atan2%2C%20sin%2C%20cos%2C%20sqrt%0A%0A%20%20%20%20%23%20Nature%0A%20%20%20%20rho%20%3D%201.229%20%20%20%20%20%20%20%20%20%20%20%20%23%20kg%2Fm%5E3%2C%20not%20varying%20based%20on%20altitude%0A%20%20%20%20g%20%3D%209.81%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20m%2Fs%5E2%0A%0A%20%20%20%20%23%20Aircraft%0A%20%20%20%20wing_area%20%3D%2055%20%20%20%20%20%20%20%20%20%23%20m%5E2%0A%20%20%20%20aircraft_mass%20%3D%205000%20%20%20%23%20kg%0A%20%20%20%20max_thrust%20%3D%201.2%20*%20aircraft_mass%20*%20g%20%20%23%20N%0A%20%20%20%20max_pitch_rate%20%3D%2010%20%20%20%20%20%20%20%20%23%20deg%2Fs%0A%20%20%20%20alpha_command_target%20%3D%2013%20%20%23%20deg%2C%20based%20on%20Cl_max%0A%0A%20%20%20%20engine_out_thrust%20%3D%200.5%20*%20max_thrust%20%20%23%20N%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20aircraft_mass%2C%0A%20%20%20%20%20%20%20%20alpha_command_target%2C%0A%20%20%20%20%20%20%20%20atan2%2C%0A%20%20%20%20%20%20%20%20cos%2C%0A%20%20%20%20%20%20%20%20degrees%2C%0A%20%20%20%20%20%20%20%20engine_out_thrust%2C%0A%20%20%20%20%20%20%20%20g%2C%0A%20%20%20%20%20%20%20%20max_pitch_rate%2C%0A%20%20%20%20%20%20%20%20radians%2C%0A%20%20%20%20%20%20%20%20rho%2C%0A%20%20%20%20%20%20%20%20sin%2C%0A%20%20%20%20%20%20%20%20sqrt%2C%0A%20%20%20%20%20%20%20%20wing_area%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%23%20Aero%20Data%0A%0A%20%20%20%20Since%20we%20don't%20have%20aero%20data%2C%20in%20particular%20to%20a%20maximum%20AoA%20of%2090%20degrees%2C%20I'm%20using%20the%20following%20data%20from%20%5BAerodynamic%20characteristics%20of%20seven%20symmetrical%20airfoil%20sections%20through%20180-degree%20angle%20of%20attack%20for%20use%20in%20aerodynamic%20analysis%20of%20vertical%20axis%20wind%20turbines%5D(https%3A%2F%2Fwww.osti.gov%2Fservlets%2Fpurl%2F6548367)%20as%20a%20place-holder%20for%20now.%20%0A%0A%20%20%20%20In%20addition%20to%20the%20data%20covering%20180%20degrees%20of%20alpha%20it%20also%20includes%20data%20for%20various%20Reynolds%20numbers.%20Currently%20using%20the%20fairly%20low%20Reynolds%20number%20of%202%20million.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Aero%20Data%0A%20%20%20%20alphas%20%3D%20%5B%200%2C%201%2C%202%2C%203%2C%204%2C%205%2C%206%2C%207%2C%208%2C%209%2C%2010%2C%2011%2C%2012%2C%2013%2C%2014%2C%2015%2C%2016%2C%2017%2C%2018%2C%2019%2C%2020%2C%2021%2C%2022%2C%2023%2C%2024%2C%2025%2C%2026%2C%2027%2C%2030%2C%2035%2C%2040%2C%2045%2C%2050%2C%2055%2C%2060%2C%2065%2C%2070%2C%2075%2C%2080%2C%2085%2C%2090%20%5D%0A%0A%20%20%20%20Cls%20%3D%20%5B%200%2C%200.11%2C%200.22%2C%200.33%2C%200.44%2C%200.55%2C%200.66%2C%200.77%2C%200.88%2C%200.99%2C%201.0727%2C%201.1539%2C%201.2072%2C%201.2169%2C%201.1614%2C%201.0478%2C%200.9221%2C%200.7826%2C%200.7163%2C%200.7091%2C%200.7269%2C%200.7595%2C%200.7981%2C%200.8429%2C%200.8882%2C%200.9352%2C%200.9842%2C%201.0355%2C%200.9150%2C%201.0200%2C%201.0750%2C%201.0850%2C%201.0400%2C%200.9650%2C%200.8750%2C%200.7650%2C%200.6500%2C%200.5150%2C%200.3700%2C%200.2200%2C%200.0700%20%5D%0A%0A%20%20%20%20Cds%20%3D%20%5B%200.0064%2C%200.0064%2C%200.0066%2C%200.0069%2C%200.0073%2C%200.0081%2C%200.0090%2C%200.0097%2C%200.0105%2C%200.0113%2C%200.0128%2C%200.0140%2C%200.0155%2C%200.0172%2C%200.0191%2C%200.0213%2C%200.0237%2C%200.1380%2C%200.2520%2C%200.2740%2C%200.2970%2C%200.3200%2C%200.3440%2C%200.3690%2C%200.3940%2C%200.4200%2C%200.4460%2C%200.4730%2C%200.5700%2C%200.7450%2C%200.9200%2C%201.0750%2C%201.2150%2C%201.3450%2C%201.4700%2C%201.5750%2C%201.6650%2C%201.7350%2C%201.7800%2C%201.8%2C%201.8%20%5D%20%0A%20%20%20%20return%20Cds%2C%20Cls%2C%20alphas%0A%0A%0A%40app.cell%0Adef%20_(Cds%2C%20Cls%2C%20alphas%2C%20plt)%3A%0A%20%20%20%20%23%20Plot%20the%20aero%20data%0A%20%20%20%20plt.figure()%0A%0A%20%20%20%20plt.plot(alphas%2C%20Cls%2C%20label%3D%22%24C_l%24%22)%0A%20%20%20%20plt.plot(alphas%2C%20Cds%2C%20label%3D%22%24C_d%24%22)%0A%0A%20%20%20%20plt.xlabel(%22alpha%20(deg)%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.ylabel(%22%24C_l%24%20and%20%24C_d%24%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.title(%22%24C_l%24%20and%20%24C_d%24%20versus%20alpha%22%2C%20fontsize%3D15)%0A%20%20%20%20plt.legend()%0A%20%20%20%20plt.show()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20rf%22%22%22%0A%20%20%20%20%23%23%23%203-DOF%20Simulation%20Implementation%0A%0A%20%20%20%20%7Bmo.image('public%2FPegasus%2FVTOLAxes.png'%2C%20width%3D600)%7D%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(atan2%2C%20degrees)%3A%0A%20%20%20%20def%20calc_gamma(vx%2C%20vy)%3A%0A%20%20%20%20%20%20%20%20if%20vx%20%3D%3D%200%20and%20vy%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%200%0A%20%20%20%20%20%20%20%20if%20vx%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20vy%20%3E%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%2090%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20-90%0A%20%20%20%20%20%20%20%20return%20degrees(atan2(vy%2C%20vx))%0A%20%20%20%20return%20(calc_gamma%2C)%0A%0A%0A%40app.function%0Adef%20calc_alpha(theta%2C%20gamma)%3A%0A%20%20%20%20return%20theta%20-%20gamma%0A%0A%0A%40app.cell%0Adef%20_(cos%2C%20radians%2C%20sin)%3A%0A%20%20%20%20def%20thrust_force_from_body_to_inertial(thrust%2C%20theta)%3A%0A%20%20%20%20%20%20%20%20thrust_x%20%3D%20-thrust%20*%20sin(radians(theta))%0A%20%20%20%20%20%20%20%20thrust_y%20%3D%20%20thrust%20*%20cos(radians(theta))%0A%20%20%20%20%20%20%20%20return%20thrust_x%2C%20thrust_y%0A%20%20%20%20return%20(thrust_force_from_body_to_inertial%2C)%0A%0A%0A%40app.cell%0Adef%20_(cos%2C%20radians%2C%20sin)%3A%0A%20%20%20%20def%20lift_drag_force_from_wind_to_inertial(lift%2C%20drag%2C%20gamma)%3A%0A%20%20%20%20%20%20%20%20Lx%20%3D%20lift%20*%20cos(radians(gamma%20%2B%2090))%0A%20%20%20%20%20%20%20%20Ly%20%3D%20lift%20*%20sin(radians(gamma%20%2B%2090))%0A%20%20%20%20%20%20%20%20Dx%20%3D%20drag%20*%20cos(radians(gamma%20%2B%20180))%0A%20%20%20%20%20%20%20%20Dy%20%3D%20drag%20*%20sin(radians(gamma%20%2B%20180))%0A%20%20%20%20%20%20%20%20return%20(Lx%2C%20Ly%2C%20Dx%2C%20Dy)%0A%20%20%20%20return%20(lift_drag_force_from_wind_to_inertial%2C)%0A%0A%0A%40app.cell%0Adef%20_(Cls%2C%20alphas%2C%20np%2C%20rho%2C%20wing_area)%3A%0A%20%20%20%20def%20lift_force(alpha%2C%20v)%3A%0A%20%20%20%20%20%20%20%20Cl%20%3D%20np.interp(alpha%2C%20alphas%2C%20Cls)%0A%20%20%20%20%20%20%20%20return%200.5%20*%20rho%20*%20Cl%20*%20wing_area%20*%20v**2%0A%20%20%20%20return%20(lift_force%2C)%0A%0A%0A%40app.cell%0Adef%20_(Cds%2C%20alphas%2C%20np%2C%20rho%2C%20wing_area)%3A%0A%20%20%20%20def%20drag_force(alpha%2C%20v)%3A%0A%20%20%20%20%20%20%20%20Cd%20%3D%20np.interp(alpha%2C%20alphas%2C%20Cds)%0A%20%20%20%20%20%20%20%20return%200.5%20*%20rho%20*%20Cd%20*%20wing_area%20*%20v**2%0A%20%20%20%20return%20(drag_force%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%23%20Simulation%20Loop%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20aircraft_mass%2C%0A%20%20%20%20alpha_command_target%2C%0A%20%20%20%20calc_gamma%2C%0A%20%20%20%20drag_force%2C%0A%20%20%20%20engine_out_thrust%2C%0A%20%20%20%20g%2C%0A%20%20%20%20lift_drag_force_from_wind_to_inertial%2C%0A%20%20%20%20lift_force%2C%0A%20%20%20%20max_pitch_rate%2C%0A%20%20%20%20sqrt%2C%0A%20%20%20%20thrust_force_from_body_to_inertial%2C%0A)%3A%0A%20%20%20%20dt%20%3D%200.01%20%20%23%20100Hz%0A%0A%20%20%20%20weight%20%3D%20aircraft_mass%20*%20g%0A%0A%20%20%20%20%23%20State%20and%20initial%20conditions%0A%20%20%20%20starting_altitude%20%3D%20300%20%20%20%20%20%20%20%20%20%23%20m%0A%20%20%20%20x%2C%20y%20%3D%200%2C%20starting_altitude%20%20%20%20%20%23%20m%0A%20%20%20%20vx%2C%20vy%20%3D%200%2C%200%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20m%2Fs%0A%20%20%20%20theta%20%3D%200%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20degrees%0A%20%20%20%20gamma%2C%20alpha%20%3D%200%2C%200%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20degrees%0A%0A%20%20%20%20reaction_time%20%3D%200%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20s%0A%0A%20%20%20%20time_history%20%3D%20%5B0%5D%0A%20%20%20%20position_x_history%20%3D%20%5Bx%5D%0A%20%20%20%20position_y_history%20%3D%20%5By%5D%0A%20%20%20%20vy_history%20%3D%20%5B0%5D%0A%20%20%20%20alpha_history%20%3D%20%5Balpha%5D%0A%20%20%20%20gamma_history%20%3D%20%5Bgamma%5D%0A%20%20%20%20theta_history%20%3D%20%5Btheta%5D%0A%20%20%20%20airspeed_history%20%3D%20%5B0%5D%0A%20%20%20%20delta_altitude_history%20%3D%20%5B0%5D%0A%20%20%20%20lift_y_history%20%3D%20%5B0%5D%0A%20%20%20%20thrust_y_history%20%3D%20%5Bengine_out_thrust%5D%0A%0A%20%20%20%20time%20%3D%200%0A%0A%20%20%20%20while(True)%3A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20current%20airspeed%0A%20%20%20%20%20%20%20%20v%20%3D%20sqrt(vx**2%20%2B%20vy**2)%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20forces%0A%20%20%20%20%20%20%20%20lift%20%3D%20lift_force(alpha%2C%20v)%0A%20%20%20%20%20%20%20%20drag%20%3D%20drag_force(alpha%2C%20v)%0A%0A%20%20%20%20%20%20%20%20%23%20Convert%20forces%20into%20inertial%20x%20and%20y%20components%0A%20%20%20%20%20%20%20%20Lx%2C%20Ly%2C%20Dx%2C%20Dy%20%3D%20lift_drag_force_from_wind_to_inertial(lift%2C%20drag%2C%20gamma)%0A%20%20%20%20%20%20%20%20engine_x%2C%20engine_y%20%3D%20thrust_force_from_body_to_inertial(engine_out_thrust%2C%20theta)%0A%0A%20%20%20%20%20%20%20%20%23%20Sum%20forces%0A%20%20%20%20%20%20%20%20F_x%20%3D%20Lx%20%2B%20Dx%20%2B%20engine_x%0A%20%20%20%20%20%20%20%20F_y%20%3D%20Ly%20%2B%20Dy%20%2B%20engine_y%20-%20weight%0A%0A%20%20%20%20%20%20%20%20%23%20Resultant%20accelerations%0A%20%20%20%20%20%20%20%20a_x%20%3D%20F_x%20%2F%20aircraft_mass%0A%20%20%20%20%20%20%20%20a_y%20%3D%20F_y%20%2F%20aircraft_mass%0A%0A%20%20%20%20%20%20%20%20%23%20Integrations%20for%20velocity%20and%20position%0A%20%20%20%20%20%20%20%20d_vx%20%3D%20a_x%20*%20dt%0A%20%20%20%20%20%20%20%20d_vy%20%3D%20a_y%20*%20dt%0A%20%20%20%20%20%20%20%20x%20%2B%3D%20(vx%20%2B%200.5%20*%20d_vx)%20*%20dt%0A%20%20%20%20%20%20%20%20y%20%2B%3D%20(vy%20%2B%200.5%20*%20d_vy)%20*%20dt%0A%20%20%20%20%20%20%20%20vx%20%2B%3D%20d_vx%0A%20%20%20%20%20%20%20%20vy%20%2B%3D%20d_vy%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20gamma%2C%20alpha%0A%20%20%20%20%20%20%20%20gamma%20%3D%20calc_gamma(vx%2C%20vy)%0A%20%20%20%20%20%20%20%20alpha%20%3D%20calc_alpha(theta%2C%20gamma)%0A%0A%20%20%20%20%20%20%20%20%23%20FCS%20logic%20-%20simple%20alpha%20command%20with%20alpha%20target%20matching%20Cl_max%0A%20%20%20%20%20%20%20%20if%20time%20%3E%3D%20reaction_time%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha_error%20%3D%20alpha%20-%20alpha_command_target%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20abs(alpha_error)%20%3E%200.1%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_pitch_delta%20%3D%20max_pitch_rate%20*%20dt%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20alpha%20%3E%20alpha_command_target%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20theta%20-%3D%20min(max_pitch_delta%2C%20abs(alpha_error))%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20theta%20%2B%3D%20min(max_pitch_delta%2C%20abs(alpha_error))%0A%0A%20%20%20%20%20%20%20%20%23%20Time%20marches%20on%0A%20%20%20%20%20%20%20%20time%20%2B%3D%20dt%0A%0A%20%20%20%20%20%20%20%20%23%20History%20recording%0A%20%20%20%20%20%20%20%20time_history.append(time)%0A%20%20%20%20%20%20%20%20position_x_history.append(x)%0A%20%20%20%20%20%20%20%20position_y_history.append(y)%0A%20%20%20%20%20%20%20%20vy_history.append(vy)%0A%20%20%20%20%20%20%20%20alpha_history.append(alpha)%0A%20%20%20%20%20%20%20%20gamma_history.append(gamma)%0A%20%20%20%20%20%20%20%20theta_history.append(theta)%0A%20%20%20%20%20%20%20%20airspeed_history.append(sqrt(vx**2%20%2B%20vy**2)%20*%201.944012)%20%20%23%20knots%0A%20%20%20%20%20%20%20%20delta_altitude_history.append(starting_altitude%20-%20y)%0A%20%20%20%20%20%20%20%20lift_y_history.append(Ly)%0A%20%20%20%20%20%20%20%20thrust_y_history.append(engine_y)%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%23%20Have%20we%20recovered%20or%20crashed%3F%0A%20%20%20%20%20%20%20%20if%20y%20%3C%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Crashed...%20time%3A%20%7Btime%3A.1f%7Ds%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20gamma%20%3E%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Recovered...%20time%3A%20%7Btime%3A.1f%7Ds%20%20recovery%20altitude%3A%20%7By%3A.1f%7Dm%20%20%20altitude%20lost%3A%20%7Bstarting_altitude%20-%20y%3A.1f%7Dm%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20airspeed_history%2C%0A%20%20%20%20%20%20%20%20alpha_history%2C%0A%20%20%20%20%20%20%20%20delta_altitude_history%2C%0A%20%20%20%20%20%20%20%20gamma_history%2C%0A%20%20%20%20%20%20%20%20lift_y_history%2C%0A%20%20%20%20%20%20%20%20position_x_history%2C%0A%20%20%20%20%20%20%20%20position_y_history%2C%0A%20%20%20%20%20%20%20%20theta_history%2C%0A%20%20%20%20%20%20%20%20thrust_y_history%2C%0A%20%20%20%20%20%20%20%20time_history%2C%0A%20%20%20%20%20%20%20%20vy_history%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%23%20Plot%20Routines%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plt%2C%20position_x_history%2C%20position_y_history)%3A%0A%20%20%20%20def%20plot_flight_profile()%3A%0A%20%20%20%20%20%20%20%20plt.figure()%0A%20%20%20%20%20%20%20%20plt.plot(position_x_history%2C%20position_y_history)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Horizontal%20Distance%20(m)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Altitude%20(m)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.title(r%22Flight%20Profile%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.show()%0A%20%20%20%20return%20(plot_flight_profile%2C)%0A%0A%0A%40app.cell%0Adef%20_(alpha_history%2C%20gamma_history%2C%20plt%2C%20theta_history%2C%20time_history)%3A%0A%20%20%20%20def%20plot_angles()%3A%0A%20%20%20%20%20%20%20%20plt.figure()%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20alpha_history%2C%20label%3Dr%22%24%5Calpha%24%22)%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20gamma_history%2C%20label%3Dr%22%24%5Cgamma%24%22)%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20theta_history%2C%20label%3Dr%22%24%5Ctheta%24%22)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Time%20(s)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Degrees%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.title(r%22%24%5Calpha%24%20%24%5Cgamma%24%20%24%5Ctheta%24%20vs%20Time%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.legend()%0A%20%20%20%20%20%20%20%20plt.show()%0A%20%20%20%20return%20(plot_angles%2C)%0A%0A%0A%40app.cell%0Adef%20_(airspeed_history%2C%20plt%2C%20time_history)%3A%0A%20%20%20%20def%20plot_airspeed()%3A%0A%20%20%20%20%20%20%20%20plt.figure()%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20airspeed_history)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Time%20(s)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Airspeed%20(KIAS)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.title(%22Airspeed%20vs%20Time%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.show()%0A%20%20%20%20return%20(plot_airspeed%2C)%0A%0A%0A%40app.cell%0Adef%20_(delta_altitude_history%2C%20maxVS%2C%20plt%2C%20vy_history)%3A%0A%20%20%20%20def%20plot_vertical_speed_vs_altitude_loss()%3A%0A%20%20%20%20%20%20%20%20plt.figure()%0A%20%20%20%20%20%20%20%20plt.plot(delta_altitude_history%2C%20vy_history)%0A%20%20%20%20%20%20%20%20plt.axhline(y%20%3D%20-maxVS%2C%20color%20%3D%20'r'%2C%20linestyle%20%3D%20'-')%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Altitude%20Loss%20(m)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Vertical%20Speed%20(m%2Fs)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.title(%22Vertical%20Speed%20vs%20Altitude%20Loss%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.show()%0A%20%20%20%20return%20(plot_vertical_speed_vs_altitude_loss%2C)%0A%0A%0A%40app.cell%0Adef%20_(lift_y_history%2C%20plt%2C%20thrust_y_history%2C%20time_history)%3A%0A%20%20%20%20def%20plot_lift_components()%3A%0A%20%20%20%20%20%20%20%20plt.figure()%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20lift_y_history%2C%20label%3D%22Aero%20Lift%22)%0A%20%20%20%20%20%20%20%20plt.plot(time_history%2C%20thrust_y_history%2C%20label%3D%22Fan%20Lift%22)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Time%20(s)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Lift%20(N)%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.title(%22Lift%20vs%20Time%22%2C%20fontsize%3D15)%0A%20%20%20%20%20%20%20%20plt.legend()%0A%20%20%20%20%20%20%20%20plt.show()%20%20%20%20%0A%20%20%20%20return%20(plot_lift_components%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%20Results%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%23%23%20Profile%20View%0A%0A%20%20%20%20Showing%20altitude%20loss%20versus%20horizontal%20range%20flown.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_flight_profile)%3A%0A%20%20%20%20plot_flight_profile()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%23%23%20Angles%0A%0A%20%20%20%20Showing%20the%20time%20history%20for%20all%20the%20angles.%20Max%20pitch%20angle%20of%20-42%20degrees%2C%20ending%20with%20%2B12%20degrees.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_angles)%3A%0A%20%20%20%20plot_angles()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%23%20Airspeed%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_airspeed)%3A%0A%20%20%20%20plot_airspeed()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%23%20Vertical%20Speed%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_vertical_speed_vs_altitude_loss)%3A%0A%20%20%20%20plot_vertical_speed_vs_altitude_loss()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%23%23%23%23%20Aerodynamic%20Lift%20vs%20Lift%20Fan%20Lift%0A%0A%20%20%20%20Lift%20in%20the%20inertial%20y%20axis.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plot_lift_components)%3A%0A%20%20%20%20plot_lift_components()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%20H-V%20Height%20Velocity%20Diagrams%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20return%20mo%2C%20np%2C%20plt%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
3c534190871b851188b4c10c5a5d1bdbf8abb2572005f11eb1e6aa986bc17121