2D Laplace Equation
Specify the Laplace equation
Specify the Laplace equation
In[]:=
eqn=Laplacian[u[x,y],{x,y}]==0
Out[]=
(0,2)
u
(2,0)
u
Specify the Region
Specify the Region
In[]:=
width=48;height=12;
In[]:=
Ω=Rectangle[{0,0},{width,height}]
Out[]=
Rectangle[{0,0},{48,12}]
In[]:=
Ω
1
Specify the Boundary Conditions
Specify the Boundary Conditions
In[]:=
dcond1=DirichletConditionu[x,height]==22,x<=
width
3
Out[]=
DirichletCondition[u[x,12]22,x≤16]
In[]:=
dcond2=DirichletConditionu[x,height]==18,x>
2width
3
Out[]=
DirichletCondition[u[x,12]18,x>32]
In[]:=
dcond3=DirichletCondition[u[x,0]==0,True]
Out[]=
DirichletCondition[u[x,0]0,True]
Solve the Dirichlet problem
Solve the Dirichlet problem
In[]:=
solution=NDSolveValueu[x,y]==NeumannValue[0,y==0]+NeumannValue[0,x==0]+NeumannValue[0,x==width]+NeumannValue0,y==height&&<x<,{dcond1,dcond2},u,{x,y}∈Ω
2
∇
{x,y}
width
3
2width
3
Out[]=
InterpolatingFunction
Visualize the Solution
Visualize the Solution
In[]:=
ContourPlotsolution[x,y],{x,y}∈Ω,AspectRatio,PlotRange->All,AxesLabel{"x","y"}
1
3
Out[]=
Vector Field
Vector Field
In[]:=
v=Grad[-solution[x,y],{x,y}]
Out[]=
-InterpolatingFunction[x,y],-InterpolatingFunction[x,y]
In[]:=
VectorPlotv,{x,y}∈Ω,AspectRatio,PlotRange->All,AxesLabel{"x","y"},PlotLegendsAutomatic
1
3
In[]:=
Plot3Dsolution[x,y],{x,y}∈Ω,AspectRatio,PlotRange->All,AxesLabel{"x","y","u(x,y)"},PlotTheme"Business"
2
3
Out[]=