9from matplotlib
import pyplot
as plt
33 time = float(sys.argv[1])
36pvdfile =
"particles.pvd"
38partData = reader.load()
40time = reader.get_snapshot_time()
61solver = sphtools.RiemannSolver(gas_gamma)
63delta_x = (x_max - x_min) / N
64center = (x_max + x_min) / 2
65x_s = np.arange(x_min - center, x_max - center, delta_x)
66rho_s, v_s, P_s, _ = solver.solve(rho_L, v_L, P_L, rho_R, v_R, P_R, x_s / time)
70u_s = P_s / (rho_s * (gas_gamma - 1.0))
71s_s = P_s / rho_s**gas_gamma
74c_R = np.sqrt(gas_gamma * P_R / rho_R)
75x_shock = (c_R + v_R) * time
78plt.figure(figsize=(7, 7 / 1.6))
84plt.subplot(rows, cols, 1)
85plt.plot(x, v,
".", color=
"r", ms=4.0)
86plt.plot(x_s, v_s,
"--", color=
"k", alpha=0.8, lw=1.2)
87plt.xlabel(
"${\\rm{Position}}~x$", labelpad=0)
88plt.ylabel(
"${\\rm{Velocity}}~v_x$", labelpad=0)
93plt.subplot(rows, cols, 2)
94plt.plot(x, rho,
".", color=
"r", ms=4.0)
95plt.plot(x_s, rho_s,
"--", color=
"k", alpha=0.8, lw=1.2)
96plt.ylabel(
"${\\rm{Density}}~\\rho$", labelpad=0)
99plt.xlabel(
"${\\rm{Position}}~x$", labelpad=0)
103plt.subplot(rows, cols, 3)
104plt.plot(x, P,
".", color=
"r", ms=4.0)
105plt.plot(x_s, P_s,
"--", color=
"k", alpha=0.8, lw=1.2)
106plt.xlabel(
"${\\rm{Position}}~x$", labelpad=0)
107plt.ylabel(
"${\\rm{Pressure}}~P$", labelpad=0)
112plt.subplot(rows, cols, 4)
113plt.plot(x, u,
".", color=
"r", ms=4.0)
114plt.plot(x_s, u_s,
"--", color=
"k", alpha=0.8, lw=1.2)
115plt.xlabel(
"${\\rm{Position}}~x$", labelpad=0)
116plt.ylabel(
"${\\rm{Internal~Energy}}~u$", labelpad=0)
122plt.savefig(
"SodShock{0:.5f}.png".format(time), dpi=200)
Reads in particle fields from a single .vtu file, or all .vtu at a given snapshot time specified in t...