2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
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
|
2001-06-05 20:58:48 +00:00
|
|
|
04/22/01 JSB Moved code into here from FGAircraft
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#include "FGAerodynamics.h"
|
2001-07-23 20:31:59 +00:00
|
|
|
#include "FGFactorGroup.h"
|
|
|
|
#include "FGCoefficient.h"
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
static const char *IdSrc = "$Id$";
|
2000-10-14 02:10:10 +00:00
|
|
|
static const char *IdHdr = ID_AERODYNAMICS;
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS IMPLEMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec),
|
|
|
|
vMoments(3),
|
|
|
|
vForces(3),
|
|
|
|
vFs(3),
|
|
|
|
vLastFs(3),
|
|
|
|
vDXYZcg(3)
|
2000-10-02 23:07:30 +00:00
|
|
|
{
|
2001-06-05 20:58:48 +00:00
|
|
|
Name = "FGAerodynamics";
|
|
|
|
|
|
|
|
AxisIdx["DRAG"] = 0;
|
|
|
|
AxisIdx["SIDE"] = 1;
|
|
|
|
AxisIdx["LIFT"] = 2;
|
|
|
|
AxisIdx["ROLL"] = 3;
|
|
|
|
AxisIdx["PITCH"] = 4;
|
|
|
|
AxisIdx["YAW"] = 5;
|
|
|
|
|
|
|
|
Coeff = new CoeffArray[6];
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
if (debug_lvl & 2) cout << "Instantiated: FGAerodynamics" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
FGAerodynamics::~FGAerodynamics()
|
|
|
|
{
|
2001-06-05 20:58:48 +00:00
|
|
|
unsigned int i,j;
|
|
|
|
for (i=0; i<6; i++) {
|
|
|
|
for (j=0; j<Coeff[i].size(); j++) {
|
|
|
|
delete Coeff[i][j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] Coeff;
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
if (debug_lvl & 2) cout << "Destroyed: FGAerodynamics" << endl;
|
2000-10-02 23:07:30 +00:00
|
|
|
}
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
bool FGAerodynamics::Run(void)
|
|
|
|
{
|
|
|
|
unsigned int axis_ctr,ctr;
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
if (!FGModel::Run()) {
|
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2001-11-30 17:49:37 +00:00
|
|
|
//correct signs of drag and lift to wind axes convention
|
|
|
|
//positive forward, right, down
|
|
|
|
vFs(1)*=-1; vFs(3)*=-1;
|
|
|
|
//cout << "Aircraft::vFs: " << vFs << endl;
|
2001-11-20 22:34:24 +00:00
|
|
|
vForces = State->GetTs2b()*vFs;
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
vDXYZcg(eX) = -(Aircraft->GetXYZrp(eX)
|
2001-11-12 16:06:29 +00:00
|
|
|
- MassBalance->GetXYZcg(eX))*inchtoft;
|
2001-10-05 20:19:59 +00:00
|
|
|
vDXYZcg(eY) = (Aircraft->GetXYZrp(eY)
|
2001-11-12 16:06:29 +00:00
|
|
|
- MassBalance->GetXYZcg(eY))*inchtoft;
|
2001-10-05 20:19:59 +00:00
|
|
|
vDXYZcg(eZ) = -(Aircraft->GetXYZrp(eZ)
|
2001-11-12 16:06:29 +00:00
|
|
|
- MassBalance->GetXYZcg(eZ))*inchtoft;
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
vMoments = vDXYZcg*vForces; // M = r X F
|
2001-06-05 20:58:48 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2000-10-02 23:07:30 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2001-07-10 15:56:38 +00:00
|
|
|
bool FGAerodynamics::Load(FGConfigFile* AC_cfg)
|
2000-10-02 23:07:30 +00:00
|
|
|
{
|
2001-06-05 20:58:48 +00:00
|
|
|
string token, axis;
|
|
|
|
|
|
|
|
AC_cfg->GetNextConfigLine();
|
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
while ((token = AC_cfg->GetValue()) != string("/AERODYNAMICS")) {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (token == "AXIS") {
|
|
|
|
CoeffArray ca;
|
|
|
|
axis = AC_cfg->GetValue("NAME");
|
|
|
|
AC_cfg->GetNextConfigLine();
|
2001-11-20 22:34:24 +00:00
|
|
|
while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
|
2001-07-23 20:31:59 +00:00
|
|
|
if( token == "COEFFICIENT" ) {
|
|
|
|
ca.push_back( new FGCoefficient(FDMExec) );
|
|
|
|
ca.back()->Load(AC_cfg);
|
|
|
|
} else if ( token == "GROUP" ) {
|
|
|
|
ca.push_back( new FGFactorGroup(FDMExec) );
|
|
|
|
ca.back()->Load(AC_cfg);
|
|
|
|
}
|
2001-06-05 20:58:48 +00:00
|
|
|
}
|
|
|
|
Coeff[AxisIdx[axis]] = ca;
|
|
|
|
AC_cfg->GetNextConfigLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
string FGAerodynamics::GetCoefficientStrings(void)
|
|
|
|
{
|
|
|
|
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 += ", ";
|
|
|
|
}
|
2001-07-23 20:31:59 +00:00
|
|
|
CoeffStrings += Coeff[axis][sd]->GetCoefficientStrings();
|
2001-06-05 20:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return CoeffStrings;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
string FGAerodynamics::GetCoefficientValues(void)
|
|
|
|
{
|
|
|
|
string SDValues = "";
|
|
|
|
char buffer[10];
|
|
|
|
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 += ", ";
|
|
|
|
}
|
2001-07-23 20:31:59 +00:00
|
|
|
SDValues += Coeff[axis][sd]->GetCoefficientValues();
|
2001-06-05 20:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SDValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
double FGAerodynamics::GetLoD(void)
|
2001-06-05 20:58:48 +00:00
|
|
|
{
|
2001-11-20 22:34:24 +00:00
|
|
|
double LoD;
|
2001-06-05 20:58:48 +00:00
|
|
|
|
|
|
|
if (vFs(1) != 0.00) return vFs(3)/vFs(1);
|
|
|
|
else return 0.00;
|
2000-10-02 23:07:30 +00:00
|
|
|
}
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGAerodynamics::Debug(void)
|
|
|
|
{
|
|
|
|
//TODO: Add your source code here
|
|
|
|
}
|
|
|
|
|