I am attempting to solve the nonlinear Richards equation for the dependent variable $\Psi(t,x,y)$. The equation is as follows:
$\frac{\partial\theta(\Psi)}{\partial t}=\nabla. (k(\Psi)\nabla(\Psi + y) )$
where $\theta(\Psi)$ is a function representing the soil water content and $k(\Psi)$ is the hydraulic conductivity of the medium. Both are defined by the equations:
I am using Mathematica 14 for this task, and the code snippet below is what I have written to tackle the equation:
subst = {n -> 2.9, \[Theta]s -> 0.42, \[Theta]r -> 0.026, \[Alpha] ->
0.95, ks -> 0.12};
\[Theta][\[CapitalPsi]_] :=
If[\[CapitalPsi] <=
0, \[Theta]r + (\[Theta]s - \[Theta]r) (1/(1 + (-\[Alpha] \
\[CapitalPsi])^n))^((n - 1)/n), \[Theta]s] /. subst;
k[\[CapitalPsi]_] :=
If[\[CapitalPsi] <= 0,
ks \[Theta][\[CapitalPsi]]^(1/
2) (1 - ((1 - \[Theta][\[CapitalPsi]]^(n - 1)/n))^(n - 1)/
n)^2, ks] /. subst;
LogLinearPlot[\[Theta][-\[CapitalPsi]], {\[CapitalPsi], 0.1, 30000},
PlotRange -> All]
LogLinearPlot[k[-\[CapitalPsi]], {\[CapitalPsi], 0, 30},
PlotRange -> All]
<< NDSolve`FEM`
Clear[x, t]
m = ToElementMesh[FullRegion[2], {{0, 10}, {0, 10}},
MaxCellMeasure -> 0.1, "MeshOrder" -> 2]
m["Wireframe"]
op = (D[\[Theta][u[t, x, y]], t] -
Div[k[u[t, x, y]] Grad[u[t, x, y], {x, y}], {x,
y}]) - (NeumannValue[-10., y == 10 && x <= 2] +
NeumannValue[10., x == 10 && y <= 2]);
ic = u[0, x, y] == 0
sol = NDSolveValue[{op == 0, ic}, u, {x, y} \[Element] m, {t, 0, 3}];
However, Mathematica returns an error message:
CoefficientArrays::ivar
Reference paper:
https://link.springer.com/article/10.1007/s10596-016-9566-3
EDIT
@user21 and @Alex Trounev thank you both for your insights and guidance. Following your suggestions, I have solved the problem with Neumann boundary conditions:
subst = {n -> 2.06, \[Theta]s -> 0.396, \[Theta]r -> 0.131, \[Alpha] ->
0.423, ks -> 4.96 10^-2};
\[Theta][\[CapitalPsi]_] =
If[\[CapitalPsi] <=
0, \[Theta]r + (\[Theta]s - \[Theta]r) (1/(1 + (-\[Alpha] \
\[CapitalPsi])^n))^((n - 1)/n), \[Theta]s] /. subst;
k[\[CapitalPsi]_] =
If[\[CapitalPsi] <= 0,
ks \[Theta][\[CapitalPsi]]^(1/
2) (1 - ((1 - \[Theta][\[CapitalPsi]]^(n - 1)/n))^(n - 1)/
n)^2, ks] /. subst;
<< NDSolve`FEM`
m = ToElementMesh[FullRegion[2], {{0, 2}, {0, 3}},
MaxCellMeasure -> 0.25, "MeshOrder" -> 2];
coeff = (D[\[Theta][\[CapitalPsi][t, x, y]], t] /.
Derivative[1, 0, 0][\[CapitalPsi]][t, x, y] -> 1);
op = coeff*D[\[CapitalPsi][t, x, y], t] +
Inactive[
Div][-k[\[CapitalPsi][t, x,
y]] . (Inactive[Grad][(\[CapitalPsi][t, x, y]), {x, y}] +
Inactive[Grad][y, {x, y}]), {x, y}];
T = 3/16.;
steps = 100;
\[CapitalDelta]t = T/steps;
\[CapitalDelta]td = T/3;
(*Solving with a flux boundary condition and a continuous negative \
pressure in all the domain*)
sol = Monitor[
NDSolveValue[{op ==
NeumannValue[-1, y == 3 && 0 <= x <= 1], \[CapitalPsi][0, x,
y] == -1}, \[CapitalPsi], {x, y} \[Element] m, {t, 0,
T, \[CapitalDelta]t}, Method -> Automatic,
EvaluationMonitor :> (monitor = Row[{"t = ", CForm[t]}])], monitor]
vecplot2[t_] := Block[{vfield, vecplot, streamplot, cplot},
vfield = {Evaluate[D[(sol[t, x, y]), x]],
Evaluate[D[(sol[t, x, y]), y]]};
streamplot =
StreamPlot[{vfield}, {x, y} \[Element] m, StreamPoints -> Fine];
(*vecplot=VectorPlot[{vfield},{x,y}\[Element]m];*);
streamplot
]
n = 10
delta = T/n
tab = Table[vecplot2[i T], {i, 0.001, T, delta}]
However, I'm facing a difficulties with Dirichlet boundary conditions, especially when trying to implement the initial condition for Psi[0, x, y] = 1 - y, as outlined in the paper.
How can I apply the initial condition Psi[0, x, y] = 1 - y ?
Here is the code I can't make it work (The same problem of example 2 of the paper):
ic1 = \[CapitalPsi][0, x, y] == 1 - y
ic2 =
DirichletCondition[\[CapitalPsi][t, x, y] == -2 +
2.2 t/\[CapitalDelta]td,
y == 3 && x <= 1 && t <= \[CapitalDelta]td]
ic3 =
DirichletCondition[\[CapitalPsi][t, x, y] == 0.2,
y == 3 && x <= 1 && t > \[CapitalDelta]td]
ic4 = DirichletCondition[\[CapitalPsi][0, x, y] == 1 - y, True]
sol =
Monitor[NDSolveValue[{op == 0, ic1, ic2, ic3,
ic4}, \[CapitalPsi], {x, y} \[Element] m, {t, 0,
T, \[CapitalDelta]t}, Method -> Automatic,
EvaluationMonitor :> (monitor = Row[{"t = ", CForm[t]}])],
monitor]