3
$\begingroup$

I wish to use NDSolve to solve the following partial differential equation:

$$\frac{1}{v}\frac{\partial^2 u(x,y)}{\partial x^2}\,\frac{\partial u(x,y)}{\partial x}+\frac{\partial^2 u(x,y)}{\partial y^2}=0$$

Where $v$ is speed of sound 343.21 and the boundary conditions being $\{u(0,y)=0,u(1,y)=0,u(x,0)=\sin (\pi x),u(x,1)=0\} $

Here's the code I intend to run in order to perform everything I want on it:

eq = (1/343.21)*D[u[x, y], {x, 1}]*D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == 0;
bc = {u[0, y] == 0, u[1, y] == 0, u[x, 0] == Sin[Pi*x], u[x, 1] == 0};

sol = 
  NDSolve[{eq, bc}, u, {x, 0, 1}, {y, 0, 1}, 
    Method -> 
     {"PDEDiscretization" -> 
        {"MethodOfLines", 
         "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 100}}}]

I get the error message:

NDSolveValue::ivone: Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent variable. >>

UPDATE 13.02.2017:

Background information to the equation can be found Here1 and Here 2

$\endgroup$
4
  • 1
    $\begingroup$ The boundary conditions are not consistent in the point (1,0). What about trying u(x,0) = Sin[pi x]? $\endgroup$ Commented Feb 10, 2017 at 20:28
  • $\begingroup$ @Dr.WolfgangHintze .With u(x,0) = Sin[pi x] the same errors. :( $\endgroup$ Commented Feb 10, 2017 at 21:56
  • $\begingroup$ Can you add some background information for the equation? $\endgroup$
    – xzczd
    Commented Feb 11, 2017 at 6:54
  • $\begingroup$ @xzczd.I'm updated the question. $\endgroup$ Commented Feb 11, 2017 at 10:17

2 Answers 2

2
$\begingroup$

This is not a complete solution. NSolve is not able to solve the non-linear equation (in my version 10), but we study some simple linear cases in order to solve the issue of boundary and initial conditions. Finally we propose a method to find a solution of the non-linear solution.

Let us first study similar cases in which the problem has solutions. We consider linearized equations of hyperbolic type (wave equation) and elliptic type (Laplace equation).

The boundary conditions in $x$ are as given in the OP, we call the complementary condition initial condition taken from the wave equation picture, and choose a simple sine function:

eq = D[u[x, t], {x, 1}]*D[u[x, t], {x, 2}] + D[u[x, t], {t, 2}] == 
  0; (* non-liner equation of the OP *)
eq1 = D[u[x, t], {x, 2}] - D[u[x, t], {t, 2}] == 0; (* wave equation *)
eq2 = D[u[x, t], {x, 2}] + D[u[x, t], {t, 2}] == 0; (* Laplace equation *)
bc1 = {(* boundary conditions *) u[0, t] == 0, u[1, t] == 0,(* 
   initial condition *) u[x, 0] == Sin[\[Pi] x]};

sol1 = NDSolve[{eq1, bc1}, u[x, t], {x, 0, 1}, {t, 0, 2}][[1]];
uu1[x_, t_] := u[x, t] /. sol1[[1]];
Plot3D[uu1[x, t], {x, 0, 1}, {t, 0, 2}, PlotRange -> All, 
 PlotLabel -> "wave equation"]

enter image description here

sol2 = NDSolve[{eq2, bc1}, u[x, t], {x, 0, 1}, {t, 0, 2}][[1]];
uu2[x_, t_] := u[x, t] /. sol2[[1]];
Plot3D[uu2[x, t], {x, 0, 1}, {t, 0, 2}, PlotRange -> All, 
 PlotLabel -> "Laplace equation", AxesLabel -> {"x", "t", "u"}]

enter image description here

The treatment of the non-linear equation is very brief (in my version 10)

sol = NDSolve[{eq, bc1}, u[x, t], {x, 0, 1}, {t, 0, 2}][[1]]

During evaluation of In[101]:= NDSolve::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve. >>

It would be interesting to study analytically the ansatz

u[x_, t_] := Sum[a[n, t] Sin[n \[Pi] x], {n, 1, \[Infinity]}]

i.e. trying to solve the system of equations for a[n,t].

$\endgroup$
2
2
$\begingroup$

Method 1.

Let us consider the two-dimensional nonlinear PDE equations: $$\frac{1}{v}\frac{\partial^2 u(x,y)}{\partial x^2}\,\frac{\partial u(x,y)}{\partial x}+\frac{\partial^2 u(x,y)}{\partial y^2}=0$$ and the boundary conditions being:

$\{u(x,0)=\text{f1}(x),u(x,1)=\text{f2}(x),u(0,y)=\text{f3}(y),u(1,y)=\text{f4}(y)\}$

where:$\text{f1}(x)=\sin (\pi x),\text{f2}(x)=0,\text{f3}(y)=0,\text{f4}(y)=0$

defined in the domain $D=\{a\leq x\leq b,c\leq y\leq d\}$ .

enter image description here

The finite difference schemes take the form.

$\left(\frac{U(i+1,j)}{h^2}-\frac{2 U(i,j)}{h^2}+\frac{U(i-1,j)}{h^2}\right) \left(\frac{U(i+1,j)}{h}-\frac{U(i,j)}{h}\right)+\frac{U(i,j+1)}{k^2}-\frac{2 U(i,j)}{k^2}+\frac{U(i,j-1)}{k^2}$

{nD = 20, a = 0, b = 1, c = 0, d = 1, nX = 20, nY = 20, 
h = (b - a)/nX, k = (d - c)/nY};
xN = Table[x[i] -> a + i*h, {i, 0, nX}];
yN = Table[y[j] -> c + j*k, {j, 0, nY}];
fd[i_, j_] :=(1/343.21) (U[i + 1, j]/h^2 - 2*U[i, j]/h^2 + U[i - 1, j]/h^2)*(U[i + 1, j]/h - U[i, j]/h) + (U[i, j + 1]/k^2 - 2*U[i, j]/k^2 + U[i, j - 1]/k^2);
f1[i_] := Sin[Pi*i*h];
f2[i_] := 0;
f3[j_] := 0;
f4[j_] := 0;
bc = Flatten[{Table[U[i, 0] -> f1[i], {i, 0, nX}], 
Table[U[i, nY] -> f2[i], {i, 0, nX}], 
Table[U[0, j] -> f3[j], {j, 0, nY}], 
Table[U[nX, j] -> f4[j], {j, 0, nY}]}];
eqs = Flatten[Table[fd[i, j] == 0, {i, 1, nX - 1}, {j, 1, nY - 1}]];
eqs1 = Rationalize[Flatten[eqs /. bc], 0];
vars = Flatten[Table[{U[i, j], 0}, {i, 1, nX - 1}, {j, 1, nY - 1}], 1];
sole = FindRoot[eqs1, vars, MaxIterations -> 200] // Quiet;
points = Table[{x[i], y[j], U[i, j]}, {i, 0, nX}, {j, 0, nY}];
points1 = Flatten[N[points /. xN /. yN /. bc /. sole, nD], 1];
g = Interpolation[points1, Method -> "Hermite"];
Plot3D[g[x, y], {x, 0, 1}, {y, 0, 1}, AxesLabel -> Automatic, 
PlotRange -> All, BoxRatios -> {1, 1, 1}]

enter image description here

Method 2.

By adding a time derivative to an elliptic PDE, and obtaining the steady-state solution (by waiting for the process may reach a steady state).

tF = 20;
eq1 = 1/343.21*D[u[x, y, t], {x, 2}]*D[u[x, y, t], {x, 1}] +
D[u[x, y, t], {y, 2}] == D[u[x, y, t], t];
bc1 = {u[0, y, t] == 0, u[1, y, t] == 0, u[x, 0, t] == Sin[Pi*x], 
u[x, 1, t] == 0, u[x, y, 0] == Sin[Pi*x]};
sole2 = NDSolve[{eq1, bc1}, u, {x, 0, 1}, {y, 0, 1}, {t, 0, tF},
Method -> {"MethodOfLines", "SpatialDiscretization" 
-> {"TensorProductGrid",  "MaxPoints" -> 20}}]
Plot3D[u[x, y, tF] /. sole2, {x, 0, 1}, {y, 0, 1}, AxesLabel 
-> Automatic, BoxRatios -> {1, 1, 1}]

The result is the same as in Method 1.

enter image description here

$\endgroup$
4
  • $\begingroup$ @xzczd.OK my mistake. $\endgroup$ Commented Feb 12, 2017 at 9:05
  • $\begingroup$ I just want to point out that, after $v$ is adding to the equation, the influence of the nonlinear term becomes very weak, now the result almost doesn't change even if D[u[x, y, t], {x, 2}]*D[u[x, y, t], {x, 1}] is removed from the equation… $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 10:32
  • $\begingroup$ @xzczd. Can You give a better answer from mine ? :P $\endgroup$ Commented Feb 15, 2017 at 14:27
  • $\begingroup$ This is currently beyond my reach. The lack of background information is fatal, I think. (I saw your update in the question, it helps, but still not enough… ) It seems to be so hard to find materials related to this equation, strange. $\endgroup$
    – xzczd
    Commented Feb 15, 2017 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.