]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGAuxiliary.cpp
Updates from JSBSim, including new turbine engine model from David Culp
[flightgear.git] / src / FDM / JSBSim / FGAuxiliary.cpp
index d744579d36a3d63647cfc2c67f444e4143838778..aa188c32c446c1d2b68a1276dceaaa60b37ce17a 100644 (file)
@@ -41,6 +41,7 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGAuxiliary.h"
+#include "FGAerodynamics.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGAtmosphere.h"
@@ -54,6 +55,9 @@ INCLUDES
 #include "FGMatrix33.h"
 #include "FGColumnVector3.h"
 #include "FGColumnVector4.h"
+#include "FGPropertyManager.h"
+
+namespace JSBSim {
 
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_AUXILIARY;
@@ -70,6 +74,10 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
   psl = rhosl = 1;
   earthPosAngle = 0.0;
   
+  vPilotAccelN.InitMatrix();
+  
+  bind();
+  
   Debug(0);
 }
 
@@ -77,6 +85,7 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
 
 FGAuxiliary::~FGAuxiliary()
 {
+  unbind();
   Debug(1);
 }
 
@@ -88,6 +97,10 @@ bool FGAuxiliary::Run()
 
   if (!FGModel::Run()) {
     GetState();
+    
+    //caculate total temperature assuming isentropic flow
+    tat=sat*(1 + 0.2*mach*mach);
+    
     if (mach < 1) {   //calculate total pressure assuming isentropic flow
       pt=p*pow((1 + 0.2*mach*mach),3.5);
     } else {
@@ -145,14 +158,24 @@ bool FGAuxiliary::Run()
     // mass, the acceleration vector is calculated. The term wdot is equivalent
     // to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
     // The radius R is calculated below in the vector vToEyePt.
-        
-    vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
-
-    vPilotAccel = Aircraft->GetBodyAccel()
-                  + Rotation->GetPQRdot() * vToEyePt
-                  + Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt)
-                  + Inertial->GetGravity();
+    
+    vPilotAccel.InitMatrix();   
+    if ( Translation->GetVt() > 1 ) {
+       vPilotAccel =  Aerodynamics->GetForces() 
+                  +  Propulsion->GetForces()
+                  +  GroundReactions->GetForces();
+       vPilotAccel /= MassBalance->GetMass();
+       vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
+       vToEyePt *= inchtoft;
+       vPilotAccel += Rotation->GetPQRdot() * vToEyePt;
+       vPilotAccel += Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt);
+    } else {
+       vPilotAccel = -1*( State->GetTl2b() * Inertial->GetGravity() );
+    }   
 
+    vPilotAccelN = vPilotAccel/Inertial->gravity();
+      
+    
     earthPosAngle += State->Getdt()*Inertial->omega();
     return false;
   } else {
@@ -188,16 +211,62 @@ double FGAuxiliary::GetCrossWind(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGColumnVector3 FGAuxiliary::GetNpilot(void)
+void FGAuxiliary::bind(void)
 {
-  return vPilotAccel/Inertial->gravity();
+  typedef double (FGAuxiliary::*PMF)(int) const;
+  PropertyManager->Tie("velocities/vc-fps", this,
+                       &FGAuxiliary::GetVcalibratedFPS);
+  PropertyManager->Tie("velocities/vc-kts", this,
+                       &FGAuxiliary::GetVcalibratedKTS);
+  PropertyManager->Tie("velocities/ve-fps", this,
+                       &FGAuxiliary::GetVequivalentFPS);
+  PropertyManager->Tie("velocities/ve-kts", this,
+                       &FGAuxiliary::GetVequivalentKTS);
+  PropertyManager->Tie("velocities/tat-r", this,
+                       &FGAuxiliary::GetTotalTemperature);
+  PropertyManager->Tie("velocities/pt-lbs_sqft", this,
+                       &FGAuxiliary::GetTotalPressure);
+                     
+  PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this,1,
+                       (PMF)&FGAuxiliary::GetPilotAccel);
+  PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this,2,
+                       (PMF)&FGAuxiliary::GetPilotAccel);
+  PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this,3,
+                       (PMF)&FGAuxiliary::GetPilotAccel);
+  PropertyManager->Tie("accelerations/n-pilot-x-norm", this,1,
+                       (PMF)&FGAuxiliary::GetNpilot);
+  PropertyManager->Tie("accelerations/n-pilot-y-norm", this,2,
+                       (PMF)&FGAuxiliary::GetNpilot);
+  PropertyManager->Tie("accelerations/n-pilot-z-norm", this,3,
+                       (PMF)&FGAuxiliary::GetNpilot);
+  PropertyManager->Tie("position/epa-rad", this,
+                       &FGAuxiliary::GetEarthPositionAngle);
+  /* PropertyManager->Tie("atmosphere/headwind-fps", this,
+                       &FGAuxiliary::GetHeadWind,
+                       true);
+  PropertyManager->Tie("atmosphere/crosswind-fps", this,
+                       &FGAuxiliary::GetCrossWind,
+                       true); */
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGAuxiliary::GetNpilot(int idx)
+void FGAuxiliary::unbind(void)
 {
-  return (vPilotAccel/Inertial->gravity())(idx);
+  PropertyManager->Untie("velocities/vc-fps");
+  PropertyManager->Untie("velocities/vc-kts");
+  PropertyManager->Untie("velocities/ve-fps");
+  PropertyManager->Untie("velocities/ve-kts");
+  PropertyManager->Untie("accelerations/a-pilot-x-ft_sec2");
+  PropertyManager->Untie("accelerations/a-pilot-y-ft_sec2");
+  PropertyManager->Untie("accelerations/a-pilot-z-ft_sec2");
+  PropertyManager->Untie("accelerations/n-pilot-x-norm");
+  PropertyManager->Untie("accelerations/n-pilot-y-norm");
+  PropertyManager->Untie("accelerations/n-pilot-z-norm");
+  PropertyManager->Untie("position/epa-rad");
+  /* PropertyManager->Untie("atmosphere/headwind-fps");
+  PropertyManager->Untie("atmosphere/crosswind-fps"); */
+
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -209,6 +278,7 @@ void FGAuxiliary::GetState(void)
   p = Atmosphere->GetPressure();
   rhosl = Atmosphere->GetDensitySL();
   psl = Atmosphere->GetPressureSL();
+  sat = Atmosphere->GetTemperature();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -257,3 +327,4 @@ void FGAuxiliary::Debug(int from)
   }
 }
 
+} // namespace JSBSim