You are on page 1of 80

Monte Carlo Simulation experimental and

theoretical view

Introduction

The History of Monte Carlo Simulation

Buffon
Kelvin
Gosset (Student)

Fermi, von Neumann, Ulam


Neutron transport
System Transport (RAMS)
Uncertainty and Sensitivity Analysis

170788

18241907
1908

193040s

1950s

1990s

RAMS: evaluating the probability of system failure

Y
S

P( F ) P( x F ) I F ( x)q( x)d x

x x1, x2 , ..., x j , ..., xn : vector of the uncertain system parameters


n

q( x ) q j ( x j ) : multidimensional probability density function (PDF) of


j 1

F n : failure region (in this case, F = {Y(x) > Y})


1, if x F (Y(x) > Y)
n
I F ( x) : 0,1 : indicator function - I F ( x )
0, if x F (Y(x) Y)

Passive decay heat removal system of a


Gas-cooled Fast Reactor (GFR)

Nine uncertain parameters, x (Gaussian):


Power
Pressure
Cooler wall temperature
Nusselt numbers (forced, mixed, free)
Friction factors (forced, mixed, free)

x :T

hot
out,core

x :T

x 1200 C

avg
out,core

Tout,core

SYSTEM FUNCTIONAL FAILURE


F
=

x 850 C

Isolation Condenser in SBWR


The Isolation Condenser (IC) system is designed to remove excess sensible and core
decay heat from the Simplified Boiling Water Reactor (SBWR) by natural circulation,
when the normal heat removal system is unavailable

11 design and critical parameters 40 subcritical parameters to be investigated

RHR System in HTR-PM


The Passive Residual Heat Removal (RHR) System of the HTR-PM
Legend:
1.Reactor
2.Vessel
3.Water cooling wall
4.Hot water header
5.Cold water header
6.Shade
7.Hot leg
8.Cold leg
9.Water tank
10.Air cooler
11.Air cooling tower
12.Inlet shutter
13.Outlet shutter
14.Inlet net
15.Outlet net
16.Wind shield

RHR System in HTR-PM


The Simulation Code Models

Residual Heat in
Reactor Core

radiation

Water-Cooled Wall
Natural circulation
Air-Cooler in the
Tower

Atmosphere

37 Inputs

natural convection

Problem statement
Description of phenomena Adoption of mathematical models
(which are for example turned into
operative computer codes for simulations)
Models Deterministic or Stochastic

In practice the system under analysis can not be characterized exactly


and the knowledge of the undergoing phenomena is incomplete

Uncertainty on both the values of the model parameters and


on the hypothesis underlying the model structure

Uncertainty propagates within the model and causes uncertainty


of the model outputs

How uncertainty propagates

y = m(x)

m(x)

y = m(x)
x = vector of n uncertain input
parameters
m(x) = model structure
Deterministic (e.g., advection-dispersion equation, Newton law)
(e.g., Poisson model, exponential model)
Stochastic
y = output vector correspondent
to x and m(x)

Reliability assessment failure probability


evaluation by Monte Carlo (MC)

11

Monte Carlo (MC)


sampling of uncertain parameters
(probability distributions)
x = {x1, x2, , xj, , xn}

System model code


(e.g. RELAP)

Fuel cladding
Temperature, Y(x)

NT independent runs

Failure threshold, Y

S
Time

System
performance indicator, Y(x)

number Y x Y
Sample estimate of the failure probability P(F), P F
NT

The Monte Carlo (MC)-based approach for failure probability


evaluation: drawbacks

12

numberY x Y
P F
NT

LONG CALCULATIONS!

SMALL NUMBER FOR


HIGHLY RELIABLE SYSTEMS!

+
UNCERTAINTY/CONFIDENCE

The Monte Carlo (MC)-based approach for failure probability


evaluation: technical developments

13

ESTIMATION OF THE RELIABILITY OF T-H SYSTEMS

Issues:
TRANSIENTS
GENERATION

Rare failure events


-Failure Domain
(FD) Identification
- Confidence on the
Safety Margin
estimation

