# How to choose a simple manufactured solution for Euler equation?

In order to verify a two-phase subsonic compressible isothermal Euler code, I am trying to implement a manufactured solution following what is discussed here and references therein. Also, as an extension of the question already answered here, I am looking for a more detailed explanation on the choice of a manufactured solution for a specific case and especially on the choice of the related parameters.

For instance, in this paper, the authors suggest for the density a manufactured solution of the form (in 2D): $$\rho(x,y)=\rho_0 + \rho_x \sin \left( \frac{a_{\rho x}\pi x}{L} \right) + \rho_y \cos \left( \frac{a_{\rho y}\pi y}{L} \right) + \rho_{xy} \cos \left( \frac{a_{\rho xy}\pi xy}{L^2} \right)$$ where $\rho_0,\rho_x,\rho_y,\rho_{xy},a_{\rho x},a_{\rho y},a_{\rho x y}$ are given just like that without any explanation.

I find this expression really complicated and my question is why the authors have chosen such a complicated function ? I know that trigonometric functions are good candidate because $C^\infty$ but still why the proposed manufactured solution is such a complex combination of such functions ? Why a simple cosinus cannot be enough ? And above all, how do they choose the value for the seven parameters written above ? What make you choose between setting $\rho_{xy}$ to 2 and 500 for instance ?

• I would guess that they use this form in order to enforce periodicity in all directions. Remember, manufactured solutions must satisfy all governing equations including continuity. I assume you can pick their relative amplitudes however you would like, so long as they satisfy your Mach number assumption. Aug 15 '16 at 23:04

With manufactured solutions, you pick the form of the solutions you want, crank them through the governing equations, and generate right-hand side functions that you can go implement to drive the solution to the solution you manufactured. Some solutions are chosen to satisfy other properties that you want. Spencer's comment suggests that boundary conditions are one set of properties you might desire to also include in your manufactured solution. Periodicity is another one. Also, you need to pick solutions that are smooth enough to have enough derivatives to pass neatly through your operator. There are numerous other conditions you might want to impose on your solution, so the reasons for choices may not ever be guessable from the outside. This paper does not give the authors' reasons for selecting this particular form.

Transcendental functions are often used since they may excite multiple modes of the operator simultaneously. A sum or product of them is an easy way to combine such functions into something that explores a multi-dimensional space effectively.

• So I guess a "too simple" manufactured solution wouldn't be enough to test the "range of application" of my operator. What are the parameters for ? I think it is a way to give a weighting in specific direction for instance or to emphasize a special effect... Aug 16 '16 at 7:45
• It's not recommended if you want to demonstrate the convergence rate of your method (which is its primary use). The parameters are there to allow you to adjust the effect of any of the terms. Aug 16 '16 at 13:22
• Ok but assuming a set of parameters and functions that solves Euler equations with IC and BC, how do you know whether or not your manufactured solution will be a correct one to accurately test your operator for the conditions your mentioned above (BC, periodicity, spatiality...) before performing the convergence order test ? Aug 16 '16 at 14:12
• @Coriolis, you don't know until you try it, which is why transcendental functions are recommended. That should be enough to push your mesh hard enough that representing your function on the mesh shows convergence. If your method goes from RHS to solution appropriately, then you're really only measuring the convergence properties of the selected solution on your mesh, thus the preference for "hard" chosen solutions. Aug 16 '16 at 15:54
• Ok and finally, can I use MMS for testing time convergence ? I mean, do I need to manufacture a solution that varies only in time (resp. space) for time (resp. space) convergence or do I need to keep both space and time in my MS ? Aug 17 '16 at 10:11

Augmenting what Bill Barth already said:

1/ You don't want to use polynomials because many methods (such as finite element methods) are exact for at least lower order polynomials.

2/ You want to choose the solution to be analytic or at least $C^\infty$ so that the solution can be well approximated.

These two requirements naturally lead to trig functions.

For the coefficients: 3/ You want to choose $a_{\rho x}$ large enough so that you get more than, say, half of an oscillation into your domain width.

4/ But you want to choose $a_{\rho x}$ small enough so that you have a chance of resolving the solution with your mesh. For example, even on the coarsest mesh, you probably want at least 2 mesh sizes per period of the (co)sine, and then go to more and more elements per period as you refine the mesh.

These last two points lead to pretty obvious choices for the frequency of the (co)sines.

As for the fore-factors: they typically do not matter. At least for linear problems, they just scale right through (if you choose the solution twice as large, the error will also be twice as large). For nonlinear problems, however, you will want to choose these factors so that the nonlinearity is there and important, but not overwhelming your algorithm.

• Your answer is very helpful. About your last sentence however : as far as I understand, the fore-factors are just here to act on the amplitude of the trig function, so I don't get your explanation about non-linearity... Aug 18 '16 at 20:19
• @Coriolis if the problem is linear then scaling the solution by a constant just factors out and has no effect on the numerics. If nonlinear terms are important then this isn't necessarily the case. Aug 21 '16 at 14:26