From: jrfrank@ibm-pc.borg.retro.com   
      
   Hop David wrote in   
   news:41531C4A.5010801@tabletoptelephone.com:   
      
   > I'm trying to model orbits with Lunar perturbations in Microsoft Excel   
   >   
   > My first step is just trying to get an ordinary ellipse without lunar   
   > peturbations. I use   
   >   
   > a = GMe/r0^2   
   > V1 = V0 + a*t   
   > r1 = r0 + V0t + .5*a*t^2   
      
   What you've got here is (basically) a first-order Euler integrator.   
      
   > Then the next row of cells uses the last row's r1 as r0, etc.   
   >   
   > So a path over (say) a ten second time increment gives me the   
   > endpoints of a small parabola fragment. The r1 at the end of a   
   > parabola fragment is slightly larger than the r1 end of a tiny ellipse   
   > fragment.   
   >   
   > Given this error I'd expected a slowing growing spiral rather than an   
   > ellipse and this is exactly what I get.   
      
   Right. The error comes from the assumption that a is constant over the   
   entire increment t, while in reality it's constantly changing.   
      
   > There is no point in putting the moon's influence into each row of   
   > cells when my model of a simple two body is horribly inaccurate.   
   >   
   > I am hoping someone here will suggest better equations to put in the   
   > cells.   
      
   You can improve your method by computing r and v at the *midpoint* of your   
   time increment, then computing gravity at the midpoint, then using that to   
   compute r and v at the end of the increment. Like this:   
      
   a0 = G*Me/r0^2   
   v1 = v0 + a0*(0.5*t)   
   r1 = r0 + v0*(0.5*t) + 0.5*a0*(0.5*t)^2   
   a1 = G*Me/r1^2   
   v2 = v0 + a1*t   
   r2 = r0 + v1*t + 0.5*a1*t^2   
      
   Then plug r2 and v2 into the next row and repeat. This is (basically) a   
   second-order Runge-Kutta integrator. It should give you decent accuracy   
   over short time periods (say, a small number of orbits). Try experimenting   
   with the step size t; very long step sizes suffer from truncation error   
   (due to only using the first two terms of the series expansion) while very   
   short step sizes suffer from roundoff error. There's usually a sweet spot   
   in there.   
      
   If you still need more accuracy, or want to simulate longer time periods,   
   higher-order integrators are available, but they are more complex and   
   pretty clumsy to implement in a spreadsheet. This general class of problem   
   is called numerical integration of Ordinary Differential Equations (ODEs).   
   The algorithms are available in any good numerical methods textbook.   
   There's quite a lot on the web as well. Google on some of the buzzwords   
   above and many of the top results will be class handouts from university   
   lectures on the subject.   
   --   
   JRF   
      
   Reply-to address spam-proofed - to reply by E-mail,   
   check "Organization" (I am not assimilated) and   
   think one step ahead of IBM.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|