Exemplo n.º 1
0
//------------------------------------------------------------------------------
bool TimeData::ValidateRefObjects(GmatBase *param)
{
    //loj: 3/23/04 removed checking for type
    bool status = false;

    if (HasObjectType(VALID_OBJECT_TYPE_LIST[SPACECRAFT]))
    {
        if (mIsInitialEpochSet)
        {
            status = true;
        }
        else
        {
            Spacecraft *sc = (Spacecraft*)FindFirstObject(VALID_OBJECT_TYPE_LIST[SPACECRAFT]);
            Real rval = sc->GetRealParameter(wxT("A1Epoch"));

            if (rval != GmatBase::REAL_PARAMETER_UNDEFINED)
            {
                mInitialEpoch = sc->GetRealParameter(wxT("A1Epoch"));
                mIsInitialEpochSet = true;
                status = true;
            }
        }
    }

    return status;
}
Exemplo n.º 2
0
      // do some test here
   void HarrisPriesterDrag::test()
   {
      cout<<"testing HarrisPriesterDrag"<<endl;
      
      IERS::loadSTKFile("InputData\\EOP-v1.1.txt");
      ReferenceFrames::setJPLEphFile("InputData\\DE405\\jplde405");

      Vector<double> r(3),v(3);
      r(0)=-4453783.586;
      r(1)=-5038203.756;
      r(2)=-426384.456;

      v(0) =  3831.888;
      v(1) = -2887.221;
      v(2) = -6.018232;
      
      EarthBody body;
      UTCTime t(53157.5);

      Spacecraft sc;
      sc.setDragArea(20.0);
      sc.setDragCoeff(2.2);
      sc.setDryMass(1000.0);

      Vector<double> rv(6,0.0);
      Vector<double> p(0,0);
      for(int i=0;i<3;i++)
      {
         rv(i) = r(i);
         rv(i+3) = v(i);
      }
      sc.initStateVector(rv);

      double den = computeDensity(t,body,r,v);
      doCompute(t,body,sc);
      
      Vector<double> accl = getAccel();
      
      double ax = accl(0);
      double ay = accl(1);
      double az = accl(2);

      int a = 0;
#pragma unused(ay,ax,az,den,a)
   }
Exemplo n.º 3
0
      /* Call the relevant methods to compute the acceleration.
      * @param t Time reference class
      * @param bRef Body reference class
      * @param sc Spacecraft parameters and state
      * @return the acceleration [m/s^s]
      */
   void MoonForce::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
   {
      /* Oliver P69 and P248
       * a = GM*( (s-r)/norm(s-r)^3 - s/norm(s)^3 )
       *
       * da/dr = -GM*( I/norm(r-s)^3 - 3(r-s)transpose(r-s)/norm(r-s)^5)
       */

      Vector<double> r_moon = ReferenceFrames::getJ2kPosition(utc.asTDB(), SolarSystem::Moon);
      
      r_moon = r_moon * 1000.0;         // from km to m

      Vector<double> d = sc.R() - r_moon;
      double dmag = norm(d);
      double dcubed = dmag * dmag *dmag;

      Vector<double> temp1 = d / dcubed;         //  detRJ/detRJ^3

      double smag = norm(r_moon);
      double scubed = smag * smag * smag;

      Vector<double> temp2 = r_moon / scubed;   //  Rj/Rj^3

      Vector<double> sum = temp1 + temp2;
      a = sum * (-mu);                          // a

      // da_dr
      da_dr.resize(3,3,0.0);
      double muod3 = mu / dcubed;
      double jk = 3.0 * muod3/dmag/dmag; 

      double xx = d(0);
      double yy = d(1);
      double zz = d(2);

      da_dr(0,0) = jk * xx * xx - muod3;
      da_dr(0,1) = jk * xx * yy;
      da_dr(0,2) = jk * xx * zz;

      da_dr(1,0) = da_dr(0,1);
      da_dr(1,1) = jk * yy * yy - muod3;
      da_dr(1,2) = jk * yy * zz;

      da_dr(2,0) = da_dr(0,2);
      da_dr(2,1) = da_dr(1,2);
      da_dr(2,2) = jk * zz * zz - muod3;

      // da_dv
      da_dv.resize(3,3,0.0);


      //da_dp
      
   }  // End of method 'MoonForce::doCompute()'
