How to Model a Basic 2-body Planetary System

Here is a tutorial explaining how to model a two dimensional  2-body planetary system in Excel. It uses the Euler method of integration. The tutorial starts with explaining the simple newtonial laws acting on the two planets. There are essentially just two forces acting on each body at any time: the inertia and the gravitational attraction. During each small time step, from the distance between bodies we can calculate the gravitational forces and from the Newton’s second law we can further calculate the acceleration. From acceleration and the initial speed (the speed at the beginning of the time step) we can calculate the speed at the end of each time step and from all the above known quantities we can find the position at the end of the time interval. This iterative process is (dynamically) repeated over and over and the solution is plotted on a 2D scatter chart. A detailed step-by-step Excel-VBA implementation is further shown.

Recommending this site to your friends would be highly appreciated. Thanks for your support!

[sociallocker][/sociallocker]

This article has 3 Comments

  1. Evgeny, Thanks for reporting. You were right, in 2007 the chart was not updating. I fixed it by adding “DoEvents” statement in 2 more places. The uploaded file is usable now in 2007. In 2007 it’s going to be roughly 10 times slower that in 2003 though (welcome to MS innovation).

    Also if someone doesn’t know how to turn the Macros on here it is: 1) Left click the round “Office Button”, 2) Left click “Options” (bottom right), 3) Left click “Trust center” on the left side of the pop up, 4) Left Click “Trust Center Settings”, 5) Left click “Macro setings” 6) Click “Enable all macros….” 7) Exit all menus by clicking OK, OK.

  2. There is some troubles under 2007 excel. When i click once on start-pause button – there is no moving on chart. It have to be added (Application.ScreenUpdating = True) before the first (loop) in VBA code. In that way it looks fine.
    Thanks a lot, very interesting website. I just was amazed with roller-coaster))

Leave a Reply

Your email address will not be published. Required fields are marked *