~ubuntu-branches/ubuntu/precise/flightgear/precise

« back to all changes in this revision

Viewing changes to src/FDM/JSBSim/models/FGMassBalance.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ove Kaaven
  • Date: 2011-01-30 15:46:35 UTC
  • mfrom: (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110130154635-rlynmg9n5hzxq5xe
Tags: 2.0.0-3
* Recommend fgfs-aircraft-base and fgfs-models-base.
  Closes. #610276.
* Added note about scenery SharedModels.tgz to README.Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 Date started: 09/12/2000
6
6
 Purpose:      This module models weight and balance
7
7
 
8
 
 ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
8
 ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.org) --------------
9
9
 
10
10
 This program is free software; you can redistribute it and/or modify it under
11
11
 the terms of the GNU Lesser General Public License as published by the Free Software
41
41
#include "FGMassBalance.h"
42
42
#include "FGPropulsion.h"
43
43
#include "FGBuoyantForces.h"
44
 
#include <input_output/FGPropertyManager.h>
 
44
#include "input_output/FGPropertyManager.h"
 
45
#include <iostream>
 
46
#include <cstdlib>
 
47
 
 
48
using namespace std;
45
49
 
46
50
namespace JSBSim {
47
51
 
59
63
  Weight = EmptyWeight = Mass = 0.0;
60
64
 
61
65
  vbaseXYZcg.InitMatrix(0.0);
 
66
  vXYZcg.InitMatrix(0.0);
 
67
  vLastXYZcg.InitMatrix(0.0);
 
68
  vDeltaXYZcg.InitMatrix(0.0);
62
69
  baseJ.InitMatrix();
63
70
  mJ.InitMatrix();
64
71
  mJinv.InitMatrix();
85
92
{
86
93
  if (!FGModel::InitModel()) return false;
87
94
 
 
95
  vLastXYZcg.InitMatrix(0.0);
 
96
  vDeltaXYZcg.InitMatrix(0.0);
 
97
 
88
98
  return true;
89
99
}
90
100
 
96
106
  string element_name = "";
97
107
  double bixx, biyy, bizz, bixy, bixz, biyz;
98
108
 
 
109
  FGModel::Load(el); // Perform base class Load.
 
110
 
99
111
  bixx = biyy = bizz = bixy = bixz = biyz = 0.0;
100
112
  if (el->FindElement("ixx"))
101
113
    bixx = el->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2");
130
142
    element = el->FindNextElement("pointmass");
131
143
  }
132
144
 
 
145
  double ChildFDMWeight = 0.0;
 
146
  for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
 
147
    if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
 
148
  }
 
149
 
133
150
  Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
134
 
    + BuoyantForces->GetGasMass()*slugtolb;
 
151
    + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
135
152
 
136
153
  Mass = lbtoslug*Weight;
137
154
 
 
155
  FGModel::PostLoad(el);
 
156
 
138
157
  Debug(2);
139
158
  return true;
140
159
}
149
168
  if (FGModel::Run()) return true;
150
169
  if (FDMExec->Holding()) return false;
151
170
 
 
171
  RunPreFunctions();
 
172
 
 
173
  double ChildFDMWeight = 0.0;
 
174
  for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
 
175
    if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
 
176
  }
 
177
 
152
178
  Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
153
 
    + BuoyantForces->GetGasMass()*slugtolb;
 
179
    + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
154
180
 
155
181
  Mass = lbtoslug*Weight;
156
182
 
160
186
            + GetPointMassMoment()
161
187
            + BuoyantForces->GetGasMassMoment()) / Weight;
162
188
 
 
189
  // Track frame-by-frame delta CG, and move the EOM-tracked location
 
190
  // by this amount.
 
191
  if (vLastXYZcg.Magnitude() == 0.0) vLastXYZcg = vXYZcg;
 
192
  vDeltaXYZcg = vXYZcg - vLastXYZcg;
 
193
  vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
 
194
  vLastXYZcg = vXYZcg;
 
195
  Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
 
196
 
163
197
// Calculate new total moments of inertia
164
198
 
165
199
  // At first it is the base configuration inertia matrix ...
196
230
                    k2, k4, k5,
197
231
                    k3, k5, k6 );
198
232
 
 
233
  RunPostFunctions();
 
234
 
199
235
  Debug(0);
200
236
 
201
237
  return false;
313
349
}
314
350
 
315
351
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
352
 
 
353
void FGMassBalance::PointMass::bind(FGPropertyManager* PropertyManager, int num) {
 
354
  string tmp = CreateIndexedPropertyName("inertia/pointmass-weight-lbs", num);
 
355
  PropertyManager->Tie( tmp.c_str(), this, &PointMass::GetPointMassWeight,
 
356
                                       &PointMass::SetPointMassWeight);
 
357
 
 
358
  tmp = CreateIndexedPropertyName("inertia/pointmass-location-X-inches", num);
 
359
  PropertyManager->Tie( tmp.c_str(), this, eX, &PointMass::GetPointMassLocation,
 
360
                                           &PointMass::SetPointMassLocation);
 
361
  tmp = CreateIndexedPropertyName("inertia/pointmass-location-Y-inches", num);
 
362
  PropertyManager->Tie( tmp.c_str(), this, eY, &PointMass::GetPointMassLocation,
 
363
                                           &PointMass::SetPointMassLocation);
 
364
  tmp = CreateIndexedPropertyName("inertia/pointmass-location-Z-inches", num);
 
365
  PropertyManager->Tie( tmp.c_str(), this, eZ, &PointMass::GetPointMassLocation,
 
366
                                           &PointMass::SetPointMassLocation);
 
367
}
 
368
 
 
369
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316
370
//    The bitmasked value choices are as follows:
317
371
//    unset: In this case (the default) JSBSim would only print
318
372
//       out the normally expected messages, essentially echoing