7
$\begingroup$

I know the method of constructing solutions. For example I have a BVP:

$$ u_{xx} + u = 0 $$ subjected to: $$ u_{x}(0) = f_1, $$ $$ u_{x}(1) = f_2 $$

If I want to check the correctness of my numerical implementation, just plug in $u(x) = \sin(x)$ and then $f_1 = \cos(0), f_2 = \cos(1)$ and then run the script for implementation. If the graphs of the numerical solution and that of $u(x) = \sin(x)$ approximately matches then I have the correct implementation.

This may present some problems when constructing solutions with not-so-simple differential equations. Currently I am having trouble finding one for: $u_t = ku_{xx}$.

Are there any other methods or is there a simple function for this one?

$\endgroup$
13
$\begingroup$

The Method of Manufactured Solutions (PDF link) goes more as less as follows. You pick a solution that excites enough modes of your operator and satisfies the boundary and initial conditions, and you then turn the crank to get a right-hand-side function that you can implement. Though, just bare sines and cosines are a poor choice since they might be eigenfunctions of your operator and lead to a solution that has false accuracy. A product of transcendental functions is usually used.

After you have implemented that RHS function, you should generate a range of numerical solutions on a sequence of successively finer meshes. Then you should compute the difference between your computed values to the exact value on each mesh in some norm or other metric. The choice of that norm should be based on the convergence theory that you have for your numerical method. At that point, the goal is to check to see if your method achieves the order of accuracy that the theory predicts. This is typically $O(h^{(p+k)})$ where $h$ is the mesh size, $p$ is the order of the method, and $k$ is dependent on the norm you chose.

If, for small enough $h$, your method behaves like the theory predicts, then you've made one measure of the accuracy/correctness of your implementation.

$\endgroup$
  • $\begingroup$ To be clear: The method of manufactured solutions only works for $u_t - k u_{xx} = f$, where $f$ is not fixed a priori and may depend on $k$ (and, of course, your chosen exact solution $\bar u$). $\endgroup$ – Christian Clason Oct 6 '14 at 15:46
  • $\begingroup$ Thanks for responding. What I have understood is that I should be implementing rather: $u_{t} - ku_{xx} = f$ subjected to: $u(x,0) = g_1, u_{x}(0,t) = g_2, u_x(1,t) = g_3 $. Now a choice of $u(x,t) = 1+x^2t^2 + xt$ gives $f = 2ktx^2 + x-2t^2, g_1 = 1, g_2 = 0, g_3 = 2t^2 + t$ and if now my $ norm(u_{app} - u_{ex}) \le epsilon $ at each iteration then I am good. Matched graphs are another indicator of the same conclusion. Correct? $\endgroup$ – Sohail Oct 6 '14 at 15:48
  • 2
    $\begingroup$ @Sohail: Graphing using your eye to compare is a decent first indicator, but you really need to a sequence of refined meshes and check the order of convergence. You have the right idea with the method, but you should pick a combination of transcendental functions to get the best information out of the method. $\endgroup$ – Bill Barth Oct 6 '14 at 17:09
  • 2
    $\begingroup$ @BillBarth I wasn't knocking it, just trying to point out to Sohail that he can apply it in his case as long as he allows for a right-hand side that may depend on $k$ (because he seemed to think the method could not be applied for his example). $\endgroup$ – Christian Clason Oct 6 '14 at 17:30
  • 2
    $\begingroup$ This is the canonical reference (PDF): infoserve.sandia.gov/sand_doc/2000/001444.pdf $\endgroup$ – Bill Barth Oct 6 '14 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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