![Page 1: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/1.jpg)
Laplace’s Equation in2 and 3 Dimensions
Douglas Wilhelm Harder, M.Math. LELDepartment of Electrical and Computer Engineering
University of Waterloo
Waterloo, Ontario, Canada
ece.uwaterloo.ca
© 2012 by Douglas Wilhelm Harder. Some rights reserved.
![Page 2: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/2.jpg)
2
Outline
This topic discusses numerical solutions to Laplace’s equation in two and three dimensions– Discuss the physical problem and properties– Examine the equation– Consider boundary conditions in two and three dimensions– Approximate the equation using a finite-difference equation
• This will define a system of linear equations
Laplace's Equation in 2 and 3 Dimensions
![Page 3: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/3.jpg)
3
Outcomes Based Learning Objectives
By the end of this laboratory, you will:– Understand Laplace’s equation– Understand how to approximate the equation in two and three
dimensions using finite-difference equations– You will understand how the solutions may be approximated
using a system of linear equations
Laplace's Equation in 2 and 3 Dimensions
![Page 4: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/4.jpg)
4
Motivating Example
Laplace’s equation is a simple statement of second partial derivatives
where u(x) is a function of n variables– We will consider n = 1, 2 and 3
2 0u
Laplace's Equation in 2 and 3 Dimensions
![Page 5: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/5.jpg)
5
Motivating Example
In one dimension, this simplifies to
where u(x) and the solution to any boundary-value problem is a straight line connecting the two end points
2
20
d u
dx
Laplace's Equation in 2 and 3 Dimensions
![Page 6: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/6.jpg)
6
Motivating Example
If we are dealing with soap films, the force that exerted by the film is proportional to the concavity
With concentrations, thermal energy and electric potentials, for a system to be in steady state, the forces exerted by the second derivatives with respect to concentration, thermal energy and electric potentials must be zero and cancel
Laplace's Equation in 2 and 3 Dimensions
![Page 7: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/7.jpg)
7
Motivating Example
In two and three dimensions, Laplace’s equation says that at each point, the sums of the concavities is zero
and
2 2
2 20
u u
x y
2 2 2
2 2 20
u u u
x y z
Laplace's Equation in 2 and 3 Dimensions
![Page 8: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/8.jpg)
8
Motivating Example
If we are dealing with soap films, the force that is exerted by the film is proportional to the concavity
User:Rror
Laplace's Equation in 2 and 3 Dimensions
![Page 9: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/9.jpg)
9
Motivating Example
If we are dealing with a concentration, the concentration at any point will be the average of the concentrations around it– In the steady state, we do not expect one point to be more
concentrated than everything around it
Laplace's Equation in 2 and 3 Dimensions
![Page 10: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/10.jpg)
10
Motivating Example
If we are dealing with a thermal energy, the thermal energy at any point will be the average of the thermal energy around it– We do not expect, in the steady state, the temperature at one
point to be higher or lower than all the points in the immediate neighbourhood
Laplace's Equation in 2 and 3 Dimensions
![Page 11: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/11.jpg)
11
Finite-Element Equation
So, given:
and
Let’s approximate these using the divided-difference approximations of the partial derivatives
2 2
2 20
u u
x y
2 2 2
2 2 20
u u u
x y z
Laplace's Equation in 2 and 3 Dimensions
![Page 12: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/12.jpg)
12
Finite-Difference Equation
On substitution, we get:
Multiplying by h2 and collecting like terms simplifies these…
2 2
, 2 , , , 2 , ,0
u x h y u x y u x h y u x y h u x y u x y h
h h
2 2 2
, , 2 , , , , , , 2 , , , , , , 2 , , , ,0
u x h y z u x y z u x h y z u x y h z u x y z u x y h z u x y z h u x y z u x y z h
h h h
Laplace's Equation in 2 and 3 Dimensions
![Page 13: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/13.jpg)
13
Finite-Difference Equation
Solve for u(x, y) or u(x, y, z):
What do these approximations mean?
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
, , , , , , , , , , , ,, ,
6
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 hu x y z
Laplace's Equation in 2 and 3 Dimensions
![Page 14: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/14.jpg)
14
Finite-Difference Equation
In two dimensions,
says that the value of u(x, y) is average of the four points around it
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
Laplace's Equation in 2 and 3 Dimensions
![Page 15: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/15.jpg)
15
Finite-Difference Equation
In three dimensions,
says that the value of u(x, y , z) is average of the six points around it
, , , , , , , , , , , ,, ,
6
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 hu x y z
Laplace's Equation in 2 and 3 Dimensions
![Page 16: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/16.jpg)
16
Boundary Values
In one dimension, we have the average of two values:
To satisfy the constraints, given the real line
2
u x h u x hu x
Laplace's Equation in 2 and 3 Dimensions
![Page 17: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/17.jpg)
17
Boundary Values
In one dimension, we have the average of two values:
To satisfy the constraints, given the real line
we must specify the boundary values of a domain—in this case, an interval
2
u x h u x hu x
Laplace's Equation in 2 and 3 Dimensions
![Page 18: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/18.jpg)
18
Boundary Values
In two dimensions, we must evaluate the function in four directions
Given a plane,
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
Laplace's Equation in 2 and 3 Dimensions
![Page 19: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/19.jpg)
19
Boundary Values
In two dimensions, we must evaluate the function in four directions
Given a plane, we mustspecify an encloseddomain
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
Laplace's Equation in 2 and 3 Dimensions
![Page 20: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/20.jpg)
20
Boundary Values
In two dimensions, we must evaluate the function in four directions
The constraints must bedefined along theentire boundary ∂D
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
Laplace's Equation in 2 and 3 Dimensions
![Page 21: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/21.jpg)
21
The Laplacian Operator
How about three dimensions?
Laplace's Equation in 2 and 3 Dimensions
![Page 22: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/22.jpg)
22
The Laplacian Operator
The domain D will have to be some volume in three space
Laplace's Equation in 2 and 3 Dimensions
![Page 23: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/23.jpg)
23
The Laplacian Operator
The boundary values must be specified on the entire boundary ∂D of the given domain
Laplace's Equation in 2 and 3 Dimensions
![Page 24: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/24.jpg)
24
The Laplacian Operator
Examples of such constraints in two dimensions may be given by voltages
Note that constraints may also be internal as well as external
Laplace's Equation in 2 and 3 Dimensions
![Page 25: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/25.jpg)
25
The Laplacian Operator
In three dimensions, if we have a cubic domain with two opposite sides at 100 oC and the otherfour sides at 0 oC, thepotential inside the domainis shown here– At the centre of the
cube, it is the averageof the six sides:33.3333 oC
Laplace's Equation in 2 and 3 Dimensions
![Page 26: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/26.jpg)
26
The Laplacian Operator
In three dimensions, if we have a cubic domain containing three heat sources at 100 oC, and all sides at0 oC, the temperature throughout the room (assuming minimal convection) would beas shown
Laplace's Equation in 2 and 3 Dimensions
![Page 27: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/27.jpg)
27
The Laplacian Operator
Given a closed wire frame, dipping the frame into a solution will produce a soap film– At each point, the concavities in the three directions will sum to
zero
This fails for soap bubbles because Laplace’s equation isn’t satisfied: there is an external force—the force of the air inside the bubble pushing out– It is a sphere because that is the shape that satisfies Poisson’s
equation
Laplace's Equation in 2 and 3 Dimensions
![Page 28: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/28.jpg)
28
Approximating a Solution
In one dimension, when we solved BVPs, we divided the domain—the interval—into n equally spaced points
h
Laplace's Equation in 2 and 3 Dimensions
![Page 29: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/29.jpg)
29
Approximating a Solution
In two dimensions, our finite-difference equation refers to points such as x + h and y – h; thus, this suggests a grid of points h
h
Laplace's Equation in 2 and 3 Dimensions
![Page 30: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/30.jpg)
30
Approximating a Solution
For simplicity, we will associate these variables:
x-dimension ix
ixy-dimension iy
iyz-dimension iz
iztime dimension k
k
Laplace's Equation in 2 and 3 Dimensions
![Page 31: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/31.jpg)
31
Approximating a Solution
Thus, if we had a rectangular domain in two dimensions– The boundary conditions would be defined on the edge of the
rectangle
Laplace's Equation in 2 and 3 Dimensions
![Page 32: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/32.jpg)
32
Approximating a Solution
We could overlay a grid of nx × ny points– We will assume h is identical in both dimensions
h
h
Laplace's Equation in 2 and 3 Dimensions
![Page 33: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/33.jpg)
33
Approximating a Solution
This seems appropriate for a matrix:– U is an nx × ny matrix
– The entry ui ,i approximates the property at that location
Laplace's Equation in 2 and 3 Dimensions
x y
![Page 34: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/34.jpg)
34
Approximating a Solution
We know the value of the boundary points
Laplace's Equation in 2 and 3 Dimensions
![Page 35: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/35.jpg)
35
Approximating a Solution
Now we must approximate the values at the interior points
Laplace's Equation in 2 and 3 Dimensions
![Page 36: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/36.jpg)
36
Approximating a Solution
Now we must approximate the values at the interior points– We will zoom in on one interior point:
Laplace's Equation in 2 and 3 Dimensions
![Page 37: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/37.jpg)
37
Approximating a Solution
Now we must approximate the values at the interior points– We will zoom in on one interior point:
Laplace's Equation in 2 and 3 Dimensions
![Page 38: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/38.jpg)
38
Approximating a Solution
We could apply our finite-difference equation at this point:
Substitute x = x3 and y = y4 and rewrite the equation
, , , ,,
4
u x h y u x h y u x y h u x y hu x y
Laplace's Equation in 2 and 3 Dimensions
![Page 39: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/39.jpg)
39
Approximating a Solution
The simplified linear equation is
But
3 4 3 4 3 4 3 4 3 44 , , , , , 0u x y u x h y u x h y u x y h u x y h
3 2
3 4
4 3
4 5
x h x
x h x
y h y
y h y
Laplace's Equation in 2 and 3 Dimensions
![Page 40: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/40.jpg)
40
Approximating a Solution
The simplified linear equation is
– Also, we approximate u(xi , yi ) ≈ ui ,i
3 4 2 4 4 4 3 3 3 54 , , , , , 0u x y u x y u x y u x y u x y
x y x y
Laplace's Equation in 2 and 3 Dimensions
![Page 41: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/41.jpg)
41
Approximating a Solution
The simplified linear equation is
3,4 2,4 4,4 3,3 3,54 0u u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 42: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/42.jpg)
42
Approximating a Solution
What happens if some of the adjacent values are on the boundary?
2,4 1,4 3,4 2,3 2,54 0u u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 43: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/43.jpg)
43
Approximating a Solution
Recall that the boundary values are all given, thus, in this case, u1,4 is a given value
2,4 1,4 3,4 2,3 2,54 0u u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 44: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/44.jpg)
44
Approximating a Solution
Bring it to the other side…
2,4 3,4 2,3 2,5 1,44u u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 45: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/45.jpg)
45
Approximating a Solution
Thus, at each of the 28 interior points, we could write down a linear equation:
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 46: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/46.jpg)
46
Approximating a Solution
Solve the system of equations, to get the approximate values at each of the interior points…
Laplace's Equation in 2 and 3 Dimensions
![Page 47: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/47.jpg)
47
Approximating a Solution
This gives us 28 linear equations in 28 unknowns– All the boundary values must be known…
Laplace's Equation in 2 and 3 Dimensions
![Page 48: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/48.jpg)
48Approximating a Solution in 3 Dimensions
It wouldn’t be very different in three dimensions, either…
, , 1, , 1, , , 1, , 1, , , 1 , , 16 0x y z x y z x y z x y z x y z x y z x y zi i i i i i i i i i i i i i i i i i i i iu u u u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 49: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/49.jpg)
49
Irregular Domains
Grids are perfect if we are attempting to approximate a solution on a rectangular region– Most systems are not rectangular…– We can solve Laplace’s equation on any simply connected or
contiguous domain
Laplace's Equation in 2 and 3 Dimensions
![Page 50: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/50.jpg)
50
Irregular Domains
Suppose we have an irregular shape
Laplace's Equation in 2 and 3 Dimensions
![Page 51: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/51.jpg)
51
Irregular Domains
It may be possible to impose a grid on the shape
Laplace's Equation in 2 and 3 Dimensions
![Page 52: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/52.jpg)
52
Irregular Domains
Those points outside the region would have to be specified
Laplace's Equation in 2 and 3 Dimensions
![Page 53: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/53.jpg)
53
Irregular Domains
We could increase the number of points, but this may still be sub-optimal
Laplace's Equation in 2 and 3 Dimensions
![Page 54: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/54.jpg)
54
Irregular Domains
We may have symmetries in one subdomain, but not in others
Laplace's Equation in 2 and 3 Dimensions
![Page 55: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/55.jpg)
55
Finite Elements
An alternative techniques, pioneered by Alexander Hrennikoff (a civil engineer) and Richard Courant in the early 1940s– Finite elements allow the user to use tessellations– This divides the domain into triangular sub-domains in two
dimensions or tetrahedral sub-domains in three dimensions
The Nanotechnology students will see the finite-element method in their 3B term
Laplace's Equation in 2 and 3 Dimensions
![Page 56: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/56.jpg)
56
Initial and Boundary Conditions
When you consider this grid, there are 16 unknown points
Laplace's Equation in 2 and 3 Dimensions
![Page 57: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/57.jpg)
57
Initial and Boundary Conditions
To create a system of linear equations, it’s necessary to label the points from 1 to 16 in some manner
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 58: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/58.jpg)
58
Initial and Boundary Conditions
We will need a mapping between what we will call u-space and the w-space
w1 ↔ u2,2 w2 ↔ u2,3
w3 ↔ u3,2 w4 ↔ u3,3
w5 ↔ u3,4 w6 ↔ u4,3
w7 ↔ u4,4 w8 ↔ u4,5
w9 ↔ u4,6 w10 ↔ u4,7
w11 ↔ u4,8 w12 ↔ u5,4
w13 ↔ u5,5 w14 ↔ u5,6
w15 ↔ u5,7 w16 ↔ u5,8
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
u2,2 u2,3
u3,2 u3,3 u3,4
u4,3 u4,4 u4,5 u4,6 u4,7 u4,8
u5,4 u5,5 u5,6 u5,7 u5,8
Laplace's Equation in 2 and 3 Dimensions
![Page 59: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/59.jpg)
59
Boundary Conditions
Now, suppose the boundary conditions are:±5 V at the ends and 0 V everywhere else
Laplace's Equation in 2 and 3 Dimensions
![Page 60: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/60.jpg)
60
Boundary Conditions
Those points closest to these boundaries would begiven the specified values
Laplace's Equation in 2 and 3 Dimensions
![Page 61: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/61.jpg)
61
Approximating Solutions
Now we have a grid of points where each has either:– A specified value (the boundary values), or– Unknown values (what we will solve for)
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 62: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/62.jpg)
62
Approximating Solutions
At each unknown point, we apply the finite-difference equation
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 63: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/63.jpg)
63
Approximating Solutions
We will zoom on the top left area
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 64: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/64.jpg)
64
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Approximating Solutions
Apply the equation at w1:
w5
w6 w7
1 3 24 5 V 5 V 0w w w
w1 w2
w3 w4
5 V
5 V
1 3 24 10 Vw w w
Laplace's Equation in 2 and 3 Dimensions
![Page 65: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/65.jpg)
65
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Approximating Solutions
Apply the equation at w2:
w5
w6 w7
2 4 14 5 V 0 V 0w w w
w1 w2
w3 w4
5 V
5 V
2 4 14 5 Vw w w
Laplace's Equation in 2 and 3 Dimensions
![Page 66: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/66.jpg)
66
Approximating Solutions
Apply the equation at w3:
w5
w6 w7
3 1 44 0 V 5 V 0w w w
w1 w2
w3 w4
5 V
5 V
3 1 44 5 Vw w w
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 67: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/67.jpg)
67
Approximating Solutions
And apply the equation at w4:4 2 6 3 54 0w w w w w
w1 w2
w3 w4
5 V
5 V
w6
w5
w7
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 68: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/68.jpg)
68
Approximating Solutions
This generates a system of 16 linear equations in 16 unknowns 1 3 2
2 4 1
3 1 4
4 2 6 3 5
5 7 4
6 4 7
7 5 12 6 8
8 13 7 9
9 14 8 10
10 15 9 11
11 16 10
12 7 13
13
4 10 V
4 5 V
4 5 V
4 0 V
4 0 V
4 0 V
4 0 V
4 0 V
4 0 V
4 0 V
4 10 V
4 0 V
4
w w w
w w w
w w w
w w w w w
w w w
w w w
w w w w w
w w w w
w w w w
w w w w
w w w
w w w
w
8 12 14
14 9 13 15
15 10 14 16
16 11 15
0 V
4 0 V
4 0 V
4 10 V
w w w
w w w w
w w w w
w w w
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 69: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/69.jpg)
69
Approximating Solutions
In matrix form, we have:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4 1 1
1 4 1
1 4 1
1 1 4 1 1
1 4 1
1 4 1
1 1 4 1 1
1 4 1 1
1 4 1 1
1 4 1 1
1 4 1
1 4 1
1 1 4 1
1 1 4 1
1 1 4 1
1 1 4
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
10
5
5
0
0
0
0
0
0
0
10
0
0
0
0
10
Laplace's Equation in 2 and 3 Dimensions
![Page 70: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/70.jpg)
70
Approximating Solutions
Solving this in Matlab yields:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
3.7848
2.5696
2.5696
1.4937
0.4177
0.4177
0.1773
0.1292
0.5285
1.4488
3.8164
0.0029
0.1656
0.5361
1.4504
3.8167
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Laplace's Equation in 2 and 3 Dimensions
![Page 71: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/71.jpg)
71
Approximating Solutions
Recall our initial designations of the 16 points:
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
3.7848
2.5696
2.5696
1.4937
0.4177
0.4177
0.1773
0.1292
0.5285
1.4488
3.8164
0.0029
0.1656
0.5361
1.4504
3.8167
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Laplace's Equation in 2 and 3 Dimensions
![Page 72: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/72.jpg)
72
Approximating Solutions
Substituting the values we determined yields:
3.78
2.57
2.57
1.49
0.42
0.42
0.18
0.00
–0.13
–0.17
–0.52
–0.54
–1.45
–1.45
–3.82
–3.82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
3.7848
2.5696
2.5696
1.4937
0.4177
0.4177
0.1773
0.1292
0.5285
1.4488
3.8164
0.0029
0.1656
0.5361
1.4504
3.8167
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Laplace's Equation in 2 and 3 Dimensions
![Page 73: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/73.jpg)
73
Approximating Solutions
The electric potential we just approximated could be used to determine the path of a positive charge from the source to the sink
3.78
2.57
2.57
1.49
0.42
0.42
0.18
0.00
–0.13
–0.17
–0.52
–0.54
–1.45
–1.45
–3.82
–3.82
Laplace's Equation in 2 and 3 Dimensions
![Page 74: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/74.jpg)
74
Approximating Insulated Boundaries
If a boundary is insulated, we will assume it has a value equal to its neighbour– We made similar assumptions by setting finite difference
equations to zero
Laplace's Equation in 2 and 3 Dimensions
![Page 75: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/75.jpg)
75
Approximating Insulated Boundaries
Suppose in our example, the base is insulated
Insulated
Laplace's Equation in 2 and 3 Dimensions
![Page 76: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/76.jpg)
76
Approximating Insulated Boundaries
Apply the equation at w2:
w5
w6 w7
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
2 4 14 5 V ? 0w w w
w1 w2
w3 w4
5 V
5 V
Insulated
Laplace's Equation in 2 and 3 Dimensions
![Page 77: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/77.jpg)
77
Approximating Insulated Boundaries
Apply the equation at w2:
w5
w6 w7
2 4 1 24 5 V 0w w w w
w1 w2
w3 w4
5 V
5 V
2 4 13 5 Vw w w
Insulated
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 78: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/78.jpg)
78
Approximating Insulated Boundaries
Apply the equation at w3:
w5
w6 w7
3 1 44 ? 5 V 0w w w
w1 w2
w3 w4
5 V
5 V
Insulated
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 79: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/79.jpg)
79
Approximating Insulated Boundaries
Apply the equation at w3:
w5
w6 w7
3 1 3 44 5 V 0w w w w
w1 w2
w3 w4
5 V
5 V
3 1 43 5 Vw w w
Insulated
, 1, 1, , 1 , 14 0x y x y x y x y x yi i i i i i i i i iu u u u u
Laplace's Equation in 2 and 3 Dimensions
![Page 80: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/80.jpg)
80
Approximating Insulated Boundaries
This gives a system of 16 linear equations in 16 unknowns1 3 2
2 4 1
3 1 4
4 2 6 3 5
5 7 4
6 4 7
7 5 12 6 8
8 13 7 9
9 14 8 10
10 15 9 11
11 16 10
12 7 13
13
4 10 V
3 5 V
3 5 V
4 0 V
2 0 V
2 0 V
4 0 V
3 0 V
3 0 V
3 0 V
4 10 V
2 0 V
3
w w w
w w w
w w w
w w w w w
w w w
w w w
w w w w w
w w w w
w w w w
w w w w
w w w
w w w
w
8 12 14
14 9 13 15
15 10 14 16
16 11 15
0 V
3 0 V
3 0 V
4 10 V
w w w
w w w w
w w w w
w w w
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Insulated
Laplace's Equation in 2 and 3 Dimensions
![Page 81: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/81.jpg)
81
Approximating Insulated Boundaries
The only entries that changed are those on the diagonal:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4 1 1
1 3 1
1 3 1
1 1 4 1 1
1 2 1
1 2 1
1 1 4 1 1
1 3 1 1
1 3 1 1
1 3 1 1
1 4 1
1 2 1
1 1 3 1
1 1 3 1
1 1 3 1
1 1 4
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
10
5
5
0
0
0
0
0
0
0
10
0
0
0
0
10
Laplace's Equation in 2 and 3 Dimensions
![Page 82: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/82.jpg)
82
Approximating Insulated Boundaries
Solving this in Matlab yields:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4.6093
4.2187
4.2187
3.0467
1.8748
1.8748
0.7028
0.7832
2.0393
3.2340
4.4124
0.1551
1.0131
2.1008
3.2501
4.4156
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Laplace's Equation in 2 and 3 Dimensions
![Page 83: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/83.jpg)
83
Insulated
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4.6093
4.2187
4.2187
3.0467
1.8748
1.8748
0.7028
0.7832
2.0393
3.2340
4.4124
0.1551
1.0131
2.1008
3.2501
4.4156
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Approximating Insulated Boundaries
Recall our initial designations of the 16 points:
w1 w2
w3 w4 w5
w6 w7 w8 w9 w10 w11
w12 w13 w14 w15 w16
Laplace's Equation in 2 and 3 Dimensions
![Page 84: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/84.jpg)
84
Insulated
Approximating Insulated Boundaries
Substituting the values we determined yields:
4.61
4.22
4.22
3.05
1.87
1.87
0.70
– 0.15
–0.78
–1.01
–2.04
–2.10
–3.23
–3.25
–4.41
–4.42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4.6093
4.2187
4.2187
3.0467
1.8748
1.8748
0.7028
0.7832
2.0393
3.2340
4.4124
0.1551
1.0131
2.1008
3.2501
4.4156
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
Laplace's Equation in 2 and 3 Dimensions
![Page 85: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/85.jpg)
85
4.61
4.22
4.22
3.05
1.87
1.87
0.70
– 0.15
–0.78
–1.01
–2.04
–2.10
–3.23
–3.25
–4.41
–4.42
3.78
2.57
2.57
1.49
0.42
0.42
0.18
0.00
–0.13
–0.17
–0.52
–0.54
–1.45
–1.45
–3.82
–3.82
Approximating Insulated Boundaries
The transition is muchmore gradual withinsulated boundaries
Insulated
Laplace's Equation in 2 and 3 Dimensions
![Page 86: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/86.jpg)
86
Specifying Boundary Conditions
How do we create such a system of linear equations?– First we must allow the user to specify boundary conditions– The user will pass in a matrix
• Boundary values will be already specified– Insulated boundaries are marked with NaN
• Points at which we want to approximate the solution are assigned –∞
Laplace's Equation in 2 and 3 Dimensions
![Page 87: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/87.jpg)
87
Specifying Boundary Conditions
In our first example, the boundary would be specified by:>> M = [5 5 5 0 0 0 0 0 0 5 -Inf -Inf 0 0 0 0 0 0 5 -Inf -Inf -Inf 0 0 0 -5 -5 0 0 -Inf -Inf -Inf -Inf -Inf -Inf -5 0 0 0 -Inf -Inf -Inf -Inf -Inf -5 0 0 0 0 0 0 0 -5 -5];
Laplace's Equation in 2 and 3 Dimensions
![Page 88: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/88.jpg)
88
Specifying Boundary Conditions
In our second example, they would be specified by:>> M = [5 5 5 NaN NaN NaN NaN NaN NaN 5 -Inf -Inf NaN NaN NaN NaN NaN NaN 5 -Inf -Inf -Inf NaN NaN NaN -5 -5 NaN NaN -Inf -Inf -Inf -Inf -Inf -Inf -5 NaN NaN NaN -Inf -Inf -Inf -Inf -Inf -5 NaN NaN NaN NaN NaN NaN NaN -5 -5];
Insulated
Laplace's Equation in 2 and 3 Dimensions
![Page 89: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/89.jpg)
89
Approximating the Solution
The first step is argument checking:– Ensure that none of the points on the edge of the array are –∞– There must be a boundary value (fixed or insulated) around the
entire array
>> M = [5 5 5 NaN NaN NaN NaN NaN NaN
5 -Inf -Inf NaN NaN NaN NaN NaN NaN
5 -Inf -Inf -Inf NaN NaN NaN -5 -5 NaN NaN -Inf -Inf -Inf -Inf -Inf -Inf -5 NaN NaN NaN -Inf -Inf -Inf -Inf -Inf -5 NaN NaN NaN NaN NaN NaN NaN -5 -5];
Laplace's Equation in 2 and 3 Dimensions
![Page 90: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/90.jpg)
90
Approximating the Solution
The second and third steps are initialization and mapping each of the m unsolved points to a unique number from 1 to m
Laplace's Equation in 2 and 3 Dimensions
![Page 91: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/91.jpg)
91
Approximating the Solution
These steps are done for you:function [U_out] = laplace2d( U ) % 2. Initialization [n_x, n_y] = size( U ); U_out = U;
% 3. Associate each -Inf with an integer from 1 to m u_to_w = zeros( n_x, n_y ); w_to_u = zeros( 2, n_x * n_y ); m = 0; for ix = 1:n_x for iy = 1:n_y if U(ix, iy) == -Inf m = m + 1; u_to_w(ix, iy) = m; w_to_u(:, m) = [ix, iy]'; end end end
Laplace's Equation in 2 and 3 Dimensions
![Page 92: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/92.jpg)
92
Approximating the Solution
Step 4 creates and solves the system of linear equationsfunction [U_out] = laplace2d( U ) % 2. Initialization [n_x, n_y] = size( U ); U_out = U;
% 3. Associate each -Inf with an integer from 1 to m u_to_w = zeros( n_x, n_y ); w_to_u = zeros( 2, n_x * n_y ); m = 0; for ix = 1:n_x for iy = 1:n_y if U(ix, iy) == -Inf m = m + 1; u_to_w(ix, iy) = m; w_to_u(:, m) = [ix, iy]'; end end end % Create the sparse system of linear equations M = spalloc( m, m, 5*m ); b = zeros( m, 1 );
Laplace's Equation in 2 and 3 Dimensions
![Page 93: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/93.jpg)
93
Creating the System of Linear Equations
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
After running Step 3, the variables are assigned:m = 5
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
Laplace's Equation in 2 and 3 Dimensions
![Page 94: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/94.jpg)
94
Creating the System of Linear Equations
The next step, Step 4, involves us creating and solving the system of linear equations– We begin by creating the appropriately sized matrices and
vectors:
>> M = zeros( m, m )M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> b = zeros( m, 1 )b = 0 0 0 0 0
Laplace's Equation in 2 and 3 Dimensions
![Page 95: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/95.jpg)
95
Creating the System of Linear Equations
How do we update M and b?
Laplace's Equation in 2 and 3 Dimensions
![Page 96: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/96.jpg)
96
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
M = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b = 0 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
Laplace's Equation in 2 and 3 Dimensions
![Page 97: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/97.jpg)
97
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
The neighbouring points are atc + [-1 0]';c + [ 1 0]';c + [ 0 -1]';c + [ 0 1]';
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
b = 0 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
M = 0 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
![Page 98: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/98.jpg)
98
Approximating the Solution
Given the ith unknown point, if a neighbouring point is:– An insulated boundary (NaN):
• Do nothing!
– A Dirichlet boundary condition:• Subtract 1 from the ith diagonal entry of M, and• Subtract the value from the ith entry of the vector b
– Another unknown (-Inf) point (say the jth unknown)• Subtract 1 from the ith diagonal entry of M, and• Add 1 to the (i, j)th entry of M
Laplace's Equation in 2 and 3 Dimensions
![Page 99: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/99.jpg)
99
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
The first point is 5 and not –∞: update M and b>> p = c + [-1 0]';p = 1 2>> U(p(1), p(2))ans = 5
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
b = -5 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
M = -1 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
![Page 100: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/100.jpg)
100
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
The second point is –∞: update M>> p = c + [ 1 0]';p = 3 2>> u_to_w(p(1), p(2))ans = 4
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
M = -2 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b = -5 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
Laplace's Equation in 2 and 3 Dimensions
![Page 101: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/101.jpg)
101
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
The third point is NaN: do nothing...>> p = c + [ 0 -1]';p = 2 1
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
M = -2 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b = -5 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
Laplace's Equation in 2 and 3 Dimensions
![Page 102: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/102.jpg)
102
Approximating the Solution
Focusing on the first point 1, we note that it is at>> c = w_to_u(:, 1)c = 2 2
The fourth point is –∞: update M>> p = c + [ 0 1]';p = 2 3>> u_to_w(p(1), p(2))ans = 2
u_to_w = 0 0 0 0 0 0 1 2 3 0 0 4 0 5 0 0 0 0 0 0
M = -3 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b = -5 0 0 0 0
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
Laplace's Equation in 2 and 3 Dimensions
![Page 103: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/103.jpg)
103
Approximating the Solution
Performing this on all m unknown entries, we have the matrix M and the vector b:
M = -3 1 0 1 0 1 -4 1 0 0 0 1 -4 0 1 1 0 0 -3 0 0 0 1 0 -4
b = -5 -14 -6 -10 -11
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
Laplace's Equation in 2 and 3 Dimensions
![Page 104: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/104.jpg)
104
Approximating the Solution
Solving the system Mu = b yields
>> u = M \ bu = 5.2978 5.7940 3.8784 5.0993 3.7196
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
M = -3 1 0 1 0 1 -4 1 0 0 0 1 -4 0 1 1 0 0 -3 0 0 0 1 0 -4
b = -5 -14 -6 -10 -11
Laplace's Equation in 2 and 3 Dimensions
![Page 105: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/105.jpg)
105
Approximating the Solution
Step 5 has us substitute these values back into Uout:
U_out = 5.0000 5.0000 5.0000 5.0000 5.0000 NaN 5.2978 5.7940 3.8784 1.0000 NaN 5.0993 9.0000 3.7196 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
>> u = M \ bu = 5.2978 5.7940 3.8784 5.0993 3.7196
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
M = -3 1 0 1 0 1 -4 1 0 0 0 1 -4 0 1 1 0 0 -3 0 0 0 1 0 -4
b = -5 -14 -6 -10 -11
Laplace's Equation in 2 and 3 Dimensions
![Page 106: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/106.jpg)
106
Approximating the Solution
We will leave the NaN unchanged in the solution matrix...
U_out = 5.0000 5.0000 5.0000 5.0000 5.0000 NaN 5.2978 5.7940 3.8784 1.0000 NaN 5.0993 9.0000 3.7196 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
w_to_u = 2 2 2 3 3 ... 2 3 4 2 4 ...
>> u = M \ bu = 5.2978 5.7940 3.8784 5.0993 3.7196
U = 5 5 5 5 5 NaN -Inf -Inf -Inf 1 NaN -Inf 9 -Inf 1 1 1 1 1 1
M = -3 1 0 1 0 1 -4 1 0 0 0 1 -4 0 1 1 0 0 -3 0 0 0 1 0 -4
b = -5 -14 -6 -10 -11
Laplace's Equation in 2 and 3 Dimensions
![Page 107: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/107.jpg)
107
Approximating the Solution
Step 4 is to create and solve the system of linear equations % Create the sparse system of linear equations M = spalloc( m, m, 5*m ); b = zeros( m, 1 );
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
![Page 108: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/108.jpg)
108
Another Example
If you want to attempt to solve the first problem, use:U5a = zeros( 6, 9 );U5a( 1:3, 1:3 ) = 5;U5a( 3:6, 8:9 ) = -5;U5a( 2:3, 2:3 ) = -Inf;U5a( 3:4, 3:4 ) = -Inf;U5a( 4:5, 4:8 ) = -Inf;U5a_soln = laplace2d( U5a )mesh( U5a_soln' )
3.78
2.57
2.57
1.49
0.42
0.42
0.18
0.00
–0.13
–0.17
–0.52
–0.54
–1.45
–1.45
–3.82
–3.82
Laplace's Equation in 2 and 3 Dimensions
![Page 109: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/109.jpg)
109
Another Example
If you want to attempt to solve the second problem, use:U5b = NaN*ones( 6, 9 );U5b( 1:3, 1:3 ) = 5;U5b( 3:6, 8:9 ) = -5;U5b( 2:3, 2:3 ) = -Inf;U5b( 3:4, 3:4 ) = -Inf;U5b( 4:5, 4:8 ) = -Inf;U5b_soln = laplace2d( U5b )mesh( U5b_soln' )
Insulated
4.61
4.22
4.22
3.05
1.87
1.87
0.70
–0.15
–0.78
1.01
–2.04
–2.10
–3.23
3.25
–4.41
–4.42
Laplace's Equation in 2 and 3 Dimensions
![Page 110: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/110.jpg)
110
Solutions in 3D
Your function lapace3d will take a 3D array as an argument and it will fill in any entries that are -Inf.
To plot such objects, the function isosurf will take such a 3D array and
isosurf( U_out, 30 )
will plot thirty surfaces from the highest value to the lowest
Laplace's Equation in 2 and 3 Dimensions
![Page 111: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/111.jpg)
111
Solutions in 3D
U4c = -Inf*ones( 4, 4, 4 );U4c( 1 , : , : ) = 1;U4c(end, : , : ) = 4;U4c( : , 1 , : ) = 2;U4c( : , end, : ) = 5;U4c( : , : , 1 ) = 3;U4c( : , : , end) = 6;U4c_soln = laplace3d( U4c )isosurf( U4c_soln, 21 )
U4c_soln(:,:,1) = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
U4c_soln(:,:,2) = 2 1 1 5 2 2.6 3.2 5 2 3.2 3.8 5 2 4 4 5
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
![Page 112: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/112.jpg)
112
Solutions in 3D
U4d = -Inf*ones( 15, 15, 15 );U4d([1, end], : , :) = 100;U4d(:, [1, end], :) = 0;U4d(:, :, [1, end]) = 0;U4d_soln = laplace3d( U4d )isosurf( U4d_soln, 21 )
Note: colours may vary...
Laplace's Equation in 2 and 3 Dimensions
Note: isosurf is available for download in the Laboratory directory
![Page 113: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/113.jpg)
113
Solutions in 3D
U4e = -Inf*ones( 15, 15, 15 );U4e( 1 , : , : ) = 100;U4e(end, : , : ) = NaN;U4e( : , 1 , : ) = 0;U4e( : , end, : ) = NaN;U4e( : , : , 1 ) = 50;U4e( : , : , end) = NaN;U4e_soln = laplace3d( U4e )isosurf( U4e_soln, 21 )
100
0
50
Note: colours may vary...
Laplace's Equation in 2 and 3 Dimensions
![Page 114: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/114.jpg)
114
Solutions in 3D
U4f = -Inf*ones( 15, 15, 15 );U4f([1, end], :, :) = NaN;U4f(:, [1, end], :) = NaN;U4f(:, :, 1) = 0;U4f(:, :, end) = NaN;U4f(8, 8, 8) = 100;U4f_soln = laplace3d( U4f )isosurf( U4f_soln, 100 )
10
16
33
Note: colours may vary...
Laplace's Equation in 2 and 3 Dimensions
![Page 115: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/115.jpg)
115
Laboratory 5
During the laboratory, you will implement two functions:lapace2d and laplace3d
Once you have lapace2d working, laplace3d will require only a few modifications
Laplace's Equation in 2 and 3 Dimensions
![Page 116: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/116.jpg)
116
Steps to the Problem
Thus, the steps are:1. Argument checking
2. Initialization
3. Mapping the unknown points to a unique number from 1 to m
4. Creating and solving the system of linear equations
5. Substituting these values back into the solution
Laplace's Equation in 2 and 3 Dimensions
![Page 117: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/117.jpg)
117
Useful Matlab Commands
Note the behaviour of for-loops in Matlab when the argument being iterated over is a matrix:
>> for v = [0 0 1 1; 0 1 0 1] v end
v = 0 0v = 0 1v = 1 0v = 1 1
Laplace's Equation in 2 and 3 Dimensions
![Page 118: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/118.jpg)
118
Useful Matlab Commands
As another example, consider:
>> for v = [1 2 3; 4 5 6; 7 8 9] v end
v = 1 4 7v = 2 5 8v = 3 6 9
Laplace's Equation in 2 and 3 Dimensions
![Page 119: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/119.jpg)
119
Useful Matlab Commands
It is possible to create grids in higher dimensions:>> M = zeros( 4, 5, 3 )M(:, :, 1) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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
![Page 120: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/120.jpg)
120
Useful Matlab Commands
Other functions work as expected:>> size( M )ans = 4 5 3
Laplace's Equation in 2 and 3 Dimensions
![Page 121: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/121.jpg)
121
Useful Matlab Commands
Matrices indexed by more than two indices have their dimensions checked using ndims:
>> ndims( M )ans = 3
>> 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
![Page 122: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/122.jpg)
122
Useful Matlab Commands
Sparse matrices are matrices that are mostly zero...
Sparse matrices may be allocated with spalloc:>> M = spalloc( 1000, 1000, 5000 );
This:– Assumes the matrix will be 1000 × 1000– It will reserve memory for 5000 non-zero entries
The internal representation is all that changes: everything else is essentially the same
Laplace's Equation in 2 and 3 Dimensions
![Page 123: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/123.jpg)
123
Useful Matlab Commands
Outside the display, everything else is the same:M = spalloc( 5, 5, 12 );M(1, 1) = 4; M(2, 2) = 7; M(3, 3) = 4; M(4, 4) = 8;M(5, 5) = 9; M(2, 1) = -3; M(3, 2) = -1; M(5, 4) = -2;M(1, 2) = -2; M(2, 3) = -1; M(3, 4) = -2; M(4, 5) = -3;M M = (1,1) 4 (2,1) -3 (1,2) -2 (2,2) 7 (3,2) -1 (2,3) -1 (3,3) 4 (3,4) -2 (4,4) 8 (5,4) -2 (4,5) -3 (5,5) 9
M \ [1 2 3 4 5]' ans = 0.6201 0.7403 1.3214 0.7727 0.7273
M = zeros( 5, 5 );M(1, 1) = 4; M(2, 2) = 7; M(3, 3) = 4; M(4, 4) = 8;M(5, 5) = 9; M(2, 1) = -3; M(3, 2) = -1; M(5, 4) = -2;M(1, 2) = -2; M(2, 3) = -1; M(3, 4) = -2; M(4, 5) = -3;M M = 4 -2 0 0 0 -3 7 -1 0 0 0 -1 4 -2 0 0 0 0 8 -3 0 0 0 -2 9
M \ [1 2 3 4 5]' ans = 0.6201 0.7403 1.3214 0.7727 0.7273
Laplace's Equation in 2 and 3 Dimensions
![Page 124: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/124.jpg)
124
Summary
We have looked at solving Laplace’s equation– Considered the physical problem for Laplace’s equation– Considered the effects in two and three dimensions– Found a finite-difference equation approximating Laplace’s
equation in both two and three dimensions• We find those points that are unknown: 1, …, m• We set up the system of equations• We solve the system of equations and substitute the values back
into the matrix
Laplace's Equation in 2 and 3 Dimensions
![Page 125: Laplace’s Equation in 2 and 3 Dimensions Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,](https://reader038.vdocuments.site/reader038/viewer/2022103005/56649d8c5503460f94a73b51/html5/thumbnails/125.jpg)
125
References
[1] Glyn James, Modern Engineering Mathematics, 4th Ed., Prentice Hall, 2007, p.778.
[2] Glyn James, Advanced Modern Engineering Mathematics, 4th Ed., Prentice Hall, 2011, p.164.
Laplace's Equation in 2 and 3 Dimensions