diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp index dcaa9d43c..e53df6a81 100644 --- a/src/FDM/JSBSim/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/FGAtmosphere.cpp @@ -89,7 +89,8 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0; // turbType = ttNone; - turbType = ttBerndt; + turbType = ttStandard; +// turbType = ttBerndt; TurbGain = 0.0; bind(); @@ -261,6 +262,53 @@ void FGAtmosphere::Calculate(double altitude) void FGAtmosphere::Turbulence(void) { switch (turbType) { + case ttStandard: { + vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX)); + vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX)); + vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX)); + + + MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude; + MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt(); + Magnitude += MagnitudeAccel*rate*State->Getdt(); + + vDirectiondAccelDt.Normalize(); + vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt(); + vDirectionAccel.Normalize(); + vDirection += vDirectionAccel*rate*State->Getdt(); + + vDirection.Normalize(); + + // Diminish turbulence within three wingspans + // of the ground + vTurbulence = TurbGain*Magnitude * vDirection; + double HOverBMAC = Position->GetHOverBMAC(); + if (HOverBMAC < 3.0) + vTurbulence *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0); + + vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection; + + vBodyTurbGrad = State->GetTl2b()*vTurbulenceGrad; + vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan(); +// if (Aircraft->GetHTailArm() != 0.0) +// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm(); +// else +// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0; + + if (Aircraft->GetVTailArm()) + vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm(); + else + vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0; + + // Clear the horizontal forces + // actually felt by the plane, now + // that we've used them to calculate + // moments. + vTurbulence(eX) = 0.0; + vTurbulence(eY) = 0.0; + + break; + } case ttBerndt: { vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX)); vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX)); diff --git a/src/FDM/JSBSim/FGAtmosphere.h b/src/FDM/JSBSim/FGAtmosphere.h index 4290f1714..d70526426 100644 --- a/src/FDM/JSBSim/FGAtmosphere.h +++ b/src/FDM/JSBSim/FGAtmosphere.h @@ -161,7 +161,7 @@ public: private: double rho; - enum tType {ttBerndt, ttNone} turbType; + enum tType {ttStandard, ttBerndt, ttNone} turbType; int lastIndex; double h;