What is the best way to simulate an object in orbit?

  • Thread starter Thread starter vb7prog
  • Start date Start date
  • Tags Tags
    Orbit
AI Thread Summary
The physics simulator is currently unable to achieve orbital motion, indicating potential errors in the equations used for calculating gravitational forces and object trajectories. The user is correctly accounting for the change in gravity with altitude, but the equations employed for height and velocity assume constant acceleration, which is not valid at varying distances from Earth. The discussion highlights the need for a differential equation approach to accurately model the gravitational force, which varies with distance and should be integrated over time. Additionally, the importance of using vector forms for forces and considering external forces, like rocket thrust, is emphasized for realistic simulations. Proper understanding and implementation of these concepts are crucial for achieving accurate results in the simulator.
vb7prog
Messages
2
Reaction score
0
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 Earth's 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 I am 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 I am 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...
 
Physics news on Phys.org
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.
 
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, I am only missing one value Fg.

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

lim g->0 100t - 1/2gt^2
 
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.
 
vb7prog said:
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, I am only missing one value Fg.
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:

<br /> \begin{aligned}<br /> \mathbf r(t+\Delta t) &amp;= \mathbf r(t) + \Delta t \,\mathbf v (t) \\<br /> \mathbf v(t+\Delta t) &amp;= \mathbf v(t) + \Delta t \,\mathbf a (t)<br /> \end{aligned}<br />

Beware, Euler integration is very inaccurate. Nonetheless, understanding how Euler integration works is an essential step to understanding more advanced methods.
 
Thread 'Gauss' law seems to imply instantaneous electric field propagation'
Imagine a charged sphere at the origin connected through an open switch to a vertical grounded wire. We wish to find an expression for the horizontal component of the electric field at a distance ##\mathbf{r}## from the sphere as it discharges. By using the Lorenz gauge condition: $$\nabla \cdot \mathbf{A} + \frac{1}{c^2}\frac{\partial \phi}{\partial t}=0\tag{1}$$ we find the following retarded solutions to the Maxwell equations If we assume that...
Maxwell’s equations imply the following wave equation for the electric field $$\nabla^2\mathbf{E}-\frac{1}{c^2}\frac{\partial^2\mathbf{E}}{\partial t^2} = \frac{1}{\varepsilon_0}\nabla\rho+\mu_0\frac{\partial\mathbf J}{\partial t}.\tag{1}$$ I wonder if eqn.##(1)## can be split into the following transverse part $$\nabla^2\mathbf{E}_T-\frac{1}{c^2}\frac{\partial^2\mathbf{E}_T}{\partial t^2} = \mu_0\frac{\partial\mathbf{J}_T}{\partial t}\tag{2}$$ and longitudinal part...
Thread 'Recovering Hamilton's Equations from Poisson brackets'
The issue : Let me start by copying and pasting the relevant passage from the text, thanks to modern day methods of computing. The trouble is, in equation (4.79), it completely ignores the partial derivative of ##q_i## with respect to time, i.e. it puts ##\partial q_i/\partial t=0##. But ##q_i## is a dynamical variable of ##t##, or ##q_i(t)##. In the derivation of Hamilton's equations from the Hamiltonian, viz. ##H = p_i \dot q_i-L##, nowhere did we assume that ##\partial q_i/\partial...
Back
Top