Exemplo n.º 4
0
   void SolarRadiationPressure::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
   {
      crossArea = sc.getDragArea();
      dryMass = sc.getDryMass();
      reflectCoeff = sc.getReflectCoeff();

      Vector<double> r_sun = ReferenceFrames::getJ2kPosition(utc.asTDB(),SolarSystem::Sun);
      Vector<double> r_moon = ReferenceFrames::getJ2kPosition(utc.asTDB(),SolarSystem::Moon);
      
      // from km to m
      r_sun = r_sun*1000.0;
      r_moon = r_moon*1000.0;

      // a
      a = accelSRP(sc.R(),r_sun)*getShadowFunction(sc.R(),r_sun,r_moon,SM_CONICAL);

      // da_dr   reference to Montenbruck P248
      // and it's in the same way as the gravitational attraction of the sun
      da_dr.resize(3,3,0.0);

      double au2 = ASConstant::AU * ASConstant::AU;
      double factor = -1.0*reflectCoeff * (crossArea/dryMass) * ASConstant::P_Sol*au2;

      Vector<double> d = sc.R() - r_sun;
      double dmag = norm(d);
      double dcubed = dmag * dmag *dmag;

      Vector<double> temp1 = d / dcubed;         //  detRJ/detRJ^3

      double muod3 = factor / dcubed;
      double jk = 3.0 * muod3/dmag/dmag; 

      double xx = d(0);
      double yy = d(1);
      double zz = d(2);

      da_dr(0,0) = jk * xx * xx - muod3;
      da_dr(0,1) = jk * xx * yy;
      da_dr(0,2) = jk * xx * zz;

      da_dr(1,0) = da_dr(0,1);
      da_dr(1,1) = jk * yy * yy - muod3;
      da_dr(1,2) = jk * yy * zz;

      da_dr(2,0) = da_dr(0,2);
      da_dr(2,1) = da_dr(1,2);
      da_dr(2,2) = jk * zz * zz - muod3;

      // da_dv
      da_dv.resize(3,3,0.0);

      // da_dp
      dadcr.resize(3,0.0);
      dadcr = a /reflectCoeff;

      da_dcr(0,0) = dadcr(0);
      da_dcr(1,0) = dadcr(1);
      da_dcr(2,0) = dadcr(2);

   }  // End of method 'SolarRadiationPressure::doCompute()'
