Omniadisce

Computational physics 19.1: A gas in a box

Lesson Beginner

Join free to take this lesson

Anyone can look around, but taking a lesson needs a free account. With one, your answers are checked step by step and your progress is saved, so you can stop and pick up where you left off on any device.

12 steps · about 30 min

By the end you can

  • Keep the positions and velocities of many molecules in two arrays of N rows and 3 columns
  • Move every molecule at once with pos = pos + vel * dt
  • Make the walls bounce molecules back: out = (pos < 0) | (pos > L), then vel[out] = -vel[out]
  • Watch a gas spread out to fill its box, and measure the share in one half

Who it is for: Anyone who has done units 5, 9, 15 and 17 of this course, and physics lessons 12.4-12.5 (gases) and 20.1 (microstates).

The steps

  1. A gas you can follow
  2. Every molecule in one array
  3. Fill the box
  4. Every molecule moves at once
  5. One line moves them all
  6. Walls that bounce
  7. Picking entries
  8. Bounce
  9. The gas spreads out
  10. Spreading out
  11. All back to the left?
  12. What made it spread?

Discussion 0 comments

Log in to join the discussion.

× Enlarged view