|
.
|
\
|
=
|
.
|
\
|
=
= =
}
t
t
t
t
u u
t
t ~ 2
Lengthof needle
Distance between parallel lines
Number of tosses
Number crossing parallel lines
Or, if the length of the needle
is the same as the line spacing (L=W):
t ~ 2
Number of tosses
Number crossing parallel lines
www.efg2.com/Lab/Mathemetics/Buffon.htm
You can try it online:
So what?
This is an example of a stochastic
simulation used to derive a physical
quantity of interest!
Our model was based upon randomly
throwing needles around equally
spaced lines.
Stochastic simulation is sometimes
called Monte Carlo Simulation.
Monte Carlo Method
The term
Monte Carlo
was introduced
by von
Neumann and
Ulam during
World War II,
as a code word
for secret work
at Los Alamos.
1940
Monte Carlo: The city of Monte Carlo in Monaco was
(and still is) well known for its gambling casinos.
To pi or not to pi
We already looked at one way
to use Monte Carlo (or, using
an acronym, MC) to determine
the value of .
Given a cork board, a marker
and an infinite number of
darts, you can determine the
value of a different way.
1. Draw a square
2. Inscribe a circle
3. Throw darts randomly
D
A
c
= D
2
/4
A
s
= D
2
D
D
They have the same D.
If you multiply the area of the square
by /4, you get the area of the circle,
or in other words:
The ratio of the area of the circle to
the area of the square is /4!
So, to calculate , you simply need to
multiply the ratio of the area of the
circle to that of the square by 4.
square of Area
circle of Area
4 = t
Number in red area = 10
Number in blue area = 35
Solution
The number of darts hitting an area, if
thrown randomly, will be representative of
the area of the figure (in effect, an
estimate of a 2D integral)
As the number of darts approaches
infinity, all space will be occupied
Area of square = 10+35 = 45
Area of circle = 35
111 . 3
45
35
4
square of Area
circle of Area
4 = ~ = t
First Step to MATLAB Solution
Pseudo-code:
Pick random x and y values between
[0,1].
Is x
2
+y
2
less than or equal to 1? If
yes, score a hit.
Repeat the above steps a lot of times.
Calculate
pi = 4 times (hits)/(no. of trials)
In MATLAB
In MATLAB, you can generate a
pseudo-random number between 0
and 1 by using the command :
>>rand
Other programming languages, C/C++,
FORTRAN, etc. have ways to
generate random numbers.
Can we do this in
MATLAB?
% Matlab Program to Find Pi using Random Numbers
% and a circle inscribed in square
Nrand = input('How Many Random Numbers ');
NInside = 0;
for nloops=1:Nrand
Xrand = rand; % Generate Random XY Point
Yrand = rand;
Rrand = Xrand^2 + Yrand^2; % Find its distance from origin
if (Rrand <= 1)
NInside = NInside + 1;
end
end
disp(['Total Generated: ' num2str(Nrand) ' Inside Pts: ' ...
num2str(NInside)]);
piapprox = 4*NInside/Nrand;
disp([' Approximation to pi = ' num2str(piapprox)]);
rand The Fine Print:
Most computer routines for generating random
numbers are not really random at all! They are
actually deterministic!
The next random number is calculated from the
previous one using a single algorithm or formula.
The sequence of numbers appears to be somewhat
random and uniformly distributed over the range
[0,1], but in fact it would fail rigorous
mathematical analysis for randomness.
Referred to as pseudo-random because the
numbers only appear to be random.
rand The Fine Print:
Using the same seed (starting value)
repeatedly will generate the exact
same sequence of numbers.
Eventually, the series of numbers will
also repeat!
You can work around this (somewhat)
by using different values as the seed,
such as a number based on current
clock time, and by not using so many
numbers that the series repeats
itself.
Truly Random Numbers
For truly random numbers, some
random physical process must be
sampled.
Typically this is done by using special
hardware to sample a quantum
phenomenon.
Sampling atmospheric white noise by
connecting sound cards to AM radios
tuned to frequencies free of broadcasts.
Timing successive pairs of radioactive
decays detected by a Geiger-Mller tube
More MC Examples
Process Simulation, Operational Research, Industrial
Engineering
Queues
Assembly lines
Road traffic flow optimization
Evacuation of buildings, venues, disaster areas
Analysis of WTC 9/11 evacuation
Grocery store shopping
Golf course operation
Financial applications:
Stocks, options pricing
project planning: risk analysis.
Computer graphics rendering using ray tracing
techniques
Other MC Examples
Geophysics
plate tectonics, earthquakes, lava flows
Weather, hurricane track prediction, storm damage
prediction
Internet operation
packet transfers, collisions, routes
worm and virus propagation
Search & Rescue
planning a search area and search pattern
Solving multi-dimensional definite integrals
efficiency of stochastic methods over deterministic
methods increases as dimensions increase in number
ASSIGNMENT!
Integration using MC
| | b a x
x f
n
a b
dx x f
i
n
i
i
b
a
,
) (
) (
) (
1
e
~
}
=
where n values for x
i
are randomly picked such that
Larger n -> better approximation
Use random numbers in range [a,b] to sample the
function at many values and take their average
(the average height of the function) and multiply
by the width of the sample region, b-a.
Integration using MC
| |
.
.
,
) , ,... , , (
1
) (
) ,..., , , (
1
3 2 1
1
1 2 3 3 2 1
1
1 1
2
2 2
3
3 3
times n repeated is This
function the of i evaluation each for
picked randomly are b a x values K where
x x x x f
n
a b
dx dx dx dx x x x x f
k k ki
Ki
n
i
i i i
K
k
k k
b
a x
K
b
a x
K
b
a x
b
a x
K
K K
e
~
[
} } } }
= =
= = = =
Can be applied to K-dimensional integrals, and is faster than
any other known method if K>5
What was von Neumanns
secret work?
Direct simulation of neutron diffusion in
fissionable material
n
Not long after WW II, Monte Carlo methods were also
used to evaluate complex multidimensional integrals and
to solve certain integral equations occurring in physics
that were not amenable to analytical solution
The Monte Carlo technique applied to particle
transport actually follows each of many trial
particles from a source throughout its life to its
death in some terminal category (absorption,
escape, etc.).
The individual probabilistic events that comprise a
process are simulated sequentially.
Probability distributions based on transport data
are randomly sampled to determine the outcome at
each step.
The Life and Death of a Particle
This diagram represents the random event history of a
neutron incident on a slab of material that is fissionable.
Numbers between 0 and 1 are selected randomly to
determine what (if any) and where an event takes place,
based on the rules (physics) and probabilities (transport data)
governing the processes and materials involved.
A neutron collision occurs at
event 1. The neutron is
scattered in the direction
shown, which is selected
randomly from the physical
scattering distribution. A photon
is also produced and is
temporarily stored, or banked,
for later analysis.
At event 2, fission occurs,
resulting in the termination of
the incoming neutron and the
birth of two outgoing neutrons
and one photon. One neutron
and the photon are banked for
later analysis.
The first fission neutron is
captured at event 3 and
terminated.
The banked neutron is now
retrieved and, by random
sampling, leaks out of the slab at
event 4.
The fission-produced photon has
a collision at event 5 and leaks
out at event 6.
The remaining photon generated
at event 1 is now followed with a
capture at event 7.
This is only one possible sequence!
Many must be tried to build up the
required data.
What are we trying to
solve?
In the case of radiation transport,
the Boltzmann Transport Equation.
Examine different reactions that can
occur, and make sure all events are
accounted for.
Basically, it is a particle balance (analogous to
conservation of mass or conservation of energy in classical
engineering problems)
n r,V, t
( )
= particle density function
=
# particles
volume
at position r,velocity V, and time t
Boltzmann Transport
Equation
a conservation of neutrons equation
cn r,V, t
( )
ct
= VVn r,V, t
( )
VE
total
r,V
( )
n r,V, t
( )
+ V
}
' E
scatter
r,V';V, t
( )
n r,V' t
( )
dV'
+v V' E
fission
r,V';V, t
( )
n r,V' t
( )
dV'
}
+Q r,V, t
( )
creation from scatter
creation from fission
fixed source creation
leave or enter
destroyed (absorption)
Geometry
X
i
X
i+1
d
i
u
i
d
i
is the distance traveled
between successive collisions
E
i
E
i+1
X
i+2
E
i+2
u
i+1
d
i+1
E
i
the energy of the
neutron after a collision
not resulting in absorption
The number of particles of energy E penetrating
to depth d out of N
0
trials is given as
d
e N N
E
=
0
And therefore the probability of
penetration to depth d is
( )
d
e
trials of number
d to g penetratin number
d P
E
=
And therefore the probability of
particle interaction at some path length < d (i.e.
particle did NOT interact until d) is
( )
d
e d P
E
=1
So, assigning a random number associated with the
distance travelled to the next interaction, p
d
,
bounded [0,1] equal to P(d), we get
p
d
=1e
E d
Now, we solve for d
d =
1
E
ln 1 p
d
( )
1
E
ln p
d
( )
Note: This is true because 1-p
d
is
distributed the same as p
d
=
t
(E) is referred to as a cross-section, or
probability of ANY interaction (note it is energy
dependent! More on cross sections later)
d
X
i+1
X
i
u
cosu =
X
i+1
X
i
d
X
i+1
= X
i
+ d cosu
Solve for X
i+1
If it is still inside the slab, then we
will have to continue to track where
the particle goes next. Otherwise,
we can assume the particle is lost,
and start a new particle.
The energy of the particle after a collision must be
calculated, because the probability of the next
interaction depends on it. Assume elastic, isotropic
scattering.
The energy of the outgoing particle can lie anywhere
from the energy of the incident particle E
i
to the
minimum possible energy oE
i
, depending on the
change in angle due to the collision, and the mass of
the target.
Change in direction of 0 -> no change in energy
Change in direction of 180 -> maximum change in
energy.
E,p
E,p
Incident
neutron
Scattered
neutron
Target
nucleus
Recoil
nucleus
E
A
,P
Neutron Kinematics
Energy Momentum
Energy Equations
A
E E E + = '
m
p
E
2
2
=
For perfectly elastic collisions, the energy equation is
From classical mechanics, we know
Therefore:
M
P
m
p
m
p
2 2
'
2
2 2 2
+ = Equation (1)
Note: this p is momentum!
Conservation of Momentum
p
p
P
p
p
P
Using the law of cosines from trigonometry:
P
2
=p
2+
p
2
+-2ppcos
Equation (2)
Now you can plug in the values of momentum and re-write
mE p or mE p or
m
p
E 2 2
2
2
2
= = =
Note: this p is momentum!
P
2
=p
2+
p
2
+-2ppcos
2ME
A
( )
2
= 2mE
( )
2
+ 2mE
'
( )
2
2 2mE 2mE
'
cosu
2ME
A
= 2mE + 2mE
'
2m EE
'
cosu
Divide by 2m Note: M/m ~ A for neutrons
AE
A
= E + E
'
2 EE
'
cosu
Recall that E
A
=E-E
A E E
'
( )
= E + E
'
2 EE
'
cosu
( )
( ) ( )
( ) ( ) 0 1 cos 2 1
cos 2 1 1
cos 2
cos 2
' '
' '
' ' '
' ' '
= +
= +
=
+ =
E A EE E A
EE E A E A
EE E AE E AE
EE E E AE AE
u
u
u
u
This is a quadratic in E, and has the solution
( )
| |
2
2 2
2
'
sin cos
1
u u +
+
= A
A
E
E
So what?
( )
| |
2
2 2
2
'
sin cos
1
u u +
+
= A
A
E
E
Note that a neutron will have the minimum energy
when it collides head-on (= radians)
( )
| |
2
2 2
2
'
sin cos
1
u u +
+
= A
A
E
E
-1
0
E
'
=
E
A+1
( )
2
A 1
| |
2
E
'
E
=
A1
( )
2
A +1
( )
2
o =
A 1
A +1
|
\
|
.
|
2
Collision
parameter
Note: E=oE
The energy of the particle after a
collision that is not absorbed must be
calculated. Generally, it can be
assumed that elastic, isotropic
scattering occurs.
Therefore, the energy of the outgoing
particle can lie anywhere from the
energy of the incident particle E
i
to
the minimum possible energy oE
i
.
energy in change maximum =
i i
E E o
The energy of the outgoing particle will
randomly vary between the minimum energy
(oE
i
) and the maximum incident energy E
i
.
A different random number, p
E
, in the range
[0,1] is picked to represent the fraction of
the maximum possible change in particle
energy for this collision.
E
i+1
=oE
i
+ p
E
E
i
oE
i
| |
We can now model each collision
d =
1
E
ln 1 p
d
( )
1
E
ln p
d
( )
u cos
1
+ =
+
d X X
i i
E
i+1
=oE
i
+ p
E
E
i
oE
i
| |
How far to next event?
Where is the particle in the slab?
What is the energy after event?
Back to
Recall that E (cross section) is a function
of energy E (e.g. low energy thermal neutrons are
much more likely to cause fission, neutrons at certain
intermediate resonance energies are more easily
captured)
To determine the type of collision event,
we first require the probabilities for
capture, fission and scattering, all of
which depend on E
( ) ( ) ( ) ( ) E E E E
s f c t
E + E + E = E
t
s
s
t
f
f
t
c
c
p p p
E
E
=
E
E
=
E
E
=
Because of the normalization to E
t
, i.e. we are certain
that one of three possibilities must occur, we know that
1 = + +
s f c
p p p
Pick a random number in the interval [0,1]
See where it lies to see what interaction occurred.
capture
fission
scattering
0 p
c
p
c
+p
f
1=p
c
+p
f
+p
s
Selecting Collision Type
Now that you have everything
determined in terms of probability, once
you get to a collision site, you
Pick a random number to determine
what interaction occurs:
Capture (kill) the particle, or
Fission occurs, bank extra neutrons, or
Scatter particle (another random number
is picked for direction & energy loss) and
transport again.
Moderator Ratios
Material
E
s
(cm
-1
) E
a
(cm
-1
)
MR
H
2
O 0.927 1.47 0.022 62
D
2
O (pure) 0.510 0.35 0.000033 5500
D
2
O (99.75%) 0.510 0.35 0.000088 2050
D
2
O (99%) 0.510 0.35 0.000253 710
BeO 0.174 0.69 0.00068 180
Graphite 0.158 0.38 0.00027 220
a
s
MR
E
E
=
where the lethargy
(average change in neutron
energy per collision)
o
o
o
ln
1
1
(
+ =
Note: in a moderator, there is no fissionable material,
f
=0.
A good moderator is something that slows down neutrons
without absorbing too many of them in the process, i.e. it has a
high MR.
Energy Dependence
In a real simulation, the cross-sections
will be represented in a table form
(Energy versus cross-section) or by a
continuous function (or functions).
Energy (MeV) E
a
E
f
E
s
1E-8 10 3 5
1E-7 11 4 6
.
.
10 1E-3 1E-5 20
Fission Neutrons
In a real simulation, the number of fission neutrons
emitted depends on the kind of fissionable material,
and the energy of the initiating neutron.
Anywhere from zero to five neutrons could be
emitted during fission!
The average number of emitted neutrons is
represented by v (nu) in the Boltzmann Transport
Equation (lead coefficient of the creation from fission term)
For U
235
, v 2.4 neutrons per fission
For Pu
238
, v 2.9 neutrons per fission
Deterministic Modelling
The behaviour of physical processes can
often be described mathematically by
ordinary or partial differential equations,
for example:
Heat flow: diffusion equation
Reactor physics: neutron transport
equation
Fluid flow: Navier-Stokes equation
Often, these equations are
representations of one of the
Conservation Laws (Energy, Momentum,
Mass)
Solving Differential Equations
An analytical solution would describe
exactly and continuously such things as
temperature, pressure, mass, density,
charge, neutron flux, etc., at any point in
time and space.
Example:
BUT, an exact analytical solution is often
very difficult to determine in real-world
applications, due to:
irregular shape of the solution domain,
non-linearities within the solution domain.
irregular or fluctuating boundary conditions.
dx
x df
x f
) (
) ( =
x
e x f = ) (
Approximate Solutions
Relatively simple algebraic equations can be
used, with care, to approximate the solution to
a partial differential equation.
Generally, the continuous system represented
by a differential equation is reduced to an
equivalent discrete system of several simpler
equations that approximate the continuous
system.
Digital computers provide the computational
power needed to solve the discrete system of
algebraic equations (matrices).
First Step - Discretization
The problem space is broken up into
smaller pieces or regions.
Each region has a central point, referred
to as a node.
The properties of the region are
averaged over the region, and considered
to be concentrated or lumped at the
node.
A node interacts with adjacent nodes
through the interface between the two
adjacent regions they occupy.
Taylor Series
The Taylor series expansion is a very useful
starting point for deriving approximations to
derivatives. For any continuous function f(x)
with continuous derivatives of any order, we
can write
This holds at every point in the function, but
involves an infinite number of terms. If we
approximate the series with only a finite
number of the most significant terms, we can
derive something useful.
) (
!
) (
) ( ) (
1
x
dx
f d
n
x
x f x x f
n
n
n
n
=
A
+ = A +
Truncating Higher Order
Terms
Lets truncate the series to remove
terms that we hope will be
insignificant. This will convert the
series from an infinite series to just
a finite number of terms.
4
3 2
) ( O ) ( ' ' '
6
) (
) ( ' '
2
) (
) ( ' ) ( ) ( x x f
x
x f
x
x xf x f x x f A +
A
+
A
+ A + = A +
[A]
where
dx
df
f = '
2
2
' '
dx
f d
f =
3
3
' ' '
dx
f d
f =
Truncated
terms
Truncation Error: O(h
n
)
The truncated terms will be represented
by the notation O(h
n
) which means a
term that varies as h
n
when h is small
enough, or more briefly, a term of
order h
n.
The discarded terms in our
approximation, O(h
n
), is referred to as
the truncation error.
If the truncation error approaches zero
as h approaches zero, the approximation
is said to converge on the exact solution.
Note Ax, h are interchangable, meaning a small change in x
Approximation of
x A
4
3 2
) ( ) ( ' ' '
6
) (
) ( ' '
2
) (
) ( ' ) ( ) ( x O x f
x
x f
x
x xf x f x x f A +
A
A
+ A = A
[B]
If we substitute for in [A], we get the following:
x A
If we isolate
) ( ' x f in equation [A] or [B], we have the following:
) (
) ( ) (
) ( '
) (
) ( ) (
) ( '
x O
x
x x f x f
x f
x O
x
x f x x f
x f
A +
A
A
=
A +
A
A +
=
dx
df
f = '
The forward difference
The backward difference
4
3 2
) ( O ) ( ' ' '
6
) (
) ( ' '
2
) (
) ( ' ) ( ) ( x x f
x
x f
x
x xf x f x x f A +
A
+
A
+ A + = A +
[A]
First Derivative Approximation
( x, f(x) )
( x+Ax, f(x+Ax) )
Ax
truncation error of order (Ax)
2
( x+Ax, f(x)+Ax
df
dx
(x) )
Reduce Ax for Better Approximation
(x,f(x))
(x+Ax,f(x+Ax))
Ax
truncation error of order (Ax)
2
( x+Ax, f(x)+Ax
df
dx
(x) )
When the truncation error terms are dropped, we have finite
difference approximations to replace and .
Using these approximations, we can replace a differential
equation with algebraic equations that should be much easier to
solve, especially if we take advantage of the power of digital
computers.
Approximation of
Adding [A] and [B] and solving for , we get the following:
) ( ' ' x f
2
2
' '
dx
f d
f =
) ( ' ' x f
2
2
) (
) (
) ( ) ( 2 ) (
) ( ' ' x O
x
x x f x f x x f
x f A +
A
A + A +
=
) ( ' x f
4
3 2
) ( ) ( ' ' '
6
) (
) ( ' '
2
) (
) ( ' ) ( ) ( x O x f
x
x f
x
x xf x f x x f A +
A
A
+ A = A [B]
4
3 2
) ( O ) ( ' ' '
6
) (
) ( ' '
2
) (
) ( ' ) ( ) ( x x f
x
x f
x
x xf x f x x f A +
A
+
A
+ A + = A +
[A]
Example: Heat Conduction
Numerical methods are often used to solve problems in heat
conduction.
As you may know, heat always flows from a hotter area to a
cooler area. The rate of heat transfer depends on the
temperature gradient, and on the physical properties of medium
through which the heat is moving.
The heat transfer process is mathematically represented by
Fouriers law, otherwise known as the diffusion equation. In
Cartesian coordinates:
t
T
z
T
y
T
x
T
c
c
=
c
c
+
c
c
+
c
c
T
2
2
2
2
2
2
1
p
T
C
k
=
where thermal diffusivity
= density (kg/m
3
)
C
p
= specific heat (J/kg-K)
k = thermal conductivity (W/m-K)
One-Dimensional Heat Conduction
Lets look at a greatly simplified heat conduction problem,
and use finite differences to develop an approximate
solution.
If we consider a rod of some material, coated in a
perfect insulator except at one end where it contacts
some surface that changes in temperature in a known
way, we should be able to simplify this to a heat
conduction problem in only one spatial dimension, i.e. the
one-dimensional diffusion equation will apply:
t
T
1
x
T
T
2
2
c
c
=
c
c
Simple Heat Transfer
Divide up the rod into equally sized regions Ax in length, with
nodes (numbered above from 1 to 7) at the center of each
region.
Write finite difference equations representing the diffusion
equation at each node to determine the temperatures at
discrete time intervals of At
Solve these equations iteratively, starting from known initial
conditions.
1 2 3 4 5 6 7
0
x
T
=
c
c
( ) t T
F
Ax
Internal Nodes
An internal node i interacts with adjacent
nodes i-1 and i+1 and is separated from
each adjacent node by a distance Ax
t
T
1
x
T
T
2
2
c
c
=
c
c
| | | |
2
T
i 1 i 1 i i
T
2
x) (
t
r where
(t) T r 2 1 (t) T (t) T r t) (t T
t
t) T(x, t) t T(x,
x) (
t) 2T(x, t) x, T(x t) x, T(x
A
=
+ + = +
+
=
A
+ +
+
Substituting the derivatives with finite differences
At the boundaries
Boundary conditions sometimes complicate things,
but there are tricks we can apply that work.
At the insulated end (node 7), we need to satisfy
the no heat transfer condition. There is no
node 8, but we achieve the same effect by
assuming there IS a node 8 that is identical in
temperature to node 6. We then write an Internal
Node equation as if there is a node 8!
6 7 8
Let T
8
(t)=T
6
(t)
| | | | ) (t T r 2 1 (t) T 2r t) (t T
7 6 7
+ = +
At the boundaries
At the left-hand end, the temperature is simply
the value of the forcing function, T
F
(t). This
temperature can be assumed to apply at an
imaginary node zero (similar to the other end
of the rod where we artificially added a node
8)
Note that we need not have any concern about
what kind of function T
F
(t) is as long as we have
values of T
F
(t) at each time interval!
| | | | (t) T r 2 1 (t) T (t) T r t) (t T
1 F 2 1
+ + = +
Matrix Representation
t t
F
t
T
T
T
T
T
T
T t rT
T
T
T
T
T
T
T
r r
r r r
r r r
r r r
r r r
r r r
r r
A +
(
(
(
(
(
(
(
(
(
=
(
(
(
(
(
(
(
(
(
+
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
7
6
5
4
3
2
1
7
6
5
4
3
2
1
0
0
0
0
0
0
) (
2 1 2 0 0 0 0 0
2 1 0 0 0 0
0 2 1 0 0 0
0 0 2 1 0 0
0 0 0 2 1 0
0 0 0 0 2 1
0 0 0 0 0 2 1
Most elements of the matrix are fixed values,
based on the material properties that make up the
(constant) thermal diffusivity.
Calculate the forcing function, then the T
i
values.
We have a solution?
Given:
Temperatures at every node at
time t=0, AND
Values of T
F
(t) at each time
interval,
we can estimate the rod temperature at
any node at any time interval by solving
our seven equations for the seven
unknowns (i.e the temperatures at the
next time interval)
Improvements to Accuracy
As we reduce At or Ax, our
approximations should become better
BUT
We cannot know exactly how big the
truncation error is (because it is an
infinite series!)- we hope that it is
getting smaller with smaller As.
We incur a higher computing effort
(more nodes, more time intervals).
We run into a potential problem with
stability!
Stability
there is a potential problem with the explicit finite difference
method.
If we carelessly pick Ax and At, the solution may go UNSTABLE,
and predict nothing accurately!
If we let the coefficient of T
i
(t) go negative (i.e. any diagonal
entry in the solution matrix <0), we will have an unstable
calculation!
Thus r < is a requirement for stability. If At is too big, or Ax is
too small, in effect we are trying to transfer too much heat in
each iteration.
Physically, this would represent heat flowing backwards a
violation of the second law of thermodynamics!
2
1
) ( C
t
2
p
<
A
A
=
x
r
T o
Improvements to stability
To avoid stability problems, pick intervals
carefully, OR
Reformulate using an implicit method instead:
e.g. replace the time derivative with a
backward difference instead of a forward
difference
This will result in an equation at each node relating the
current nodal temperature to the future temperatures of
the node and its adjoining neighbours.
A more complex solution of simultaneous equations in the
unknowns (the future temperatures) will result, but its
solution will be guaranteed to be stable, even if we use
much bigger values for the time interval.
Implicit Method
| | | |
2
T
i 1 i 1 i i
T
2
x) (
t
r where
(t) T 1 r 2 (t) T (t) T r t) (t T
t
t) - t T(x, t) T(x,
x) (
t) 2T(x, t) x, T(x t) x, T(x
A
=
+ + + =
A
=
A
+ +
+
Use the BACKWARD difference approximation for the time derivative
Implicit Method Matrix Solution
t t
F
t
T
T
T
T
T
T
t rT T
T
T
T
T
T
T
T
r r
r r r
r r r
r r r
r r r
r r r
r r
A
(
(
(
(
(
(
(
(
(
+
=
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
+
+
+
+
+
+
+
7
6
5
4
3
2
1
7
6
5
4
3
2
1
) (
1 2 2 0 0 0 0 0
1 2 0 0 0 0
0 1 2 0 0 0
0 0 1 2 0 0
0 0 0 1 2 0
0 0 0 0 1 2
0 0 0 0 0 1 2
Matrix Inversion
The matrix A is called tridiagonal because it has only three
diagonals of -r, (2r+1), and -r.
It is diagonally dominant because the absolute value of each
element of the diagonal is greater than the sum of the
absolute values of the elements on the same row off the
diagonal, i.e. |2r+1| > |-r| + |-r|.
This assures that A
-1
can be determined, and the solution is
stable.
AT
t+t
=T
t
A
-1
A T
t+t
= A
-1
T
t
T
t+t
= A
-1
T
t
Coming up
OPG Tour of Simulators on Nov. 14
th
,
1:00PM or 3:00PM. Map and
details posted on WebCT. Please
carpool!
Quiz Nov. 18
th
Assignment due Nov. 22
nd
.
Lecture 8 Topics
Deterministic Modelling, Pt. 2
Practical Applications in Heat
Transfer and Hydraulic
Modelling
Recall from Last Lecture
We replace differentials with finite difference
approximations
Our approximations are derived using Taylor Series
When we truncate the Taylor Series to a finite
number of terms, the terms we threw away
constitute the truncation error.
The order of the truncation error is determined by
the coefficient of the first discarded term
The error generally shrinks as Ax 0,
Other Errors (besides Truncation
Error)
Boundary conditions may also have to be
approximated by finite differences, which
may introduce additional discretization
errors (e.g. if our forcing function T
F
(t) in
the heat conduction example had to be
approximated using finite differences).
Any computation (such as in a digital
computer) not carried out to an infinite
number of digits will introduce round-off
error, e.g.
0.1
10
=0.000110011001100110011
2
Round-off Errors
Round-off error was more of a problem
when computers only used 16 bits (accuracy
about 1 part in 32768)
Now, most computers use at least 32 bits
for real number representations (1 in 10
7
accuracy), and can possibly use 64 bits or
better.
Still, you can get significant round-off
error when calculating a-b if ab, or
a+b if ab,
At some point, if you keep reducing interval
size (Ax 0), round-off error becomes
more significant than truncation error
A Real Heat Conduction Example
Large motors must be protected
from overload. If too much load is
put on a motor, the motor windings
will overheat and can burn out,
requiring replacement of the motor.
All motors have large starting
currents of about six times normal
running current, but this starting
current lasts only a short time.
Motor Overload Protection
If a fuse is used to protect against
overload, it must activate at over
six times normal running current, or
it will always activate when the
motor is turned on.
If a large motor runs continuously
at more than about 120% normal
running current, it will probably
burn out.
Simple fuse protection is unsuitable.
M
M
M
M
START
STOP
OVERLOAD RELAY
Motor Overload Protection
The heater will heat up a
bimetallic strip, which will open
a contact to stop the motor if
the temperature rises above a
setpoint temperature.
Because the heater and
bimetallic strip take time to heat
up, the high starting current will
be allowed to pass without
activating the overload relay.
However, sustained high current
will eventually stop the motor.
Motor
Contactor
Relay
Instead of a fuse, a
small heater is used
to provide a thermal
image of the motors
windings.
Power
Source
Thermal Overload Relay Model
Modeling a thermal overload relay is a
simple heat conduction problem.
We need only one node, representing the
heaters and bimetallic strip.
The node is heated by the current in the
heater, at a rate proportional to the
current squared.
The node is cooled by conduction to its
surroundings, roughly proportional to the
node temperature above ambient
temperature.
Conservation of Energy Equation
The rate of temperature increase of the node is proportional to the
energy added by the heating elements, and the energy removed by
heat dissipation to the surroundings.
) (
2
AMB
T T kI
dt
dT
= where is a dissipation constant
and k is a heating constant
As current increases, the temperature will increase until thermal
equilibrium is achieved.
Let I
SP
be the maximum allowed continuous current that is safe for the
motor. The maximum temperature T
SP
will then be the equilibrium
temperature for that current, at which we want the overload relay to
activate.
SP AMB SP SP
T T T kI A = = ) (
2
2
SP
SP
I
T
k
A
=
) (
2
2
AMB SP
SP
T T T
I
I
dt
dT
A =
At equilibrium, the temperature change over time is zero; therefore:
Approximating using the forward difference approximation
for the time derivative:
| |
(
A
+ A + A = A +
2
2
1 ) ( ) ( I
I
T
T t t t T t t T
SP
SP
AMB
Subtracting T
AMB
from both sides simplifies the
calculation:
| |
2
2
1 ) ( ) (
) ( ) (
I
I
T t
t t T t t T
T t T t T Let
SP
SP
AMB
A A
+ A A = A + A
= A
Summary
The value of AT is updated each iteration based on the
current flow to the motor.
If AT calculated by the approximation above
exceeds AT
SP
, the overload relay will activate.
Typically, an overload relay is set to operate at
115% of full-load current.
The dissipation factor is typically chosen to yield about a
ten-second delay in detecting overload, so that the
starting current transient of about six times full-load can
pass without initiating detection of the overload condition.
Hydraulics Modelling:
Fluids in Nuclear Plants
Fluid dynamics problems are very common in
nuclear plant simulations, because there are many
systems through which water, oil, or gases flow.
Typically, we are interested in computing the
pressures and flows within these systems at
successive time intervals, because these quantities:
directly influence other, connected systems, or
are quantities that must be monitored or
controlled to maintain production or safety.
Generally, we derive the
fluid system pressures at
key locations in a system
which we treat as nodes.
In other words, we
discretize a system of
pipes, valves, pumps,
filters, tanks, and the like
by placing nodes where we
want to calculate the
system pressures (i.e.
where pressure
measurements are made,
or at common headers
where flows divide or
converge.
We then approximate the governing equations, and solve for the current
pressure at each node based on the previous flows to and from each node.
Using these new nodal pressures, we then estimate any change in the flows
between the nodes.
Now lets derive some way of approximating pressure variations and
flows between nodes in hydraulic circuits.
In any volume of a fluid, pressure varies with density and with
depth h (or elevation).
We know that
Let consider elevation changes first. Whenever we dive to the
bottom of a pool, we feel how pressure increases with increasing
water depth. Whenever we go higher into the atmosphere in a plane,
we feel how the air pressure drops.
We know intuitively that pressure changes with elevation in fluids.
What about changes in density?
i
i
i
i
i
i
h
p
dh
p
d dp
c
c
+
c
c
=
w
out
(
(
(
p
i
(t + At) = p
i
(t)+ C
i
At w(t)
+
V
1
2
2
+ gh
1
=
p
2
+
V
2
2
2
+ gh
2
+ K
V
2
2
where p
1
and p
2
are the upstream and downstream pressures at two
adjacent nodes,
V
1
and V
2
are the fluid velocities (average ) at the two nodes,
h
1
and h
2
are the node elevations,
is the fluid density,
g is the gravitational acceleration constant, and
K is a friction coefficient which depends on the shape and roughness of
the flow path, and the fluid viscosity (fluid internal friction).
V
[5]
In the modified Bernoulli equation, the first three terms
on each side of the equation represent respectively the
pressure energy, kinetic energy, and potential energy of
the fluid at each node.
The extra term on the left side is the approximate
energy lost to friction as it flows from node 1 to node 2
due to the fluids viscosity and friction at the boundaries
(pipe walls).
Most often, fluid flow is turbulent (Reynolds number
>2300), and thus the friction term varies with the
square of the flow velocity.
Equation Terms
p
1
+
V
1
2
2
+ gh
1
=
p
2
+
V
2
2
2
+ gh
2
+ K
V
2
2
Friction Reduces Pressure
If the flow velocities are not significantly different at the
two nodes, the energy lost due to friction in going from node
1 to node 2 will result in a drop in pressure between the
nodes. Pressure can also be affected by a change in
elevation, i.e. for turbulent incompressible flow:
p
1
p
2
+ g h
1
h
2
( )
= C w
12
2
where w
12
is the flow from node 1 to node 2
Letting , and solving for the mass flow rate:
w
12
= A
12
p
1
p
2
+ g(h
1
- h
2
)
C
1
A
12
=
[6]
Flow vs. Pressure
In other words, the flow rate in turbulent
incompressible flow between nodes is roughly
proportional to the square-root of the pressure
difference between those nodes (if their
elevation is the same):
The Conservation of Energy equation will yield
different simplifications if the flow is not
turbulent or is compressible (because some
derivative terms dp/d are no longer negligible!)
w
12
= A
12
p
1
p
2
Flow vs. Pressure
If the flow is
laminar and
incompressible (a
typical example is
oil), the flow rate
typically varies in
direct proportion to
the pressure
difference:
If the flow is
compressible (i.e. a gas),
the flow rate usually
varies in direct proportion
to the square root of the
difference of the
pressures squared
(provided the pressure
difference is not too large,
and the speed of the flow is
not nearly supersonic):
w
12
= A
12
( p
1
p
2
)
w
12
= A
12
p
1
2
p
2
2
Flow Example 1
Consider a simple situation
in which a tank (swimming
pool) with a horizontal
cross-section area of A is
being filled by a flow with a
known mass flowrate of w
in
We can easily estimate the water mass m
T
and the level h in the tank:
dm
T
dt
= w
in
dm
T
= w
in
dt
m
T
(t + At) = m
T
(t) + At w
in
(t)
=
m
T
V
=
m
T
Ah
h =
m
T
A
Flow Example 2
w
in
m
T
h
Now, the inflow is entering at
the bottom of the tank. The
hydrostatic pressure of the
water already in the tank will
affect the pressure at the
bottom of the tank where the
water is entering. The water
source will have to overcome this
hydrostatic pressure to push
water into the tank.
Let P
T
be the pressure at the tank bottom, and let us assume
that the tank is open to the atmosphere. Then:
P
T
=P
atm
+ gh
P
T
P
atm
Flow (Pressure Difference)
If the water flowing into the
tank is from a constant
pressure source P
s
, then we
can estimate the expected
flow into the tank by knowing
what the pressure is where
the water enters the tank
from the source:
T S ST in
P P A w =
A
ST
is a constant that we can derive experimentally, or we
can estimate it using empirical formulae based on the pipe
roughness, and the presence of any elbows, valves, or other
flow disruptions, as explained in many fluid mechanics texts.
Solving Example 2
0. Establish Initial Conditions: At t=0, m
T
is known.
P
s
is known. A
ST
, g, r, A(surface area) are known.
m
T
(t +At) =m
T
(t)+Atw
in
(t)
4. Go back to step 1 for next iteration.
3. Determine new flow into tank based on new bottom pressure:
2. Determine new tank level and bottom pressure:
h =
m
T
A
P
T
=P
atm
+ gh
T S ST in
P P A w =
1. Solve for new tank mass based on the previous mass and inflow:
Flow Example 3
w
in
m
T
h
P
S
P
T
P
C
For the next example, we
will close off the top of the
tank. This is typical of tanks
in some industrial
applications, including
nuclear plant systems. If
the tank is not somehow
vented to the atmosphere,
the cover gas will change
pressure as the tank level
changes.
Water entering the tank will take up a portion of the tank volume,
compressing the cover gas into the remaining tank volume. The cover
gas pressure will in turn influence the bottom pressure in the tank, and
the flow into the tank.
As you would expect, when the tank fills sufficiently, the bottom
pressure will approach the source pressure, and inflow will stop.
Solving Example 3
0. Establish Initial Conditions:
At t=0, m
T
is known. P
s
and P
c
is known.
A
ST
, g, r, A are known
1. Solve for the tank mass based on the previous mass and the
inflow:
m
T
(t +At) =m
T
(t)+At w
in
(t)
2. Determine new tank level:
h(t + At) =
m
T
(t + At)
A
The cover gas volume will change with a change in h. It drops as
much as the water volume has increased in the tank.
The cover gas is usually air, or is sometimes an inert gas like
helium. Either way, it is not a bad approximation to treat it like an
ideal gas:
Solving Example 3 (cont.)
constant nRT PV ~ =
P
C
(t + At)V
C
(t + At) = P
C
(t)V
C
(t)
P
C
(t + At) =
P
C
(t)V
C
(t)
V
C
(t + At)
The change in cover gas volume resulted from the change in water mass:
m
T
= V
T
dm
T
dt
=
dV
T
dt
~ w
in
(t)
dV
C
dt
=
dV
T
dt
~
w
in
(t)
Assumes temperature is
not changing
Solving Example 3
6. Go back to 1 for next iteration.
5. Determine flow into tank based on new bottom pressure:
P
T
(t +At) =P
C
(t +At)+ gh(t +At)
w
in
(t + At) = A
ST
P
S
P
T
(t + At)
3. Determine the change in cover gas volume and pressure:
V
C
(t + At) = V
C
(t) + At
dV
C
dt
= V
C
(t) At
w
in
(t)
P
C
(t + At) =
P
C
(t)V
C
(t)
V
C
(t) At
w
in
(t)
1
2
4
5
3
S1
S5
w
12
w
24
w
45
w
S5
w
34
w
13
w
S1
p
1
p
3
p
2
p
4
p
5
0 w w
0 w w w
0 w w
0 w w
0 w w w
S5 45
45 34 24
34 13
24 12
13 12 S1
= +
= +
=
=
=
We can write Conservation of Mass equations for the internal nodes:
Let the admittance between two adjoining nodes be defined as follows:
a
ij
=
A
ij
p
i
p
j
+ g(h
i
- h
j
)
Recalling equation [6]:
[7]
1
2
4
5
3
S1
S5
w
12
= A
ij
p
1
p
2
+ g(h
1
- h
2
)
[6]
Admittance Matrix Solution
Rewriting the above conservation of mass equations for each
node yields linear equations in the unknowns, p
i
. We have
linearized the system of equations with our definition of
admittance so they can be easily solved.
0 ) p p ( a ) p p ( a
0 ) p p ( a ) p p ( a ) p p ( a
0 ) p p ( a ) p p ( a
0 ) p p ( a ) p p ( a
0 ) p p ( a ) p p ( a ) p p ( a
5 5 S5 5 4 45
5 4 45 4 3 34 4 2 24
4 3 34 3 1 13
4 2 24 2 1 12
3 1 13 2 1 12 1 S1 S1
=
= +
=
=
=
S
Lets assume for simplicity that all nodes are at the same elevation.
Then, combining [6] and [7], we have equations of the following form:
) p (p a w
j i ij ij
=
Regrouping
S5 S5 S5 45 5 45 4
45 5 45 34 24 4 34 3 24 2
34 4 34 13 3 13 1
24 4 24 12 2 12 1
S1 S1 13 3 12 2 13 12 S1 1
a p ) a (a p ) a ( p
0 ) a ( p ) a a ( p ) a ( p ) a ( p
0 ) a ( p ) a (a p ) a ( p
0 ) a ( p ) a (a p ) a ( p
a p ) a ( p ) a ( p ) a a (a p
= + +
= + + + + +
= + + +
= + + +
= + + + +
a
(
(
(
(
(
(
=
(
(
(
(
(
(
(
(
(
(
(
(
+
+ +
+
+
+ +
S5 S5
S1 S1
5
4
3
2
1
S5 45 45
45 45 34 24 34 24
34 34 13 13
24 24 12 12
13 12 13 12 S1
p a
0
0
0
p a
p
p
p
p
p
a a a 0 0 0
a a a a a a 0
0 a a a 0 a
0 a 0 a a a
0 0 a a a a a
Admittance Matrix Method
We can now solve a linear system of equations of
the form Ap = s, where A is the admittance
matrix, p is the vector of unknown pressures we
are trying to determine, and s is the source
vector of external pressures or flows.
1. Determine A from eq. [7] (Note that we use the
pressures from the previous iteration to estimate
admittances for the next iteration.)
2. Invert matrix A and calculate new pressures:
p = A
-1
s
3. Use eq. [6] to determine flows based on new
pressures.
Admittance Matrix Method
We should always be able to invert the
admittance matrix A if its diagonal
elements are all positive, and some of its
off-diagonal elements are negative (i.e. the
matrix is positive definite and diagonally
dominant)
A zero admittance off-diagonal matrix
element represents:
A non-existent flow path between the nodes, or
A blocked flow path (e.g. a closed valve)
between nodes, which could split the flow
network in two!
Once we know new pressures, new flows can
be easily determined.
Admittance Matrix Method
We can enhance the stability and realism
of the admittance matrix approach by
adding a small capacitance at each node as
a source.
This helps with paths that may close (i.e.
when a valve closes).
The transient response is slowed down a
little, but is guaranteed to be solvable in
all circumstances.
Darlington Feedwater System
Portion of Darlington Feedwater Model Admittance Matrix (18 by 18)
Node C D E F K L B A X
Pressure Sources index 1 2 3 4 5 6 7 8 9
PCX(1)
AOC(1)[POX+PSH(1)]+
ACT(1)*PC1+Cap/t*PCX(1)
1
AOC(1)
+ACB(1)
+ACT(1)
0 0 0 0 0 -ACB(1) 0 0
PCX(2)
AOC(2)[POX+PSH(2)]+
ACT(2)*PC1+Cap/t*PCX(2)
2 0
AOC(2)
+ACB(2)
+ACT(2)
0 0 0 0 -ACB(2) 0 0
PCX(3)
AOC(3)[POX+PSH(3)]+
ACT(3)*PC1+Cap/t*PCX(3)
3 0 0
AOC(3)
+ACB(3)
+ACT(3)
0 0 0 -ACB(3) 0 0
PCX(4)
AOC(4)[POX+PSH(4)]+
ACT(4)*PC1+Cap/t*PCX(4)
4 0 0 0
AOC(4)
+ACB(4)
+ACT(4)
0 0 -ACB(4) 0 0
PKX(1)
AOC(5)[POX+PSH(5)]+
ACT(5)*PC1+Cap/t*PCX(5)
5 0 0 0 0
AOC(5)
+AKX(1)
+ACT(5)
0 0 0 -AKX(1)
PKX(2)
AOC(6)[POX+PSH(6)]+
ACT(6)*PC1+Cap/t*PCX(6)
6 0 0 0 0 0
AOC(6)
+AKX(2)
+ACT(6)
0 0 -AKX(2)
PBX
ABRKB*TAPAMB
+Cap/t*PBX
7 -ACB(1) -ACB(2) -ACB(3) -ACB(4) 0 0
ACB(1)+ACB(2)
+ACB(3)+ACB(4)
+ABA+ABRKB
-ABA 0
PAX
ABRKA*TAPAMB
+Cap/t*PAX
8 0 0 0 0 0 0 -ABA
AAM1(1)+AAM1(2)
+AAM1(3)+AAM1(4)
+ABA+AXA+ABRK
A
-AXA
PXX Cap/t*PXX 9 0 0 0 0 -AKX(1) -AKX(2) 0 -AXA
AKX(1)+AKX(2)+
AXA+AXY
PYX
PPX(1)*AYP(1)+PPX(2)*
AYP(2)+PPX(3)*AYP(3)
+PPX(4)*AYP(4)+AU1S*PU1S
+AU1D*PU1D+AU3S*PU3S
+AU3D*PU3D+AU4S*PU4S
+AU4D*PU4D+AXY*PXX
+Cap/t*PYX
10 0 0 0 0 0 0 0 0 -AXY
PM1(1)
ABRM1(1)*TAPAMB+
PM1(1)*AM1N1(1)
+Cap/t*PM1(1)
11 0 0 0 0 0 0 0 -AAM1(1) 0
TOUR on Saturday, 1PM or 3PM
QUIZ next week:
All materials in lecture folders
Concentrate on principles, definitions,
basic derivations (e.g. using Taylor
Series)
Not so much on MATLAB
45-90 min. to complete
ASSIGNMENT
LAST of my lectures in 2 weeks
Lecture 9
Marks posted for OPG Tour, Assignment 4
Return of Quiz 2.
Assignment 4 still to be marked
Next Week: Wrap up - Prof. Kaye
Simplifications and Assumptions
Often, to make a practical model,
assumptions and simplifications are
required.
Assumptions and simplifications should
ALWAYS be stated.
Assumptions may not always be correct
or may result in misleading results. When
in doubt, review model assumptions!
Assumption is the mother of all
screwups
Euler Method
Problems involving a first order differential equation, and
an initial condition, i.e. a kind of Initial Value Problem:
dy
dt
= y' = f (t, y) y(0) = y
0
y' = f (t
n
, y
n
) ~
y
n+1
y
n
h
y
n+1
~ y
n
+ hf (t
n
, y
n
)
We calculate x
n+1,
= x
n
+h from x
n
, and the forward
difference approximation gives us y
n+1
based on x
n
, y
n
, as
follows:
Note: Our guess for the next value of y is based on the
slope at the start of the interval h when using the forward
difference approximation.
Euler Method
It is an explicit method and it is
single-step, meaning the next
value comes from previous known
values in a simple straightforward
calculation.
Easy to calculate, but not that
accurate (i.e of order h, O(h)), and
subject to instability in certain
circumstances.
Why unstable?
Consider a very simple example:
y = ay
If we use the forward difference approximation:
y
n+1
= y
n
+hay
n
= (1+ha)y
n
If we extend this back to y
0
, we can say
y
n+1
= (1+ha)
n+1
y
0
For a bounded (stable) solution, |1+ha|<1, or else
the solution is unstable.
Stability of Explicit Methods
|1+ha|<1 h is between -2/a and
0
(note a<0, and solution is y=y
0
e
a(x-x
0
)
)
This sets a very tight restriction on
how big h can be!
Any tiny error (e.g. round off error)
will grow without bound if |1+ha|>1
Implicit Euler Method
We calculate x
n+1,
= x
n
+h from x
n
, and the
backward difference approximation gives us an
equation for y
n+1
based on x
n
, y
n
, and y
n+1
as
follows:
) , (
) , ( '
1 1 1
1
1 1
+ + +
+
+ +
+ ~
~ =
n n n n
n n
n n
y t hf y y
h
y y
y t f y
Note: Our guess for the next value of y is based on the slope at
the end of the interval h for the backward difference
approximation.
Note also: More computing is required to solve for y
n+1
Stabilty: Implicit Euler
Consider the same simple example:
y = ay (remember, a<0)
If we use the backward difference approximation:
y
n+1
= y
n
+hay
n+1
or y
n+1
= y
n
(1-ha)
-1
Extend this back to y
0
y
n+1
= (1-ha)
-(n+1)
y
0
For a bounded solution, (1-ha)>1, which is true for ANY h!
Improved Accuracy
There are other ways to improve the
accuracy of finite difference methods
(other than simply reducing interval
size).
Three of them are
Midpoint method - O(h
2
)
Heuns Method, RK2 - O(h
2
)
Runge-Kutta method, RK4 - O(h
4
)
(t
n+1
,y
n
+hf(t
n
,y
n
))
y
t
(t
n+1
,y
n+1
)
(t
n
,y
n
)
h
Euler Method
Heuns Method
Average the slopes at either end of the
interval.
Has higher accuracy, because Forward
Difference tends to guess to one side of
curve, while Backward Difference tends to
estimate to the other side, and the best
slope is nearly always in between.
Also known as RK2
)] , ( )
~
, ( [
2
) , (
~
1 1 1
1
n n n n n n
n n n n
y t f y t f
h
y y
y t hf y y
+ + ~
+ ~
+ + +
+
h/2 h/2
Euler method
(t
n
,f(t
n
))
Heun method
(t
n+1
,f(t
n+1
))
(t
n+1
,y
n
+h/2*[f(t
n
,y
n
)+f(t
n
,y
n
+hf(t
n
,y
n
)])
Midpoint Method
To improve the estimate, lets use
the slope at the midpoint of the
interval instead of at the start
and/or end:
)) , (
2
,
2
(
1 n n n n n n
y t f
h
y
h
t hf y y + + + ~
+
h/2 h/2
Euler method
a
b
Midpoint method
(t
n+1
,f(t
n+1
))
(t
n
,f(t
n
))
Runge-Kutta Method
More properly known as the Runge-Kutta
fourth order method,or RK4, it is one of a
class of Runge-Kutta methods. Lots of
information and demos are available on the
internet, as this is the standard method.
RK4 uses a weighted average of four slopes to
give a better approximation of how much a
function changes over an interval.
MATLAB function: ode45 for the explicit RK4
method, ode15s for the implicit RK4 method.
Error of order O(h
5
) at each step, O(h
4
)
overall.
Runge-Kutta Method
Numerically approximating y' = f (t, y), given t
0
, y
0
:
t
n+1
= t
n
+ h
a = f (t
n
, y
n
)
b = f (t
n
+
h
2
, y
n
+
h
2
a)
c = f (t
n
+
h
2
, y
n
+
h
2
b)
d = f (t
n
+ h, y
n
+ hc)
y
n+1
= y
n
+
h
6
a + 2b + 2c + d
| |
h/2 h/2
Euler method
a
b
Midpoint method
c
d
Slope
(a+2b+2c+d)/6
RK4 method
(t
n+1
,f(t
n+1
))
(t
n
,f(t
n
))
Runge-Kutta (RK4) Method
Which method to use?
Higher order methods such as RK4 are generally
more accurate, but require more calculations
per step. The calculation of f(x) uses the most
time.
Euler method is really simple and fast, and for
that reason it has historically been used in
real-time power plant simulation.
It may be worthwhile to investigate the use of
higher order approximations in OPG simulators,
now that computers are faster than before.
MATLAB routines can use Self-adjusting
intervals when solving problems.
FD Approximations - Review
The Taylor Series can be used to derive
many different finite difference
approximations for replacing derivatives
with easier algebraic approximations.
By comparing their truncation errors (the
first discarded term), the relative
accuracy of two different finite
difference approximations can be
evaluated.
ceprofs.tamu.edu/hchen/cven688/chap03a.ppt
FD Approximations -
Review
Stability is important!
Explicit methods are faster per iteration,
but may be unstable.
Implicit methods are more computationally
intense, but can progress with larger
intervals and are always stable.
Stiff problems, having potentially large
changes in f(x) in small intervals (eg.
Reactor kinetics problem in assignment 4)
almost always require implicit methods.
Example Derivation
GOAL: Derive a finite difference
approximation for f(x
n
) based on
x
n
, x
n+1
, x
n+2
, x
n+3
, and determine
the truncation error of that
approximation.
Start with the Taylor series:
) (
!
) (
) ( ) (
1
x
dx
f d
n
x
x f x x f
n
n
n
n
=
A
+ = A +
Note: After expanding using Taylor
Series, all RHS quantities are at x
n
Let x
n+1
= x
n
+ Ax = x
n
+ h, x
n+2
= x
n
+ 2h, etc.
f (x
n+1
) = f (x
n
) +
h
1
1!
f ' (x
n
) +
h
2
2!
f ' ' (x
n
) +
h
3
3!
f ' ' ' (x
n
) +
h
4
4!
f
(4)
(x
n
) +
h
5
5!
f
(5)
(x
n
) + ...
f (x
n+1
) = f (x
n
) + hf ' (x
n
) +
h
2
2
f ' ' (x
n
) +
h
3
6
f ' ' ' (x
n
) +
h
4
24
f
(4)
(x
n
) +
h
5
120
f
(5)
(x
n
) + ... [A]
f (x
n+2
) = f (x
n
) +
2h
( )
1
1!
f ' (x
n
) +
2h
( )
2
2!
f ' ' (x
n
) +
2h
( )
3
3!
f ' ' ' (x
n
) +
2h
( )
4
4!
f
(4)
(x
n
) +
2h
( )
5
5!
f
(5)
(x
n
) + ...
f (x
n+2
) = f (x
n
) + 2hf ' (x
n
) + 2h
2
f ' ' (x
n
) +
4
3
h
3
f ' ' ' (x
n
) +
2
3
h
4
f
(4)
(x
n
) +
4
15
h
5
f
(5)
(x
n
) + ... [B]
f (x
n+3
) = f (x
n
) + 3hf ' (x
n
) +
9
2
h
2
f ' ' (x
n
) +
9
2
h
3
f ' ' ' (x
n
) +
81
24
h
4
f
(4)
(x
n
) +
243
120
h
5
f
(5)
(x
n
) + ... [C]
Next
Try to eliminate the lowest order
derivatives of f(x), keeping the desired
derivative and a minimum number of
higher order derivatives (that make up
the truncation error). In our
example,we want to keep f(x) and
eliminate or reduce f(x), f(x) as best
we can.
Add or subtract multiples of each
equation to achieve this. For our
example, lets try [A]+2[B]-[C], to
eliminate the f(x) term
[A] + 2[B] [C] =
f (x
n+1
) + 2 f (x
n+2
) f (x
n+3
)
= f (x
n
)[1+ 2 1]
+ hf ' (x
n
)[1+ 4 3]
+ h
2
f ' ' (x
n
)[
1
2
+ 4
9
2
]
+ h
3
f ' ' ' (x
n
)[
1
6
+
8
3
9
2
] + ...
f ' (x
n
) =
2 f (x
n
) + f (x
n+1
) + 2 f (x
n+2
) f (x
n+3
)
2h
5
3
h
2
f ' ' ' (x
n
) + ...
Approximation of f
Truncation
error
Proving an approximation
(like Quiz 2 problem)
h
x f h x f h x f
x f
2
) ( 3 ) ( 4 ) 2 (
) ( '
+ + +
~
Write Taylor series for function values NOT at x
f (x+ 2h) = f (x)+ 2hf '(x)+
4h
2
2
f ' '(x)+
8h
3
6
f ' ' '(x)+
16h
4
24
f
(4)
(x)
f (x+ h) = f (x)+ hf '(x)+
h
2
2
f ' '(x)+
h
3
6
f ' ' '(x)+
h
4
24
f
(4)
(x)+...
Substitute the expansions (with
truncation terms included!) back
into the approximation formula:
f (x + 2h)+ 4 f (x + h) 3 f (x)
= f (x)[1+ 4 3]+ hf '(x)[2+ 4]+ h
2
f ' '(x)[4 / 2+ 4 / 2]+ h
3
f ' ' '(x)[8/ 6+ 4 / 6]+...
= 2hf '(x)
2
3
h
3
f ' ' '(x)+...
Rearrange to isolate f(x)
f '(x) =
f (x+ 2h)+ 4 f (x+ h) 3f (x)
2h
+
1
3
h
2
f ' ' '(x)+...
Truncation
error
Other Numerical Analysis Techniques
We have only scratched the surface.
More sophisticated methods exist that
are more suitable when solution domains
have complex or changing geometries.
Finite Element method: first used in
structural analysis. Also used in
aerospace and many other engineering
and scientific applications.
Also Finite Volume method, Spectral
method, Panel method, Boundary element
method, Graduate course.
Suggestions
Expect anything
Follow instructions!
Name your assignment file submission according
to the standard (not just Assignment 4)
Also include your name and student number
INSIDE your submission at least once.
Add comments in MATLAB, otherwise you will
not be able to debug your own code at a later
date (And your peers and evaluators definitely
wont understand what your code does!)
Real-World Problems
Fix it, Live with it, or walk away
If you dont take the time to do it
right the first time, when will you
ever find time to fix it?
If it aint broke, dont fix it!
80/20 rule
Administrative
So remember me?
Administrative
Final Exam: December 12, 12h00
3 hours long
UA1140
Assignment #5 Now due Dec 11
Group projects are coming in
tomorrow night.
Grades will be uploaded to WebCT
when I mark the projects
Step 5: Evaluating the
Solution
Define the Problem
Generate Solutions
Decide Course of Action
Implement Solution
Evaluate Solution
Evaluation
This should be an ongoing process
throughout the life of the project.
Evaluation may be measured against
identified project milestones
Milestone: a significant event
If project objectives are not being
met, this must be communicated to
management in a timely manner.
A checklist may help
Evaluation checklist
Have the assumptions
been challenged?
Does the solution solve
the real problem?
Is the problem
permanently, or
temporarily solved?
Does the solution have
impact?
Have the consequences of
the solution been
examined?
Have both positive and
negative sides of the
solution been argued?
Has the solution
accomplished all it could?
Is the solution
economically efficient and
justifiable?
Does the solution meet
the clients and
customers needs?
Does the solution cause
other problems
(environmental or safety)?
Is the solution logical?
Is the solution
economically,
environmentally, and
politically responsible and
safe?
Ethics
When discussing a conflict related
to ethics, have you ever heard (or
thought): I had not thought of it
in that light?
Many times the ethical aspects of a
situation may not be entirely clear.
Solutions are not always black and
white with regards to ethics, but
are shades of gray.
Ethics Checklist
Is it legal?
Will you be violating either civil or company law?
Is it balanced?
Is it fair to all concerned in the short term as
well as the long term?
Does it promote a win-win relationship?
How will it make you feel about yourself?
Will it make you proud?
Would you feel good if your decisions were
published in the newspaper?
Would you feel good if your family knew about it?
Apply the 5 Ps to the Solution
The Power of Ethical Management
K. Blanchard and N. Pearle (1988)
Related to the three point checklist
provided, the 5 Ps will help you
further analyze the solution.
It is often very instructive to have
a third party either listen to your
explanations or argue your points.
The Five Ps
Purpose
What is the objective you are striving for?
Pride
Can you take pride in the developed solution?
Patience
Have you taken time to think through all
ramifications of the solution?
Persistence
Have you given up too soon on finding a solution
that is fair and balanced to all?
Perspective
Does the solution fit with your ideals and
beliefs?
Example: The Gift
You are responsible for managing
the purchase of dosimetry for the
laboratory you work in.
Each year, the representatives
from the different vendors leave
small tokens of appreciation (pens,
mugs, etc).
This year, one rep. leaves you an
expensive monogrammed briefcase,
which is much out of the ordinary
You are in a position to influence
the purchase this year of a large
quantity of equipment.
Should you:
Keep the case, on the grounds that
your judgment will not be affected in
any way?
Keep the case, since it would only
cause embarrassment all around if it
were returned?
Return the case?
Other?
Applying the 5 Ps
Purpose
Ask yourself what would you do to remain unbiased.
Pride
Would you feel pride in accepting the case or pride in
returning the case?
Patience
Set aside a time to think about whether or not you
should accept the case. Talk it out with someone.
Persistence
Have you pursued all the avenues to resolve either
keeping or returning the case?
Perspective
Even if you feel your judgment will not be affected by
accepting the gift, how will it appear to other
colleagues? Are you setting a good example?
Some Poll Results
US Canada US, by age
Option
Total (%) Total (%) < 26 26 - 50 > 50
Keep the case, judgment not affected 19.7 14.6 27.7 17.9 15.4
Keep the case, avoid embarrassment 3.3 4.9 4.9 2.8 3.1
Return the case 65.8 61.0 56.9 68.1 67.6
Other 9.5 18.3 9.0 9.8 12.1
Adapted from Chem. Eng. Magazine, Sept. 1980, p.132
Almost 28% of people under 26
thought it was OK to keep the case
Safety
One of the most important aspects
of the evaluation process is to
ensure that the proposed solution is
safe to both humans and the
environment.
Can use KT Potential Problem
Analysis or HAZOP (HAZard and
OPerability) Analysis
Fault tree analysis may be useful
Some words about HAZOP
Investigation of deviations from the design
intention for a process by a team of
individuals with expertise in different areas
such as engineering, operations,
maintenance, safety, etc.
Normal Operations
Deviation
1
Potential
Accident *
Deviation
3
Potential
Accident *
Deviation
2
Potential
Accident*
Deviation
4
Potential
Accident*
*If applicable
safeguards fail
Procedure for HAZOP Analysis
(3) Subdivide the
system or activity
and develop
deviations
(2) Define the
problems of
interest for the
analysis
(4) Conduct
HAZOP reviews
(1) Define the
system or activity
(5) Use the results
in decision making
Developing credible deviations:
the guide word approach
Guide Word
No (not)
More (high, long)
Less (low, short)
.
.
Guide Word + System Condition = Deviation
System Condition
Flow
Pressure
Temperature
.
.
Limitations of the
HAZOP Technique
Requires a well-defined system or
activity
Time consuming
Focuses on one-event causes of
deviations
This is all we will say about this technique in this course
Example: Portable Heater
As the health and safety officer
at the nuclear plant you are
working at, you are asked to
obtain a portable kerosene heater
to use in the winter for the
emergency off-site command post.
Being a graduate from the UOIT Problem
Solving course, you know that, prior to
purchasing this heater, you should do a
safety analysis on its use.
First, you ask yourself: Is a kerosene
heater the best choice?
Since the Off-Site command post does
not initially have electrical power
available, this portable and self contained
heat source as a stop-gap measure seems
reasonable. The total number of people
expected in the post are 10.
You decide initially that a potential
problem analysis (PPA) is in order.
Potential
Problem
Consequence Possible Cause Preventative
Action
Contingent
Action
Improper fuel
used in heater
Explosion
Using gasoline
to fill tank
Place warning
sign near heater
Verify Gasoline
before loading
heater
Heater tips over Fire
People around
heater
Place heater in
protected
location
Remove
combustible
materials from
vicinity
Improper
venting
Installed by
qualified
technician
Check vent
prior to lighting Carbon
monoxide
build-up
Asphyxiation
Chimney
plugged
Check chimney
each heating
session
Regular
maintenance on
chimney/flue
You now determine that the consequences (top level events)
and potential problems (basic events) will fit
nicely into a fault tree .
KT PPA
Fault Tree Math
IF you can assign
probabilities of occurrence
(# times/month, for
example) to the basic
events, you can then get
the top level probabilities
(probability of occurrence
per month).
For AND gates
P(A
1
A
2
..A
n
)
= P(A
1
)P(A
2
)..
For OR gates
P(A
1
+A
2
+..A
n
)
= P(A
1
)+P(A
2
)..
Basic Equations
For example(made up numbers)
p(Heater improperly vented)=0.001/month
p(Chimney plugged)=0.2/month
p(Heater tips over)=0.5/month
p(Wrong fuel)=0.05/month
Using Boolean logic, we get:
P(Asphyxiation)=0.201/month
P(Fire)=0.5/month
P(Explosion)=0.05/month
Most Probable
If you want to talk risk
Risk = Probability x Consequence
Let us measure consequence (C) in
terms on number people injured (#
injured/10 total people in post)
C(Asphyxiation)=0.6 (6 people injured)
C(Fire)=0.2 (2 people injured)
C(Explosion)=0.8 (8 people injured)
Risk(Asphyx)=(0.201)*(0.6)=0.12
Risk(Fire)=(0.5)*(0.2)=0.1
Risk(Explosion)=(0.05)*(0.8)=0.04
Putting it all together!
Case Study: Sears Catalog
In 1992, Sears, Roebuck and Co.
announced elimination of their
catalog sales (and closing of over
100 stores in the face of a $830
million deficit).
What lead up to this situation?
History
In 1886, R.W. Sears began selling
watches and jewelry with mailers.
Nine years later, they had
produced a 532 page catalog of
merchandise aimed at Americas
farm families.
The catalog quickly caught on and
became a lifeline for people in
remote areas.
By 1992, there were Fall/Winter,
Spring/Summer and Christmas
Wishbook offerings, along with
many other seasonal catalogs.
The catalog sales, although in
excess of $3.3 billion, was in
serious troubleexperiencing
significant red ink in spite of
impressive sales.
Sears management had failed to
recognize a paradigm shift.
Other marketers were targeting
specific audiences, whereas Sears
continued to produce large and costly
Big Book.
They were stuck in paradigm
paralysis that as long as an item had
the Sears name on it, it would sell.
Who, these days, would buy a
refrigerator or stove through a
catalog??? They were, however, still
in the catalog
Sears did not even have a 1-800
number to call in orders (other
companies had started this years
earlier).
The ripple effect from eliminating
the Big Book was extensive, for
example:
Over 50% of business lost in 2 Sears
plants, resulting in them closing and job
losses over 1000.
Paper industry lost 40,000 tons/year in
business
US Postal Service lost $100 million in
postage and handling per year.
Lets analyze this situation using
our problem solving skills!
First, why was the problem allowed to
get so serious?
Our first guess is that Sears was
stuck in paradigm paralysis
How can we come up with ideas to fix
the problem?
Lets try a Duncker Diagram to try
and clarify the problemwe can also
try a Problem Statement-Restatement
technique
What can we see here?
Some of the specific solutions in the
Duncker Diagram and the Statement-
Restatement table point to:
Improve sales by using more than just
distributing the Big Book
Improving image
Improving customer satisfaction
Lets use these solution guidelines in
a Fishbone diagram to explore
further! Our goal is to increase sales
in the catalog division. Brainstorm!
You can now take each one of the
specific solutions from the Fishbone
diagram, and brainstorm around it a
number of alternatives.
Lets just look at one
Produce smaller specialty catalogs
targeting specific groups.
Brainstorming
Consider specialty groups
Babies/small children
Baby clothes, targeting expectant mothers
Baby shower catalogs
Educational games for pre-school
Specialty baby foods
Handy gadgets for baby care
Elderly
Convenience items for the infirm
Large print books
Group travel/companionship
Teenagers
Team logo products
Audio equipment
High-tech computer games (Feedback, VR)
CDs, DVDs, MP3s
Newlyweds
Honeymoon packages (travel; cruises)
Housing/real estate service
Gift ideas
The brainstorming technique
generated some ideas not previously
brought forth, such as a national
catalog travel agency, that would
target diverse groups such as
newlyweds or the elderly. Also, the
entertainment market may be worth
investigating further.
These areas may be fertile ground
for diversification.
Lets try another brainstorming
technique called random stimulation
to explore more possibilities
Random Stimulation
Choose a random word
>>rand;
>> violin
What does violin bring to mind?
Music -> CDs/MP3s
Instrument -> marching band accessories
Strings -> fishing equipment -> boating
accessories -> nautical items -> nautical
fashions -> other specialty fashion clothes
Bow -> archery -> uncommon sporting good
items
Try another word
>> rand;
>> ghost
What does ghost bring to mind?
Witches -> brooms ->cleaning products,
appliances, gadgets
White -> sheets -> specialty bedding items,
towels, etc
Halloween -> costumes
More entertainment & leisure items were
generated, along with some new items.
Lets summarize in a Fishbone diagram,
concentrating on specialty catalogs.
Each one of these could be targeted catalogs
Each one of these could be targeted catalogs
Decision Analysis
The next step is to determine
which of the identified catalogs
should be printed.
To do this, we would list our
MUSTS and WANTS
MUST show a profit in 18 months
WANT to operate without hiring new
personnel
etc, etc
Decision Analysis
MUSTS Travel Baby Items Etc etc
Turn a profit in 18
months
GO GO NO GO
WANTS Weight Rating Score Rating Score
Use existing
personnel
10 10 100 9 90
Etc 9 8 72 7 63
Etc 8 4 32 2 16
Etc 7 2 14 1 7
218 176
NO GO
Travel catalog wins!
Potential Problem Analysis
Now, we
want to do a
PPA to
identify any
potential
complications
with this
solution.
Sears Catalog Summary
Of course, this analysis gets to be
very large as you explore more
parameters and more options
(i.e., 6 books).
You will notice, however, that we
followed the general heuristic we
developed in this course.
Define
Generate
Decide
Implement
Evaluate
Find out where the problem is
Explore the problem
PS/DS-Duncker diagram
Statement-Restatement
Blockbusting
Random stimulation
Analogy
KT Analysis
Situation
Problem
Decision
Potential Problem
Plan
Carry through
Experiment
Gantt
Deployment
Critical path
Satisfy objectives
Ethical considerations
Safety considerations
Six Simples Rules
Take a proactive approach not only to problem
solving but also to your life.
Have a vision of what you want to accomplish
and take steps that are in the right direction
Dont be afraid to fail. We can learn from our
failures.
Observe good problem solvers. Ask them
questions and brainstorm with them.
Dont dismiss ideas of others immediately; use
them as triggers.
Get into the habit of planning your time and
prioritizing the tasks you must accomplish.