00001 #pragma ident "$Id: CiraExponentialDrag.cpp 2457 2010-08-18 14:20:12Z coandrei $"
00002
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00069
00070
00071
00072
00073
00074
00075 double CiraExponentialDrag::computeDensity(UTCTime utc,
00076 EarthBody& rb,
00077 Vector<double> r,
00078 Vector<double> v)
00079 {
00080
00081 Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc);
00082
00083
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;
00089
00090
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
00103 int n = CIRA_SIZE;
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
00121 this->brack = bracket;
00122 double rho = rho_0[bracket] * std::exp((h0[bracket] - height)/H[bracket]);
00123
00124 return rho;
00125
00126 }
00127
00128 }
00129
00130