Home » Posts tagged 'Universal Kepler’s equation'

# Tag Archives: Universal Kepler’s equation

## Universal Kepler’s equation

In this example we solve the universal Kepler’s equation to determine universal anomaly after dt time with a given initial radius r0, velocity v0 and semimajor axis of a spacecraft.

```clc;
clear all;
mu       = 398600;        % Earth’s gravitational parameter [km^3/s^2]
% Initial conditions
r0       = 12000;  %[km] Initial radius
vr0      = 3;      %[km/s] Initial radial speed
dt       = 7200;   %[s] Time interval
a        = -20000; %[km] Semimajor axis
alfa = 1/a;        %[km^-1] Reciprocal of the semimajor axis;

X0 = mu^0.5*abs(alfa)*dt;  %[km^0.5]Initial estimate of X0
Xi = X0;
tol = 1E-10;              % Tolerance
while(1)
zi = alfa*Xi^2;
[ Cz,Sz] = Stumpff( zi );
fX  = r0*vr0/(mu)^0.5*Xi^2*Cz + (1 - alfa*r0)*Xi^3*Sz + r0*Xi -(mu)^0.5*dt;
fdX = r0*vr0/(mu)^0.5*Xi*(1 - alfa*Xi^2*Sz) + (1 - alfa*r0)*Xi^2*Cz + r0;
eps = fX/fdX;
Xi = Xi - eps;
if(abs(eps) < tol )
break
end
end
fprintf('Universal anomaly X = %4.3f [km^0.5] \n',Xi)

% Equations from the book
% Orbital Mechanics for Engineering Students,2nd Edition,Aerospace Engineering```
`Universal anomaly X = 173.324 [km^0.5]`

## Stumpff functions

The Stumpff functions C(z),S(z) developed by Karl Stumpff, are used for analyzing orbits using the universal variable formulation.

``` clc;
clear all;
z = -25:0.1:400;
n = size(z);
for i = 1:n(2)
if     (z(i) > 0)
S(i) = (z(i)^0.5 -sin(z(i)^0.5))/z(i)^1.5;
C(i) = (1 - cos(z(i)^0.5))/z(i);
elseif (z(i) < 0)
S(i) = (sinh((-z(i))^0.5) - (-z(i))^0.5)/((-z(i))^1.5);
C(i) = (cosh((-z(i))^0.5) - 1)/(-z(i));
else
S(i) = 1/6;
C(i) = 0.5;
end
end
% Plot
figure(1);
scatter(z(1:500),C(1:500),'.b');
hold on;grid on;
scatter(z(1:500),S(1:500),'.r');
xlabel('z');
ylabel('C(z),S(z)');
legend('C(z)','S(z)');
title('Stumpff functions C(z),S(z)');
text(10,0.4,'smallsats.org','Color',[0 0 0], 'VerticalAlignment','middle',...
'HorizontalAlignment','left','FontSize',14 );
hold off;

figure(2);
scatter(z(501:n(2)),C(501:n(2)),'.b');
hold on;grid on;
scatter(z(501:n(2)),S(501:n(2)),'.r');
xlabel('z');
ylabel('C(z),S(z)');
legend('C(z)','S(z)');
title('Stumpff functions C(z),S(z)');
text(250,0.0010,'smallsats.org','Color',[0 0 0], 'VerticalAlignment','middle',...
'HorizontalAlignment','left','FontSize',14 );
hold off;  ```

Equations from the book Orbital Mechanics for Engineering Students, Second Edition, Aerospace Engineering