Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
lroberts36 committed Sep 25, 2024
1 parent d554036 commit 1632222
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions example/poisson_gmg/plot_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,48 @@
plt.style.use("tableau-colorblind10")

solver = "BiCGSTAB"
solver_lbl = "BCGS"
difco = 1e6
refine = True

for bound_pro in ["Constant", "Linear"]:
for interior_pro in ["Constant", "OldLinear"]:

p = subprocess.run(
[
"./poisson-gmg-example",
"-i",
"parthinput.poisson",
"poisson/solver=" + solver,
"poisson/interior_D=" + str(difco),
"poisson/prolongation=" + bound_pro,
"poisson/solver_params/prolongation=" + interior_pro,
],
capture_output=True,
text=True,
)
dat = np.genfromtxt(p.stdout.splitlines())
for interior_pro in ["Constant", "Linear", "SplitLin", "Kwak"]:
command = ["./poisson-gmg-example", "-i", "parthinput.poisson"]
command.append("poisson/solver=" + solver)
command.append("poisson/interior_D=" + str(difco))
command.append("poisson/boundary_prolongation=" + bound_pro)
if interior_pro == "SplitLin":
command.append("poisson/solver_params/prolongation=Default")
else:
command.append("poisson/interior_prolongation=" + interior_pro)
command.append("poisson/solver_params/prolongation=User")

if refine:
command.append("parthenon/static_refinement0/x1min=-1.0")
command.append("parthenon/static_refinement0/x1max=-0.75")
command.append("parthenon/static_refinement0/x2min=-1.0")
command.append("parthenon/static_refinement0/x2max=-0.75")
command.append("parthenon/static_refinement0/level=3")

p = subprocess.run(command, capture_output=True, text=True)
lines = p.stdout.splitlines()
# Ignore any initialization junk that gets spit out earlier from adding parameters
idx = lines.index("# [0] v-cycle")
dat = np.genfromtxt(lines[idx:])
label = "{}_{}".format(solver_lbl, interior_pro)
if refine:
label = "{}_{}_Bnd{}".format(solver_lbl, interior_pro, bound_pro)
plt.semilogy(
dat[:, 0],
dat[:, 1],
label=solver + "_" + str(difco) + "_" + bound_pro + "_" + interior_pro,
label=label.replace("Constant", "Const").replace("Linear", "Lin"),
)


plt.legend(loc="upper right")
plt.ylim([1.0e-14, 1e2])
plt.legend()
plt.ylim([1.0e-14, 1e4])
plt.xlim([0, 40])
plt.xlabel("# of V-cycles")
plt.ylabel("RMS Residual")
plt.title("$D_{int} = 10^6$ w/ Refinement")
plt.savefig("convergence_1e6.pdf")

0 comments on commit 1632222

Please sign in to comment.