Poisson Equation with Specified Boundary

0 downloads 0 Views 2MB Size Report
Consider the following Poisson equation defined on the unit square: ∂. 2 u. ∂x. 2. +. ∂. 2 u. ∂y. 2. = g (x, y), 0 < x < 1, 0 < y < 1. (1) subject to the following BCs.
����������������������������

�������������������������������� �������������������� ��������������������� ���������� Consider the following Poisson equation defined on the unit square: ∂2 u ∂x2

+

∂2 u ∂y2

= g (x, y),

0 < x < 1, 0 < y < 1

(1)

subject to the following BCs BC1 :

u (x, 0) = 0

(Dirichlet Boundary Condition)

BC2 :

u (x, 1) = 0

(Dirichlet Boundary Condition)

BC3 :

u (0, y) = 0

(Dirichlet Boundary Condition)

BC4 :

∂u ∂x

(1, y) = 0

(Neumann Boundary Condition)

������������������� In this section we will show that for a certain values of g(x,y) we can find an analytical solution. In particular, we will consider a candidate solution of the form: u(x,y)= α Cos[ n π x] Sin[m π y] - α Sin[m π y] where n and m are integers. Let us test if this solution satisfies our Poisson Equation u[x_, y_] := α Cos[ n π x] Sin[m π y] - α Sin[m π y]

Let us take the Laplacian of this function D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] // Simplify π2 α m2 - m2 + n2  Cos[n π x] Sin[m π y]

Thus if we define g(x,y) to be g[x_, y_] := π2 α m2 - m2 + n2  Cos[n π x] Sin[m π y]

then our u(x,y) function will satisfy

(2)

2 ���

PoissonEquation_FEM.nb

∂2 u ∂x2

+

∂2 u ∂y2

= g (x, y),

0 < x < 1, 0 < y < 1

Let us confirm this that the above expression for g(x,y) will satisfy our Poisson equation D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] - g[x, y] // Simplify 0

Next let us check if our solution satisfies the BCs At y=0 and y=1 we have Dirichlet BC {u[x, 0], u[x, 1]} {0, - α Sin[m π] + α Cos[n π x] Sin[m π]}

It follows,therefore, that as long as m is an integer the Dirichlet BCs at y=0 and y=1 are satisfied. For example if m=4 {u[x, 0], u[x, 1]} /. m → 4 {0, 0}

Consider next the Dirichlet BC at x=0 for all values of y u[0, y] 0

Thus the Dirichlet BC at x=0 is satisfied. Finally let us test to see if the Neumann condition is satisfied at x=1: D[u[x, y], x] /. x → 1 - n π α Sin[n π] Sin[m π y]

Thus the Neumann condition will be satisfied and long as n is an integer D[u[x, y], x] /. x → 1 /. n → 3 0

������� The following Poisson equation ∂2 u ∂x2

+

∂2 u ∂y2

= π2 α m2 - m2 + n2  Cos[n π x] Sin[m π y],

0 < x < 1, 0 < y < 1

(3)

subject to the following BCs BC1 :

u (x, 0) = 0

(Dirichlet Boundary Condition)

BC2 :

u (x, 1) = 0

(Dirichlet Boundary Condition)

BC3 :

u (0, y) = 0

(Dirichlet Boundary Condition)

(4)

PoissonEquation_FEM.nb

BC4 :

∂u ∂x

(1, y) = 0

(Neumann Boundary Condition)

The solution to this problem is u (x, y) = α Cos[ n π x] Sin[m π y] - α Sin[m π y], such that m, n are integers.

Mathematica��������������� We will take the following parameters for this problem m = 2; n = 1; α = 1; g[x_, y_] := π2 α m2 - m2 + n2  Cos[n π x] Sin[m π y]

This problem can be solved conveniently using Finite Elements sol = NDSolveValue[{Laplacian[u[x, y], {x, y}] - g[x, y] ⩵ NeumannValue[0, x ⩵ 1], DirichletCondition[u[x, 0] ⩵ 0, y == 0], DirichletCondition[u[x, 1] ⩵ 0, y ⩵ 1], DirichletCondition[u[0, y] ⩵ 0, x ⩵ 0]}, u, {x, 0, 1}, {y, 0, 1}] InterpolatingFunction

������� {{��� ��}� {��� ��}} ������� ������



Plot3D[sol[x, y], {x, 0, 1}, {y, 0, 1}, AxesLabel → {"y", "x", "u"}, ColorFunction → "TemperatureMap", BoundaryStyle → Thick, Mesh → True, ImageSize → 400]

���

3

PoissonEquation_FEM.nb

������������ ContourPlot[sol[x, y], {x, 0, 1}, {y, 0, 1}, ColorFunction → "TemperatureMap", PlotPoints → 80, PlotLegends → Automatic, FrameLabel → {Style["x", 18], Style["y", 18]}] 1.0

0.8

1.5 0.6 0.5

y

4 ���

0.4

-0.5

-1.5 0.2

0.0 0.0

0.2

0.4

0.6

0.8

1.0

x

�������������� Let us now compare the numerical value with the exact solution which is given by u (x, y) = α Cos[ n π x] Sin[m π y] - α Sin[m π y]

We define a function for evaluating the exact solution at any given point in the domain exactSoln[x_, y_] := α Cos[ n π x] Sin[m π y] - α Sin[m π y]

PoissonEquation_FEM.nb

Plot3D[exactSoln[x, y], {x, 0, 1}, {y, 0, 1}, AxesLabel → {"y", "x", "u"}, ColorFunction → "TemperatureMap", BoundaryStyle → Thick, Mesh → True, ImageSize → 400]

ContourPlot[exactSoln[x, y], {x, 0, 1}, {y, 0, 1}, ColorFunction → "TemperatureMap", PlotPoints → 80, PlotLegends → Automatic, FrameLabel → {Style["x", 18], Style["y", 18]}] 1.0

0.8

1.5 0.6

y

0.5

0.4

-0.5

-1.5 0.2

0.0 0.0

0.2

0.4

0.6

x

0.8

1.0

���

5

6 ���

PoissonEquation_FEM.nb

������������������� To assess the error in our numerical solution we can compute the absolute error at any xi , yj node Abs[ uexaxt (xi , yj ) - unum (xi , yj )] Here is the value of u(x,y) at following x and y values {0.487, 0.7435}: val1 = exactSoln[0.487, 0.7435] 0.958371

The value of our numerical solution at the same nodal values is val2 = sol[0.487, 0.7435] 0.958312

Thus absolute error at the selected nodal point is Abs[val1 - val2] 0.0000585626

The agreement is accurate to 0.006% at the selected nodal value