Hi, i am trying to solve the following differential equations for a satellite travelling from earth to jupiter using a runge kutta algorithm.(adsbygoogle = window.adsbygoogle || []).push({});

The equations are:

dr/dt=+-(h/r)[((r/r0)-1)(1-(r/r1))]^(0.5)

and

dr/d(theta)=+-r[((r/r0)-1)(1-(r/r1))]^(0.5).

where r0 and r1 are the radii of earths and Jupiters orbits respectively.

The problem is when trying to solve with the runge kutta when the initial conditions are set (ie r = r0) the function returns 0 and hence there is nochange in further steps. The equations in polar co ords. and my RK is as follows:

double dr(double r)

{

double h,v0=38534.7, r0=0.1495*(pow(10.0,12)), r1=0.7778*(pow(10.0,12));

h=v0*r0;

return h/pow(r,2);

}

int main()

{

double t=0.0, s=10000,r1,th1,kr1,kr2,kr3,kr4; //Declaration and initiation of vars for use in 4th order runge kutta

int n=0;

while (t<=8000000)

{

t=n*s; //time

cout << t << "\t" << r0 << endl; //output data to terminal and file

outs1 << t << "\t" << r0 << endl;

//Runge Kutta Method

kr1=s*dr(r0);

kr2=s*dr(r0+kr1/2);

kr3=s*dr(r0+kr2/2);

kr4=s*dr(r0+kr3);

r1=r0+(kr1+2*kr2+2*kr3+kr4)/6.0;

r0=r1;

n++;

}

}

I am unsure if i am using the correct equations of motion to solve this, a full breakdown of the math is availible at http://www.greyfriars-catering.co.uk/math.pdf" [Broken]and any help would be greatly appreciated.

Cheers

Sol

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Satellite orbit in C++ using runge kutta

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Satellite orbit using | Date |
---|---|

Plotting Orbits on MATLAB | Aug 16, 2016 |

Verlet algorithm: Why am I getting this output? | Jan 26, 2016 |

Classical orbital elements | Sep 26, 2013 |

Need an algorithm for satellite passing through non-penumbral earth shadow | Dec 8, 2008 |

Orbit Simulator pseudocode | Jun 27, 2008 |

**Physics Forums - The Fusion of Science and Community**