Esempio n. 1
0
bool FGPropulsion::Run(bool Holding)
{
  unsigned int i;

  if (FGModel::Run(Holding)) return true;
  if (Holding) return false;

  RunPreFunctions();

  vForces.InitMatrix();
  vMoments.InitMatrix();

  for (i=0; i<numEngines; i++) {
    Engines[i]->Calculate();
    ConsumeFuel(Engines[i]);
    vForces  += Engines[i]->GetBodyForces();  // sum body frame forces
    vMoments += Engines[i]->GetMoments();     // sum body frame moments
  }

  TotalFuelQuantity = 0.0;
  for (i=0; i<numTanks; i++) {
    Tanks[i]->Calculate( in.TotalDeltaT, in.TAT_c);
    if (Tanks[i]->GetType() == FGTank::ttFUEL) {
      TotalFuelQuantity += Tanks[i]->GetContents();
    }
  }

  if (refuel) DoRefuel( in.TotalDeltaT );
  if (dump) DumpFuel( in.TotalDeltaT );

  RunPostFunctions();

  return false;
}
Esempio n. 2
0
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPiston::Calculate(void)
{
  RunPreFunctions();

  if (FuelFlow_gph > 0.0) ConsumeFuel();

  Throttle = FCS->GetThrottlePos(EngineNumber);
  Mixture = FCS->GetMixturePos(EngineNumber);

  // Input values.

  p_amb = Atmosphere->GetPressure() * psftopa;
  double p = Auxiliary->GetTotalPressure() * psftopa;
  p_ram = (p - p_amb) * Ram_Air_Factor + p_amb;
  T_amb = RankineToKelvin(Atmosphere->GetTemperature());

  RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
  MeanPistonSpeed_fps =  ( RPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS

  IAS = Auxiliary->GetVcalibratedKTS();

  doEngineStartup();
  if (Boosted) doBoostControl();
  doMAP();
  doAirFlow();
  doFuelFlow();

  //Now that the fuel flow is done check if the mixture is too lean to run the engine
  //Assume lean limit at 22 AFR for now - thats a thi of 0.668
  //This might be a bit generous, but since there's currently no audiable warning of impending
  //cutout in the form of misfiring and/or rough running its probably reasonable for now.

  //  if (equivalence_ratio < 0.668)
  //    Running = false;

  doEnginePower();
  if (IndicatedHorsePower < 0.1250) Running = false;

  doEGT();
  doCHT();
  doOilTemperature();
  doOilPressure();

  if (Thruster->GetType() == FGThruster::ttPropeller) {
    ((FGPropeller*)Thruster)->SetAdvance(FCS->GetPropAdvance(EngineNumber));
    ((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
  }

  PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired();
  Thruster->Calculate(PowerAvailable);

  RunPostFunctions();
}
Esempio n. 3
0
double FGRocket::Calculate(void)
{
  double dT = State->Getdt()*Propulsion->GetRate();
  double thrust;

  if (!Flameout && !Starved) ConsumeFuel();

  PropellantFlowRate = (FuelExpended + OxidizerExpended)/dT;
  Throttle = FCS->GetThrottlePos(EngineNumber);

  // If there is a thrust table, it is a function of propellant remaining. The
  // engine is started when the throttle is advanced to 1.0. After that, it
  // burns without regard to throttle setting. The table returns a value between
  // zero and one, representing the percentage of maximum vacuum thrust being
  // applied.

  if (ThrustTable != 0L) { // Thrust table given -> Solid fuel used

    if ((Throttle == 1 || BurnTime > 0.0 ) && !Starved) {
      BurnTime += State->Getdt();
      double TotalEngineFuelAvailable=0.0;
      for (int i=0; i<(int)SourceTanks.size(); i++)
        TotalEngineFuelAvailable += Propulsion->GetTank(SourceTanks[i])->GetContents();

      VacThrust = ThrustTable->GetValue(TotalEngineFuelAvailable);
    } else {
      VacThrust = 0.0;
    }

  } else { // liquid fueled rocket assumed

    if (Throttle < MinThrottle || Starved) { // Combustion not supported

      PctPower = 0.0; // desired thrust
      Flameout = true;
      VacThrust = 0.0;

    } else { // Calculate thrust

      PctPower = Throttle / MaxThrottle; // Min and MaxThrottle range from 0.0 to 1.0, normally.
      Flameout = false;
      VacThrust = Isp * PropellantFlowRate;

    }

  } // End thrust calculations

  thrust = Thruster->Calculate(VacThrust);
  It += thrust * dT;

  return thrust;
}