Intro to Monte Carlo simulation

© All Rights Reserved

9 views

Intro to Monte Carlo simulation

© All Rights Reserved

- Statistics Formula Sheet
- ME 1 sem syllabus in regulation 2013
- 02 EMT Presentation
- Avoiding_Detection__Scripter_Edition_-_Scripter_Discussion_-_TRiBot_Forums.pdf
- Probability & Probability Distribution
- Sparse Data
- bsc-h-compsci
- Statistics
- Chapter1(2) Edit
- ITS Undergraduate 16482 3107100058 Paper
- Normal Distribution
- Two Way Anova Class
- 3. Management-Activity Prediction for Differently-Mouneshachari S
- Standard Deviation
- Descriptive Statistics Inc Normality Test AdaptiveBMS
- Markov Random Field Extensions using State Space Models
- Gaussian Wiretap Channel With Amplitude and Variance Constraints.pdf
- Error Probability in Digital Fiber Optic Communication Systems 1979
- Ideal gases and the ideal gas law_ pV = nRT
- sol-quiz1-2011

You are on page 1of 19

A

G

L

A

E

ID O

L

N

A AR

C

V

A

O

A

S

R

P

A

A

T

S

A

2

M

0

,

4

O

M

S

E

T

N

B

IV

IT

Q: If I gave you an unfair coin, how would you determine its

bias?

A: Flip it several times, find the ratio of heads to tails

What youve done is a Monte Carlo

Not exact, but can get as close as you want (Law of Large

Numbers, stay tuned)

In the spirit of the name Monte Carlo, how would you find the probability of getting

a full house with triple aces in Texas Holdem with 3 other players?

1. Calculate it from first principles of probability

2. Deal lots of random games and count the number that gave trip aces and a pair

Pros

Pros

Exact

Rigorous

Can be done quickly by a

computer

Cons

Cons

Difficult?

Time consuming

Not exact (approximate)

How does pressure vary as a function of volume, number of

molecules (N, not n), and temperature in an ideal gas?

1. Calculate it from first principles of

mechanics/thermodynamics (statistical mechanics)

2. Simulate lots of particles moving and interacting

according to the assumptions of kinetic theory and the laws

of physics

1. Gasses consist of pointlike molecules with negligible volume

but significant mass

2. All molecules have the same mass

3. The number of particles is large (we can use statistics; the

Monte Carlo method is justified)

4. Molecules interact elastically (with each other, and with the

walls of the container)

Elastic = kinetic energy is conserved

5. Molecules are in random motion, the x, y, and z components

of their velocities follow normal distributions

http://quantumfreak.com/

There are more particles with velocity near the mean (, average)

Histogram the particle velocities, and they will look like the graph

below

our simulated particles, they must follow this

distribution (histogram must look like bell curve)

http://www.itl.nist.gov/div898/handbook/pmc/

section5/pmc51.htm

mean

mean approaches the

population mean

Regardless of population

distribution, the histogram of

observed sample means follows

a normal distribution

INITIALIZATION

chamber size

number of particles

particle mass

temp

length of simulation

size of timestep t

Position: uniform distribution for each component

Velocity: normal distribution (bell curve) for each component: ,

entirely contained in the positions and velocities of the particles

INITIALIZATION - CODE

cham ber_size = .05 # m eters

a_tot = 24 * cham ber_size ** 2 # m ^ 2 (6 sides, each squares of side 2*cham ber_size)

num _particles = 100000

particle_m ass = 6.6335e-26 # kg, m ass of argon

tem p = 300 # kelvin

k = 1.3806503e-23 # boltzm ann constant, in m ^ 2 kg s^ -2

particle_pos = [[uniform (-cham ber_size, cham ber_size) for iin range(3)]

for iin range(num _particles)] # m eters

particle_vel= [[norm alvariate(0, sqrt(k*tem p/particle_m ass)) for iin range(3)]

for iin range(num _particles)] # m /s

[x2, y2, z2],

...

[xn, yn, zn]]

[vx2, vy2, vz2],

...

