Welcome, Guest. Please Login.
Gravity Simulator
11/22/17 at 10:28:57
News: Registration for new users has been disabled to discourage spam. If you would like to join the forum please send me an email with your desired screen name to tony at gravitysimulator dot com.
Home Help Search Login


Pages: 1
Send Topic Print
What is the Time step? (Read 4689 times)
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
What is the Time step?
01/29/11 at 11:32:25
 
What exactly is the Time Step used in GS? If I have a timestep of "1" then is that recalculating what the objects are doing every 1 second of realtime?  I'm not sure that it is, since if I create Earth in the simulation I can see it slowly moving around the sun at that timestep, even though it's 1 AU from the sun.  
 
So what's the time unit being used here, exactly?  
 
And while I'm asking this, what exactly are the DoEvents and GraphicsInterval in the Preferences, and how do they relate to the timestep (I know this has been explained before, it'd be nice to have it all in one place though).
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: What is the Time step?
Reply #1 - 01/29/11 at 13:33:38
 
the timestep is the time the sim takes to calculate the new positions of the bodies . Low timestep means high accurancy .  
The reason why you see advance the planets quickly  is that there are performed thousands of timesteps each second .  
But even drawing the positions on the screen takes time , which is often not necessary . So Tony programmed the feature to draw only after a fixed number of performed timesteps on the screen . This is the Screenrefresh . Setting this value higher than 1 improves the execution speed . A typical value is 50 . It means the program only draws on the screen after having performed "50" timesteps .  
 
The do events works similar . This feature handles events such as Menu Acces . The higher the value , the higher the execution speed because no tilme is spilled to check for Menu updates for instance .
Back to top
 
 
Email View Profile   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: What is the Time step?
Reply #2 - 01/29/11 at 15:03:26
 
Yeah, but what units are the Timesteps measured in? If I have a timestep of "1" then what is that "one" of? I get that higher timesteps mean lower accuracy, but I thought that the timestep meant that the calculations were being done once every (timestep) number of simulated seconds (so a timestep of 1024 meant that the calculations were being done every 17 minutes or so of simulated time) - but evidently that isn't the case.
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: What is the Time step?
Reply #3 - 01/29/11 at 16:47:08
 
Frank gave a good explanation of the DoEvents.  If set too low, the menus and buttons will seem sluggish.  If set too high, the simulation runs very slowly.  I only lower it if I'm running a simulation with hundreds of objects.
 
The time steps is in seconds.  On the Time Step interface, it says "Time Step -- Seco..."  I didn't want to make the interface bigger simply to contain the entire word "seconds".
 
As an example, let's use linear motion.  I drive my car down the road at 10 m/s.  At a time step of 1, my distances are (please forgive my table formatting:
 
time  distance
0 0
1 10
2 20
 
At a time step of 10, my distances are
0  0
10  100
20  200
 
 
etc.
 
I see phoenixshade is replying as I type.  You'll probably get a better from him  Wink
Back to top
 
 
Email View Profile WWW   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: What is the Time step?
Reply #4 - 01/29/11 at 17:30:54
 
Yeah, I thought that was what was going on...  
 
Right now if I create Earth at 1 AU from the Sun, it seems that a timestep of 1 causes it to visibly move around the sun (it seems that timestep 1 is about 20 days, in this case with just the Earth around the sun). If I slow down the timestep to about 1/204800 (I think? The display doesn't actually show the timestep below 0.01) then that seems to correspond to a simulated second being the same as a real second (approximately).  
 
I guess if I have more objects then that equivalence won't be the same since the extra objects will slow down the processing speed?
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
phoenixshade
Uploader



Proud to be an Ape

Posts: 26
Gender: male
Re: What is the Time step?
Reply #5 - 01/29/11 at 20:55:38
 
Quote from EDG on 01/29/11 at 17:30:54:
Yeah, I thought that was what was going on...

Right now if I create Earth at 1 AU from the Sun, it seems that a timestep of 1 causes it to visibly move around the sun (it seems that timestep 1 is about 20 days, in this case with just the Earth around the sun). If I slow down the timestep to about 1/204800 (I think? The display doesn't actually show the timestep below 0.01) then that seems to correspond to a simulated second being the same as a real second (approximately).

I guess if I have more objects then that equivalence won't be the same since the extra objects will slow down the processing speed?

 
Any discussion of timestep should start with an explanation of the method Gravsim uses to calculate the positions of the objects. It uses what is known as the Euler method. Here's a non-mathematical explanation.
 
Let's start with two bodies. (We'll keep it to two dimensions here, but it works the same in three.) We know their positions and we know their velocities, so we can plot them on a graph:
 

 
 
We calculate the acceleration of gravity between the objects...
 

 
 
... then we add that accleration to the velocity, which gives us the new position of the objects:
 

 
 
The stepsize determines how much time we let pass between these calculations. So if we cut the stepsize in half, then we are only letting the objects travel half as far:
 

 
 
As before, we calculate the acceleration of gravity:
 

 
 
and add it to the original velocities to get the new velocity:
 

 
 
If we repeat the process a second time, we are now "caught up" to the first sim:
 

 
We've calculated two frames instead of one to reach the same point in time, which doubles the cost in processor time... but it also gives us a more accurate rendering of the positions of our objects.
 
 
If we continue to cut the stepsize down, we can get progressively closer to the true path these objects would follow:
 

 
 
THIS is the value that you are adjusting when you change the time step. It is given in units of seconds, which you'll see if you raise it high enough. (It will convert to days or years at high values, in which cases it shows the units.)
 
In general, you should always set this to the smallest possible number to get an acceptable simulation speed. This is why I have said in at least a couple of posts that you should always adjust the Graphics Interval (in the Preferences menu... and if you're reading this Tony, I'd love to see a dashboard element for this...) to the highest number possible that still gives you an acceptable FRAME RATE. (Don't confuse this with "time step"; I'm talking about frame rates as in film/animation here.) With small numbers of bodies you might be surprised how high this can be. In three-body simulations I usually have it up around 10000. This frees up a LOT of processor time, so you can drop the time step to very low values, which increases the accuracy of your simulations.
 
So, to sum it up with a good rule of thumb:
 
Movement too fast: DECREASE the TIME STEP.
Movement too slow: INCREASE the GRAPHICS INTERVAL.
Back to top
 
 
View Profile   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: What is the Time step?
Reply #6 - 01/29/11 at 23:24:46
 
Thanks, phoenix! Smiley
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
phoenixshade
Uploader



Proud to be an Ape

Posts: 26
Gender: male
Re: What is the Time step?
Reply #7 - 01/29/11 at 23:36:27
 
Quote from EDG on 01/29/11 at 23:24:46:
Thanks, phoenix! Smiley

 
You're very welcome. And Danger Mouse rules.
Back to top
 
 
View Profile   IP Logged
Cygnus2112
Uploader



I Love YaBB 2!

Posts: 4
Gender: male
Re: What is the Time step?
Reply #8 - 02/26/11 at 22:30:21
 
Can you also explain the Time Step Control?
Back to top
 
 
Email View Profile   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: What is the Time step?
Reply #9 - 02/28/11 at 11:01:35
 
The time step control has been explained by Tony here : ( last post )  
http://www.orbitsimulator.com/cgi-bin/yabb/YaBB.pl?num=1176774875/14#14
Back to top
 
 
Email View Profile   IP Logged
Pages: 1
Send Topic Print