Solutions:
Advanced MC Simulation
methods
1. Subset Simulation (SS)
2. Line Sampling (LS)
Order statistics

Long calculations
Meta-models (e.g. Artificial Neural Networks)
1. Identification of important directions for pointing towards the failure region FD
2. Pre-selection of failure transients

The experimental view

Contents

Sampling Random Numbers


Simulation of system transport
Simulation for reliability/availability analysis of a component
Examples

SAMPLING RANDOM
NUMBERS

Example: Exponential Distribution

Probability density function:

f T ( t ) e t

t0

t0

Expected value and variance:


1
E[T ]

fT(t)

fT (t ) e t

Var[T ]

2
t

Sampling Random Numbers from FX(x)

Sample R from UR(r) and find X:

X FX1 R

Example: Exponential distribution

FX x 1 ex
R FX x 1 ex

X FX1 R

ln 1 R

Sampling from discrete distributions

x0 , x1 ,..., xk ,...
k

Fk P X xk P X xi
i 0

sample an R ~ U [0,1)

Graphically:

Failure probability estimation: example

Arc number i
1
2
3
4
5

Failure
probability Pi
0.050
0.025
0.050
0.020
0.075

1- Calculate the analytic solution for the failure probability of the network,
i.e., the probability of no connection between nodes S and T
2- Repeat the calculation with Monte Carlo simulation

Analytic solution

1) Minimal cut sets


M2={2,5}
M3={1,3,5}
M4={2,3,4}
2) Network failure probability (rare event approximation):
4

P[ X T 1] P[M j ] 3.07 103


j 1

P[ M 1 ] p1 p4 0.05 0.02 1103


P[ M 2 ] p2 p5 0.025 0.075 1.875 103
P[ M 3 ] p1 p3 p5 0.05 0.05 0.075 1.875 104
P[ M 4 ] p2 p3 p4 0.025 0.05 0.02 7.5 105
21

Monte Carlo simulation

The arrival state of arc i after it has undergone a transition can be


sampled by applying the inverse transform method to the set of discrete
probabilities pi ,1 pi of the mutually exclusive andexhaustive arrival
states
B
1
2
pi B
1

B
1
S
3
B
1i

1 p

R
S

We calculate the arrival state for all the arcs of the newtork
As a result of these transitions, if the system falls in any configuration
corresponding to a minimal cut set, we add 1 to Nf
The trial simulation then proceeds until we collect N trials. We obtain
the estimation of the failure probability dividing Nf by N

Monte Carlo simulation

N number of trials
NF number of trials corresponding to realization of a minimal cut set
The failure probability is equal to NF / N

clear all;
%arc failure probabilities
p=[0.05,0.025,0.05,0.02,0.075]; nf=0;
n=1e6; %number of MC simulations
for i=1:n
%sampling of arcs fault events
r=rand(1,5); s=zeros(1,5); rpm=r-p;
for j=1:5
if (rpm(1,j)<=0)
s(1,j)=1;
end
end
%cut set check
fault=s(1,1)*s(1,4)+s(1,2)*s(1,5)+s(1,1)*s(1,3)*s(1,5)+s(1,2)*s(1,3)*s(1,4);
if fault >= 1
nf=nf+1;
end
end
pf=nf/n; %system failure probability

For n=106, we obtain

P[ X T 1] 3.04 103

SIMULATION OF SYSTEM
TRANSPORT

Monte Carlo simulation for system reliability

PLANT = system of Nc suitably connected components.


COMPONENT = a subsystem of the plant (pump, valve,...) which may stay
in different exclusive (multi)states (nominal, failed, stand-by,... ). Stochastic
transitions from state-to-state occur at stochastic times.
STATE of the PLANT at t = the set of the states in which the Nc
components stay at t. The states of the plant are labeled by a scalar which
enumerates all the possible combinations of all the component states.
PLANT TRANSITION = when any one of the plant components performs a
state transition we say that the plant has performed a transition. The time at
which the plant performs the n-th transition is called tn and the plant state
thereby entered is called kn.
PLANT LIFE = stochastic process.

Plant life: random walk

Random walk = realization of the system life generated by the underlying


