public static double GetCy(CalculationVector u)
        {
            var    cx  = GetCx(u);
            var    mah = u.Mah;
            double cya;

            if (mah <= 0.25)
            {
                cya = 2.8;
            }
            else if (mah <= 1.1)
            {
                cya = 2.8 + 0.447 * (mah - 0.25);
            }
            else if (mah <= 1.6)
            {
                cya = 3.18 - 0.660 * (mah - 1.1);
            }
            else if (mah <= 3.6)
            {
                cya = 2.85 + 0.350 * (mah - 1.6);
            }
            else
            {
                cya = 3.55;
            }
            return((cya - cx) * u.Alpha);
        }
 private static double GetVelocityDx(CalculationVector u)
 {
     return((1.0 / GetMass(u.CurrentTime)) *
            ((GetThrust(u.CurrentTime) -
              Math.Pow(u.Velocity, 2.0) * Atmosphere.GetDensity(u.Radius - RadiusOfEarth) / 2.0 * GetCx(u) * Surf) *
             Math.Cos(u.Alpha) -
             GetCy(u) * Math.Sin(u.Alpha) * Atmosphere.GetDensity(u.Radius - RadiusOfEarth) * Math.Pow(u.Velocity, 2.0) /
             2.0 * Surf) - GetG(u) * Math.Sin(u.Tetta));
 }
