4dff647Bead-sheet cymbal: 2D FPUT plate with bending and dome, chaos scan, web appJeremy Magland 1"""Figure from results/explore2.npz (written by experiments.py with TAG=explore2). Run: python plots.py"""
3from __future__ import annotations
5import os
7import matplotlib
9matplotlib.use("Agg")
10import matplotlib.pyplot as plt # noqa: E402
11import numpy as np # noqa: E402
13HERE = os.path.dirname(os.path.abspath(__file__))
14RES = os.path.join(HERE, "results")
16if __name__ == "__main__":
17 d = np.load(os.path.join(RES, "explore2.npz"))
18 fig, ax = plt.subplots(2, 2, figsize=(14, 8))
19 for j, Kb in enumerate((8.0, 25.0)):
20 k = f"Kb{Kb:g}_Hd10_E{10000:g}"
21 t, Ek, f = d[k + "_t"], d[k + "_Ek"], d[k + "_f"]
22 order = np.argsort(f)
23 sh = Ek / Ek.sum(1, keepdims=True)
24 edges = np.geomspace(f.min(), f.max() * 1.0001, 37)
25 B = np.stack([sh[:, (f >= a) & (f < b)].sum(1) for a, b in zip(edges[:-1], edges[1:])], 1)
26 ax[0, j].pcolormesh(t * 1000, np.sqrt(edges[:-1] * edges[1:]), np.log10(B.T + 1e-12), vmin=-6, vmax=0, cmap="magma",
27 shading="auto", rasterized=True)
28 ax[0, j].set(yscale="log", title=f"bending {Kb:g}, dome 10, E = 10000: energy share per band", xlabel="time (ms of sound)",
29 ylabel="pitch (Hz)")
30 for E, col in zip((3000.0, 10000.0, 30000.0), ("C0", "C1", "C3")):
31 k = f"Kb{Kb:g}_Hd10_E{E:g}"
32 t, Ek, f = d[k + "_t"], d[k + "_Ek"], d[k + "_f"]
33 sh = Ek / Ek.sum(1, keepdims=True)
34 ax[1, j].plot(t * 1000, sh[:, f > 4000].sum(1), color=col, label=f"E = {E:g}, above 4 kHz")
35 ax[1, j].plot(t * 1000, sh[:, f > 1000].sum(1), color=col, lw=0.8, ls="--", label=f"E = {E:g}, above 1 kHz")
36 ax[1, j].set(ylim=(0, 1), xlabel="time (ms of sound)", ylabel="share of energy", title=f"bending {Kb:g}, dome 10, undamped")
37 ax[1, j].grid(alpha=0.3)
38 ax[1, 0].legend(fontsize=7)
39 fig.tight_layout()
40 fig.savefig(os.path.join(RES, "explore.png"), dpi=90)
41 print("wrote results/explore.png")