[vxn, vyn, vzn]]

How do I access the x

coordinate of the 84th

particle?

How do I access the z

component of the 4th

Seconds?

1. Each particle moves a distance of (vx t) in the x direction,

(vy t) in the y direction, (vz t) in the z direction

Code: particle_pos[i][coord] + = particle_vel[i][coord] * delta_t

xi

Seconds?

2. Particles collide with walls, imparting momentum (impulse) to them

Q: What would happen in our simulation?

A: The particle would go through the wall! Fix this:

(xf,

yf)

(xf,

y f)

(xi,

y i)

xwall

xf = xwall (xf

xwall)

= 2*xwall xf

y'f = yf

Seconds?

2. Particles collide with walls, imparting momentum (impulse) to

them

collision?

A: It is equal

(vxfto

, the change in momentum of the particle, ie 2

* m * vx

vyf)

(vxf,

vyf)

(vxi,

vyi)

vxf = -vxf =

-vxi

v'yf = vyf =

vyi

xwall

vx = -2vx

vy = 0

Seconds?

2. Particles collide with walls, imparting momentum (impulse)

to them

if particle_pos[i][coord] > cham ber_size:

# put it back in the cham ber

particle_pos[i][coord] = 2 * cham ber_size - particle_pos[i][coord]

# reverse its velocity in this direction

particle_vel[i][coord] = -particle_vel[i][coord]

# add the m om entum im parted to the w allof the cham ber

p_tot + = 2 * particle_m ass * abs(particle_vel[i][coord])

Seconds?

2. Particles collide with walls, imparting momentum (impulse)

to them

Furthermore, the sum of momentum imparted to the walls by all

the particles in one timestep is equal to the total impulse on the

walls in that timestep

This total impulse gives us the force on the walls, which gives us

the pressure (P=F/A, and we know the area because we chose

the size of the container!)

f_tot = p_tot / delta_t

pressure = f_tot / a_tot

KINETIC ENERGY

v(T), Ideal Gas Law

Rearrangements

RESULTS

Boyle's Law

4.50E-13

4.00E-13

3.50E-13

3.00E-13

2.50E-13

Pressure (Pa)

P = (4.13E-16)

(1/V)

2.00E-13

1.50E-13

1.00E-13

5.00E-14

0.00E+00

0

200

400

600

800

1000

1200

1/Volume (m^-3)

particle_mass = 3E-30kg

Compare with P = NkT (1/V) NkT = 4.14E-16

RESULTS

Gay-Lussac's Law

8.00E-13

7.00E-13

6.00E-13

5.00E-13

Pressure (Pa)

4.00E-13

P = (1.38E15)T

3.00E-13

2.00E-13

1.00E-13

0.00E+00

50

100

150

200

250

300

350

400

450

500

550

Temperature (K)

001m3, particle_mass = 3E-30kg

Compare with P = (Nk/V)T Nk/V = 1.38E-15

RESULTS

Mass variation

8.00E-13

7.00E-13

6.00E-13

5.00E-13

4.00E-13

Pressure (Pa)

3.00E-13

2.00E-13

1.00E-13

1.00E-29

1.00E-28

1.00E-27

1.00E-26

1.00E-25

1.00E-24

0.00E+00

1.00E-23 1.00E-22

001m3, temp = 500K

Compare with P = (Nk/V)T Nk/V = 1.38E-15

THANK YOU!

Thanks for your attention

Please provide feedback, comments, questions, etc:

vyassa.baratham@stonybrook.edu

