home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / demo / ode.zoo / binary.ode < prev    next >
Text File  |  1990-01-03  |  534b  |  28 lines

  1. # BINARY.ODE
  2. # Planetary orbit in binary star system
  3. # Plot x against y
  4.  
  5. # Use 5th order Runge-Kutta, auto step-size, 500  steps
  6. $m 6
  7. $n 500
  8.  
  9. #Solve to 20
  10. $t 20
  11.  
  12. # (x,y) is position of the planet; (vx,vy) its velocity.
  13. x   = 1
  14. y   = 0
  15. vx  = 0
  16. vy  = 1.155, 1.160, 1.165    # notice sensitivity to initial values!
  17.  
  18. # Binary star centres are at (0,0) and (-5,0)
  19. r13 = cub(sqrt(sqr(x)+  sqr(y)))
  20. r23 = cub(sqrt(sqr(x+5)+sqr(y)))
  21.  
  22. x'  = vx
  23. y'  = vy
  24.  
  25. # Newton's Law
  26. vx' = -x/r13 - (x+5)/r23
  27. vy' = -y/r13 - y/r23
  28.