1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Module: FGFactorGroup.cpp
6 Purpose: Encapsulates coefficients in the mathematical construct:
7 factor*(coeff1 + coeff2 + coeff3 + ... + coeffn)
8 Called by: FGAerodynamics
10 ------------- Copyright (C) 2001 Tony Peden (apeden@earthlink.net) -----------
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24 Place - Suite 330, Boston, MA 02111-1307, USA.
26 Further information about the GNU General Public License can also be found on
27 the world wide web at http://www.gnu.org.
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
31 This class models the stability derivative coefficient lookup tables or
32 equations. Note that the coefficients need not be calculated each delta-t.
34 Note that the values in a row which index into the table must be the same value
35 for each column of data, so the first column of numbers for each altitude are
36 seen to be equal, and there are the same number of values for each altitude.
38 See the header file FGFactorGroup.h for the values of the identifiers.
41 --------------------------------------------------------------------------------
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #include "FGCoefficient.h"
49 #include "FGFactorGroup.h"
51 #include "FGFDMExec.h"
59 extern short debug_lvl;
61 static const char *IdSrc = "$Id$";
62 static const char *IdHdr = ID_FACTORGROUP;
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex) {
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74 FGFactorGroup::~FGFactorGroup() {
76 for (i=0; i<sum.size(); i++) {
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83 bool FGFactorGroup::Load(FGConfigFile *AC_cfg) {
87 name = AC_cfg->GetValue("NAME");
88 AC_cfg->GetNextConfigLine();
89 *AC_cfg >> description;
90 token = AC_cfg->GetValue();
91 if( token == "FACTOR") {
92 FGCoefficient::Load(AC_cfg);
93 //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
95 token = AC_cfg->GetValue();
96 while ( token != "/GROUP" ) {
97 sum.push_back( new FGCoefficient(FDMExec) );
98 sum.back()->Load(AC_cfg);
99 //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
100 token = AC_cfg->GetValue();
102 AC_cfg->GetNextConfigLine();
109 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
111 float FGFactorGroup::TotalValue(void) {
115 for(i=0;i<sum.size();i++) {
116 totalsum+=sum[i]->TotalValue();
117 SDtotal += sum[i]->GetSD();
119 totalsum *= FGCoefficient::TotalValue();
120 SDtotal *= FGCoefficient::GetSD();
121 cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl;
122 cout << "FGFactorGroup::SDtotal: " << SDtotal << endl;
126 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
128 string FGFactorGroup::GetCoefficientStrings(void) {
132 CoeffStrings += name;
133 CoeffStrings += ", ";
134 CoeffStrings += FGCoefficient::Getname();
135 for(i=0;i<sum.size();i++) {
136 CoeffStrings += ", ";
137 CoeffStrings += sum[i]->Getname();
142 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
144 string FGFactorGroup::GetCoefficientValues(void) {
149 snprintf(buffer,10,"%9.6f",SDtotal);
150 values += string(buffer);
152 snprintf(buffer,10,"%9.6f",FGCoefficient::GetSD() );
153 values += string(buffer);
155 for(i=0;i<sum.size();i++) {
156 values += sum[i]->GetCoefficientValues();