ForceModel.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ForceModel.hpp 2535 2011-03-25 15:58:06Z ccutlip $"
00002 
00009 #ifndef GPSTK_FORCE_MODEL_HPP
00010 #define GPSTK_FORCE_MODEL_HPP
00011 
00012 //============================================================================
00013 //
00014 //  This file is part of GPSTk, the GPS Toolkit.
00015 //
00016 //  The GPSTk is free software; you can redistribute it and/or modify
00017 //  it under the terms of the GNU Lesser General Public License as published
00018 //  by the Free Software Foundation; either version 2.1 of the License, or
00019 //  any later version.
00020 //
00021 //  The GPSTk is distributed in the hope that it will be useful,
00022 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 //  GNU Lesser General Public License for more details.
00025 //
00026 //  You should have received a copy of the GNU Lesser General Public
00027 //  License along with GPSTk; if not, write to the Free Software Foundation,
00028 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029 //
00030 //  Wei Yan - Chinese Academy of Sciences . 2009, 2010
00031 //
00032 //============================================================================
00033 
00034 
00035 #include "Vector.hpp"
00036 #include "Matrix.hpp"
00037 #include "Spacecraft.hpp"
00038 #include "EarthBody.hpp"
00039 
00040 namespace gpstk
00041 {
00044 
00049    class ForceModel
00050    {
00051    public:
00052 
00057       enum ForceModelIndex
00058       {
00059          FMI_BASE       = 1000,  
00060 
00061          FMI_GEOEARTH,           
00062          FMI_GEOSUN,             
00063          FMI_GEOMOON,            
00064          FMI_DRAG,               
00065          FMI_SRP,                
00066          FMI_RELATIVE,           
00067          FMT_EMPIRICAL,          
00068          
00069          //... add more here
00070 
00071          FMI_LIST   = 2000      
00072       };
00073 
00074       enum ForceModelType
00075       {
00076          Cd,               // Coefficient of drag
00077          Cr               // Coefficient of Reflectivity
00078       };
00079 
00081       ForceModel()
00082       {         
00083          a.resize(3,0.0);
00084          da_dr.resize(3,3,0.0);
00085          da_dv.resize(3,3,0.0);
00086          da_dp.resize(3,0,0.0);      // default np = 0;
00087 
00088          da_dcd.resize(3,1,0.0);
00089          da_dcr.resize(3,1,0.0);
00090       }
00091 
00093       virtual ~ForceModel(){}
00094 
00095 
00097       virtual void doCompute(UTCTime t, EarthBody& bRef, Spacecraft& sc)
00098       {
00099          a.resize(3,0.0);
00100          da_dr.resize(3,3,0.0);
00101          da_dv.resize(3,3,0.0);
00102          da_dp.resize(3,0,0.0);      // default np = 0;
00103 
00104          da_dcd.resize(3,1,0.0);
00105          da_dcr.resize(3,1,0.0);
00106 
00107       }
00108          
00110       virtual std::string modelName() const
00111       { return "ForceModel"; }
00112 
00113 
00115       virtual int forceIndex() const
00116       { return FMI_BASE; }
00117 
00118 
00123       virtual Vector<double> getAccel() const
00124       { return a; }
00125 
00130       virtual Matrix<double> partialR() const
00131       { return da_dr; }
00132 
00137       virtual Matrix<double> partialV() const
00138       { return da_dv; }
00139 
00144       virtual Matrix<double> partialP() const
00145       { return da_dp; }
00146 
00151       virtual Matrix<double> partialCd() const
00152       { return da_dcd; } 
00153 
00158       virtual Matrix<double> partialCr() const
00159       { return da_dcr; }
00160 
00163       int getNP() const
00164       { return da_dp.cols(); }
00165 
00167       Matrix<double> getAMatrix() const
00168       {
00169             /* A Matrix
00170             |                        |
00171             | 0         I      0      |
00172             |                        |
00173          A =| da_dr      da_dv   da_dp  |
00174             |                        |
00175             | 0         0      0      |
00176             |                        |
00177             */
00178 
00179          const int np = da_dp.cols();
00180 
00181          gpstk::Matrix<double> A(6+np,6+np,0.0);
00182 
00183          A(0,3) = 1.0;
00184          A(1,4) = 1.0;
00185          A(2,5) = 1.0;
00186 
00187          // da_dr
00188          A(3,0) = da_dr(0,0);
00189          A(3,1) = da_dr(0,1);
00190          A(3,2) = da_dr(0,2);
00191          A(4,0) = da_dr(1,0);
00192          A(4,1) = da_dr(1,1);
00193          A(4,2) = da_dr(1,2);
00194          A(5,0) = da_dr(2,0);
00195          A(5,1) = da_dr(2,1);
00196          A(5,2) = da_dr(2,2);
00197 
00198          // da_dv
00199          A(3,3) = da_dv(0,0);
00200          A(3,4) = da_dv(0,1);
00201          A(3,5) = da_dv(0,2);
00202          A(4,3) = da_dv(1,0);
00203          A(4,4) = da_dv(1,1);
00204          A(4,5) = da_dv(1,2);
00205          A(5,3) = da_dv(2,0);
00206          A(5,4) = da_dv(2,1);
00207          A(5,5) = da_dv(2,2);
00208 
00209          // da_dp
00210          for(int i=0;i<np;i++)
00211          {
00212             A(3,6+i) = da_dp(0,i);
00213             A(4,6+i) = da_dp(1,i);
00214             A(5,6+i) = da_dp(2,i);
00215          }
00216 
00217          return A;
00218 
00219       }  // End of method 'getAMatrix()'
00220 
00221       void test()
00222       {
00223          /*
00224          cout<<"test Force Model"<<endl;
00225 
00226          a.resize(3,2.0);
00227          da_dr.resize(3,3,3.0);
00228          da_dv.resize(3,3,4.0);
00229          da_dp.resize(3,2,5.0);
00230          writeToFile("default.fm");
00231 
00232          // it work well
00233          */
00234       }
00235 
00236    protected:
00237 
00239       Vector<double> a;         // 3
00240       
00242       Matrix<double> da_dr;      // 3*3
00243       
00245       Matrix<double> da_dv;      // 3*3
00246       
00248       Matrix<double> da_dp;      // 3*np
00249          
00251       Matrix<double> da_dcd;      // 3*1
00252          
00254       Matrix<double> da_dcr;      // 3*1
00255 
00256       
00257 
00258    }; // End of 'class ForceModel'
00259 
00266    inline std::ostream& operator<<( std::ostream& s,
00267                                     const gpstk::ForceModel& fm )
00268    {
00269       Vector<double> a = fm.getAccel();
00270       Matrix<double> da_dr = fm.partialR();
00271       Matrix<double> da_dv = fm.partialV();
00272       Matrix<double> da_dp = fm.partialP();
00273 
00274       s<<"a ["<<a.size()<<"]\n{\n"
00275          <<a<<endl<<"}\n\n";
00276 
00277       s<<"da/dr ["<<da_dr.rows()<<","<<da_dr.cols()<<"]\n{\n"
00278          <<da_dr<<endl<<"}\n\n";
00279 
00280       s<<"da/dv ["<<da_dv.rows()<<","<<da_dv.cols()<<"]\n{\n"
00281          <<da_dv<<endl<<"}\n\n";
00282 
00283       s<<"da/dp ["<<da_dp.rows()<<","<<da_dp.cols()<<"]\n{\n"
00284          <<da_dp<<endl<<"}\n\n";
00285 
00286       Matrix<double> A = fm.getAMatrix();
00287 
00288       s<<"A = ["<<A.rows()<<","<<A.cols()<<"]\n{\n"
00289          <<A<<endl<<"}\n\n";
00290 
00291       return s;
00292 
00293    }
00294 
00295       // @}
00296 
00297 }  // End of namespace 'gpstk'
00298 
00299 
00300 #endif  // GPSTK_FORCE_MODEL_HPP
00301 
00302 

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