00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file GravityFunctions.h 00003 * \brief Gravity force function models. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.2 $ 00006 * \date $Date: 2005/06/10 12:53:28 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /* 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 #ifndef __OSESSAME_GRAVITYFUNCTIONS_H__ 00013 #define __OSESSAME_GRAVITYFUNCTIONS_H__ 00014 #include <matrix/Matrix.h> 00015 #include <utils/Time.h> 00016 #include <orbit/OrbitState.h> 00017 #include <attitude/Attitude.h> 00018 #include <environment/Environment.h> 00019 #include <vector.h> 00020 using namespace std; 00021 using namespace O_SESSAME; 00022 00023 /*! \brief Gravity force function modeling two-body gravity. 00024 * @ingroup EnvironmentForceFunctions 00025 * 00026 * 00027 Newton formulated the simplified two-body equation, or Law of Universal Gravitation. This formulation is a simplified model because it only accounts for two bodies: the central body, and the spacecraft. In general it can be applied to any two massive bodies which have a gravitational attraction with the following assumptions: 00028 -# The bodies are spherically symmetric. 00029 -# There are no external or internal forces acting on the system other than the gravitational forces which act along the line joining the centers of the two bodies. 00030 00031 \image html images\TwoBody.jpg 00032 \image latex images\TwoBody.pdf "Two body gravity diagram" 00033 \par 00034 Newton's Law of Universal Gravitation states that the force of gravity between two bodies is proportional to the product of their masses and inversely proportional to the square of the distance between them: 00035 \f[ 00036 {\bf F}_{g} = - \frac{GMm}{r^{2}}\frac{{\bf r}}{r} 00037 \f] 00038 where \f${\bf F}_{g}\f$ is the force of gravity acting on mass \f$M\f$ and \f$m\f$, and the vector between the two masses is \f${\bf r}={\bf r}_{M}-{\bf r}_{m}\f$. The parameter \f$G\f$ is the universal contant, which is usually measured by observing the quantity \f$Gm_{\oplus}\f$, since the mass of the earth is large and more easily measured. This gravitational parameter, \f$\mu\f$ has a modern (most recent, accurate) value of \f$3.986\,004\,415\times 10^{5} \frac{km^{3}}{s^{2}}\f$. It is important to note that the vector \f${\bf r}\f$ is measured with respect to inertial axes. 00039 00040 * @param _currentTime current simulation time 00041 * @param _currentOrbitState current orbit state, including representation and reference frame 00042 * @param _currentAttitudeState current attitude state, including rotation and reference frame 00043 * @param _parameterList EnvFuncParamaterType parameter list for external variables = [\f$\mu\f$], gravitational parameter [km^3/(solar s)^2] 00044 * @return This force functions returns a 3-element vector of forces (x,y,z) due to gravity using a 00045 * two-body simplified force model. 00046 */ 00047 inline Vector GravityForceFunction(const ssfTime &_currentTime, const OrbitState &_currentOrbitState, const AttitudeState &_currentAttitudeState, const EnvFuncParamaterType &_parameterList) 00048 { 00049 static Vector Forces(3); 00050 static Vector Position(3); 00051 Position(_) = _currentOrbitState.GetState()(_(VectorIndexBase,VectorIndexBase+2)); 00052 Forces = - *(reinterpret_cast<double*>(_parameterList[0])) / pow(norm2(Position),3) * Position; 00053 return Forces; 00054 } 00055 00056 /*! \brief Gravity gradient torque function modeling two-body gravity. 00057 * @ingroup EnvironmentTorqueFunctions 00058 * 00059 The spacecraft body is subject to a non-uniform gravity field which can cause external torques about the body 00060 center. This non-uniformity is due to the inverse-square relation of the force field and the distance from the 00061 mass center, as well as a non-spherical, non-homogenous central body (such as the Earth, but especially true 00062 for asteroid or irregularly shaped central bodies). 00063 00064 The gravity gradient torque about the body principal axes is: 00065 \f[ 00066 {\bf T}_{gg} = 3\omega _c ^2 {\bf o_3} ^{\times} {\bf{I}}{\bf o_3} 00067 \f] 00068 where \f$\omega_c = 3\frac{\mu}{r^{3}}\f$ and \f$\mathbf{o_{3}}\f$ is the 00069 \f$3^{rd}\f$ column of the body-orbital rotation. 00070 00071 For enhanced accuracy, a better model would include a higher order gravity field that is dependent on the 00072 spacecraft's position and the central body's orientation. Furthermore, it is useful to analyze the spacecraft's 00073 moment of inertia matrix to evaluate its stability due to the gravity gradient disturbance torque. 00074 00075 * @param _currentTime current simulation time 00076 * @param _currentOrbitState current orbit state, including representation and reference frame 00077 * @param _currentAttitudeState current attitude state, including rotation and reference frame 00078 * @param _parameterList EnvFuncParamaterType parameter list for external variables = [\f$MOI; \mu\f$], Moments of Inertia, gravitational parameter 00079 * @return This force functions returns a 3-element vector of torques (Tx,Ty,Tz) due to gravity gradient using a 00080 * two-body simplified force model. 00081 */ 00082 inline Vector GravityGradientTorque(const ssfTime &_currentTime, const OrbitState &_currentOrbitState, const AttitudeState &_currentAttitudeState, const EnvFuncParamaterType &_parameterList) 00083 { 00084 static Matrix MOI(3,3); MOI = *(reinterpret_cast<Matrix*>(_parameterList[0])); 00085 static Vector o3(3); o3 = (_currentAttitudeState.GetRotation2Orbital(_currentOrbitState)).GetDCM()(_,3); 00086 static Vector Position(3); Position = (_currentOrbitState.GetStateRepresentation()->GetPositionVelocity())(_(1,3)); 00087 return 3 * *(reinterpret_cast<double*>(_parameterList[1]))/(pow(norm2(Position),3)) * skew(o3) * MOI * o3; 00088 } 00089 00090 #endif 00091 // Do not change the comments below - they will be added automatically by CVS 00092 /***************************************************************************** 00093 * $Log: GravityFunctions.h,v $ 00094 * Revision 1.2 2005/06/10 12:53:28 jayhawk_hokie 00095 * Changed header file format to make it easier to link to the spacecraft code by only having to specify dsacss/dep/spacecraft/src (ex. "file.h" changed to <dir/file.h> where dir is a folder in src). 00096 * 00097 * Revision 1.1.1.1 2005/04/26 17:40:56 cakinli 00098 * Adding OpenSESSAME to DSACSS distrib to capture fixed version. 00099 * 00100 * Revision 1.4 2003/10/18 21:37:28 rsharo 00101 * Removed "../utils" from all qmake project paths. Prepended "utils 00102 * /" to all #include directives for utils. Removed ".h" extensions from STL header 00103 * s and referenced STL components from "std::" namespace. Overall, changed to be 00104 * more portable. 00105 * 00106 * Revision 1.3 2003/06/12 23:06:21 nilspace 00107 * Fixed torque function. 00108 * 00109 * Revision 1.2 2003/06/12 21:26:50 nilspace 00110 * Replaced minus sign in Forces calculation. 00111 * 00112 * Revision 1.1 2003/06/12 17:58:40 nilspace 00113 * Initial Submission. 00114 * 00115 * Revision 1.6 2003/05/22 21:03:26 nilspace 00116 * Fixed to run faster with static variables. 00117 * 00118 * Revision 1.5 2003/05/20 17:47:59 nilspace 00119 * Updated comments. 00120 * 00121 * Revision 1.4 2003/05/13 18:49:41 nilspace 00122 * Fixed to get the StateObjects. 00123 * 00124 * Revision 1.3 2003/05/10 00:43:13 nilspace 00125 * Updated the includes for Orbit.h and Attitude.h 00126 * 00127 * Revision 1.2 2003/04/22 20:25:44 simpliciter 00128 * Updated LaTeX formulas for \ddot{r} and \dot{state vector} for 00129 * proper display. 00130 * 00131 * Revision 1.1 2003/04/08 22:48:29 nilspace 00132 * Initial Submission. 00133 * 00134 * 00135 ******************************************************************************/