def compute4web(I, a, T, dt, theta=0.5): """ Run a case with the solver, compute error measure, and plot the numerical and exact solutions in a PNG plot whose data are embedded in an HTML image tag. """ u, t = solver(I, a, T, dt, theta) u_e = u_exact(t, I, a) e = u_e - u E = np.sqrt(dt * np.sum(e**2)) plt.figure() t_e = np.linspace(0, T, 1001) # fine mesh for u_e u_e = u_exact(t_e, I, a) plt.plot(t, u, 'r--o') plt.plot(t_e, u_e, 'b-') plt.legend(['numerical', 'exact']) plt.xlabel('t') plt.ylabel('u') plt.title('theta=%g, dt=%g' % (theta, dt)) # Save plot to HTML img tag with PNG code as embedded data from parampool.utils import save_png_to_str html_text = save_png_to_str(plt, plotwidth=400) return E, html_text
def compute4web(I, a, T, dt, theta=0.5): """ Run a case with the solver, compute error measure, and plot the numerical and exact solutions in a PNG plot whose data are embedded in an HTML image tag. """ u, t = solver(I, a, T, dt, theta) u_e = u_exact(t, I, a) e = u_e - u E = np.sqrt(dt * np.sum(e ** 2)) plt.figure() t_e = np.linspace(0, T, 1001) # fine mesh for u_e u_e = u_exact(t_e, I, a) plt.plot(t, u, "r--o") plt.plot(t_e, u_e, "b-") plt.legend(["numerical", "exact"]) plt.xlabel("t") plt.ylabel("u") plt.title("theta=%g, dt=%g" % (theta, dt)) # Save plot to HTML img tag with PNG code as embedded data from parampool.utils import save_png_to_str html_text = save_png_to_str(plt, plotwidth=400) return E, html_text
def compute4web(I, a, T, dt, theta=0.5): """ Run a case with the solver, compute error measure, and plot the numerical and exact solutions in a PNG plot whose data are embedded in an HTML image tag. """ u, t = solver(I, a, T, dt, theta) u_e = exact_solution(t, I, a) e = u_e - u E = np.sqrt(dt*np.sum(e**2)) plt.figure() t_e = np.linspace(0, T, 1001) # fine mesh for u_e u_e = exact_solution(t_e, I, a) plt.plot(t, u, 'r--o') # red dashes w/circles plt.plot(t_e, u_e, 'b-') # blue line for exact sol. plt.legend(['numerical', 'exact']) plt.xlabel('t') plt.ylabel('u') plt.title('theta=%g, dt=%g' % (theta, dt)) # Save plot to HTML img tag with PNG code as embedded data from parampool.utils import save_png_to_str html_text = save_png_to_str(plt, plotwidth=400) return E, html_text
def explore(I, a, T, dt, theta=0.5, makeplot=True): """ Run a case with the solver, compute error measure, and plot the numerical and exact solutions (if makeplot=True). """ u, t = solver(I, a, T, dt, theta) # Numerical solution u_e = exact_solution(t, I, a) e = u_e - u E = sqrt(dt * sum(e**2)) if makeplot: plt.figure() # create new plot t_e = linspace(0, T, 1001) # fine mesh for u_e u_e = exact_solution(t_e, I, a) plt.plot(t, u, 'r--o') # red dashes w/circles plt.plot(t_e, u_e, 'b-') # blue line for exact sol. plt.legend(['numerical', 'exact']) plt.xlabel('t') plt.ylabel('u') plt.title('theta=%g, dt=%g' % (theta, dt)) from parampool.utils import save_png_to_str html_text = save_png_to_str(plt, plotwidth=400) return E, html_text
def explore(I, a, T, dt, theta=0.5, makeplot=True): """ Run a case with the solver, compute error measure, and plot the numerical and exact solutions (if makeplot=True). """ u, t = solver(I, a, T, dt, theta) # Numerical solution u_e = exact_solution(t, I, a) e = u_e - u E = sqrt(dt*sum(e**2)) if makeplot: plt.figure() # create new plot t_e = linspace(0, T, 1001) # fine mesh for u_e u_e = exact_solution(t_e, I, a) plt.plot(t, u, 'r--o') # red dashes w/circles plt.plot(t_e, u_e, 'b-') # blue line for exact sol. plt.legend(['numerical', 'exact']) plt.xlabel('t') plt.ylabel('u') plt.title('theta=%g, dt=%g' % (theta, dt)) from parampool.utils import save_png_to_str html_text = save_png_to_str(plt, plotwidth=400) return E, html_text