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

« back to all changes in this revision

Viewing changes to src/FDM/JSBSim/models/propulsion/FGTurbine.cpp

  • Committer: Package Import Robot
  • Author(s): Ove Kaaven
  • Date: 2011-09-03 22:16:12 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20110903221612-2cjy0z7ztj5nkln5
Tags: 2.4.0-1
* New upstream release. Closes: #638588.
* Build-Depend on OpenSceneGraph 3.0, and the Subversion library.
* Recommend fgfs-scenery-base.
* Enable parallel builds (shorter compile times on multicore CPUs).
* Removed hack that tried to build without optimizations if
  building with optimizations fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include <iostream>
43
43
#include <sstream>
44
44
#include "FGTurbine.h"
45
 
#include "FGState.h"
 
45
#include "FGThruster.h"
46
46
#include "models/FGPropulsion.h"
47
 
#include "FGThruster.h"
 
47
#include "models/FGAuxiliary.h"
 
48
#include "models/FGAtmosphere.h"
48
49
 
49
50
using namespace std;
50
51
 
51
52
namespace JSBSim {
52
53
 
53
 
static const char *IdSrc = "$Id$";
 
54
static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.32 2011/06/07 00:28:03 jentron Exp $";
54
55
static const char *IdHdr = ID_TURBINE;
55
56
 
56
57
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73
74
  BypassRatio = BleedDemand = 0.0;
74
75
  IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0;
75
76
  N1_spinup = 1.0; N2_spinup = 3.0; 
 
77
  EPR = 1.0;
76
78
 
77
79
  ResetToIC();
78
80
 
95
97
 
96
98
void FGTurbine::ResetToIC(void)
97
99
{
 
100
    
 
101
  FGEngine::ResetToIC();
 
102
    
98
103
  N1 = N2 = 0.0;
99
104
  N2norm = 0.0;
100
105
  correctedTSFC = TSFC;
112
117
// The main purpose of Calculate() is to determine what phase the engine should
113
118
// be in, then call the corresponding function.
114
119
 
115
 
double FGTurbine::Calculate(void)
 
120
void FGTurbine::Calculate(void)
116
121
{
117
122
  double thrust;
118
123
 
 
124
  RunPreFunctions();
 
125
 
119
126
  TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
120
127
  double qbar = Auxiliary->Getqbar();
121
 
  dt = State->Getdt() * Propulsion->GetRate();
 
128
  dt = FDMExec->GetDeltaT() * Propulsion->GetRate();
122
129
  ThrottlePos = FCS->GetThrottlePos(EngineNumber);
123
130
  if (ThrottlePos > 1.0) {
124
131
    AugmentCmd = ThrottlePos - 1.0;
145
152
 
146
153
  if (!Running && Cutoff && Starter) {
147
154
     if (phase == tpOff) phase = tpSpinUp;
148
 
     }
 
155
  }
149
156
 
150
157
  // start
151
158
  if ((Starter == true) || (qbar > 30.0)) {
169
176
    default: thrust = Off();
170
177
  }
171
178
 
172
 
  thrust = Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
 
179
  Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
173
180
 
174
 
  return thrust;
 
181
  RunPostFunctions();
175
182
}
176
183
 
177
184
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223
230
 
224
231
  if (!Augmentation) {
225
232
    correctedTSFC = TSFC * sqrt(T/389.7) * (0.84 + (1-N2norm)*(1-N2norm));
226
 
    FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000);
 
233
    FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 10000.0);
227
234
    if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF;
228
235
    NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8);
229
236
    thrust = thrust * (1.0 - BleedDemand);
353
360
 
354
361
double FGTurbine::Trim()
355
362
{
356
 
    double idlethrust, milthrust, thrust, tdiff;
 
363
    double idlethrust, milthrust, thrust, tdiff, N2, N2norm;
357
364
    idlethrust = MilThrust * IdleThrustLookup->GetValue();
358
365
    milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
359
366
    N2 = IdleN2 + ThrottlePos * N2_factor;
388
395
 
389
396
double FGTurbine::CalcFuelNeed(void)
390
397
{
391
 
  double dT = State->Getdt() * Propulsion->GetRate();
 
398
  double dT = FDMExec->GetDeltaT() * Propulsion->GetRate();
392
399
  FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr
393
400
  FuelExpended = FuelFlowRate * dT;     // Calculates fuel expended in this time step
394
401
  return FuelExpended;
473
480
      MaxThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix);
474
481
    } else if (name == "Injection") {
475
482
      InjectionLookup = new FGFunction(PropertyManager, function_element, property_prefix);
476
 
    } else {
477
 
      cerr << "Unknown function type: " << name << " in turbine definition." <<
478
 
      endl;
479
483
    }
480
484
  }
481
485
 
534
538
  PropertyManager->Tie( property_name.c_str(), &Seized);
535
539
  property_name = base_property_name + "/stalled";
536
540
  PropertyManager->Tie( property_name.c_str(), &Stalled);
 
541
  property_name = base_property_name + "/bleed-factor";
 
542
  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, &FGTurbine::GetBleedDemand, &FGTurbine::SetBleedDemand);
537
543
}
538
544
 
539
545
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
540
546
 
541
547
int FGTurbine::InitRunning(void) {
542
 
  State->SuspendIntegration();
 
548
  FDMExec->SuspendIntegration();
543
549
  Cutoff=false;
544
550
  Running=true;  
545
551
  N2=IdleN2;
546
552
  Calculate();
547
 
  State->ResumeIntegration();
 
553
  FDMExec->ResumeIntegration();
548
554
  return phase==tpRun;
549
555
}
550
556