orbit.ode 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # This example does a planetary orbit simulation, with two suns situated at
  2. # (0,0) and (-5,0) and one planet starting out at (1,0). You may run it by
  3. # typing
  4. # ode -f orbit.ode | graph -T X -C -y -1 3 -x -6 2
  5. # step 0,10
  6. # step 10,20
  7. # step 20,30
  8. # step 30,40
  9. # step 40,50
  10. # step 50,60
  11. # .
  12. # The planet's orbit will be traced out incrementally. If you are using a
  13. # color X Window System display, each segment of the orbit will be a
  14. # different color. This is a feature provided by `graph', which normally
  15. # changes the linemode after each dataset it reads. If you do not like this
  16. # feature, you may turn it off by using `graph -B' instead of `graph'.
  17. # x and y are positions
  18. # vx and vy are velocities
  19. vx' = -x/((x^2+y^2)^(3/2)) -(x+5)/(((x+5)^2+y^2)^(3/2))
  20. vy' = -y/((x^2+y^2)^(3/2)) -y/(((x+5)^2+y^2)^(3/2))
  21. y' = vy
  22. x' = vx
  23. x = 1
  24. y = 0
  25. print x,y every 5
  26. # these values seem to give a nice orbit:
  27. # vx = 0
  28. # vy = 1.142
  29. # a more exciting result can be obtained from:
  30. vx = 0
  31. vy = 1.165
  32. #step 0,20