"""Lecture 34: the representative capsule (B = 357 kg/m^2) entering at 7.8 km/s from 100 km at 2 deg with L/D from 0
to 0.4, lift up: peak deceleration (sensed), peak stagnation heat flux and heat load. Writes img/fig-34-lift.png."""
import numpy as np
from _visual import plt, save, despine, MAROON
import _entry33 as X

LDS = (0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4)
RUNS = [dict(ld=ld, **X.peaks(X.lifting(ld))) for ld in LDS]

if __name__ == "__main__":
    fig, axes = plt.subplots(1, 3, figsize=(10.4, 3.9), gridspec_kw=dict(wspace=0.38))
    for ax, key, scale, lab in zip(axes, ("load", "q", "Q"), (1.0, 1e-6, 1e-6),
                                   ("peak load (g)", "peak heat flux (MW/m²)", "heat load (MJ/m²)")):
        ax.plot(LDS, [r[key] * scale for r in RUNS], "o-", color=MAROON, lw=2.2, ms=5)
        ax.set_xlabel("lift / drag"); ax.set_title(lab, fontsize=11); ax.set_ylim(0, None); despine(ax)
    save(fig, "fig-34-lift")
