CiraExponentialDrag.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: CiraExponentialDrag.cpp 2457 2010-08-18 14:20:12Z coandrei $"
00002 
00010 //============================================================================
00011 //
00012 //  This file is part of GPSTk, the GPS Toolkit.
00013 //
00014 //  The GPSTk is free software; you can redistribute it and/or modify
00015 //  it under the terms of the GNU Lesser General Public License as published
00016 //  by the Free Software Foundation; either version 2.1 of the License, or
00017 //  any later version.
00018 //
00019 //  The GPSTk is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU Lesser General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU Lesser General Public
00025 //  License along with GPSTk; if not, write to the Free Software Foundation,
00026 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 //
00028 //  Wei Yan - Chinese Academy of Sciences . 2009, 2010
00029 //
00030 //============================================================================
00031 
00032 
00033 #include "CiraExponentialDrag.hpp"
00034 #include "ReferenceFrames.hpp"
00035 #include "StringUtils.hpp"
00036 
00037 namespace gpstk
00038 {
00039    
00040    void CiraExponentialDrag::test()
00041    {
00042       cout<<"testing CiraExponentialDrag"<<endl;
00043 
00044    
00045       Vector<double> r(3),v(3);
00046       r(0)=-4453783.586;
00047       r(1)=-5038203.756;
00048       r(2)=-426384.456;
00049 
00050       v(0) =  3831.888;
00051       v(1) = -2887.221;
00052       v(2) = -6.018232;
00053 
00054       EarthBody body;
00055       UTCTime t;
00056       Spacecraft sc;
00057 
00058       double den = computeDensity(t,body,r,v);
00059       doCompute(t,body,sc);
00060 
00061       Vector<double> accl = getAccel();
00062 
00063       double ax = accl(0);
00064       double ay = accl(1);
00065       double az = accl(2);
00066    }
00067 
00068       /* Compute the atmospheric density using an exponential atmosphere model.
00069        * @param utc Time reference object.
00070        * @param rb  Reference body object.
00071        * @param r   ECI position vector in meters.
00072        * @param v   ECI velocity vector in m/s
00073        * @return Atmospheric density in kg/m^3.
00074        */
00075    double CiraExponentialDrag::computeDensity(UTCTime utc, 
00076                                               EarthBody& rb,
00077                                               Vector<double> r, 
00078                                               Vector<double> v)
00079    {
00080       // Get the J2000 to TOD transformation
00081       Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc);
00082 
00083       // Transform r from J2000 to TOD
00084       Vector<double> r_tod = N*r;
00085       double rmag = norm(r_tod);
00086       
00087       Position geoidPos(r_tod(0),r_tod(1),r_tod(3),Position::Cartesian);
00088       double height = geoidPos.getAltitude()/1000.0;              //  convert to [km]
00089 
00090       // check to see if too low
00091       if (height < h0[0])
00092       {
00093          string msg = "CiraExponentialDrag is valid for 50.0 km t0 1000.0 km"
00094             + string("the altitude you try is ")
00095             + StringUtils::asString(height) + " km!";
00096 
00097          Exception e(msg);
00098 
00099          GPSTK_THROW(e);
00100       }
00101 
00102       // find the right height bracket
00103       int n = CIRA_SIZE; //h0.length;
00104       int bracket = 0;
00105       if (height >= h0[n-1]) 
00106       {
00107          bracket = n - 1;
00108       }
00109       else 
00110       {
00111          for (int i = 0; i < (n-1); i++) 
00112          {
00113             if ((height >= h0[i]) && (height < h0[i+1]))
00114             {
00115                bracket = i;
00116             }
00117          }
00118       }
00119 
00120       // compute the density
00121       this->brack = bracket;
00122       double rho = rho_0[bracket] * std::exp((h0[bracket] - height)/H[bracket]);
00123 
00124       return rho;
00125 
00126    }  // End of method 'CiraExponentialDrag::computeDensity()'
00127 
00128 }  // End of namespace 'gpstk'
00129 
00130 

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