viscous.ode 689 B

123456789101112131415161718192021222324252627
  1. # This example simulates a bead sliding on a smooth circular wire. The
  2. # output displays the height of the bead as a function of time. There is
  3. # viscous damping, so the bead should settle toward the equilibrium point
  4. # (i.e. ordinate = 0).
  5. # You may run this example by doing:
  6. #
  7. # ode < viscous.ode | graph -T X -C
  8. #
  9. # or alternatively, to get a real-time plot,
  10. #
  11. # ode < viscous.ode | graph -T X -C -x 0 20 -y 0 2.5
  12. a = 1 # radius of circular wire
  13. g = 10 # acceleration due to gravity
  14. w = 10 # angular velocity of circular wire
  15. b = 1 # damping coefficient
  16. the' = vthe
  17. vthe' = (w^2)*sin(the)*cos(the) - (g/a)*sin(the) - b * vthe
  18. the = 0.1
  19. vthe = 0
  20. print t, the
  21. step 0, 20