"""Lecture 14, the propulsive efficiency 2/(1 + Ve/V) (flight.propulsion.propulsive_efficiency) against the ratio of
exit to flight speed, with the three streams of anim-14-jets.py. Writes img/fig-14-propulsive.png."""
import numpy as np
from _visual import plt, save, despine, MAROON, BLUE, GREEN, INK, GREY
from _scripts import load
from flight import propulsion as PR

J = load("anim-14-jets")
R = np.linspace(1.0, 5.0, 200)

if __name__ == "__main__":
    fig, ax = plt.subplots(figsize=(10, 5.2))
    ax.plot(R, PR.propulsive_efficiency(1.0, R), color=INK, lw=2.6)
    for r in J.ROWS:
        x = r["ve"] / J.V
        ax.plot(x, r["eta"], "o", color=r["c"], ms=9)
        ax.text(x + 0.08, r["eta"] + 0.02, f"{r['lab']}: {r['eta']:.2f}", color=r["c"], fontsize=12)
    ax.set_xlim(1, 5); ax.set_ylim(0, 1.05)
    ax.set_xlabel("exit speed / flight speed, $V_e/V$"); ax.set_ylabel("propulsive efficiency $\\eta_p$")
    despine(ax)
    save(fig, "fig-14-propulsive")
