SunForce.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SunForce.cpp 2457 2010-08-18 14:20:12Z coandrei $"
00002 
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 "SunForce.hpp"
00033 #include "ASConstant.hpp"
00034 #include "DayTime.hpp"
00035 #include "IERS.hpp"
00036 #include "ReferenceFrames.hpp"
00037 
00038 namespace gpstk
00039 {
00040       // Default constructor
00041    SunForce::SunForce()
00042       : mu(ASConstant::GM_Sun)
00043    { }
00044    
00045    
00046       /* Call the relevant methods to compute the acceleration.
00047        * @param t Time reference class
00048        * @param bRef Body reference class
00049        * @param sc Spacecraft parameters and state
00050        * @return the acceleration [m/s^s]
00051        */
00052    void SunForce::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
00053    {
00054       /* Oliver P69 and P248
00055        * a = GM*( (s-r)/norm(s-r)^3 - s/norm(s)^3 )
00056        *
00057        * da/dr = -GM*( I/norm(r-s)^3 - 3(r-s)transpose(r-s)/norm(r-s)^5)
00058        */
00059 
00060       Vector<double> r_sun = ReferenceFrames::getJ2kPosition(utc.asTDB(), SolarSystem::Sun);
00061 
00062       r_sun = r_sun * 1000.0;                          // from km to m
00063 
00064       Vector<double> d = sc.R() - r_sun;
00065       double dmag = norm(d);
00066       double dcubed = dmag * dmag *dmag;
00067 
00068       Vector<double> temp1 = d / dcubed;              //  detRJ/detRJ^3
00069 
00070       double smag = norm(r_sun);
00071       double scubed = smag * smag * smag;
00072 
00073       Vector<double> temp2 = r_sun / scubed;            //  Rj/Rj^3
00074 
00075       Vector<double> sum = temp1 + temp2;
00076       a = sum * (-mu);
00077 
00078       // da_dr
00079       da_dr.resize(3,3,0.0);
00080       double muod3 = mu / dcubed;
00081       double jk = 3.0 * muod3/dmag/dmag; 
00082 
00083       double xx = d(0);
00084       double yy = d(1);
00085       double zz = d(2);
00086 
00087       da_dr(0,0) = jk * xx * xx - muod3;
00088       da_dr(0,1) = jk * xx * yy;
00089       da_dr(0,2) = jk * xx * zz;
00090 
00091       da_dr(1,0) = da_dr(0,1);
00092       da_dr(1,1) = jk * yy * yy - muod3;
00093       da_dr(1,2) = jk * yy * zz;
00094 
00095       da_dr(2,0) = da_dr(0,2);
00096       da_dr(2,1) = da_dr(1,2);
00097       da_dr(2,2) = jk * zz * zz - muod3;
00098 
00099       // da_dv
00100       da_dv.resize(3,3,0.0);
00101 
00102       //da_dp
00103       
00104    }  // End of method 'SunForce::doCompute()'
00105 
00106 
00107    void SunForce::test()
00108    {
00109       //IERS::loadSTKFile("InputData\\EOP-v1.1.txt");
00110       ReferenceFrames::setJPLEphFile("InputData\\DE405\\jplde405");
00111 
00112       DayTime time(2000,1,1,0,0,0.0);
00113       double mjd = time.MJD();
00114 
00115       Vector<double> posSun =  ReferenceFrames::getJ2kPosition(time,SolarSystem::Sun);
00116 
00117       cout << posSun << endl;
00118 
00119       int a =0;
00120    }
00121 
00122 }  // End of namespace 'gpstk'
00123 

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