Professional Documents
Culture Documents
Laplace's Equation in 2 and 3 Dimensions: Douglas Wilhelm Harder, M.Math. LEL
Laplace's Equation in 2 and 3 Dimensions: Douglas Wilhelm Harder, M.Math. LEL
2 and 3 Dimensions
ece.uwaterloo.ca
dwharder@alumni.uwaterloo.ca
d 2u
2
0
dx
where u(x) and the solution to any boundary-value
problem is a straight line connecting the two end points
Laplace's Equation in 2 and 3 Dimensions
6
Motivating Example
and
2u 2u 2u
2 2 0
x y
2
z
Laplace's Equation in 2 and 3 Dimensions
8
Motivating Example
User:Rror
Laplace's Equation in 2 and 3 Dimensions
9
Motivating Example
So, given:
2u 2u
2 0
x y
2
and
2u 2u 2u
2 2 0
x y
2
z
On substitution, we get:
u x h, y 2u x, y u x h, y u x, y h 2u x, y u x, y h
0
h2 h2
u x h, y, z 2u x, y, z u x h, y, z u x, y h, z 2u x, y, z u x, y h, z u x, y, z h 2u x, y, z u x, y , z h
0
h2 h2 h2
In two dimensions,
u x h, y u x h, y u x, y h u x, y h
u x, y
4
says that the value of u(x, y) is average of the four points
around it
Laplace's Equation in 2 and 3 Dimensions
15
Finite-Difference Equation
In three dimensions,
u x h, y, z u x h, y, z u x, y h, z u x, y h, z u x, y, z h u x, y, z h
u x, y, z
6
says that the value of u(x, y , z) is average of the six
points around it
Laplace's Equation in 2 and 3 Dimensions
16
Boundary Values
Given a plane,
Laplace's Equation in 2 and 3 Dimensions
19
Boundary Values
h
Laplace's Equation in 2 and 3 Dimensions
29
Approximating a Solution
h
Laplace's Equation in 2 and 3 Dimensions
30
Approximating a Solution
x-dimension ix ix
y-dimension iy iy
z-dimension iz iz
time dimension k k
Laplace's Equation in 2 and 3 Dimensions
31
Approximating a Solution
h
Laplace's Equation in 2 and 3 Dimensions
33
Approximating a Solution
But
x3 h x2
x3 h x4
y4 h y3
y4 h y5
Laplace's Equation in 2 and 3 Dimensions
40
Approximating a Solution
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
5V w1 w2
w3 w4 w5
w6 w7
Laplace's Equation in 2 and 3 Dimensions
65
Approximating Solutions
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Apply the equation at w2:
4w2 5 V w4 w1 0 V 0
4w2 w4 w1 5 V
5V
5V w1 w2
w3 w4 w5
w6 w7
Laplace's Equation in 2 and 3 Dimensions
66
Approximating Solutions
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Apply the equation at w3:
4w3 w1 0 V 5 V w4 0
4w3 w1 w4 5 V
5V
5V w1 w2
w3 w4 w5
w6 w7
Laplace's Equation in 2 and 3 Dimensions
67
Approximating Solutions
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
And apply the equation at w4:
4w4 w2 w6 w3 w5 0
5V
5V w1 w2
w3 w4 w5
w6 w7
Laplace's Equation in 2 and 3 Dimensions
68
Approximating Solutions
4 w2 w4 w1 5 V
4 w3 w1 w4 5 V
4 w4 w2 w6 w3 w5 0 V
4 w5 w7 w4 0 V
4 w6 w4 w7 0 V
4 w7 w5 w12 w6 w8 0 V w1 w2
4 w8 w13 w7 w9 0 V
w3 w4 w5
4 w9 w14 w8 w10 0 V
4 w10 w15 w9 w11 0 V w6 w7 w8 w9 w10 w11
4 w11 w16 w10 10 V
w12 w13 w14 w15 w16
4 w12 w7 w13 0 V
4 w13 w8 w12 w14 0 V
4 w14 w9 w13 w15 0 V
4 w15 w10 w14 w16 0 V
4 w16 w11 w15 10 V
Laplace's Equation in 2 and 3 Dimensions
69
Approximating Solutions
1 1 4 w16 10
Laplace's Equation in 2 and 3 Dimensions
70
Approximating Solutions
3.78 2.57
Insulated
Laplace's Equation in 2 and 3 Dimensions
76
Approximating Insulated Boundaries
5V
Insulated
5V w1 w2
w3 w4 w5
w6 w7
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Laplace's Equation in 2 and 3 Dimensions
77
Approximating Insulated Boundaries
Insulated
5V w1 w2
w3 w4 w5
w6 w7
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Laplace's Equation in 2 and 3 Dimensions
78
Approximating Insulated Boundaries
5V
Insulated
5V w1 w2
w3 w4 w5
w6 w7
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Laplace's Equation in 2 and 3 Dimensions
79
Approximating Insulated Boundaries
Insulated
5V w1 w2
w3 w4 w5
w6 w7
4uix ,iy uix 1,iy uix 1,iy uix ,iy 1 uix ,iy 1 0
Laplace's Equation in 2 and 3 Dimensions
80
Approximating Insulated Boundaries
1 1 4 w16 10
Laplace's Equation in 2 and 3 Dimensions
82
Approximating Insulated Boundaries
3.78 2.57
Insulated
Laplace's Equation in 2 and 3 Dimensions
89
Approximating the Solution
Suppose we have:
>> U = [5 5 5 5 5; NaN -Inf -Inf -Inf 1; NaN -Inf 9 -Inf 1; 1 1 1 1 1]
U =
5 5 5 5 5
NaN -Inf -Inf -Inf 1
NaN -Inf 9 -Inf 1
1 1 1 1 1
>> b = zeros( m, 1 )
b =
0
0
0
0
0
Laplace's Equation in 2 and 3 Dimensions
95
Creating the System of Linear Equations
w_to_u =
2 2 2 3 3 ...
2 3 4 2 4 ...
M = b =
0 0 0 0 0 0
0 0 0 0 0 0 u_to_w =
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 2 3 0
0 0 0 0 0 0 0 4 0 5 0
0 0 0 0 0
Laplace's Equation in 2 and 3 Dimensions
97
Approximating the Solution
M = b =
0 0 0 0 0 0
0 0 0 0 0 0 u_to_w =
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 2 3 0
0 0 0 0 0 0 0 4 0 5 0
0 0 0 0 0
Laplace's Equation in 2 and 3 Dimensions
98
Approximating the Solution
u_to_w =
M = b = 0 0 0 0 0
-2 0 0 1 0 -5 0 1 2 3 0
0 0 0 0 0 0 0 4 0 5 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Laplace's Equation in 2 and 3 Dimensions
102
Approximating the Solution
U = M = b =
5 5 5 5 5 -3 1 0 1 0 -5
NaN -Inf -Inf -Inf 1 1 -4 1 0 0 -14
NaN -Inf 9 -Inf 1 0 1 -4 0 1 -6
1 1 1 1 1 1 0 0 -3 0 -10
0 0 1 0 -4 -11
>> u = M \ b
u =
5.2978
5.7940
3.8784
5.0993
3.7196
Laplace's Equation in 2 and 3 Dimensions
105
Approximating the Solution
U = M = b =
5 5 5 5 5 -3 1 0 1 0 -5
NaN -Inf -Inf -Inf 1 1 -4 1 0 0 -14
NaN -Inf 9 -Inf 1 0 1 -4 0 1 -6
1 1 1 1 1 1 0 0 -3 0 -10
0 0 1 0 -4 -11
>> u = M \ b U_out =
u = 5.0000 5.0000 5.0000 5.0000 5.0000
5.2978 NaN 5.2978 5.7940 3.8784 1.0000
5.7940 NaN 5.0993 9.0000 3.7196 1.0000
3.8784 1.0000 1.0000 1.0000 1.0000 1.0000
5.0993
3.7196
w_to_u =
2 2 2 3 3 ...
2 3 4 2 4 ...
Laplace's Equation in 2 and 3 Dimensions
106
Approximating the Solution
U = M = b =
5 5 5 5 5 -3 1 0 1 0 -5
NaN -Inf -Inf -Inf 1 1 -4 1 0 0 -14
NaN -Inf 9 -Inf 1 0 1 -4 0 1 -6
1 1 1 1 1 1 0 0 -3 0 -10
0 0 1 0 -4 -11
>> u = M \ b U_out =
u = 5.0000 5.0000 5.0000 5.0000 5.0000
5.2978 NaN 5.2978 5.7940 3.8784 1.0000
5.7940 NaN 5.0993 9.0000 3.7196 1.0000
3.8784 1.0000 1.0000 1.0000 1.0000 1.0000
5.0993
3.7196
w_to_u =
2 2 2 3 3 ...
2 3 4 2 4 ...
Laplace's Equation in 2 and 3 Dimensions
107
Approximating the Solution
for j = 1:m
% Get the coordinates of the kth point
% For each of the 4 (6 for 3D) adjacent points, determine if the point
% is an insluated boundary point, a Dirichlet boundary point or an
% unknown value and modify M as appropriate.
end
w = M \ b;
for j = 1:m
% Copy the value from w into U_out
end
Laplace's Equation in 2 and 3 Dimensions
108
Another Example
Insulated
Laplace's Equation in 2 and 3 Dimensions
110
Solutions in 3D
U4c_soln(:,:,3) =
2 1 1 5
2 3.2 3.8 5
2 3.8 4.4 5
2 4 4 5
U4c_soln(:,:,4) =
6 6 6 6
6 6 6 6
6 6 6 6
6 6 6 6
Note: colours may vary...
Laplace's Equation in 2 and 3 Dimensions
112
Solutions in 3D
50
v =
0
0
v =
0
1
v =
1
0
v =
1
1
Laplace's Equation in 2 and 3 Dimensions
118
Useful Matlab Commands
>> for v = [1 2 3; 4 5 6; 7 8 9]
v
end
v =
1
4
7
v =
2
5
8
v =
3
6
9
Laplace's Equation in 2 and 3 Dimensions
119
Useful Matlab Commands
M(:, :, 2) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
M(:, :, 3) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
Laplace's Equation in 2 and 3 Dimensions
120
Useful Matlab Commands
>> ndims( 1 )
ans =
2
>> ndims( [1 2 3] )
ans =
2
>> ndims( [1 2 3 4; 5 6 7 8] )
ans =
2
Laplace's Equation in 2 and 3 Dimensions
122
Useful Matlab Commands
This:
Assumes the matrix will be 1000 1000
It will reserve memory for 5000 non-zero entries
M \ [1 2 3 4 5]' M \ [1 2 3 4 5]'
ans = ans =
0.6201 0.6201
0.7403 0.7403
1.3214 1.3214
0.7727 0.7727
0.7273 0.7273
Laplace's Equation in 2 and 3 Dimensions
124
Summary