A reentry simulation. Uses RHSReentry.m.

------------------------------------------------------------------------
See also ReentryPlot, RHSReentry, Plot2D, Figui
------------------------------------------------------------------------

Contents

%--------------------------------------------------------------------------
%    Copyright (c) 2007 Princeton Satellite Systems, Inc.
%    All Rights Reserved.
%--------------------------------------------------------------------------

Simulation parameters

nSim  = 50000;
dT    = 0.0001;
h     = 80000;

% Constants
mu  = Constant('mu earth')*1e9; % Convert to m

% Use the default data in the right-hand-side function
d  = RHSReentry;

Initial states

vC  = sqrt(d.rPlanet*d.g);

if( h > 80000 )
  error('The altitude is too high for StdAtm.');
end

r = d.rPlanet + h; % Add 70 km
v = sqrt(mu/r)/vC; % Circular orbit
r = r/d.rPlanet;
x = [r;0;0;v;0;0;0];

% Plotting arrays
x = [x  zeros(7,nSim)];
u = zeros(2,nSim+1);
t = linspace(1,nSim+1,nSim+1)*dT;

% This displays a GUI to show you how much time is left in the sim
TimeDisplay( 'initialize', 'Reentry Simulation', nSim )

Simulation

for k = 1:nSim

  % Update the display
  TimeDisplay( 'update' )

  % Propagate one step
  x(:,k+1) = RK4( 'RHSReentry', x(:,k), dT, 0, d );

  % Save the control for plotting
  u(:,k+1) = [d.sigma;d.alpha];

  % Compute the altitude to prevent going through the surface
  h = x(1,k+1)*d.rPlanet - d.rPlanet;

  if( h < 1 )
    break;
  end

end

% Close the display
TimeDisplay( 'close' )

Plotting

% Shrink the arrays to the length of the simulation
x    = x(:,1:(k+1));
u    = u(:,1:(k+1));

% Dimensionalize the time
t    = t(1:(k+1))*sqrt(d.rPlanet/d.g);

% Convert the sim variables to dimensional variables and plot
ReentryPlot( x, t, d, u );

% Create the time array and label
[t, tL] = TimeLabl(t);
yL = {'H (m)' '\theta (rad)' '\phi (rad)' 'v (m/s)' '\gamma (rad)' '\psi (rad)'};

% Restore the dimensions and plot
x(1,:) = x(1,:)*d.rPlanet - d.rPlanet;
x(4,:) = x(4,:)*vC;
Plot2D( t, x(1:6,:), tL, yL, 'Reentry States');

Figui


%--------------------------------------