00001 #pragma ident "$Id: ForceModelList.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "ForceModelList.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037 ForceModelList::ForceModelList()
00038 {
00039
00040
00041 setFMT.clear();
00042 clear();
00043 }
00044
00045
00046 Vector<double> ForceModelList::getDerivatives(UTCTime utc, EarthBody& bref, Spacecraft& sc)
00047 {
00048 const int np = setFMT.size();
00049
00050 a.resize(3,0.0);
00051 da_dr.resize(3,3,0.0);
00052 da_dv.resize(3,3,0.0);
00053 da_dp.resize(3,np,0.0);
00054
00055 da_dcd.resize(3,1,0.0);
00056 da_dcr.resize(3,1,0.0);
00057
00058 for(std::list<ForceModel*>::iterator it = forceList.begin();
00059 it != forceList.end();
00060 ++it)
00061 {
00062 (*it)->doCompute(utc,bref,sc);
00063
00064 a += (*it)->getAccel();
00065 da_dr += (*it)->partialR();
00066 da_dv += (*it)->partialV();
00067
00068
00069
00070
00071 da_dcd += (*it)->partialCd();
00072 da_dcr += (*it)->partialCr();
00073
00074 }
00075
00076
00077 int i = 0;
00078
00079 for(std::set<ForceModel::ForceModelType>::iterator it = setFMT.begin();
00080 it!=setFMT.end();
00081 it++)
00082 {
00083 if((*it)==ForceModel::Cd)
00084 {
00085 da_dp(0,i) = da_dcd(0,0);
00086 da_dp(1,i) = da_dcd(1,0);
00087 da_dp(2,i) = da_dcd(2,0);
00088 }
00089 else if((*it)==ForceModel::Cr)
00090 {
00091 da_dp(0,i) = da_dcr(0,0);
00092 da_dp(1,i) = da_dcr(1,0);
00093 da_dp(2,i) = da_dcr(2,0);
00094 }
00095 else
00096 {
00097 Exception e("Error in ForceModelList::getDerivatives():Unexpect ForceModelType");
00098 GPSTK_THROW(e);
00099 }
00100
00101 i++;
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 Matrix<double> phi = sc.getTransitionMatrix();
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 Matrix<double> A = getAMatrix();
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 Matrix<double> dphi = A * phi;
00142
00143
00144 Vector<double> r = sc.R();
00145 Vector<double> v = sc.V();
00146
00147 gpstk::Vector<double> dy(42+6*np,0.0);
00148
00149 dy(0) = v(0);
00150 dy(1) = v(1);
00151 dy(2) = v(2);
00152 dy(3) = a(0);
00153 dy(4) = a(1);
00154 dy(5) = a(2);
00155
00156 for(int i=0;i<3;i++)
00157 {
00158 for(int j=0;j<3;j++)
00159 {
00160 dy(6+i*3+j) = dphi(i,j);
00161 dy(15+i*3+j) = dphi(i,j+3);
00162 dy(24+3*np+i*3+j) = dphi(i+3,j);
00163 dy(33+3*np+i*3+j) = dphi(i+3,j+3);
00164 }
00165 for(int k=0;k<np;k++)
00166 {
00167 dy(24+i*np+k) = dphi(i,i*np+k);
00168 dy(42+3*np+i*np+k) = dphi(i+3,i*np+k);
00169 }
00170 }
00171
00172 return dy;
00173
00174 }
00175
00176
00177 void ForceModelList::printForceModel(std::ostream& s)
00178 {
00179
00180 int i(1);
00181
00182 for(list<ForceModel*>::iterator it = forceList.begin();
00183 it != forceList.end();
00184 ++it)
00185 {
00186 s << setw(3) << i << " "
00187 << (*it)->forceIndex()<<" "
00188 << (*it)->modelName()<<endl;
00189
00190 i++;
00191 }
00192
00193 }
00194
00195 void ForceModelList::setForceModelType(std::set<ForceModel::ForceModelType> fmt)
00196 {
00197 setFMT.clear();
00198 for(std::set<ForceModel::ForceModelType>::iterator it = fmt.begin();
00199 it != fmt.end();
00200 ++it)
00201 {
00202 setFMT.insert(*it);
00203 }
00204
00205 }
00206
00207
00208
00209 }
00210