Exemplo n.º 1
0
 public SATModel(double t0, double t1, double h, KeplerElements elements)
 {
     this.t0           = t0;
     this.t1           = t1;
     SamplingIncrement = h;
     gsX0 = Converter.OscToVec(elements);
 }
Exemplo n.º 2
0
        public static TMatrix TransformMatrix(KeplerElements elements)
        {
            var A = new double[3, 3];
            var u = elements.оmega + elements.v;

            A[0, 0] = Math.Cos(u) * Math.Cos(elements.lgNode) - Math.Sin(u) * Math.Sin(elements.lgNode) * Math.Cos(elements.i);
            A[0, 1] = -Math.Sin(u) * Math.Cos(elements.lgNode) - Math.Cos(u) * Math.Sin(elements.lgNode) * Math.Cos(elements.i);
            A[0, 2] = Math.Sin(elements.lgNode) * Math.Sin(elements.i);
            A[1, 0] = Math.Cos(u) * Math.Sin(elements.lgNode) + Math.Sin(u) * Math.Cos(elements.lgNode) * Math.Cos(elements.i);
            A[1, 1] = -Math.Sin(u) * Math.Sin(elements.lgNode) + Math.Cos(u) * Math.Cos(elements.lgNode) * Math.Cos(elements.i);
            A[1, 2] = -Math.Cos(elements.lgNode) * Math.Sin(elements.i);
            A[2, 0] = Math.Sin(u) * Math.Sin(elements.i);
            A[2, 1] = Math.Cos(u) * Math.Sin(elements.i);
            A[2, 2] = Math.Cos(elements.i);
            return(new TMatrix(A));
        }
Exemplo n.º 3
0
        public static TVector OscToVec(KeplerElements elements)
        {
            var     A    = TransformMatrix(elements);
            var     p    = elements.a * (1 - Math.Pow(elements.ecc, 2));
            TVector bufR = new TVector(new double[] {
                p / (1 + elements.ecc * Math.Cos(elements.v))
                , 0
                , 0
            });
            TVector bufV = new TVector(new double[] {
                Math.Sqrt(mu / p) * elements.ecc * Math.Sin(elements.v)
                , Math.Sqrt(mu / p) * (1 + elements.ecc * Math.Cos(elements.v))
                , 0
            });
            var r = A * bufR;
            var v = A * bufV;

            return(new TVector(r.Vector.Concat(v.Vector).ToArray()));
        }
Exemplo n.º 4
0
        private void buttonRun_Click(object sender, EventArgs e)
        {
            double time = Double.Parse(textBoxTime.Text);
            double dt   = Double.Parse(textBoxDt.Text);
            Func <double, double> gradtorad = grad => grad * Math.PI / 180;
            KeplerElements        InitElement;

            switch (modelBox.SelectedIndex)
            {
            case 0:
                model = new EarthModel(0, time, dt);
                break;

            case 1:
                model = new MoonModel(0, time, dt);
                break;

            case 2:
                InitElement = new KeplerElements(Double.Parse(textSemiMajorAxis.Text),
                                                 Double.Parse(textBoxEcc.Text),
                                                 gradtorad(Double.Parse(textBoxArgPer.Text)),
                                                 gradtorad(Double.Parse(textBoxTrueAnomaly.Text)),
                                                 gradtorad(Double.Parse(textBoxInclination.Text)),
                                                 gradtorad(Double.Parse(textBoxAscNode.Text)));
                model = new SATModel(0, time, dt, InitElement);
                break;

            case 3:
                model = new TestModel(0, time, dt);
                break;

            case 4:
                InitElement = new KeplerElements(Double.Parse(textSemiMajorAxis.Text),
                                                 Double.Parse(textBoxEcc.Text),
                                                 gradtorad(Double.Parse(textBoxArgPer.Text)),
                                                 gradtorad(Double.Parse(textBoxTrueAnomaly.Text)),
                                                 gradtorad(Double.Parse(textBoxInclination.Text)),
                                                 gradtorad(Double.Parse(textBoxAscNode.Text)));
                model = new SATModel(0, time, dt, InitElement);

                break;
            }


            TIntegrator integrator = null;

            switch (integratorBox.SelectedIndex)
            {
            case 0:
                integrator = new Eiler();
                break;

            case 1:
                integrator = new RungeKutta();
                break;

            case 2:
                integrator = new TDormanPrince();
                break;

            default:
                integrator = new TDormanPrince();
                break;
            }
            if (modelBox.SelectedIndex == 4)
            {
                Model modelWithDec = null;
                if (checkBoxSolar.Checked)
                {
                    modelWithDec = new SolarDecorator(model, 0, time, dt);
                }
                if (checkBoxLunar.Checked)
                {
                    modelWithDec = new LunarDecorator(model, 0, time, dt);
                }
                integrator.Run(modelWithDec);
                modelWithDec.CloseFile();
                boxAxisY.Items.AddRange(new string[] { "dx", "dy", "dz" });
            }
            else
            {
                if (checkBoxSolar.Checked)
                {
                    model = new SolarDecorator(model, 0, time, dt);
                }
                if (checkBoxLunar.Checked)
                {
                    model = new LunarDecorator(model, 0, time, dt);
                }
            }
            integrator.Run(model);
            model.CloseFile();
            UpdateComboBox();
        }