state-transition stochastic process.

Phase Space

Example: System Reliability Estimation

C R (t ) C R (t ) t 0, TM

C R (t ) C R (t ) 1 t , TM

C R (t ) C R (t ) 1 t , TM

C R (t ) C R (t ) t 0, TM
R

Events at components
level, which do not entail
system failure

C (t )
FT (t )
M

Stochastic Transitions: Governing


Probabilities

T(tt; k)dt = conditional probability of a transition at tdt, given that the


preceding transition occurred at t and that the state thereby entered was
k.
C(k k; t) = conditional probability that the plant enters state k, given that
a transition occurred at time t when the system was in state k. Both these
probabilities form the trasport kernel:
K(t; k t; k)dt = T(t t; k)dt C(k k; t)
(t; k) = ingoing transition density or probability density function (pdf) of a
system transition at t, resulting in the entrance in state k

SIMULATION FOR COMPONENT


AVAILABILITY / RELIABILITY
ESTIMATION

One component with exponential


distribution of the failure time

1
m

State 2
State 1

State X=1 ON
State X=2 OFF

One component with exponential


distribution of the failure time

1
m

State 2
State 1

State X=1 ON
State X=2 OFF

One component with exponential


distribution of the failure time

1
m

State 2
State 1

State X=1 ON
State X=2 OFF

One component with exponential


distribution of the failure time

values
2

3 10-3 h-1

25 10-3 h-1

State X=1 ON
State X=2 OFF

Limit unavailability:

1/ m
U
0.1071
1/ m 1/

Monte carlo simulation for estimating the


system availability at time t
- Nt time intervals t
- If the component fails in t+t, the counter increases cA(tj) =
cA(tj) +1; otherwise, cA(tj) = cA(tj)

Trial 1

Monte carlo simulation for estimating the


system availability at time t
- another trial

Trial 1
Trial i-th

Monte carlo simulation for estimating the


system availability at time t
- another trial

Trial 1
Trial i-th
Trial M-th

Monte carlo simulation for estimating the


system availability at time t

The counter cA(tj) adds 1 until M trials have been sampled

GA (t j )

P{ X (t ) 1}= unavailability at time tj


= mean value of cA(tj) at time tj

Trial 1
Trial i-th

Trial M-th

GA (t j )

c A (t j )
M

Pseudo Code

%Initialize parameters
Tm=mission time; Nt=number of trials; Dt=bin length;
Time_axis=0:Dt:Tm;

0.8

Unavailability
Falta de disponibilidad

FOR i=1:Nt
%parameter initialization for each trial
t=0; failure_time=0; repair_time=0; state=1;
while t<Tm
if state=1
t=t+exprnd(1/lambda); state=2; failure_time=t;
lower_b=minimum(find(time_axis>=failure_time));
counter(i,lower_b)=1;
Else
t=t+exprnd(1/mu); state=1; repair_time=t;
upper_b=find(time_axis<up_time,1,'last');
counter(i,lower_b+1:upper_b)=1;
Endif
End while
End For
unav=sum_channel(counter)/n_simulations

nico
Singleensayo
trial
Monte CarloMonte
simulation
Simulacion
Carlo
Limit de
unavailability
Falta
disponibilidad en estado estacionario

0.6

0.4

0.2

0
0

100

200

300

400

500
Tiempo

Time

600

700

800

900

1000

SIMULATION FOR SYSTEM


AVAILABILITY / RELIABILITY
ESTIMATION

Phase Space

Indirect Monte Carlo: Example (1)

A
C
B

Components times of transition between states are exponentially distributed


( ij m = rate of transition of component i going from its state ji to the state mi)
1

Initial

Arrival
2

1A( B2)

1A( B3)

21

( B)
2A
3

3A( B1)

A( B )

3A( B2)

Indirect Monte Carlo: Example (2)

Initial

Arrival
1

C
1
2

C
1
3

C
1
4

C21

C23

C24

C31

C32

C34

C41

C42

C43

The components are initially (t=0) in their nominal states (1,1,1)


