I am using ContourPlot
to compare the norm of the two vector fields, $||\boldsymbol{f}||/||\boldsymbol{g}||$, which should be contour on $(x,y)$ plane.
Consider the following PDEs about $u(x,y,t)$ and $v(x,y,t)$,
L = 4;
solu = NDSolveValue[{D[u[t, x, y], t, t] ==
D[u[t, x, y], x, x] + D[u[t, x, y], y, y] + Sin[u[t, x, y]],
u[t, -L, y] == u[t, L, y], u[t, x, -L] == u[t, x, L], u[0, x, y] == Exp[-(x^2 + y^2)],
Derivative[1, 0, 0][u][0, x, y] == 0}, u, {t, 0, 4}, {x, -L, L}, {y, -L, L}]
solv = NDSolveValue[{D[v[t, x, y], t, t] ==
D[v[t, x, y], x, x] + D[v[t, x, y], y, y]/2 + (1 - v[t, x, y]^2) (1 + 2 v[t, x, y]),
v[0, x, y] == E^-(x^2 + y^2), v[t, -L, y] == v[t, L, y],
v[t, x, -L] == v[t, x, L], Derivative[1, 0, 0][v][0, x, y] == 0},
v, {t, 0, 4}, {x, -L, L}, {y, -L, L}]
and these two vector fields
f[x_, y_, t_] = solu[t, x, y]*Grad[solv[t, x, y], {x, y}] + Grad[solu[t, x, y], {x, y}];
g[x_, y_, t_] = Grad[solu[t, x, y], {x, y}]*solu[t, x, y];
I can plot the respective contours with
{ContourPlot[Norm[f[x, y, 1]], {x, 0, L}, {y, 0, L}, PlotRange -> All, ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend[Automatic, All], FrameLabel -> {x, y}],
ContourPlot[Norm[g[x, y, 1]], {x, 0, L}, {y, 0, L}, PlotRange -> All, ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend[Automatic, All], FrameLabel -> {x, y}]}
But if I plot their ratio, i.e. the ratio of the norms of the two vector fields, ContourPlot
produces a strange result, which looks not correct.
ContourPlot[Norm[f[x, y, 1]]/Norm[g[x, y, 1]], {x, 0, L}, {y, 0, L}, PlotRange -> All,
ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend[Automatic, All], FrameLabel -> {x,y}]
A quick check:
Norm[f[1.6, 0.5, 1]]/Norm[g[1.6, 0.5, 1]]
(*4.72938*)
This is not consistent with the last contour plot. What am I doing wrong? Thank you in advance.
Log[ Norm[ f[x, y, 1] ] / Norm[ g[x, y, 1] ] ]
and useLog[ Norm[ f[1.6, 0.5, 1] ] / Norm[ g[1.6, 0.5, 1] ] ]
for the sanity check. $\endgroup$