From a1df1fb70ad3bf07e97d7ad094e9dd1ab7df9a4e Mon Sep 17 00:00:00 2001 From: bcoconni Date: Mon, 15 Dec 2014 20:12:18 +0100 Subject: [PATCH] Synced JSBSim. Adds the following new features: - Ability to modify the location of external forces via the property tree - Ability to specify manually the inertia matrix of "point masses" - Improvements of the water injection feature in the turbine code --- src/FDM/JSBSim/FGFDMExec.cpp | 6 +- src/FDM/JSBSim/FGFDMExec.h | 6 +- .../initialization/FGInitialCondition.cpp | 13 ++--- src/FDM/JSBSim/initialization/FGTrim.cpp | 5 +- .../JSBSim/input_output/FGGroundCallback.h | 31 ++++++++-- src/FDM/JSBSim/math/FGLocation.h | 26 ++++----- src/FDM/JSBSim/models/FGExternalForce.cpp | 5 +- src/FDM/JSBSim/models/FGExternalForce.h | 17 +++++- src/FDM/JSBSim/models/FGExternalReactions.cpp | 4 +- src/FDM/JSBSim/models/FGExternalReactions.h | 4 +- src/FDM/JSBSim/models/FGLGear.cpp | 5 +- src/FDM/JSBSim/models/FGMassBalance.cpp | 37 ++++++++---- src/FDM/JSBSim/models/FGMassBalance.h | 3 +- src/FDM/JSBSim/models/FGPropagate.cpp | 18 +++--- .../JSBSim/models/propulsion/FGTurbine.cpp | 56 ++++++++++++++++--- src/FDM/JSBSim/models/propulsion/FGTurbine.h | 24 +++++++- 16 files changed, 183 insertions(+), 77 deletions(-) mode change 100644 => 100755 src/FDM/JSBSim/models/FGExternalForce.cpp mode change 100644 => 100755 src/FDM/JSBSim/models/FGExternalForce.h mode change 100644 => 100755 src/FDM/JSBSim/models/FGExternalReactions.cpp mode change 100644 => 100755 src/FDM/JSBSim/models/FGExternalReactions.h diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index b43cacba1..9eceb1cd8 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -76,7 +76,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.163 2014/09/04 10:17:20 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.164 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdHdr,ID_FDMEXEC); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1201,7 +1201,7 @@ void FGFDMExec::DoTrim(int mode) FGTrim trim(this, (JSBSim::TrimMode)mode); if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl; trim.Report(); - sim_time = saved_time; + Setsim_time(saved_time); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1216,7 +1216,6 @@ void FGFDMExec::DoSimplexTrim(int mode) } saved_time = sim_time; FGSimplexTrim trim(this, (JSBSim::TrimMode)mode); - sim_time = saved_time; Setsim_time(saved_time); std::cout << "dT: " << dT << std::endl; } @@ -1229,7 +1228,6 @@ void FGFDMExec::DoLinearization(int mode) if (Constructing) return; saved_time = sim_time; FGLinearization lin(this,mode); - sim_time = saved_time; Setsim_time(saved_time); } diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index b3d7a7ba9..b583602f9 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -54,7 +54,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.91 2014/05/17 15:35:53 jberndt Exp $" +#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.93 2014/11/30 13:06:05 bcoconni Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -178,7 +178,7 @@ CLASS DOCUMENTATION property actually maps toa function call of DoTrim(). @author Jon S. Berndt - @version $Revision: 1.91 $ + @version $Revision: 1.93 $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -550,6 +550,7 @@ public: @return the current simulation time. */ double Setsim_time(double cur_time) { sim_time = cur_time; + GetGroundCallback()->SetTime(sim_time); return sim_time; } @@ -570,6 +571,7 @@ public: @return the new simulation time. */ double IncrTime(void) { if (!holding) sim_time += dT; + GetGroundCallback()->SetTime(sim_time); Frame++; return sim_time; } diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp index b9ad81e12..b1b8f5d63 100644 --- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp +++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp @@ -66,7 +66,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.97 2014/11/15 11:57:37 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.98 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdHdr,ID_INITIALCONDITION); //****************************************************************************** @@ -110,7 +110,7 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0, position.SetLongitude(lonRad0); position.SetLatitude(latRad0); - position.SetAltitudeAGL(altAGLFt0, 0.0); + position.SetAltitudeAGL(altAGLFt0); orientation = FGQuaternion(phi0, theta0, psi0); const FGMatrix33& Tb2l = orientation.GetTInv(); @@ -666,21 +666,21 @@ void FGInitialCondition::SetTerrainElevationFtIC(double elev) double FGInitialCondition::GetAltitudeAGLFtIC(void) const { - return position.GetAltitudeAGL(0.0); + return position.GetAltitudeAGL(); } //****************************************************************************** double FGInitialCondition::GetTerrainElevationFtIC(void) const { - return position.GetTerrainRadius(0.0) - position.GetSeaLevelRadius(); + return position.GetTerrainRadius() - position.GetSeaLevelRadius(); } //****************************************************************************** void FGInitialCondition::SetAltitudeAGLFtIC(double agl) { - double terrainElevation = position.GetTerrainRadius(0.0) + double terrainElevation = position.GetTerrainRadius() - position.GetSeaLevelRadius(); SetAltitudeASLFtIC(agl + terrainElevation); lastAltitudeSet = setagl; @@ -1055,8 +1055,7 @@ bool FGInitialCondition::Load_v2(Element* document) if (position_el->FindElement("radius")) { position.SetRadius(position_el->FindElementValueAsNumberConvertTo("radius", "FT")); } else if (position_el->FindElement("altitudeAGL")) { - position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"), - 0.0); + position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT")); } else if (position_el->FindElement("altitudeMSL")) { position.SetAltitudeASL(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT")); } else { diff --git a/src/FDM/JSBSim/initialization/FGTrim.cpp b/src/FDM/JSBSim/initialization/FGTrim.cpp index 3de32e76e..ff1601c36 100644 --- a/src/FDM/JSBSim/initialization/FGTrim.cpp +++ b/src/FDM/JSBSim/initialization/FGTrim.cpp @@ -57,7 +57,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.23 2014/05/01 18:32:54 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.24 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdHdr,ID_TRIM); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -399,8 +399,7 @@ void FGTrim::trimOnGround(void) FGColumnVector3 normal, vDummy; FGLocation lDummy; - double height = gearLoc.GetContactPoint(fdmex->GetSimTime(), lDummy, - normal, vDummy, vDummy); + double height = gearLoc.GetContactPoint(lDummy, normal, vDummy, vDummy); c.normal = Tec2b * normal; contacts.push_back(c); diff --git a/src/FDM/JSBSim/input_output/FGGroundCallback.h b/src/FDM/JSBSim/input_output/FGGroundCallback.h index 96ddde811..3c122ba1d 100644 --- a/src/FDM/JSBSim/input_output/FGGroundCallback.h +++ b/src/FDM/JSBSim/input_output/FGGroundCallback.h @@ -45,7 +45,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.17 2014/05/17 15:35:54 jberndt Exp $" +#define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.18 2014/11/30 12:35:32 bcoconni Exp $" namespace JSBSim { @@ -62,7 +62,7 @@ CLASS DOCUMENTATION ball formed earth with an adjustable terrain elevation. @author Mathias Froehlich - @version $Id: FGGroundCallback.h,v 1.17 2014/05/17 15:35:54 jberndt Exp $ + @version $Id: FGGroundCallback.h,v 1.18 2014/11/30 12:35:32 bcoconni Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -73,7 +73,7 @@ class FGGroundCallback : public SGReferenced { public: - FGGroundCallback() {} + FGGroundCallback() : time(0.0) {} virtual ~FGGroundCallback() {} /** Compute the altitude above sealevel @@ -96,14 +96,33 @@ public: FGColumnVector3& normal, FGColumnVector3& v, FGColumnVector3& w) const = 0; + /** Compute the altitude above ground. + The altitude depends on location l. + @param l location + @param contact Contact point location below the location l + @param normal Normal vector at the contact point + @param v Linear velocity at the contact point + @param w Angular velocity at the contact point + @return altitude above ground + */ + virtual double GetAGLevel(const FGLocation& location, FGLocation& contact, + FGColumnVector3& normal, FGColumnVector3& v, + FGColumnVector3& w) const + { return GetAGLevel(time, location, contact, normal, v, w); } + /** Compute the local terrain radius @param t simulation time @param location location */ virtual double GetTerrainGeoCentRadius(double t, const FGLocation& location) const = 0; + /** Compute the local terrain radius + @param location location + */ + virtual double GetTerrainGeoCentRadius(const FGLocation& location) const + { return GetTerrainGeoCentRadius(time, location); } + /** Return the sea level radius - @param t simulation time @param location location */ virtual double GetSeaLevelRadius(const FGLocation& location) const = 0; @@ -120,6 +139,10 @@ public: */ virtual void SetSeaLevelRadius(double radius) { } + void SetTime(double _time) { time = _time; } + +private: + double time; }; typedef SGSharedPtr FGGroundCallback_ptr; diff --git a/src/FDM/JSBSim/math/FGLocation.h b/src/FDM/JSBSim/math/FGLocation.h index 38a6c76cb..9f086f6b8 100644 --- a/src/FDM/JSBSim/math/FGLocation.h +++ b/src/FDM/JSBSim/math/FGLocation.h @@ -51,7 +51,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_LOCATION "$Id: FGLocation.h,v 1.33 2014/08/28 11:46:12 bcoconni Exp $" +#define ID_LOCATION "$Id: FGLocation.h,v 1.34 2014/11/30 12:35:32 bcoconni Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -150,7 +150,7 @@ CLASS DOCUMENTATION @see W. C. Durham "Aircraft Dynamics & Control", section 2.2 @author Mathias Froehlich - @version $Id: FGLocation.h,v 1.33 2014/08/28 11:46:12 bcoconni Exp $ + @version $Id: FGLocation.h,v 1.34 2014/11/30 12:35:32 bcoconni Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -333,13 +333,13 @@ public: @param altitudeASL altitude above Sea Level in feet. @see SetGroundCallback */ void SetAltitudeASL(double altitudeASL) - { SetRadius(GroundCallback->GetSeaLevelRadius(*this) + altitudeASL); } + { SetRadius(GetSeaLevelRadius() + altitudeASL); } /** Set the altitude above ground level. @param altitudeAGL altitude above Ground Level in feet. @see SetGroundCallback */ - void SetAltitudeAGL(double altitudeAGL, double time) - { SetRadius(GroundCallback->GetTerrainGeoCentRadius(time, *this) + altitudeAGL); } + void SetAltitudeAGL(double altitudeAGL) + { SetRadius(GetTerrainRadius() + altitudeAGL); } /** Get the local sea level radius @return the sea level radius at the location in feet. @@ -350,36 +350,34 @@ public: /** Get the local terrain radius @return the terrain level radius at the location in feet. @see SetGroundCallback */ - double GetTerrainRadius(double time) const - { ComputeDerived(); return GroundCallback->GetTerrainGeoCentRadius(time, *this); } + double GetTerrainRadius(void) const + { ComputeDerived(); return GroundCallback->GetTerrainGeoCentRadius(*this); } /** Get the altitude above sea level. @return the altitude ASL in feet. @see SetGroundCallback */ - double GetAltitudeASL() const + double GetAltitudeASL(void) const { ComputeDerived(); return GroundCallback->GetAltitude(*this); } /** Get the altitude above ground level. @return the altitude AGL in feet. @see SetGroundCallback */ - double GetAltitudeAGL(double time) const { + double GetAltitudeAGL(void) const { FGLocation c; FGColumnVector3 n,v,w; - return GetContactPoint(time,c,n,v,w); + return GetContactPoint(c,n,v,w); } /** Get terrain contact point information below the current location. - @param time Simulation time @param contact Contact point location @param normal Terrain normal vector in contact point (ECEF frame) @param v Terrain linear velocity in contact point (ECEF frame) @param w Terrain angular velocity in contact point (ECEF frame) @return Location altitude above contact point (AGL) in feet. @see SetGroundCallback */ - double GetContactPoint(double time, - FGLocation& contact, FGColumnVector3& normal, + double GetContactPoint(FGLocation& contact, FGColumnVector3& normal, FGColumnVector3& v, FGColumnVector3& w) const - { ComputeDerived(); return GroundCallback->GetAGLevel(time, *this, contact, normal, v, w); } + { ComputeDerived(); return GroundCallback->GetAGLevel(*this, contact, normal, v, w); } ///@} /** Sets the ground callback pointer. The FGGroundCallback instance will be diff --git a/src/FDM/JSBSim/models/FGExternalForce.cpp b/src/FDM/JSBSim/models/FGExternalForce.cpp old mode 100644 new mode 100755 index 010b311b1..182d09cec --- a/src/FDM/JSBSim/models/FGExternalForce.cpp +++ b/src/FDM/JSBSim/models/FGExternalForce.cpp @@ -60,7 +60,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGExternalForce.cpp,v 1.14 2014/01/13 10:46:07 ehofman Exp $"); +IDENT(IdSrc,"$Id: FGExternalForce.cpp,v 1.15 2014/11/25 01:44:17 dpculp Exp $"); IDENT(IdHdr,ID_EXTERNALFORCE); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -124,6 +124,9 @@ FGExternalForce::FGExternalForce(FGFDMExec *FDMExec, Element *el, int index) location = location_element->FindElementTripletConvertTo("IN"); SetLocation(location); } + PropertyManager->Tie( BasePropertyName + "/locx", (FGExternalForce*)this, &FGExternalForce::GetLocX, &FGExternalForce::SetLocX); + PropertyManager->Tie( BasePropertyName + "/locy", (FGExternalForce*)this, &FGExternalForce::GetLocY, &FGExternalForce::SetLocY); + PropertyManager->Tie( BasePropertyName + "/locz", (FGExternalForce*)this, &FGExternalForce::GetLocZ, &FGExternalForce::SetLocZ); direction_element = el->FindElement("direction"); if (!direction_element) { diff --git a/src/FDM/JSBSim/models/FGExternalForce.h b/src/FDM/JSBSim/models/FGExternalForce.h old mode 100644 new mode 100755 index 5cfb5f02e..0d7df5a59 --- a/src/FDM/JSBSim/models/FGExternalForce.h +++ b/src/FDM/JSBSim/models/FGExternalForce.h @@ -51,7 +51,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.11 2012/12/23 14:56:58 bcoconni Exp $" +#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.13 2014/11/25 01:44:17 dpculp Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -121,6 +121,15 @@ CLASS DOCUMENTATION The force direction is not actually required to be specified as a unit vector, but prior to the force vector being calculated, the direction vector is normalized. + + The location of the force vector, in structural coordinates, can be set at + runtime through the following properties: + + @code + external_reactions/{force name}/locx + external_reactions/{force name}/locy + external_reactions/{force name}/locz + @endcode */ @@ -163,6 +172,12 @@ public: void SetX(double x) {vDirection(eX) = x;} void SetY(double y) {vDirection(eY) = y;} void SetZ(double z) {vDirection(eZ) = z;} + double GetLocX(void) const {return vActingXYZn(eX);} + double GetLocY(void) const {return vActingXYZn(eY);} + double GetLocZ(void) const {return vActingXYZn(eZ);} + void SetLocX(double x) {vXYZn(eX) = x; vActingXYZn(eX) = x;} + void SetLocY(double y) {vXYZn(eY) = y; vActingXYZn(eY) = y;} + void SetLocZ(double z) {vXYZn(eZ) = z; vActingXYZn(eZ) = z;} private: diff --git a/src/FDM/JSBSim/models/FGExternalReactions.cpp b/src/FDM/JSBSim/models/FGExternalReactions.cpp old mode 100644 new mode 100755 index b07da0908..14489904f --- a/src/FDM/JSBSim/models/FGExternalReactions.cpp +++ b/src/FDM/JSBSim/models/FGExternalReactions.cpp @@ -6,7 +6,7 @@ Purpose: Manages the External Forces Called by: FGAircraft - ------------- Copyright (C) 2006 David P. Culp (davidculp2@comcast.net) ------------- + ------------- Copyright (C) 2006 David P. Culp (daveculp@cox.net) ------------- 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 @@ -54,7 +54,7 @@ DEFINITIONS GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -IDENT(IdSrc,"$Id: FGExternalReactions.cpp,v 1.18 2014/06/09 11:52:07 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGExternalReactions.cpp,v 1.19 2014/11/25 01:42:27 dpculp Exp $"); IDENT(IdHdr,ID_EXTERNALREACTIONS); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGExternalReactions.h b/src/FDM/JSBSim/models/FGExternalReactions.h old mode 100644 new mode 100755 index b6c39a764..d322817e8 --- a/src/FDM/JSBSim/models/FGExternalReactions.h +++ b/src/FDM/JSBSim/models/FGExternalReactions.h @@ -4,7 +4,7 @@ Author: David P. Culp Date started: 17/11/06 - ------------- Copyright (C) 2006 David P. Culp (davidculp2@comcast.net) ------------- + ------------- Copyright (C) 2006 David P. Culp (daveculp@cox.net) ------------- 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 @@ -46,7 +46,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.15 2013/11/24 11:40:56 bcoconni Exp $" +#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.16 2014/11/25 01:42:27 dpculp Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS diff --git a/src/FDM/JSBSim/models/FGLGear.cpp b/src/FDM/JSBSim/models/FGLGear.cpp index a77d7bfe0..7ac687ee5 100644 --- a/src/FDM/JSBSim/models/FGLGear.cpp +++ b/src/FDM/JSBSim/models/FGLGear.cpp @@ -63,7 +63,7 @@ DEFINITIONS GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -IDENT(IdSrc,"$Id: FGLGear.cpp,v 1.117 2014/06/08 12:50:05 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGLGear.cpp,v 1.118 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdHdr,ID_LGEAR); // Body To Structural (body frame is rotated 180 deg about Y and lengths are given in @@ -270,7 +270,6 @@ void FGLGear::ResetToIC(void) const FGColumnVector3& FGLGear::GetBodyForces(FGSurface *surface) { double gearPos = 1.0; - double t = fdmex->GetSimTime(); vFn.InitMatrix(); @@ -286,7 +285,7 @@ const FGColumnVector3& FGLGear::GetBodyForces(FGSurface *surface) // Compute the height of the theoretical location of the wheel (if strut is // not compressed) with respect to the ground level - double height = gearLoc.GetContactPoint(t, contact, normal, terrainVel, dummy); + double height = gearLoc.GetContactPoint(contact, normal, terrainVel, dummy); // Does this surface contact point interact with another surface? if (surface) { diff --git a/src/FDM/JSBSim/models/FGMassBalance.cpp b/src/FDM/JSBSim/models/FGMassBalance.cpp index 0181c09eb..18b051879 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.cpp +++ b/src/FDM/JSBSim/models/FGMassBalance.cpp @@ -51,7 +51,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.50 2014/06/09 11:52:07 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.51 2014/11/29 13:47:19 bcoconni Exp $"); IDENT(IdHdr,ID_MASSBALANCE); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -102,17 +102,10 @@ bool FGMassBalance::InitModel(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGMassBalance::Load(Element* document) +static FGMatrix33 ReadInertiaMatrix(Element* document) { - string element_name = ""; double bixx, biyy, bizz, bixy, bixz, biyz; - Name = "Mass Properties Model: " + document->GetAttributeValue("name"); - - // Perform base class Pre-Load - if (!FGModel::Load(document)) - return false; - bixx = biyy = bizz = bixy = bixz = biyz = 0.0; if (document->FindElement("ixx")) bixx = document->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2"); @@ -126,9 +119,25 @@ bool FGMassBalance::Load(Element* document) bixz = document->FindElementValueAsNumberConvertTo("ixz", "SLUG*FT2"); if (document->FindElement("iyz")) biyz = document->FindElementValueAsNumberConvertTo("iyz", "SLUG*FT2"); - SetAircraftBaseInertias(FGMatrix33( bixx, -bixy, bixz, - -bixy, biyy, -biyz, - bixz, -biyz, bizz )); + + return FGMatrix33( bixx, -bixy, bixz, + -bixy, biyy, -biyz, + bixz, -biyz, bizz ); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +bool FGMassBalance::Load(Element* document) +{ + string element_name = ""; + + Name = "Mass Properties Model: " + document->GetAttributeValue("name"); + + // Perform base class Pre-Load + if (!FGModel::Load(document)) + return false; + + SetAircraftBaseInertias(ReadInertiaMatrix(document)); if (document->FindElement("emptywt")) { EmptyWeight = document->FindElementValueAsNumberConvertTo("emptywt", "LBS"); } @@ -291,6 +300,10 @@ void FGMassBalance::AddPointMass(Element* el) } else { } } + else { + pm->SetPointMassShapeType(PointMass::esUnspecified); + pm->SetPointMassMoI(ReadInertiaMatrix(el)); + } pm->bind(PropertyManager, PointMasses.size()); PointMasses.push_back(pm); diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h index 2c783ad87..d31943a2f 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.h +++ b/src/FDM/JSBSim/models/FGMassBalance.h @@ -48,7 +48,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.31 2014/05/17 15:17:13 jberndt Exp $" +#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.32 2014/11/29 13:47:19 bcoconni Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONSS @@ -267,6 +267,7 @@ private: void SetRadius(double r) {Radius = r;} void SetLength(double l) {Length = l;} void SetName(string name) {Name = name;} + void SetPointMassMoI(const FGMatrix33& MoI) { mPMInertia = MoI; } double GetPointMassMoI(int r, int c) {return mPMInertia(r,c);} void bind(FGPropertyManager* PropertyManager, int num); diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp index d46c192f3..c0d20fdb6 100644 --- a/src/FDM/JSBSim/models/FGPropagate.cpp +++ b/src/FDM/JSBSim/models/FGPropagate.cpp @@ -79,7 +79,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.125 2014/05/17 15:15:53 jberndt Exp $"); +IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.126 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdHdr,ID_PROPAGATE); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -125,7 +125,7 @@ bool FGPropagate::InitModel(void) // For initialization ONLY: VState.vLocation.SetEllipse(in.SemiMajor, in.SemiMinor); - VState.vLocation.SetAltitudeAGL(4.0, FDMExec->GetSimTime()); + VState.vLocation.SetAltitudeAGL(4.0); VState.dqPQRidot.resize(5, FGColumnVector3(0.0,0.0,0.0)); VState.dqUVWidot.resize(5, FGColumnVector3(0.0,0.0,0.0)); @@ -485,8 +485,8 @@ void FGPropagate::RecomputeLocalTerrainVelocity() { FGLocation contact; FGColumnVector3 normal; - VState.vLocation.GetContactPoint(FDMExec->GetSimTime(), contact, normal, - LocalTerrainVelocity, LocalTerrainAngularVelocity); + VState.vLocation.GetContactPoint(contact, normal, LocalTerrainVelocity, + LocalTerrainAngularVelocity); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -509,28 +509,28 @@ void FGPropagate::SetSeaLevelRadius(double tt) double FGPropagate::GetLocalTerrainRadius(void) const { - return VState.vLocation.GetTerrainRadius(FDMExec->GetSimTime()); + return VState.vLocation.GetTerrainRadius(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% double FGPropagate::GetDistanceAGL(void) const { - return VState.vLocation.GetAltitudeAGL(FDMExec->GetSimTime()); + return VState.vLocation.GetAltitudeAGL(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% double FGPropagate::GetDistanceAGLKm(void) const { - return VState.vLocation.GetAltitudeAGL(FDMExec->GetSimTime())*0.0003048; + return VState.vLocation.GetAltitudeAGL()*0.0003048; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGPropagate::SetDistanceAGL(double tt) { - VState.vLocation.SetAltitudeAGL(tt, FDMExec->GetSimTime()); + VState.vLocation.SetAltitudeAGL(tt); UpdateVehicleState(); } @@ -538,7 +538,7 @@ void FGPropagate::SetDistanceAGL(double tt) void FGPropagate::SetDistanceAGLKm(double tt) { - VState.vLocation.SetAltitudeAGL(tt*3280.8399, FDMExec->GetSimTime()); + VState.vLocation.SetAltitudeAGL(tt*3280.8399); UpdateVehicleState(); } diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp index 5a609f29d..2fce543aa 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp @@ -5,7 +5,7 @@ Date started: 03/11/2003 Purpose: This module models a turbine engine. - ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net) --------- + ------------- Copyright (C) 2003 David Culp (daveculp@cox.net) --------- 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 @@ -51,7 +51,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.43 2014/06/08 12:50:05 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.44 2014/12/12 01:21:17 dpculp Exp $"); IDENT(IdHdr,ID_TURBINE); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -73,7 +73,9 @@ FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number, struct Inp Augmented = AugMethod = Injected = 0; BypassRatio = BleedDemand = 0.0; IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0; - N1_spinup = 1.0; N2_spinup = 3.0; + N1_spinup = 1.0; N2_spinup = 3.0; + InjectionTime = 30.0; + InjectionTimer = InjWaterNorm = 0.0; EPR = 1.0; Load(exec, el); @@ -94,10 +96,10 @@ void FGTurbine::ResetToIC(void) FGEngine::ResetToIC(); - N1 = N2 = 0.0; + N1 = N2 = InjN1increment = InjN2increment = 0.0; N2norm = 0.0; correctedTSFC = TSFC; - AugmentCmd = 0.0; + AugmentCmd = InjWaterNorm = 0.0; InletPosition = NozzlePosition = 1.0; Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false; Cutoff = true; @@ -131,6 +133,8 @@ void FGTurbine::Calculate(void) if ((phase == tpTrim) && (in.TotalDeltaT > 0)) { if (Running && !Starved) { phase = tpRun; + N1_factor = MaxN1 - IdleN1; + N2_factor = MaxN2 - IdleN2; N2 = IdleN2 + ThrottlePos * N2_factor; N1 = IdleN1 + ThrottlePos * N1_factor; OilTemp_degK = 366.0; @@ -209,7 +213,12 @@ double FGTurbine::Run() double n = N2norm + 0.1; if (n > 1) n = 1; spoolup = delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - sigma)); - + N1_factor = MaxN1 - IdleN1; + N2_factor = MaxN2 - IdleN2; + if ((Injected == 1) && Injection && (InjWaterNorm > 0)) { + N1_factor += InjN1increment; + N2_factor += InjN2increment; + } N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, spoolup, spoolup * 3.0); N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, spoolup, spoolup * 2.4); N2norm = (N2 - IdleN2) / N2_factor; @@ -250,12 +259,14 @@ double FGTurbine::Run() } } - if ((Injected == 1) && Injection) { + if ((Injected == 1) && Injection && (InjWaterNorm > 0.0)) { InjectionTimer += in.TotalDeltaT; if (InjectionTimer < InjectionTime) { thrust = thrust * InjectionLookup->GetValue(); + InjWaterNorm = 1.0 - (InjectionTimer/InjectionTime); } else { Injection = false; + InjWaterNorm = 0.0; } } @@ -455,8 +466,14 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el) AugMethod = (int)el->FindElementValueAsNumber("augmethod"); if (el->FindElement("injected")) Injected = (int)el->FindElementValueAsNumber("injected"); - if (el->FindElement("injection-time")) + if (el->FindElement("injection-time")){ InjectionTime = el->FindElementValueAsNumber("injection-time"); + InjWaterNorm =1.0; + } + if (el->FindElement("injection-N1-inc")) + InjN1increment = el->FindElementValueAsNumber("injection-N1-inc"); + if (el->FindElement("injection-N2-inc")) + InjN2increment = el->FindElementValueAsNumber("injection-N2-inc"); string property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber); @@ -522,6 +539,24 @@ void FGTurbine::bindmodel() PropertyManager->Tie( property_name.c_str(), &Stalled); property_name = base_property_name + "/bleed-factor"; PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, &FGTurbine::GetBleedDemand, &FGTurbine::SetBleedDemand); + property_name = base_property_name + "/MaxN1"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetMaxN1, &FGTurbine::SetMaxN1); + property_name = base_property_name + "/MaxN2"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetMaxN2, &FGTurbine::SetMaxN2); + property_name = base_property_name + "/InjectionTimer"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetInjectionTimer, &FGTurbine::SetInjectionTimer); + property_name = base_property_name + "/InjWaterNorm"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetInjWaterNorm, &FGTurbine::SetInjWaterNorm); + property_name = base_property_name + "/InjN1increment"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetInjN1increment, &FGTurbine::SetInjN1increment); + property_name = base_property_name + "/InjN2increment"; + PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, + &FGTurbine::GetInjN2increment, &FGTurbine::SetInjN2increment); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -531,7 +566,10 @@ int FGTurbine::InitRunning(void) FDMExec->SuspendIntegration(); Cutoff=false; Running=true; - N2=IdleN2; + N1_factor = MaxN1 - IdleN1; + N2_factor = MaxN2 - IdleN2; + N2 = IdleN2 + ThrottlePos * N2_factor; + N1 = IdleN1 + ThrottlePos * N1_factor; Calculate(); FDMExec->ResumeIntegration(); return phase==tpRun; diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.h b/src/FDM/JSBSim/models/propulsion/FGTurbine.h index 67816c191..d7f03434e 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.h +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.h @@ -4,7 +4,7 @@ Author: David Culp Date started: 03/11/2003 - ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net)---------- + ------------- Copyright (C) 2003 David Culp (daveculp@cox.net)---------- 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 @@ -42,7 +42,7 @@ INCLUDES #include "FGEngine.h" -#define ID_TURBINE "$Id: FGTurbine.h,v 1.22 2011/08/04 13:45:42 jberndt Exp $" +#define ID_TURBINE "$Id: FGTurbine.h,v 1.23 2014/12/12 01:21:17 dpculp Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -130,6 +130,8 @@ CLASS DOCUMENTATION 0 = Water injection not installed 1 = Water injection installed injection-time - Time, in seconds, of water injection duration + InjN1increment - % increase in N1 when injection is taking place + InjN2increment - % increase in N2 when injection is taking place

NOTES:

@@ -150,7 +152,7 @@ CLASS DOCUMENTATION /engine/direct.xml @author David P. Culp - @version "$Id: FGTurbine.h,v 1.22 2011/08/04 13:45:42 jberndt Exp $" + @version "$Id: FGTurbine.h,v 1.23 2014/12/12 01:21:17 dpculp Exp $" */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -199,8 +201,14 @@ public: double GetEPR(void) const {return EPR;} double GetEGT(void) const {return EGT_degC;} + double GetMaxN1(void) const {return MaxN1;} + double GetMaxN2(void) const {return MaxN2;} double getOilPressure_psi () const {return OilPressure_psi;} double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);} + double GetInjectionTimer(void) const {return InjectionTimer;} + double GetInjWaterNorm(void) const {return InjWaterNorm;} + double GetInjN1increment(void) const {return InjN1increment;} + double GetInjN2increment(void) const {return InjN2increment;} void SetInjection(bool injection) {Injection = injection;} void SetIgnition(int ignition) {Ignition = ignition;} @@ -210,6 +218,13 @@ public: void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;} void SetReverse(bool reversed) { Reversed = reversed; } void SetCutoff(bool cutoff) { Cutoff = cutoff; } + void SetMaxN1(double maxn1) {MaxN1 = maxn1;} + void SetMaxN2(double maxn2) {MaxN2 = maxn2;} + void SetInjectionTimer(double injtimer) {InjectionTimer = injtimer;} + void SetInjWaterNorm(double injwater) {InjWaterNorm = injwater;} + void SetInjN1increment(double injN1inc) {InjN1increment = injN1inc;} + void SetInjN2increment(double injN2inc) {InjN2increment = injN2inc;} + int InitRunning(void); void ResetToIC(void); @@ -264,6 +279,9 @@ private: double correctedTSFC; double InjectionTimer; double InjectionTime; + double InjWaterNorm; + double InjN1increment; + double InjN2increment; double Off(void); double Run();