One minimal cut set of order 1 (C in state 4:(*,*,4)) and one minimal
cut set of order 2 (A and B in 3: (3,3,*)).

Analog Monte Carlo Trial

SAMPLING THE TIME OF TRANSITION


The rate of transition of component A(B) out of its nominal state 1 is:

1A( B ) 1A( B2) 1A( B3)


The rate of transition of component C out of its nominal state 1 is:

1C 1C2 1C3 1C4


The rate of transition of the system out of its current configuration (1,
1, 1) is:
1,1,1 1A 1B 1C
We are now in the position of sampling the first system transition time
t1, by applying the inverse transform method:
t1 t 0

where Rt ~ U[0,1)

1,1,1

ln(1 Rt )

Sampling the kind of Transition (1)

Assuming that t1 < TM (otherwise we would proceed to the successive trial),


we now need to determine which transition has occurred, i.e. which
component has undergone the transition and to which arrival state.
The probabilities of components A, B, C undergoing a transition out of their
initial nominal states 1, given that a transition occurs at time t1, are:

1A ,
1,1,1

1B ,
1,1,1

1C
1,1,1

Thus, we can apply the inverse transform method to the discrete distribution

1A C
1,1,1

R
C

1B
1,1,1

1C
1,1,1
1

Sampling the Kind of Transition (2)

Given that at t1 component B undergoes a transition, its arrival state


can be sampled by applying the inverse transform method to the set of
discrete probabilities
B
B
12 13
B , B
1 1

of the mutually exclusive and exhaustive arrival states


B
1
2
B
1

B
1
3
B
1

S
R

RSU[0,1)

As a result of this first transition, at t1 the system is operating in


configuration (1,3,1).
The simulation now proceeds to sampling the next transition time t2 with
the updated transition rate
1,3,1
A
B
C

1 3 1

Sampling the Next Transition

The next transition, then, occurs at

t 2 t1

1,3,1

ln(1 Rt )

where Rt ~ U[0,1).
Assuming again that t2 < TM, the component undergoing the transition and
its final state are sampled as before by application of the inverse trasform
method to the appropriate discrete probabilities.
The trial simulation then proceeds through the various transitions from one
system configuration to another up to the mission time TM.

Unreliability and Unavailability Estimation

When the system enters a failed configuration (*,*,4) or


(3,3,*), where the * denotes any state of the component,
tallies are appropriately collected for the unreliability and
instantaneous unavailability estimates (at discrete times tj
[0, TM]);
After performing a large number of trials M, we can
obtain estimates of the system unreliability
and
instantaneous unavailability by simply dividing by M, the
accumulated contents of CR(tj) and CA(tj), tj[0,TM]

Direct Monte Carlo: Example (1)

A
C
B

For any arbitrary trial, starting at t=0 with the system in nominal
configuration (1,1,1) we would sample all the transition times:
i A, B, C

1
i
i
ln(1 Rt ,1mi )

t1mi t 0 i
m

2
,
3
for
i

A
,
B

i
1mi
mi 2,3,4 for i C
i
where Rt ,1mi ~ U [0,1)

Direct Monte Carlo: Example (2)

A
C
B

These transition times would then be ordered in ascending order from


tmin to tmaxTM .
Let us assume that tmin corresponds to the transition of component A
to state 3 of failure. The current time is moved to t1= tmin in
correspondence of which the system configuration changes, due to
the occurring transition, to (3,1,1) still operational.

Example (2)

The new transition times of component A are then sampled

A
3m A

t1

A
3m A

