From 587fd0937e94e1883cdf98cd2ff62d4343a2081b Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 13 Jan 2006 09:49:09 +0000 Subject: [PATCH] Remove a bunch of unneede files. --- src/FDM/JSBSim/FGAerodynamics.cpp | 430 ---------- src/FDM/JSBSim/FGAerodynamics.h | 199 ----- src/FDM/JSBSim/FGAircraft.cpp | 399 ---------- src/FDM/JSBSim/FGAircraft.h | 184 ----- src/FDM/JSBSim/FGAtmosphere.cpp | 541 ------------- src/FDM/JSBSim/FGAtmosphere.h | 205 ----- src/FDM/JSBSim/FGAuxiliary.cpp | 420 ---------- src/FDM/JSBSim/FGAuxiliary.h | 245 ------ src/FDM/JSBSim/FGCoefficient.cpp | 522 ------------- src/FDM/JSBSim/FGCoefficient.h | 206 ----- src/FDM/JSBSim/FGColumnVector3.cpp | 159 ---- src/FDM/JSBSim/FGColumnVector3.h | 307 -------- src/FDM/JSBSim/FGConfigFile.cpp | 354 --------- src/FDM/JSBSim/FGConfigFile.h | 147 ---- src/FDM/JSBSim/FGElectric.cpp | 171 ---- src/FDM/JSBSim/FGElectric.h | 107 --- src/FDM/JSBSim/FGEngine.cpp | 349 --------- src/FDM/JSBSim/FGEngine.h | 252 ------ src/FDM/JSBSim/FGFCS.cpp | 890 --------------------- src/FDM/JSBSim/FGFCS.h | 651 ---------------- src/FDM/JSBSim/FGFactorGroup.cpp | 210 ----- src/FDM/JSBSim/FGFactorGroup.h | 115 --- src/FDM/JSBSim/FGForce.cpp | 180 ----- src/FDM/JSBSim/FGForce.h | 338 -------- src/FDM/JSBSim/FGGroundCallback.cpp | 78 -- src/FDM/JSBSim/FGGroundCallback.h | 88 --- src/FDM/JSBSim/FGGroundReactions.cpp | 272 ------- src/FDM/JSBSim/FGGroundReactions.h | 113 --- src/FDM/JSBSim/FGInertial.cpp | 145 ---- src/FDM/JSBSim/FGInertial.h | 103 --- src/FDM/JSBSim/FGInitialCondition.cpp | 1036 ------------------------- src/FDM/JSBSim/FGInitialCondition.h | 302 ------- src/FDM/JSBSim/FGLGear.cpp | 596 -------------- src/FDM/JSBSim/FGLGear.h | 329 -------- src/FDM/JSBSim/FGLocation.cpp | 221 ------ src/FDM/JSBSim/math/FGFunction.cpp | 6 +- 36 files changed, 4 insertions(+), 10866 deletions(-) delete mode 100644 src/FDM/JSBSim/FGAerodynamics.cpp delete mode 100644 src/FDM/JSBSim/FGAerodynamics.h delete mode 100644 src/FDM/JSBSim/FGAircraft.cpp delete mode 100644 src/FDM/JSBSim/FGAircraft.h delete mode 100644 src/FDM/JSBSim/FGAtmosphere.cpp delete mode 100644 src/FDM/JSBSim/FGAtmosphere.h delete mode 100644 src/FDM/JSBSim/FGAuxiliary.cpp delete mode 100644 src/FDM/JSBSim/FGAuxiliary.h delete mode 100644 src/FDM/JSBSim/FGCoefficient.cpp delete mode 100644 src/FDM/JSBSim/FGCoefficient.h delete mode 100644 src/FDM/JSBSim/FGColumnVector3.cpp delete mode 100644 src/FDM/JSBSim/FGColumnVector3.h delete mode 100644 src/FDM/JSBSim/FGConfigFile.cpp delete mode 100644 src/FDM/JSBSim/FGConfigFile.h delete mode 100644 src/FDM/JSBSim/FGElectric.cpp delete mode 100644 src/FDM/JSBSim/FGElectric.h delete mode 100644 src/FDM/JSBSim/FGEngine.cpp delete mode 100644 src/FDM/JSBSim/FGEngine.h delete mode 100644 src/FDM/JSBSim/FGFCS.cpp delete mode 100644 src/FDM/JSBSim/FGFCS.h delete mode 100644 src/FDM/JSBSim/FGFactorGroup.cpp delete mode 100644 src/FDM/JSBSim/FGFactorGroup.h delete mode 100644 src/FDM/JSBSim/FGForce.cpp delete mode 100644 src/FDM/JSBSim/FGForce.h delete mode 100644 src/FDM/JSBSim/FGGroundCallback.cpp delete mode 100644 src/FDM/JSBSim/FGGroundCallback.h delete mode 100644 src/FDM/JSBSim/FGGroundReactions.cpp delete mode 100644 src/FDM/JSBSim/FGGroundReactions.h delete mode 100644 src/FDM/JSBSim/FGInertial.cpp delete mode 100644 src/FDM/JSBSim/FGInertial.h delete mode 100644 src/FDM/JSBSim/FGInitialCondition.cpp delete mode 100644 src/FDM/JSBSim/FGInitialCondition.h delete mode 100644 src/FDM/JSBSim/FGLGear.cpp delete mode 100644 src/FDM/JSBSim/FGLGear.h delete mode 100644 src/FDM/JSBSim/FGLocation.cpp diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp deleted file mode 100644 index 209d864ce..000000000 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Module: FGAerodynamics.cpp - Author: Jon S. Berndt - Date started: 09/13/00 - Purpose: Encapsulates the aerodynamic forces (gear and collision) - - ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- - -HISTORY --------------------------------------------------------------------------------- -09/13/00 JSB Created -04/22/01 JSB Moved code into here from FGAircraft - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FGAerodynamics.h" -#include "FGPropagate.h" -#include "FGAircraft.h" -#include "FGState.h" -#include "FGMassBalance.h" -#include "FGFactorGroup.h" -#include "FGPropertyManager.h" - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_AERODYNAMICS; - -const unsigned NAxes=6; -const char* AxisNames[] = { "drag", "side", "lift", "roll", - "pitch","yaw" }; -const char* AxisNamesUpper[] = { "DRAG", "SIDE", "LIFT", "ROLL", - "PITCH","YAW" }; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - - -FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec) -{ - Name = "FGAerodynamics"; - - AxisIdx["DRAG"] = 0; - AxisIdx["SIDE"] = 1; - AxisIdx["LIFT"] = 2; - AxisIdx["ROLL"] = 3; - AxisIdx["PITCH"] = 4; - AxisIdx["YAW"] = 5; - - Coeff = new CoeffArray[6]; - - impending_stall = stall_hyst = 0.0; - alphaclmin = alphaclmax = 0.0; - alphahystmin = alphahystmax = 0.0; - clsq = lod = 0.0; - alphaw = 0.0; - bi2vel = ci2vel = 0.0; - bind(); - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGAerodynamics::~FGAerodynamics() -{ - unsigned int i,j; - - unbind(); - - for (i=0; i<6; i++) { - for (j=0; jGetVt(); - if (twovel != 0) { - bi2vel = Aircraft->GetWingSpan() / twovel; - ci2vel = Aircraft->Getcbar() / twovel; - } - - alphaw = Auxiliary->Getalpha() + Aircraft->GetWingIncidence(); - - alpha = Auxiliary->Getalpha(); - - if (alphaclmax != 0) { - if (alpha > 0.85*alphaclmax) { - impending_stall = 10*(alpha/alphaclmax - 0.85); - } else { - impending_stall = 0; - } - } - - if (alphahystmax != 0.0 && alphahystmin != 0.0) { - if (alpha > alphahystmax) { - stall_hyst = 1; - } else if (alpha < alphahystmin) { - stall_hyst = 0; - } - } - - vLastFs = vFs; - vFs.InitMatrix(); - - for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { - for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) { - vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue(); - } - } - - //correct signs of drag and lift to wind axes convention - //positive forward, right, down - if ( Auxiliary->Getqbar() > 0) { - clsq = vFs(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar()); - clsq *= clsq; - } - if ( vFs(eDrag) > 0) { - lod = vFs(eLift) / vFs(eDrag); - } - - //correct signs of drag and lift to wind axes convention - //positive forward, right, down - vFs(eDrag)*=-1; vFs(eLift)*=-1; - - vForces = State->GetTs2b()*vFs; - - vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp()); - - vMoments = vDXYZcg*vForces; // M = r X F - - for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { - for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) { - vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue(); - } - } - - return false; - } else { - return true; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAerodynamics::Load(FGConfigFile* AC_cfg) -{ - string parameter, axis, scratch; - - AC_cfg->GetNextConfigLine(); - - while ((parameter = AC_cfg->GetValue()) != string("/AERODYNAMICS")) { - if (parameter == "AXIS") { - CoeffArray ca; - axis = AC_cfg->GetValue("NAME"); - AC_cfg->GetNextConfigLine(); - while ((parameter = AC_cfg->GetValue()) != string("/AXIS")) { - if ( parameter == "COEFFICIENT" ) { - ca.push_back( new FGCoefficient(FDMExec) ); - ca.back()->Load(AC_cfg); - } else if ( parameter == "GROUP" ) { - ca.push_back( new FGFactorGroup(FDMExec) ); - ca.back()->Load(AC_cfg); - } - } - Coeff[AxisIdx[axis]] = ca; - AC_cfg->GetNextConfigLine(); - } else if (parameter == "AC_ALPHALIMITS") { - *AC_cfg >> scratch >> alphaclmin >> alphaclmax; - if (debug_lvl > 0) cout << " Maximum Alpha: " << alphaclmax - << " Minimum Alpha: " << alphaclmin - << endl; - } else if (parameter == "AC_HYSTLIMITS") { - *AC_cfg >> scratch >> alphahystmin >> alphahystmax; - if (debug_lvl > 0) cout << " Hysteresis Start: " << alphahystmax - << " Hysteresis End: " << alphahystmin - << endl; - } - } - - bindModel(); - - return true; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -string FGAerodynamics::GetCoefficientStrings(string delimeter) -{ - string CoeffStrings = ""; - bool firstime = true; - unsigned int axis, sd; - - for (axis = 0; axis < 6; axis++) { - for (sd = 0; sd < Coeff[axis].size(); sd++) { - if (firstime) { - firstime = false; - } else { - CoeffStrings += delimeter; - } - CoeffStrings += Coeff[axis][sd]->GetCoefficientName(); - } - } - return CoeffStrings; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -string FGAerodynamics::GetCoefficientValues(string delimeter) -{ - string SDValues = ""; - bool firstime = true; - - for (unsigned int axis = 0; axis < 6; axis++) { - for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) { - if (firstime) { - firstime = false; - } else { - SDValues += delimeter; - } - SDValues += Coeff[axis][sd]->GetSDstring(); - } - } - - return SDValues; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAerodynamics::bind(void) -{ - typedef double (FGAerodynamics::*PMF)(int) const; - - PropertyManager->Tie("forces/fbx-aero-lbs", this,1, - (PMF)&FGAerodynamics::GetForces); - PropertyManager->Tie("forces/fby-aero-lbs", this,2, - (PMF)&FGAerodynamics::GetForces); - PropertyManager->Tie("forces/fbz-aero-lbs", this,3, - (PMF)&FGAerodynamics::GetForces); - PropertyManager->Tie("moments/l-aero-lbsft", this,1, - (PMF)&FGAerodynamics::GetMoments); - PropertyManager->Tie("moments/m-aero-lbsft", this,2, - (PMF)&FGAerodynamics::GetMoments); - PropertyManager->Tie("moments/n-aero-lbsft", this,3, - (PMF)&FGAerodynamics::GetMoments); - PropertyManager->Tie("forces/fwx-aero-lbs", this,1, - (PMF)&FGAerodynamics::GetvFs); - PropertyManager->Tie("forces/fwy-aero-lbs", this,2, - (PMF)&FGAerodynamics::GetvFs); - PropertyManager->Tie("forces/fwz-aero-lbs", this,3, - (PMF)&FGAerodynamics::GetvFs); - PropertyManager->Tie("forces/lod-norm", this, - &FGAerodynamics::GetLoD); - PropertyManager->Tie("aero/cl-squared-norm", this, - &FGAerodynamics::GetClSquared); - PropertyManager->Tie("aero/alpha-max-deg", this, - &FGAerodynamics::GetAlphaCLMax, - &FGAerodynamics::SetAlphaCLMax, - true); - PropertyManager->Tie("aero/alpha-min-deg", this, - &FGAerodynamics::GetAlphaCLMin, - &FGAerodynamics::SetAlphaCLMin, - true); - PropertyManager->Tie("aero/bi2vel", this, - &FGAerodynamics::GetBI2Vel); - PropertyManager->Tie("aero/ci2vel", this, - &FGAerodynamics::GetCI2Vel); - PropertyManager->Tie("aero/alpha-wing-rad", this, - &FGAerodynamics::GetAlphaW); - PropertyManager->Tie("systems/stall-warn-norm", this, - &FGAerodynamics::GetStallWarn); - PropertyManager->Tie("aero/stall-hyst-norm", this, - &FGAerodynamics::GetHysteresisParm); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAerodynamics::bindModel(void) -{ - unsigned i,j; - FGPropertyManager* node; - string axis_node_name; - node = PropertyManager->GetNode("aero/buildup",true); - for (i=0;iGetNode( string(AxisNames[i]),true ); - for (j=0; j < Coeff[i].size(); j++) { - Coeff[i][j]->bind(node); - } - node = (FGPropertyManager*)node->getParent(); - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAerodynamics::unbind(void) -{ - unsigned i,j; - - PropertyManager->Untie("forces/fbx-aero-lbs"); - PropertyManager->Untie("forces/fby-aero-lbs"); - PropertyManager->Untie("forces/fbz-aero-lbs"); - PropertyManager->Untie("moments/l-aero-lbsft"); - PropertyManager->Untie("moments/m-aero-lbsft"); - PropertyManager->Untie("moments/n-aero-lbsft"); - PropertyManager->Untie("forces/fwx-aero-lbs"); - PropertyManager->Untie("forces/fwy-aero-lbs"); - PropertyManager->Untie("forces/fwz-aero-lbs"); - PropertyManager->Untie("forces/lod-norm"); - PropertyManager->Untie("aero/cl-squared-norm"); - PropertyManager->Untie("aero/alpha-max-deg"); - PropertyManager->Untie("aero/alpha-min-deg"); - PropertyManager->Untie("aero/bi2vel"); - PropertyManager->Untie("aero/ci2vel"); - PropertyManager->Untie("aero/alpha-wing-rad"); - PropertyManager->Untie("aero/stall-hyst-norm"); - PropertyManager->Untie("systems/stall-warn-norm"); - - for ( i=0; iunbind(); - - } - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAerodynamics::convert(void) -{ - - for (int axis=0; axis<6; axis++) { - if (Coeff[axis].size()>0) { - cout << endl << " " << endl; - for (int c=0; cconvert(); - } - cout << " " << endl; - } - } - -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGAerodynamics::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - if (from == 0) { // Constructor - - } - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAerodynamics" << endl; - if (from == 1) cout << "Destroyed: FGAerodynamics" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h deleted file mode 100644 index e6d8ac2fe..000000000 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ /dev/null @@ -1,199 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGAerodynamics.h - Author: Jon S. Berndt - Date started: 09/13/00 - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -09/13/00 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGAERODYNAMICS_H -#define FGAERODYNAMICS_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef FGFS -# include -# ifdef SG_HAVE_STD_INCLUDES -# include -# include -# else -# include -# include -# endif -#else -# include -# include -#endif - -#include "FGModel.h" -#include "FGConfigFile.h" -#include "FGCoefficient.h" -#include "FGColumnVector3.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_AERODYNAMICS "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** Encapsulates the aerodynamic calculations. - This class owns and contains the list of coefficients that define the - aerodynamic properties of this aircraft. Here also, such unique phenomena - as ground effect and maximum lift curve tailoff are handled. - @config -
-    \
-       \
-         {Coefficient definitions}
-       \
-       {Additional axis definitions}
-    \ 
- - @author Jon S. Berndt, Tony Peden - $Id$ -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGAerodynamics : public FGModel { - -public: - /** Constructor - @param Executive a pointer to the parent executive object */ - FGAerodynamics(FGFDMExec* Executive); - /// Destructor - ~FGAerodynamics(); - - /** Runs the Aerodynamics model; called by the Executive - @return false if no error */ - bool Run(void); - - /** Loads the Aerodynamics model. - The Load function for this class expects the configuration file to - have found the AERODYNAMICS keyword in the configution file and to - have set that line to the current line. - @param AC_cfg pointer to the current configuration file. - @return true if successful */ - bool Load(FGConfigFile* AC_cfg); - - /** Gets the total aerodynamic force vector. - @return a force vector reference. */ - FGColumnVector3& GetForces(void) {return vForces;} - - /** Gets the aerodynamic force for an axis. - @param n Axis index. This could be 0, 1, or 2, or one of the - axis enums: eX, eY, eZ. - @return the force acting on an axis */ - double GetForces(int n) const {return vForces(n);} - - /** Gets the total aerodynamic moment vector. - @return a moment vector reference. */ - FGColumnVector3& GetMoments(void) {return vMoments;} - - /** Gets the aerodynamic moment for an axis. - @return the moment about a single axis (as described also in the - similar call to GetForces(int n).*/ - double GetMoments(int n) const {return vMoments(n);} - - FGColumnVector3& GetvLastFs(void) { return vLastFs; } - double GetvLastFs(int axis) const { return vLastFs(axis); } - FGColumnVector3& GetvFs(void) { return vFs; } - double GetvFs(int axis) const { return vFs(axis); } - inline double GetLoD(void) const { return lod; } - inline double GetClSquared(void) const { return clsq; } - inline double GetAlphaCLMax(void) const { return alphaclmax; } - inline double GetAlphaCLMin(void) const { return alphaclmin; } - - inline double GetAlphaHystMax(void) const { return alphahystmax; } - inline double GetAlphaHystMin(void) const { return alphahystmin; } - inline double GetHysteresisParm(void) const { return stall_hyst; } - inline double GetStallWarn(void) const { return impending_stall; } - double GetAlphaW(void) const { return alphaw; } - - double GetBI2Vel(void) const { return bi2vel; } - double GetCI2Vel(void) const { return ci2vel; } - - inline void SetAlphaCLMax(double tt) { alphaclmax=tt; } - inline void SetAlphaCLMin(double tt) { alphaclmin=tt; } - - /** Gets the strings for the current set of coefficients. - @param delimeter either a tab or comma string depending on output type - @return a string containing the descriptive names for all coefficients */ - string GetCoefficientStrings(string delimeter); - - /** Gets the coefficient values. - @param delimeter either a tab or comma string depending on output type - @return a string containing the numeric values for the current set of - coefficients */ - string GetCoefficientValues(string delimeter); - - void bind(void); - void bindModel(void); - void unbind(void); - void convert(void); - -private: - typedef map AxisIndex; - AxisIndex AxisIdx; - typedef vector CoeffArray; - CoeffArray* Coeff; - FGColumnVector3 vFs; - FGColumnVector3 vForces; - FGColumnVector3 vMoments; - FGColumnVector3 vLastFs; - FGColumnVector3 vDXYZcg; - double alphaclmax, alphaclmin; - double alphahystmax, alphahystmin; - double impending_stall, stall_hyst; - double bi2vel, ci2vel,alphaw; - double clsq,lod; - - typedef double (FGAerodynamics::*PMF)(int) const; - - void Debug(int from); -}; - -} // namespace JSBSim - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif - diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp deleted file mode 100644 index 23caea68f..000000000 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Module: FGAircraft.cpp - Author: Jon S. Berndt - Date started: 12/12/98 - Purpose: Encapsulates an aircraft - Called by: FGFDMExec - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- -Models the aircraft reactions and forces. This class is instantiated by the -FGFDMExec class and scheduled as an FDM entry. - -HISTORY --------------------------------------------------------------------------------- -12/12/98 JSB Created -04/03/99 JSB Changed Aero() method to correct body axis force calculation - from wind vector. Fix provided by Tony Peden. -05/03/99 JSB Changed (for the better?) the way configurations are read in. -9/17/99 TP Combined force and moment functions. Added aero reference - point to config file. Added calculations for moments due to - difference in cg and aero reference point - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#ifdef FGFS -# ifndef __BORLANDC__ -# include -# endif -# ifdef SG_HAVE_STD_INCLUDES -# include -# else -# include -# endif -#else -# if defined (sgi) && !defined(__GNUC__) -# include -# else -# include -# endif -#endif - -#include "FGAircraft.h" -#include "FGMassBalance.h" -#include "FGInertial.h" -#include "FGGroundReactions.h" -#include "FGAerodynamics.h" -#include "FGState.h" -#include "FGFDMExec.h" -#include "FGPropagate.h" -#include "FGPropertyManager.h" - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -GLOBAL DATA -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_AIRCRAFT; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex) -{ - Name = "FGAircraft"; - WingSpan = 0.0; - HTailArea = VTailArea = 0.0; - HTailArm = VTailArm = 0.0; - lbarh = lbarv = 0.0; - vbarh = vbarv = 0.0; - WingIncidence = 0.0; - - bind(); - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGAircraft::~FGAircraft() -{ - unbind(); - Debug(1); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAircraft::Run(void) -{ - if (!FGModel::Run()) { // if false then execute this Run() - vForces.InitMatrix(); - vForces += Aerodynamics->GetForces(); - vForces += Propulsion->GetForces(); - vForces += GroundReactions->GetForces(); - - vMoments.InitMatrix(); - vMoments += Aerodynamics->GetMoments(); - vMoments += Propulsion->GetMoments(); - vMoments += GroundReactions->GetMoments(); - - vBodyAccel = vForces/MassBalance->GetMass(); - - vNcg = vBodyAccel/Inertial->gravity(); - - vNwcg = State->GetTb2s() * vNcg; - vNwcg(3) = -1*vNwcg(3) + 1; - - return false; - } else { // skip Run() execution this time - return true; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGAircraft::GetNlf(void) -{ - return -1*Aerodynamics->GetvFs(3)/MassBalance->GetWeight(); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAircraft::Load(FGConfigFile* AC_cfg) -{ - string token = ""; - string parameter; - double EW, bixx, biyy, bizz, bixy, bixz, biyz; - double pmWt, pmX, pmY, pmZ; - FGColumnVector3 vbaseXYZcg; - - bixx = biyy = bizz = bixy = bixz = biyz = 0.0; - - AC_cfg->GetNextConfigLine(); - - while ((token = AC_cfg->GetValue()) != string("/METRICS")) { - *AC_cfg >> parameter; - if (parameter == "AC_WINGAREA") { - *AC_cfg >> WingArea; - if (debug_lvl > 0) cout << " WingArea: " << WingArea << endl; - } else if (parameter == "AC_WINGSPAN") { - *AC_cfg >> WingSpan; - if (debug_lvl > 0) cout << " WingSpan: " << WingSpan << endl; - } else if (parameter == "AC_WINGINCIDENCE") { - *AC_cfg >> WingIncidence; - if (debug_lvl > 0) cout << " Incidence: " << WingIncidence << endl; - } else if (parameter == "AC_CHORD") { - *AC_cfg >> cbar; - if (debug_lvl > 0) cout << " Chord: " << cbar << endl; - } else if (parameter == "AC_HTAILAREA") { - *AC_cfg >> HTailArea; - if (debug_lvl > 0) cout << " H. Tail Area: " << HTailArea << endl; - } else if (parameter == "AC_HTAILARM") { - *AC_cfg >> HTailArm; - if (debug_lvl > 0) cout << " H. Tail Arm: " << HTailArm << endl; - } else if (parameter == "AC_VTAILAREA") { - *AC_cfg >> VTailArea; - if (debug_lvl > 0) cout << " V. Tail Area: " << VTailArea << endl; - } else if (parameter == "AC_VTAILARM") { - *AC_cfg >> VTailArm; - if (debug_lvl > 0) cout << " V. Tail Arm: " << VTailArm << endl; - } else if (parameter == "AC_IXX") { - *AC_cfg >> bixx; - if (debug_lvl > 0) cout << " baseIxx: " << bixx << " slug-ft2" << endl; - } else if (parameter == "AC_IYY") { - *AC_cfg >> biyy; - if (debug_lvl > 0) cout << " baseIyy: " << biyy << " slug-ft2" << endl; - } else if (parameter == "AC_IZZ") { - *AC_cfg >> bizz; - if (debug_lvl > 0) cout << " baseIzz: " << bizz << " slug-ft2" << endl; - } else if (parameter == "AC_IXY") { - *AC_cfg >> bixy; - if (debug_lvl > 0) cout << " baseIxy: " << bixy << " slug-ft2" << endl; - } else if (parameter == "AC_IXZ") { - *AC_cfg >> bixz; - if (debug_lvl > 0) cout << " baseIxz: " << bixz << " slug-ft2" << endl; - } else if (parameter == "AC_IYZ") { - *AC_cfg >> biyz; - if (debug_lvl > 0) cout << " baseIyz: " << biyz << " slug-ft2" << endl; - } else if (parameter == "AC_EMPTYWT") { - *AC_cfg >> EW; - MassBalance->SetEmptyWeight(EW); - if (debug_lvl > 0) cout << " EmptyWeight: " << EW << " lbm" << endl; - } else if (parameter == "AC_CGLOC") { - *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ); - MassBalance->SetBaseCG(vbaseXYZcg); - if (debug_lvl > 0) cout << " CG (x, y, z): " << vbaseXYZcg << endl; - } else if (parameter == "AC_EYEPTLOC") { - *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ); - if (debug_lvl > 0) cout << " Eyepoint (x, y, z): " << vXYZep << endl; - } else if (parameter == "AC_AERORP") { - *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ); - if (debug_lvl > 0) cout << " Ref Pt (x, y, z): " << vXYZrp << endl; - } else if (parameter == "AC_VRP") { - *AC_cfg >> vXYZvrp(eX) >> vXYZvrp(eY) >> vXYZvrp(eZ); - if (debug_lvl > 0) cout << " Visual Ref Pt (x, y, z): " << vXYZvrp << endl; - } else if (parameter == "AC_POINTMASS") { - *AC_cfg >> pmWt >> pmX >> pmY >> pmZ; - MassBalance->AddPointMass(pmWt, pmX, pmY, pmZ); - if (debug_lvl > 0) cout << " Point Mass Object: " << pmWt << " lbs. at " - << "X, Y, Z (in.): " << pmX << " " << pmY << " " << pmZ - << endl; - } - } - - MassBalance->SetAircraftBaseInertias(FGMatrix33( bixx, -bixy, -bixz, - -bixy, biyy, -biyz, - -bixz, -biyz, bizz )); - - // calculate some derived parameters - if (cbar != 0.0) { - lbarh = HTailArm/cbar; - lbarv = VTailArm/cbar; - if (WingArea != 0.0) { - vbarh = HTailArm*HTailArea / (cbar*WingArea); - vbarv = VTailArm*VTailArea / (cbar*WingArea); - } - } - return true; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAircraft::bind(void) -{ - typedef double (FGAircraft::*PMF)(int) const; - PropertyManager->Tie("metrics/Sw-sqft", this, - &FGAircraft::GetWingArea); - PropertyManager->Tie("metrics/bw-ft", this, - &FGAircraft::GetWingSpan); - PropertyManager->Tie("metrics/cbarw-ft", this, - &FGAircraft::Getcbar); - PropertyManager->Tie("metrics/iw-deg", this, - &FGAircraft::GetWingIncidence); - PropertyManager->Tie("metrics/Sh-sqft", this, - &FGAircraft::GetHTailArea); - PropertyManager->Tie("metrics/lh-ft", this, - &FGAircraft::GetHTailArm); - PropertyManager->Tie("metrics/Sv-sqft", this, - &FGAircraft::GetVTailArea); - PropertyManager->Tie("metrics/lv-ft", this, - &FGAircraft::GetVTailArm); - PropertyManager->Tie("metrics/lh-norm", this, - &FGAircraft::Getlbarh); - PropertyManager->Tie("metrics/lv-norm", this, - &FGAircraft::Getlbarv); - PropertyManager->Tie("metrics/vbarh-norm", this, - &FGAircraft::Getvbarh); - PropertyManager->Tie("metrics/vbarv-norm", this, - &FGAircraft::Getvbarv); - PropertyManager->Tie("moments/l-total-lbsft", this,1, - (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("moments/m-total-lbsft", this,2, - (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("moments/n-total-lbsft", this,3, - (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("forces/fbx-total-lbs", this,1, - (PMF)&FGAircraft::GetForces); - PropertyManager->Tie("forces/fby-total-lbs", this,2, - (PMF)&FGAircraft::GetForces); - PropertyManager->Tie("forces/fbz-total-lbs", this,3, - (PMF)&FGAircraft::GetForces); - PropertyManager->Tie("metrics/aero-rp-x-in", this,1, - (PMF)&FGAircraft::GetXYZrp); - PropertyManager->Tie("metrics/aero-rp-y-in", this,2, - (PMF)&FGAircraft::GetXYZrp); - PropertyManager->Tie("metrics/aero-rp-z-in", this,3, - (PMF)&FGAircraft::GetXYZrp); - PropertyManager->Tie("metrics/eyepoint-x-in", this,1, - (PMF)&FGAircraft::GetXYZep); - PropertyManager->Tie("metrics/eyepoint-y-in", this,2, - (PMF)&FGAircraft::GetXYZep); - PropertyManager->Tie("metrics/eyepoint-z-in", this,3, - (PMF)&FGAircraft::GetXYZep); - PropertyManager->Tie("metrics/visualrefpoint-x-in", this,1, - (PMF)&FGAircraft::GetXYZvrp); - PropertyManager->Tie("metrics/visualrefpoint-y-in", this,2, - (PMF)&FGAircraft::GetXYZvrp); - PropertyManager->Tie("metrics/visualrefpoint-z-in", this,3, - (PMF)&FGAircraft::GetXYZvrp); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAircraft::unbind(void) -{ - PropertyManager->Untie("metrics/Sw-sqft"); - PropertyManager->Untie("metrics/bw-ft"); - PropertyManager->Untie("metrics/cbarw-ft"); - PropertyManager->Untie("metrics/iw-deg"); - PropertyManager->Untie("metrics/Sh-sqft"); - PropertyManager->Untie("metrics/lh-ft"); - PropertyManager->Untie("metrics/Sv-sqft"); - PropertyManager->Untie("metrics/lv-ft"); - PropertyManager->Untie("metrics/lh-norm"); - PropertyManager->Untie("metrics/lv-norm"); - PropertyManager->Untie("metrics/vbarh-norm"); - PropertyManager->Untie("metrics/vbarv-norm"); - PropertyManager->Untie("moments/l-total-lbsft"); - PropertyManager->Untie("moments/m-total-lbsft"); - PropertyManager->Untie("moments/n-total-lbsft"); - PropertyManager->Untie("forces/fbx-total-lbs"); - PropertyManager->Untie("forces/fby-total-lbs"); - PropertyManager->Untie("forces/fbz-total-lbs"); - PropertyManager->Untie("metrics/aero-rp-x-in"); - PropertyManager->Untie("metrics/aero-rp-y-in"); - PropertyManager->Untie("metrics/aero-rp-z-in"); - PropertyManager->Untie("metrics/eyepoint-x-in"); - PropertyManager->Untie("metrics/eyepoint-y-in"); - PropertyManager->Untie("metrics/eyepoint-z-in"); - PropertyManager->Untie("metrics/visualrefpoint-x-in"); - PropertyManager->Untie("metrics/visualrefpoint-y-in"); - PropertyManager->Untie("metrics/visualrefpoint-z-in"); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGAircraft::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - if (from == 0) { // Constructor - } - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAircraft" << endl; - if (from == 1) cout << "Destroyed: FGAircraft" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h deleted file mode 100644 index 78ea4c44c..000000000 --- a/src/FDM/JSBSim/FGAircraft.h +++ /dev/null @@ -1,184 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGAircraft.h - Author: Jon S. Berndt - Date started: 12/12/98 - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -12/12/98 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGAIRCRAFT_H -#define FGAIRCRAFT_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef FGFS -# include -# ifdef SG_HAVE_STD_INCLUDES -# include -# include -# else -# include -# include -# endif -#else -# include -# include -#endif - -#include "FGModel.h" -#include "FGConfigFile.h" -#include "FGColumnVector3.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_AIRCRAFT "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** Encapsulates an Aircraft and its systems. - Owns all the parts (other classes) which make up this aircraft. This includes - the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties, - landing gear, etc. These constituent parts may actually run as separate - JSBSim models themselves, but the responsibility for initializing them and - for retrieving their force and moment contributions falls to FGAircraft. - @author Jon S. Berndt - @version $Id$ - @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling - Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate - School, January 1994 - @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices", - JSC 12960, July 1977 - @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at - NASA-Ames", NASA CR-2497, January 1975 - @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", - Wiley & Sons, 1979 ISBN 0-471-03032-5 - @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons, - 1982 ISBN 0-471-08936-2 -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGAircraft : public FGModel { -public: - /** Constructor - @param Executive a pointer to the parent executive object */ - FGAircraft(FGFDMExec *Executive); - - /// Destructor - ~FGAircraft(); - - /** Runs the Aircraft model; called by the Executive - @see JSBSim.cpp documentation - @return false if no error */ - bool Run(void); - - /** Loads the aircraft. - The executive calls this method to load the aircraft into JSBSim. - @param AC_cfg a pointer to the config file instance - @return true if successful */ - bool Load(FGConfigFile* AC_cfg); - - /** Gets the aircraft name - @return the name of the aircraft as a string type */ - inline string GetAircraftName(void) { return AircraftName; } - - /// Gets the wing area - double GetWingArea(void) const { return WingArea; } - /// Gets the wing span - double GetWingSpan(void) const { return WingSpan; } - /// Gets the average wing chord - double Getcbar(void) const { return cbar; } - inline double GetWingIncidence(void) const { return WingIncidence; } - inline double GetHTailArea(void) const { return HTailArea; } - inline double GetHTailArm(void) const { return HTailArm; } - inline double GetVTailArea(void) const { return VTailArea; } - inline double GetVTailArm(void) const { return VTailArm; } - inline double Getlbarh(void) const { return lbarh; } // HTailArm / cbar - inline double Getlbarv(void) const { return lbarv; } // VTailArm / cbar - inline double Getvbarh(void) const { return vbarh; } // H. Tail Volume - inline double Getvbarv(void) const { return vbarv; } // V. Tail Volume - inline FGColumnVector3& GetMoments(void) { return vMoments; } - inline double GetMoments(int idx) const { return vMoments(idx); } - inline FGColumnVector3& GetForces(void) { return vForces; } - inline double GetForces(int idx) const { return vForces(idx); } - inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; } - inline double GetBodyAccel(int idx) { return vBodyAccel(idx); } - inline FGColumnVector3& GetNcg (void) { return vNcg; } - inline double GetNcg(int idx) { return vNcg(idx); } - inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; } - inline FGColumnVector3& GetXYZvrp(void) { return vXYZvrp; } - inline FGColumnVector3& GetXYZep(void) { return vXYZep; } - inline double GetXYZrp(int idx) const { return vXYZrp(idx); } - inline double GetXYZvrp(int idx) const { return vXYZvrp(idx); } - inline double GetXYZep(int idx) const { return vXYZep(idx); } - inline void SetAircraftName(string name) {AircraftName = name;} - - double GetNlf(void); - - inline FGColumnVector3& GetNwcg(void) { return vNwcg; } - - void bind(void); - void unbind(void); - -private: - FGColumnVector3 vMoments; - FGColumnVector3 vForces; - FGColumnVector3 vXYZrp; - FGColumnVector3 vXYZvrp; - FGColumnVector3 vXYZep; - FGColumnVector3 vDXYZcg; - FGColumnVector3 vBodyAccel; - FGColumnVector3 vNcg; - FGColumnVector3 vNwcg; - - double WingArea, WingSpan, cbar, WingIncidence; - double HTailArea, VTailArea, HTailArm, VTailArm; - double lbarh,lbarv,vbarh,vbarv; - string AircraftName; - - void Debug(int from); -}; - -} // namespace JSBSim -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif - diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp deleted file mode 100644 index d779258a5..000000000 --- a/src/FDM/JSBSim/FGAtmosphere.cpp +++ /dev/null @@ -1,541 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Module: FGAtmosphere.cpp - Author: Jon Berndt - Implementation of 1959 Standard Atmosphere added by Tony Peden - Date started: 11/24/98 - Purpose: Models the atmosphere - Called by: FGSimExec - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- -Models the atmosphere. The equation used below was determined by a third order -curve fit using Excel. The data is from the ICAO atmosphere model. - -HISTORY --------------------------------------------------------------------------------- -11/24/98 JSB Created -07/23/99 TP Added implementation of 1959 Standard Atmosphere - Moved calculation of Mach number to FGPropagate - Later updated to '76 model -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -[1] Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill, - 1989, ISBN 0-07-001641-0 - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include "FGAtmosphere.h" -#include "FGState.h" -#include "FGFDMExec.h" -#include "FGAircraft.h" -#include "FGPropagate.h" -#include "FGInertial.h" -#include "FGPropertyManager.h" - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_ATMOSPHERE; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - - -FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) -{ - Name = "FGAtmosphere"; - lastIndex = 0; - h = 0.0; - psiw = 0.0; - htab[0]=0; - htab[1]=36089.239; - htab[2]=65616.798; - htab[3]=104986.878; - htab[4]=154199.475; - htab[5]=170603.675; - htab[6]=200131.234; - htab[7]=259186.352; //ft. - - MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0; -// turbType = ttNone; - turbType = ttStandard; -// turbType = ttBerndt; - TurbGain = 0.0; - TurbRate = 1.0; - - T_dev_sl = T_dev = delta_T = 0.0; - - bind(); - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGAtmosphere::~FGAtmosphere() -{ - unbind(); - Debug(1); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAtmosphere::InitModel(void) -{ - FGModel::InitModel(); - - Calculate(h); - SLtemperature = intTemperature; - SLpressure = intPressure; - SLdensity = intDensity; - SLsoundspeed = sqrt(SHRatio*Reng*intTemperature); - rSLtemperature = 1.0/intTemperature; - rSLpressure = 1.0/intPressure; - rSLdensity = 1.0/intDensity; - rSLsoundspeed = 1.0/SLsoundspeed; - temperature=&intTemperature; - pressure=&intPressure; - density=&intDensity; - - useExternal=false; - - return true; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAtmosphere::Run(void) -{ - if (!FGModel::Run()) { // if false then execute this Run() - //do temp, pressure, and density first - if (!useExternal) { - h = Propagate->Geth(); - Calculate(h); - } - - if (turbType != ttNone) { - Turbulence(); - vWindNED += vTurbulence; - } - - if (vWindNED(1) != 0.0) psiw = atan2( vWindNED(2), vWindNED(1) ); - - if (psiw < 0) psiw += 2*M_PI; - - soundspeed = sqrt(SHRatio*Reng*(*temperature)); - - Debug(2); - - return false; - } else { // skip Run() execution this time - return true; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// -// See reference 1 - -void FGAtmosphere::Calculate(double altitude) -{ - double slope, reftemp, refpress; - int i = 0; - - i = lastIndex; - if (altitude < htab[lastIndex]) { - if (altitude <= 0) { - i = 0; - altitude=0; - } else { - i = lastIndex-1; - while (htab[i] > altitude) i--; - } - } else if (altitude > htab[lastIndex+1]) { - if (altitude >= htab[7]) { - i = 7; - altitude = htab[7]; - } else { - i = lastIndex+1; - while (htab[i+1] < altitude) i++; - } - } - - switch(i) { - case 1: // 36089 ft. - slope = 0; - reftemp = 389.97; - refpress = 472.452; - //refdens = 0.000706032; - break; - case 2: // 65616 ft. - slope = 0.00054864; - reftemp = 389.97; - refpress = 114.636; - //refdens = 0.000171306; - break; - case 3: // 104986 ft. - slope = 0.00153619; - reftemp = 411.57; - refpress = 8.36364; - //refdens = 1.18422e-05; - break; - case 4: // 154199 ft. - slope = 0; - reftemp = 487.17; - refpress = 0.334882; - //refdens = 4.00585e-7; - break; - case 5: // 170603 ft. - slope = -0.00109728; - reftemp = 487.17; - refpress = 0.683084; - //refdens = 8.17102e-7; - break; - case 6: // 200131 ft. - slope = -0.00219456; - reftemp = 454.17; - refpress = 0.00684986; - //refdens = 8.77702e-9; - break; - case 7: // 259186 ft. - slope = 0; - reftemp = 325.17; - refpress = 0.000122276; - //refdens = 2.19541e-10; - break; - case 0: - default: // sea level - slope = -0.00356616; // R/ft. - reftemp = 518.67; // R - refpress = 2116.22; // psf - //refdens = 0.00237767; // slugs/cubic ft. - break; - - } - - T_dev = 0.0; - if (delta_T != 0.0) { - T_dev = delta_T; - } else { - if ((h < 36089.239) && (T_dev_sl != 0.0)) { - T_dev = T_dev_sl * ( 1.0 - (h/36089.239)); - } - } - density_altitude = h + T_dev * 66.7; - - reftemp+=T_dev; - if (slope == 0) { - intTemperature = reftemp; - intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i])); - //intDensity = refdens*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i])); - intDensity = intPressure/(Reng*intTemperature); - } else { - intTemperature = reftemp+slope*(altitude-htab[i]); - intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng)); - //intDensity = refdens*pow(intTemperature/reftemp,-(Inertial->SLgravity()/(slope*Reng)+1)); - intDensity = intPressure/(Reng*intTemperature); - } - lastIndex=i; - //cout << "Atmosphere: h=" << altitude << " rho= " << intDensity << endl; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// Return the pressure at an arbitrary altitude and then restore the internal state - -double FGAtmosphere::GetPressure(double alt) { - Calculate(alt); - double p = *pressure; - // Reset the internal atmospheric state - Run(); - return(p); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// square a value, but preserve the original sign - -static inline double square_signed (double value) -{ - if (value < 0) - return value * value * -1; - else - return value * value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::Turbulence(void) -{ - switch (turbType) { - case ttStandard: { - vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - - MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude; - // Scale the magnitude so that it moves - // away from the peaks - MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) / - (1 + fabs(Magnitude))); - MagnitudeAccel += MagnitudedAccelDt*rate*TurbRate*State->Getdt(); - Magnitude += MagnitudeAccel*rate*State->Getdt(); - - vDirectiondAccelDt.Normalize(); - - // deemphasise non-vertical forces - vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX)); - vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY)); - - vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt(); - vDirectionAccel.Normalize(); - vDirection += vDirectionAccel*rate*State->Getdt(); - - vDirection.Normalize(); - - // Diminish turbulence within three wingspans - // of the ground - vTurbulence = TurbGain * Magnitude * vDirection; - double HOverBMAC = Auxiliary->GetHOverBMAC(); - if (HOverBMAC < 3.0) - vTurbulence *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0); - - vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection; - - vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad; - - if (Aircraft->GetWingSpan() > 0) { - vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan(); - } else { - vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0; - } -// if (Aircraft->GetHTailArm() != 0.0) -// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm(); -// else -// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0; - - if (Aircraft->GetVTailArm() > 0) - vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm(); - else - vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0; - - // Clear the horizontal forces - // actually felt by the plane, now - // that we've used them to calculate - // moments. - vTurbulence(eX) = 0.0; - vTurbulence(eY) = 0.0; - - break; - } - case ttBerndt: { - vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - - - MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude; - MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt(); - Magnitude += MagnitudeAccel*rate*State->Getdt(); - - vDirectiondAccelDt.Normalize(); - vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt(); - vDirectionAccel.Normalize(); - vDirection += vDirectionAccel*rate*State->Getdt(); - - // Diminish z-vector within two wingspans - // of the ground - double HOverBMAC = Auxiliary->GetHOverBMAC(); - if (HOverBMAC < 2.0) - vDirection(eZ) *= HOverBMAC / 2.0; - - vDirection.Normalize(); - - vTurbulence = TurbGain*Magnitude * vDirection; - vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection; - - vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad; - vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan(); - if (Aircraft->GetHTailArm() > 0) - vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm(); - else - vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0; - - if (Aircraft->GetVTailArm() > 0) - vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm(); - else - vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0; - - break; - } - default: - break; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::UseExternal(void) { - temperature=&exTemperature; - pressure=&exPressure; - density=&exDensity; - useExternal=true; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::UseInternal(void) { - temperature=&intTemperature; - pressure=&intPressure; - density=&intDensity; - useExternal=false; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::bind(void) -{ - typedef double (FGAtmosphere::*PMF)(int) const; - PropertyManager->Tie("atmosphere/T-R", this, - &FGAtmosphere::GetTemperature); - PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, - &FGAtmosphere::GetDensity); -// PropertyManager->Tie("atmosphere/P-psf", this, -// &FGAtmosphere::GetPressure); - PropertyManager->Tie("atmosphere/a-fps", this, - &FGAtmosphere::GetSoundSpeed); - PropertyManager->Tie("atmosphere/T-sl-R", this, - &FGAtmosphere::GetTemperatureSL); - PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, - &FGAtmosphere::GetDensitySL); - PropertyManager->Tie("atmosphere/P-sl-psf", this, - &FGAtmosphere::GetPressureSL); - PropertyManager->Tie("atmosphere/a-sl-fps", this, - &FGAtmosphere::GetSoundSpeedSL); - PropertyManager->Tie("atmosphere/theta-norm", this, - &FGAtmosphere::GetTemperatureRatio); - PropertyManager->Tie("atmosphere/sigma-norm", this, - &FGAtmosphere::GetDensityRatio); - PropertyManager->Tie("atmosphere/delta-norm", this, - &FGAtmosphere::GetPressureRatio); - PropertyManager->Tie("atmosphere/a-norm", this, - &FGAtmosphere::GetSoundSpeedRatio); - PropertyManager->Tie("atmosphere/psiw-rad", this, - &FGAtmosphere::GetWindPsi); - PropertyManager->Tie("atmosphere/delta-T", this, - &FGAtmosphere::GetDeltaT, &FGAtmosphere::SetDeltaT); - PropertyManager->Tie("atmosphere/T-sl-dev-F", this, - &FGAtmosphere::GetSLTempDev, &FGAtmosphere::SetSLTempDev); - PropertyManager->Tie("atmosphere/density-altitude", this, - &FGAtmosphere::GetDensityAltitude); - PropertyManager->Tie("atmosphere/p-turb-rad_sec", this,1, - (PMF)&FGAtmosphere::GetTurbPQR); - PropertyManager->Tie("atmosphere/q-turb-rad_sec", this,2, - (PMF)&FGAtmosphere::GetTurbPQR); - PropertyManager->Tie("atmosphere/r-turb-rad_sec", this,3, - (PMF)&FGAtmosphere::GetTurbPQR); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAtmosphere::unbind(void) -{ - PropertyManager->Untie("atmosphere/T-R"); - PropertyManager->Untie("atmosphere/rho-slugs_ft3"); -// PropertyManager->Untie("atmosphere/P-psf"); - PropertyManager->Untie("atmosphere/a-fps"); - PropertyManager->Untie("atmosphere/T-sl-R"); - PropertyManager->Untie("atmosphere/rho-sl-slugs_ft3"); - PropertyManager->Untie("atmosphere/P-sl-psf"); - PropertyManager->Untie("atmosphere/a-sl-fps"); - PropertyManager->Untie("atmosphere/delta-T"); - PropertyManager->Untie("atmosphere/T-sl-dev-F"); - PropertyManager->Untie("atmosphere/density-altitude"); - PropertyManager->Untie("atmosphere/theta-norm"); - PropertyManager->Untie("atmosphere/sigma-norm"); - PropertyManager->Untie("atmosphere/delta-norm"); - PropertyManager->Untie("atmosphere/a-norm"); - PropertyManager->Untie("atmosphere/psiw-rad"); - PropertyManager->Untie("atmosphere/p-turb-rad_sec"); - PropertyManager->Untie("atmosphere/q-turb-rad_sec"); - PropertyManager->Untie("atmosphere/r-turb-rad_sec"); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGAtmosphere::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - if (from == 0) { // Constructor - } - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAtmosphere" << endl; - if (from == 1) cout << "Destroyed: FGAtmosphere" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - } - if (debug_lvl & 32) { // Turbulence - if (frame == 0 && from == 2) { - cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), " - << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), " - << "vDirection(X), vDirection(Y), vDirection(Z), " - << "Magnitude, " - << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl; - } else if (from == 2) { - cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl; - } - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGAtmosphere.h b/src/FDM/JSBSim/FGAtmosphere.h deleted file mode 100644 index 711057f75..000000000 --- a/src/FDM/JSBSim/FGAtmosphere.h +++ /dev/null @@ -1,205 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGAtmosphere.h - Author: Jon Berndt - Implementation of 1959 Standard Atmosphere added by Tony Peden - Date started: 11/24/98 - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -11/24/98 JSB Created -07/23/99 TP Added implementation of 1959 Standard Atmosphere - Moved calculation of Mach number to FGPropagate - Updated to '76 model - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGAtmosphere_H -#define FGAtmosphere_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include "FGModel.h" -#include "FGColumnVector3.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_ATMOSPHERE "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** Models the standard atmosphere. - @author Tony Peden, Jon Berndt - @version $Id$ - @see Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill, - 1989, ISBN 0-07-001641-0 -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGAtmosphere : public FGModel { -public: - - /// Constructor - FGAtmosphere(FGFDMExec*); - /// Destructor - ~FGAtmosphere(); - /** Runs the Atmosphere model; called by the Executive - @return false if no error */ - bool Run(void); - - bool InitModel(void); - - /// Returns the temperature in degrees Rankine. - inline double GetTemperature(void) const {return *temperature;} - /** Returns the density in slugs/ft^3. - This function may only be used if Run() is called first. */ - inline double GetDensity(void) const {return *density;} - /// Returns the pressure in psf. - inline double GetPressure(void) const {return *pressure;} - /// Returns the pressure at an arbitrary altitude in psf - double GetPressure(double alt); - /// Returns the speed of sound in ft/sec. - inline double GetSoundSpeed(void) const {return soundspeed;} - - /// Returns the sea level temperature in degrees Rankine. - inline double GetTemperatureSL(void) const { return SLtemperature; } - /// Returns the sea level density in slugs/ft^3 - inline double GetDensitySL(void) const { return SLdensity; } - /// Returns the sea level pressure in psf. - inline double GetPressureSL(void) const { return SLpressure; } - /// Returns the sea level speed of sound in ft/sec. - inline double GetSoundSpeedSL(void) const { return SLsoundspeed; } - - /// Returns the ratio of at-altitude temperature over the sea level value. - inline double GetTemperatureRatio(void) const { return (*temperature)*rSLtemperature; } - /// Returns the ratio of at-altitude density over the sea level value. - inline double GetDensityRatio(void) const { return (*density)*rSLdensity; } - /// Returns the ratio of at-altitude pressure over the sea level value. - inline double GetPressureRatio(void) const { return (*pressure)*rSLpressure; } - /// Returns the ratio of at-altitude sound speed over the sea level value. - inline double GetSoundSpeedRatio(void) const { return soundspeed*rSLsoundspeed; } - - /// Tells the simulator to use an externally calculated atmosphere model. - void UseExternal(void); - /// Tells the simulator to use the internal atmosphere model. - void UseInternal(void); //this is the default - /// Gets the boolean that tells if the external atmosphere model is being used. - bool External(void) { return useExternal; } - - /// Provides the external atmosphere model with an interface to set the temperature. - inline void SetExTemperature(double t) { exTemperature=t; } - /// Provides the external atmosphere model with an interface to set the density. - inline void SetExDensity(double d) { exDensity=d; } - /// Provides the external atmosphere model with an interface to set the pressure. - inline void SetExPressure(double p) { exPressure=p; } - - /// Sets the temperature deviation at sea-level in degrees Fahrenheit - inline void SetSLTempDev(double d) { T_dev_sl = d; } - /// Gets the temperature deviation at sea-level in degrees Fahrenheit - inline double GetSLTempDev(void) const { return T_dev_sl; } - /// Sets the current delta-T in degrees Fahrenheit - inline void SetDeltaT(double d) { delta_T = d; } - /// Gets the current delta-T in degrees Fahrenheit - inline double GetDeltaT(void) const { return delta_T; } - /// Gets the at-altitude temperature deviation in degrees Fahrenheit - inline double GetTempDev(void) const { return T_dev; } - /// Gets the density altitude in feet - inline double GetDensityAltitude(void) const { return density_altitude; } - - /// Sets the wind components in NED frame. - inline void SetWindNED(double wN, double wE, double wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;} - - /// Retrieves the wind components in NED frame. - inline FGColumnVector3& GetWindNED(void) { return vWindNED; } - - /** Retrieves the wind direction. The direction is defined as north=0 and - increases counterclockwise. The wind heading is returned in radians.*/ - inline double GetWindPsi(void) const { return psiw; } - - inline void SetTurbGain(double tt) {TurbGain = tt;} - inline void SetTurbRate(double tt) {TurbRate = tt;} - - inline double GetTurbPQR(int idx) const {return vTurbPQR(idx);} - inline FGColumnVector3& GetTurbPQR(void) {return vTurbPQR;} - - void bind(void); - void unbind(void); - - -protected: - double rho; - - enum tType {ttStandard, ttBerndt, ttNone} turbType; - - int lastIndex; - double h; - double htab[8]; - double SLtemperature,SLdensity,SLpressure,SLsoundspeed; - double rSLtemperature,rSLdensity,rSLpressure,rSLsoundspeed; //reciprocals - double *temperature,*density,*pressure; - double soundspeed; - bool useExternal; - double exTemperature,exDensity,exPressure; - double intTemperature, intDensity, intPressure; - double T_dev_sl, T_dev, delta_T, density_altitude; - - double MagnitudedAccelDt, MagnitudeAccel, Magnitude; - double TurbGain; - double TurbRate; - FGColumnVector3 vDirectiondAccelDt; - FGColumnVector3 vDirectionAccel; - FGColumnVector3 vDirection; - FGColumnVector3 vTurbulence; - FGColumnVector3 vTurbulenceGrad; - FGColumnVector3 vBodyTurbGrad; - FGColumnVector3 vTurbPQR; - - FGColumnVector3 vWindNED; - double psiw; - - void Calculate(double altitude); - void Turbulence(void); - void Debug(int from); -}; - -} // namespace JSBSim - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif - diff --git a/src/FDM/JSBSim/FGAuxiliary.cpp b/src/FDM/JSBSim/FGAuxiliary.cpp deleted file mode 100644 index c7e29e7b8..000000000 --- a/src/FDM/JSBSim/FGAuxiliary.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Module: FGAuxiliary.cpp - Author: Tony Peden, Jon Berndt - Date started: 01/26/99 - Purpose: Calculates additional parameters needed by the visual system, etc. - Called by: FGSimExec - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- -This class calculates various auxiliary parameters. - -REFERENCES - Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989 - pgs. 112-126 -HISTORY --------------------------------------------------------------------------------- -01/26/99 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include "FGAuxiliary.h" -#include "FGAerodynamics.h" -#include "FGPropagate.h" -#include "FGAtmosphere.h" -#include "FGState.h" -#include "FGFDMExec.h" -#include "FGAircraft.h" -#include "FGInertial.h" -#include "FGPropertyManager.h" - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_AUXILIARY; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - - -FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex) -{ - Name = "FGAuxiliary"; - vcas = veas = pt = tat = 0; - psl = rhosl = 1; - earthPosAngle = 0.0; - qbar = 0; - qbarUW = 0.0; - qbarUV = 0.0; - Mach = 0.0; - alpha = beta = 0.0; - adot = bdot = 0.0; - gamma = Vt = Vground = 0.0; - psigt = 0.0; - day_of_year = 1; - seconds_in_day = 0.0; - hoverbmac = hoverbcg = 0.0; - - vPilotAccel.InitMatrix(); - vPilotAccelN.InitMatrix(); - vToEyePt.InitMatrix(); - vAeroPQR.InitMatrix(); - vEulerRates.InitMatrix(); - - bind(); - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGAuxiliary::~FGAuxiliary() -{ - unbind(); - Debug(1); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGAuxiliary::Run() -{ - double A,B,D, hdot_Vt; - const FGColumnVector3& vPQR = Propagate->GetPQR(); - const FGColumnVector3& vUVW = Propagate->GetUVW(); - const FGColumnVector3& vUVWdot = Propagate->GetUVWdot(); - const FGColumnVector3& vVel = Propagate->GetVel(); - - if (!FGModel::Run()) - { - p = Atmosphere->GetPressure(); - rhosl = Atmosphere->GetDensitySL(); - psl = Atmosphere->GetPressureSL(); - sat = Atmosphere->GetTemperature(); - -// Rotation - - double cTht = Propagate->GetCosEuler(eTht); - double cPhi = Propagate->GetCosEuler(ePhi); - double sPhi = Propagate->GetSinEuler(ePhi); - - vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi; - if (cTht != 0.0) { - vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht; - vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sPhi; - } - - vAeroPQR = vPQR + Atmosphere->GetTurbPQR(); - -// Translation - - vAeroUVW = vUVW + Propagate->GetTl2b()*Atmosphere->GetWindNED(); - - Vt = vAeroUVW.Magnitude(); - if ( Vt > 0.05) { - if (vAeroUVW(eW) != 0.0) - alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0; - if (vAeroUVW(eV) != 0.0) - beta = vAeroUVW(eU)*vAeroUVW(eU)+vAeroUVW(eW)*vAeroUVW(eW) > 0.0 ? atan2(vAeroUVW(eV), - sqrt(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW))) : 0.0; - - double mUW = (vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW)); - double signU=1; - if (vAeroUVW(eU) != 0.0) - signU = vAeroUVW(eU)/fabs(vAeroUVW(eU)); - - if ( (mUW == 0.0) || (Vt == 0.0) ) { - adot = 0.0; - bdot = 0.0; - } else { - adot = (vAeroUVW(eU)*vUVWdot(eW) - vAeroUVW(eW)*vUVWdot(eU))/mUW; - bdot = (signU*mUW*vUVWdot(eV) - vAeroUVW(eV)*(vAeroUVW(eU)*vUVWdot(eU) - + vAeroUVW(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW)); - } - } else { - alpha = beta = adot = bdot = 0; - } - - qbar = 0.5*Atmosphere->GetDensity()*Vt*Vt; - qbarUW = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW)); - qbarUV = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV)); - Mach = Vt / Atmosphere->GetSoundSpeed(); - MachU = vMachUVW(eU) = vAeroUVW(eU) / Atmosphere->GetSoundSpeed(); - vMachUVW(eV) = vAeroUVW(eV) / Atmosphere->GetSoundSpeed(); - vMachUVW(eW) = vAeroUVW(eW) / Atmosphere->GetSoundSpeed(); - -// Position - - Vground = sqrt( vVel(eNorth)*vVel(eNorth) + vVel(eEast)*vVel(eEast) ); - - if (vVel(eNorth) == 0) psigt = 0; - else psigt = atan2(vVel(eEast), vVel(eNorth)); - - if (psigt < 0.0) psigt += 2*M_PI; - - if (Vt != 0) { - hdot_Vt = -vVel(eDown)/Vt; - if (fabs(hdot_Vt) <= 1) gamma = asin(hdot_Vt); - } else { - gamma = 0.0; - } - - tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow - tatc = RankineToCelsius(tat); - - if (MachU < 1) { // Calculate total pressure assuming isentropic flow - pt = p*pow((1 + 0.2*MachU*MachU),3.5); - } else { - // Use Rayleigh pitot tube formula for normal shock in front of pitot tube - B = 5.76*MachU*MachU/(5.6*MachU*MachU - 0.8); - D = (2.8*MachU*MachU-0.4)*0.4167; - pt = p*pow(B,3.5)*D; - } - - A = pow(((pt-p)/psl+1),0.28571); - if (MachU > 0.0) { - vcas = sqrt(7*psl/rhosl*(A-1)); - veas = sqrt(2*qbar/rhosl); - } else { - vcas = veas = 0.0; - } - - vPilotAccel.InitMatrix(); - if ( Vt > 1.0 ) { - vPilotAccel = Aerodynamics->GetForces() - + Propulsion->GetForces() - + GroundReactions->GetForces(); - vPilotAccel /= MassBalance->GetMass(); - vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep()); - vPilotAccel += Propagate->GetPQRdot() * vToEyePt; - vPilotAccel += vPQR * (vPQR * vToEyePt); - } else { - vPilotAccel = Propagate->GetTl2b() * FGColumnVector3( 0.0, 0.0, Inertial->gravity() ); - } - - vPilotAccelN = vPilotAccel/Inertial->gravity(); - - earthPosAngle += State->Getdt()*Inertial->omega(); - - // VRP computation - const FGLocation& vLocation = Propagate->GetLocation(); - FGColumnVector3 vrpStructural = Aircraft->GetXYZvrp(); - FGColumnVector3 vrpBody = MassBalance->StructuralToBody( vrpStructural ); - FGColumnVector3 vrpLocal = Propagate->GetTb2l() * vrpBody; - vLocationVRP = vLocation.LocalToLocation( vrpLocal ); - - // Recompute some derived values now that we know the dependent parameters values ... - hoverbcg = Propagate->GetDistanceAGL() / Aircraft->GetWingSpan(); - - FGColumnVector3 vMac = Propagate->GetTb2l()*MassBalance->StructuralToBody(Aircraft->GetXYZrp()); - hoverbmac = (Propagate->GetDistanceAGL() + vMac(3)) / Aircraft->GetWingSpan(); - - return false; - } else { - return true; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGAuxiliary::GetHeadWind(void) -{ - double psiw,vw; - - psiw = Atmosphere->GetWindPsi(); - vw = Atmosphere->GetWindNED().Magnitude(); - - return vw*cos(psiw - Propagate->GetEuler(ePsi)); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGAuxiliary::GetCrossWind(void) -{ - double psiw,vw; - - psiw = Atmosphere->GetWindPsi(); - vw = Atmosphere->GetWindNED().Magnitude(); - - return vw*sin(psiw - Propagate->GetEuler(ePsi)); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAuxiliary::bind(void) -{ - typedef double (FGAuxiliary::*PMF)(int) const; - typedef double (FGAuxiliary::*PF)(void) 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/machU", this, &FGAuxiliary::GetMachU); - PropertyManager->Tie("velocities/tat-r", this, &FGAuxiliary::GetTotalTemperature); - PropertyManager->Tie("velocities/tat-c", this, &FGAuxiliary::GetTAT_C); - PropertyManager->Tie("velocities/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure); - PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR); - PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR); - PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR); - PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, (PMF)&FGAuxiliary::GetEulerRates); - PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, (PMF)&FGAuxiliary::GetEulerRates); - PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, (PMF)&FGAuxiliary::GetEulerRates); - PropertyManager->Tie("velocities/u-aero-fps", this, eU, (PMF)&FGAuxiliary::GetAeroUVW); - PropertyManager->Tie("velocities/v-aero-fps", this, eV, (PMF)&FGAuxiliary::GetAeroUVW); - PropertyManager->Tie("velocities/w-aero-fps", this, eW, (PMF)&FGAuxiliary::GetAeroUVW); - PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt, &FGAuxiliary::SetVt, true); - PropertyManager->Tie("velocities/mach-norm", this, &FGAuxiliary::GetMach, &FGAuxiliary::SetMach, true); - PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground); - PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, (PMF)&FGAuxiliary::GetPilotAccel); - PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, (PMF)&FGAuxiliary::GetPilotAccel); - PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, (PMF)&FGAuxiliary::GetPilotAccel); - PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, (PMF)&FGAuxiliary::GetNpilot); - PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, (PMF)&FGAuxiliary::GetNpilot); - PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, (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); */ - PropertyManager->Tie("aero/alpha-rad", this, (PF)&FGAuxiliary::Getalpha, &FGAuxiliary::Setalpha, true); - PropertyManager->Tie("aero/beta-rad", this, (PF)&FGAuxiliary::Getbeta, &FGAuxiliary::Setbeta, true); - PropertyManager->Tie("aero/mag-beta-rad", this, (PF)&FGAuxiliary::GetMagBeta); - PropertyManager->Tie("aero/alpha-deg", this, inDegrees, (PMF)&FGAuxiliary::Getalpha); - PropertyManager->Tie("aero/beta-deg", this, inDegrees, (PMF)&FGAuxiliary::Getbeta); - PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, (PMF)&FGAuxiliary::GetMagBeta); - PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar, &FGAuxiliary::Setqbar, true); - PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW, &FGAuxiliary::SetqbarUW, true); - PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV, &FGAuxiliary::SetqbarUV, true); - PropertyManager->Tie("aero/alphadot-rad_sec", this, (PF)&FGAuxiliary::Getadot, &FGAuxiliary::Setadot, true); - PropertyManager->Tie("aero/betadot-rad_sec", this, (PF)&FGAuxiliary::Getbdot, &FGAuxiliary::Setbdot, true); - PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getadot); - PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getbdot); - PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG); - PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC); - PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma, &FGAuxiliary::SetGamma); - PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAuxiliary::unbind(void) -{ - PropertyManager->Untie("velocities/vc-fps"); - PropertyManager->Untie("velocities/vc-kts"); - PropertyManager->Untie("velocities/ve-fps"); - PropertyManager->Untie("velocities/ve-kts"); - PropertyManager->Untie("velocities/machU"); - PropertyManager->Untie("velocities/tat-r"); - PropertyManager->Untie("velocities/tat-c"); - PropertyManager->Untie("velocities/p-aero-rad_sec"); - PropertyManager->Untie("velocities/q-aero-rad_sec"); - PropertyManager->Untie("velocities/r-aero-rad_sec"); - PropertyManager->Untie("velocities/pt-lbs_sqft"); - PropertyManager->Untie("velocities/phidot-rad_sec"); - PropertyManager->Untie("velocities/thetadot-rad_sec"); - PropertyManager->Untie("velocities/psidot-rad_sec"); - PropertyManager->Untie("velocities/u-aero-fps"); - PropertyManager->Untie("velocities/v-aero-fps"); - PropertyManager->Untie("velocities/w-aero-fps"); - PropertyManager->Untie("velocities/vt-fps"); - PropertyManager->Untie("velocities/mach-norm"); - PropertyManager->Untie("velocities/vg-fps"); - 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"); */ - PropertyManager->Untie("aero/qbar-psf"); - PropertyManager->Untie("aero/qbarUW-psf"); - PropertyManager->Untie("aero/qbarUV-psf"); - PropertyManager->Untie("aero/alpha-rad"); - PropertyManager->Untie("aero/beta-rad"); - PropertyManager->Untie("aero/alpha-deg"); - PropertyManager->Untie("aero/beta-deg"); - PropertyManager->Untie("aero/alphadot-rad_sec"); - PropertyManager->Untie("aero/betadot-rad_sec"); - PropertyManager->Untie("aero/mag-beta-rad"); - PropertyManager->Untie("aero/alphadot-deg_sec"); - PropertyManager->Untie("aero/betadot-deg_sec"); - PropertyManager->Untie("aero/mag-beta-deg"); - PropertyManager->Untie("aero/h_b-cg-ft"); - PropertyManager->Untie("aero/h_b-mac-ft"); - PropertyManager->Untie("flight-path/gamma-rad"); - PropertyManager->Untie("flight-path/psi-gt-rad"); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGAuxiliary::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - if (from == 0) { // Constructor - - } - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAuxiliary" << endl; - if (from == 1) cout << "Destroyed: FGAuxiliary" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - if (Mach > 100 || Mach < 0.00) - cout << "FGPropagate::Mach is out of bounds: " << Mach << endl; - if (qbar > 1e6 || qbar < 0.00) - cout << "FGPropagate::qbar is out of bounds: " << qbar << endl; - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGAuxiliary.h b/src/FDM/JSBSim/FGAuxiliary.h deleted file mode 100644 index f269f39b7..000000000 --- a/src/FDM/JSBSim/FGAuxiliary.h +++ /dev/null @@ -1,245 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGAuxiliary.h - Author: Jon Berndt - Date started: 01/26/99 - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -11/22/98 JSB Created - 1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGAUXILIARY_H -#define FGAUXILIARY_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include "FGModel.h" -#include "FGColumnVector3.h" -#include "FGLocation.h" -#include "FGPropagate.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_AUXILIARY "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** Encapsulates various uncategorized scheduled functions. - Pilot sensed accelerations are calculated here. This is used - for the coordinated turn ball instrument. Motion base platforms sometimes - use the derivative of pilot sensed accelerations as the driving parameter, - rather than straight accelerations. - - The theory behind pilot-sensed calculations is presented: - - For purposes of discussion and calculation, assume for a minute that the - pilot is in space and motionless in inertial space. She will feel - no accelerations. If the aircraft begins to accelerate along any axis or - axes (without rotating), the pilot will sense those accelerations. If - any rotational moment is applied, the pilot will sense an acceleration - due to that motion in the amount: - - [wdot X R] + [w X (w X R)] - Term I Term II - - where: - - wdot = omegadot, the rotational acceleration rate vector - w = omega, the rotational rate vector - R = the vector from the aircraft CG to the pilot eyepoint - - The sum total of these two terms plus the acceleration of the aircraft - body axis gives the acceleration the pilot senses in inertial space. - In the presence of a large body such as a planet, a gravity field also - provides an accelerating attraction. This acceleration can be transformed - from the reference frame of the planet so as to be expressed in the frame - of reference of the aircraft. This gravity field accelerating attraction - is felt by the pilot as a force on her tushie as she sits in her aircraft - on the runway awaiting takeoff clearance. - - In JSBSim the acceleration of the body frame in inertial space is given - by the F = ma relation. If the vForces vector is divided by the aircraft - 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. - - @author Tony Peden, Jon Berndt - @version $Id$ -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGAuxiliary : public FGModel { -public: - /** Constructor - @param Executive a pointer to the parent executive object */ - FGAuxiliary(FGFDMExec* Executive); - - /// Destructor - ~FGAuxiliary(); - - /** Runs the Auxiliary routines; called by the Executive - @return false if no error */ - bool Run(void); - -// GET functions - - // Atmospheric parameters GET functions - double GetVcalibratedFPS(void) const { return vcas; } - double GetVcalibratedKTS(void) const { return vcas*fpstokts; } - double GetVequivalentFPS(void) const { return veas; } - double GetVequivalentKTS(void) const { return veas*fpstokts; } - - // total pressure above is freestream total pressure for subsonic only - // for supersonic it is the 1D total pressure behind a normal shock - double GetTotalPressure(void) const { return pt; } - double GetTotalTemperature(void) const { return tat; } - double GetTAT_C(void) const { return tatc; } - - double GetPilotAccel(int idx) const { return vPilotAccel(idx); } - double GetNpilot(int idx) const { return vPilotAccelN(idx); } - double GetAeroPQR(int axis) const { return vAeroPQR(axis); } - double GetEulerRates(int axis) const { return vEulerRates(axis); } - - const FGColumnVector3& GetPilotAccel (void) const { return vPilotAccel; } - const FGColumnVector3& GetNpilot (void) const { return vPilotAccelN; } - const FGColumnVector3& GetAeroPQR (void) const { return vAeroPQR; } - const FGColumnVector3& GetEulerRates (void) const { return vEulerRates; } - const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; } - const FGLocation& GetLocationVRP(void) const { return vLocationVRP; } - - double GethVRP(void) const { return vLocationVRP.GetRadius() - Propagate->GetSeaLevelRadius(); } - double GetAeroUVW (int idx) const { return vAeroUVW(idx); } - double Getalpha (void) const { return alpha; } - double Getbeta (void) const { return beta; } - double Getadot (void) const { return adot; } - double Getbdot (void) const { return bdot; } - double GetMagBeta (void) const { return fabs(beta); } - - double Getalpha (int unit) const { if (unit == inDegrees) return alpha*radtodeg; - else cerr << "Bad units" << endl; return 0.0;} - double Getbeta (int unit) const { if (unit == inDegrees) return beta*radtodeg; - else cerr << "Bad units" << endl; return 0.0;} - double Getadot (int unit) const { if (unit == inDegrees) return adot*radtodeg; - else cerr << "Bad units" << endl; return 0.0;} - double Getbdot (int unit) const { if (unit == inDegrees) return bdot*radtodeg; - else cerr << "Bad units" << endl; return 0.0;} - double GetMagBeta (int unit) const { if (unit == inDegrees) return fabs(beta)*radtodeg; - else cerr << "Bad units" << endl; return 0.0;} - - double Getqbar (void) const { return qbar; } - double GetqbarUW (void) const { return qbarUW; } - double GetqbarUV (void) const { return qbarUV; } - double GetVt (void) const { return Vt; } - double GetVground (void) const { return Vground; } - double GetMach (void) const { return Mach; } - double GetMachU (void) const { return MachU; } - - double GetHOverBCG(void) const { return hoverbcg; } - double GetHOverBMAC(void) const { return hoverbmac; } - - double GetGamma(void) const { return gamma; } - double GetGroundTrack(void) const { return psigt; } - double GetEarthPositionAngle(void) const { return earthPosAngle; } - - double GetHeadWind(void); - double GetCrossWind(void); - -// SET functions - - void SetAeroUVW(FGColumnVector3 tt) { vAeroUVW = tt; } - - void Setalpha (double tt) { alpha = tt; } - void Setbeta (double tt) { beta = tt; } - void Setqbar (double tt) { qbar = tt; } - void SetqbarUW (double tt) { qbarUW = tt; } - void SetqbarUV (double tt) { qbarUV = tt; } - void SetVt (double tt) { Vt = tt; } - void SetMach (double tt) { Mach=tt; } - void Setadot (double tt) { adot = tt; } - void Setbdot (double tt) { bdot = tt; } - - void SetAB (double t1, double t2) { alpha=t1; beta=t2; } - void SetGamma (double tt) { gamma = tt; } - -// Time routines, SET and GET functions - - void SetDayOfYear (int doy) { day_of_year = doy; } - void SetSecondsInDay (double sid) { seconds_in_day = sid; } - - int GetDayOfYear (void) const { return day_of_year; } - double GetSecondsInDay (void) const { return seconds_in_day; } - - void bind(void); - void unbind(void); - -private: - double vcas, veas; - double rhosl, rho, p, psl, pt, tat, sat, tatc; // Don't add a getter for pt! - - FGColumnVector3 vPilotAccel; - FGColumnVector3 vPilotAccelN; - FGColumnVector3 vToEyePt; - FGColumnVector3 vAeroPQR; - FGColumnVector3 vAeroUVW; - FGColumnVector3 vEuler; - FGColumnVector3 vEulerRates; - FGColumnVector3 vMachUVW; - FGLocation vLocationVRP; - - double Vt, Vground, Mach, MachU; - double qbar, qbarUW, qbarUV; - double alpha, beta; - double adot,bdot; - double psigt, gamma; - double seconds_in_day; // seconds since current GMT day began - int day_of_year; // GMT day, 1 .. 366 - - double earthPosAngle; - double hoverbcg, hoverbmac; - - void Debug(int from); -}; - -} // namespace JSBSim - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp deleted file mode 100644 index 1e2aab5e8..000000000 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Module: FGCoefficient.cpp - Author: Jon S. Berndt - Date started: 12/28/98 - Purpose: Encapsulates the stability derivative class FGCoefficient; - Called by: FGAircraft - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- -This class models the stability derivative coefficient lookup tables or -equations. Note that the coefficients need not be calculated each delta-t. - -Note that the values in a row which index into the table must be the same value -for each column of data, so the first column of numbers for each altitude are -seen to be equal, and there are the same number of values for each altitude. - -See the header file FGCoefficient.h for the values of the identifiers. - -HISTORY --------------------------------------------------------------------------------- -12/28/98 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "FGCoefficient.h" -#include "FGState.h" -#include "FGFDMExec.h" -#include "FGPropertyManager.h" - -#ifndef FGFS -# if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740) -# include -# else -# include -# endif -#else -# include STL_IOMANIP -#endif - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_COEFFICIENT; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -FGCoefficient::FGCoefficient( FGFDMExec* fdex ) -{ - FDMExec = fdex; - State = FDMExec->GetState(); - Table = 0; - IsFactor = false; - - PropertyManager = FDMExec->GetPropertyManager(); - - Table = (FGTable*)0L; - LookupR = LookupC = 0; - numInstances = 0; - rows = columns = tables = 0; - - StaticValue = 0.0; - totalValue = 0.0; - bias = 0.0; - gain = 1.0; - SD = 0.0; - - filename.erase(); - description.erase(); - name.erase(); - method.erase(); - multparms.erase(); - multparmsRow.erase(); - multparmsCol.erase(); - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGCoefficient::~FGCoefficient() -{ - if (Table) delete Table; - Debug(1); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -bool FGCoefficient::Load(FGConfigFile *AC_cfg) -{ - int start, end, n; - string mult; - - if (AC_cfg) { - name = AC_cfg->GetValue("NAME"); - method = AC_cfg->GetValue("TYPE"); - AC_cfg->GetNextConfigLine(); - *AC_cfg >> description; - if (method == "EQUATION") type = EQUATION; - else if (method == "TABLE") type = TABLE; - else if (method == "TABLE3D") type = TABLE3D; - else if (method == "VECTOR") type = VECTOR; - else if (method == "VALUE") type = VALUE; - else type = UNKNOWN; - - if (type == VECTOR || type == TABLE || type == TABLE3D) { - - if (type == TABLE3D) { - *AC_cfg >> rows >> columns >> tables; - Table = new FGTable(rows, columns, tables); - *AC_cfg >> multparmsRow >> multparmsCol >> multparmsTable; - LookupR = PropertyManager->GetNode( multparmsRow ); - LookupC = PropertyManager->GetNode( multparmsCol ); - LookupT = PropertyManager->GetNode( multparmsTable ); - } else if (type == TABLE) { - *AC_cfg >> rows >> columns; - Table = new FGTable(rows, columns); - *AC_cfg >> multparmsRow >> multparmsCol; - LookupR = PropertyManager->GetNode( multparmsRow ); - LookupC = PropertyManager->GetNode( multparmsCol ); - } else { - *AC_cfg >> rows; - Table = new FGTable(rows); - *AC_cfg >> multparmsRow; - LookupR = PropertyManager->GetNode( multparmsRow ); - } - } - - // Here, read in the line of the form: - // {property1} | {property2} | {property3} - // where each non-dimensionalizing property for this coefficient is - // separated by a | character - - string line=AC_cfg->GetCurrentLine(); - unsigned j=0; - char tmp[255]; - for(unsigned i=0;iGetNextConfigLine(); - - if (type == VALUE) { - *AC_cfg >> StaticValue; - } else if (type == VECTOR || type == TABLE || type == TABLE3D) { - *Table << *AC_cfg; - } else { - cerr << "Unimplemented coefficient type: " << type << endl; - } - - AC_cfg->GetNextConfigLine(); - FGCoefficient::Debug(2); - - return true; - } else { - return false; - } -} - - - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGCoefficient::Value(double rVal, double cVal, double tVal) -{ - double Value; - unsigned int midx; - - SD = Value = gain*Table->GetValue(rVal, cVal, tVal) + bias; - - for (midx=0; midx < multipliers.size(); midx++) { - Value *= multipliers[midx]->getDoubleValue(); - } - return Value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGCoefficient::Value(double rVal, double cVal) -{ - double Value; - unsigned int midx; - - SD = Value = gain*Table->GetValue(rVal, cVal) + bias; - - for (midx=0; midx < multipliers.size(); midx++) { - Value *= multipliers[midx]->getDoubleValue(); - } - return Value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGCoefficient::Value(double Val) -{ - double Value; - - SD = Value = gain*Table->GetValue(Val) + bias; - - for (unsigned int midx=0; midx < multipliers.size(); midx++) - Value *= multipliers[midx]->getDoubleValue(); - - return Value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGCoefficient::Value(void) -{ - double Value; - - SD = Value = gain*StaticValue + bias; - - for (unsigned int midx=0; midx < multipliers.size(); midx++) - Value *= multipliers[midx]->getDoubleValue(); - - return Value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGCoefficient::TotalValue(void) -{ - switch(type) { - - case UNKNOWN: - totalValue = -1; - break; - - case VALUE: - totalValue = Value(); - break; - - case VECTOR: - totalValue = Value( LookupR->getDoubleValue() ); - break; - - case TABLE: - totalValue = Value( LookupR->getDoubleValue(), - LookupC->getDoubleValue() ); - break; - - case TABLE3D: - totalValue = Value( LookupR->getDoubleValue(), - LookupC->getDoubleValue(), - LookupT->getDoubleValue() ); - break; - - case EQUATION: - totalValue = 0.0; - break; - } - return totalValue; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGCoefficient::DisplayCoeffFactors(void) -{ - unsigned int i; - - cout << " Non-Dimensionalized by: "; - - if (multipliers.size() == 0) { - cout << "none" << endl; - } else { - for (i=0; igetName() << " "; - } - cout << endl; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -string FGCoefficient::GetSDstring(void) -{ - char buffer[20]; - string value; - - sprintf(buffer,"%9.6f",SD); - value = string(buffer); - return value; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGCoefficient::bind(FGPropertyManager *parent) -{ - string mult; - unsigned i; - - node = parent->GetNode(name,true); - - node->SetString("description",description); - if (LookupR) node->SetString("row-parm",LookupR->getName() ); - if (LookupC) node->SetString("column-parm",LookupC->getName() ); - - mult=""; - if (multipliers.size() == 0) - mult="none"; - - for (i=0; igetName(); - if ( i < multipliers.size()-1 ) mult += " "; - } - node->SetString("multipliers",mult); - - node->Tie("SD-norm",this,&FGCoefficient::GetSD ); - node->Tie("value-lbs",this,&FGCoefficient::GetValue ); - - node->Tie("bias", this, &FGCoefficient::getBias, - &FGCoefficient::setBias ); - - node->Tie("gain", this, &FGCoefficient::getGain, - &FGCoefficient::setGain ); - -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGCoefficient::unbind(void) -{ - node->Untie("SD-norm"); - node->Untie("value-lbs"); - node->Untie("bias"); - node->Untie("gain"); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGPropertyManager* FGCoefficient::resolveSymbol(string name) -{ - FGPropertyManager* tmpn; - - tmpn = PropertyManager->GetNode(name,false); - if ( !tmpn ) { - cerr << "Coefficient multipliers cannot create properties, check spelling?" << endl; - exit(1); - } - return tmpn; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGCoefficient::convert(string prop) -{ - if (IsFactor) - cout << " " << endl; - else - cout << " " << endl; - - cout << " " << description << "" << endl; - cout << " " << endl; - - for (int i=0; i" << (multipliers[i]->GetFullyQualifiedName()).substr(12) << "" << endl; - - if (!prop.empty()) - cout << " aero/function/" << prop << "" << endl; - - switch (type) { - case VALUE: - cout << " " << StaticValue << "" << endl; - break; - - case VECTOR: - cout << " " << endl; - cout << " " << (LookupR->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << endl; - Table->Print(30); - cout << " " << endl; - cout << "
" << endl; - break; - - case TABLE: - cout << " " << endl; - cout << " " << (LookupR->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << (LookupC->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << endl; - Table->Print(30); - cout << " " << endl; - cout << "
" << endl; - break; - - case TABLE3D: - cout << " " << endl; - cout << " " << (LookupR->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << (LookupC->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << (LookupT->GetFullyQualifiedName()).substr(12) << "" << endl; - cout << " " << endl; - Table->Print(30); - cout << " " << endl; - cout << "
" << endl; - break; - - } - - cout << "
" << endl; - cout << "
" << endl; - - if (IsFactor) { - cout << " === MOVE THE ABOVE FACTOR " << name << " OUTSIDE OF AND BEFORE ANY DEFINITION ===" << endl; - for (int i=0; iconvert(name); - } - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGCoefficient::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - - if (from == 2) { // Loading - cout << "\n " << highint << underon << name << underoff << normint << endl; - cout << " " << description << endl; - cout << " " << method << endl; - - if (type == VECTOR || type == TABLE || type == TABLE3D) { - cout << " Rows: " << rows << " indexed by: " << LookupR->getName() << endl; - if (type == TABLE || type == TABLE3D) { - cout << " Cols: " << columns << " indexed by: " << LookupC->getName() << endl; - if (type == TABLE3D) { - cout << " Tables: " << tables << " indexed by: " << LookupT->getName() << endl; - } - } - Table->Print(); - } else if (type == VALUE) { - cout << " Value = " << StaticValue << endl; - } - - DisplayCoeffFactors(); - } - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGCoefficient" << endl; - if (from == 1) cout << "Destroyed: FGCoefficient" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h deleted file mode 100644 index cee7b4778..000000000 --- a/src/FDM/JSBSim/FGCoefficient.h +++ /dev/null @@ -1,206 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGCoefficient.h - Author: Jon Berndt - Date started: 12/28/98 - - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - Further information about the GNU General Public License can also be found on - the world wide web at http://www.gnu.org. - -HISTORY --------------------------------------------------------------------------------- -12/28/98 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGCOEFFICIENT_H -#define FGCOEFFICIENT_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef FGFS -# include -#endif - -#include -#include -#include "FGConfigFile.h" -#include "FGTable.h" -#include "FGJSBBase.h" -#include "FGPropertyManager.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_COEFFICIENT "$Id$" - -using std::vector; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -class FGFDMExec; -class FGState; -class FGAtmosphere; -class FGFCS; -class FGAircraft; -class FGPropagate; -class FGAuxiliary; -class FGOutput; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** This class models the aero coefficient and stability derivative coefficient - lookup table, value, vector, or equation (equation not modeled, yet). - Each coefficient for an axis is stored in that axes' vector of coefficients. - Each FDM execution frame the Run() method of the FGAerodynamics model - is called and the coefficient values are calculated. - @author Jon S. Berndt - @version $Id$ -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGCoefficient : public FGJSBBase -{ -public: - /** Constructor. - @param exec a pointer to the FGFDMExec instance. */ - FGCoefficient(FGFDMExec* exec); - /// Destructor. - virtual ~FGCoefficient(); - - /** Loads the stability derivative/aero coefficient data from the config file - as directed by the FGAerodynamics instance. - @param AC_cfg a pointer to the current config file instance. */ - virtual bool Load(FGConfigFile* AC_cfg); - - typedef vector MultVec; - - enum Type {UNKNOWN, VALUE, VECTOR, TABLE, TABLE3D, EQUATION}; - - /** Returns the value for this coefficient. - Each instance of FGCoefficient stores a value for the "type" of coefficient - it is, one of: VALUE, VECTOR, TABLE, or EQUATION. This TotalValue function - is called when the value for a coefficient needs to be known. When it is called, - depending on what type of coefficient is represented by the FGCoefficient - instance, TotalValue() directs the appropriate Value() function to be called. - The type of coefficient represented is determined when the config file is read. - The coefficient definition includes the "type" specifier. - @return the current value of the coefficient represented by this instance of - FGCoefficient. */ - virtual double TotalValue(void); - - /** Returns the value for this coefficient. - TotalValue is stored each time TotalValue() is called. This function returns - the stored value but does not calculate it anew. This is valuable for merely - printing out the value. - @return the most recently calculated and stored value of the coefficient - represented by this instance of FGCoefficient. */ - virtual inline double GetValue(void) const { return totalValue; } - - /// Returns the name of this coefficient. - virtual inline string Getname(void) const {return name;} - - /// Returns the value of the coefficient only - before it is re-dimensionalized. - virtual inline double GetSD(void) const { return SD;} - - /** Outputs coefficient information. - Non-dimensionalizing parameter descriptions are output - for each aero coefficient defined. */ - virtual void DisplayCoeffFactors(void); - - /// Returns the name of the coefficient. - virtual inline string GetCoefficientName(void) { return name; } - /// Returns the stability derivative or coefficient value as a string. - virtual string GetSDstring(void); - - inline void setBias(double b) { bias=b; } - inline void setGain(double g) { gain=g; }; - inline double getBias(void) const { return bias; } - inline double getGain(void) const { return gain; } - - virtual void bind(FGPropertyManager *parent); - virtual void unbind(void); - void convert(string prop=""); - -protected: - FGFDMExec* FDMExec; - bool IsFactor; - typedef vector CoeffArray; - CoeffArray sum; - -private: - int numInstances; - string description; - string name; - string filename; - string method; - string multparms; - string multparmsRow; - string multparmsCol; - string multparmsTable; - double Value(double, double, double); - double Value(double, double); - double Value(double); - double Value(void); - double StaticValue; - double totalValue; - double bias,gain; - FGPropertyManager *LookupR, *LookupC, *LookupT; - - FGPropertyManager *node; // must be private!! - - MultVec multipliers; - int rows, columns, tables; - Type type; - double SD; // Actual stability derivative (or other coefficient) value - FGTable *Table; - - FGState* State; - FGAtmosphere* Atmosphere; - FGFCS* FCS; - FGAircraft* Aircraft; - FGPropagate* Propagate; - FGAuxiliary* Auxiliary; - FGOutput* Output; - FGPropertyManager* PropertyManager; - - FGPropertyManager* resolveSymbol(string name); - - virtual void Debug(int from); -}; - -} // using namespace JSBSim - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif - diff --git a/src/FDM/JSBSim/FGColumnVector3.cpp b/src/FDM/JSBSim/FGColumnVector3.cpp deleted file mode 100644 index 8cdfd64a6..000000000 --- a/src/FDM/JSBSim/FGColumnVector3.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -Module: FGColumnVector3.cpp -Author: Originally by Tony Peden [formatted here (and broken??) by JSB] -Date started: 1998 -Purpose: FGColumnVector3 class -Called by: Various - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- - -HISTORY --------------------------------------------------------------------------------- -??/??/?? TP Created -03/16/2000 JSB Added exception throwing - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FGColumnVector3.h" -#include - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_COLUMNVECTOR3; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -FGColumnVector3::FGColumnVector3(void) -{ - data[0] = data[1] = data[2] = 0.0; - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -string FGColumnVector3::Dump(string delimeter) const -{ - char buffer[256]; - sprintf(buffer, "%f%s%f%s%f", Entry(1), delimeter.c_str(), Entry(2), delimeter.c_str(), Entry(3)); - return string(buffer); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGColumnVector3 FGColumnVector3::operator/(const double scalar) const -{ - if (scalar != 0.0) - return operator*( 1.0/scalar ); - - cerr << "Attempt to divide by zero in method " - "FGColumnVector3::operator/(const double scalar), " - "object " << this << endl; - return FGColumnVector3(); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGColumnVector3& FGColumnVector3::operator/=(const double scalar) -{ - if (scalar != 0.0) - operator*=( 1.0/scalar ); - else - cerr << "Attempt to divide by zero in method " - "FGColumnVector3::operator/=(const double scalar), " - "object " << this << endl; - - return *this; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGColumnVector3::Magnitude(void) const -{ - if (Entry(1) == 0.0 && Entry(2) == 0.0 && Entry(3) == 0.0) - return 0.0; - else - return sqrt( Entry(1)*Entry(1) + Entry(2)*Entry(2) + Entry(3)*Entry(3) ); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGColumnVector3& FGColumnVector3::Normalize(void) -{ - double Mag = Magnitude(); - - if (Mag != 0.0) - operator*=( 1.0/Mag ); - - return *this; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGColumnVector3 FGColumnVector3::multElementWise(const FGColumnVector3& V) const -{ - return FGColumnVector3(Entry(1) * V(1), Entry(2) * V(2), Entry(3) * V(3)); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -ostream& operator<<(ostream& os, const FGColumnVector3& col) -{ - os << col(1) << " , " << col(2) << " , " << col(3); - return os; -} - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -// The bitmasked value choices are as follows: -// unset: In this case (the default) JSBSim would only print -// out the normally expected messages, essentially echoing -// the config files as they are read. If the environment -// variable is not set, debug_lvl is set to 1 internally -// 0: This requests JSBSim not to output any messages -// whatsoever. -// 1: This value explicity requests the normal JSBSim -// startup messages -// 2: This value asks for a message to be printed out when -// a class is instantiated -// 4: When this value is set, a message is displayed when a -// FGModel object executes its Run() method -// 8: When this value is set, various runtime state variables -// are printed out periodically -// 16: When set various parameters are sanity checked and -// a message is printed out when they go out of bounds - -void FGColumnVector3::Debug(int from) -{ - if (debug_lvl <= 0) return; - - if (debug_lvl & 1) { // Standard console startup message output - } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGColumnVector3" << endl; - if (from == 1) cout << "Destroyed: FGColumnVector3" << endl; - } - if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - } - if (debug_lvl & 8 ) { // Runtime state variables - } - if (debug_lvl & 16) { // Sanity checking - } - if (debug_lvl & 64) { - if (from == 0) { // Constructor - cout << IdSrc << endl; - cout << IdHdr << endl; - } - } -} - -} // namespace JSBSim diff --git a/src/FDM/JSBSim/FGColumnVector3.h b/src/FDM/JSBSim/FGColumnVector3.h deleted file mode 100644 index 19a508b6b..000000000 --- a/src/FDM/JSBSim/FGColumnVector3.h +++ /dev/null @@ -1,307 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -Header: FGColumnVector3.h -Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt] -Date started: Unknown - -HISTORY --------------------------------------------------------------------------------- -??/??/???? ?? Initial version and more. -03/06/2004 MF Rework, document and do much inlineing. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SENTRY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifndef FGCOLUMNVECTOR3_H -#define FGCOLUMNVECTOR3_H - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#include -#ifdef FGFS -# include -# include -# include STL_STRING -# include STL_FSTREAM -# include STL_IOSTREAM - SG_USING_STD(string); - SG_USING_STD(ostream); - SG_USING_STD(istream); - SG_USING_STD(cerr); - SG_USING_STD(cout); - SG_USING_STD(endl); -// SG_USING_STD(sqrt); -#else -# include -# if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740) -# include -# include -# include -# else -# include -# include -# if defined(sgi) && !defined(__GNUC__) -# include -# else -# include -# endif - using std::ostream; - using std::istream; - using std::cerr; - using std::cout; - using std::endl; - using std::sqrt; -# endif - using std::string; -#endif - -#include "FGJSBBase.h" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINITIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#define ID_COLUMNVECTOR3 "$Id$" - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FORWARD DECLARATIONS -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -namespace JSBSim { - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DOCUMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -/** This class implements a 3 dimensional vector. - @author Jon S. Berndt, Tony Peden, et. al. - @version $Id$ -*/ - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -class FGColumnVector3 : public FGJSBBase -{ -public: - /** Default initializer. - Create a zero vector. */ - FGColumnVector3(void); - - /** Initialization by given values. - @param X value of the x-conponent. - @param Y value of the y-conponent. - @param Z value of the z-conponent. - Create a vector from the doubles given in the arguments. */ - FGColumnVector3(double X, double Y, double Z) { - data[0] = X; - data[1] = Y; - data[2] = Z; - Debug(0); - } - - /** Copy constructor. - @param v Vector which is used for initialization. - Create copy of the vector given in the argument. */ - FGColumnVector3(const FGColumnVector3& v) { - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = v.data[2]; - Debug(0); - } - - /// Destructor. - ~FGColumnVector3(void) { Debug(1); } - - /** Read access the entries of the vector. - @param idx the component index. - Return the value of the matrix entry at the given index. - Indices are counted starting with 1. - Note that the index given in the argument is unchecked. */ - double operator()(unsigned int idx) const { return Entry(idx); } - - /** Write access the entries of the vector. - @param idx the component index. - Return a reference to the vector entry at the given index. - Indices are counted starting with 1. - Note that the index given in the argument is unchecked. */ - double& operator()(unsigned int idx) { return Entry(idx); } - - /** Read access the entries of the vector. - @param idx the component index. - Return the value of the matrix entry at the given index. - Indices are counted starting with 1. - This function is just a shortcut for the @ref double - operator()(unsigned int idx) const function. It is - used internally to access the elements in a more convenient way. - Note that the index given in the argument is unchecked. */ - double Entry(unsigned int idx) const { return data[idx-1]; } - - /** Write access the entries of the vector. - @param idx the component index. - Return a reference to the vector entry at the given index. - Indices are counted starting with 1. - This function is just a shortcut for the @ref double& - operator()(unsigned int idx) function. It is - used internally to access the elements in a more convenient way. - Note that the index given in the argument is unchecked. */ - double& Entry(unsigned int idx) { return data[idx-1]; } - - /** Prints the contents of the vector - @param delimeter the item separator (tab or comma) - @return a string with the delimeter-separated contents of the vector */ - string Dump(string delimeter) const; - - /** Assignment operator. - @param b source vector. - Copy the content of the vector given in the argument into *this. */ - FGColumnVector3& operator=(const FGColumnVector3& b) { - data[0] = b.data[0]; - data[1] = b.data[1]; - data[2] = b.data[2]; - return *this; - } - - /** Comparison operator. - @param b other vector. - Returns true if both vectors are exactly the same. */ - bool operator==(const FGColumnVector3& b) const { - return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2]; - } - - /** Comparison operator. - @param b other vector. - Returns false if both vectors are exactly the same. */ - bool operator!=(const FGColumnVector3& b) const { return ! operator==(b); } - - /** Multiplication by a scalar. - @param scalar scalar value to multiply the vector with. - @return The resulting vector from the multiplication with that scalar. - Multiply the vector with the scalar given in the argument. */ - FGColumnVector3 operator*(const double scalar) const { - return FGColumnVector3(scalar*Entry(1), scalar*Entry(2), scalar*Entry(3)); - } - - /** Multiply by 1/scalar. - @param scalar scalar value to devide the vector through. - @return The resulting vector from the division through that scalar. - Multiply the vector with the 1/scalar given in the argument. */ - FGColumnVector3 operator/(const double scalar) const; - - /** Cross product multiplication. - @param v vector to multiply with. - @return The resulting vector from the cross product multiplication. - Compute and return the cross product of the current vector with - the given argument. */ - FGColumnVector3 operator*(const FGColumnVector3& V) const { - return FGColumnVector3( Entry(2) * V(3) - Entry(3) * V(2), - Entry(3) * V(1) - Entry(1) * V(3), - Entry(1) * V(2) - Entry(2) * V(1) ); - } - - /// Addition operator. - FGColumnVector3 operator+(const FGColumnVector3& B) const { - return FGColumnVector3( Entry(1) + B(1), Entry(2) + B(2), Entry(3) + B(3) ); - } - - /// Subtraction operator. - FGColumnVector3 operator-(const FGColumnVector3& B) const { - return FGColumnVector3( Entry(1) - B(1), Entry(2) - B(2), Entry(3) - B(3) ); - } - - /// Subtract an other vector. - FGColumnVector3& operator-=(const FGColumnVector3 &B) { - Entry(1) -= B(1); - Entry(2) -= B(2); - Entry(3) -= B(3); - return *this; - } - - /// Add an other vector. - FGColumnVector3& operator+=(const FGColumnVector3 &B) { - Entry(1) += B(1); - Entry(2) += B(2); - Entry(3) += B(3); - return *this; - } - - /// Scale by a scalar. - FGColumnVector3& operator*=(const double scalar) { - Entry(1) *= scalar; - Entry(2) *= scalar; - Entry(3) *= scalar; - return *this; - } - - /// Scale by a 1/scalar. - FGColumnVector3& operator/=(const double scalar); - - void InitMatrix(void) { data[0] = data[1] = data[2] = 0.0; } - void InitMatrix(double a) { data[0] = data[1] = data[2] = a; } - void InitMatrix(double a, double b, double c) { - data[0]=a; data[1]=b; data[2]=c; - } - - /** Length of the vector. - Compute and return the euclidean norm of this vector. */ - double Magnitude(void) const; - - /** Length of the vector in a coordinate axis plane. - Compute and return the euclidean norm of this vector projected into - the coordinate axis plane idx1-idx2. */ - double Magnitude(int idx1, int idx2) const { - return sqrt( Entry(idx1)*Entry(idx1) + Entry(idx2)*Entry(idx2) ); - } - - /** Normalize. - Normalize the vector to have the Magnitude() == 1.0. If the vector - is equal to zero it is left untouched. */ - FGColumnVector3& Normalize(void); - - // ??? Is this something sensible ?? - FGColumnVector3 multElementWise(const FGColumnVector3& V) const; - - // little trick here. - struct AssignRef { - AssignRef(FGColumnVector3& r, int i) : Ref(r), idx(i) {} - AssignRef operator<<(const double ff) { - Ref.Entry(idx) = ff; - return AssignRef(Ref, idx+1); - } - FGColumnVector3& Ref; - int idx; - }; - AssignRef operator<<(const double ff) { - Entry(1) = ff; - return AssignRef(*this, 2); - } - -private: - double data[3]; - - void Debug(int from); -}; - -/** Scalar multiplication. - @param scalar scalar value to multiply with. - @param A Vector to multiply. - Multiply the Vector with a scalar value.*/ -inline FGColumnVector3 operator*(double scalar, const FGColumnVector3& A) { - // use already defined operation. - return A*scalar; -} - -/** Write vector to a stream. - @param os Stream to write to. - @param M Matrix to write. - Write the matrix to a stream.*/ -ostream& operator<<(ostream& os, const FGColumnVector3& col); - -} // namespace JSBSim - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif diff --git a/src/FDM/JSBSim/FGConfigFile.cpp b/src/FDM/JSBSim/FGConfigFile.cpp deleted file mode 100644 index 4502e51e3..000000000 --- a/src/FDM/JSBSim/FGConfigFile.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Header: FGConfigFile.h - Author: Jon Berndt - Date started: 03/29/00 - Purpose: Config file read-in class - Called by: FGAircraft - -FUNCTIONAL DESCRIPTION --------------------------------------------------------------------------------- - -HISTORY --------------------------------------------------------------------------------- -03/16/2000 JSB Created - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -INCLUDES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FGConfigFile.h" -#include -#include - -namespace JSBSim { - -static const char *IdSrc = "$Id$"; -static const char *IdHdr = ID_CONFIGFILE; - -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS IMPLEMENTATION -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - -FGConfigFile::FGConfigFile(string cfgFileName) -{ -#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) - cfgfile.open(cfgFileName.c_str(), ios::in ); -#else - cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary ); -#endif - CommentsOn = false; - CurrentIndex = 0; - Opened = true; -#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) - if (!cfgfile.fail() && !cfgfile.eof()) GetNextConfigLine(); -#else - if (cfgfile.is_open()) GetNextConfigLine(); -#endif - else Opened = false; - - Debug(0); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -FGConfigFile::~FGConfigFile() -{ - cfgfile.close(); - Debug(1); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -string FGConfigFile::GetNextConfigLine(void) -{ - int comment_starts_at; - int comment_ends_at; - int comment_length; - int line_length; - bool start_comment, end_comment; - string CommentStringTemp; - - do { - CurrentLine = GetLine(); - line_length = CurrentLine.length(); - comment_starts_at = CurrentLine.find(""); - - if (comment_ends_at >= 0) end_comment = true; - else end_comment = false; - - if (!start_comment && !end_comment) { // command comment - if (CommentsOn) CommentStringTemp = CurrentLine; - CommentString += CommentStringTemp + "\r\n"; - } else if (start_comment && comment_ends_at > comment_starts_at) { // - CommentsOn = false; - comment_length = comment_ends_at + 2 - comment_starts_at + 1; - LineComment = CurrentLine.substr(comment_starts_at+4, comment_length-4-3); - CurrentLine.erase(comment_starts_at, comment_length); - if (CurrentLine.find_first_not_of(" ") == string::npos) { - CurrentLine.erase(); - } - } else if ( start_comment && !end_comment) { // - CommentsOn = false; - comment_length = comment_ends_at + 2 + 1; - CommentStringTemp = CurrentLine.substr(0, comment_length-4); - CommentString += CommentStringTemp + "\r\n"; - CurrentLine.erase(0, comment_length); - } else if (start_comment && comment_ends_at < comment_starts_at) { // --> command