diff --git a/examples/GreshoVortex/gresho.yml b/examples/GreshoVortex/gresho.yml index 9fb6af048e396878446fd9d6308a08ccf300a0d5..066b433a948db232c9665fd7d007753a19e058fa 100644 --- a/examples/GreshoVortex/gresho.yml +++ b/examples/GreshoVortex/gresho.yml @@ -17,7 +17,7 @@ TimeIntegration: Snapshots: basename: gresho # Common part of the name of output files time_first: 0. # Time of the first output (in internal units) - delta_time: 1e-2 # Time difference between consecutive outputs (in internal units) + delta_time: 1e-1 # Time difference between consecutive outputs (in internal units) # Parameters governing the conserved quantities statistics Statistics: diff --git a/examples/GreshoVortex/plotSolution.py b/examples/GreshoVortex/plotSolution.py index db7ccceaaa21daed309654e2c59815b5c141cf15..e9d957d80cff3db61d7095d63b46c122c98526ce 100644 --- a/examples/GreshoVortex/plotSolution.py +++ b/examples/GreshoVortex/plotSolution.py @@ -41,9 +41,9 @@ params = {'axes.labelsize': 10, 'xtick.labelsize': 10, 'ytick.labelsize': 10, 'text.usetex': True, -'figure.figsize' : (6.45,6.45), -'figure.subplot.left' : 0.07, -'figure.subplot.right' : 0.985, + 'figure.figsize' : (9.90,6.45), +'figure.subplot.left' : 0.045, +'figure.subplot.right' : 0.99, 'figure.subplot.bottom' : 0.05, 'figure.subplot.top' : 0.99, 'figure.subplot.wspace' : 0.15, @@ -87,6 +87,9 @@ boxSize = sim["/Header"].attrs["BoxSize"][0] time = sim["/Header"].attrs["Time"][0] scheme = sim["/HydroScheme"].attrs["Scheme"] kernel = sim["/HydroScheme"].attrs["Kernel function"] +neighbours = sim["/HydroScheme"].attrs["Kernel target N_ngb"] +eta = sim["/HydroScheme"].attrs["Kernel eta"] +git = sim["Code"].attrs["Git Revision"] pos = sim["/PartType0/Coordinates"][:,:] x = pos[:,0] - boxSize / 2 @@ -96,60 +99,100 @@ r = sqrt(x**2 + y**2) v_r = (x * vel[:,0] + y * vel[:,1]) / r v_phi = (-y * vel[:,0] + x * vel[:,1]) / r v_norm = sqrt(vel[:,0]**2 + vel[:,1]**2) +rho = sim["/PartType0/Density"][:] u = sim["/PartType0/InternalEnergy"][:] +S = sim["/PartType0/Entropy"][:] +P = sim["/PartType0/Pressure"][:] # Plot the interesting quantities figure() -# Internal energy profile -------------------------------- -subplot(221) -plot(r, u, 'x', color='r') -plot(solution_r, solution_u, '--', color='k', alpha=0.8, lw=1.2) +# Azimuthal velocity profile ----------------------------- +subplot(231) + +plot(r, v_phi, '.', color='r', ms=0.5) +plot(solution_r, solution_v_phi, '--', color='k', alpha=0.8, lw=1.2) plot([0.2, 0.2], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) plot([0.4, 0.4], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) xlabel("${\\rm{Radius}}~r$", labelpad=0) -ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0) -text(0.02, 8.97, "%s"%scheme, fontsize=9, backgroundcolor="w") -text(0.02, 8.82, "%s"%kernel, fontsize=9, backgroundcolor="w") +ylabel("${\\rm{Azimuthal~velocity}}~v_\\phi$", labelpad=0) xlim(0,R_max) -ylim(7.3, 9.1) +ylim(-0.1, 1.2) -# Azimuthal velocity profile ----------------------------- -subplot(222) +# Radial density profile -------------------------------- +subplot(232) -plot(r, v_phi, 'x', color='r') -plot(solution_r, solution_v_phi, '--', color='k', alpha=0.8, lw=1.2) +plot(r, rho, '.', color='r', ms=0.5) +plot(solution_r, solution_rho, '--', color='k', alpha=0.8, lw=1.2) plot([0.2, 0.2], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) plot([0.4, 0.4], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) xlabel("${\\rm{Radius}}~r$", labelpad=0) -ylabel("${\\rm{Azimuthal~velocity}}~v_\\phi$", labelpad=0) +ylabel("${\\rm{Density}}~\\rho$", labelpad=0) xlim(0,R_max) -ylim(-0.1, 1.2) -text(0.75, 1, "$t=%.3f$"%(time), ha="right", va="bottom") +ylim(rho0-0.3, rho0 + 0.3) +#yticks([-0.2, -0.1, 0., 0.1, 0.2]) -# Radial velocity profile -------------------------------- -subplot(223) +# Radial pressure profile -------------------------------- +subplot(233) -plot(r, v_r, 'x', color='r', label="$\\texttt{SWIFT}$") -plot(solution_r, solution_v_r, '--', color='k', alpha=0.8, lw=1.2, label="$\\rm{Solution}$") +plot(r, P, '.', color='r', ms=0.5) +plot(solution_r, solution_P, '--', color='k', alpha=0.8, lw=1.2) plot([0.2, 0.2], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) plot([0.4, 0.4], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) xlabel("${\\rm{Radius}}~r$", labelpad=0) -ylabel("${\\rm{Radial~velocity}}~v_r$", labelpad=-5) -legend(loc="upper right", fontsize=10, frameon=False, numpoints=1, handletextpad=0.1, handlelength=1.2) +ylabel("${\\rm{Pressure}}~P$", labelpad=0) +xlim(0, R_max) +ylim(4.9 + P0, P0 + 6.1) + +# Internal energy profile -------------------------------- +subplot(234) + +plot(r, u, '.', color='r', ms=0.5) +plot(solution_r, solution_u, '--', color='k', alpha=0.8, lw=1.2) +plot([0.2, 0.2], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) +plot([0.4, 0.4], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) +xlabel("${\\rm{Radius}}~r$", labelpad=0) +ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0) xlim(0,R_max) -ylim(-0.2, 0.2) -yticks([-0.2, -0.1, 0., 0.1, 0.2]) +ylim(7.3, 9.1) + + +# Radial entropy profile -------------------------------- +subplot(235) +plot(r, S, '.', color='r', ms=0.5) +plot(solution_r, solution_s, '--', color='k', alpha=0.8, lw=1.2) +plot([0.2, 0.2], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) +plot([0.4, 0.4], [-100, 100], ':', color='k', alpha=0.4, lw=1.2) +xlabel("${\\rm{Radius}}~r$", labelpad=0) +ylabel("${\\rm{Entropy}}~S$", labelpad=0) +xlim(0, R_max) +ylim(4.9 + P0, P0 + 6.1) # Image -------------------------------------------------- -subplot(224) -scatter(pos[:,0], pos[:,1], c=v_norm, cmap="PuBu", edgecolors='face', s=4, vmin=0, vmax=1) -text(0.95, 0.95, "$|v|$", ha="right", va="top") -xlim(0,1) -ylim(0,1) -xlabel("$x$", labelpad=0) -ylabel("$y$", labelpad=0) - -savefig("greshoVortex_%03d.png"%snap) +#subplot(234) +#scatter(pos[:,0], pos[:,1], c=v_norm, cmap="PuBu", edgecolors='face', s=4, vmin=0, vmax=1) +#text(0.95, 0.95, "$|v|$", ha="right", va="top") +#xlim(0,1) +#ylim(0,1) +#xlabel("$x$", labelpad=0) +#ylabel("$y$", labelpad=0) + +# Information ------------------------------------- +subplot(236, frameon=False) + +text(-0.49, 0.9, "Gresho-Chan vortex with $\\gamma=%.3f$ at $t=%.2f$"%(gas_gamma,time), fontsize=10) +text(-0.49, 0.8, "Background $\\rho_0=%.3f$"%rho0, fontsize=10) +text(-0.49, 0.7, "Background $P_0=%.3f$"%P0, fontsize=10) +plot([-0.49, 0.1], [0.62, 0.62], 'k-', lw=1) +text(-0.49, 0.5, "$\\textsc{Swift}$ %s"%git, fontsize=10) +text(-0.49, 0.4, scheme, fontsize=10) +text(-0.49, 0.3, kernel, fontsize=10) +text(-0.49, 0.2, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10) +xlim(-0.5, 0.5) +ylim(0, 1) +xticks([]) +yticks([]) + +savefig("GreshoVortex.png", dpi=200) diff --git a/examples/GreshoVortex/run.sh b/examples/GreshoVortex/run.sh index 9a312d0c161aab07c33c1bb7beb26a205e216a39..69e28350a2cb9e6747eb879288603f968ebf0a40 100755 --- a/examples/GreshoVortex/run.sh +++ b/examples/GreshoVortex/run.sh @@ -16,10 +16,4 @@ fi ../swift -s -t 1 gresho.yml # Plot the solution -for i in {0..100} -do - python plotSolution.py $i -done - -# Make a movie -mencoder mf://*.png -mf w=645:h=645:fps=12:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o gresho.avi +python plotSolution.py 11 diff --git a/examples/SodShock_1D/plotSolution.py b/examples/SodShock_1D/plotSolution.py index 90417148f995658a061fdf1e28d807f36268d894..57f66fe29b9be86a3c4de0d90eafe615d0cb2dbb 100644 --- a/examples/SodShock_1D/plotSolution.py +++ b/examples/SodShock_1D/plotSolution.py @@ -76,6 +76,7 @@ scheme = sim["/HydroScheme"].attrs["Scheme"] kernel = sim["/HydroScheme"].attrs["Kernel function"] neighbours = sim["/HydroScheme"].attrs["Kernel target N_ngb"] eta = sim["/HydroScheme"].attrs["Kernel eta"] +git = sim["Code"].attrs["Git Revision"] x = sim["/PartType0/Coordinates"][:,0] v = sim["/PartType0/Velocities"][:,0] @@ -226,46 +227,46 @@ figure() # Velocity profile -------------------------------- subplot(231) -plot(x, v, '.', color='r') +plot(x, v, '.', color='r', ms=4.0) plot(x_s, v_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$v_x$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Velocity}}~v_x$", labelpad=0) xlim(-0.5, 0.5) ylim(-0.1, 0.95) # Density profile -------------------------------- subplot(232) -plot(x, rho, '.', color='r') +plot(x, rho, '.', color='r', ms=4.0) plot(x_s, rho_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$\\rho$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Density}}~\\rho$", labelpad=0) xlim(-0.5, 0.5) ylim(0.05, 1.1) # Pressure profile -------------------------------- subplot(233) -plot(x, P, '.', color='r') +plot(x, P, '.', color='r', ms=4.0) plot(x_s, P_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$P$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Pressure}}~P$", labelpad=0) xlim(-0.5, 0.5) ylim(0.01, 1.1) # Internal energy profile ------------------------- subplot(234) -plot(x, u, '.', color='r') +plot(x, u, '.', color='r', ms=4.0) plot(x_s, u_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$u$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0) xlim(-0.5, 0.5) ylim(0.8, 2.2) # Entropy profile --------------------------------- subplot(235) -plot(x, S, '.', color='r') +plot(x, S, '.', color='r', ms=4.0) plot(x_s, s_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$S$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Entropy}}~S$", labelpad=0) xlim(-0.5, 0.5) ylim(0.8, 3.8) @@ -276,9 +277,10 @@ text(-0.49, 0.9, "Sod shock with $\\gamma=%.3f$ in 1D at $t=%.2f$"%(gas_gamma,t text(-0.49, 0.8, "Left:~~ $(P_L, \\rho_L, v_L) = (%.3f, %.3f, %.3f)$"%(P_L, rho_L, v_L), fontsize=10) text(-0.49, 0.7, "Right: $(P_R, \\rho_R, v_R) = (%.3f, %.3f, %.3f)$"%(P_R, rho_R, v_R), fontsize=10) plot([-0.49, 0.1], [0.62, 0.62], 'k-', lw=1) -text(-0.49, 0.5, scheme, fontsize=10) -text(-0.49, 0.4, kernel, fontsize=10) -text(-0.49, 0.3, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10) +text(-0.49, 0.5, "$\\textsc{Swift}$ %s"%git, fontsize=10) +text(-0.49, 0.4, scheme, fontsize=10) +text(-0.49, 0.3, kernel, fontsize=10) +text(-0.49, 0.2, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10) xlim(-0.5, 0.5) ylim(0, 1) xticks([]) diff --git a/examples/SodShock_2D/plotSolution.py b/examples/SodShock_2D/plotSolution.py index 753e9295f6828ab0b3f2c4ed787d70f756640f6f..e74651c567bb711b3190662cf78d421a66134775 100644 --- a/examples/SodShock_2D/plotSolution.py +++ b/examples/SodShock_2D/plotSolution.py @@ -76,6 +76,7 @@ scheme = sim["/HydroScheme"].attrs["Scheme"] kernel = sim["/HydroScheme"].attrs["Kernel function"] neighbours = sim["/HydroScheme"].attrs["Kernel target N_ngb"] eta = sim["/HydroScheme"].attrs["Kernel eta"] +git = sim["Code"].attrs["Git Revision"] x = sim["/PartType0/Coordinates"][:,0] v = sim["/PartType0/Velocities"][:,0] @@ -226,46 +227,46 @@ figure() # Velocity profile -------------------------------- subplot(231) -plot(x, v, '.', color='r') +plot(x, v, '.', color='r', ms=0.5) plot(x_s, v_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$v_x$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Velocity}}~v_x$", labelpad=0) xlim(-0.5, 0.5) ylim(-0.1, 0.95) # Density profile -------------------------------- subplot(232) -plot(x, rho, '.', color='r') +plot(x, rho, '.', color='r', ms=0.5) plot(x_s, rho_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$\\rho$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Density}}~\\rho$", labelpad=0) xlim(-0.5, 0.5) ylim(0.05, 1.1) # Pressure profile -------------------------------- subplot(233) -plot(x, P, '.', color='r') +plot(x, P, '.', color='r', ms=0.5) plot(x_s, P_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$P$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Pressure}}~P$", labelpad=0) xlim(-0.5, 0.5) ylim(0.01, 1.1) # Internal energy profile ------------------------- subplot(234) -plot(x, u, '.', color='r') +plot(x, u, '.', color='r', ms=0.5) plot(x_s, u_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$u$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0) xlim(-0.5, 0.5) ylim(0.8, 2.2) # Entropy profile --------------------------------- subplot(235) -plot(x, S, '.', color='r') +plot(x, S, '.', color='r', ms=0.5) plot(x_s, s_s, '--', color='k', alpha=0.8, lw=1.2) -xlabel("$x$", labelpad=0) -ylabel("$S$", labelpad=0) +xlabel("${\\rm{Position}}~x$", labelpad=0) +ylabel("${\\rm{Entropy}}~S$", labelpad=0) xlim(-0.5, 0.5) ylim(0.8, 3.8) @@ -276,9 +277,10 @@ text(-0.49, 0.9, "Sod shock with $\\gamma=%.3f$ in 2D at $t=%.2f$"%(gas_gamma,t text(-0.49, 0.8, "Left:~~ $(P_L, \\rho_L, v_L) = (%.3f, %.3f, %.3f)$"%(P_L, rho_L, v_L), fontsize=10) text(-0.49, 0.7, "Right: $(P_R, \\rho_R, v_R) = (%.3f, %.3f, %.3f)$"%(P_R, rho_R, v_R), fontsize=10) plot([-0.49, 0.1], [0.62, 0.62], 'k-', lw=1) -text(-0.49, 0.5, scheme, fontsize=10) -text(-0.49, 0.4, kernel, fontsize=10) -text(-0.49, 0.3, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10) +text(-0.49, 0.5, "$\\textsc{Swift}$ %s"%git, fontsize=10) +text(-0.49, 0.4, scheme, fontsize=10) +text(-0.49, 0.3, kernel, fontsize=10) +text(-0.49, 0.2, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10) xlim(-0.5, 0.5) ylim(0, 1) xticks([])