44import matplotlib.pyplot
as plt
45from scipy
import stats
54 time = float(sys.argv[1])
56pvdfile =
"particles.pvd"
58partData = reader.load()
59time = reader.get_snapshot_time()
76r = np.sqrt((x - 1.0) ** 2 + (y - 1.0) ** 2 + (z - 1.0) ** 2)
77v = -np.sqrt(vx**2 + vy**2 + vz**2)
80r_bin_edge = np.arange(0.0, 1.0, 0.02)
81r_bin = 0.5 * (r_bin_edge[1:] + r_bin_edge[:-1])
82rho_bin, _, _ = stats.binned_statistic(r, rho, statistic=
"mean", bins=r_bin_edge)
83v_bin, _, _ = stats.binned_statistic(r, v, statistic=
"mean", bins=r_bin_edge)
84P_bin, _, _ = stats.binned_statistic(r, P, statistic=
"mean", bins=r_bin_edge)
86u_bin, _, _ = stats.binned_statistic(r, u, statistic=
"mean", bins=r_bin_edge)
87rho2_bin, _, _ = stats.binned_statistic(r, rho**2, statistic=
"mean", bins=r_bin_edge)
88v2_bin, _, _ = stats.binned_statistic(r, v**2, statistic=
"mean", bins=r_bin_edge)
89P2_bin, _, _ = stats.binned_statistic(r, P**2, statistic=
"mean", bins=r_bin_edge)
91u2_bin, _, _ = stats.binned_statistic(r, u**2, statistic=
"mean", bins=r_bin_edge)
92rho_sigma_bin = np.sqrt(rho2_bin - rho_bin**2)
93v_sigma_bin = np.sqrt(v2_bin - v_bin**2)
94P_sigma_bin = np.sqrt(P2_bin - P_bin**2)
96u_sigma_bin = np.sqrt(u2_bin - u_bin**2)
101x_s = np.arange(0, 2.0, 2.0 / N) - 1.0
102rho_s = np.ones(N) * rho0
103P_s = np.ones(N) * rho0
107u0 = rho0 * P0 * (gas_gamma - 1)
108us = 0.5 * (gas_gamma - 1) * v0
112rho_s[np.abs(x_s) < rs] = rho0 * ((gas_gamma + 1) / (gas_gamma - 1)) ** 3
113P_s[np.abs(x_s) < rs] = (
114 0.5 * rho0 * v0**2 * (gas_gamma + 1) ** 3 / (gas_gamma - 1) ** 2
116v_s[np.abs(x_s) < rs] = 0.0
119rho_s[np.abs(x_s) >= rs] = rho0 * (1 + v0 * time / np.abs(x_s[np.abs(x_s) >= rs])) ** 2
120P_s[np.abs(x_s) >= rs] = 0
125u_s = P_s / (rho_s * (gas_gamma - 1.0))
126s_s = P_s / rho_s**gas_gamma
129fig = plt.figure(figsize=(7, 7 / 1.6))
130fig.suptitle(f
"Noh 3D, t={time:.3f}")
134binned_marker_size = 4
139 markeredgecolor=
"none",
146errorbar_props = dict(color=binned_color, ms=binned_marker_size, fmt=
".", lw=1.2)
152plt.subplot(rows, cols, 1)
153plt.plot(r, v, **scatter_props)
154plt.plot(x_s, v_s,
"--", color=line_color, alpha=0.8, lw=1.2)
156 plt.errorbar(r_bin, v_bin, yerr=v_sigma_bin, **errorbar_props)
157plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
158plt.ylabel(
"${\\rm{Velocity}}~v_r$", labelpad=-4)
163plt.subplot(rows, cols, 2)
164plt.plot(r, rho, **scatter_props)
165plt.plot(x_s, rho_s,
"--", color=line_color, alpha=0.8, lw=1.2)
167 plt.errorbar(r_bin, rho_bin, yerr=rho_sigma_bin, **errorbar_props)
168plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
169plt.ylabel(
"${\\rm{Density}}~\\rho$", labelpad=0)
174plt.subplot(rows, cols, 3)
175plt.plot(r, P, **scatter_props)
176plt.plot(x_s, P_s,
"--", color=line_color, alpha=0.8, lw=1.2)
178 plt.errorbar(r_bin, P_bin, yerr=P_sigma_bin, **errorbar_props)
179plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
180plt.ylabel(
"${\\rm{Pressure}}~P$", labelpad=0)
185plt.subplot(rows, cols, 4)
186plt.plot(r, u, **scatter_props)
187plt.plot(x_s, u_s,
"--", color=line_color, alpha=0.8, lw=1.2)
189 plt.errorbar(r_bin, u_bin, yerr=u_sigma_bin, **errorbar_props)
190plt.xlabel(
"${\\rm{Radius}}~r$", labelpad=0)
191plt.ylabel(
"${\\rm{Internal~Energy}}~u$", labelpad=0)
198fname = f
"NohProfile{time:.4f}.png"
199plt.savefig(fname, dpi=200)
Reads in particle fields from a single .vtu file, or all .vtu at a given snapshot time specified in t...