2
$\begingroup$

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? enter image description here

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

$\endgroup$
1
  • $\begingroup$ 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♦ :) $\endgroup$
    – k.dkhk
    Commented May 3, 2021 at 21:45

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
7
  • $\begingroup$ But when I change my step size in time (dt) to compute the errors, do I need to keep step size in space (dx) constant? $\endgroup$
    – k.dkhk
    Commented May 1, 2021 at 21:58
  • $\begingroup$ No, that would make your scheme unstable. $\endgroup$
    – nicoguaro
    Commented May 1, 2021 at 22:04
  • $\begingroup$ And how should I measure the error? Should I take difference between my method and the exact solution at every gridpoint (in time and space) and define the error as the sum of them all? $\endgroup$
    – k.dkhk
    Commented May 2, 2021 at 16:01
  • 1
    $\begingroup$ You could sample your analytical solution and then compute the $L_2$ norm of the difference. $\endgroup$
    – nicoguaro
    Commented May 2, 2021 at 18:25
  • 1
    $\begingroup$ Yes, that's the $L_2$ norm. Feel free to share a link to the plot here or to create a chat room. $\endgroup$
    – nicoguaro
    Commented May 3, 2021 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.