From: david Date: Sun, 16 Mar 2003 21:14:45 +0000 (+0000) Subject: Added a new turbulence type ttStandard, and made it the default. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b3930c9c6054fd4a733dd625af54a175622d49f4;p=flightgear.git Added a new turbulence type ttStandard, and made it the default. ttStandard is copied from ttBerndt, with the following modifications: 1. All turbulence is diminished within three wingspans of the ground. 2. The horizontal forces are used to calculate the moments, but then zeroed out so that only the vertical force is actually applied to the aircraft. 3. The yaw moment is not used. In fact, the horizontal forces and the yaw moment should be allowed, but they are extremely rare compared to the vertical force and the pitch/roll moments. For now, simply zeroing them gives the most accurate feel. --- 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;