monte carlo integration in excel sean gant jay lee

10
Monte Carlo Integration in Excel Sean Gant Jay Lee

Upload: clemence-mcdonald

Post on 25-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Monte Carlo Integration in Excel Sean Gant Jay Lee

Monte Carlo Integration in Excel

Sean Gant

Jay Lee

Page 2: Monte Carlo Integration in Excel Sean Gant Jay Lee

A

y

x

B

f(x)

Monte Carlo Integration

Page 3: Monte Carlo Integration in Excel Sean Gant Jay Lee

Monte Carlo Integration

A

y

x

B

f(x)

Page 4: Monte Carlo Integration in Excel Sean Gant Jay Lee

Monte Carlo Integration

A

y

x

B

f(x)

B

total

below

N

NABdxxf

0)(

Page 5: Monte Carlo Integration in Excel Sean Gant Jay Lee

Gas-phase elementary reaction:2A → B

Isothermal reaction in a PFR with no pressure drop

Only A is fed, P0 = 8.2 atm, T0 = 500K, ε = -0.5

CA0 = 0.2 mol/dm3, k = 10 dm3/mol-s, vo = 25 dm3/s

QUESTIONWhat volume is needed to achieve 90% conversion?

Page 6: Monte Carlo Integration in Excel Sean Gant Jay Lee

Mole Balance:

Rate Law:

Stoichiometry:

Combine:

X

AA r

dXFV

0

0

2AA kCr

)1(

)1(

0

0

Xv

XF

v

FC AAA

dXX

X

kC

FV

X

A

A

0 2

2

20

0

)1(

)5.01(

Page 7: Monte Carlo Integration in Excel Sean Gant Jay Lee

Setting Up Excel Spreadsheet

• What are your inputs? (Using “Rand()” Function)– X: Your independent variable (range you are

integrating)– Y: Dependent variable ( from 0 to max over X-

range)

• What is your defined area?– L x W of “box” (multiply the two ranges)

• What constitutes a hit?– If random point lies below function then “hit”

Page 8: Monte Carlo Integration in Excel Sean Gant Jay Lee

Setting up Excel Spreadsheet

Page 9: Monte Carlo Integration in Excel Sean Gant Jay Lee

Setting up Excel Spreadsheet• Random Number Generator

– Rand()*(b-a)+a • Generate a number between a and b

• The “Status”– If(X<f(X), “below”, “above”)

• If value of f(X) > Y then mark “below”

• The “Count”– If(Status=“below”,1,0)

• If value of status is “below” then count a “hit”

• Making sense of data– Take total number of hits and divide by total number of points to

find fraction under function– Multiply calculated fraction by area of “box” to find the area

under the curve. In this case this value is the volume of your PFR. 44.6 dm3 as compared to 45.3 dm3 found by solving analytically.

Page 10: Monte Carlo Integration in Excel Sean Gant Jay Lee

Setting up Excel Spreadsheet