How to demonstrate the order of convergence of FTBS method for solving a hyperbolic PDE

consider the Purely hyperbolic model problem $$u_t+au_x=0$$ $$u(-1,t)=u(1,t) \text{ (periodic boundary)}$$ $$u(x,0)=f(x)$$

with $$f(y)=\sin(2\pi y)$$. Furthermore the exact solution is given by $$u(x,t)=f(x-at)$$. I have implemented Forward–time backward–space (see page 1: http://www.etakl.net/notes_etc/numerical/schemes.pdf ) on a uniform grid in time and space and the figure demonstrates my results with certain values of dt, dx and a.

MY QUIESTION: How can I construct a test/example to demonstrate the order of convergence? In theory the order of convergance should be 1 in time and 1 in space, right? I am using the FDM book by LeVeque and this problem is from chapter 10. I am using Python and I will be happy to share my code if needed. Thanks

• If anyone else ever stumble upon this question, feel free to drop a comment at ask! I did solve it after getting help from nicoguaro♦ :) May 3 '21 at 21:45

You could refine your discretization and then compare the logarithm of the error ($$\log |e|$$) with the logarithm of the size ($$\log h$$) of your elements. Using a linear regression you could obtain an approximation of the order of convergence. Keep in mind that this order of convergence is asymptotic when $$h \rightarrow 0$$, so, for "large" $$h$$ you could see a different behavior.
• You could sample your analytical solution and then compute the $L_2$ norm of the difference. May 2 '21 at 18:25
• Yes, that's the $L_2$ norm. Feel free to share a link to the plot here or to create a chat room. May 3 '21 at 2:28