"""Figure: truncated series V/V0 just inside the electrode (nu = 0.001) in the plane y=0, out to the rim (x=6). Data from rim_overshoot.py (rim_profiles.npy). Style as in the paper's Fig. 9. """ import sys from pathlib import Path import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt HERE = Path(__file__).resolve().parent sys.path.insert(0, str(HERE)) from pbvp import b, c plt.rcParams.update({"font.size": 9, "font.family": "serif", "mathtext.fontset": "cm"}) profile_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path.cwd() / "rim_profiles.npy" D = np.load(profile_path, allow_pickle=True).item() mu, NT = D["mu"], D["NT"]; nus = 0.001; P = D["prof"][nus] x = np.sqrt(4*(mu-b)*(b-nus)*(b-c)/(b-c)) # plane y=0 (lambda=c) fig, ax = plt.subplots(figsize=(3.6, 2.7), constrained_layout=True) for Q, sty in zip((60, 240, 960), [dict(color="C0", ls="--"), dict(color="C3", ls="-."), dict(color="k", ls="-")]): ax.plot(x, P[Q], lw=1, label=rf"$q\leq{Q}$ ({NT[Q]} terms)", **sty) ax.axhline(1.0, color="0.45", lw=0.8, ls=":", label=r"boundary value $V_0$ on the electrode") ax.axvline(6.0, color="0.3", lw=0.6) ax.text(5.93, 0.04, "rim", fontsize=7, ha="right", color="0.3") ax.set_xlim(3, 6.05); ax.set_ylim(0, 1.3) ax.set_xlabel(r"$x$ along the electrode, plane $y=0$") ax.set_ylabel(r"$V/V_0$") ax.legend(fontsize=7, loc="lower left") out_pdf = Path.cwd() / "mathieu_series_rim.pdf" out_png = Path.cwd() / "mathieu_series_rim.png" fig.savefig(out_pdf); fig.savefig(out_png, dpi=200) print("wrote", out_pdf, "and", out_png) for Q in (60, 240, 960): k = P[Q].argmax(); print(f"q<={Q}: max {P[Q][k]:.4f} at x = {x[k]:.3f} (6 - x = {6-x[k]:.3f})")