ln(1 R

A
t , 3m A

k 1,2
A

Rt ,3m A ~ U [0,1)

and placed at the proper position in the timeline of the succession of


occurring transitions
The simulation then proceeds to the successive times in the list, in
correspondence of which a system transition occurs.
After each transition, the timeline is updated with the times of the
transitions that the component which has undergone the last transition
can do from its new state.
During the trial, each time the system enters a failed configuration,
tallies are collected and in the end, after M trials, the unreliability and
unavailability estimates are computed.

The theoretical view

Contents

Sampling
Evaluation of definite integrals
Simulation of system transport
Simulation for reliability/availability analysis

Contents

Sampling
Evaluation of definite integrals
Simulation of system transport
Simulation for reliability/availability analysis

Buffons needle

Buffon considered a set of parallel straight lines a distance D apart onto a


plane and computed the probability P that a needle of length L < D randomly
positioned on the plane would intersect one of these lines.

P P Y L sin

fY ( y )
f ( )
P

1
D
1

y [0, D]

[0, ]

dy d
L/D

A D / 2

Sampling (pseudo) Random Numbers


Uniform Distribution

cdf :

U R r PR r r

pdf :

u R r

0
dU R r
1
dr

Sampling (pseudo) Random Numbers


Uniform Distribution

R ~ U [0,1)
xi axi 1 c mod m
Where

a, c [0, m 1]
m 1

ri

xi
m

Example: a = 5, c = 1, m = 16

x0 2 r0

2
16

x1 (5 2 1) mod 16 11 r1
...
x15 13 r15
x16 2

13
16

11
16

Sampling (pseudo) Random Numbers


Generic Distribution
F X x

PrR r U R r

Sample R from UR(r) and find X:

X FX1 R
r

1 R

Question: which distribution does X obey?

PX x PFX1 R x

Application of the operator Fx to the argument of P above yields

PX x PR FX x FX x
Summary: From an R UR(r) we obtain an X FX(x)

Example: Exponential Distribution

Markovian system with two states (good, failed)


hazard rate, = constant
cdf

FT t PT t 1 et

pdf fT t dt Pt T t dt et dt
Sampling a failure time T

R FR r FT t 1 et

1
T

T F

ln 1 R

Example: Weibull Distribution

hazard rate not constant


CDF FT t P T t 1 e t

pdf fT t dt P t T t dt t 1e t dt
Sampling a failure time T

R FR r FT t 1 e

T F R ln 1 R

1
T

Sampling by the Inverse Transform Method:


Discrete Distributions

x0 , x1 ,..., xk ,...
k

Fk P X xk P X xi
i 0

sample an R ~ U [0,1)

P Fk 1 R Fk FR ( Fk ) FR ( Fk 1 )
R ~ U [0,1) and FR (r ) r

P Fk 1 R Fk Fk Fk 1 f k P X xk

Graphically:

Contents

Sampling
Evaluation of definite integrals
Simulation of system transport
Simulation for reliability/availability analysis

MC Evaluation of Definite Integrals (1D)


Analog Case

G g x f x dx
b

f x pdf

f x 0 ;

f x dx 1

MC analog dart game: sample x from f(x)


the probability that a shot hits x dx is f(x)dx
the award is g(x)
Consider N trials with result {x1, x2, ,xn}: the average award is

1
GN
N

g x
i 1

MC Evaluation of Definite Integrals (1D)


Example
2

cos
x
dx

0.6366198
0 2

By setting: f

x 1,

G E g ( x)


g x cos x
2

2
cos
x

dx
0
2
1
Var GN
Var
g x

N
2
1 1 2
Var GN

N
2

E
g ( x)

1
2

1
2
2

E
g
(
x
)

E
g
(
x
)

N
1
9.47 10 2
N

for N 10 4 histories, xi ~ U [0,1) g xi cos xi


2

GN 0.6342, sG2 N 9.6 10 6

MC Evaluation of Definite Integrals (1D)


Biased Case

The expression for G may be written

f x

G
g x f1 x dx g1 x f1 x dx
D
D
f1 x

MC biased dart game: sample x from f1(x)


the probability that a shot hits x dx is f1(x)dx
the award is

f x
g1 x
g x
f1 x

G1N

1 N
g1 xi
N i 1

MC Evaluation of Definite Integrals (1D)


Biased Case: Example
2

G cos x dx
0.6366198

2
0
1

The pdf f1*(x) is: f1* ( x) a bx 2


From the normalization condition:
1

f ( x)dx a bx 2 dx 1 a
*
1

b
1 b 3(a 1)
3

f1* ( x) a 3(a 1) x 2

For the minimum value


1

G cos
0

xdx

cos

3
1.5
2

x 1

2
2

(1.5

1.5
x
) dx
2
1.5 1.5 x
0
f ( x)
g1 ( x )

MC Evaluation of Definite Integrals (1D)


Biased Case: Example
Finally we obtain:
1
Var1 G1N
N

2 1
4
0.406275 9.9026 10
N


cos xi
2
for N 104 histories, xi ~ f1* g1 xi
1.5 1.5 xi2

G1N 0.6366, sG21 N 9.95 108

Contents

Sampling
Evaluation of definite integrals
Simulation of system transport
Simulation for reliability/availability analysis

Monte Carlo simulation for system reliability

PLANT = system of Nc suitably connected components.


COMPONENT = a subsystem of the plant (pump, valve,...) which may
stay in different exclusive (multi)states (nominal, failed, stand-by,... ).
Stochastic transitions from state-to-state occur at stochastic times.
STATE of the PLANT at t = the set of the states in which the Nc
components stay at t. The states of the plant are labeled by a scalar
which enumerates all the possible combinations of all the component
states.
PLANT TRANSITION = when any one of the plant components
performs a state transition we say that the plant has performed a
transition. The time at which the plant performs the n-th transition is
called tn and the plant state thereby entered is called kn.
PLANT LIFE = stochastic process.

Plant life: random walk

Random walk = realization of the system life generated by the underlying


state-transition stochastic process.

Stochastic Transitions: Governing


Probabilities

T(tt; k)dt = conditional probability of a transition at t dt, given that the


preceding transition occurred at t and that the state thereby entered was k.
C(k k; t) = conditional probability that the plant enters state k, given that a
transition occurred at time t when the system was in state k.
Both these probabilities form the trasport kernel:
K(t; k t; k)dt = T(t t; k)dt C(k k; t)

(t; k) = ingoing transition density or probability density function (pdf) of a


system transition at t, resulting in the entrance in state k

The von Neumanns Approach and


the Transport Equation

The transition density (t; k) is expanded in series of the


partial transition densities:
n(t; k) = pdf that the system performs the nth transition at t,
entering the state k.
Then,

(t , k ) n (t , k )
n 0

0 (t , k ) dt ' (t ' , k ' ) K (t , k | t ' , k ' )


k ' t0

Transport equation for the plant states


74

Monte Carlo Solution to the Transport


Equation (1)

Initial Conditions: (t*, k*)


Formally rewrite the partial transition densities:

(t1 , k1 ) dt0 0 (t0 , k0 ) K (t1 , k1 t0 , k0 ) K (t1 , k1 t*, k *)


t1

k0

t*

(t 2 , k 2 ) dt1 1 (t1 , k1 ) K (t 2 , k 2 t1 , k1 )
t2

k1

t*

dt1 K (t1 , k1 t*, k *) K (t 2 , k 2 t1 , k1 )


t2

t*

k1

(t , k )
n

k1 ,k 2 ,...,kn 1
t2

tn

t*

dtn 1

tn 1

t*

dtn 2 ...

... dt1K (t1 , k1 t*, k *) K (t2 , k2 t1 , k1 ) K (t , k tn 1 , kn 1 )


t*

MC Evaluation of Definite Integrals

G g x f x dx
b

f x pdf

f x 0 ;

f x dx 1

MC analog dart game: sample x = (t1, k1; t2, k2; ...) from
f(x)= K (t1 , k1 t*, k*)K (t2 , k2 t1 , k1 ) K (t , k tn1 , kn1 )

the probability that a shot hits x dx is f(x)dx


the award is g(x)=1
Consider N trials with result {x1, x2, ,xn}: the average award is

1
GN
N

g x
i 1

Contents

Sampling
Evaluation of definite integrals
Simulation of system transport
Simulation for reliability/availability analysis

Monte Carlo Simulation in RAMS

G(t ) ( , k ) Rk ( , t )d
t

Expected value

= subset of all system failure states


Rk(,t) = 1 G(t) = unreliability
Rk(,t) = prob. system not exiting before t from the state k
entered at <t
G(t) = unavailability

Monte Carlo solution of a definite integral:


expected value sample mean

References

You might also like