S
l
R =
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
slices
tubes
( thin
insulating
sheets )
( thin superconducting sheets )
3
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
=
t
r R
1 1
m
m
l
S
l m
S
l m
S
R
m
i
m
i
o o o
= = =
= = 1 1
1
1
S
l m
m
S
l
r
t
o
o
= =
m conductors in parallel:
S
l
R
o
=
n conductors in series:
=
s
r R
S
n
l
r
s
o
=
n
n
S
l
S
n
l
R
n
i
o o
= =
=1
S
l
R
o
=
Computing and CAD II
Professor Jan K. Sykulski
If tubes and slices are in correct position
there is negligible effect as they are not disturbing the field.
If they are not in correct position:
tubes increase resistance giving R
+
upper bound
slices decrease resistance giving R
lower bound
Only in undisturbed field R
= R
+
otherwise R
< R < R
+
4
Computing and CAD II
Professor Jan K. Sykulski
Example
I
I
a
a
a
2a
slices
tubes
2a
Computing and CAD II
Professor Jan K. Sykulski
Example
I
I
a
a
a
2a
slices
tubes
+
2a
depth unit per
a
a
R 2
2
= =
+
depth unit per
a
a
a
a
R 5 . 1
2
= + =
2a
2a
a
a
a
a
5
Computing and CAD II
Professor Jan K. Sykulski
Example
I
I
a
a
a
2a
) ( 2
2
tubes depth unit per
a
a
R = =
+
) ( 5 . 1
2
slices depth unit per
a
a
a
a
R = + =
2a
depth unit per
R R
R
ave
75 . 1
2
5 . 1 2
2
=
+
=
+
=
+
( ) ) ! ( 25 . 0 75 . 1 : guaranteed depth unit per R Answer =
depth unit per R program element finite a from result Accurate 73 . 1 : ) ( =
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
=
=
+ +
= =
t
i
s
j
ij
r
R where R I Power
1
1
2
1
1
=
=
= =
s
k
t
l
ls
r
R where
R
V
Power
1
1
2
1
1
Tubes:
Slices:
where for each r:
S
l
S
l
r =
6
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
I I
2
+
+
=
R R
R
ave
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
Construction
lines
7
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
Coarse
tube/slice
lines
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
Improved
tube/slice
lines
8
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
Finite
element
solution
Computing and CAD II
Professor Jan K. Sykulski
Tubes and Slices
Resistance
(per unit depth)
[value material resistivity]
Guaranteed
accuracy
Actual error
Hand calculation 2.7333 22.0 % 12.4 %
TAS coarse 2.4388 9.5 % 0.3 %
TAS refined 2.4324 4.0 % 0.3 %
Finite elements 2.4316 0.9 % 
9
Computing and CAD II
Professor Jan K. Sykulski
Classification of
methods of field
modelling:
analogue methods
analytical solutions
numerical methods
(algebraical computation)
graphical computation
The most popular
methods:
separation of variables
images
analogue techniques
conformal transformations
Laplace transforms
transmissionline
modelling
finite differences
finite elements
boundary elements
integral formulations
tubes and slices
...
Computing and CAD II
Professor Jan K. Sykulski
Review of field equations
0
2
2
2
2
2
2
=
c
c
+
c
c
+
c
c
z
V
y
V
x
V
Laplaces equation:
where V is a function of position V(x,y,z)
often written for convenience as:
In twodimensional problems (2D): 0
2
2
2
2
=
c
c
+
c
c
y
V
x
V
where V(x,y)
V could be an electrostatic potential or magnetostatic potential.
0
2
= V V
Some fields (e.g. a magnetic field) may be described using a vector potential:
0
2
= V A where A(x,y,z) = A
x
(x,y,z)i + A
y
(x,y,z)j + A
z
(x,y,z)k
0
2
= V
x
A
0
2
= V
z
A
0
2
= V
y
A
10
Computing and CAD II
Professor Jan K. Sykulski
Review of field equations
Laplaces equation:
0
2
= V V
0
2
= V A
In twodimensional problems (2D): k k A A A
z
= =
k J
z
J =
as
where ) , ( y x A
0
2
= V A
0
2
2
2
2
=
c
c
+
c
c
y
A
x
A
or
Computing and CAD II
Professor Jan K. Sykulski
Review of field equations
Laplaces equation:
0
2
= V V
0
2
= V A
Poissons equation:
Helmholtz equation:
Diffusion equation:
Wave equation:
f V = V
2
0
2 2
= + V V k V
t
V
h
V
c
c
= V
2
2
1
2
2
2 2
t
V
V
c
c
= V 
F A = V
2
f V k V = + V
2 2
homogeneous
nonhomogeneous
11
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
0
2
= u V
boundary the on everywhere defined
n
or
c
u c
u
Equation specified inside:
A unique solution exists!
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
i,j
12
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
i,j
0 : 2 '
2
2
2
2
2
=
c
u c
+
c
u c
= u V
y x
D in equation s Laplace
( ) ( )
...
! 3 ! 2
,
3
3 3
,
2
2 2
,
, , 1
+
c
u c A
+
c
u c A
+
c
u c
A + u = u
+
j i j i
j i
j i j i
x
x
x
x
x
x
( ) ( )
...
! 3 ! 2
,
3
3 3
,
2
2 2
,
, , 1
+
c
u c A
c
u c A
+
c
u c
A u = u
j i j i
j i
j i j i
x
x
x
x
x
x
Adding:
( ) ( ) } {
4
,
2
2
2
, , 1 , 1
2 x O
x
x
j i
j i j i j i
A +
c
u c
A + u = u + u
+
where O{(Ax)
4
} represents terms containing fourth and higher order powers of Ax.
Neglecting these terms yields:
( )
2
, 1 , , 1
,
2
2
2
x x
j i j i j i
j i
A
u + u u
=
c
u c
+
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
i,j
0 : 2 '
2
2
2
2
2
=
c
u c
+
c
u c
= u V
y x
D in equation s Laplace
( )
2
, 1 , , 1
,
2
2
2
x x
j i j i j i
j i
A
u + u u
=
c
u c
+
Similarly, under the same assumptions, in the y direction:
( )
2
1 , , 1 ,
,
2
2
2
y y
j i j i j i
j i
A
u + u u
=
c
u c
+
( )
( )
( )
( ) 0 2
1
2
1
1 , , 1 , 2 , 1 , , 1 2
= u + u u
A
+ u + u u
A
+ + j i j i j i j i j i j i
y x
13
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
i,j
0 : 2 '
2
2
2
2
2
=
c
u c
+
c
u c
= u V
y x
D in equation s Laplace
( )
( )
( )
( ) 0 2
1
2
1
1 , , 1 , 2 , 1 , , 1 2
= u + u u
A
+ u + u u
A
+ + j i j i j i j i j i j i
y x
If for convenience we choose a square mesh,
so that A x = A y :
0 4
, 1 , 1 , , 1 , 1
= u u + u + u + u
+ + j i j i j i j i j i
or
( )
1 , 1 , , 1 , 1 ,
4
1
+ +
u + u + u + u = u
j i j i j i j i j i
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
0 : 2 '
2
2
2
2
2
=
c
u c
+
c
u c
= u V
y x
D in equation s Laplace
( )
( )
( )
( ) 0 2
1
2
1
1 , , 1 , 2 , 1 , , 1 2
= u + u u
A
+ u + u u
A
+ + j i j i j i j i j i j i
y x
A fivepoint computation scheme:
0 4
, 1 , 1 , , 1 , 1
= u u + u + u + u
+ + j i j i j i j i j i
or
( )
1 , 1 , , 1 , 1 ,
4
1
+ +
u + u + u + u = u
j i j i j i j i j i
If for convenience we choose a square mesh,
so that A x = A y :
4
1
1
1
1
i 1
i +1
i
j 1
j +1
j
14
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
x
y
2
2
2
2
4
4
V = 100 V
V = 0
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
x
y
V = 100 V
V = 100 V
V = 0
V = 0
y
x
0 =
c
c
x
V
0 =
c
c
y
V
15
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
x
y
V = 100 V
V = 0
y
x
tube
tube
slice
slice
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
x
y
V = 100 V
V = 100 V
V = 0
V = 0
y
x
0 =
c
c
x
V
0 =
c
c
y
V
V = 100 V
V = 0
1 2 3 4
5
2
4
Fictitious nodes
16
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
1 2 3 4
5
2
4
0 4 0 100
1 2 2
= + + + V V V
0 4 0 100
2 3 1
= + + + V V V
0 4 0 100
3 4 2
= + + + V V V
0 4 100 100
4 5 3
= + + + V V V
0 4 100 0
5 4 4
= + + + V V V
(
(
(
(
(
(
=
(
(
(
(
(
(
(
(
(
(
(
(
100
200
100
100
100
4 2 0 0 0
1 4 1 0 0
0 1 4 1 0
0 0 1 4 1
0 0 0 2 4
5
4
3
2
1
V
V
V
V
V
Ax=b
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
1 2 3 4
5
2
4
0 4 0 100
1 2 2
= + + + V V V
0 4 0 100
2 3 1
= + + + V V V
0 4 0 100
3 4 2
= + + + V V V
0 4 100 100
4 5 3
= + + + V V V
0 4 100 0
5 4 4
= + + + V V V
( )
1 , 1 , , 1 , 1 ,
4
1
+ +
+ + + =
j i j i j i j i j i
V V V V V
4
1
1
1
1
17
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
1 2 3 4
5
2
4
0 4 0 100
1 2 2
= + + + V V V
0 4 0 100
2 3 1
= + + + V V V
0 4 0 100
3 4 2
= + + + V V V
0 4 100 100
4 5 3
= + + + V V V
0 4 100 0
5 4 4
= + + + V V V
( )
1 , 1 , , 1 , 1 ,
4
1
+ +
+ + + =
j i j i j i j i j i
V V V V V
( ) 100 2
4
1
2 1
+ = V V
( ) 100
4
1
3 1 2
+ + = V V V
( ) 100
4
1
4 2 3
+ + = V V V
( ) 200
4
1
5 3 4
+ + = V V V
( ) 100 2
4
1
4 5
+ = V V
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
1 2 3 4
5
2
4
( ) 100 2
4
1
2 1
+ = V V
( ) 100
4
1
3 1 2
+ + = V V V
( ) 100
4
1
4 2 3
+ + = V V V
( ) 200
4
1
5 3 4
+ + = V V V
( ) 100 2
4
1
4 5
+ = V V
v1=0.0; v2=0.0; v3=0.0; v4=0.0; v5=0.0; iter=0;
A simple iterative scheme:
.
.
do {
v1 = 0.25*(2*v2 +100);
v2 = 0.25*(v1 + v3 +100);
v3 = 0.25*(v2 + v4 +100);
v4 = 0.25*(v3 + v5 +200);
v5 = 0.25*(2*v4 +100);
iter += 1;
printf (%3d %6.2f %6.2f %6.2f %6.2f
%6.2f\n,iter,v1,v2,v3,v4,v5):
} while (iter < 20);
.
18
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
( )
1 , 1 , , 1 ,
2
4
1
+ +
+ + =
j i j i j i j i
V V V V
( )
1 , , 1 , 1 ,
2
4
1
+ +
+ + =
j i j i j i j i
V V V V
identify the special nodes
and apply special formulae
N
M
1
1
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
( )
3 , 2 , 1 2 , 1 ,
4
1
i i i j i
V V V V + + =
+
( ) 100
4
1
1 , 1 , , 1 ,
+ + + =
+ j M j M j M j i
V V V V
identify the special nodes
and apply special formulae
identify the nodes next to a boundary
and apply relevant formulae
( ) 100
4
1
1 , , 1 , 1 ,
+ + + =
+ N i N i N i j i
V V V V
M
N
1
1
19
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
identify the special nodes
and apply special formulae
identify the nodes next to a boundary
and apply relevant formulae
M
N
1
1
apply fivepoint formula to all other nodes
( )
1 , 1 , , 1 , 1 ,
4
1
+ +
+ + + =
j i j i j i j i j i
V V V V V
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
identify the special nodes
and apply special formulae
identify the nodes next to a boundary
and apply relevant formulae
M
N
1
1
apply fivepoint formula to all other nodes
Can we accelerate
the convergence?
20
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
i
j
i,j
( )
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V
1 , , 1
) 1 (
1 ,
) 1 (
, 1
) 1 (
,
4
1
+ +
+
+
+ + + =
New value available
Old value
New Old
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
i
j
i,j
( )
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V
1 , , 1
) 1 (
1 ,
) 1 (
, 1
) 1 (
,
4
1
+ +
+
+
+ + + =
k
j i
k
j i
k
j i
V V
,
) 1 (
,
) 1 (
,
=
+ +
o
where k is an iteration count
Let
where is a residual
or
) 1 (
, ,
) 1 (
,
+ +
+ =
k
j i
k
j i
k
j i
V V o
Let
) 1 (
, ,
) 1 (
,
+ +
+ =
k
j i
k
j i
k
j i
V V o o 1 < 2
 
)
`
+ + + + =
+ +
+
+ k
j i
k
j i
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V V V
, 1 , , 1
) 1 (
1 ,
) 1 (
, 1 ,
) 1 (
,
4
1
o
( )  
k
j i
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V V
1 , , 1
) 1 (
1 ,
) 1 (
, 1 ,
) 1 (
,
4
1
1
+ +
+
+
+ + + + = o o
or
fivepoint formula overrelaxation
SOR
Successive OverRelaxation
21
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
identify the special nodes
and apply special formulae
identify the nodes next to a boundary
and apply relevant formulae
M
N
1
1
apply fivepoint formula to all other nodes
apply SOR to accelerate convergence
( )
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V
1 , , 1
) 1 (
1 ,
) 1 (
, 1
) 1 (
,
4
1
+ +
+
+
+ + + =
k
j i
k
j i
k
j i
V V
,
) 1 (
,
) 1 (
,
=
+ +
o
) 1 (
, ,
) 1 (
,
+ +
+ =
k
j i
k
j i
k
j i
V V o o 1 < 2
choose optimum value for
Choosing
opt
problem dependent
schemes for estimating
opt
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
An improved iterative scheme:
introduce an array v[i,j]
sweep the nodes in i (1 to M) and j (1 to N)
i
j
identify the Neumann boundary nodes
and apply the formula with fictitious nodes
identify the special nodes
and apply special formulae
identify the nodes next to a boundary
and apply relevant formulae
M
N
1
1
apply fivepoint formula to all other nodes
apply SOR to accelerate convergence
( )
k
j i
k
j i
k
j i
k
j i
k
j i
V V V V V
1 , , 1
) 1 (
1 ,
) 1 (
, 1
) 1 (
,
4
1
+ +
+
+
+ + + =
k
j i
k
j i
k
j i
V V
,
) 1 (
,
) 1 (
,
=
+ +
o
choose optimum value for
monitor errors to terminate iterations
%) 1 . . ( 100
max
max
) 1 (
,
,
g e criterion local
V
k
j i
j i
local
s =
+
o
c
%) 5 . 0 . . ( 100
1
max
,
) 1 (
,
g e criterion global
V
N M
j i
k
j i
global
s
=
+
o
c
22
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method Example
V = 100 V
V = 0
1 2 3 4
5
2
4
(
(
(
(
(
(
=
(
(
(
(
(
(
(
(
(
(
(
(
100
200
100
100
100
4 2 0 0 0
1 4 1 0 0
0 1 4 1 0
0 0 1 4 1
0 0 0 2 4
5
4
3
2
1
V
V
V
V
V
Other methods of solving Ax=b exist
SOR particularly easy to implement in FD
Matrix sparsity may be explored
Matrix symmetry may be an issue
The pros and cons of the FD scheme
intuitive and easy to implement
SOR natural for a five point scheme
writing a code relatively straightforward
FD grid difficult to fit into practical devices
curved boundaries awkward to handle
mesh grading difficult
boundary conditions require special schemes
Computing and CAD II
Professor Jan K. Sykulski
The finitedifference method
The FD scheme for diffusion and wave problems (time derivatives)
Diffusion equation in 1D:
Wave equation in 1D:
t
V
x
V
c
c
=
c
c
o
2
2
The time derivatives can be obtained with the aid of Taylors series:
t
V V
t
V
k i k i
A
=
c
c
+ , 1 ,
2
2
2
2
t
V
x
V
c
c
=
c
c

( )
2
1 , , 1 ,
2
2
2
t
V V V
t
V
k i k i k i
A
+
=
c
c
+
( ) t
V V
x
V V V
k i k i k i k i k i
A
=
A
+
+ + , 1 ,
2
, 1 , , 1
2
o
( ) ( )
2
1 , , 1 ,
2
, 1 , , 1
2 2
t
V V V
x
V V V
k i k i k i k i k i k i
A
+
=
A
+
+ +

A new value of the potential (at a new time instant k+1)
23
Computing and CAD II
Professor Jan K. Sykulski
The FD method for diffusion problem
t
x
time
space
t = 0
x = 0
x = L
Boundary
and initial conditions specified
( ) t
V V
x
V V V
k i k i k i k i k i
A
=
A
+
+ + , 1 ,
2
, 1 , , 1
2
o
FD scheme:
i,k+1
i1,k
i+1,k i,k
x
t
Computing and CAD II
Professor Jan K. Sykulski
The FD method for wave problem
t
x
time
space
t = 0
x = 0
x = L
Boundary
and initial conditions specified
FD scheme:
i,k+1
i1,k
i+1,k i,k
x
t
( ) ( )
2
1 , , 1 ,
2
, 1 , , 1
2 2
t
V V V
x
V V V
k i k i k i k i k i k i
A
+
=
A
+
+ +

i,k1
Stability condition:
1
1
2
s 
.

\

A
A
x
t

To achieve good accuracy
x must be small.
But this necessitates very small
time steps t and thus the scheme
may be computationally inefficient.
24
Computing and CAD II
Professor Jan K. Sykulski
The FD method for diffusion problem
t
x
time
space
t = 0
x = 0
x = L
Boundary
and initial conditions specified
( ) t
V V
x
V V V
k i k i k i k i k i
A
=
A
+
+ + , 1 ,
2
, 1 , , 1
2
o
FD scheme:
i,k+1
i1,k
i+1,k i,k
x
t
Stability condition:
( ) 2
1
2
s
A
A
x
t
o
To achieve good accuracy
x must be small.
But this necessitates very small
time steps t and thus the scheme
may be computationally inefficient.
Explicit scheme.
Computing and CAD II
Professor Jan K. Sykulski
The FD method for diffusion problem
Crank & Nicolson (1947) introduced a scheme which is always convergent.
is replaced by the mean of FD representations on time rows k and k+1:
2
2
x
V
c
c
( ) ( ) t
V V
x
V V V
x
V V V
k i k i k i k i k i k i k i k i
A
=
)
`
A
+
+
A
+
+ + + + + + , 1 ,
2
, 1 , , 1
2
1 , 1 1 , 1 , 1
2 2
2
1
o
so that ( ) ( )
k i k i k i k i k i k i
rV rV r rV rV V r rV
, 1 , , 1 1 , 1 1 , 1 , 1
2 2 2 2
+ + + + +
+ + = + + where
( )
2
x
t
r
A
A
=
o
We have 3 unknowns on the left and three known values on the right.
With N nodes for each time row, N simultaneous equations need to be solved at each time step.
Implicit scheme.
25
Computing and CAD II
Professor Jan K. Sykulski
The FD method for diffusion problem
A weighted average approximation:
( ) ( ) t
V V
x
V V V
R
x
V V V
R
k i k i k i k i k i k i k i k i
A
=
A
+
+
A
+
+ + + + + + , 1 ,
2
, 1 , , 1
2
1 , 1 1 , 1 , 1
2
) 1 (
2
o
where 0 R 1 R = 0 explicit scheme
R = Crank  Nicolson
R = 1 fully implicit
backward scheme
Implicit Explicit Fully implicit
Computing and CAD II
Professor Jan K. Sykulski
The FD method for diffusion problem
A weighted average approximation:
( ) ( ) R x
t
r
2 1 2
1
2
s
A
A
=
o
( ) ( ) t
V V
x
V V V
R
x
V V V
R
k i k i k i k i k i k i k i k i
A
=
A
+
+
A
+
+ + + + + + , 1 ,
2
, 1 , , 1
2
1 , 1 1 , 1 , 1
2
) 1 (
2
o
where 0 R 1 R = 0 explicit scheme
R = Crank  Nicolson
R = 1 fully implicit
backward scheme
Implicit Explicit Fully implicit
0 R < stable if
R 1 unconditionally stable
26
Computing and CAD II
Professor Jan K. Sykulski
The FD method for 2D problems
Diffusion equation in 2D:
t
V
y
V
x
V
c
c
=
c
c
+
c
c
o
2
2
2
2
i.e. solution on a rectangle.
x
y
x
y
t
time
t
Computing and CAD II
Professor Jan K. Sykulski
The FD method for 2D problems
Explicit scheme computationally laborious as very small t needed.
x
y
t
time
27
Computing and CAD II
Professor Jan K. Sykulski
The FD method for 2D problems
CrankNicolson M N simultaneous equations need to ne solved on each time step.
x
y
t
time
Computing and CAD II
Professor Jan K. Sykulski
The FD method for 2D problems
Alternating Direction Implicit (ADI) method 25 times faster than explicit
x
y
t
time
7 times faster than CrankNicolson
and then the other way round. This process is repeated sequentially.
One second derivative, say in x, replaced by implicit scheme, whereas the other one by explicit.
28
Computing and CAD II
Professor Jan K. Sykulski
The pros and cons of the FD scheme
intuitive and easy to implement
SOR natural for a five point scheme
writing a code relatively straightforward
FD grid difficult to fit into practical devices
curved boundaries awkward to handle
mesh grading difficult
boundary conditions require special schemes
FD method: Alternative formulations
Other issues:
material boundaries and interfaces
conducting and magnetic materials
current carrying conductors
induced eddy currents
magnetic nonlinearity
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
Helmholtz equation in x,y, coordinates
s
J A j
y
A
y x
A
x
=


.

\

c
c
c
c
+ 
.

\

c
c
c
c
eo v v where reluctivity
v
1
= and v(x,y).
x
y
1
2
3
4
0
J
NE
,o
NE
,v
NE J
NW
,o
NW
,v
NW
J
SW
,o
SW
,v
SW
J
SE
,o
SE
,v
SE
a
b
c
d
e
f
g
h
h
1 h
3
h
4
h
2
N
W
S
E
A j J
x
A
y
A
curl
s z
eo v v =


.

\

c
c
c
c
j i or its curl form
29
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
Apply Stokes theorem
x
y
1
2
3
4
0
J
NE
,o
NE
,v
NE J
NW
,o
NW
,v
NW
J
SW
,o
SW
,v
SW
J
SE
,o
SE
,v
SE
a
b
c
d
e
f
g
h
h
1 h
3
h
4
h
2
N
W
S
E
A j J
x
A
y
A
curl
s z
eo v v =


.

\

c
c
c
c
j i
( )
} }}
= l F s F d d curl
and perform surface integration over the cell bdfg:
( ) dy dx A j J d
x
A
y
A
N
S
E
W
s
} } }
=


.

\

c
c
c
c
eo v v l j i
where E=h
1
/2, N=h
2
/2, W=h
3
/2 and S=h
4
/2.
On ab the contribution to the integral is:
dy
x
A
dy
x
A
y
A
E x
N
NE
N
=
} }
c
c
=


.

\

c
c
c
c
0 0
v v v j j i
and the following approximation may be used:
) (
1
0 1
N O
h
A A
x
A
E x
+
=
c
c
=
and thus:
( )
1
0 1
0
h
A A N
dy
x
A
y
A
NE
N
~


.

\

c
c
c
c
}
v
v v j j i
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
x
y
1
2
3
4
0
J
NE
,o
NE
,v
NE J
NW
,o
NW
,v
NW
J
SW
,o
SW
,v
SW
J
SE
,o
SE
,v
SE
a
b
c
d
e
f
g
h
h
1 h
3
h
4
h
2
N
W
S
E
( ) dy dx A j J d
x
A
y
A
N
S
E
W
s
} } }
=


.

\

c
c
c
c
eo v v l j i
On ab the contribution
to the integral is:
The complete line integral is therefore:
=


.

\

c
c
c
c
}
l j i d
x
A
y
A
v v
( ) + + + + =
0 4 3 2 1
A o o o o
( )
4 4 3 3 2 2 1 1
A A A A o o o o + + +
where:
1
1
h
S N
SE NE
v v
o
+
=
2
2
h
W E
NW NE
v v
o
+
=
3
3
h
S N
SW NW
v v
o
+
=
4
4
h
W E
SW SE
v v
o
+
=
( )
1
0 1
0
h
A A N
dy
x
A
y
A
NE
N
~


.

\

c
c
c
c
}
v
v v j j i
30
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
x
y
1
2
3
4
0
J
NE
,o
NE
,v
NE J
NW
,o
NW
,v
NW
J
SW
,o
SW
,v
SW
J
SE
,o
SE
,v
SE
a
b
c
d
e
f
g
h
h
1 h
3
h
4
h
2
N
W
S
E
( ) dy dx A j J d
x
A
y
A
N
S
E
W
s
} } }
=


.

\

c
c
c
c
eo v v l j i
The complete line integral:
For the surface integral of the RHS consider the first quadrant:
( ) dy dx A j NEJ dy dx A j J
N E
NE NE
N E
s
} } } }
=
0 0 0 0
eo eo
0
0 0
A NE dy dx A
N E
=
} }
( )
2
0
0
0
K O
y
A
y
x
A
x A A +
c
c
+
c
c
+ =
A double Taylor expansion about node 0 yields:
and neglecting higher terms:
( ) ( )
4 4 3 3 2 2 1 1 0 4 3 2 1
A A A A A d
x
A
y
A
o o o o o o o o v v + + + + + + =


