"""Lecture 18, thrust available from the Tejas-class engine (F404-GE-IN20, 84.5 kN with afterburner) by Mattingly's
low-bypass turbofan lapse (Gudmundsson eqs. 7-31 to 7-34, flight.propulsion.MattinglyJet): maximum (afterburner, solid)
and military (dashed) thrust against Mach number at four altitudes. Writes img/fig-18-thrust.png."""
import numpy as np
from _visual import plt, save, despine, MAROON, BLUE, GREEN, PURPLE, INK
import _fighter as F

M = np.linspace(0.0, 2.4, 400)
ALTS = [(0.0, MAROON), (6000.0, GREEN), (11000.0, BLUE), (15000.0, PURPLE)]
V = F.TEJ

if __name__ == "__main__":
    fig, ax = plt.subplots(figsize=(10, 5))
    for h, c in ALTS:
        ax.plot(M, [F.thrust(V, x, h, True) / 1e3 for x in M], color=c, lw=2.5, label=f"{h / 1e3:.0f} km")
        ax.plot(M, [F.thrust(V, x, h, False) / 1e3 for x in M], color=c, lw=1.8, ls="--")
    ax.plot([], [], color=INK, lw=2.5, label="afterburner"); ax.plot([], [], color=INK, lw=1.8, ls="--", label="military")
    ax.set_xlabel("Mach number"); ax.set_ylabel("thrust (kN)"); ax.set_ylim(0, 150)
    ax.legend(frameon=False, fontsize=12, loc="upper left", ncol=3)
    despine(ax)
    save(fig, "fig-18-thrust")
