# AN IDEAL GAS MONTE CARLO VYASSA BARATHAM, STONY BROOK UNIVERSITY APRIL 20, 2013, 2:20-3:20PM CSPLASH 2013.

## Presentation on theme: "AN IDEAL GAS MONTE CARLO VYASSA BARATHAM, STONY BROOK UNIVERSITY APRIL 20, 2013, 2:20-3:20PM CSPLASH 2013."— Presentation transcript:

AN IDEAL GAS MONTE CARLO VYASSA BARATHAM, STONY BROOK UNIVERSITY APRIL 20, 2013, 2:20-3:20PM CSPLASH 2013

WHAT IS A MONTE CARLO? 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)

WHAT IS A MONTE CARLO? AN EXAMPLE 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 1 Pros Exact Rigorous Cons Difficult? Time consuming 2 Pros Simple, easy to understand Can be done quickly by a computer Cons Not rigorous (probabilistic) Not exact (approximate)

OUR MONTE CARLO – IDEAL GASSES 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 (statistical mechanics) 2. Simulate lots of particles moving and interacting according to the assumptions of kinetic theory and the laws of physics

ASSUMPTIONS OF KINETIC THEORY 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/

NORMAL DISTRIBUTIONS (BELL CURVE) http://www.itl.nist.gov/div898/handbook/pmc/section 5/pmc51.htm

LAW OF LARGE NUMBERS

INITIALIZATION

INITIALIZATION - CODE chamber_size =.05 #meters a_tot = 24 * chamber_size ** 2 #m^2 (6 sides, each squares of side 2*chamber_size) num_particles = 100000 particle_mass = 6.6335e-26 #kg, mass of argon temp = 300 #kelvin k = 1.3806503e-23 #boltzmann constant, in m^2 kg s^-2 particle_pos = [[uniform(-chamber_size, chamber_size) for i in range(3)] for i in range(num_particles)] #meters particle_vel = [[normalvariate(0, sqrt(k*temp/particle_mass)) for i in range(3)] for i in range(num_particles)] #m/s particle_pos: [[x 1, y 1, z 1 ], [x 2, y 2, z 2 ],... [x n, y n, z n ]] particle_vel: [[v x1, v y1, v z1 ], [v x2, v y2, v z2 ],... [v xn, v yn, v zn ]] How do I access the x coordinate of the 84 th particle? How do I access the z component of the 4 th particles velocity?

SIMULATION: What Happens in Δt Seconds? 1.Each particle moves a distance of (v x Δt) in the x direction, (v y Δt) in the y direction, (v z Δt) in the z direction Code: particle_pos[i][coord] += particle_vel[i][coord] * delta_t xixi x f = x i + (v x, v y, v z )Δt

SIMULATION: What Happens in Δt 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: (x f, y f ) (x i, y i ) (x f, y f ) x wall x f = x wall – (x f – x wall ) = 2*x wall – x f y' f = y f

SIMULATION: What Happens in Δt Seconds? 2.Particles collide with walls, imparting momentum (impulse) to them Q: What is the momentum imparted to the wall by one collision? A: It is equal to the change in momentum of the particle, ie 2 * m * v x (v xi, v yi ) (v xf, v yf ) x wall (v xf, v yf ) v xf = -v xf = -v xi v' yf = v yf = v yi Δv x = -2v x Δv y = 0

SIMULATION: What Happens in Δt Seconds? if particle_pos[i][coord] > chamber_size: #put it back in the chamber particle_pos[i][coord] = 2 * chamber_size - particle_pos[i][coord] #reverse its velocity in this direction particle_vel[i][coord] = -particle_vel[i][coord] #add the momentum imparted to the wall of the chamber p_tot += 2 * particle_mass * abs(particle_vel[i][coord]) 2.Particles collide with walls, imparting momentum (impulse) to them

SIMULATION: What Happens in Δt 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!) #calculate pressure from momentum f_tot = p_tot / delta_t pressure = f_tot / a_tot

KINETIC ENERGY Combination (sub in kT) Rearrangements v(T), Ideal Gas Law

RESULTS P = (4.13E-16)(1/V) With num_particles = 100000, temp = 300K, particle_mass = 3E-30kg Compare with P = NkT (1/V) NkT = 4.14E-16

RESULTS P = (1.38E-15)T With num_particles = 100000, volume =.001m 3, particle_mass = 3E-30kg Compare with P = (Nk/V)T Nk/V = 1.38E-15

RESULTS With num_particles = 100000, volume =.001m 3, temp = 500K Compare with P = (Nk/V)T Nk/V = 1.38E-15