import%20marimo%0A%0A__generated_with%20%3D%20%220.14.10%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%20r%22%22%22%0A%20%20%20%20%23%20EAS%20-%20Equivalent%20AirSpeed%0A%0A%20%20%20%20Aerodynamic%20forces%20like%20lift%2C%20drag%20etc.%20are%20proportional%20to%20the%20dynamic%20pressure.%0A%0A%20%20%20%20%24Q%20%3D%20%5Cfrac%7B1%7D%7B2%7D%20%5Crho%20V%5E2%24%0A%0A%20%20%20%20%24Q%24%20-%20dynamic%20pressure%20%0A%20%20%20%20%24%5Crho%24%20-%20air%20density%0A%20%20%20%20%24V%24%20-%20airspeed%20of%20the%20aircraft%20relative%20to%20the%20air%20mass%0A%0A%20%20%20%20The%20air%20density%20%24%5Crho%24%20varies%20based%20on%20pressure%20altitude%20and%20temperature%2C%20see%20%5BInternational%20Standard%20Atmosphere%5D(https%3A%2F%2Fseanmcleod70.github.io%2FFlightDynamicsCalcs%2FInternationalStandardAtmosphere.html).%0A%0A%20%20%20%20-%20**TAS**%20-%20True%20Airspeed%2C%20the%20velocity%20of%20the%20aircraft%20relative%20to%20the%20air%20mass.%0A%0A%20%20%20%20-%20**IAS**%20-%20Indicated%20Airspeed%2C%20airspeed%20measured%20by%20the%20pitot-static%20system.%0A%0A%20%20%20%20-%20**CAS**%20-%20Calibrated%20Airspeed%2C%20IAS%20corrected%20for%20instrument%20and%20position%20errors.%0A%0A%20%20%20%20-%20**EAS**%20-%20Equivalent%20Airspeed%2C%20CAS%20corrected%20for%20compressibility%20effects.%0A%0A%20%20%20%20The%20pitot%20static%20system%20of%20the%20aircraft%20measures%20the%20difference%20between%20the%20total%2Fstagnation%20pressure%20%24p_t%24%0A%20%20%20%20and%20the%20static%20pressure%20%24p_s%24%2C%20and%20is%20calibrated%20for%20standard%20sea-level%20ISA%20conditions%20via%20%24%5Crho_0%24%2C%20the%20air%0A%20%20%20%20density%20for%20standard%20sea-level%20ISA%20conditions%2C%20%241.225%20kg%2Fm%5E3%24.%0A%0A%20%20%20%20%24IAS%20%3D%20%5Csqrt%7B%5Cdfrac%7B2(p_t%20-%20p_s)%7D%7B%5Crho_0%7D%7D%24%0A%0A%20%20%20%20Assuming%20standard%20day%20ISA%20sea-level%20conditions%20and%20assuming%20no%20instrument%20or%20position%20error%20and%20low%20enough%0A%20%20%20%20airspeed%20that%20compressibility%20isn't%20a%20factor%2C%20then%20%24TAS%20%3D%20IAS%20%3D%20CAS%20%3D%20EAS%24.%0A%0A%20%20%20%20%23%23%20Compressibility%0A%0A%20%20%20%20When%20the%20aircraft%20is%20flying%20at%20high%20airspeeds%20the%20total%2Fstagnation%20pressure%20in%20the%20pitot%20tube%20is%20not%20representative%0A%20%20%20%20of%20the%20airstream%20dynamic%20pressure%20due%20to%20a%20magnification%20by%20compressibility.%20The%20compressibility%20of%20the%20airflow%20in%0A%20%20%20%20the%20pitot%20tube%20produces%20a%20pressure%20which%20is%20greater%20than%20if%20the%20flow%20was%20incompressible.%20Therefore%20the%20airspeed%20%0A%20%20%20%20indicator%20reports%20an%20erroneous%20airspeed%20based%20on%20this%20magnification.%0A%0A%20%20%20%20The%20following%20plot%20shows%20the%20ratio%20of%20the%20dynamic%20pressure%20%24Q%24%20for%20a%20specific%20CAS%20as%20the%20altitude%20varies%20compared%0A%20%20%20%20to%20the%20sea-level%20dynamic%20pressure%20%24Q_0%24%20for%20the%20same%20CAS.%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_(plot_dynamic_pressure_scaling)%3A%0A%20%20%20%20plot_dynamic_pressure_scaling(%5B100%2C%20200%2C%20300%2C%20400%5D%2C%2030000)%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%20EAS%20is%20defined%20as%20producing%20the%20same%20dynamic%20pressure%20when%20coupled%20with%20standard%20sea%20level%20density%20as%20the%20TAS%0A%20%20%20%20coupled%20with%20the%20actual%20air%20density.%0A%0A%20%20%20%20%24(EAS)%5E2%20%5Crho_0%20%3D%20(TAS)%5E2%20%5Crho%24%0A%0A%20%20%20%20%24EAS%20%3D%20TAS%20%5Csqrt%7B%5Cdfrac%7B%5Crho%7D%7B%5Crho_0%7D%7D%24%0A%0A%20%20%20%20%24%5Crho%24%20-%20actual%20air%20density%20%24%5Crho_0%24%20-%20standard%20sea%20level%20density%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%20In%20terms%20of%20when%20compressibility%20needs%20to%20be%20taken%20into%20account%2C%20it%20depends%20on%20the%20degree%20of%20accuracy%20required%2C%20%0A%20%20%20%20with%20regards%20to%20whether%20you%20treat%20%24%5Crho%24%20as%20a%20constant%20or%20as%20a%20variable.%20The%20following%20equation%20calculates%0A%20%20%20%20the%20density%20%24%5Crho%24%20as%20a%20function%20of%20Mach.%0A%0A%20%20%20%20%24%5Cdfrac%7B%5Crho_0%7D%7B%5Crho%7D%20%3D%20%5Cleft(%201%20%2B%20%5Cdfrac%7B%5Cgamma%20-%201%7D%7B2%7D%20M%5E2%20%5Cright)%5E%7B1%2F(%5Cgamma%20-%201)%7D%24%0A%0A%20%20%20%20Looking%20at%20the%20plot%20of%20this%20function%20below%20for%20%24M%20%3C%200.32%24%20the%20variation%20in%20%24%5Crho%24%20is%20smaller%20then%205%25.%20As%20a%20result%0A%20%20%20%20a%20general%20rule%20of%20thumb%20the%20density%20variation%20should%20be%20accounted%20for%20at%20Mach%20numbers%20%3E%200.3.%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_(plot_density_versus_mach)%3A%0A%20%20%20%20plot_density_versus_mach()%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%20Airspeed%20Corrections%0A%0A%20%20%20%20%24EAS%20%3D%20CAS%20%2B%20%5CDelta%20V_C%24%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_(plot_compressibility_correction)%3A%0A%20%20%20%20plot_compressibility_correction(%5B5000%2C%2010000%2C%2015000%2C%2020000%2C%2025000%2C%2030000%5D%2C%20100%2C%20400)%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%20Plot%20Routines%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(dynamic_pressure%2C%20np%2C%20plt)%3A%0A%20%20%20%20def%20plot_dynamic_pressure_scaling(cas_speeds%2C%20max_alt)%3A%0A%20%20%20%20%20%20%20%20fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(10%2C%205))%0A%0A%20%20%20%20%20%20%20%20alts%20%3D%20np.linspace(0%2C%20max_alt%2C%2050)%0A%20%20%20%20%20%20%20%20for%20cas%20in%20cas_speeds%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20cas_0_pressure%20%3D%20dynamic_pressure(cas%2C%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20dynamic_pressure_ratio%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20alt%20in%20alts%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dynamic_pressure_ratio.append(dynamic_pressure(cas%2C%20alt)%20%2F%20cas_0_pressure)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(alts%2C%20dynamic_pressure_ratio%2C%20label%3Df'%7Bcas%7D%20KCAS')%0A%0A%20%20%20%20%20%20%20%20ax.set_ylabel('Dynamic%20pressure%20ratio%20%20%24%5C%5Cdfrac%7BQ%7D%7BQ_0%7D%24')%0A%20%20%20%20%20%20%20%20ax.set_xlabel('Altitude%20(ft)')%0A%20%20%20%20%20%20%20%20ax.set_title('Dynamic%20Pressure%20Ratio%20vs%20Altitude')%0A%20%20%20%20%20%20%20%20ax.legend()%0A%0A%20%20%20%20%20%20%20%20return%20plt.gca()%0A%20%20%20%20return%20(plot_dynamic_pressure_scaling%2C)%0A%0A%0A%40app.cell%0Adef%20_(math%2C%20np%2C%20plt%2C%20ticker)%3A%0A%20%20%20%20def%20plot_density_versus_mach()%3A%0A%20%20%20%20%20%20%20%20fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(10%2C%205))%0A%0A%20%20%20%20%20%20%20%20gamma%20%3D%201.4%0A%20%20%20%20%20%20%20%20exponent%20%3D%201%2F(gamma%20-%201)%0A%0A%20%20%20%20%20%20%20%20density_ratios%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20machs%20%3D%20np.linspace(0%2C%201%2C%2050)%0A%20%20%20%20%20%20%20%20for%20mach%20in%20machs%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20density_ratio%20%3D%20math.pow(1%20%2B%20((gamma%20-1)%2F2)*mach**2%2C%20exponent)%0A%20%20%20%20%20%20%20%20%20%20%20%20density_ratios.append(1%2Fdensity_ratio)%0A%20%20%20%20%20%20%20%20ax.plot(machs%2C%20density_ratios)%0A%0A%20%20%20%20%20%20%20%20ax.axhline(y%3D0.95%2C%20linestyle%3D'--')%0A%20%20%20%20%20%20%20%20ax.axvline(x%3D0.32%2C%20linestyle%3D'--')%0A%0A%20%20%20%20%20%20%20%20ax.xaxis.set_major_locator(ticker.MultipleLocator(0.1))%0A%0A%20%20%20%20%20%20%20%20ax.set_ylabel('%24%5C%5Cdfrac%7B%5C%5Crho%7D%7B%5C%5Crho_0%7D%24')%0A%20%20%20%20%20%20%20%20ax.set_xlabel('M')%0A%20%20%20%20%20%20%20%20ax.set_title('Density%20Variation%20versus%20Mach')%0A%0A%20%20%20%20%20%20%20%20return%20plt.gca()%0A%20%20%20%20return%20(plot_density_versus_mach%2C)%0A%0A%0A%40app.cell%0Adef%20_(CAStoEAS%2C%20ftTom%2C%20ktToms%2C%20msTokt%2C%20np%2C%20plt)%3A%0A%20%20%20%20def%20plot_compressibility_correction(altitudes%2C%20min_cas%2C%20max_cas)%3A%0A%20%20%20%20%20%20%20%20fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(10%2C%205))%0A%0A%20%20%20%20%20%20%20%20for%20alt%20in%20altitudes%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20corrections%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20cass%20%3D%20np.linspace(min_cas%2C%20max_cas%2C%2050)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20cas%20in%20cass%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eas%20%3D%20CAStoEAS(ktToms(cas)%2C%20ftTom(alt))%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20corrections.append(msTokt(eas)%20-%20cas)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(cass%2C%20corrections%2C%20label%3Df'%7Balt%7Dft')%0A%0A%20%20%20%20%20%20%20%20ax.set_ylabel('Compressibility%20Correction%20%24%5C%5CDelta%20V_C%24%20(kt)')%0A%20%20%20%20%20%20%20%20ax.set_xlabel('CAS%20(kt)')%0A%20%20%20%20%20%20%20%20ax.set_title('Compressibility%20Correction')%0A%20%20%20%20%20%20%20%20ax.legend()%0A%0A%20%20%20%20%20%20%20%20return%20plt.gca()%0A%20%20%20%20return%20(plot_compressibility_correction%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%20Utility%20Functions%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(CAStoTAS%2C%20ISA%2C%20ftTom%2C%20ktToms)%3A%0A%20%20%20%20def%20dynamic_pressure(cas%2C%20alt)%3A%0A%20%20%20%20%20%20%20%20%23%20cas%20-%20kt%2C%20alt%20-%20ft%0A%20%20%20%20%20%20%20%20_%2C%20density%2C%20_%2C%20_%20%3D%20ISA.state(ftTom(alt))%0A%20%20%20%20%20%20%20%20tas%20%3D%20CAStoTAS(ktToms(cas)%2C%20ftTom(alt))%0A%0A%20%20%20%20%20%20%20%20return%200.5%20*%20density%20*%20tas**2%0A%20%20%20%20return%20(dynamic_pressure%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20def%20ftTom(ft)%3A%0A%20%20%20%20%20%20%20%20return%20ft%20%2F%203.28084%0A%0A%20%20%20%20def%20mToft(m)%3A%0A%20%20%20%20%20%20%20%20return%20m%20*%203.28084%0A%0A%20%20%20%20def%20msTokt(ms)%3A%0A%20%20%20%20%20%20%20%20return%20ms%20*%201.944012%0A%0A%20%20%20%20def%20ktToms(kt)%3A%0A%20%20%20%20%20%20%20%20return%20kt%20%2F%201.944012%20%0A%20%20%20%20return%20ftTom%2C%20ktToms%2C%20msTokt%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20math%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20matplotlib.ticker%20as%20ticker%0A%20%20%20%20from%20ISA%20import%20ISAtmosphere%2C%20CAStoTAS%2C%20TAStoCAS%2C%20CAStoEAS%2C%20EAStoTAS%2C%20MachtoCAS%2C%20CAStoMach%0A%0A%20%20%20%20ISA%20%3D%20ISAtmosphere()%0A%20%20%20%20return%20CAStoEAS%2C%20CAStoTAS%2C%20ISA%2C%20math%2C%20mo%2C%20np%2C%20plt%2C%20ticker%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
80bf1467c4ba1a344d556a6a1c21a1f9e6975de99e7ca336442eee4ef41640cc