# Sending an object into orbit

1. Mar 22, 2008

### vb7prog

Hi, I'm trying to build a physics simulator right now its just doing launching an object a a certain velocity and angle and see when it lands or if it escapes earths gravity. It appears like the simulator is working but then to test it I tried getting an object to orbit and it can't so it leads me to think my formulas are messed up. objects either fly away or never escape...

first im ignoring air-resistence right now, but i am taking into account the change in gravity as you get higher up:

A = 398658366000000.0;
B = 6367443;

calcGravity = A / ((B + height of object)^2)

^^ I feel good about this one, B is the radius of the earth averaged between the equator and the poles, A is the universal gravity constant times the mass of earth, with calcGravity being equal to the accleration due to gravity (9.8 m/s^2 near the surface of the earth)

height = ( upwards velocity * time in seconds) - (1/2 of calcGravity) * (time^2)

basically height = v*t - 0.5*a*(t^2)

is there something wrong with these equations or do they not apply at extreme altitudes, I'm not that great at physics so maybe im missing something, i do have a feeling that it has to do with the fact that the vertical velocity is constant and somehow needs to be curtailed at some point, but at what point or how is beyond me...

2. Mar 22, 2008

### CompuChip

You should note that the acceleration due to gravity is not constant. The formula would be
$$F_g = \frac{G M m}{r^2}$$
where G is the universal gravitational constant, M is the mass of the earth, m is the mass of the object you're launching and r is the distance from the center of the earth to the object.
For distances r which are close to the radius of the earth, this formula reduces to the familiar $F = m g$, where g \approx 9.81 takes into account the G M factor. But if the distance varies considerably, you might have to take this effect into account (and would get a differential equation for r, which you would have to solve).

Note that you have a quadratic equation for the height, which will always have two zeroes (t = 0 and some t = T). So no matter how large you make the initial velocity, the object will always come back down.

3. Mar 22, 2008

### vb7prog

this is a programming hobby of mine and the time is integrated into a loop and before i do the main calculation the new acceleration of gravity is computed

Im using the equation Fg = GM/R^2, I am adding the current height of the object to the radius in the calculations, I'm not sure where a differential equation would come in as it seems to me straight algebra, im only missing one value Fg.

as for the quadratic since the acceleration due to gravity is always getting smaller I dont see how the height will be falling. it may be true but if you saw the numbers earths gravitation is headed for zero and it looks like the object is not coming back

lim g->0 100t - 1/2gt^2

4. Mar 22, 2008

### kamerling

It appears that you are computing the solution of the differential equation:
y'' = -k/(r+y)^2 where k = G*M_1*M_2, but something like height = v*t - 0.5*a*(t^2) doesn't belong in there because it's only valid for constant acceleration.
A simple program to solve the differential equation (in 1 dimension)
y = 0 //initial height (m)
v = 5000 // initial speed (m/s)
dt = 0.01 //time step (s)
k = G * M_1 * M_2
r = 6367443 // radius of earth
t = 0
repeat:
t = t + dt
g = - k/(r+y)^2
v = v + g * dt
y = y + v * dt
until some suitable end condition

this is known as the Euler method for solving differential equation, and is simple but
rather inaccurate and it will need a very small timestep. The error is caused because of the assumption that g and v will be constant during the time interval from t to t+dt. Search around for runge-kutta method.

5. Mar 22, 2008

### Staff: Mentor

What you have written, Fg=GM/R^2 is not "straight algebra". It is not even correct. GM/R^2 has units of acceleration, not force. The gravitational force has magnitude GMm/R^2. Dividing by the mass of the object yields GM/R^2. Yes, so I'm being picky, but getting units incorrect is one of the most common mistakes students make when solving physics problems.

So why is this not straight algebra? Acceleration is the second derivative of distance, and the distance is changing with time. This seemingly simple is in fact a second order differential equation. In fact, it's worse than that. Force is a vector, not a scalar. What you have is actually a three-dimensional differential equation. You can simplify it to two (or one) dimensions only if gravity, external forces such as rocket thrust, and the initial velocity are coplanar (colinear). Since the rocket takes off from the surface of the rotating Earth, the initial velocity is not colinear with the gravitational force. In other words, the problem is two-dimensional at a minimum.

If you want something even close to realism, you should use a vector form such as

$$\mathbf a = \frac {\mathbf F_{\text{ext}}}{m} - \frac {GM_{\oplus}}{||\mathbf r||^3}\mathbf r$$

So how to integrate this? You need some model of the external force, $\mathbf F_{\text{ext}}}$ as expressed in some inertial frame. You can start with a rocket thrusting straight up, but keep in mind that real rockets don't do that. They turn as the ascend so that the thrust is horizontal by the time they reach orbital altitude.

A simple way to integrate the state (position and velocity) is via Euler's method:

\begin{aligned} \mathbf r(t+\Delta t) &= \mathbf r(t) + \Delta t \,\mathbf v (t) \\ \mathbf v(t+\Delta t) &= \mathbf v(t) + \Delta t \,\mathbf a (t) \end{aligned}

Beware, Euler integration is very inaccurate. Nonetheless, understanding how Euler integration works is an essential step to understanding more advanced methods.