static void Main0(string[] args) { // Constants const int N_Step = 720; // Maximum number of steps // Variables int i; int N_Step1; int N_Step2; double Step; double Mjd0_UTC; Geo.Algorithm.Vector Y0 = new Geo.Algorithm.Vector(6); Geo.Algorithm.Vector Kep = new Geo.Algorithm.Vector(6); ForceModelOption Aux_ref = new ForceModelOption(), Aux = new ForceModelOption(); // Auxiliary parameters double Max_J20, Max_J22, Max_J44, Max_J1010; double Max_Sun, Max_Moon, Max_SRad, Max_Drag; Geo.Algorithm.Vector[] Eph_Ref = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_J20 = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_J22 = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_J44 = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_J1010 = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_Sun = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_Moon = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_SRad = new Geo.Algorithm.Vector[N_Step + 1]; Geo.Algorithm.Vector[] Eph_Drag = new Geo.Algorithm.Vector[N_Step + 1]; // Initialize UT1-UTC and UTC-TAI time difference IERS = new IERS(-0.05, -30.00, 0.0, 0.0); // Epoch state (remote sensing satellite) Mjd0_UTC = DateUtil.DateToMjd(1999, 03, 01, 00, 00, 0.0); Kep = new Vector(7178.0e3, 0.0010, 98.57 * OrbitConsts.RadPerDeg, 0.0, 0.0, 0.0); Y0 = Kepler.State(OrbitConsts.GM_Earth, Kep, 0.0); // Model parameters Aux_ref.Mjd0_TT = Mjd0_UTC - IERS.GetTT_UTC(Mjd0_UTC) / 86400.0; Aux_ref.Area = 5.0; // [m^2] Remote sensing satellite Aux_ref.Mass = 1000.0; // [kg] Aux_ref.CoefOfRadiation = 1.3; Aux_ref.CoefOfDrag = 2.3; Aux_ref.MaxDegree = 20; Aux_ref.MaxOrder = 20; Aux_ref.EnableSun = true; Aux_ref.EnableMoon = true; Aux_ref.EnableSolarRadiation = true; Aux_ref.EnableDrag = true; // Reference orbit Step = 120.0; // [s] N_Step1 = 50; // 100 mins N_Step2 = 720; // 1 day Aux = Aux_ref; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Ref); // J2,0 perturbations Aux.MaxDegree = 2; Aux.MaxOrder = 0; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J20); // J2,2 perturbations Aux.MaxDegree = 2; Aux.MaxOrder = 2; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J22); // J4,4 perturbations Aux.MaxDegree = 4; Aux.MaxOrder = 4; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J44); // J10,10 perturbations Aux.MaxDegree = 10; Aux.MaxOrder = 10; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J1010); Aux.MaxDegree = 20; Aux.MaxOrder = 20; // Solar perturbations Aux.EnableSun = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Sun); Aux.EnableSun = true; // Lunar perturbations Aux.EnableMoon = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Moon); Aux.EnableMoon = true; // Solar radiation pressure perturbations Aux.EnableSolarRadiation = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_SRad); Aux.EnableSolarRadiation = true; // Drag perturbations Aux.EnableDrag = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Drag); Aux.EnableDrag = true; // Find maximum over N_Step1 steps Max_J20 = Max_J22 = Max_J44 = Max_J1010 = Max_Sun = Max_Moon = Max_SRad = Max_Drag = 0.0; for (i = 0; i <= N_Step1; i++) { var refEph = Eph_Ref[i].Slice(0, 2); Max_J20 = max(Norm(Eph_J20[i].Slice(0, 2) - refEph), Max_J20); Max_J22 = max(Norm(Eph_J22[i].Slice(0, 2) - refEph), Max_J22); Max_J44 = max(Norm(Eph_J44[i].Slice(0, 2) - refEph), Max_J44); Max_J1010 = max(Norm(Eph_J1010[i].Slice(0, 2) - refEph), Max_J1010); Max_Sun = max(Norm(Eph_Sun[i].Slice(0, 2) - refEph), Max_Sun); Max_Moon = max(Norm(Eph_Moon[i].Slice(0, 2) - refEph), Max_Moon); Max_SRad = max(Norm(Eph_SRad[i].Slice(0, 2) - refEph), Max_SRad); Max_Drag = max(Norm(Eph_Drag[i].Slice(0, 2) - refEph), Max_Drag); } ; // Output var info = "Exercise 3-4: Orbit Perturbations " + "\r\n" + "\r\n"; info += "Remote sensing satellite: " + "\r\n" + "\r\n"; info += " Maximum position errors within "; Console.Write(info); info = String.Format("{0, 8:F}", N_Step1 * Step / 60.0); info += " min propagation interval " + "\r\n"; info += " J2,0 J2,2 J4,4 J10,10" + " Sun Moon SolRad Drag" + "\r\n"; info += " [m] [m] [m] [m]" + " [m] [m] [m] [m]"; Console.WriteLine(info); info = String.Format("{0, 8:F}{1, 8:F}{2, 8:F}{3, 8:F}{4, 8:F}{5, 8:F}{6, 8:F}{7, 8:F}", Max_J20, Max_J22, Max_J44, Max_J1010, Max_Sun, Max_Moon, Max_SRad, Max_Drag); Console.WriteLine(info); Console.WriteLine(); // Find maximum over N_Step2 steps for (i = N_Step1 + 1; i <= N_Step2; i++) { var refEph = Eph_Ref[i].Slice(0, 2); Max_J20 = max(Norm(Eph_J20[i].Slice(0, 2) - refEph), Max_J20); Max_J22 = max(Norm(Eph_J22[i].Slice(0, 2) - refEph), Max_J22); Max_J44 = max(Norm(Eph_J44[i].Slice(0, 2) - refEph), Max_J44); Max_J1010 = max(Norm(Eph_J1010[i].Slice(0, 2) - refEph), Max_J1010); Max_Sun = max(Norm(Eph_Sun[i].Slice(0, 2) - refEph), Max_Sun); Max_Moon = max(Norm(Eph_Moon[i].Slice(0, 2) - refEph), Max_Moon); Max_SRad = max(Norm(Eph_SRad[i].Slice(0, 2) - refEph), Max_SRad); Max_Drag = max(Norm(Eph_Drag[i].Slice(0, 2) - refEph), Max_Drag); } ; // Output info = " Maximum position errors within "; Console.Write(info); info = String.Format("{0, 8:F}", N_Step2 * Step / 60.0); info += " min propagation interval " + "\r\n"; info += " J2,0 J2,2 J4,4 J10,10" + " Sun Moon SolRad Drag" + "\r\n"; info += " [m] [m] [m] [m]" + " [m] [m] [m] [m]"; Console.WriteLine(info); info = String.Format("{0, 8:F}{1, 8:F}{2, 8:F}{3, 8:F}{4, 8:F}{5, 8:F}{6, 8:F}{7, 8:F}", Max_J20, Max_J22, Max_J44, Max_J1010, Max_Sun, Max_Moon, Max_SRad, Max_Drag); Console.WriteLine(info); Console.WriteLine(); // Epoch state (geostationary satellite) Kep = new Vector(42166.0e3, 0.0004, 0.02 * OrbitConsts.RadPerDeg, 0.0, 0.0, 0.0); Y0 = Kepler.State(OrbitConsts.GM_Earth, Kep, 0.0); // Model parameters Aux_ref.Area = 10.0; // [m^2] Geostationary satellite // Reference orbit Step = 1200.0; // [s] N_Step1 = 72; // 1 day N_Step2 = 144; // 2 days Aux = Aux_ref; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Ref); // J2,0 perturbations Aux.MaxDegree = 2; Aux.MaxOrder = 0; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J20); // J2,2 perturbations Aux.MaxDegree = 2; Aux.MaxOrder = 2; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J22); // J4,4 perturbations Aux.MaxDegree = 4; Aux.MaxOrder = 4; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J44); // J10,10 perturbations Aux.MaxDegree = 10; Aux.MaxOrder = 10; Ephemeris(Y0, N_Step2, Step, Aux, Eph_J1010); Aux.MaxDegree = 20; Aux.MaxOrder = 20; // Solar perturbations Aux.EnableSun = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Sun); Aux.EnableSun = true; // Lunar perturbations Aux.EnableMoon = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Moon); Aux.EnableMoon = true; // Solar radiation pressure perturbations Aux.EnableSolarRadiation = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_SRad); Aux.EnableSolarRadiation = true; // Drag perturbations Aux.EnableDrag = false; Ephemeris(Y0, N_Step2, Step, Aux, Eph_Drag); Aux.EnableDrag = true; // Find maximum over N_Step1 steps Max_J20 = Max_J22 = Max_J44 = Max_J1010 = Max_Sun = Max_Moon = Max_SRad = Max_Drag = 0.0; for (i = 0; i <= N_Step1; i++) { var refEph = Eph_Ref[i].Slice(0, 2); Max_J20 = max(Norm(Eph_J20[i].Slice(0, 2) - refEph), Max_J20); Max_J22 = max(Norm(Eph_J22[i].Slice(0, 2) - refEph), Max_J22); Max_J44 = max(Norm(Eph_J44[i].Slice(0, 2) - refEph), Max_J44); Max_J1010 = max(Norm(Eph_J1010[i].Slice(0, 2) - refEph), Max_J1010); Max_Sun = max(Norm(Eph_Sun[i].Slice(0, 2) - refEph), Max_Sun); Max_Moon = max(Norm(Eph_Moon[i].Slice(0, 2) - refEph), Max_Moon); Max_SRad = max(Norm(Eph_SRad[i].Slice(0, 2) - refEph), Max_SRad); Max_Drag = max(Norm(Eph_Drag[i].Slice(0, 2) - refEph), Max_Drag); } ; // Output // Output info = "Geostationary satellite: " + "\r\n"; info += " Maximum position errors within "; Console.Write(info); info = String.Format("{0, 8:F}", N_Step1 * Step / 60.0); info += " min propagation interval " + "\r\n"; info += " J2,0 J2,2 J4,4 J10,10" + " Sun Moon SolRad Drag" + "\r\n"; info += " [m] [m] [m] [m]" + " [m] [m] [m] [m]"; Console.WriteLine(info); info = String.Format("{0, 8:F}{1, 8:F}{2, 8:F}{3, 8:F}{4, 8:F}{5, 8:F}{6, 8:F}{7, 8:F}", Max_J20, Max_J22, Max_J44, Max_J1010, Max_Sun, Max_Moon, Max_SRad, Max_Drag); Console.WriteLine(info); Console.WriteLine(); // Find maximum over N_Step2 steps for (i = N_Step1 + 1; i <= N_Step2; i++) { var refEph = Eph_Ref[i].Slice(0, 2); Max_J20 = max(Norm(Eph_J20[i].Slice(0, 2) - refEph), Max_J20); Max_J22 = max(Norm(Eph_J22[i].Slice(0, 2) - refEph), Max_J22); Max_J44 = max(Norm(Eph_J44[i].Slice(0, 2) - refEph), Max_J44); Max_J1010 = max(Norm(Eph_J1010[i].Slice(0, 2) - refEph), Max_J1010); Max_Sun = max(Norm(Eph_Sun[i].Slice(0, 2) - refEph), Max_Sun); Max_Moon = max(Norm(Eph_Moon[i].Slice(0, 2) - refEph), Max_Moon); Max_SRad = max(Norm(Eph_SRad[i].Slice(0, 2) - refEph), Max_SRad); Max_Drag = max(Norm(Eph_Drag[i].Slice(0, 2) - refEph), Max_Drag); } ; // Output info = " Maximum position errors within "; Console.Write(info); info = String.Format("{0, 8:F}", N_Step2 * Step / 60.0); info += " min propagation interval " + "\r\n"; info += " J2,0 J2,2 J4,4 J10,10" + " Sun Moon SolRad Drag" + "\r\n"; info += " [m] [m] [m] [m]" + " [m] [m] [m] [m]"; Console.WriteLine(info); info = String.Format("{0, 8:F}{1, 8:F}{2, 8:F}{3, 8:F}{4, 8:F}{5, 8:F}{6, 8:F}{7, 8:F}", Max_J20, Max_J22, Max_J44, Max_J1010, Max_Sun, Max_Moon, Max_SRad, Max_Drag); Console.WriteLine(info); Console.WriteLine(); Console.ReadKey(); }
static void Main0(string[] args) { // Variables int i; // Loop counter double MJD_GPS, MJD_TT; // Modified Julian Date (GPS,TT) double MJD_UTC, MJD_UT1; // Modified Julian Date (UTC,UT1) Matrix P = new Matrix(3, 3), N = new Matrix(3, 3); // Precession/nutation matrix Matrix Theta = new Matrix(3, 3); // Sidereal Time matrix Matrix S = new Matrix(3, 3), dTheta = new Matrix(3, 3); // and derivative Matrix Pi = new Matrix(3, 3); // Polar motion matrix Matrix U = new Matrix(3, 3), dU = new Matrix(3, 3); // ICRS to ITRS transformation and derivative Vector r_WGS = new Vector(3), v_WGS = new Vector(3); // Position/velocity in the Earth-fixed frame Vector r = new Vector(3), v = new Vector(3); // Position/velocity in the ICRS Vector y = new Vector(6), Kep = new Vector(6); // Satte vector and Keplerian elements // Header var endl = "\r\n"; var info = "Exercise 5-2: Velocity in the Earth-fixed frame" + endl + endl; Console.WriteLine(info); // Earth Orientation Parameters (UT1-UTC[s],UTC-TAI[s], x["], y["]) // (from IERS Bulletin B #135 and C #16; valid for 1999/03/04 0:00 UTC) IERS IERS = new IERS(0.6492332, -32.0, 0.06740, 0.24173); // Date MJD_GPS = DateUtil.DateToMjd(1999, 03, 04, 0, 0, 0.0); MJD_UTC = MJD_GPS - IERS.GetGPS_UTC(MJD_GPS) / 86400.0; MJD_UT1 = MJD_UTC + IERS.GetUT1_UTC(MJD_UTC) / 86400.0; MJD_TT = MJD_UTC + IERS.GetTT_UTC(MJD_UTC) / 86400.0; // Earth-fixed state vector of GPS satellite #PRN15 // (from NIMA ephemeris nim09994.eph; WGS84(G873) system) r_WGS = new Vector(19440.953805e+3, 16881.609273e+3, -6777.115092e+3); // [m] v_WGS = new Vector(-8111.827456e-1, -2573.799137e-1, -30689.508125e-1); // [m/s] // ICRS to ITRS transformation matrix and derivative P = IERS.PrecessionMatrix(OrbitConsts.MJD_J2000, MJD_TT); // IAU 1976 Precession N = IERS.NutMatrix(MJD_TT); // IAU 1980 Nutation Theta = IERS.GreenwichHourAngleMatrix(MJD_UT1); // Earth rotation Pi = IERS.PoleMatrix(MJD_UTC); // Polar motion S[0, 1] = 1.0; S[1, 0] = -1.0; // Derivative of Earth rotation dTheta = OrbitConsts.RotationSpeedOfEarth_Rad * S * Theta; // matrix [1/s] U = Pi * Theta * N * P; // ICRS to ITRS transformation dU = Pi * dTheta * N * P; // Derivative [1/s] // Transformation from WGS to ICRS r = U.Transpose() * r_WGS; v = U.Transpose() * v_WGS + dU.Transpose() * r_WGS; // Orbital elements y = r.Stack(v); Kep = Kepler.Elements(OrbitConsts.GM_Earth, y); // Output info = "Date" + endl + endl + " " + DateUtil.MjdToDateTimeString(MJD_GPS) + " GPS" + endl + " " + DateUtil.MjdToDateTimeString(MJD_UTC) + " UTC" + endl + " " + DateUtil.MjdToDateTimeString(MJD_UT1) + " UT1" + endl + " " + DateUtil.MjdToDateTimeString(MJD_TT) + " TT " + endl + endl; Console.WriteLine(info); info = "WGS84 (G873) State vector:" + endl + endl; info += " Position "; for (i = 0; i < 3; i++) { info += String.Format("{0, 10:F6}", r_WGS[i] / 1000.0); } ; info += " [km]"; Console.WriteLine(info); info = " Velocity "; for (i = 0; i < 3; i++) { info += String.Format("{0, 10:F6}", v_WGS[i] / 1000.0); } ; info += " [km/s]" + endl + endl; Console.WriteLine(info); info = "ICRS-ITRS transformation" + endl + endl + String.Format("{0, 10:F6}", U) + endl; info += "Derivative of ICRS-ITRS transformation [10^(-4)/s]" + endl + endl + String.Format("{0, 10:F6}", dU * 1.0e4) + endl; info += "ICRS State vector:" + endl; Console.WriteLine(info); info = " Position "; for (i = 0; i < 3; i++) { info += String.Format("{0, 14:F6}", r[i] / 1000.0); } ; info += " [km]"; Console.WriteLine(info); info = " Velocity "; for (i = 0; i < 3; i++) { info += String.Format("{0, 14:F6}", v[i] / 1000.0); } ; info += " [km/s]" + endl + endl; Console.WriteLine(info); info = "Orbital elements:" + endl + endl + " Semimajor axis " + String.Format("{0, 10:F3}", Kep[0] / 1000.0) + " km" + endl + " Eccentricity " + String.Format("{0, 10:F7}", Kep[1]) + endl + " Inclination " + String.Format("{0, 10:F3}", Kep[2] * OrbitConsts.DegPerRad) + " deg" + endl + " RA ascend. node " + String.Format("{0, 10:F3}", Kep[3] * OrbitConsts.DegPerRad) + " deg" + endl + " Arg. of perigee " + String.Format("{0, 10:F3}", Kep[4] * OrbitConsts.DegPerRad) + " deg" + endl + " Mean anomaly " + String.Format("{0, 10:F3}", Kep[5] * OrbitConsts.DegPerRad) + " deg" + endl; Console.WriteLine(info); Console.ReadKey(); }
static void Main0(string[] args) { // Variables double MJD_UTC; // Modified Julian Date (UTC) double MJD_UT1; // Modified Julian Date (UTC) double MJD_TT; // Modified Julian Date (TT) Matrix P = new Matrix(3, 3); // Precession matrix (ICRS -> mean-of-date) Matrix N = new Matrix(3, 3); // Nutation matrix (mean-of-date -> true-of-date) Matrix Theta = new Matrix(3, 3); // Sidereal Time matrix (tod -> pseudo-Earth-fixed) Matrix Pi = new Matrix(3, 3); // Polar motion matrix (pseudo-Earth-fixed -> ITRS) // Header var info = "Exercise 5-1: Transformation from celestial " + "to terrestrial reference system" + "\r\n"; Console.WriteLine(info); // Earth Orientation Parameters (UT1-UTC[s],UTC-TAI[s], x["], y["]) // (from IERS Bulletin B #135 and C #16; valid for 1999/03/04 0:00 UTC) IERS IERS = new IERS(0.6492332, -32.0, 0.06740, 0.24173); // Date MJD_UTC = DateUtil.DateToMjd(1999, 03, 04, 0, 0, 0.0); MJD_UT1 = MJD_UTC + IERS.GetUT1_UTC(MJD_UTC) / 86400.0; MJD_TT = MJD_UTC + IERS.GetTT_UTC(MJD_UTC) / 86400.0; // IAU 1976 Precession // (ICRF to mean equator and equinox of date) P = IERS.PrecessionMatrix(OrbitConsts.MJD_J2000, MJD_TT); // IAU 1980 Nutation // (Transformation to the true equator and equinox) N = IERS.NutMatrix(MJD_TT); // Apparent Sidereal Time // Rotation about the Celestial Ephemeris Pole Theta = IERS.GreenwichHourAngleMatrix(MJD_UT1); // Note: here we evaluate the equation of the // equinoxes with the MJD_UT1 time argument // (instead of MJD_TT) // Polar motion // (Transformation from the CEP to the IRP of the ITRS) Pi = IERS.PoleMatrix(MJD_UTC); // Note: the time argument of polar motion series // is not rigorously defined, but any differences // are negligible // Output var endl = "\r\n"; info = "Date" + "\r\n" + " " + DateUtil.MjdToDateTimeString(MJD_UTC) + " UTC" + endl + " " + DateUtil.MjdToDateTimeString(MJD_UT1) + " UT1" + endl + " " + DateUtil.MjdToDateTimeString(MJD_TT) + " TT " + endl + endl + endl; Console.WriteLine(info); info = "IAU 1976 Precession matrix (ICRS to tod)" + endl + P.ToString(); Console.WriteLine(info); info = "IAU 1980 Nutation matrix (tod to mod)" + endl + N.ToString(); Console.WriteLine(info); info = "Earth Rotation matrix" + endl + Theta.ToString(); Console.WriteLine(info); info = "Polar motion matrix" + endl + Pi.ToString(); Console.WriteLine(info); info = "ICRS-ITRS transformation" + endl + (Pi * Theta * N * P).ToString(); Console.WriteLine(info); Console.ReadKey(); }