Exemplo n.º 5
0
      // this is the real one
   void AtmosphericDrag::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
   {
      // To consist with STK
      double omega_e = 7.292115E-05;  // IERS 1996 conventions
      //double omega_e = rb.getSpinRate(utc);

      Vector<double> r = sc.R();   // satellite position in m
      Vector<double> v = sc.V();   // satellite velocity in m/s

      const double cd = sc.getDragCoeff();
      const double area = sc.getDragArea();
      const double mass = sc.getDryMass();

      double rmag = norm(r);
      double beta = cd * area / mass;  // [m^2/kg]

      // compute the atmospheric density
      double rho = computeDensity(utc, rb, r, v);   // [kg/m^3]

      // debuging...
      //rho  = 6.3097802844338E-12;
      
      // compute the relative velocity vector and magnitude
      Vector<double> we(3,0.0);
      we(2)= omega_e;

      Vector<double> wxr = cross(we,r);
      Vector<double> vr = v - wxr;
      double vrmag = norm(vr);
      
      // form -1/2 (Cd*A/m) rho
      double coeff = -0.5 * beta * rho;
      double coeff2 = coeff * vrmag;

      // compute the acceleration in ECI frame (km/s^2)
      a = vr * coeff2;                                  ///////// a

      // Partial reference: Montenbruck,P248

      // form partial of drag wrt v  
      // da_dv = -0.5*Cd*(A/M)*p*(vr*transpose(vr)/vr+vr1)
      Matrix<double> tr(3,1,0.0);
      tr(0,0)=vr(0);
      tr(1,0)=vr(1);
      tr(2,0)=vr(2);

      Matrix<double> vrvrt = tr*transpose(tr); 
      vrvrt = vrvrt / vrmag;
      
      double eye3[3*3] = {1,0,0,0,1,0,0,0,1};
      Matrix<double> vrm(3,3,0.0);
      vrm = eye3;

      vrm = vrm * vrmag;
      da_dv = (vrvrt + vrm) * coeff;               //////// da_dv

      // da_dr
      // da_dr = -0.5*Cd*(A/M)*vr*dp_dr-da_dv*X(w)
      da_dr.resize(3,3,0.0);

      Matrix<double> X(3,3,0.0);
      X(0,1) = -we(2);      // -wz
      X(0,2) = +we(1);      //  wy
      X(1,0) = +we(2);      // +wz
      X(1,2) = -we(0);      // -wx
      X(2,0) = -we(1);      // -wy
      X(2,1) = +we(0);      // +wx
      
      Matrix<double> part1(3,3,0.0);
      Matrix<double> part2(3,3,0.0);
      
   
      // Get the J2000 to TOD transformation
      Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc);

      // Transform r from J2000 to TOD
      Vector<double> r_tod = N * r;
      Position geoidPos(r_tod(0),r_tod(1),r_tod(3));
      
      // Satellite height
      double height = geoidPos.getAltitude()/1000.0;              //  convert to [km]
      
      const int n = CIRA_SIZE; ;

      int bracket = 0;

      if (height >= h0[n-1]) 
      {
         bracket = n - 1;
      }
      else 
      {
         for (int i = 0; i < (n-1); i++) 
         {
            if ((height >= h0[i]) && (height < h0[i+1]))
            {
               bracket = i;
            }
         }
      }  // End 'if (height >= h0[n-1]) '
      
      double Hh = H[bracket];
      double coeff4 = -1.0 / (Hh * rmag);

      Vector<double> drhodr = r*coeff4;
      
      Matrix<double> tr2(3,1,0.0);
      tr2(0,0) = drhodr(0);
      tr2(1,0) = drhodr(1);
      tr2(2,0) = drhodr(2);

      part1 = tr*transpose(tr2);      // //Matrix part1 = vr.outerProduct(drhodr);
      part1 = part1*coeff2;

      //part1 = dp_dr*a/rho;
      part2 =-da_dv*X;
      da_dr = part1-part2;

      // form partial of drag wrt cd
      double coeff3 = coeff2 / cd;
      this->dadcd = vr*coeff3;                        ////////   da_dcd

      this->da_dcd(0,0) = dadcd(0);
      this->da_dcd(1,0) = dadcd(1);
      this->da_dcd(2,0) = dadcd(2);

   }  // End of method 'AtmosphericDrag::doCompute()'
Exemplo n.º 6
0
//------------------------------------------------------------------------------
void EstimationRootFinder::BufferSatelliteStates(bool fillingBuffer)
{
   Spacecraft *fromSat = NULL, *toSat = NULL;
   FormationInterface *fromForm = NULL, *toForm = NULL;
   std::string soName;

   for (std::vector<Spacecraft *>::iterator i = satBuffer.begin();
        i != satBuffer.end(); ++i)
   {
      soName = (*i)->GetName();
      if (fillingBuffer)
      {
//         fromSat = (Spacecraft *)FindObject(soName);
         toSat = *i;
      }
      else
      {
         fromSat = *i;
//         toSat = (Spacecraft *)FindObject(soName);
      }

      #ifdef DEBUG_STOPPING_CONDITIONS
         MessageInterface::ShowMessage(
            "   Sat is %s, fill direction is %s; fromSat epoch = %.12lf   "
            "toSat epoch = %.12lf\n",
            fromSat->GetName().c_str(),
            (fillingBuffer ? "from propagator" : "from buffer"),
            fromSat->GetRealParameter("A1Epoch"),
            toSat->GetRealParameter("A1Epoch"));

         MessageInterface::ShowMessage(
            "   '%s' Satellite state:\n", fromSat->GetName().c_str());
         Real *satrv = fromSat->GetState().GetState();
         MessageInterface::ShowMessage(
            "      %.12lf  %.12lf  %.12lf\n      %.12lf  %.12lf  %.12lf\n",
            satrv[0], satrv[1], satrv[2], satrv[3], satrv[4], satrv[5]);
      #endif

      (*toSat) = (*fromSat);

      #ifdef DEBUG_STOPPING_CONDITIONS
         MessageInterface::ShowMessage(
            "After copy, From epoch %.12lf to epoch %.12lf\n",
            fromSat->GetRealParameter("A1Epoch"),
            toSat->GetRealParameter("A1Epoch"));
      #endif
   }

   for (std::vector<FormationInterface *>::iterator i = formBuffer.begin();
        i != formBuffer.end(); ++i)
   {
      soName = (*i)->GetName();
      #ifdef DEBUG_STOPPING_CONDITIONS
         MessageInterface::ShowMessage("Buffering formation %s, filling = %s\n",
            soName.c_str(), (fillingBuffer?"true":"false"));
      #endif
      if (fillingBuffer)
      {
//         fromForm = (Formation *)FindObject(soName);
         toForm = *i;
      }
      else
      {
         fromForm = *i;
//         toForm = (Formation *)FindObject(soName);
      }

      #ifdef DEBUG_STOPPING_CONDITIONS
         MessageInterface::ShowMessage(
            "   Formation is %s, fill direction is %s; fromForm epoch = %.12lf"
            "   toForm epoch = %.12lf\n",
            fromForm->GetName().c_str(),
            (fillingBuffer ? "from propagator" : "from buffer"),
            fromForm->GetRealParameter("A1Epoch"),
            toForm->GetRealParameter("A1Epoch"));
      #endif

      (*toForm) = (*fromForm);

      toForm->UpdateState();

      #ifdef DEBUG_STOPPING_CONDITIONS
         Integer count = fromForm->GetStringArrayParameter("Add").size();

         MessageInterface::ShowMessage(
            "After copy, From epoch %.12lf to epoch %.12lf\n",
            fromForm->GetRealParameter("A1Epoch"),
            toForm->GetRealParameter("A1Epoch"));

         MessageInterface::ShowMessage(
            "   %s for '%s' Formation state:\n",
            (fillingBuffer ? "Filling buffer" : "Restoring states"),
            fromForm->GetName().c_str());

         Real *satrv = fromForm->GetState().GetState();

         for (Integer i = 0; i < count; ++i)
            MessageInterface::ShowMessage(
               "      %d:  %.12lf  %.12lf  %.12lf  %.12lf  %.12lf  %.12lf\n",
               i, satrv[i*6], satrv[i*6+1], satrv[i*6+2], satrv[i*6+3],
               satrv[i*6+4], satrv[i*6+5]);
      #endif
   }

   #ifdef DEBUG_STOPPING_CONDITIONS
      for (std::vector<Spacecraft *>::iterator i = satBuffer.begin();
           i != satBuffer.end(); ++i)
         MessageInterface::ShowMessage(
            "   Epoch of '%s' is %.12lf\n", (*i)->GetName().c_str(),
            (*i)->GetRealParameter("A1Epoch"));
   #endif
}
Exemplo n.º 7
0
//------------------------------------------------------------------------------
//int RunTest(TestOutput &out)
//------------------------------------------------------------------------------
int RunTest(TestOutput &out)
{

   Real realVal;
   Real expResult;
   
   // for SolarSystem, internal CoordinateSystem
   SolarSystem *ssPtr = new SolarSystem("MySolarSystem");
   
   // set J2000Body for Earth
   CelestialBody *earthPtr = ssPtr->GetBody("Earth");
   std::string j2000BodyName = "Earth";
   CelestialBody *j2000Body = earthPtr;
   earthPtr->SetJ2000BodyName(j2000BodyName);
   earthPtr->SetJ2000Body(j2000Body);
   
   // for CoordinateSystem - EarthMJ2000Eq
   CoordinateSystem *csPtr = new CoordinateSystem("CoordinateSystem", "EarthMJ2000Eq");
   AxisSystem *mj2000EqAxis = new MJ2000EqAxes("MJ2000Eq");
   csPtr->SetRefObject(mj2000EqAxis, Gmat::AXIS_SYSTEM, mj2000EqAxis->GetName());
   csPtr->SetSolarSystem(ssPtr);
   csPtr->SetStringParameter("Origin", "Earth");
   csPtr->SetStringParameter("J2000Body", "Earth");
   csPtr->SetRefObject(earthPtr, Gmat::SPACE_POINT, "Earth");
   csPtr->Initialize();
   
   // for CoordinateSystem - EarthMJ2000Ec
   CoordinateSystem *eccsPtr = new CoordinateSystem("CoordinateSystem", "EarthMJ2000Ec");
   AxisSystem *ecAxis = new MJ2000EcAxes("MJ2000Ec");
   eccsPtr->SetRefObject(ecAxis, Gmat::AXIS_SYSTEM, ecAxis->GetName());
   eccsPtr->SetSolarSystem(ssPtr);
   eccsPtr->SetStringParameter("Origin", "Earth");
   eccsPtr->SetStringParameter("J2000Body", "Earth");
   eccsPtr->SetRefObject(earthPtr, Gmat::SPACE_POINT, "Earth");
   eccsPtr->Initialize();
   
   // set SLP file to SolarSystem
   std::string slpFileName = "C:\\projects\\gmat\\files\\planetary_ephem\\slp\\mn2000.pc";
   SlpFile *theSlpFile = new SlpFile(slpFileName);
   ssPtr->SetSource(Gmat::SLP);
   ssPtr->SetSourceFile(theSlpFile);
   
   // for Spacecraft
   Spacecraft *scPtr = new Spacecraft("MySpacecraft");
   scPtr->SetRefObject(csPtr, Gmat::COORDINATE_SYSTEM);
   
   //---------------------------------------------------------------------------
   out.Put("======================================== test BplaneParameters\n");
   //---------------------------------------------------------------------------
   
   out.Put("=================================== Test with default spacecraft orbit");
   out.Put("========== state = ", scPtr->GetCartesianState().ToString());
   
   out.Put("============================== test BdotT()");
   BdotT *btParam = new BdotT();
   btParam->SetSolarSystem(ssPtr);
   btParam->SetInternalCoordSystem(csPtr);
   btParam->SetRefObjectName(Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   btParam->SetRefObject(csPtr, Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   btParam->SetRefObjectName(Gmat::SPACECRAFT, "MySpacecraft");
   btParam->SetRefObject(scPtr, Gmat::SPACECRAFT, "MySpacecraft");
   btParam->Initialize();
   
   out.Put("num RefObjects = ", btParam->GetNumRefObjects());
   out.Put("----- test btParam->EvaluateReal()");
   out.Put("----- Should get an exception due to non-hyperbolic orbit");
   realVal = btParam->EvaluateReal();
   
   out.Put("============================== test BdotR()");
   BdotR *brParam = new BdotR();
   brParam->SetSolarSystem(ssPtr);
   brParam->SetInternalCoordSystem(csPtr);
   brParam->SetRefObjectName(Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   brParam->SetRefObject(csPtr, Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   brParam->SetRefObjectName(Gmat::SPACECRAFT, "MySpacecraft");
   brParam->SetRefObject(scPtr, Gmat::SPACECRAFT, "MySpacecraft");
   brParam->Initialize();
   
   out.Put("num RefObjects = ", brParam->GetNumRefObjects());
   out.Put("----- test brParam->EvaluateReal()");
   out.Put("----- Should get an exception due to non-hyperbolic orbit");
   realVal = brParam->EvaluateReal();
   out.Put("");

   out.Put("=================================== Test in EarthMJ2000Ec");
   
   BdotT *btecParam = new BdotT();
   btecParam->SetSolarSystem(ssPtr);
   btecParam->SetInternalCoordSystem(csPtr);
   btecParam->SetRefObjectName(Gmat::COORDINATE_SYSTEM, "EarthMJ2000Ec");
   btecParam->SetRefObject(eccsPtr, Gmat::COORDINATE_SYSTEM, "EarthMJ2000Ec");
   btecParam->SetRefObjectName(Gmat::SPACECRAFT, "MySpacecraft");
   btecParam->SetRefObject(scPtr, Gmat::SPACECRAFT, "MySpacecraft");
   
   out.Put("----- test btParam->EvaluateReal()");
   out.Put("----- Should get an exception due to non-hyperbolic orbit");
   realVal = btecParam->EvaluateReal();
   out.Put("");
   
   BdotR *brecParam = new BdotR();
   brecParam->SetSolarSystem(ssPtr);
   brecParam->SetInternalCoordSystem(csPtr);
   brecParam->SetRefObjectName(Gmat::COORDINATE_SYSTEM, "EarthMJ2000Ec");
   brecParam->SetRefObject(eccsPtr, Gmat::COORDINATE_SYSTEM, "EarthMJ2000Ec");
   brecParam->SetRefObjectName(Gmat::SPACECRAFT, "MySpacecraft");
   brecParam->SetRefObject(scPtr, Gmat::SPACECRAFT, "MySpacecraft");
   
   out.Put("----- test brParam->EvaluateReal()");
   out.Put("----- Should get an exception due to non-hyperbolic orbit");
   realVal = brecParam->EvaluateReal();
   out.Put("");
   
   /*
   ***************************************************************************
   * From Steve Hughes(2005/06/16)
   % Position and velocity in EarthMJ2000Eq
   % (Epoch does not matter so you can choose your own)
   rv = [233410.6846140172000   83651.0868276347170  -168884.42195943173]';
   vv = [-0.4038280708568842      2.0665425988121107  0.4654706868112324]';

   *%  Bplane Coordinates for EarthMJ2000Eq system*
   Sat.EarthMJ2000Eq.BdotT =   365738.686341826
   Sat.EarthMJ2000Eq.BdotR =   276107.260600374
   
   *%  Bplane Coordinates for EarthMJ2000Ec system*
   Sat.EarthMJ2000Ec.BdotT =   381942.623061352
   Sat.EarthMJ2000Ec.BdotR =   253218.95413318
   ***************************************************************************
   */
   
   // Now set spacecraft state to hyperbolic orbit
   Real state[6];
 
   state[0] =  233410.6846140172000;
   state[1] =   83651.0868276347170;
   state[2] = -168884.42195943173;
   state[3] = -0.4038280708568842;
   state[4] =  2.0665425988121107;
   state[5] =  0.4654706868112324;
   scPtr->SetState("Cartesian", state);
   Rvector6 stateVec(state);
   
   out.Put("=================================== Test with hyperbolic orbit");
   out.Put("========== state = ", scPtr->GetCartesianState().ToString());
   
   // Now test in EartMJ2000Eq
   
   out.Put("=================================== Test in EarthMJ2000Eq");
   btParam->SetRefObjectName(Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   btParam->SetRefObject(csPtr, Gmat::COORDINATE_SYSTEM, "EarthMJ2000Eq");
   
   expResult = 365738.686341826;
   out.Put("----- test btParam->EvaluateReal() Should return ", expResult);
   realVal = btParam->EvaluateReal();
   out.Validate(realVal, expResult);
   
   expResult = 276107.260600374;
   out.Put("----- test brParam->EvaluateReal() Should return ", expResult);
   realVal = brParam->EvaluateReal();
   out.Validate(realVal, expResult);
   
   // Now test in EartMJ2000Ec
   
   out.Put("=================================== Test in EarthMJ2000Ec");
      
   realVal = btecParam->EvaluateReal();
   
   out.Put("----- test btecParam->EvaluateReal() Should return ", expResult);
   expResult = 381942.623061352;
   out.Validate(realVal, expResult);
   
   expResult = 253218.95413318;
   out.Put("----- test brecParam->EvaluateReal() Should return ", expResult);
   realVal = brecParam->EvaluateReal();
   out.Validate(realVal, expResult);
   
   //---------------------------------------------
   // clean up
   //---------------------------------------------
   delete btParam;
   delete brParam;
   delete btecParam;
   delete brecParam;
   delete scPtr;
   delete ssPtr;
   delete csPtr;
   //delete theSlpFile; //problem deleting!!
}
Exemplo n.º 8
0
   // this is the real one
   void RelativityEffect::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
   {
      /* reference: Jisheng,Li P110 Bernese5 GENREL.f
         a_rl = a_rl1 + a_rl2 + a_rl3

         a_rl2 and a_rl3 are ignored for precise orbit determination
      */
      const double GM = ASConstant::GM_Earth;
      const double C = ASConstant::SPEED_OF_LIGHT;
      
      Vector<double> r = sc.R();
      Vector<double> v = sc.V();

      double beta = 1.0;
      double gama = 1.0;
      
      double c2 = C * C;
      double r2 = dot(r,r);
      double v2 = dot(v,v);

      double r_mag = norm(r);
      double r3 = r2 * r_mag;
      
      double p = GM/c2/r3;
      
      // a
      a.resize(3,0.0);
      
      double pr = 2.0 * (beta + gama) * GM / r_mag - gama * v2;
      double pv = 2.0 * (1.0 + gama) * dot(r,v);
      
      a = p * ( pr * r + pv * v );

      // da_dr
      da_dr.resize(3,3,0.0);

      double prr = -(GM/r_mag)*(GM/r_mag)*(2.0*(beta+gama)/c2);
      double pvv = (GM/r3)*(2.0*(1.0+gama)/c2);
      double par = -3.0/r2;
      double ppr = (GM/r3)*((GM/r_mag)*(2.0*(beta+gama)/c2)-gama*v2/c2);

      for(int i=0; i<3; i++)
      {
         for(int j=0; j<3; j++)
         {
            double det = (i == j) ? 1.0 : 0.0;
            
            da_dr(i,j) = prr*r(i)*r(j)
               + pvv*v(i)*v(j)
               + par*a(i)*r(j)
               + ppr*det;
         }
      }
      
      // da_dv
      da_dv.resize(3,3,0.0);
      
      double prv = -(GM/r3)*(2.0*gama/c2);
      double pvr = (GM/r3)*(2.0*(1.0+gama)/c2);
      double ppv = pvr*dot(r,v);

      for(int i=0;i<3;i++)
      {
         for(int j=0;j<3;j++)
         {
            double det = (i == j) ? 1.0 : 0.0;

            da_dr(i,j) = prv*r(i)*v(j)
               + pvr*v(i)*r(j)
               + ppv*det;
         }
      }

      // da_dp  add it later...
      //da_GM da_dbeta da_gama
      
   }  // End of method 'RelativityEffect::doCompute()'
Exemplo n.º 9
0
//------------------------------------------------------------------------------
bool BeginFiniteBurn::Initialize()
{
   bool retval = GmatCommand::Initialize();
   
   #ifdef DEBUG_BEGIN_MANEUVER
      MessageInterface::ShowMessage
         ("BeginFiniteBurn::Initialize() entered. burnName=%s\n", burnName.c_str());
   #endif
   
   GmatBase *mapObj = NULL;
   if (retval)
   {
      // Look up the maneuver object
      if ((mapObj = FindObject(burnName)) == NULL) 
         throw CommandException("Unknown finite burn \"" + burnName + "\"\n");
      if (mapObj->IsOfType("FiniteBurn") == false)
         throw CommandException(burnName + " is not a FiniteBurn\n");

      maneuver = (FiniteBurn*)mapObj;

      #ifdef DEBUG_BEGIN_MANEUVER
         MessageInterface::ShowMessage(
            "BeginFiniteBurn::Initialize() found %s with type %s\n", 
            maneuver->GetName().c_str(), maneuver->GetTypeName().c_str());
      #endif      

      // find all of the spacecraft
      StringArray::iterator scName;
      Spacecraft *sc;
      sats.clear();
      for (scName = satNames.begin(); scName != satNames.end(); ++scName)
      {
         if ((mapObj = FindObject(*scName)) == NULL) 
            throw CommandException("Unknown SpaceObject \"" + (*scName) + "\"");

         if (mapObj->IsOfType(Gmat::SPACECRAFT) == false)
            throw CommandException((*scName) + " is not a Spacecraft");
         sc = (Spacecraft*)mapObj;

         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() found %s with type %s\n", 
               scName->c_str(), sc->GetTypeName().c_str());
         #endif
         
         sats.push_back(sc);
      }
      
      // Delete old burnForce
      if (burnForce != NULL)
      {
         #ifdef DEBUG_MEMORY
         MemoryTracker::Instance()->Remove
            (burnForce, burnForce->GetName(), "BeginFiniteBurn::Initialize()",
             "deleting burn force");
         #endif
         if (transientForces != NULL)
         {
            std::vector<PhysicalModel *>::iterator transient = find(
               transientForces->begin(), transientForces->end(), burnForce);
            if (transient != transientForces->end())
            {
               #ifdef DEBUG_TRANSIENTFORCE_MANAGEMENT
                  MessageInterface::ShowMessage("Removing burn force <%p> from "
                        "the transient force list\n", burnForce);
               #endif
               transientForces->erase(transient);
            }
         }
         delete burnForce;
         burnForce = NULL;
      }
      
      // If all is okay, create the FiniteThrust object and configure it.
      std::string thrustName = burnName + "_FiniteThrust";
      burnForce = new FiniteThrust(thrustName);
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Add
         (burnForce, thrustName, "BeginFiniteBurn::Initialize()",
          "burnForce = new FiniteThrust()");
      #endif
      
      burnForce->SetRefObject(maneuver, maneuver->GetType(),
                              maneuver->GetName());

      Gmat::ObjectType type = Gmat::SPACECRAFT;
      StringArray::iterator iter;
      
      // load up the spacecraft name list
      for (iter = satNames.begin(); iter != satNames.end(); ++iter)
      {
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() setting %s on %s\n", 
               iter->c_str(), thrustName.c_str());
         #endif
         burnForce->SetRefObjectName(type, *iter);
      }
   }
   
   #ifdef DEBUG_BEGIN_MANEUVER
   MessageInterface::ShowMessage
      ("BeginFiniteBurn::Initialize() returning %d\n", isInitialized);
   #endif
   
   return isInitialized;
}