def plot_decay_majorant_v_of_deg(h, maj, deg, result_path): plt.figure() plt.hold(True) plt.loglog(h, maj, 'b-*') plotslopes.slope_marker((h[1], maj[1]), (1 + deg, 1)) plt.legend(["M^2"], "lower right") plt.xlabel("h") plt.ylabel("M^2 P%d" % (deg)) plt.grid(True) fig = plt.gcf() fig.savefig(result_path + ".eps")
def plot_convergence_rates(): r2, E2, dt2 = convergence_rates(m=5, solver_function=solver, num_periods=8) plt.loglog(dt2, E2) r4, E4, dt4 = convergence_rates(m=5, solver_function=solver_adjust_w, num_periods=8) plt.loglog(dt4, E4) plt.legend(['original scheme', r'adjusted $\omega$'], loc='upper left') plt.title('Convergence of finite difference methods') from plotslopes import slope_marker slope_marker((dt2[1], E2[1]), (2, 1)) slope_marker((dt4[1], E4[1]), (4, 1)) plt.savefig('tmp_convrate.png') plt.savefig('tmp_convrate.pdf') plt.show()
def plot_decay_error_majorant(deg, h, error, majorant, result_path): # Plot error and majorant results for deg = 2 plt.figure() plt.hold(True) plt.loglog(h, majorant, 'k-^') plt.loglog(h, error, 'k-s') if deg == 1: plotslopes.slope_marker((h[1], error[1]), (2, 1)) elif deg == 2: plotslopes.slope_marker((h[1], error[1]), (3, 1)) plt.legend(["M^2", "|| e ||^2"], "lower right") plt.xlabel("h") plt.ylabel("|| e ||^2, M^2") plt.grid(True) fig = plt.gcf() fig.savefig(result_path + ".eps")