Omniadisce

Computational physics 8.1: A mass on a spring

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.

11 steps · about 25 min

By the end you can

  • Write a spring's acceleration as a line of Python: a = -k / m * x
  • Step an oscillator with Euler–Cromer: v first, then x with the new v
  • Compare a simulation with the exact x = A cos(ωt), ω = √(k/m)
  • Check the energy, ½kx² + ½mv², stays the same

Who it is for: Anyone who has done units 5 and 6, and physics lessons 9.3, 9.4 and 9.6 (simple harmonic motion, the shadow of a circle, energy in an oscillation).

The steps

  1. The pull back, from physics lesson 9.3
  2. Left of the middle
  3. Euler–Cromer, as in unit 6
  4. Write the pull back
  5. Against the exact answer
  6. Simulation and exact
  7. Plain Euler again
  8. Watch plain Euler grow
  9. Energy as a check
  10. Check the energy
  11. Why test on a spring?

Discussion 0 comments

Log in to join the discussion.

× Enlarged view