1
Fork 0

Save water animation

This commit is contained in:
Edgar P. Burkhart 2022-04-13 14:18:40 +02:00
parent 66b2a272ff
commit 975823fec8
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -44,7 +44,7 @@ P[:, C[1], C[2]] = model.fields["porosity"][:, C[0]]
AW = np.full((model.t.size, *X.shape), np.nan) AW = np.full((model.t.size, *X.shape), np.nan)
AW[:, C[1], C[2]] = model.fields["alpha.water"][:, C[0]] AW[:, C[1], C[2]] = model.fields["alpha.water"][:, C[0]]
fig, ax = plt.subplots() fig, ax = plt.subplots(figsize=(19.2, 10.8), dpi=100)
tit = ax.text( tit = ax.text(
0.5, 0.5,
0.95, 0.95,
@ -68,13 +68,13 @@ ax.axhline(4.5, ls="-.", lw=1, c="k", alpha=0.2, zorder=1.2)
def anim(i): def anim(i):
tit.set_text(f"t={i[0]}s") tit.set_text(f"t={model.t[i]}s")
aw_m.set_array(i[1]) aw_m.set_array(AW[i])
return (aw_m,) return (aw_m,)
fig.colorbar(aw_m) fig.colorbar(aw_m)
ax.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe") ax.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe")
ax.grid(c="k", alpha=0.2) ax.grid(c="k", alpha=0.2)
ani = animation.FuncAnimation(fig, anim, frames=zip(model.t, AW), interval=1 / 25) ani = animation.FuncAnimation(fig, anim, frames=model.t.size)
plt.show() ani.save(out.parent.joinpath("anim.mp4"), fps=24)