RHSCubeSatGG:

--------------------------------------------------------------------------
   Right-hand-side for a CubeSat orbit and attitude dynamical model.

   The states are: 
     [position; velocity; quaternion; angular velocity; charge]

   Includes the following disturbances:
     Aerodynamic           force   torque
     Earth radiation       force   torque
     Earth albedo          force   torque
     Solar                 force   torque
     Earth gravity         force
     Gravity gradient              torque
     Magnetic dipole               torque
     Magnetic hysteresis           torque
     Impulse                       torque
     
 
   Uses a point-mass gravity model. Computes sun location with SunV1 and
   accounts for eclipses from the Earth.

   Can output the disturbance forces and torques for post-processing.
--------------------------------------------------------------------------
   Form:
   [xDot, dist] = RHSCubeSatGG( x, t, d )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   x        (14,1)   [r;v;q;w;b]
   t         (1,1)   Time, sec
   d          (.)    Data structure including
                       .rP         (1,1)  Planet Radius (m)
                       .mass       (1,1)  Total CubeSat Mass (kg)
                       .inertia    (3,3)  Inertia tensor matrix
                       .cM         (1,1)  Center of mass (m)
                       .a          (1,n)  Area for each of n faces (m^2)
                       .n          (3,n)  Unit normal for each face
                       .r          (3,n)  Position of centroid of each
                                          face (m) 
                       .cD         (1,2*n)
                       .op         (4,2*n)
                       .th         (2,2*n)
                       .power      (.)    Power data structure
                                   .solarCellNormal (3,N) Normal vector
                                                          of each solar 
                                                          cells (1:N)
                                   .solarCellArea   (1,N) Area of each
                                                          cell (m^2)
                                   .solarCellEff    (1,N) Effeccieny of
                                                          each cell
                                   .consumption     (1,1)
                                   .batteryCapacity (1,1)
                                   .effPowerConversion (1,1)
                       .mu         (1,1)  Gravitational constant
                       .jD0        (1,1)  Initial Julian date epoch
                       .dipole     (3,1)  The nominal dipole of the
                                          CubeSat
                       .shadowFun  (:)    Shadowing function handle, i.e.
                                          @WeWishCubeSatShadowFun
                       .skewOmega  (3,3)  
                       .atm        (.)   Data structure for atmosphere
                           .aP     (1,1)
                           .f      (1,1)
                           .fHat   (1,1)
                           .fhat400(1,1)
                       .magHyst    (.)    Data structure of magnetic hysteresis
                                          properties. 
                           .compNums  (1,n)  Vector of the dampers 
                                             component numbers, where n is
                                             the number of dampers.
                           .material   (:)   String name of damper material
                           .Bs        (1,1)  Saturation flux density (T)
                           .Hc        (1,1)  Coercivity (A/m)
                           .Br        (1,1)  Remnance (T)
                           .u         (3,n)  Vectors along damper
                                             longitudinal axes
                           .vol       (1,n)  Volume of each damper (m^3)
                       .planet   (:)  String of planet name
                       .controlTorque (3,1)  The control torque vector 
                                             along the magnetic hysteresis
                                             torquerer (Nm)
                       .impulse       (.)    Data structure with excitation
                                             impulse data
                           .on        (1,1)  Trigger impulse (off=0, on=1)
                           .torque    (1,3)  Impulse torque  (Nm)
                           .time      (1,1)  Impulse start time (s)
                           .length    (1,1)  Length of impulse (s)
   bField    (3,1)    Magnetic Flux of the Earth

   distFlags (1,7)  Disturbance flags to turn on/off individually.
                       (1) Gravity Gradient          torque
                       (2) Magnetic dipole           torque
                       (3) Magnetic hystesis         torque
                       (4) Aerodynamic       force   torque
                       (5) Solar             force   torque
                       (6) Radiation         force   torque
                       (7) Albedo            force   torque

   -------
   Outputs
   -------
   x           (14+n,1)	d[r;v;q;w;b;damper]/dt
   dist        (1,1)   Disturbances
                       .tGG        (3,1) Gravity gradient torque
                       .tMag       (3,1) Magnetic torque
                       .fAero      (3,1) Aerodynamic force
                       .tAero      (3,1) Aerodynamic torque
                       .fSolar     (3,1) Solar force
                       .tSolar     (3,1) Solar torque
                       .fRad       (3,1) Radiation force
                       .tRad       (3,1) Radiation torque
                       .fAlbedo    (3,1) Albedo force
                       .tAlbedo    (3,1) Albedo torque

--------------------------------------------------------------------------

Children:

Common: Coord/QForm
Common: Coord/QIToBDot
Common: Math/Cross
Common: Math/Dot
Common: Math/Mag
CubeSat: Power/SolarCellPower
SC: Actuator/MagneticHysteresis
SC: Actuator/TorqueHysteresisDamper
SC: Attitude/GravityGradientFromR
SC: Environs/BDipole
SC: Ephem/ECIToPlanet
SC: Ephem/Eclipse
SC: Ephem/SunV1
SCPro: ProEnvirons/AtmJ70ToGround
SCPro: ProEnvirons/DistAero
SCPro: ProEnvirons/DistAlbedo
SCPro: ProEnvirons/DistRadiation
SCPro: ProEnvirons/DistSolar