0
$\begingroup$

I would like to solve the laplace-equation in 2 dimensions, using mixed boundary conditions. The code I used is:

NDSolve[ {D[u[x, z], x, x] == -D[u[x, z], z, z],u[x, 10] == 0, (D[u[x, z], z] /. z -> 10) == 0,u[x, 0] == SquareWave[x]}, u, {x, 0, 10}, {z, 0, 10}] 

The error messages I get are:

CoefficientArrays::poly: (u^(0,1))[x,10] is not a polynomial. NDSolve::fembdnl: The dependent variable in (u^(0,1))[x,10]==0 in the boundary condition DirichletCondition[(u^(0,1))[x,10]==0,z==10.] needs to be linear. 

I don't know what's the problem, can you help me figure out this error messages?

Best regards

Thorsten

$\endgroup$
1
  • $\begingroup$ Your boundary condition is wrong. (You set 3 boundary conditions in z direction and 0 boundary condition in x direction.) $\endgroup$ Commented Oct 21, 2016 at 14:04

1 Answer 1

1
$\begingroup$

You must write u[x,z] instead of u in NDSolve. Then the problem can be numerically solved.

However, as xzczd pointed out in a coment, the boundary conditions are not correct. With three b.c. in z-direction an None in x-direction the problem is ill-defined.

Nevertheless there is a numerical "solution", and due to numerical inaccuracy the violation of the second b.c. (the derivative) is not obvious.

Here is the numerical solution:

$Version (* Out[298]= "10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)" *) uu[x_, z_] = u[x, z] /. NDSolve[{D[u[x, z], x, x] == -D[u[x, z], z, z], u[x, 10] == 0, (D[u[x, z], z] /. z -> 10) == 0, u[x, 0] == SquareWave[x]}, u[x, z], {x, 0, 10}, {z, 0, 10}][[1]] (* Out[293]= InterpolatingFunction[{{0., 10.}, {0., 10.}}, <>][x, z] *) Plot3D[uu[x, z], {x, 0, 10}, {z, 0, 10}, ViewPoint -> {\[Pi], \[Pi]/2, 2}, AxesLabel -> {x, z, u}] 

enter image description here

$\endgroup$
4
  • $\begingroup$ Well... but how can one set 3 b.c. for one direction when solving Laplace equation? $\endgroup$ Commented Oct 21, 2016 at 15:25
  • $\begingroup$ @xzczd Good question. You are right. In my opinion it is a numerical effect that you are allowed to gives 3 b.c. Try varying the derivative (D[u[x, z], z] /. z -> 10) == d. You can go as high as d = 20 without altering the picture. This b.c. is by no means matched. So one should be careful appreciating nice pictures. $\endgroup$ Commented Oct 21, 2016 at 16:12
  • $\begingroup$ @xzczd Please see the updated version of my solution. $\endgroup$ Commented Oct 21, 2016 at 16:20
  • $\begingroup$ I even guess in v10.1 that b.c. is simply ignored. Just tested on Cloud, though using 3 b.c. will cause failure in v11, if the condition D[u[x, z], z] /. z -> 10) == 0 is taken away, a plot that just looks the same as the above one will be generated. $\endgroup$ Commented Oct 22, 2016 at 3:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.