# 1D Euler Equations

Is it possible to accurately solve the 1D Euler equations in Mathematica using NDSolve?

For example, let us consider the problem given here: http://www.csun.edu/~jb715473/examples/euler1d.htm

Using the notation $(r,v,e)$ for $(\rho,v,E)$ we can formulate the problem in Mathematica as:

eqs = {
D[r[x, t], t] + D[r[x, t] v[x, t], x] == 0,
D[r[x, t] v[x, t], t] + D[r[x, t] v[x, t]^2 + p[x, t], x] == 0,
D[e[x, t], t] + D[v[x, t] (e[x, t] + p[x, t]), x] == 0
};


with $g:=\gamma$,

p[x_, t_] := (g - 1) (e[x, t] - r[x, t] v[x, t]^2/2);


and initial conditions

r0[x_] := 1.0 Boole[0 < x <= 0.5] + 0.25 Boole[0.5 < x <= 1.0];
v0[x_] := 0.0;
p0[x_] := 1.0 Boole[0 < x <= 0.5] + 0.1 Boole[0.5 < x <= 1.0];


Setting Dirichlet boundary conditions and throwing it into NDSolve:

ppR = 401;
ndsol = NDSolve[Join[eqs, {
r[x, 0] == r0[x], r[0, t] == r0[0], r[1, t] == r0[1],
v[x, 0] == v0[x], v[0, t] == v0[0], v[1, t] == v0[1],
p[x, 0] == p0[x], p[0, t] == p0[0], p[1, t] == p0[1]}],
{r, v, e}, {x, 0, 1}, {t, 0, 0.1},
MaxSteps -> 10^3, PrecisionGoal -> 4, AccuracyGoal -> 4,
Method -> {"MethodOfLines", "Method" -> "StiffnessSwitching",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> Pseudospectral, "MaxPoints" -> {ppR},
"MinPoints" -> {ppR}}}]


Taking the solution and plotting

DensityPlot[Evaluate[First[v[x, t] /. ndsol]], {x, 0, 1}, {t, 0, 0.1}, ColorFunction -> Hue]


We see some nasty numerical errors. Is there anyway to get an accurate solution using NDSolve?

Edit: This paper suggests that the Method of Lines should apply: http://math.lanl.gov/~mac/papers/numerics/H79.pdf

-
Your link isn't working here – Dr. belisarius Oct 8 '12 at 22:24
Strange... Is it something I did wrong? – Dale Roberts Oct 8 '12 at 22:31
perhaps this answer helps? but blind experimentation is not very satisfactory – acl Oct 8 '12 at 22:55
I hammered on this for a while, and got nowhere. BTW, I think in the r0[x_]:= its 0.125 (least of your worries) If you go through and make everything a fraction e.g. 1.4 -> 14/10 then it doesn't even crank, crashing out with a 1/0 ComplexInfinity error... – Eric Brown Oct 9 '12 at 1:00
Both links work fine for me. Perhaps the server was down for maintenance. – stevenvh Oct 9 '12 at 7:29