- Statistics Formula SheetUploaded bymeolinh
- ME 1 sem syllabus in regulation 2013Uploaded byManickamSankaran
- 02 EMT PresentationUploaded byttoorrii
- Avoiding_Detection__Scripter_Edition_-_Scripter_Discussion_-_TRiBot_Forums.pdfUploaded byJordan
- Probability & Probability DistributionUploaded byVinamra Singh
- Sparse DataUploaded bysohorabatscribd
- bsc-h-compsciUploaded byWaqar Afridi
- StatisticsUploaded byShraddha Durgan
- Chapter1(2) EditUploaded byJames Thee
- ITS Undergraduate 16482 3107100058 PaperUploaded byArga Sandhi
- Normal DistributionUploaded bySalomón CB
- Two Way Anova ClassUploaded byAbhishek Fanse
- 3. Management-Activity Prediction for Differently-Mouneshachari SUploaded byBESTJournals
- Standard DeviationUploaded bycal2_uni
- Descriptive Statistics Inc Normality Test AdaptiveBMSUploaded byneeltan142
- Markov Random Field Extensions using State Space ModelsUploaded byTao Chen
- Gaussian Wiretap Channel With Amplitude and Variance Constraints.pdfUploaded byTa Hien
- Error Probability in Digital Fiber Optic Communication Systems 1979Uploaded byJun Hong Koay
- Ideal gases and the ideal gas law_ pV = nRTUploaded byTundeOyedotun
- sol-quiz1-2011Uploaded byJon Ahn
- script 02-03-18Uploaded byRamiroScorolli
- FormUploaded bypankaj baviskar
- Stats FormulaUploaded byBryan
- 5. Equipartition & Ideal Gases IUploaded byfruitsbasket
- Concepts 20 20 20 20formula 20of 20chemistryUploaded bysandeep shukla
- NormalUploaded byMark Kevin Aguilar
- 12-confint (3)Uploaded byNovica Petkovic
- EnKF5.pdfUploaded byNovat
- 43288415Uploaded byACastisho
- Chapter08 NewUploaded byTrí

- Chicago Gun Trace Report 2017Uploaded byDNAinfo Chicago
- US Federal Trade Commission: dbcfinancialUploaded byftc
- vnvnbvbnUploaded byChristopher Medina Alcantara
- 2. ENGRACIO FABRE, JR., ET AL. v. COURT OF APPEALS, ET AL. G.R. No. 111127 July 26, 1996.pdfUploaded byIvan Angelo Apostol
- Auditor LiabilityUploaded byJunel Tamayao
- Introduction of Private PlacementUploaded bypiyushmathur
- Welding Of Boilers, Pressure Vessels And Pressure Piping Pressure PipingUploaded byNilesh Khade
- Liberty of Abode and Travel Case DigestsUploaded byValerie Tio
- Cheng vs GenatoUploaded byKim Lorenzo Calatrava
- People vs. RitterUploaded byAlecsandra Chu
- William Howard v. W. Frank Smyth, Jr., Director, Virginia Division of Corrections, 365 F.2d 428, 4th Cir. (1966)Uploaded byScribd Government Docs
- 83080891 Bars to Matrimonial RemediesUploaded byDhaval Vyas
- Bulgaria Tax Card 2015Uploaded bysagetarius92
- 19. Evangelista v Mercator Finance CorpUploaded byHeidi
- LABRECQUE v. SCHOOL ADMINISTRATIVE DISTRICT 57 et al - Document No. 12Uploaded byJustia.com
- Marcos vs. Manglapus, 177 SCRA 668; 1989Uploaded byHazelGarcia
- Christopher Morgan v HSBCUploaded byGlenn Augenstein
- Contech vs CAUploaded byJaynardVelarmino
- 255 North Front Easement Becomes AcquisitionUploaded byBen Schachtman
- Persons_M108 People v SilvanoUploaded byBebelan A. Madera
- Registrations InstructionsUploaded byAnuvind Myself
- Fyre Festival caseUploaded byAnonymous u1ag3aB7M
- IRCTC Ltd,Booked Ticket PrintingUploaded byAmit Kumar Bhoi
- f982Uploaded bywa du
- CasesUploaded byronilarbis
- Wrif of Habeas DataUploaded byStephanie Reyes Go
- Lily s Villamil vs Sps. ErguizaUploaded bykristel jane caldoza
- CIVLAWREV-Persons Ass. 7 CasesUploaded byfranciscomitz
- Comp.law.Proj-Dematerialization of SharesUploaded byUtkarsh Singh
- Land Bank vs PerezUploaded byAnonymous KvztB3