Consider Laplace's eqn in the unit disk, r^2 D[u[r, t], {r, 2}] + r D[u[r, t], {r, 1}] + D[u[r, t], {t, 2}] == 0
. The general analytic solution is easy to work out, and we can target the n=1
solution (i.e. u = r Cos[t]
) using Dirichlet boundary conditions. The problem is easily solved with the finite element method:
uf1 = NDSolveValue[{r^2 D[u[r, t], {r, 2}] + r D[u[r, t], {r, 1}] +
D[u[r, t], {t, 2}] == 0,
DirichletCondition[u[r, t] == Cos[t], r == 1 && t != 2 Pi],
PeriodicBoundaryCondition[u[r, t], t == 2 \[Pi],
Function[x, x - {0, 2 \[Pi]}]]}, u, {r, 0, 1}, {t, 0, 2 Pi}];
Now let's try an alternative way to solve the same problem, using a first order PDE, D[u[r, t], r] == -I/r D[u[r, t], t]
, for a complex scalar field u. By separating u
into its real and imaginary components, one can show that each satisfy the above Laplace's equation. We attempt to solve the PDE numerically, matching the Dirichlet condition above (for the real part):
uf2 = NDSolveValue[{D[u[r, t], r] == -I/r D[u[r, t], t],
DirichletCondition[u[r, t] == Exp[I t], r == 1 && t != 2 Pi],
PeriodicBoundaryCondition[u[r, t], t == 2 \[Pi],
Function[x, x - {0, 2 \[Pi]}]]}, u, {r, 0, 1}, {t, 0, 2 Pi}];
First things look OK: both solutions seem to approximate the exact target solution:
uA[r_, t_] = r Cos[t];
{Plot3D[Re[uf1[r, t]] - uA[r, t], {r, 0, 1}, {t, 0, 2 Pi}], Plot3D[Re[uf2[r, t]] - uA[r, t], {r, 0, 1}, {t, 0, 2 Pi}]}
but the conventional method is much better.
The question is: why does the 1st order method perform so poorly compared with the conventional (2nd order) method?
For the first order problem, Mathematica issues the usual warning about the equation being convection dominated, but can't we ignore this because we know the solutions are nice and smooth? (Btw, artificial diffusion doesn't help.) Is there an issue with applying FEM to first order PDEs, even if they are known to be elliptic?
A scan over MaxCellMeasure
shows how serious the problem is:
errList1 = {}; errList2 = {};
For[n = 3, n <= 10, n++,
mcm = 1./2^n;
mesh = ToElementMesh[FullRegion[2], {{0, 1}, {0, 2 Pi}},
MaxCellMeasure -> mcm];
Quiet[
uf1 = NDSolveValue[{r^2 D[u[r, t], {r, 2}] + r D[u[r, t], {r, 1}] +
D[u[r, t], {t, 2}] == 0,
DirichletCondition[u[r, t] == Cos[t], r == 1 && t != 2 Pi],
PeriodicBoundaryCondition[u[r, t], t == 2 \[Pi],
Function[x, x - {0, 2 \[Pi]}]]}, u, {r, t} \[Element] mesh];
uf2 = NDSolveValue[{D[u[r, t], r] == -I/r D[u[r, t], t],
DirichletCondition[u[r, t] == Exp[I t], r == 1 && t != 2 Pi],
PeriodicBoundaryCondition[u[r, t], t == 2 \[Pi],
Function[x, x - {0, 2 \[Pi]}]]}, u, {r, t} \[Element] mesh];
];
err1 = Sqrt[
Mean[Table[{ri, ti} = c; (Re[uf1[ri, ti]] - uA[ri, ti])^2, {c,
mesh["Coordinates"]}]]];
err2 = Sqrt[
Mean[Table[{ri, ti} = c; (Re[uf2[ri, ti]] - uA[ri, ti])^2, {c,
mesh["Coordinates"]}]]];
AppendTo[errList1, {mcm, err1}];
AppendTo[errList2, {mcm, err2}];
];
ListLogLogPlot[{errList2, errList1}]
Although the error of the first solution goes clearly as mcm^2
, the error of the second solution does not even convincingly go to zero with mcm
.
A final motivating comment: Although the above problem is easily evaded (though not understood) by using the usual second order formulation, one may be faced with a first order PDE that cannot be easily transformed into the standard 2nd order form. It would be useful to know how reliably solve an elliptic first order system.