Message Boards Message Boards

Use the Dirchelet Type B.C. for the 2D pde heat equation?

Posted 6 years ago

I cannot get the "DirchletCondition" type boundary condition to work on a simple 2D pde heat equation .

I can get it to work by explicitly applying the boundary condition like u[x, ylow] == ulow, u[x, yhigh] == uhigh for two opposite straight edges.

But can't get it to work using the "DirchletCondition" type boundary condition like:

DirchletCondition[ u[x, y] == ulow , y == ylow && xlow <= x <= xhigh] 


DirchletCondition[ u[x, y] == uhigh, y == yhigh && xlow <= x <= xhigh ] 

Enclosed is a copy of the working example followed by the not working example.

(* START CODE HERE *)

(* YES WORKS: solve heat equation with “direct application” of edge boundary conditions *)

xlow = -1
xhigh = 1
ylow = 0
yhigh = 1
ulow = 0
uhigh = 1

ufun = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 10,
   u[x, ylow] == ulow,
   u[x, yhigh] == uhigh},   
u, {x, xlow, xhigh}, {y, ylow, yhigh}];

Plot3D[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> "TemperatureMap"]

(* NOT WORK: resolve heat equation with “Dirchlet application” of edge boundary conditions *)

xlow = -1
xhigh = 1
ylow = 0
yhigh = 1
ulow = 0
uhigh = 1

ufun = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 10,
    DirchletCondition[ u[x, y] == ulow , y == ylow && xlow <= x <= xhigh] ,           
    DirchletCondition[ u[x, y] == uhigh, y == yhigh && xlow <= x <= xhigh ]  },    
 u, {x, xlow, xhigh}, {y, ylow, yhigh}];

Plot3D[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> "TemperatureMap"]

There is a simple error in the code after fixing it works well

xlow = -1;
xhigh = 1;
ylow = 0;
yhigh = 1;
ulow = 0;
uhigh = 1;![enter image description here][1]

ufun = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 10, 
    DirichletCondition[u[x, y] == ulow, 
     y == ylow && xlow <= x <= xhigh], 
    DirichletCondition[u[x, y] == uhigh, 
     y == yhigh && xlow <= x <= xhigh]}, 
   u, {x, xlow, xhigh}, {y, ylow, yhigh}];

Plot3D[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, 
 ColorFunction -> "TemperatureMap", Mesh -> None, 
 PlotLegends -> Automatic]

DC

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract