1
0
Fork 0

Fixed faulty frame transformation of moment of inertia.

Thanks to Jon for finding the problem.
This commit is contained in:
Anders Gidenstam 2011-07-03 22:05:57 +02:00
parent 4fd1e219a4
commit 69905cc45b
4 changed files with 52 additions and 63 deletions

View file

@ -5,7 +5,7 @@
Date started: 01/21/08 Date started: 01/21/08
Purpose: Encapsulates the buoyant forces Purpose: Encapsulates the buoyant forces
------------- Copyright (C) 2008 - 2010 Anders Gidenstam ------------- ------------- Copyright (C) 2008 - 2011 Anders Gidenstam -------------
------------- Copyright (C) 2008 Jon S. Berndt (jon@jsbsim.org) ------------- ------------- Copyright (C) 2008 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.17 2011/05/20 03:18:36 jberndt Exp $"; static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.19 2011/07/01 21:22:25 andgi Exp $";
static const char *IdHdr = ID_BUOYANTFORCES; static const char *IdHdr = ID_BUOYANTFORCES;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -179,16 +179,7 @@ const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
gasCellJ = FGMatrix33(); gasCellJ = FGMatrix33();
for (unsigned int i=0; i < size; i++) { for (unsigned int i=0; i < size; i++) {
FGColumnVector3 v = FDMExec->GetMassBalance()->StructuralToBody( Cells[i]->GetXYZ() ); gasCellJ += Cells[i]->GetInertia();
// Body basis is in FT.
const double mass = Cells[i]->GetMass();
// FIXME: Verify that this is the correct way to change between the
// coordinate frames.
gasCellJ += Cells[i]->GetInertia() +
FGMatrix33( 0, - mass*v(1)*v(2), - mass*v(1)*v(3),
- mass*v(2)*v(1), 0, - mass*v(2)*v(3),
- mass*v(3)*v(1), - mass*v(3)*v(2), 0 );
} }
return gasCellJ; return gasCellJ;

View file

@ -4,7 +4,7 @@
Author: Anders Gidenstam, Jon S. Berndt Author: Anders Gidenstam, Jon S. Berndt
Date started: 01/21/08 Date started: 01/21/08
------------- Copyright (C) 2008 - 2010 Anders Gidenstam ------------- ------------- Copyright (C) 2008 - 2011 Anders Gidenstam -------------
------------- Copyright (C) 2008 Jon S. Berndt (jon@jsbsim.org) ------------- ------------- Copyright (C) 2008 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -51,7 +51,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.12 2011/05/20 03:18:36 jberndt Exp $" #define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.13 2011/07/01 21:22:25 andgi Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -96,7 +96,7 @@ CLASS DOCUMENTATION
See FGGasCell for the full configuration file format for gas cells. See FGGasCell for the full configuration file format for gas cells.
@author Anders Gidenstam, Jon S. Berndt @author Anders Gidenstam, Jon S. Berndt
@version $Id: FGBuoyantForces.h,v 1.12 2011/05/20 03:18:36 jberndt Exp $ @version $Id: FGBuoyantForces.h,v 1.13 2011/07/01 21:22:25 andgi Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -132,19 +132,19 @@ public:
bool Load(Element* element); bool Load(Element* element);
/** Gets the total Buoyant force vector. /** Gets the total Buoyant force vector.
@return a force vector. */ @return a force vector in lbs. */
const FGColumnVector3& GetForces(void) const {return vTotalForces;} const FGColumnVector3& GetForces(void) const {return vTotalForces;}
/** Gets a component of the total Buoyant force vector. /** Gets a component of the total Buoyant force vector.
@return a component of the force vector. */ @return a component of the force vector in lbs. */
double GetForces(int idx) const {return vTotalForces(idx);} double GetForces(int idx) const {return vTotalForces(idx);}
/** Gets the total Buoyancy moment vector. /** Gets the total Buoyancy moment vector.
@return a moment vector. */ @return a moment vector in the body frame in lbs ft. */
const FGColumnVector3& GetMoments(void) const {return vTotalMoments;} const FGColumnVector3& GetMoments(void) const {return vTotalMoments;}
/** Gets a component of the total Buoyancy moment vector. /** Gets a component of the total Buoyancy moment vector.
@return a component of the moment vector. */ @return a component of the moment vector in the body frame in lbs ft. */
double GetMoments(int idx) const {return vTotalMoments(idx);} double GetMoments(int idx) const {return vTotalMoments(idx);}
/** Gets the total gas mass. The gas mass is part of the aircraft's /** Gets the total gas mass. The gas mass is part of the aircraft's
@ -153,11 +153,12 @@ public:
double GetGasMass(void); double GetGasMass(void);
/** Gets the total moment from the gas mass. /** Gets the total moment from the gas mass.
@return a moment vector. */ @return a moment vector in the structural frame in lbs in. */
const FGColumnVector3& GetGasMassMoment(void); const FGColumnVector3& GetGasMassMoment(void);
/** Gets the total moments of inertia for the gas mass. /** Gets the total moments of inertia for the gas mass in the body frame.
@return . */ @return moments of inertia matrix in the body frame
in slug ft<sup>2</sup>. */
const FGMatrix33& GetGasMassInertia(void); const FGMatrix33& GetGasMassInertia(void);
/** Gets the strings for the current set of gas cells. /** Gets the strings for the current set of gas cells.
@ -174,13 +175,13 @@ public:
private: private:
vector <FGGasCell*> Cells; vector <FGGasCell*> Cells;
// Buoyant forces and moments. Excluding the gas weight. // Buoyant forces and moments. Excluding the gas weight.
FGColumnVector3 vTotalForces; FGColumnVector3 vTotalForces; // [lbs]
FGColumnVector3 vTotalMoments; FGColumnVector3 vTotalMoments; // [lbs ft]
// Gas mass related masses, inertias and moments. // Gas mass related masses, inertias and moments.
FGMatrix33 gasCellJ; FGMatrix33 gasCellJ; // [slug ft^2]
FGColumnVector3 vGasCellXYZ; FGColumnVector3 vGasCellXYZ;
FGColumnVector3 vXYZgasCell_arm; FGColumnVector3 vXYZgasCell_arm; // [lbs in]
bool NoneDefined; bool NoneDefined;

View file

@ -4,7 +4,7 @@
Author: Anders Gidenstam Author: Anders Gidenstam
Date started: 01/21/2006 Date started: 01/21/2006
----- Copyright (C) 2006 - 2008 Anders Gidenstam (anders(at)gidenstam.org) -- ----- Copyright (C) 2006 - 2011 Anders Gidenstam (anders(at)gidenstam.org) --
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software the terms of the GNU Lesser General Public License as published by the Free Software
@ -53,7 +53,7 @@ using std::max;
namespace JSBSim { namespace JSBSim {
static const char *IdSrc = "$Id: FGGasCell.cpp,v 1.13 2010/12/29 22:39:25 andgi Exp $"; static const char *IdSrc = "$Id: FGGasCell.cpp,v 1.14 2011/07/01 21:22:25 andgi Exp $";
static const char *IdHdr = ID_GASCELL; static const char *IdHdr = ID_GASCELL;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -405,6 +405,9 @@ void FGGasCell::Calculate(double dt)
gasCellJ(2,2) = Iyy; gasCellJ(2,2) = Iyy;
gasCellJ(3,3) = Izz; gasCellJ(3,3) = Izz;
Mass = mass; Mass = mass;
// Transform the moments of inertia to the body frame.
gasCellJ += MassBalance->GetPointmassInertia(Mass, GetXYZ());
gasCellM.InitMatrix(); gasCellM.InitMatrix();
gasCellM(eX) += gasCellM(eX) +=
GetXYZ(eX) * Mass*slugtolb; GetXYZ(eX) * Mass*slugtolb;
@ -415,12 +418,10 @@ void FGGasCell::Calculate(double dt)
if (no_ballonets > 0) { if (no_ballonets > 0) {
// Add the mass, moment and inertia of any ballonets. // Add the mass, moment and inertia of any ballonets.
const FGColumnVector3 p = MassBalance->StructuralToBody( GetXYZ() );
for (i = 0; i < no_ballonets; i++) { for (i = 0; i < no_ballonets; i++) {
Mass += Ballonet[i]->GetMass(); Mass += Ballonet[i]->GetMass();
// Add ballonet moments. // Add ballonet moments due to mass (in the structural frame).
gasCellM(eX) += gasCellM(eX) +=
Ballonet[i]->GetXYZ(eX) * Ballonet[i]->GetMass()*slugtolb; Ballonet[i]->GetXYZ(eX) * Ballonet[i]->GetMass()*slugtolb;
gasCellM(eY) += gasCellM(eY) +=
@ -428,15 +429,7 @@ void FGGasCell::Calculate(double dt)
gasCellM(eZ) += gasCellM(eZ) +=
Ballonet[i]->GetXYZ(eZ) * Ballonet[i]->GetMass()*slugtolb; Ballonet[i]->GetXYZ(eZ) * Ballonet[i]->GetMass()*slugtolb;
// Moments of inertia must be converted to the gas cell frame here. gasCellJ += Ballonet[i]->GetInertia();
FGColumnVector3 v =
MassBalance->StructuralToBody( Ballonet[i]->GetXYZ() ) - p;
// Body basis is in FT.
const double mass = Ballonet[i]->GetMass();
gasCellJ += Ballonet[i]->GetInertia() +
FGMatrix33( 0, - mass*v(1)*v(2), - mass*v(1)*v(3),
- mass*v(2)*v(1), 0, - mass*v(2)*v(3),
- mass*v(3)*v(1), - mass*v(3)*v(2), 0 );
} }
} }
} }
@ -525,6 +518,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, int num, FGGasCell* parent)
Atmosphere = exec->GetAtmosphere(); Atmosphere = exec->GetAtmosphere();
PropertyManager = exec->GetPropertyManager(); PropertyManager = exec->GetPropertyManager();
Inertial = exec->GetInertial(); Inertial = exec->GetInertial();
MassBalance = exec->GetMassBalance();
ballonetJ = FGMatrix33(); ballonetJ = FGMatrix33();
@ -791,6 +785,8 @@ void FGBallonet::Calculate(double dt)
ballonetJ(1,1) = Ixx; ballonetJ(1,1) = Ixx;
ballonetJ(2,2) = Iyy; ballonetJ(2,2) = Iyy;
ballonetJ(3,3) = Izz; ballonetJ(3,3) = Izz;
// Transform the moments of inertia to the body frame.
ballonetJ += MassBalance->GetPointmassInertia(GetMass(), GetXYZ());
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -4,7 +4,7 @@
Author: Anders Gidenstam Author: Anders Gidenstam
Date started: 01/21/2006 Date started: 01/21/2006
----- Copyright (C) 2006 - 2008 Anders Gidenstam (anders(at)gidenstam.org) -- ----- Copyright (C) 2006 - 2011 Anders Gidenstam (anders(at)gidenstam.org) --
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software the terms of the GNU Lesser General Public License as published by the Free Software
@ -50,7 +50,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_GASCELL "$Id: FGGasCell.h,v 1.10 2009/10/24 22:59:30 jberndt Exp $" #define ID_GASCELL "$Id: FGGasCell.h,v 1.11 2011/07/01 21:22:25 andgi Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -189,12 +189,12 @@ public:
/** Get the center of gravity location of the gas cell /** Get the center of gravity location of the gas cell
(including any ballonets) (including any ballonets)
@return CoG location in the structural frame. */ @return CoG location in the structural frame in inches. */
const FGColumnVector3& GetXYZ(void) const {return vXYZ;} const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
/** Get the center of gravity location of the gas cell /** Get the center of gravity location of the gas cell
(including any ballonets) (including any ballonets)
@return CoG location in the structural frame. */ @return CoG location in the structural frame in inches. */
double GetXYZ(int idx) const {return vXYZ(idx);} double GetXYZ(int idx) const {return vXYZ(idx);}
/** Get the current mass of the gas cell (including any ballonets) /** Get the current mass of the gas cell (including any ballonets)
@ -202,7 +202,7 @@ public:
double GetMass(void) const {return Mass;} double GetMass(void) const {return Mass;}
/** Get the moments of inertia of the gas cell (including any ballonets) /** Get the moments of inertia of the gas cell (including any ballonets)
@return moments of inertia matrix relative the gas cell location @return moments of inertia matrix in the body frame
in slug ft<sup>2</sup>. */ in slug ft<sup>2</sup>. */
const FGMatrix33& GetInertia(void) const {return gasCellJ;} const FGMatrix33& GetInertia(void) const {return gasCellJ;}
@ -210,7 +210,7 @@ public:
Note that the buoyancy of the gas cell is handled separately by the Note that the buoyancy of the gas cell is handled separately by the
FGForce part and not included here. FGForce part and not included here.
@return moment vector in lbs ft. */ @return moment vector in the structural frame in lbs in. */
const FGColumnVector3& GetMassMoment(void) const {return gasCellM;} const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
/** Get the current gas temperature inside the gas cell /** Get the current gas temperature inside the gas cell
@ -229,8 +229,8 @@ private:
std::string type; std::string type;
int CellNum; int CellNum;
// Structural constants // Structural constants
double MaxVolume; // [ft<EFBFBD>] double MaxVolume; // [ft^2]
double MaxOverpressure; // [lbs/ft<EFBFBD>] double MaxOverpressure; // [lbs/ft^2]
FGColumnVector3 vXYZ; // [in] FGColumnVector3 vXYZ; // [in]
double Xradius, Yradius, Zradius; // [ft] double Xradius, Yradius, Zradius; // [ft]
double Xwidth, Ywidth, Zwidth; // [ft] double Xwidth, Ywidth, Zwidth; // [ft]
@ -240,17 +240,17 @@ private:
typedef vector <FGBallonet*> BallonetArray; typedef vector <FGBallonet*> BallonetArray;
BallonetArray Ballonet; BallonetArray Ballonet;
// Variables // Variables
double Pressure; // [lbs/ft<EFBFBD>] double Pressure; // [lbs/ft^2]
double Contents; // [mol] double Contents; // [mol]
double Volume; // [ft<EFBFBD>] double Volume; // [ft^2]
double dVolumeIdeal; // [ft<EFBFBD>] double dVolumeIdeal; // [ft^2]
double Temperature; // [Rankine] double Temperature; // [Rankine]
double Buoyancy; // [lbs] Note: Gross lift. double Buoyancy; // [lbs] Note: Gross lift.
// Does not include the weight of the gas itself. // Does not include the weight of the gas itself.
double ValveOpen; // 0 <= ValveOpen <= 1 (or higher). double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
double Mass; // [slug] double Mass; // [slug]
FGMatrix33 gasCellJ; // [slug foot<EFBFBD>] FGMatrix33 gasCellJ; // [slug foot^2]
FGColumnVector3 gasCellM; // [lbs ft] FGColumnVector3 gasCellM; // [lbs in]
FGAuxiliary* Auxiliary; FGAuxiliary* Auxiliary;
FGAtmosphere* Atmosphere; FGAtmosphere* Atmosphere;
@ -295,7 +295,6 @@ private:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Models a ballonet inside a gas cell. /** Models a ballonet inside a gas cell.
Models a ballonet inside a gas cell.
Not intended to be used outside FGGasCell. Not intended to be used outside FGGasCell.
See FGGasCell for the configuration file format. See FGGasCell for the configuration file format.
@author Anders Gidenstam @author Anders Gidenstam
@ -312,10 +311,10 @@ public:
/** Get the center of gravity location of the ballonet /** Get the center of gravity location of the ballonet
@return CoG location in the structural frame. */ @return CoG location in the structural frame in inches. */
const FGColumnVector3& GetXYZ(void) const {return vXYZ;} const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
/** Get the center of gravity location of the ballonet /** Get the center of gravity location of the ballonet
@return CoG location in the structural frame. */ @return CoG location in the structural frame in inches. */
double GetXYZ(int idx) const {return vXYZ(idx);} double GetXYZ(int idx) const {return vXYZ(idx);}
/** Get the current mass of the ballonets /** Get the current mass of the ballonets
@ -323,7 +322,8 @@ public:
double GetMass(void) const {return Contents * M_air;} double GetMass(void) const {return Contents * M_air;}
/** Get the moments of inertia of the ballonet /** Get the moments of inertia of the ballonet
@return moments of inertia matrix in slug ft<sup>2</sup>. */ @return moments of inertia matrix in the body frame in
slug ft<sup>2</sup>. */
const FGMatrix33& GetInertia(void) const {return ballonetJ;} const FGMatrix33& GetInertia(void) const {return ballonetJ;}
/** Get the current volume of the ballonet /** Get the current volume of the ballonet
@ -336,8 +336,8 @@ public:
private: private:
int CellNum; int CellNum;
// Structural constants // Structural constants
double MaxVolume; // [ft<EFBFBD>] double MaxVolume; // [ft^2]
double MaxOverpressure; // [lbs/ft<EFBFBD>] double MaxOverpressure; // [lbs/ft^2]
FGColumnVector3 vXYZ; // [in] FGColumnVector3 vXYZ; // [in]
double Xradius, Yradius, Zradius; // [ft] double Xradius, Yradius, Zradius; // [ft]
double Xwidth, Ywidth, Zwidth; // [ft] double Xwidth, Ywidth, Zwidth; // [ft]
@ -347,19 +347,20 @@ private:
FGFunction* BlowerInput; // [ft^3 / sec] FGFunction* BlowerInput; // [ft^3 / sec]
FGGasCell* Parent; FGGasCell* Parent;
// Variables // Variables
double Pressure; // [lbs/ft<EFBFBD>] double Pressure; // [lbs/ft^2]
double Contents; // [mol] double Contents; // [mol]
double Volume; // [ft<EFBFBD>] double Volume; // [ft^2]
double dVolumeIdeal; // [ft<EFBFBD>] double dVolumeIdeal; // [ft^2]
double dU; // [lbs ft / sec] double dU; // [lbs ft / sec]
double Temperature; // [Rankine] double Temperature; // [Rankine]
double ValveOpen; // 0 <= ValveOpen <= 1 (or higher). double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
FGMatrix33 ballonetJ; // [slug foot<EFBFBD>] FGMatrix33 ballonetJ; // [slug foot^2]
FGAuxiliary* Auxiliary; FGAuxiliary* Auxiliary;
FGAtmosphere* Atmosphere; FGAtmosphere* Atmosphere;
FGPropertyManager* PropertyManager; FGPropertyManager* PropertyManager;
FGInertial* Inertial; FGInertial* Inertial;
FGMassBalance* MassBalance;
void Debug(int from); void Debug(int from);
/* Constants. */ /* Constants. */