Пример #1
0
        public override ISimulation <RocketSimulationMoment> GenerateSimulation(double t1, double t2)
        {
            double burnTime = t1 + _propellantMass / _massLossRate;

            var xa = new IntervalIndexer <Func <double, double> >();

            xa.AddInterval((Endpoints.Closed(t1), Endpoints.Closed(burnTime)),
                           (t) => RocketAEquation(t, t1));
            xa.AddInterval((Endpoints.Open(burnTime), Endpoints.Unbounded),
                           (t) => 0);

            var xv = new IntervalIndexer <Func <double, double> >();

            xv.AddInterval((Endpoints.Closed(t1), Endpoints.Closed(burnTime)),
                           (t) => RocketVEquation(t, t1));
            xv.AddInterval((Endpoints.Open(burnTime), Endpoints.Unbounded),
                           (t) => RocketVEquation(burnTime, t1));

            var x = new IntervalIndexer <Func <double, double> >();

            x.AddInterval((Endpoints.Closed(t1), Endpoints.Closed(burnTime)),
                          (t) => RocketXEquation(t, t1));
            x.AddInterval((Endpoints.Open(burnTime), Endpoints.Unbounded),
                          (t) => RocketXEquation(burnTime, t1) + RocketVEquation(burnTime, t1) * (t - burnTime));

            return(new RocketSimulation(_baseMass, _propellantMass, _massLossRate, burnTime, xa, xv, x));
        }
 public AngularMomentumSimulation(SpecificMassEllipse disk, IntervalIndexer <Polynomial> omegat, IntervalIndexer <Polynomial> anglet, IntervalIndexer <Polynomial> vt, IntervalIndexer <Polynomial> xt)
 {
     _disk   = disk;
     _omegat = omegat;
     _anglet = anglet;
     _vt     = vt;
     _xt     = xt;
 }
Пример #3
0
 public RocketSimulation(double baseMass, double fuelMass, double changeOfMassRate, double burnTime,
                         IntervalIndexer <Func <double, double> > ya, IntervalIndexer <Func <double, double> > yv, IntervalIndexer <Func <double, double> > y)
 {
     _baseMass         = baseMass;
     _fuelMass         = fuelMass;
     _changeOfMassRate = changeOfMassRate;
     _burnTime         = burnTime;
     _ya = ya;
     _yv = yv;
     _y  = y;
 }
Пример #4
0
        private void UpdateEquations(IntervalIndexer <Polynomial> equations,
                                     Interval timeInterval,
                                     InitialMovementParameters updatedEquation)
        {
            var pol = GetPolynomialMovementEquation(
                updatedEquation.A0,
                updatedEquation.V0,
                updatedEquation.D0,
                updatedEquation.T0);


            equations.AddInterval(
                (timeInterval.LowerEndpoint, timeInterval.UpperEndpoint),
                pol);
        }
Пример #5
0
 public MovementEquation(InitialMovementParameters x, InitialMovementParameters y)
 {
     _xEquations = new IntervalIndexer <Polynomial>();
     UpdateXEquations(new Interval()
     {
         LowerEndpoint = Endpoints.Unbounded,
         UpperEndpoint = Endpoints.Unbounded
     }, x);
     _yEquations = new IntervalIndexer <Polynomial>();
     UpdateYEquations(new Interval()
     {
         LowerEndpoint = Endpoints.Unbounded,
         UpperEndpoint = Endpoints.Unbounded
     }, y);
 }
        public override ISimulation <AngularMomentumSimulationMoment> GenerateSimulation(double t1, double t2)
        {
            var(massByR, radius) = (_disc.SpecificMassByR, _disc.Radius);

            var momentOfInertiaByR = massByR * new Polynomial(0, 0, 1);
            var momentOfInertia    = momentOfInertiaByR.DefiniteIntegral(radius);

            var angularAcceleration = (_force * radius) / momentOfInertia;

            var angleOverTime = (new Polynomial(angularAcceleration)).AntiDerivative(_angularVel0).AntiDerivative();
            var anglet        = new IntervalIndexer <Polynomial>();

            anglet.AddInterval((Endpoints.Closed(t1), Endpoints.Closed(t2)), angleOverTime);

            var defaultIndexer = new IntervalIndexer <Polynomial>(new Polynomial());

            return(new AngularMomentumSimulation(_disc, defaultIndexer, anglet, defaultIndexer, defaultIndexer));
        }
Пример #7
0
 public MovementEquation(IntervalIndexer <Polynomial> xEquations, IntervalIndexer <Polynomial> yEquations)
 {
     _xEquations = xEquations;
     _yEquations = yEquations;
 }
        public override ISimulation <AngularMomentumSimulationMoment> GenerateSimulation(double t1, double t2)
        {
            var vt     = new IntervalIndexer <Polynomial>();
            var xt     = new IntervalIndexer <Polynomial>();
            var omegat = new IntervalIndexer <Polynomial>();
            var anglet = new IntervalIndexer <Polynomial>();

            var v     = new Polynomial(_v0);
            var omega = new Polynomial(_omega0);

            var vOnSurface = v + omega * _disk.Radius;

            var t = t1;

            var vOnSurface0 = vOnSurface.Evaluate(t);

            // There's friction that acts on the disk
            if (vOnSurface0.CompareTo(0, 6e-5) != 0)
            {
                var circumferenceByR = new Polynomial(0, 2 * System.Math.PI);
                var tMass            = (circumferenceByR * _disk.SpecificMassByR).DefiniteIntegral(_disk.Radius);
                var rSquared         = new Polynomial(0, 0, 1);
                var iZ       = ((circumferenceByR * _disk.SpecificMassByR) * rSquared).DefiniteIntegral(_disk.Radius);
                var friction = (-System.Math.Sign(vOnSurface0)) * (_coOfKineticFriction * tMass * g0);

                var torque = _disk.Radius * friction;
                var angularAcceleration = torque / iZ;
                omega = (new Polynomial(angularAcceleration)).AntiDerivative(_omega0);

                var a = friction / tMass;
                v = (new Polynomial(a)).AntiDerivative(_v0);

                vOnSurface = v + omega * _disk.Radius;

                var tf = t2;
                try
                {
                    tf = vOnSurface.Roots(0, t1, t2).First();
                }
                catch (InvalidOperationException)
                {
                }

                var slipInterval = (Endpoints.Closed(t), Endpoints.Open(tf));

                vt.AddInterval(slipInterval, v);
                xt.AddInterval(slipInterval, v.AntiDerivative());
                omegat.AddInterval(slipInterval, omega);
                anglet.AddInterval(slipInterval, omega.AntiDerivative());

                t = tf;
            }

            if (t < t2)
            {
                var noSlipInterval = (Endpoints.Closed(t), Endpoints.Unbounded);

                vt.AddInterval(
                    noSlipInterval,
                    new Polynomial(v.Evaluate(t))
                    );
                xt.AddInterval(
                    noSlipInterval,
                    new Polynomial(v.AntiDerivative().Evaluate(t), v.Evaluate(t))
                    .Offset(-t)
                    );

                omegat.AddInterval(
                    noSlipInterval,
                    new Polynomial(omega.Evaluate(t))
                    );
                anglet.AddInterval(
                    noSlipInterval,
                    new Polynomial(omega.AntiDerivative().Evaluate(t), omega.Evaluate(t))
                    .Offset(-t)
                    );
            }

            return(new AngularMomentumSimulation(_disk, omegat, anglet, vt, xt));
        }