Demonstrate combined simulation for a sail in interplanetary orbit.

Select a guidance method and direction. Try different CAD models to see the
effects of various optical properties. A nonideal sail will have off-axis
force components and less change in the desired orbital element over time.
------------------------------------------------------------------------
See also:     FSailCombined     SailEnvironment     SailDisturbance
FOrbitSingle     SunGuidance     FlatPlate     FlatCP1Sail, QForm,
Constant, AssignFHandle, InformDlg, Plot2D, TimeLabl, Date2JD, El2RV,
SunV2, QSail, DisturbanceStruct, EnvironmentStruct, ProfileStruct,
PlotSailProfile, DisplaySailProperties
------------------------------------------------------------------------

Contents

%--------------------------------------------------------------------------
%   Copyright (c) 2006 Princeton Satellite Systems, Inc.
%   All rights reserved.
%--------------------------------------------------------------------------
%   Since version 9.
%--------------------------------------------------------------------------

% Main User Parameters

Number of days to simulate

nDays = 450;

Constants

au    = Constant('au');
muSun = Constant('mu sun');

Place sail in orbit at the Earth

el        = [au 0 0 0 0 0];
jD        = Date2JD+200;

Sail model to load

%-------------------
model = 'FlatSail.mat'; % 'FlatCP1Sail.mat'

Guidance method - see SunGuidance for options

%----------------------------------------------
method = 'inclination'; % 'off', 'sun', etc.
direction = 1;

% END Parameters

[r,v]     = El2RV( el, [], muSun );
[uSun,rS] = SunV2( jD );
w         = [0;0;0];
q         = QSail( uSun, r, v );

Initialize simulation data structure

[d,p] = InitializeSailSim( jD, 'FlatSail.mat', 'SunGuidance' );
d = InitializeSailGravity( d, 'sun', muSun );
% Overload mass to obtain desired solar force
d.g.mass.mass = 800;
% guidance parameters
d.method = method;
d.dir = direction;
d.mu = muSun;
% review simulations structure
disp(d)
-----------------------
Flat Specular Sail
Sail normal: [1 0 0]
Sail area:    50000 m2
Sail mass:      100 kg
Sail inertia (kg/m2):
   833333.33            0            0
           0    416666.67            0
           0            0    416666.67

Sail characteristic accel: 4.5267 mm/s2
Number of bodies in model: 1
Number of components in model: 1
Sail class components: 1

Sail optical properties
Component Sail:
  Specular Front:         1 Back:     1
  Diffuse Front:          0 Back:     0
  Absorptivity Front:     0 Back:     0
  Emissivity Front:    0.03 Back:  0.03
      ephemeris: 'NoEphemeris'
    environment: @SailEnvironment
    disturbance: @SailDisturbance
       attitude: []
          orbit: @FOrbitSingle
       guidance: @SunGuidance
            jD0: 2.4596e+06
         center: 1
              g: [1×1 struct]
         planet: 'sun'
       magModel: 'BDipole'
       atmModel: 'AtmDens2'
         aeroOn: 0
       albedoOn: 0
        solarOn: 1
          magOn: 0
          radOn: 0
           ggOn: 0
         method: 'inclination'
            dir: 1
             mu: 1.3271e+11

Options - set max step

tolerances should give circular orbit when sail is edge-on

odeOpts = odeset( 'MaxStep',2*86400,'abstol',1e-8,'reltol',1e-6);
tEnd    = nDays*86400;
hDlg    = InformDlg( 'Integrating...', 'SunCombinedDemo' );
[z, x]  = ode113( @FSailCombined, [0 tEnd], [r;v;q;w], odeOpts, p, d );
close(hDlg);

xPlot = x';
time  = z';
[tPlot,tLbl] = TimeLabl( time );

Extract the profiles from the orbit

[p, env, f, tq]   = FSailCombined( time, xPlot, p, d );
[qG,coneG,clockG] = SunGuidance( time, xPlot, d, env );

% Plot results.

Will see the results of the solar force on the orbit.

PlotSailProfile( p, env, [1;0;0] );

Plot2D(tPlot,QForm(p.q,f.total),tLbl,{'Fx','Fy','Fz'},'Force in Body Frame (N)')

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