Skip to content
Snippets Groups Projects
Commit 9f11e0b3 authored by Jan Habscheid's avatar Jan Habscheid
Browse files

Updated L2-error to take the sqrt of int (f_fine - f_h)**2

parent f553c91c
No related branches found
No related tags found
No related merge requests found
Pipeline #1480206 failed
Showing
with 6468 additions and 781 deletions
No preview for this file type
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -58,12 +58,12 @@ p_interp1d = [interp1d(x[i], p[i]) for i in range(len(number_cells_vec))]
# Calculate L2-error
y_A_error_L2, y_C_error_L2, y_S_error_L2, phi_error_L2, p_error_L2 = [], [], [], [], []
for i in range(len(number_cells_vec)-1):
y_A_error_L2.append(np.trapz((y_A_interp1d[i](x[i]) - y_A_interp1d[-1](x[i]))**2, x[i]))
y_C_error_L2.append(np.trapz((y_C_interp1d[i](x[i]) - y_C_interp1d[-1](x[i]))**2, x[i]))
y_S_error_L2.append(np.trapz((y_S_interp1d[i](x[i]) - y_S_interp1d[-1](x[i]))**2, x[i]))
phi_error_L2.append(np.trapz((phi_interp1d[i](x[i]) - phi_interp1d[-1](x[i]))**2, x[i]))
p_error_L2.append(np.trapz((p_interp1d[i](x[i]) - p_interp1d[-1](x[i]))**2, x[i]))
y_A_error_L2.append(np.sqrt(np.trapz((y_A_interp1d[i](x[i]) - y_A_interp1d[-1](x[i]))**2, x[i])))
y_C_error_L2.append(np.sqrt(np.trapz((y_C_interp1d[i](x[i]) - y_C_interp1d[-1](x[i]))**2, x[i])))
y_S_error_L2.append(np.sqrt(np.trapz((y_S_interp1d[i](x[i]) - y_S_interp1d[-1](x[i]))**2, x[i])))
phi_error_L2.append(np.sqrt(np.trapz((phi_interp1d[i](x[i]) - phi_interp1d[-1](x[i]))**2, x[i])))
p_error_L2.append(np.sqrt(np.trapz((p_interp1d[i](x[i]) - p_interp1d[-1](x[i]))**2, x[i])))
# Log-log plot of L2-error
plt.figure()
plt.loglog(number_cells_vec[:-1], y_A_error_L2, 'o-', label='$y_A$')
......
......@@ -21,7 +21,7 @@ del sys.path[0]
import matplotlib.pyplot as plt
import numpy as np
# Define Parameter and buondary conditions
# Define Parameter and boundary conditions
phi_right = 0.0
p_right = 0.0
y_A_R, y_C_R = 1/3, 1/3
......@@ -61,4 +61,4 @@ axs.set_xlabel('$\delta \\varphi$ [-]')
axs.set_ylabel('$y_\\alpha$ [-]')
axs.legend()
fig.tight_layout()
fig.show()
\ No newline at end of file
fig.show()
This diff is collapsed.
This diff is collapsed.
......@@ -26,8 +26,8 @@ p_error_inf = data['p_error_inf']
# Reference order
x_ref = [1e+1, 1e+5]
O1_2_ref = [10e+4, 10e+0]
O2_2_ref = [10e-8, 10e-16]
O3_2_ref = [10e-8, 10e-20]
O2_2_ref = [10e-3, 10e-11]
# O3_2_ref = [10e-8, 10e-20]
O1_inf_ref = [10e+4, 10e+0]
O2_inf_ref = [10e-4, 10e-12]
# O3_inf_ref = [10e-1, 10e-13]
......@@ -46,8 +46,8 @@ axs[0].loglog(number_cells_vec[:-1], y_S_error_L2, 'o-', label='$y_S$', lw=lw, m
axs[0].loglog(number_cells_vec[:-1], phi_error_L2, 'o-', label='$\\varphi$', lw=lw, ms=ms)
axs[0].loglog(number_cells_vec[:-1], p_error_L2, 'o-', label='$p$', lw=lw, ms=ms)
axs[0].loglog(x_ref, O1_2_ref, Ref_Ord_marker[0], color='tab:gray', label='$O(nx)^1$', lw=lw, ms=ms)
# axs[0].loglog(x_ref, O2_2_ref, Ref_Ord_marker[1], color='tab:gray', label='$O(nx)^2$', lw=lw, ms=ms)
axs[0].loglog(x_ref, O3_2_ref, Ref_Ord_marker[2], color='tab:gray', label='$O(nx)^3$', lw=lw, ms=ms)
axs[0].loglog(x_ref, O2_2_ref, Ref_Ord_marker[1], color='tab:gray', label='$O(nx)^2$', lw=lw, ms=ms)
# axs[0].loglog(x_ref, O3_2_ref, Ref_Ord_marker[2], color='tab:gray', label='$O(nx)^3$', lw=lw, ms=ms)
axs[0].set_xlabel('log(nx)', fontsize=labelsize)
axs[0].set_ylabel('log($L_2$)', fontsize=labelsize)
axs[0].grid()
......@@ -66,7 +66,8 @@ axs[1].set_ylabel('log($L_\infty$)', fontsize=labelsize)
axs[1].grid()
axs[1].tick_params(axis='both', labelsize=labelsize)
order = [0, 5, 1, 7, 2, 6, 3, 4]
# order = [0, 5, 1, 7, 2, 6, 3, 4]
order = [0, 5, 1, 6, 2, 3, 4]
lines_labels = [ax.get_legend_handles_labels() for ax in fig.axes]
lines, labels = [sum(lol, []) for lol in zip(*lines_labels)]
lgnd = fig.legend([lines[i] for i in order], [labels[i] for i in order], bbox_to_anchor=(0.81,1.2), ncol=5, fontsize=labelsize)
......
This diff is collapsed.
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment