MoonForce.cpp

Go to the documentation of this file.
00001 
00002 #pragma ident "$Id: MoonForce.cpp 2457 2010-08-18 14:20:12Z coandrei $"
00003 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 //
00027 //  Wei Yan - Chinese Academy of Sciences . 2009, 2010
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "MoonForce.hpp"
00033 #include "ASConstant.hpp"
00034 #include "ReferenceFrames.hpp"
00035 
00036 namespace gpstk
00037 {
00038 
00039    MoonForce::MoonForce()
00040       : mu(ASConstant::GM_Moon)
00041    {}
00042 
00043 
00044       /* Call the relevant methods to compute the acceleration.
00045       * @param t Time reference class
00046       * @param bRef Body reference class
00047       * @param sc Spacecraft parameters and state
00048       * @return the acceleration [m/s^s]
00049       */
00050    void MoonForce::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
00051    {
00052       /* Oliver P69 and P248
00053        * a = GM*( (s-r)/norm(s-r)^3 - s/norm(s)^3 )
00054        *
00055        * da/dr = -GM*( I/norm(r-s)^3 - 3(r-s)transpose(r-s)/norm(r-s)^5)
00056        */
00057 
00058       Vector<double> r_moon = ReferenceFrames::getJ2kPosition(utc.asTDB(), SolarSystem::Moon);
00059       
00060       r_moon = r_moon * 1000.0;         // from km to m
00061 
00062       Vector<double> d = sc.R() - r_moon;
00063       double dmag = norm(d);
00064       double dcubed = dmag * dmag *dmag;
00065 
00066       Vector<double> temp1 = d / dcubed;         //  detRJ/detRJ^3
00067 
00068       double smag = norm(r_moon);
00069       double scubed = smag * smag * smag;
00070 
00071       Vector<double> temp2 = r_moon / scubed;   //  Rj/Rj^3
00072 
00073       Vector<double> sum = temp1 + temp2;
00074       a = sum * (-mu);                          // a
00075 
00076       // da_dr
00077       da_dr.resize(3,3,0.0);
00078       double muod3 = mu / dcubed;
00079       double jk = 3.0 * muod3/dmag/dmag; 
00080 
00081       double xx = d(0);
00082       double yy = d(1);
00083       double zz = d(2);
00084 
00085       da_dr(0,0) = jk * xx * xx - muod3;
00086       da_dr(0,1) = jk * xx * yy;
00087       da_dr(0,2) = jk * xx * zz;
00088 
00089       da_dr(1,0) = da_dr(0,1);
00090       da_dr(1,1) = jk * yy * yy - muod3;
00091       da_dr(1,2) = jk * yy * zz;
00092 
00093       da_dr(2,0) = da_dr(0,2);
00094       da_dr(2,1) = da_dr(1,2);
00095       da_dr(2,2) = jk * zz * zz - muod3;
00096 
00097       // da_dv
00098       da_dv.resize(3,3,0.0);
00099 
00100 
00101       //da_dp
00102       
00103    }  // End of method 'MoonForce::doCompute()'
00104 
00105 
00106 }  // End of namespace 'gpstk'
00107 
00108 

Generated on Tue May 22 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1