.

\

c
c
c
c
}
l j i
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
x
y
1
2
3
4
0
J
NE
,o
NE
,v
NE J
NW
,o
NW
,v
NW
J
SW
,o
SW
,v
SW
J
SE
,o
SE
,v
SE
a
b
c
d
e
f
g
h
h
1 h
3
h
4
h
2
N
W
S
E
( ) dy dx A j J d
x
A
y
A
N
S
E
W
s
} } }
=


.

\

c
c
c
c
eo v v l j i Assembling all the pieces
and expressing in terms of A
0
:
( )
( )
0 4 3 2 1
0 4 4 3 3 2 2 1 1
0
Q j
I A A A A
A
e o o o o
o o o o
+ + + +
+ + + +
=
where
SW SE NW NE
SWJ SEJ NWJ NEJ I + + + =
0
SW SE NW NE
SW SE NW NE Q o o o o + + + =
0
and
1
1
h
S N
SE NE
v v
o
+
=
2
2
h
W E
NW NE
v v
o
+
=
3
3
h
S N
SW NW
v v
o
+
=
4
4
h
W E
SW SE
v v
o
+
=
31
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
Assembling all the pieces
and expressing in terms of A
0
:
where
SW SE NW NE
SWJ SEJ NWJ NEJ I + + + =
0
SW SE NW NE
SW SE NW NE Q o o o o + + + =
0
and
1
1
h
S N
SE NE
v v
o
+
=
2
2
h
W E
NW NE
v v
o
+
=
3
3
h
S N
SW NW
v v
o
+
=
4
4
h
W E
SW SE
v v
o
+
=
Assume: h
1
= h
2
= h
3
= h
4
J = 0
o = 0
v = constant
1
=
2
=
3
=
4
Q
0
= 0
I
0
= 0
( )
( )
0 4 3 2 1
0 4 4 3 3 2 2 1 1
0
Q j
I A A A A
A
e o o o o
o o o o
+ + + +
+ + + +
=
( )
4
4 3 2 1
0
A A A A
A
+ + +
=
a five point computational scheme
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
Generally:
( )
( )
0 4 3 2 1
0 4 4 3 3 2 2 1 1
0
Q j
I A A A A
A
e o o o o
o o o o
+ + + +
+ + + +
=
where
SW SE NW NE
SWJ SEJ NWJ NEJ I + + + =
0
SW SE NW NE
SW SE NW NE Q o o o o + + + =
0
and
1
1
h
S N
SE NE
v v
o
+
=
2
2
h
W E
NW NE
v v
o
+
=
3
3
h
S N
SW NW
v v
o
+
=
4
4
h
W E
SW SE
v v
o
+
=
32
Computing and CAD II
Professor Jan K. Sykulski
FD method: Alternative formulations
Threedimensional FD solution of Laplacian and Poissonian problems
(O) outside
(I) inside
(E) east
(W) west
(N) north
(S) south
1
2
3
4
5
6
0
div B = 0 and H = grad V
div (H) = div ( grad V ) = 0
Apply Gauss theorem
to the small volume surrounding node 0.
}}} }}
= s F F d dv div
( ) ( ) { }
( ) ( ) { }
( ) ( ) { }
( ) ( ) { }
( ) ( )
( ) ( ) 0
4
1
4
1
4
4
1
4
1
4
4
2
1
4
4
2
1
4
) 3 0 3 1 0 1
6
0 6
3 0 3 1 0 1
5
0 5
3 1 6 3 1 5
0
0 4
6 5 3 0
3
0 3
3 1 6 3 1 5
0
0 2
6 5 1 0
1
0 1
=
)
`
+ 
.

\

+ + 
.

\

+ A
+
)
`
+ 
.

