i have looked up solutions for my problems but they are either not related or to complicated, since my problem is rather simple:
I want to impose 2 Dirichlet and 2 Neumann BCs on a rectangle. The analytical solution for the problem is known for comparison: u(x,y)=x1*x2 My first approach would be:
bcdiri = {u[1, x2] == x2, u[x1, 0] == 0};
bcneu = {(-D[u[x1, x2], x1] /. x1 -> 0) == -x2, (D[u[x1, x2], x2] /.
x2 -> 1) == x1};
NDSolveValue[{Derivative[0,2][u][x1,x2]+Derivative[2,0][u][x1,x2]==0}~Join~bcdiri~Join~bcneu,u[x1,x2],{x1,0,1},{x2,0,1}]
But this does not work. I also tried this:
bcneu = NeumannValue[-x2, x1 == 0];
Which works somehow...but the other Neumann BC is not included...Lists or something like && also does not work. So...how to do it?
Thanks alot in advance!
Answer
You should check help page on NeumannValue
.
sol = NDSolve[{Derivative[0, 2][u][x1, x2] +
Derivative[2, 0][u][x1, x2] == -NeumannValue[-x2, x1 == 0] +
NeumannValue[x1, x2 == 1], u[1, x2] == x2, u[x1, 0] == 0},
u[x1, x2], {x1, 0, 1}, {x2, 0, 1}];
Plot3D[u[x1, x2] /. sol, {x1, 0, 1}, {x2, 0, 1}, PlotRange -> All]
Comments
Post a Comment