![]() |
JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++
|
00001 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00002 00003 Header: FGMassBalance.h 00004 Author: Jon S. Berndt 00005 Date started: 09/12/2000 00006 00007 ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) -------------- 00008 00009 This program is free software; you can redistribute it and/or modify it under 00010 the terms of the GNU Lesser General Public License as published by the Free Software 00011 Foundation; either version 2 of the License, or (at your option) any later 00012 version. 00013 00014 This program is distributed in the hope that it will be useful, but WITHOUT 00015 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00016 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00017 details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00023 Further information about the GNU Lesser General Public License can also be found on 00024 the world wide web at http://www.gnu.org. 00025 00026 HISTORY 00027 -------------------------------------------------------------------------------- 00028 09/12/2000 JSB Created 00029 00030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00031 SENTRY 00032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00033 00034 #ifndef FGMASSBALANCE_H 00035 #define FGMASSBALANCE_H 00036 00037 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00038 INCLUDES 00039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00040 00041 #include <vector> 00042 #include <string> 00043 #include "FGModel.h" 00044 #include "math/FGColumnVector3.h" 00045 #include "math/FGMatrix33.h" 00046 #include "input_output/FGXMLElement.h" 00047 #include "input_output/FGXMLFileRead.h" 00048 00049 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00050 DEFINITIONS 00051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00052 00053 #define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.28 2012/12/12 06:19:57 jberndt Exp $" 00054 00055 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00056 FORWARD DECLARATIONSS 00057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00058 00059 using std::string; 00060 00061 namespace JSBSim { 00062 00063 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00064 CLASS DOCUMENTATION 00065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00066 00107 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00108 CLASS DECLARATION 00109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 00110 00111 class FGMassBalance : public FGModel, public FGXMLFileRead 00112 { 00113 00114 public: 00115 FGMassBalance(FGFDMExec*); 00116 ~FGMassBalance(); 00117 00118 bool Load(Element* el); 00119 bool InitModel(void); 00127 bool Run(bool Holding); 00128 00129 double GetMass(void) const {return Mass;} 00130 double GetWeight(void) const {return Weight;} 00131 double GetEmptyWeight(void) const {return EmptyWeight;} 00132 const FGColumnVector3& GetXYZcg(void) const {return vXYZcg;} 00133 double GetXYZcg(int axis) const {return vXYZcg(axis);} 00134 const FGColumnVector3& GetDeltaXYZcg(void) const {return vDeltaXYZcg;} 00135 double GetDeltaXYZcg(int axis) const {return vDeltaXYZcg(axis);} 00136 00145 FGMatrix33 GetPointmassInertia(double mass_sl, const FGColumnVector3& r) const 00146 { 00147 FGColumnVector3 v = StructuralToBody( r ); 00148 FGColumnVector3 sv = mass_sl*v; 00149 double xx = sv(1)*v(1); 00150 double yy = sv(2)*v(2); 00151 double zz = sv(3)*v(3); 00152 double xy = -sv(1)*v(2); 00153 double xz = -sv(1)*v(3); 00154 double yz = -sv(2)*v(3); 00155 return FGMatrix33( yy+zz, xy, xz, 00156 xy, xx+zz, yz, 00157 xz, yz, xx+yy ); 00158 } 00159 00169 FGColumnVector3 StructuralToBody(const FGColumnVector3& r) const; 00170 00171 void SetEmptyWeight(double EW) { EmptyWeight = EW;} 00172 void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;} 00173 00174 void AddPointMass(Element* el); 00175 double GetTotalPointMassWeight(void) const; 00176 00177 const FGColumnVector3& GetPointMassMoment(void); 00178 const FGMatrix33& GetJ(void) const {return mJ;} 00179 const FGMatrix33& GetJinv(void) const {return mJinv;} 00180 void SetAircraftBaseInertias(const FGMatrix33& BaseJ) {baseJ = BaseJ;} 00181 void GetMassPropertiesReport(void) const; 00182 00183 struct Inputs { 00184 double GasMass; 00185 double TanksWeight; 00186 FGColumnVector3 GasMoment; 00187 FGMatrix33 GasInertia; 00188 FGColumnVector3 TanksMoment; 00189 FGMatrix33 TankInertia; 00190 } in; 00191 00192 private: 00193 double Weight; 00194 double EmptyWeight; 00195 double Mass; 00196 FGMatrix33 mJ; 00197 FGMatrix33 mJinv; 00198 FGMatrix33 pmJ; 00199 FGMatrix33 baseJ; 00200 FGColumnVector3 vXYZcg; 00201 FGColumnVector3 vLastXYZcg; 00202 FGColumnVector3 vDeltaXYZcg; 00203 FGColumnVector3 vDeltaXYZcgBody; 00204 FGColumnVector3 vXYZtank; 00205 FGColumnVector3 vbaseXYZcg; 00206 FGColumnVector3 vPMxyz; 00207 FGColumnVector3 PointMassCG; 00208 const FGMatrix33& CalculatePMInertias(void); 00209 00210 00213 struct PointMass { 00214 PointMass(double w, FGColumnVector3& vXYZ) { 00215 Weight = w; 00216 Location = vXYZ; 00217 mPMInertia.InitMatrix(); 00218 Radius = 0.0; 00219 Length = 0.0; 00220 } 00221 00222 void CalculateShapeInertia(void) { 00223 switch(eShapeType) { 00224 case esTube: 00225 mPMInertia(1,1) = (Weight/(slugtolb))*Radius*Radius; // mr^2 00226 mPMInertia(2,2) = (Weight/(slugtolb*12))*(6*Radius*Radius + Length*Length); 00227 mPMInertia(3,3) = mPMInertia(2,2); 00228 break; 00229 case esCylinder: 00230 mPMInertia(1,1) = (Weight/(slugtolb*2))*Radius*Radius; // 0.5*mr^2 00231 mPMInertia(2,2) = (Weight/(slugtolb*12))*(3*Radius*Radius + Length*Length); 00232 mPMInertia(3,3) = mPMInertia(2,2); 00233 break; 00234 case esSphere: 00235 mPMInertia(1,1) = (Weight/(slugtolb*3))*Radius*Radius*2; // (2mr^2)/3 00236 mPMInertia(2,2) = mPMInertia(1,1); 00237 mPMInertia(3,3) = mPMInertia(1,1); 00238 case esBall: 00239 mPMInertia(1,1) = (Weight/(slugtolb*5))*Radius*Radius*2; // (2mr^2)/5 00240 mPMInertia(2,2) = mPMInertia(1,1); 00241 mPMInertia(3,3) = mPMInertia(1,1); 00242 break; 00243 default: 00244 break; 00245 } 00246 } 00247 00248 enum esShape {esUnspecified, esTube, esCylinder, esSphere, esBall} eShapeType; 00249 FGColumnVector3 Location; 00250 double Weight; 00251 double Radius; 00252 double Length; 00253 string Name; 00254 FGMatrix33 mPMInertia; 00255 00256 double GetPointMassLocation(int axis) const {return Location(axis);} 00257 double GetPointMassWeight(void) const {return Weight;} 00258 esShape GetShapeType(void) {return eShapeType;} 00259 const FGColumnVector3& GetLocation(void) {return Location;} 00260 const FGMatrix33& GetPointMassInertia(void) {return mPMInertia;} 00261 const string& GetName(void) {return Name;} 00262 00263 void SetPointMassLocation(int axis, double value) {Location(axis) = value;} 00264 void SetPointMassWeight(double wt) {Weight = wt;} 00265 void SetPointMassShapeType(esShape st) {eShapeType = st;} 00266 void SetRadius(double r) {Radius = r;} 00267 void SetLength(double l) {Length = l;} 00268 void SetName(string name) {Name = name;} 00269 double GetPointMassMoI(int r, int c) {return mPMInertia(r,c);} 00270 00271 void bind(FGPropertyManager* PropertyManager, int num); 00272 }; 00273 00274 std::vector <struct PointMass*> PointMasses; 00275 00276 void bind(void); 00277 void Debug(int from); 00278 }; 00279 } 00280 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00281 #endif