ddho.ode 644 B

123456789101112131415161718192021222324252627282930313233
  1. # You may run this example by doing:
  2. #
  3. # ode < ddho.ode | graph -T X -C
  4. #
  5. # or alternatively, to get a real-time plot,
  6. #
  7. # ode < ddho.ode | graph -T X -C -x 0 25 -y -0.5 1 0.5
  8. #
  9. # This example simulates a dam-driven harmonic oscillator (DDHO) with
  10. # damping, the equation for which is
  11. #
  12. # y'' = -k/m * y - R/m * y' + cos(w*t)
  13. #
  14. # If R^2 > 4km, motion is overdamped
  15. # If R^2 = 4km, motion is critically damped
  16. # If R^2 < 4km, motion is damped
  17. #
  18. # With the choice of parameters below, motion is damped but not
  19. # overdamped.
  20. y' = vy
  21. vy' = -k/m * y - R/m * vy + cos(w*t)
  22. y = 1
  23. vy = 0
  24. k = 1
  25. m = 1
  26. R = 0.5
  27. w = 2*PI
  28. print t, y
  29. step 0,25