34import matplotlib.pyplot
as plt
35from scipy
import stats
44 time = float(sys.argv[1])
46pvdfile =
"particles.pvd"
48partData = reader.load()
49time = reader.get_snapshot_time()
64r = np.sqrt((x - 1.0) ** 2 + (y - 1.0) ** 2)
65v = -np.sqrt(vx**2 + vy**2)
68r_bin_edge = np.arange(0.0, 1.0, 0.02)
69r_bin = 0.5 * (r_bin_edge[1:] + r_bin_edge[:-1])
70rho_bin, _, _ = stats.binned_statistic(r, rho, statistic=
"mean", bins=r_bin_edge)
71v_bin, _, _ = stats.binned_statistic(r, v, statistic=
"mean", bins=r_bin_edge)
72P_bin, _, _ = stats.binned_statistic(r, P, statistic=
"mean", bins=r_bin_edge)
74u_bin, _, _ = stats.binned_statistic(r, u, statistic=
"mean", bins=r_bin_edge)
75rho2_bin, _, _ = stats.binned_statistic(r, rho**2, statistic=
"mean", bins=r_bin_edge)
76v2_bin, _, _ = stats.binned_statistic(r, v**2, statistic=
"mean", bins=r_bin_edge)
77P2_bin, _, _ = stats.binned_statistic(r, P**2, statistic=
"mean", bins=r_bin_edge)
79u2_bin, _, _ = stats.binned_statistic(r, u**2, statistic=
"mean", bins=r_bin_edge)
80rho_sigma_bin = np.sqrt(rho2_bin - rho_bin**2)
81v_sigma_bin = np.sqrt(v2_bin - v_bin**2)
82P_sigma_bin = np.sqrt(P2_bin - P_bin**2)
84u_sigma_bin = np.sqrt(u2_bin - u_bin**2)
89x_s = np.arange(0, 2.0, 2.0 / N) - 1.0
90rho_s = np.ones(N) * rho0
91P_s = np.ones(N) * rho0
95u0 = rho0 * P0 * (gas_gamma - 1)
96us = 0.5 * (gas_gamma - 1) * v0
100rho_s[np.abs(x_s) < rs] = rho0 * ((gas_gamma + 1) / (gas_gamma - 1)) ** 2
101P_s[np.abs(x_s) < rs] = 0.5 * rho0 * v0**2 * (gas_gamma + 1) ** 2 / (gas_gamma - 1)
102v_s[np.abs(x_s) < rs] = 0.0
105rho_s[np.abs(x_s) >= rs] = rho0 * (1 + v0 * time / np.abs(x_s[np.abs(x_s) >= rs]))
106P_s[np.abs(x_s) >= rs] = 0
111u_s = P_s / (rho_s * (gas_gamma - 1.0))
112s_s = P_s / rho_s**gas_gamma
115plt.figure(figsize=(7, 7 / 1.6))
119binned_marker_size = 4
124 markeredgecolor=
"none",
131errorbar_props = dict(color=binned_color, ms=binned_marker_size, fmt=
".", lw=1.2)
137plt.subplot(rows, cols, 1)
138plt.plot(r, v, **scatter_props)
139plt.plot(x_s, v_s,
"--", color=line_color, alpha=0.8, lw=1.2)
140plt.errorbar(r_bin, v_bin, yerr=v_sigma_bin, **errorbar_props)
141plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
142plt.ylabel(
"${\\rm{Velocity}}~v_r$", labelpad=-4)
147plt.subplot(rows, cols, 2)
148plt.plot(r, rho, **scatter_props)
149plt.plot(x_s, rho_s,
"--", color=line_color, alpha=0.8, lw=1.2)
150plt.errorbar(r_bin, rho_bin, yerr=rho_sigma_bin, **errorbar_props)
151plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
152plt.ylabel(
"${\\rm{Density}}~\\rho$", labelpad=0)
157plt.subplot(rows, cols, 3)
158plt.plot(r, P, **scatter_props)
159plt.plot(x_s, P_s,
"--", color=line_color, alpha=0.8, lw=1.2)
160plt.errorbar(r_bin, P_bin, yerr=P_sigma_bin, **errorbar_props)
161plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
162plt.ylabel(
"${\\rm{Pressure}}~P$", labelpad=0)
167plt.subplot(rows, cols, 4)
168plt.plot(r, u, **scatter_props)
169plt.plot(x_s, u_s,
"--", color=line_color, alpha=0.8, lw=1.2)
170plt.errorbar(r_bin, u_bin, yerr=u_sigma_bin, **errorbar_props)
171plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
172plt.ylabel(
"${\\rm{Internal~Energy}}~u$", labelpad=0)
178fname = f
"NohProfile{time:.4f}.png"
179plt.savefig(fname, dpi=200)
Reads in particle fields from a single .vtu file, or all .vtu at a given snapshot time specified in t...