\

+ + 
.

\

+ A
+
+ + +
A
+
+ + + A 
.

\

+
+ + +
A
+
+ + + A 
.

\

+
c
c
+
c
c
= V = = j i E
y
V
x
V
V V grad
The stored field energy:
} } } }
O O O O
O V = O


.

\

(
c
c
+
(
c
c
= O = O = d V d
y
V
x
V
d E d W
2
2
2
2
2
1
2
1
2
1
2
1
c c c D E
The principle of equilibrium requires that the potential distribution must be such as to
minimise the stored field energy. This minimumenergy principle is mathematically equivalent
to our original differential equation in the sense that that a potential distribution which
satisfies Laplaces equation will also minimise the energy, and vice versa.
where integration is carried out over a 2D region, and is thud taken per unit length/depth.
36
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
...
2 2
+ + + + + + = fy ex dxy cy bx a V
Consider a single element and the following approximating polynomial
We choose as many terms as there are nodes in the element:
First order triangle
Second order triangle
Rectangle
1
2
3
1
2
3
4
5
6
1
2
3
4
cy bx a V + + =
2 2
fy ex dxy cy bx a V + + + + + =
dxy cy bx a V + + + =
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
cy bx a V + + =
In the three vertices (nodes) the potential is
3 3 3
2 2 2
1 1 1
cy bx a V
cy bx a V
cy bx a V
+ + =
+ + =
+ + =
or
(
(
(
(
(
(
=
(
(
(
c
b
a
y x
y x
y x
V
V
V
3 3
2 2
1 1
3
2
1
1
1
1
and rearranging
(
(
(
(
(
(
=
(
(
(
3
2
1
1
3 3
2 2
1 1
1
1
1
V
V
V
y x
y x
y x
c
b
a
and substituting back yields:
 
(
(
(
(
(
(
3
2
1
1
3 3
2 2
1 1
1
1
1
1
V
V
V
y x
y x
y x
y x V
or ( )
=
=
3
1
,
i
i i
y x V V o
37
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
 
(
(
(
(
(
(
3
2
1
1
3 3
2 2
1 1
1
1
1
1
V
V
V
y x
y x
y x
y x V
( )
=
=
3
1
,
i
i i
y x V V o
where
( ) ( ) ( ) { } y x x x y y y x y x
A
2 3 3 2 2 3 3 2 1
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
3 1 1 3 3 1 1 3 2
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
1 2 2 1 1 2 2 1 3
2
1
+ + = o
where A is the element area
At the vertices:
( ) ( ) ( ) ( ) { } 1
2
2
2
1
,
1 2 3 1 3 2 2 3 3 2 1 1 1
= = + + =
A
A
y x x x y y y x y x
A
y x o
( ) ( ) ( ) ( ) { } 0
2
1
,
2 2 3 2 3 2 2 3 3 2 2 2 1
= + + = y x x x y y y x y x
A
y x o
( ) ( ) ( ) ( ) { } 0
2
1
,
3 2 3 3 3 2 2 3 3 2 3 3 1
= + + = y x x x y y y x y x
A
y x o
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
 
(
(
(
(
(
(
3
2
1
1
3 3
2 2
1 1
1
1
1
1
V
V
V
y x
y x
y x
y x V
( )
=
=
3
1
,
i
i i
y x V V o
where
( ) ( ) ( ) { } y x x x y y y x y x
A
2 3 3 2 2 3 3 2 1
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
3 1 1 3 3 1 1 3 2
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
1 2 2 1 1 2 2 1 3
2
1
+ + = o
where A is the element area
In general
( ) j i y x
j j i
= = 0 , o
j i = =1
x
y
1
2
3
1
1
Each function vanishes at all vertices but one,
where it assumes the value of one.
3
38
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
( )
=
=
3
1
,
i
i i
y x V V o
}
V =
e
e
dS V W
2
) (
2
1
c
We can now associate energy with each element,
and remembering that in 2D this energy will be
taken per unit length/depth we write
where integration is performed over the element area.
Using ( )
=
=
3
1
,
i
i i
y x V V o we find ( )
=
V = V
3
1
,
i
i i
y x V V o
so that the element energy becomes
j
i j
j
e
i i
e
V dS V W
}
= =


.

\

V V =
3
1
3
1
) (
2
1
o o c
which may be written in a compact form       V N V W
e T e ) ( ) (
2
1
c =
where [V] is the vector of vertex values of potential, the superscript T denotes transposition,
and the 33 square element matrix [N]
(e)
is defined by
dS N
j
e
i
e
j i
o o V V =
}
) (
,
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
( )
=
=
3
1
,
i
i i
y x V V o
dS N
j
e
i
e
j i
o o V V =
}
) (
,
      V N V W
e T e ) ( ) (
2
1
c =
( ) ( ) ( ) { } y x x x y y y x y x
A
2 3 3 2 2 3 3 2 1
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
3 1 1 3 3 1 1 3 2
2
1
+ + = o
( ) ( ) ( ) { } y x x x y y y x y x
A
1 2 2 1 1 2 2 1 3
2
1
+ + = o
( ) ( ) { } j i j i
2 3 3 2
1 1
1
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
( ) ( ) { } j i j i
3 1 1 3
2 2
2
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
( ) ( ) { } j i j i
1 2 2 1
3 3
3
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
39
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
( )
=
=
3
1
,
i
i i
y x V V o
dS N
j
e
i
e
j i
o o V V =
}
) (
,
      V N V W
e T e ) ( ) (
2
1
c =
( ) ( ) { } j i j i
2 3 3 2
1 1
1
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
( ) ( ) { } j i j i
3 1 1 3
2 2
2
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
( ) ( ) { } j i j i
1 2 2 1
3 3
3
2
1
x x y y
A y x
+ =
c
c
+
c
c
= V
o o
o
The scalar product of two vectors, say a and b,
in a Cartesian coordinate system in 2D:
( ) ( ) j i j i b a
y x y x
b b a a + + =
j j i j j i i i + + + =
y y x y y x x x
b a b a b a b a
y y x x
b a b a + =
( ) ( ) { }
2
2 3
2
3 2
) (
1 , 1
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 2 3 1 3 3 2
) (
2 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 2 3 2 1 3 2
) (
3 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 3 1 3 2 1 3
) (
1 , 2
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
3 1
2
1 3
) (
2 , 2
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 3 1 2 1 1 3
) (
3 , 2
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 1 2 3 2 2 1
) (
1 , 3
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 1 2 1 3 2 1
) (
2 , 3
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
1 2
2
2 1
) (
3 , 3
4
1
x x y y
A
N
e
+ =
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
( )
=
=
3
1
,
i
i i
y x V V o
      V N V W
e T e ) ( ) (
2
1
c =
( ) ( ) { }
2
2 3
2
3 2
) (
1 , 1
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 2 3 1 3 3 2
) (
2 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 2 3 2 1 3 2
) (
3 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 3 1 3 2 1 3
) (
1 , 2
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
3 1
2
1 3
) (
2 , 2
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 3 1 2 1 1 3
) (
3 , 2
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 1 2 3 2 2 1
) (
1 , 3
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 1 2 1 3 2 1
) (
2 , 3
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
1 2
2
2 1
) (
3 , 3
4
1
x x y y
A
N
e
+ =
This completes the specification for an
arbitrary element in the finiteelement mesh.
The total energy associated with the entire
region will be found as the sum of individual
element energies:
=
elements All
e
W W
) (
40
Computing and CAD II
Professor Jan K. Sykulski
The finite element method
First order triangular element
1
2
3
( )
=
=
3
1
,
i
i i
y x V V o
      V N V W
e T e ) ( ) (
2
1
c =
This completes the specification for an
arbitrary element in the finiteelement mesh.
The total energy associated with the entire
region will be found as the sum of individual
element energies:
=
elements All
e
W W
) (
When assembling elements we notice that
some nodes will be shared between elements.
The global matrix must reflect the way in
which individual elements are linked.
1
2
3
1
4
3
8
5
6
7
2
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
0 2
1
V = 0 V = 100
0 =
c
c
y
V
0 =
c
c
y
V
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Node
number
xcoordinate ycoordinate
Potential
1 1 0 ?
2 1 1 ?
3 2 1 100
4 0 1 0
5 2 0 100
6 0 0 0
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
41
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Node
number
xcoordinate ycoordinate
Potential
1 1 0 ?
2 1 1 ?
3 2 1 100
4 0 1 0
5 2 0 100
6 0 0 0
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
The element matrices may now be determined.
For each element we need the 33 matrix
based on the coordinates of the vertices and
the size of the element.
( ) ( ) { }
2
2 3
2
3 2
) (
1 , 1
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 2 3 1 3 3 2
) (
2 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 2 3 2 1 3 2
) (
3 , 1
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 3 1 3 2 1 3
) (
1 , 2
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
3 1
2
1 3
) (
2 , 2
4
1
x x y y
A
N
e
+ =
( )( ) ( )( ) { }
1 2 3 1 2 1 1 3
) (
3 , 2
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
2 3 1 2 3 2 2 1
) (
1 , 3
4
1
x x x x y y y y
A
N
e
+ =
( )( ) ( )( ) { }
3 1 1 2 1 3 2 1
) (
2 , 3
4
1
x x x x y y y y
A
N
e
+ =
( ) ( ) { }
2
1 2
2
2 1
) (
3 , 3
4
1
x x y y
A
N
e
+ =
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Node
number
xcoordinate ycoordinate
Potential
1 1 0 ?
2 1 1 ?
3 2 1 100
4 0 1 0
5 2 0 100
6 0 0 0
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
The element matrices may now be determined.
For example, for element A:
= =
= =
= =
0 1
1 1
1 0
2 1 1 2
1 3 3 1
3 2 2 3
y y x x
y y x x
y y x x
and the element area A=0.5.
42
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Node
number
xcoordinate ycoordinate
Potential
1 1 0 ?
2 1 1 ?
3 2 1 100
4 0 1 0
5 2 0 100
6 0 0 0
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
The element matrices may now be determined.
For example, for element A:
( ) ( ) { }
2
2 3
2
3 2
) (
1 , 1
4
1
x x y y
A
N
A
+ =
= =
= =
= =
0 1
1 1
1 0
2 1 1 2
1 3 3 1
3 2 2 3
y y x x
y y x x
y y x x
and the element
area A=0.5.
Thus:
( ) ( ) { }
2
1
0 1
2
1 2 2
= + =
( )( ) ( )( ) { }
3 1 2 3 1 3 3 2
) (
2 , 1
4
1
x x x x y y y y
A
N
A
+ =
( )( ) ( )( ) { }
2
1
1 0 1 1
2
1
= + =
and so on giving the matrix for element A as
 
( )
(
(
(
(
(
(
=
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
A
N
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Node
number
xcoordinate ycoordinate
Potential
1 1 0 ?
2 1 1 ?
3 2 1 100
4 0 1 0
5 2 0 100
6 0 0 0
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
This process needs to be repeated for each
element of the; however, careful inspection of
elements B, C and D reveals that, in our
example, all four elements matrices are the
same, i.e.:
This is of course a happy coincidence, or
rather a clever use of proportions and local
node numbering, to save some work.
In general the element matrices
are all different !
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
43
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
A global matrix may now be assembled.
Initially all entries are zero.
 
(
(
(
(
(
(
(
=
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 0 0 0 0 0
0 0 0 0 0 0
N
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
A global matrix may now be assembled.
For element A:
 
(
(
(
(
(
(
(
(
(
=
2
1
0 0 0 0
2
1
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0
2
1
2
1
2
1
0 0 0
2
1
1
N
 
( )
(
(
(
=
22 21 26
12 11 16
62 61 66
N N N
N N N
N N N
N
A
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
44
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
A global matrix may now be assembled.
For element B:
 
(
(
(
(
(
(
(
(
(
(
+
+
=
2
1
2
1
0
2
1
0 0
2
1
0 0 0 0 0 0
2
1
0 1 0
2
1
0
0 0 0 0 0 0
0 0
2
1
0
2
1
2
1
2
1
2
1
0 0 0
2
1
1
N
 
( )
(
(
(
=
22 24 26
42 44 46
62 64 66
N N N
N N N
N N N
N
B
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
A global matrix may now be assembled.
For element C:
 
(
(
(
(
(
(
(
(
(
(
(
+ +
+
=
2
1
2
1
0
2
1
0 0
2
1
0 0 0 0 0 0
2
1
0 1 0
2
1
0
0 0 0
2
1
2
1
0
0 0
2
1
2
1
1
2
1
2
1
2
1
2
1
2
1
0 0 0
2
1
2
1
2
1
1
N
 
( )
(
(
(
=
33 32 31
23 22 21
13 12 11
N N N
N N N
N N N
N
C
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
45
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
Element Vertex 1 Vertex 2 Vertex 3
A 6 1 2
B 6 4 2
C 1 2 3
D 1 5 3
A global matrix may now be assembled.
For element D:
 
(
(
(
(
(
(
(
(
(
(
(
(
+
+
+ +
+ +
=
2
1
2
1
0
2
1
0 0
2
1
0 1 0
2
1
0
2
1
2
1
0 1 0
2
1
0
0
2
1
0
2
1
2
1
2
1
0
0 0
2
1
2
1
1
2
1
2
1
2
1
2
1
2
1
2
1
0 0
2
1
2
1
2
1
2
1
1
N
 
( )
(
(
(
=
33 35 31
53 55 51
13 15 11
N N N
N N N
N N N
N
D
 
( )
 
( )
 
( )
 
( )
(
(
(
(
(
(
= = = =
2
1
2
1
0
2
1
1
2
1
0
2
1
2
1
D C B A
N N N N
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
 
(
(
(
(
(
(
(
=
1 0 5 . 0 0 0 5 . 0
0 1 0 5 . 0 0 5 . 0
5 . 0 0 1 0 5 . 0 0
0 5 . 0 0 1 5 . 0 0
0 0 5 . 0 5 . 0 2 1
5 . 0 5 . 0 0 0 1 2
N
 
(
(
(
(
(
(
(
(
(
(
(
(
+
+
+ +
+ +
=
2
1
2
1
0
2
1
0 0
2
1
0 1 0
2
1
0
2
1
2
1
0 1 0
2
1
0
0
2
1
0
2
1
2
1
2
1
0
0 0
2
1
2
1
1
2
1
2
1
2
1
2
1
2
1
2
1
0 0
2
1
2
1
2
1
2
1
1
N
46
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
 
(
(
(
(
(
(
(
=
1 0 5 . 0 0 0 5 . 0
0 1 0 5 . 0 0 5 . 0
5 . 0 0 1 0 5 . 0 0
0 5 . 0 0 1 5 . 0 0
0 0 5 . 0 5 . 0 2 1
5 . 0 5 . 0 0 0 1 2
N
To minimise the total energy we must differentiate
with respect to a typical value of V
k
and equate to
zero:
     V N V W
T
c
2
1
=
0 =
c
c
k
V
W
where k refers to node numbers in the global
numbering system. However, some nodes will
have a prescribed potential (e.g. on the
boundary) and we can differentiate only with
respect to free nodes.
  0
] [
] [
] [ ] [
] [ ] [
] [ ] [
] [
=
(
c
c
=
c
c
p
f
pp pf
fp ff
T
p
T
f
k f k
V
V
N N
N N
V V
V V
W
Differentiation with respect to the free potentials
results in the following matrix equation:
0
] [
] [ ] ] [ ] [ [
=
(
p
f fp ff
V
V N N
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
0
] [
] [ ] ] [ ] [ [
=
(
p
f fp ff
V
V N N
 
(
(
(
(
(
(
(
=
1 0 5 . 0 0 0 5 . 0
0 1 0 5 . 0 0 5 . 0
5 . 0 0 1 0 5 . 0 0
0 5 . 0 0 1 5 . 0 0
0 0 5 . 0 5 . 0 2 1
5 . 0 5 . 0 0 0 1 2
N
] ][ [ ] ][ [
p fp f ff
V N V N =
] ][ [ ] [ ] [
1
p fp ff f
V N N V
=
Formal solution:
In our example:
)
`
= +
=
50 2
50 2
2 1
2 1
V V
V V
50
2 1
= = V V
(
(
(
(
=
(
6
5
4
3
2
1
0 0 5 . 0 5 . 0
5 . 0 5 . 0 0 0
2 1
1 2
V
V
V
V
V
V
47
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
 
(
(
(
(
(
(
(
=
1 0 5 . 0 0 0 5 . 0
0 1 0 5 . 0 0 5 . 0
5 . 0 0 1 0 5 . 0 0
0 5 . 0 0 1 5 . 0 0
0 0 5 . 0 5 . 0 2 1
5 . 0 5 . 0 0 0 1 2
N
] ][ [ ] ][ [
p fp f ff
V N V N =
] ][ [ ] [ ] [
1
p fp ff f
V N N V
=
Final equation:
Formal solution:
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example
x
y
V = 0 V = 100
1 2
3
1
1
1
2
2
2 3
3
3
A
B
C
D
1
2
3 4
5 6
 
(
(
(
(
(
(
(
=
1 0 5 . 0 0 0 5 . 0
0 1 0 5 . 0 0 5 . 0
5 . 0 0 1 0 5 . 0 0
0 5 . 0 0 1 5 . 0 0
0 0 5 . 0 5 . 0 2 1
5 . 0 5 . 0 0 0 1 2
N
] ][ [ ] ][ [
p fp f ff
V N V N =
b x A =
Final equation:
This is in the form:
Comments:
[N
ff
] (or A) may be a very large matrix
b is given by sources (boundary conditions)
A is normally sparse (we cannot see this here)
A is often symmetrical
48
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example 2
Consider a topologically regular mesh:
1
2
3
4
5
21
22
23
24
25
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
All these meshes are topologically identical!
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example 2
1
2
3
4
5
1
21
22
23
24
25
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
The global matrix may be partitioned as follows:
(
(
(
=
] [ ] [ ] [
] [ ] [ ] [
] [ ] [ ] [
] [
pp pf pp
fp ff fp
pp pf pp
N N N
N N N
N N N
N
The [N
ff
] submatrix is of particular interest:
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
6 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0
13 0 0 0 0 0
14 0 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0
18 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0
20 0 0 0 0 0 0 0 0 0 0 0
49
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example 2
1
2
3
4
5
1
21
22
23
24
25
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
The nonzero elements may be numbered:
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
6 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0
13 0 0 0 0 0
14 0 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0
18 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0
20 0 0 0 0 0 0 0 0 0 0 0
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
15 27 45 53
14 26 35 44 52
13 25 34 43 51
12 24 33 42 50
11 32 41
10 23 40 49
9 22 31 39 48
8 21 30 38 47
7 20 29 37 46
6 28 36
5 19
4 18
3 17
2 16
1
The matrix is symmetrical.
Only 53 values need to be stored
(instead of 1515=225)
Computing and CAD II
Professor Jan K. Sykulski
The finite element method Example 2
1
2
3
4
5
1
21
22
23
24
25
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
The nonzero elements may be numbered:
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
15 27 45 53
14 26 35 44 52
13 25 34 43 51
12 24 33 42 50
11 32 41
10 23 40 49
9 22 31 39 48
8 21 30 38 47
7 20 29 37 46
6 28 36
5 19
4 18
3 17
2 16
1
For example:
(
27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
(
(
(
(
(
(
(
(
(
(
(
(
(
45 53
35 44 52
34 43 51
33 42 50
32 41
40 49
31 39 48
30 38 47
29 37 46
28 36
+
60 values stored rather than 1515=225.
50
Computing and CAD II
Professor Jan K. Sykulski
The art of sparse matrices Example
1
2
3
4
5
6
7
8
9
The matrix:
Due to symmetry, half of this 99 matrix needs to be stored and there are 25 nonzero elements.
A simple storage scheme places the nonzero elements in a linear array and complements this
array with two integer arrays which store the corresponding row and column numbers.
11 21 51 22 32 42 52 33 43 44 54 74 84 55 65 75 66 76 96 77 87 97 88 98 99
1 2 5 2 3 4 5 3 4 4 5 7 8 5 6 7 6 7 9 7 8 9 8 9 9
1 1 1 2 2 2 2 3 3 4 4 4 4 5 5 5 6 6 6 7 7 7 8 8 9
elements
row
column
11 21 51 22 32 42 52 33 43 44 54 74 84 55 65 75 66 76 96 77 87 97 88 98 99
1 2 5 2 3 4 5 3 4 4 5 7 8 5 6 7 6 7 9 7 8 9 8 9 9
elements
row
1 4 8 10 14 17 20 23 25 pointers identifying the beginning points of columns.
(
(
(
(
(
(
(
(
(
(
(
(
99 98 97 96
88 87 84
77 76 75 74
66 65
55 54 52 51
44 43 42
33 32
22 21
11
Computing and CAD II
Professor Jan K. Sykulski
The art of sparse matrices Example
1
2
3
4
5
6
7
8
9
The matrix:
A profile storage scheme:
11 21 22 32 33 42 43 44 51 52 . 54 55 65 66 74 75 76 77 84 . . 87 88 96 97 98 99
1 1 2 2 1 5 4 4 6
1 3 5 8 13 15 19 24 28
column number of the beginning of each row.
the diagonal element which forms the end of each row.
Strictly speaking the second integer array is not necessary as the ending of a row is always
on the main diagonal. However, the addressing functions become much more complicated.
(
(
(
(
(
(
(
(
(
(
(
(
99 98 97 96
88 87 84
77 76 75 74
66 65
55 54 52 51
44 43 42
33 32
22 21
11
51
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b
All numerical schemes (except TAS) lead to Ax = b
FD and FE formulations result in very large systems of equations
The A matrix is very sparse
A is often symmetrical
Efficient storage systems are required
Fast and accurate computation is needed
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Elimination method
Gaussian elimination:
( )
add and 3
1
( )
add and 3
2
2 2 2
11 3 2
12 2 3
3 2 1
3 2 1
3 2 1
=
= + +
= +
x x x
x x x
x x x
add and 7
4
18 7 4
21 7 7
12 2 3
3 2
3 2
3 2 1
=
= +
= +
x x
x x
x x x
Forward elimination
2
3
= x
1
2
= x
42 21
21 7 7
12 2 3
3
3 2
3 2 1
=
= +
= +
x
x x
x x x 3
1
= x
Backward substitution
Two steps:
1
2
52
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Elimination method
Gaussian elimination in matrix notation:
(
(
(
=
(
(
(
(
(
(
2
11
12
1 2 2
3 2 1
2 1 3
3
2
1
x
x
x
Compose an
augmented matrix
and apply elementary
raw transformations:
Elementary Row and Column operations (transformations):
1. Interchanging two rows or columns,
2. Adding a multiple of one row or column to another,
3. Multiplying any row or column by a nonzero element.
(
(
(
=
2 1 2 2
11 3 2 1
12 2 1 3
: b A
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Elimination method
Gaussian elimination in matrix notation:
(
(
(
=
(
(
(
(
(
(
2
11
12
1 2 2
3 2 1
2 1 3
3
2
1
x
x
x
Compose an
augmented matrix
and apply elementary
raw transformations:
(
(
(
=
2 1 2 2
11 3 2 1
12 2 1 3
: b A
(
(
(
2 1 2 2
11 3 2 1
12 2 1 3
(
(
(
18 7 4 0
21 7 7 0
12 2 1 3
(
(
(
42 21 0 0
21 7 7 0
12 2 1 3
1 3
1 2
) 2 ( 3
) 1 ( 3
R R
R R
+
+
2 3
4 7 R R +
(
(
42 21 0 0
21 0 21 0
168 0 21 63
(
(
42 21 0 0
21 0 21 0
189 0 0 63
(
(
2 1 0 0
1 0 1 0
3 0 0 1
2 3
1 3
3
21 2
R R
R R
+
+
1 2
R R +
21 / 1
21 / 1
63 / 1
(
(
=
2
1
3
x Hence:
53
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Elimination method
(
(
(
2 1 2 2
11 3 2 1
12 2 1 3
(
(
(
18 7 4 0
21 7 7 0
12 2 1 3
(
(
(
42 21 0 0
21 7 7 0
12 2 1 3
1 3
1 2
) 2 ( 3
) 1 ( 3
R R
R R
+
+
2 3
4 7 R R +
(
(
42 21 0 0
21 0 21 0
168 0 21 63
(
(
42 21 0 0
21 0 21 0
189 0 0 63
2 3
1 3
3
21 2
R R
R R
+
+
1 2
R R +
21 / 1
21 / 1
63 / 1
(
(
2 1 0 0
1 0 1 0
3 0 0 1
Forward elimination
Backward substitution
Notes:
watch for zeros on the diagonal interchanging rows
multiplications lead to very large numbers subtract R
1
a
i1
/a
11
from R
i
, etc
rearrange equations so that largest coefficient is on diagonal at each step pivoting
scaling dividing each row by the magnitude of the largest coefficient
so that all coefficients have the same order of magnitude reduce roundoff errors
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b
Elimination method
Steps:
1. Augment nn matrix into n(n+1) matrix and scale.
2. Change rows so that a11 has the largest magnitude.
3. Subtract R
1
a
i1
/a
11
from rows 2 to n.
4. Repeat 2 and 3 for subsequent rows:
R
j
a
ij
/a
jj
for rows i=j+1 to n.
5. Solve x
n
=b
n
/a
nn
6. Solve x
n1
, x
n2
, x
n3
x
2
, x
1
where
(
(
(
(
=
(
(
(
(
(
(
(
(
n n nn n n
n
n
b
b
b
x
x
x
a a a
a a a
a a a
2
1
2
1
2 1
2 22 21
1 12 11
(
(
(
(
n nn n n
n
n
b a a a
b a a a
b a a a
2 1
2 2 22 21
1 1 12 11
(
(
(
(
n nn
n
n
b a
b a a
b a a a
' ' 0 0
' ' ' 0
' ' ' '
2 2 22
1 1 12 11



.

\

=
+ =
n
i j
j ij i
ii
i
x a b
a
x
1
' '
'
1
54
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b A = LU
Triangular decomposition
(
(
(
(
(
(
(
(
=
(
(
(
(
1 0 0
1 0
1
0
0 0
2
1 12
2 1
22 21
11
2 1
2 22 21
1 12 11
n
n
nn n n nn n n
n
n
u
u u
l l l
l l
l
a a a
a a a
a a a
LU A =
(
(
(
(
nn n n
n
n
l l l
u l l
u u l
2 1
2 22 21
1 12 11
1
2
=
= s
=
1
1
, ... , 2 , 1 ,
j
k
n i i j kj ik ij ij
u l a l
n j j i
l
u l a
u
ii
i
k
kj ik ij
ij
, ... , 3 , 2 ,
1
1
= >
=
1 1
1
i i
a l j For = =
11
1
11
1
1
1
a
a
l
a
u i For
j j
j
= = =
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b A = LU
Triangular decomposition
(
(
(
(
(
(
(
(
=
(
(
(
(
1 0 0
1 0
1
0
0 0
2
1 12
2 1
22 21
11
2 1
2 22 21
1 12 11
n
n
nn n n nn n n
n
n
u
u u
l l l
l l
l
a a a
a a a
a a a
LU A =
(
(
(
(
nn n n
n
n
l l l
u l l
u u l
2 1
2 22 21
1 12 11
=
= s
=
1
1
, ... , 2 , 1 ,
j
k
n i i j kj ik ij ij
u l a l
n j j i
l
u l a
u
ii
i
k
kj ik ij
ij
, ... , 3 , 2 ,
1
1
= >
=
The RHS ( of Ax = b ):
n i
l
b l b
b
l
b
b
ii
i
k
k ik i
i
, ... , 3 , 2 ,
'
' '
1
1
11
1
1
=
= =
=
Backward substitution:
+ =
= =
=
n
j k
k jk j j
n n
n n j b u b x
b x
1
1 , ... , 2 , 1 ' '
'
55
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Triangular decomposition
b Ax =
(
(
(
=
1 2 2
3 2 1
2 1 3
A
(
(
(
=
2
11
12
b
(
(
(
(
(
(
=
1 0 0
1 1 0
3 / 2 3 / 1 1
1 3 / 4 2
0 3 / 7 1
0 0 3
=
= s
=
1
1
, ... , 2 , 1 ,
j
k
n i i j kj ik ij ij
u l a l
n j j i
l
u l a
u
ii
i
k
kj ik ij
ij
, ... , 3 , 2 ,
1
1
= >
=
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Triangular decomposition
b Ax =
(
(
(
=
1 2 2
3 2 1
2 1 3
A
(
(
(
=
2
11
12
b
(
(
(
(
(
(
=
1 0 0
1 1 0
3 / 2 3 / 1 1
1 3 / 4 2
0 3 / 7 1
0 0 3
(
(
(
=
2
3
4
' b
n i
l
b l b
b
l
b
b
ii
i
k
k ik i
i
, ... , 3 , 2 ,
'
' '
1
1
11
1
1
=
= =
=
56
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Triangular decomposition
b Ax =
(
(
(
=
1 2 2
3 2 1
2 1 3
A
(
(
(
=
2
11
12
b
(
(
(
(
(
(
=
1 0 0
1 1 0
3 / 2 3 / 1 1
1 3 / 4 2
0 3 / 7 1
0 0 3
(
(
(
=
2
3
4
' b
(
(
(
2 1 0 0
3 1 1 0
4 3 / 2 3 / 1 1 ( ) ( )
2
1 2 1 3 1 3
3 1 3 / 1 2 3 / 2 4 3 / 1 3 / 2 4
3
3 2
2 3 1
=
= = =
= = =
x
x x
x x x
Augmenting b to U gives:
Getting b is in fact:
(
(
(
=
2 1 3 / 4 2
11 0 3 / 7 1
12 0 0 3
: b L
and forward substitution yields:
( ) ( ) ( ) ( )
( ) { } ( ) 2 1 / 3 3 / 4 4 2 2 '
3 3 / 7 / 4 1 11 3 / 7 / ' 1 11 '
4 3 / 12 '
3
1 2
1
= =
= = =
= =
b
b b
b
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Triangular decomposition
b Ax =
(
(
(
=
1 2 2
3 2 1
2 1 3
A
(
(
(
=
2
11
12
b
(
(
(
(
(
(
=
1 0 0
1 1 0
3 / 2 3 / 1 1
1 3 / 4 2
0 3 / 7 1
0 0 3
(
(
(
=
2
3
4
' b
(
(
(
2 1 0 0
3 1 1 0
4 3 / 2 3 / 1 1 ( ) ( )
2
1 2 1 3 1 3
3 1 3 / 1 2 3 / 2 4 3 / 1 3 / 2 4
3
3 2
2 3 1
=
= = =
= = =
x
x x
x x x
(
(
(
=
2 1 3 / 4 2
11 0 3 / 7 1
12 0 0 3
: b L ( ) ( ) ( ) ( )
( ) { } ( ) 2 1 / 3 3 / 4 4 2 2 '
3 3 / 7 / 4 1 11 3 / 7 / ' 1 11 '
4 3 / 12 '
3
1 2
1
= =
= = =
= =
b
b b
b
Forward substitution
Backward substitution
57
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Example
Triangular decomposition
b Ax =
(
(
(
=
1 2 2
3 2 1
2 1 3
A
(
(
(
=
2
11
12
b
(
(
(
(
(
(
=
1 0 0
1 1 0
3 / 2 3 / 1 1
1 3 / 4 2
0 3 / 7 1
0 0 3
(
(
(
=
2
3
4
' b
(
(
(
=
2 1 0 0
3 1 1 0
4 3 / 2 3 / 1 1
' : b U
( ) ( )
2
1 2 1 3 1 3
3 1 3 / 1 2 3 / 2 4 3 / 1 3 / 2 4
3
3 2
2 3 1
=
= = =
= = =
x
x x
x x x
(
(
(
=
2 1 3 / 4 2
11 0 3 / 7 1
12 0 0 3
: b L ( ) ( ) ( ) ( )
( ) { } ( ) 2 1 / 3 3 / 4 4 2 2 '
3 3 / 7 / 4 1 11 3 / 7 / ' 1 11 '
4 3 / 12 '
3
1 2
1
= =
= = =
= =
b
b b
b
b x LU x A = =
First find b from Lb=b by forward substitution, then
Compute x from Ux=b by backward substitution
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b
Cholesky decomposition
If matrix A is symmetric : a
ij
= a
ji
and positive definite :
T
A > 0 for all vectors
(in other words A has all positive eigenvalues)
then a Cholesky decomposition (which is twice as fast a LU) gives:
T
LL A =
=
=
1
1
2
i
k
ik ii ii
L a L
N i i j L L a
L
L
i
k
jk ik ij
ii
ji
, ... , 2 , 1
1
1
1
+ + =


.

\

=
=
Cholesky decomposition is extremely stable numerically, even without any pivoting.
58
Computing and CAD II
Professor Jan K. Sykulski
Errors Example
Consider
(
=
(
2
2
01 . 1 99 . 0
99 . 0 01 . 1
y
x
with obvious solution x = 1
y = 1
Graphically:
x
x
y
y
?
Ill conditioned problems
Computing and CAD II
Professor Jan K. Sykulski
Errors Example 2
Consider
(
(
(
=
(
(
(
(
(
(
66 . 2
35 . 2
880 . 0
47 . 1 54 . 0 83 . 0
78 . 1 56 . 0 33 . 4
53 . 2 05 . 1 02 . 3
3
2
1
x
x
x
with a solution
(
(
(
=
1
2
1
x
Gaussian elimination, using pivoting and three digits rounded gives:
(
(
(
00962 . 0 00362 . 0 0 0
65 . 6 77 . 3 44 . 1 0
23 . 7 78 . 1 56 . 0 33 . 4
(
(
(
=
66 . 2
35 . 2
880 . 0
x
?
59
Computing and CAD II
Professor Jan K. Sykulski
Errors Example 3
Consider
(
=
(
1440 . 0
8642 . 0
1441 . 0 2161 . 0
8646 . 0 2969 . 1
2
1
x
x
Let
(
=
4870 . 0
9911 . 0
x
be assumed to be a possible solution.
Calculate a residual vector:
(
= =
8
8
10
10
x A b r
The actual solution is:
(
=
2
2
x
and not a single figure in is meaningful! x
The size of the residual vector may not be a sufficient indication of the error in x !
Computing and CAD II
Professor Jan K. Sykulski
Matrix and vector norms
A norm is a measure of the magnitude (not size !) of a matrix.
A norm must satisfy the following conditions:
B A AB
B A B A
A k kA
A if only and if A and A
s
+ s +
=
= = >
. 4
. 3
. 2
0 0 0 . 1
Errors Norms
=
s s
=
n
j
ij
n i
a A
1
1
max
2 / 1
1 1
2



.

\

=
= =
m
i
n
j
ij
e
a A
For example
maximum rowsum norm
Euclidean norm
Example
(
(
(
5 4 7
4 2 4
7 4 5
16 =
A
69 . 14 =
e
A
60
Computing and CAD II
Professor Jan K. Sykulski
Condition numbers
Errors Condition numbers
( )
1
= A A A cond
Let and where is an error and is an approximate solution. b Ax = x x e = e x
A residual may be defined as x A b r =
It can be shown that ( )
b
r
A cond
x
e
s
The relative error can be as great as the relative residual times the condition number!
Let (where ). E A A + = b x A =
It can be shown that ( )
A
E
A cond
x
e
s
The error can be as large as relative errors in coefficients of A times the condition number!
What can we do? estimate condition number (e.g. LINPACK estimate)
improve the solution through iterative refinement
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Iterative methods
Gauss Seidel iteration
1. Rearrange the rows so that diagonal elements are dominating
2. Assume initial vector of solution
3. Apply
( )
+ =
=
+ +
=
N
i j
k
j
ii
ij
i
j
k
j
ii
ij
ii
i k
i
x
a
a
x
a
a
a
b
x
1
) (
1
1
) 1 ( 1
SOR iteration
( )
2 1
1
) (
1
1
) 1 ( ) ( 1
< s
+ =
=
=
+ +
o o where x a x a b
a
x x
N
i j
k
j ij
i
j
k
j ij i
ii
k
i
k
i
Example:
(
(
(
(
=
(
(
(
(
=
(
(
(
(
1
1
1
1
1
1
1
1
4 1 1 1
1 4 1 1
1 1 4 1
1 1 1 4
x giving x
1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
No of iterations
Error < 10
5
24 18 13 11
min
14 18 24 35 55 100
61
Computing and CAD II
Professor Jan K. Sykulski
x
y
V = 100 V
V = 100 V
V = 0
V = 0
y
x
0 =
c
c
x
V
0 =
c
c
y
V
Solving Ax = b SOR
1. Gauss Seidel iterations
( = 1)
2. SOR with
opt
= 1.885
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b SOR
= 1
opt
= 1.885
Iteration count: 4
62
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b SOR
= 1
opt
= 1.885
Prescribed accuracy achieved
in 106 iterations.
Iteration count: 106
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b SOR
= 1
opt
= 1.885
Iteration count: 690
Prescribed accuracy achieved
in 106 iterations.
Prescribed accuracy achieved
in 690 iterations.
63
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b SOR
Assume a linear initial solution: Final solution:
Prescribed accuracy achieved
in 51 iterations
(instead of 106 when a zero
solution was initially used).
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b SOR
Assume a linear initial solution: Final solution:
5 iterations needed to keep the local error below 1%
24 iterations needed to keep the local error below 0.2%
51 iterations needed to keep the local error below 0.05%
81 iterations needed to keep the local error below 0.01%
64
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Conjugate Gradient Method
Conjugate Gradient Method
Minimise which leads to a condition: ( ) b x x A x x
T T
f =
2
1
0 = = V b x A f
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Conjugate Gradient Method
Conjugate Gradient Method
Minimise which leads to a condition: ( ) b x x A x x
T T
f =
2
1
0 = = V b x A f
65
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Conjugate Gradient Method
Conjugate Gradient Method
Minimise which leads to a condition: ( ) b x x A x x
T T
f =
2
1
0 = = V b x A f
Computing and CAD II
Professor Jan K. Sykulski
Solving Ax = b Comparison of methods
Incomplete Cholesky Conjugate Gradient (ICCG) Method
Comparison of methods
Test problem:
If the coefficient matrix is symmetric, positive definite and sparse:
incomplete Cholesky preconditioning
conjugate gradient iterative solution
Poissons equation over a unit square
uniform mesh of first order triangles with n points
n
nodes
m
bandwidth
Gauss
elimination
Gauss
Seidel
SOR ICCG
m
2
n mniter n logn
operation
count (time)
36 8 1 2 1 1
time in
arbitrary
units
441 23 33 619 123 28
961 33 152  536 70
66
Computing and CAD II
Professor Jan K. Sykulski
A typical CAD system for electromagnetics
Preprocessor
Geometrical data
Material properties
Excitation sources
Boundary conditions
Mesh
Solver
Ax=b
Postprocessor
Field plots, forces,
stored energy,
losses, errors, etc
Data
files
Results
files
CAD
Designer
From design system Model
Back to design system Solution
Computing and CAD II
Professor Jan K. Sykulski
Coin
recognition
sensor
67
Computing and CAD II
Professor Jan K. Sykulski
Multiphysics problems
The current and resultant Joule heating in an electric switch contact
are modelled as the switch is actuated. Mechanical, thermal and
current flow are modelled using direct coupled field elements.
Computing and CAD II
Professor Jan K. Sykulski
Optimization techniques
Deterministic Stochastic
Always follows same
path from same initial
conditions
Finds local minimum
Fast: 5 to 100 evaluations
Initial conditions do not
determine path of
optimization
Attempt to find global
minimum
Slow: hundreds or thousands
of evaluations
68
Computing and CAD II
Professor Jan K. Sykulski
Local
Global
Start
Optimization techniques
Deterministic Stochastic
Global
Local
Computing and CAD II
Professor Jan K. Sykulski
Optimization techniques
Deterministic Stochastic
Direct
Search
Indirect
Search
Simulated
annealing
Evolution
strategy
Rosenbrocks
method
Pattern
search
Simplex
method
Powells
conjugate
direction
...
Steepest decent
Newtons method
Variablemetric
procedure
Conjugate
gradient
Trust region
method
...
69
Computing and CAD II
Professor Jan K. Sykulski
Singleminimum objective function
Optimization
Computing and CAD II
Professor Jan K. Sykulski
Optimization
Multipleminima objective function
70
Computing and CAD II
Professor Jan K. Sykulski
Ccore shaped magnet
( )
1
0 0
35 1
=
= B B B max F
i
, i
C
DE Differential Evolution
ES Evolution Strategy
GBA Gradient Based Method
Method Starting Optimum n
DE1 9 random 0.0803 720
DE2 13 random 0.0704 881
ES 0.7532 / 0.4344 / 0.6411 0.0642 450
GBA 0.7532 0.0855 188
ES/DE/MQ 0.7532 0.0718 118
Computing and CAD II
Professor Jan K. Sykulski
Magnetiser
( )
=
=
59
1
2
, ,
B B
k
k calculated k desired
f
( ) k
o
k desired
= 90 sin B B
max ,
59 1 s s k
Method Starting Optimum n
DE1 11 random 1.235E5 987
DE2 11 random 5.423E5 1035
ES 1.457E3 1.187E5 433
ES 9.486E2 1.318E4 351
GBA 1.457E3 1.238E4 41
GBA 9.486E2 2.433E4 281
ES/DE/MQ 1.457E3 1.961E5 234
ES/DE/MQ 9.486E2 2.125E5 206
NF/GA/SQP 6.570E5 189
Unconstrained optimisation
Method Optimum N
ES/DE/MQ 1.58E5 246
NF/GA/SQP 4.65E5 155
Constrained optimisation
NF NeuroFuzzy modelling
GA Genetic Algorithm
SQP Sequential Quadratic Programming
71
Computing and CAD II
Professor Jan K. Sykulski
Yoke
Magnet Pole piece
Optimized shimming magnet distribution of MRI system
Simplified axisymmetric model
3 mm
15 mm
Shimming magnet (Br=0.222 T)
n
s
i
zo zi
p P y x B B F ) ( ) , ( ) ( ,
2
45
1
M M = =
=
Objective function:
Computing and CAD II
Professor Jan K. Sykulski
+Ms Ms
Changes of shimming magnet distribution
during optimisation
Convergence
Flux distributions
1 iteration
10 iterations
3 iterations
3 iterations
72
Computing and CAD II
Professor Jan K. Sykulski
Pareto Optimisation
F
1
F
2
UTOPIA
NADIR
DISTOPIA
Objective
domain
search
space
POF Pareto Optimal Front
POF
F
2
max
F
2
min
F
1
min
F
1
max
Computing and CAD II
Professor Jan K. Sykulski
Designer
Company design sheets and prior
knowledge
Optimisation and design
programs
Experts on finite element analysis
73
Computing and CAD II
Professor Jan K. Sykulski
Input data
Output data
Materials
library
Induction Motor
Design Routines
FE
software
Optimisation
Analytical & Control Software
Industrially
oriented system
for induction
motor design
MATLAB
FE software
Excel
Computing and CAD II
Professor Jan K. Sykulski
Hierarchical (threelayer) structure
Knowledge base
Approximate solutions
(e.g. equivalent circuits, semiempirical, design sheets)
Extensive optimisation
Large design space
2D finite element, static or steadystate
Constrained optimisation, coupling
Medium design space
3D finiteelement, transient
Fine tuning of the design
Small design space
74
Computing and CAD II
Professor Jan K. Sykulski
Current and future developments
adaptive meshing
reliable error estimation
high speed computing
efficient handling of nonlinearity and hysteresis
modelling of new types of materials
linear movement and rotation
combined modelling of fields and circuits
coupled problems (em + stress + temperature, etc)
optimisation
integrated design systems
...
Significant progress has been made
Tremendous effort continues
Much still needs to be done
Computing and CAD II
Professor Jan K. Sykulski
Commercial software