Beispiel #3
0
        public void RunRungeKutta()
        {
            results.Clear();
            calculationVector        = new CalculationVector();
            calculationVector.Tetta  = Math.PI / 2;
            calculationVector.Radius = CalculationVector.RadiusOfEarth;
            var bw = new BackgroundWorker();

            bw.DoWork             += DoWork;
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
 private static double GetTettaDx(CalculationVector u)
 {
     if (Math.Abs(u.Velocity) <= 0.5)
     {
         return(0);
     }
     return((1.0 / (GetMass(u.CurrentTime) * u.Velocity)) *
            ((GetThrust(u.CurrentTime) -
              Atmosphere.GetDensity(u.Radius - RadiusOfEarth) * Math.Pow(u.Velocity, 2.0) / 2.0 * Surf * GetCx(u)) *
             Math.Sin(u.Alpha) +
             Atmosphere.GetDensity(u.Radius - RadiusOfEarth) * Math.Pow(u.Velocity, 2.0) / 2.0 * Surf * GetCy(u) *
             Math.Cos(u.Alpha)) -
            Math.Cos(u.Tetta) * (GetG(u) / u.Velocity - u.Velocity / u.Radius));
 }
        public static double GetCx(CalculationVector u)
        {
            var mah = u.Mah;

            if (mah <= 0.8)
            {
                return(0.29);
            }
            if (mah <= 1.068)
            {
                return(mah - 0.51);
            }
            return(0.089 + 0.5 / mah);
        }
        public static CalculationVector F(CalculationVector u, double t)
        {
            var calculationVector = new CalculationVector
            {
                Velocity    = GetVelocityDx(u),
                Tetta       = GetTettaDx(u),
                Radius      = GetRadiusDx(u),
                Hi          = GetHiDx(u),
                CurrentTime = t,
                Alpha       = 0
            };

            calculationVector.Mah = calculationVector.Velocity / Atmosphere.GetSoundVelocity(calculationVector.Radius - RadiusOfEarth);
            return(calculationVector);
        }
        public static CalculationVector operator *(CalculationVector b, double a)
        {
            var opMultiply = new CalculationVector
            {
                Alpha       = a * b.Alpha,
                CurrentTime = a * b.CurrentTime,
                Hi          = a * b.Hi,
                Radius      = a * b.Radius,
                Tetta       = a * b.Tetta,
                Velocity    = a * b.Velocity,
            };

            opMultiply.Mah = opMultiply.Velocity / Atmosphere.GetSoundVelocity(opMultiply.Radius - RadiusOfEarth);
            return(opMultiply);
        }
        public static CalculationVector operator -(CalculationVector a, CalculationVector b)
        {
            var opSubtraction = new CalculationVector
            {
                Alpha       = a.Alpha - b.Alpha,
                CurrentTime = a.CurrentTime - b.CurrentTime,
                Hi          = a.Hi - b.Hi,
                Radius      = a.Radius - b.Radius,
                Tetta       = a.Tetta - b.Tetta,
                Velocity    = a.Velocity - b.Velocity,
            };

            opSubtraction.Mah = opSubtraction.Velocity / Atmosphere.GetSoundVelocity(opSubtraction.Radius - RadiusOfEarth);
            return(opSubtraction);
        }
        public static CalculationVector operator +(CalculationVector a, CalculationVector b)
        {
            var opAddition = new CalculationVector
            {
                Alpha       = a.Alpha + b.Alpha,
                CurrentTime = a.CurrentTime + b.CurrentTime,
                Hi          = a.Hi + b.Hi,
                Radius      = a.Radius + b.Radius,
                Tetta       = a.Tetta + b.Tetta,
                Velocity    = a.Velocity + b.Velocity
            };

            opAddition.Mah = opAddition.Velocity / Atmosphere.GetSoundVelocity(opAddition.Radius - RadiusOfEarth);
            return(opAddition);
        }
        public static CalculationVector GetNewStep(CalculationVector u, double dt)
        {
            var t      = u.CurrentTime;
            var k1     = F(u, t) * dt;
            var k2     = F(u + 0.5 * k1, t + 0.5 * dt) * dt;
            var k3     = F(u + 0.5 * k2, t + 0.5 * dt) * dt;
            var k4     = F(u + k3, t + dt) * dt;
            var result = u + 1.0 / 6.0 * (k1 + 2.0 * k2 + 2.0 * k3 + k4);

            result.CurrentTime  = t + dt;
            result.Phi          = GetPhi(result.CurrentTime);
            result.Alpha        = GetAlpha(result);
            result.Massa        = GetMass(result.CurrentTime);
            result.Acceleration = (result.Velocity - u.Velocity) / dt;
            result.Density      = Atmosphere.GetDensity(result.Radius - RadiusOfEarth);
            return(result);
        }
Beispiel #11
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            var step           = calculationVector;
            var phiStart       = initialParams.Phi1;
            var deltaPhi       = 0.1 * 3.141592654 / 180.0;
            var resultAltitude = 0.0;
            var resultVelocity = 0.0;
            var deltaTime      = -10.0;
            var resultPhi      = 0.0;
            var neededVelocyty = Math.Sqrt(CalculationVector.G0 * Math.Pow(CalculationVector.RadiusOfEarth, 2) / (250000.0 + CalculationVector.RadiusOfEarth));

            while (Math.Abs(resultVelocity - neededVelocyty) > 0.1)
            {
                results.Clear();
                while (Math.Abs(resultAltitude - 250.0) > 0.1)
                {
                    results.Clear();
                    while (step.CurrentTime < initialParams.TimeSumm)
                    {
                        results.Add(step);
                        var dtCorrected = step.Velocity * dt < 10 ? dt : 10 / step.Velocity;
                        step = CalculationVector.GetNewStep(step, dtCorrected);
                    }
                    var newResult = (results.Last().Radius - CalculationVector.RadiusOfEarth) / 1000.0;
                    if (resultAltitude < 1.0)
                    {
                    }
                    else
                    {
                        var deltaOld = Math.Abs(resultAltitude - 250.0);
                        var deltaNew = Math.Abs(newResult - 250.0);
                        var singn    = deltaOld / deltaNew > 1 ? 1.0 : -1.0;
                        deltaPhi = singn * deltaPhi * deltaNew / Math.Abs(deltaOld - deltaNew);
                        if (Math.Abs(deltaPhi) > 10.0 * Math.PI / 180)
                        {
                            deltaPhi = Math.Abs(deltaPhi) / deltaPhi * 10.0 * Math.PI / 180;
                        }
                    }
                    initialParams.Phi1 -= deltaPhi;
                    SetInitParams(initialParams, dt);
                    step           = calculationVector;
                    resultAltitude = newResult;
                }
                var newVelocity = results.Last().Velocity;
                if (resultVelocity < 1.0)
                {
                }
                else
                {
                    var deltaOld = Math.Abs(resultVelocity - neededVelocyty);
                    var deltaNew = Math.Abs(newVelocity - neededVelocyty);
                    if (Math.Abs(deltaOld - deltaNew) > 1.0)
                    {
                        var singn = deltaOld / deltaNew > 1 ? 1.0 : -1.0;
                        deltaTime = singn * deltaTime * deltaNew / Math.Abs(deltaOld - deltaNew);
                        if (Math.Abs(deltaTime) > 30.0)
                        {
                            deltaTime = Math.Abs(deltaTime) / deltaTime * 30.0;
                        }
                    }
                }
                initialParams.Phi1Time -= deltaTime;
                resultPhi          = initialParams.Phi1;
                initialParams.Phi1 = phiStart;
                SetInitParams(initialParams, dt);
                step           = calculationVector;
                resultVelocity = newVelocity;
                resultAltitude = 0.0;
                deltaPhi       = 0.1 * 3.141592654 / 180.0;
            }
            initialParams.Phi1 = resultPhi;
        }
 public static double GetG(CalculationVector u)
 {
     return(G0 * RadiusOfEarth * RadiusOfEarth / (u.Radius * u.Radius));
 }
 private static double GetRadiusDx(CalculationVector calculationVector)
 {
     return(calculationVector.Velocity * Math.Sin(calculationVector.Tetta));
 }
 private static double GetHiDx(CalculationVector calculationVector)
 {
     return(calculationVector.Velocity / calculationVector.Radius * Math.Cos(calculationVector.Tetta));
 }
 private static double GetAlpha(CalculationVector u)
 {
     return(GetPhi(u.CurrentTime) - u.Tetta + u.Hi);
 }