This is an old revision of the document!
Ideal Gas Law Activity
Follow this link for the activity and the instructions: link
Or, read the instructions after the image below, and copy the code into your own GlowScript file.
You should see something that looks like this:
If you click on the “Instructions” tab in the upper right, a set of instructions for the activity should pop up. Click between “Instructions” and “Result” to alternately view the instructions and the animation. If you prefer, the same instructions are also listed below.
* Try runnning your code. You'll notice that our gas particle is currently escaping the box.
- Line 34: Add an if statement to check for when the gas particle collides with a wall.
For more information on glowscript tools, check out: https://www.glowscript.org/docs/GlowScriptDocs/index.html
GlowScript 2.7 VPython ## Constants L=1 #Give our container a length of 0.1m on each side N_Avogodro=6.02E23 # Avogodro's constant k_B=1.38E-23 # Boltzmann constant ## Gas information mass = 4E-3/N_Avogodro # helium mass in kg/atom Ratom=0.1 # exaggerated size of helium atom T=300 # Temperature equals 300 K ## Calculate v_rms based on your gas #v_rms= ## Setup a container with a gas particle inside container = box(pos=vec(0,0,0), size=vec(L+2*Ratom,L+2*Ratom,L+2*Ratom), color=color.white, opacity=0.1) particle = sphere(pos=vec(0,0,0), radius = Ratom, color = color.red) ## Assign the particle a fixed velocity particle.velocity = vector(3000,0,0) ## Set up the time variables for the while loop dt = 1E-6 t = 0 ## While loop to iterate over the time interval while True: rate(200) # Keeps animation slow enough to view ## Euler step to predict location of particle in a time dt particle.pos = particle.pos + particle.velocity*dt ## Add if statement here t = t + dt