Appendix B ————————————————————– FORTRAN Codes This appendix is to provide the reader with FORTRAN codes, which, when applied, generate directly the results for the test cases of the book. All the FORTRAN codes listed in this appendix work in a double precision mode, which means that the word length amounts to 64 bit. The SI units are used throughout this book, Appendix D. All the FORTRAN codes listed in this appendix can be downloaded from http://extra.springer.com. B.1 General Equations for Planetary Flight – Three Degree of Freedom Simulation This is a program code for the numerical integration of the general equations of planetary flight – three degree of freedom simulation – in the form of eq. (6.24) where the Earth rotation is included, as well as in the form of eq. (6.26) where the Earth rotation is not included, see Chapter 6. The given status of the program code is the test case 1 of Section 5.6, which is discussed in Sub-Section 5.8.3. On unit 40 the output file for plotting with MATLAB routines is generated. This file contains in the following order: the time T, the velocity V, the flight path angle γ (GAM), the altitude H, the position vector of the space vehicle measured from the central point of the planet R, the longitude angle θ (THETA), the azimuth angle χ (CHI1), the latitude angle φ (PHI), the total length of the flight path STOT, and the length projected onto the planet’s surface in latitude direction SLAT. C ************************************************************* C PROGRAM CODE FOR COMPUTING THE SPACE FLIGHT MECHANICS OF C SPACE VEHICLES C USE OF HIGHLY ACCURATE ”IMSL” INTEGRATION PROCEDURES C ************************************************************* USE NUMERICAL LIBRARIES IMPLICIT REAL*8 (A-H,O-Z) PARAMETER (MIN=1000001) PARAMETER (MXPARM=50,N=6) 240 Appendix B FORTRAN Codes REAL*8 M,MUEA,TOL COMMON ARC DIMENSION PARAM(MXPARM),Y(N) EXTERNAL FCN OPEN(40,FILE=’E:\MATLAB6p5\MSF 04 2\ Kepler 2’,FORM=’FORMATTED’, * STATUS=’UNKNOWN’) RE = 6378000 PI = 3.141592653 IEND = 582850 ITD = 1000 IT1 = 1 DT = 0.1 STOT = 0.0 SLAT = 0.0 ARC = PI/180. C ************************************************************* C INITIAL CONDITIONS C ************************************************************* T = 0.0 Y(1) = 10510.47 Y(2) = 0.0 Y(3) = 0.0 Y(4) = 122000 Y(5) = 90.0*ARC Y(6) = -20.0*ARC VM1 = Y(1) GAMM1 = Y(2) CHIM1 = Y(3) RM1 = RE + Y(4) THETAM1 = Y(5) PHIM1 = Y(6) TOL = 0.0005 PARAM(4) = IEND+1 PARAM(10) = 1.0 WRITE(10,15) IDO = 1 ISTEP = 0 C ************************************************************* C BEGIN OF INTEGRATION PROCEDURE C ************************************************************* 10 CONTINUE ISTEP = ISTEP + 1 ITE = ISTEP/ITD TEND = ISTEP*DT CALL DIVPRK(IDO,N,FCN,T,TEND,TOL,PARAM,Y) B.1 General Equations for Planetary Flight IF(Y(1).LE.0.OR.Y(4).LE.0)THEN WRITE(10,16)T,V,GAM,H/1000,R/1000,THETA,CHI1,PHI,STOT/1000, * SLAT/1000 STOP ’V OR H LESS THAN ZERO’ END IF V00 = Y(1) GAM00 = Y(2) CHI00 = Y(3) R00 = RE + Y(4) THETA00 = Y(5) PHI00 = Y(6) C ************************************************************* C BEGIN OF COMPUTATION OF LONGITUDINAL REGIME C ************************************************************* XI1 = R00 * COS(-PHI00) * COS(THETA00) XI = RM1 * COS(-PHIM1) * COS(THETAM1) YI1 = R00 * COS(-PHI00) * SIN(THETA00) YI = RM1 * COS(-PHIM1) * SIN(THETAM1) ZI1 = R00 * SIN(-PHI00) ZI = RM1 * SIN(-PHIM1) DXI = ABS(XI1 - XI) IF(DXI.LT.1.E-8)DXI = 1.E-8 DYI = YI1 - YI DZI = ZI1 - ZI DYDXS = (DYI/DXI)**2 DZDXS = (DZI/DXI)**2 ROOTI = SQRT(1. + DYDXS + DZDXS) DSTOT = ROOTI * DXI STOT = STOT + DSTOT C ************************************************************* C END OF COMPUTATION OF LONGITUDE REGIME C ************************************************************* C ************************************************************* C BEGIN OF COMPUTATION OF LATITUDE REGIME C ************************************************************* XJ1 = RE * COS(-PHI00) XJ = RE * COS(-PHIM1) ZJ1 = RE * SIN(-PHI00) ZJ = RE * SIN(-PHIM1) DXJ = XJ1 - XJ DZJ = ZJ1 - ZJ IF(ABS(DZJ).EQ.0)DZJ = 1.E-08 DXDZS = (DXJ/DZJ)**2 ROOTJ = SQRT(1.+DXDZS) IF(DZJ.EQ.1.E-08)DZJ = 0. 241 242 Appendix B FORTRAN Codes DSLAT = ROOTJ * DZJ SLAT = SLAT + DSLAT C ************************************************************* C END OF COMPUTATION OF LATITUDE REGIME C ************************************************************* VM1 = Y(1) GAMM1 = Y(2) CHIM1 = Y(3) RM1 = RE + Y(4) THETAM1 = Y(5) PHIM1 = Y(6) IF(ISTEP.LE.IEND.AND.IT1.EQ.ITE)THEN V = Y(1) GAM = Y(2)/ARC CHI1 = Y(3)/ARC H = Y(4) R = RE + H THETA = Y(5)/ARC PHI = Y(6)/ARC IT1 = IT1 + 1 WRITE(10,16)T,V,GAM,H/1000,R/1000,THETA,CHI1,PHI,STOT/1000, * SLAT/1000 C ************************************************************* C OUTPUT FILE FOR PLOT WITH MATLAB ROUTINES C ************************************************************* WRITE(40,16)T,V,GAM,H/1000,R/1000,THETA,CHI1,PHI,STOT/1000, * SLAT/1000 END IF IF(ISTEP.EQ.IEND)THEN IDO = 3 STOP ’END OF INTEGRATION’ END IF GOTO 10 C ************************************************************* C END OF INTEGRATION PROCEDURE C ************************************************************* 15 FORMAT(/,8X,’T’,6X,’V’,11X,’GAM’,11X,’H’,11X,’R’,8X,’THETA’,6X, * ’CHI1’,8X,’PHI’,6X,’STOT’,8X,’SLAT’,/) 16 FORMAT(F10.2,F10.3,F13.6,2E14.6,3F10.4,2E13.5) END C ************************************************************* C ************************************************************* SUBROUTINE FCN(N,T,Y,YPRIME) IMPLICIT REAL*8 (A-H,O-Z) B.1 General Equations for Planetary Flight 243 COMMON ARC DIMENSION Y(N),YPRIME(N) REAL*8 M,MUEA KROT = 0 C ************************************************************* C KROT = 0 ==> EQUATIONS WITH NO EARTH ROTATION IN P-FRAME C KROT = 1 ==> EQUATIONS WITH EARTH ROTATION IN O-FRAME C ************************************************************* S = 12.02 ! REFERENCE AREA, [m2] CD = 0.0 ! DRAG COEFFICIENT CL = 0.0 ! LIFT COEFFICIENT M = 50.0 ! VEHICLE MASS, [kg] RE = 6378000 ! RADIUS OF EARTH, [m] RHOS = 1.2930 ! DENSITY AT SEA-LEVEL; [kg/m3] GS = 9.8066 ! GRAVITATIONAL CONSTANT AT SEA-LEVEL, [m/s2] BETA = 0.000140845 ! SCALING COEFFICIENT OMEGA = 0.000072920 ! ANGULAR VELOCITY OF EARTH, [rad/s] MUEA = 0.0*ARC ! BANK ANGLE RHO = RHOS * EXP(-BETA * Y(4)) RRED = RE/(RE + Y(4)) D = RHO * S * CD * 0.5 * Y(1)**2 L = RHO * S * CL * 0.5 * Y(1)**2 G = GS * RRED**2 R = RE + Y(4) IF(KROT.EQ.1)THEN YPRIME(1) = - D/M - G * SIN(Y(2)) + OMEGA**2 * R * (COS(Y(6)))**2* * (SIN(Y(2)) - COS(Y(2)) * TAN(Y(6)) * SIN(Y(3))) YPRIME(2) = (L/M * COS(MUEA) - G*COS(Y(2)) + Y(1)**2/R * COS(Y(2)) * + 2. * OMEGA * Y(1) * COS(Y(6)) * COS(Y(3)) + OMEGA**2 * R * * (COS(Y(6)))**2 * (COS(Y(2)) + SIN(Y(2)) * TAN(Y(6)) * * SIN(Y(3))))/Y(1) YPRIME(3) = (L/M * SIN(MUEA)/COS(Y(2)) - Y(1)**2/R * COS(Y(2)) * * COS(Y(3)) * TAN(Y(6)) + 2. * OMEGA * Y(1) * * (TAN(Y(2)) * COS(Y(6)) * SIN(Y(3)) - SIN(Y(6))) * - OMEGA**2 * R * SIN(Y(6)) * COS(Y(6)) * COS(Y(3))/COS(Y(2))) * /Y(1) ELSE YPRIME(1) = - D/M - G * SIN(Y(2)) YPRIME(2) = (L/M * COS(MUEA) - G * COS(Y(2)) + Y(1)**2/R * COS(Y(2))) * /Y(1) YPRIME(3) = (L/M * SIN(MUEA)/COS(Y(2)) - Y(1)**2/R * COS(Y(2)) * * COS(Y(3)) * TAN(Y(6)))/Y(1) 244 Appendix B FORTRAN Codes END IF YPRIME(4) = Y(1) * SIN(Y(2)) YPRIME(5) = Y(1) * COS(Y(2)) * COS(Y(3))/(R * COS(Y(6))) YPRIME(6) = Y(1) * COS(Y(2)) * SIN(Y(3))/R RETURN END C ************************************************************* C END OF SUBROUTINE FCN C ************************************************************* B.2 Orbit Determination with Orbital Elements 245 B.2 Orbit Determination with Orbital Elements This is a program code for evaluation of the relations for the orbital elements and for determination of the position vector R(t) and the velocity vector V(t) for the whole orbit using the eqs. (5.53) and (5.54) of Sub-Section 5.8.1. The given status of the program code is the test case 1 of Section 5.6 in the form applied in Sub-Section 5.8.2. On unit 11 the output file for a plot with MATLAB routines is generated. It contains in the following order: the time T, the true anomaly θ (THETA1), the x-component of the position vector R in the planetocentric frame (xE , y E , z E ) RT1EXE, the y-component RT1EYE, the z-component RT1EZE (see Fig. 5.14 and eq. (5.57)), and the magnitude of the velocity vector |V| (VSCALAR1). PROGRAM ORBITAL ELEMENTS C ************************************************************* C Program calculates the orbital elements from the initial C conditions R(to) and V(to) and supplies for any time t the C position vector R(t) and the velocity vector V(t) C ************************************************************* IMPLICIT REAL*8 (A-H,O-Z) PARAMETER (NEND = 5830) DIMENSION THETA1(NEND),RT1EXE(NEND),RT1EYE(NEND),RT1EZE(NEND) DIMENSION T(NEND) REAL*8 INC,NX,NY,NZ,NABS OPEN(11,FILE=’E:\MATLAB6p5\MSF 04 2 \Orbital elements\case 1’, * FORM=’FORMATTED’,STATUS=’UNKNOWN’) C ***************************************************************** C Constants C ***************************************************************** GAMMA = 3.98920D14 PI = 3.141592653D0 ARC = PI/180.D0 C ***************************************************************** C Initial condition at time TO C ***************************************************************** RT0EXE = 0.0D0 RT0EYE = 6.10800D6 RT0EZE = 2.22313D6 VT0EXE = -10510.47D0 VT0EYE = 0.0D0 VT0EZE = 0.0D0 RSCALAR = 6.500D6 246 Appendix B FORTRAN Codes VSCALAR = 10510.47D0 T0 = 0.0D0 C ***************************************************************** C From energy equation to semi-major axis A C ***************************************************************** ENERGY = 0.5D0*VSCALAR**2 - GAMMA/RSCALAR A = - 0.5D0*GAMMA/ENERGY C ***************************************************************** C The period time TT C ***************************************************************** C ***************************************************************** C The angular momentum vector F C ***************************************************************** TT = 2.D0*PI*SQRT(A**3/GAMMA) FX = RT0EYE*VT0EZE - RT0EZE*VT0EYE FY = -(RT0EXE*VT0EZE - RT0EZE*VT0EXE) FZ = RT0EXE*VT0EYE - RT0EYE*VT0EXE C ***************************************************************** C The unit vector n of the lines of nodes C ***************************************************************** FABS = SQRT(FX**2 + FY**2 + FZ**2) GNX = -FY GNY = FX GNZ = 0.0D0 GNABS = SQRT(GNX**2 + GNY**2) NX = GNX/GNABS NY = GNY/GNABS NZ = GNZ/GNABS C ***************************************************************** C The eccentricity e C ***************************************************************** ECCX = (VT0EYE*FZ - VT0EZE*FY - GAMMA*RT0EXE/RSCALAR)/GAMMA ECCY = (-(VT0EXE*FZ - VT0EZE*FX) - GAMMA*RT0EYE/RSCALAR)/GAMMA ECCZ = (VT0EXE*FY - VT0EYE*FX - GAMMA*RT0EZE/RSCALAR)/GAMMA EABS = SQRT(ECCX**2 + ECCY**2 + ECCZ**2) C ***************************************************************** C Determination of the inclination angle i C ***************************************************************** C ***************************************************************** C Determination of the right ascension of the ascending node Omega C ***************************************************************** INC = ACOS(FZ/FABS) OMGCOS = ACOS(NX) OMGSIN = ASIN(NY) OMG = OMGCOS B.2 Orbit Determination with Orbital Elements C ***************************************************************** C Determination of the unit vectors of the orbit plane C ***************************************************************** 247 EXOXE = ECCX/EABS EXOYE = ECCY/EABS EXOZE = ECCZ/EABS EZOXE = FX/FABS EZOYE = FY/FABS EZOZE = FZ/FABS EYOXE = EZOYE*EXOZE - EZOZE*EXOYE EYOYE = -(EZOXE*EXOZE - EZOZE*EXOXE) EYOZE = EZOXE*EXOYE - EZOYE*EXOXE C ***************************************************************** C Determination of the argument of perigee omega C ***************************************************************** OMKCOS = ACOS(NX*EXOXE + NY*EXOYE) OMKSIN = ASIN(NX*EYOXE + NY*EYOYE) OMK = OMKCOS C ***************************************************************** C The true anomaly theta at time TO C ***************************************************************** ARGU = (RT0EXE*EXOXE + RT0EYE*EXOYE + RT0EZE*EXOZE)/RSCALAR DARGU = ABS(1.D0 - ARGU) IF(DARGU.LT.1D-6)ARGU = 1.0D0 THETACOS = ACOS(ARGU) THETASIN = ASIN((RT0EXE*EYOXE + RT0EYE*EYOYE + * RT0EZE*EYOZE)/RSCALAR) THETA = THETACOS C ***************************************************************** C The time TP as function of the true anomaly theta C ***************************************************************** E = 2.D0*ATAN(SQRT((1D0-EABS)/(1D0+EABS))*TAN(THETA/2D0)) TP = T0 - TT/(2D0*PI)*(E - EABS*SIN(E)) C ***************************************************************** C End of determination of orbital elements C ***************************************************************** C ***************************************************************** C Write the output for the orbital elements on file 20 C ***************************************************************** WRITE(20,101) A 101 FORMAT(/,’MAJOR AXIS A:’,27X,E12.5) WRITE(20,102) EABS 102 FORMAT(’ECCENTRICITY:’,27X,E12.5) WRITE(20,103) INC/ARC 103 FORMAT(’INCLINATION ANGLE:’,22X,E12.5) 248 Appendix B FORTRAN Codes WRITE(20,104) OMG/ARC 104 FORMAT(’RIGHT ASCENSION OF THE ASCENDING NODE:’,2X,E12.5) WRITE(20,105) OMK/ARC 105 FORMAT(’ARGUMENT OF PERIGEE:’,20X,E12.5) WRITE(20,106) THETA/ARC 106 FORMAT(’TRUE ANOMALY:’,27X,E12.5) WRITE(20,107) TP 107 FORMAT(’PERIGEE PASSAGE TP:’,21X,E12.5) WRITE(20,108) TT 108 FORMAT(’PERIOD TIME TT:’,25X,E12.5,//) C ***************************************************************** C Determination of the complete solution C ***************************************************************** EPS = 1.D-6 DT = 10.0D0 E0 = 1.D0 DO 10 N = 1,NEND T(N) = (N-1)*DT CO1 = 2.D0*PI*(T(N)-TP)/TT 20 FE = E0 - EABS*SIN(E0) - CO1 DFE = 1.D0 - EABS*COS(E0) E1 = E0 - FE/DFE DIFF = ABS(E1 - E0) E0 = E1 IF(DIFF.GT.EPS)GOTO20 THETA1(N) = 2.D0*ATAN(SQRT((1.D0+EABS)/(1.D0-EABS))*TAN(E0/2.D0)) IF(THETA1(N).LT.0)THETA1(N) = 2.D0*PI + THETA1(N) 10 CONTINUE P = A*(1.D0-EABS**2) WRITE(20,111) DO 30 N = 1,NEND EXOXE1 = COS(OMG)*COS(OMK) - SIN(OMG)*SIN(OMK)*COS(INC) EXOYE1 = SIN(OMG)*COS(OMK) + COS(OMG)*SIN(OMK)*COS(INC) EXOZE1 = SIN(OMK)*SIN(INC) EYOXE1 =-COS(OMG)*SIN(OMK) - SIN(OMG)*COS(OMK)*COS(INC) EYOYE1 =-SIN(OMG)*SIN(OMK) + COS(OMG)*COS(OMK)*COS(INC) EYOZE1 = COS(OMK)*SIN(INC) RSCALAR1 = P/(1.D0+EABS*COS(THETA1(N))) RT1EXE(N)=RSCALAR1*(COS(THETA1(N))*EXOXE1+SIN(THETA1(N))*EYOXE1) RT1EYE(N)=RSCALAR1*(COS(THETA1(N))*EXOYE1+SIN(THETA1(N))*EYOYE1) RT1EZE(N)=RSCALAR1*(COS(THETA1(N))*EXOZE1+SIN(THETA1(N))*EYOZE1) VSCALAR1=SQRT(GAMMA/P)*SQRT(1D0+2D0*EABS*COS(THETA1(N))+EABS**2) B.2 Orbit Determination with Orbital Elements C ***************************************************************** C Write the output of R(t) and V(t) for the orbit on file 20 C ***************************************************************** WRITE(20,110)T(N),THETA1(N)/ARC,RT1EXE(N)/1000,RT1EYE(N)/1000, * RT1EZE(N)/1000,VSCALAR1 C ***************************************************************** C Output file 11 of R(t) and V(t) for plot with MATLAB routines C ***************************************************************** WRITE(11,110)T(N),THETA1(N)/ARC,RT1EXE(N)/1000,RT1EYE(N)/1000, * RT1EZE(N)/1000,VSCALAR1 110 FORMAT(F10.2,F8.2,4F12.2) 111 FORMAT(5X,’TIME’,4X,’THETA’,5X,’X-COORD’, 5X,’Y-COORD’,5X, * ’Z-COORD’,4X,’VELOCITY’,/) 30 CONTINUE END 249 250 Appendix B FORTRAN Codes B.3 Lagrange’s Planet Equations This is a program code for the numerical integration of Lagrange’s planet equations in the form of eqs. (5.63) together with eqs (5.70) and (5.71). For more information regarding Lagrange’s planet equations see also [2] to [5]. The given status of the program code is the test case 1 of Section 5.6 in the form applied in Sub-Section 5.8.2 and discussed in Section 5.9.2. On units 11 and 12 the output files for plots with MATLAB routines are generated. Unit 11 contains in the following order: the time T, the true anomaly θ (THETA1), the x-component of the position vector R in the planetocentric frame (xE , y E , z E ) RT1EXE, the y-component RT1EYE, the z-component RT1EZE (see Fig. 5.14 and eq. (5.57)), and the magnitude of the velocity vector |V| (VSCALAR1). Unit 12 contains in the following order: the six orbital elements, viz. the semi-major axis a (Y(1)), the eccentricity e (Y(2)), the inclination angle i (Y(3)), the right ascension of the ascending node Ω (Y(4)), the argument of perigee ω (Y(5)), the mean anomaly M0 (Y(6)), the true anomaly θ (THETA1), the magnitude of the position vector |R| (RLA) and the time step N. PROGRAM ORBITAL ELEMENTS AND LAGRANGE’S PERTURBATION THEORY C ************************************************************* C 1) C The undisturbed orbital elements from the initial C conditions R(to) and V(to) are computed, where the equations of C the two-body theory are used. C 2) C With the undisturbed orbital elements as initial conditions, the C deviations of these orbital elements due to perturbations are C computed by integration of the Lagrange’s planet equations and C subsequent determination of the position vector R(t) and the C velocity vector V(t). C C ***************************************************************** USE NUMERICAL LIBRARIES IMPLICIT REAL*8 (A-H,O-Z) PARAMETER (MXPARM=50,NN=6) PARAMETER (NEND = 582000) COMMON GAM,TP,T0,EE0 COMMON ALA(0:NEND),EABSLA(0:NEND),INCLA(0:NEND),OMGLA(0:NEND) COMMON OMKLA(0:NEND),CHILA(0:NEND),THETALA(0:NEND),N,KPERIOD2 DIMENSION RT1EXE(NEND),RT1EYE(NEND),RT1EZE(NEND) DIMENSION TTLA(0:NEND),T(0:NEND),PARAM(MXPARM),Y(NN) B.3 Lagrange’s Planet Equations REAL*8 INC0,INCLA,NX,NY,NZ,NABS EXTERNAL FCN OPEN(11,FILE=’E:\MATLAB6p5\Buch Wei\MSF 04 2 \Orbital elements * \case 1 A’,FORM=’FORMATTED’,STATUS=’UNKNOWN’) OPEN(12,FILE=’E:\MATLAB6p5\Buch Wei\MSF 04 2 \Orbital elements * \case 1 B’,FORM=’FORMATTED’,STATUS=’UNKNOWN’) C ***************************************************************** C Constants C ***************************************************************** GAM = 3.98920D14 PI = 3.141592653D0 ARC = PI/180.D0 EE0 = 1.D-1 C ***************************************************************** C Initial conditions at time T0 C ***************************************************************** RT0EXE = 0.0D6 RT0EYE = 6.10800D6 RT0EZE = 2.22313D6 VT0EXE = -10510.47D0 VT0EYE = 0.0D0 VT0EZE = 0.0D0 RSCALAR = 6.500D6 VSCALAR = 10510.47D0 T0 = 0.0D0 C ***************************************************************** C From energy equation to semimajor axis A C ***************************************************************** ENERGY = 0.5D0*VSCALAR**2 - GAM/RSCALAR A0 = - 0.5D0*GAM/ENERGY C ***************************************************************** C The period time TT C ***************************************************************** C ***************************************************************** TT0 = 2.D0*PI*SQRT(A0**3/GAM) C The angular momentum vector F C ***************************************************************** FX = RT0EYE*VT0EZE - RT0EZE*VT0EYE FY = -(RT0EXE*VT0EZE - RT0EZE*VT0EXE) FZ = RT0EXE*VT0EYE - RT0EYE*VT0EXE C ***************************************************************** C The unit vector n of the lines of nodes C ***************************************************************** FABS = SQRT(FX**2 + FY**2 + FZ**2) 251 252 Appendix B FORTRAN Codes GNX = -FY GNY = FX GNZ = 0.0D0 GNABS = SQRT(GNX**2 + GNY**2) NX = GNX/GNABS NY = GNY/GNABS NZ = GNZ/GNABS C ***************************************************************** C The eccentricity e C ***************************************************************** ECCX = (VT0EYE*FZ - VT0EZE*FY - GAM*RT0EXE/RSCALAR)/GAM ECCY = (-(VT0EXE*FZ - VT0EZE*FX) - GAM*RT0EYE/RSCALAR)/GAM ECCZ = (VT0EXE*FY - VT0EYE*FX - GAM*RT0EZE/RSCALAR)/GAM EABS0 = SQRT(ECCX**2 + ECCY**2 + ECCZ**2) C ***************************************************************** C Determination of the inclination angle i C ***************************************************************** C ***************************************************************** C Determination of the right ascension of the ascending node Omega C ***************************************************************** INC0 = ACOS(FZ/FABS) OMGCOS = ACOS(NX) OMGSIN = ASIN(NY) OMG0 = OMGCOS C ***************************************************************** C Determination of the unit vectors of the orbit plane C ***************************************************************** EXOXE = ECCX/EABS0 EXOYE = ECCY/EABS0 EXOZE = ECCZ/EABS0 EZOXE = FX/FABS EZOYE = FY/FABS EZOZE = FZ/FABS EYOXE = EZOYE*EXOZE - EZOZE*EXOYE EYOYE = -(EZOXE*EXOZE - EZOZE*EXOXE) EYOZE = EZOXE*EXOYE - EZOYE*EXOXE C ***************************************************************** C Determination of the argument of perigee omega C ***************************************************************** OMKCOS = ACOS(NX*EXOXE + NY*EXOYE) OMKSIN = ASIN(NX*EYOXE + NY*EYOYE) OMK0 = OMKCOS C ***************************************************************** C The true anomaly theta at time T0 C ***************************************************************** B.3 Lagrange’s Planet Equations 253 ARGU = (RT0EXE*EXOXE + RT0EYE*EXOYE + RT0EZE*EXOZE)/RSCALAR DARGU = ABS(1.D0 - ARGU) IF(DARGU.LT.1D-5)ARGU = 1.0D0 THETACOS = ACOS(ARGU) THETASIN = ASIN((RT0EXE*EYOXE + RT0EYE*EYOYE + * RT0EZE*EYOZE)/RSCALAR) THETA0 = THETASIN C ***************************************************************** C The time TP as function of the true anomaly theta C ***************************************************************** E = 2.D0*ATAN(SQRT((1D0-EABS0)/(1D0+EABS0))*TAN(THETA0/2D0)) TP = T0 - TT0/(2D0*PI)*(E - EABS0*SIN(E)) CHI0 = 2.D0*PI*(T0-TP)/TT0 C ***************************************************************** C End of determination of orbital elements C ***************************************************************** C ***************************************************************** C Write the output for the orbital elements on file 20 C ***************************************************************** WRITE(20,101) A0 101 FORMAT(/,’MAJOR AXIS A:’,27X,E12.5) WRITE(20,102) EABS0 102 FORMAT(’ECCENTRICITY:’,27X,E12.5) WRITE(20,103) INC0/ARC 103 FORMAT(’INCLINATION ANGLE:’,22X,E12.5) WRITE(20,104) OMG0/ARC 104 FORMAT(’RIGHT ASCENSION OF THE ASCENDING NODE:’,2X,E12.5) WRITE(20,105) OMK0/ARC 105 FORMAT(’ARGUMENT OF PERIGEE:’,20X,E12.5) WRITE(20,106) THETA0/ARC 106 FORMAT(’TRUE ANOMALY:’,27X,E12.5) WRITE(20,107) TP 107 FORMAT(’PERIGEE PASSAGE TP:’,21X,E12.5) WRITE(20,108) TT0 108 FORMAT(’PERIOD TIME TT:’,25X,E12.5,//) C ***************************************************************** C Calculation of the disturbed orbtial elements by Lagrange’s planet C equations C ***************************************************************** EPS = 1.D-6 DT = 0.1D0 EE0 = 1.D0 NDIFF = 50 NWRITE = 1 254 Appendix B FORTRAN Codes KPERIOD1 = 0 KPERIOD2 = 0 C ***************************************************************** C The initial conditions C ***************************************************************** ALA(0) = A0 EABSLA(0) = EABS0 INCLA(0) = INC0 OMGLA(0) = OMG0 OMKLA(0) = OMK0 CHILA(0) = CHI0 TTLA(0) = TT0 THETALA(0) = 0.0D0 Y(1) = A0 Y(2) = EABS0 Y(3) = INC0 Y(4) = OMG0 Y(5) = OMK0 Y(6) = CHI0 IDO = 1 TT = 0.0D0 TOL = 0.01D0 PARAM(4) = NEND+1 PARAM(10) = 1.0D0 WRITE(22,113) C ***************************************************************** C Loop for calculation of the disturbed orbital elements as function C of time, along a full orbit cycle (2pi). C ***************************************************************** DO 10 N = 1,NEND NSTEP = N/NDIFF T(N) = (N)*DT CO1 = 2.D0*PI*(T(N)-TP)/TTLA(N-1) 20 FE = EE0 - Y(2)*SIN(EE0) - CO1 DFE = 1.D0 - Y(2)*COS(EE0) EE1 = EE0 - FE/DFE DIFF1 = ABS(EE1 - EE0) EE0 = EE1 IF(DIFF1.GT.EPS)GOTO20 THETALA(N) = 2.D0*ATAN(SQRT((1.D0 + Y(2))/ * (1.D0 - Y(2)))*TAN(EE0/2.D0)) IF(THETALA(N).GE.0D0.AND.KPERIOD1.EQ.1)THEN THETALA(N) = 2.D0*PI + THETALA(N) END IF IF(THETALA(N).LT.0D0)THEN B.3 Lagrange’s Planet Equations THETALA(N) = 2.D0*PI + THETALA(N) KPERIOD1 = 1 END IF C ***************************************************************** C IMSL function for integration of ordinary differential equations C ***************************************************************** CALL DIVPRK(IDO,NN,FCN,TT,T(N),TOL,PARAM,Y) ALA(N) = Y(1) EABSLA(N) = Y(2) INCLA(N) = Y(3) OMGLA(N) = Y(4) OMKLA(N) = Y(5) CHILA(N) = Y(6) RLA = Y(1)*(1.D0-Y(2)**2)/(1.D0 + Y(2)*COS(THETALA(N))) TTLA(N) = 2.D0*PI*SQRT(ALA(N)**3/GAM) IF(NSTEP.EQ.NWRITE)THEN C ***************************************************************** C Write the output of the orbital elements as function of time on C file 22 C ***************************************************************** C ***************************************************************** C Write the output of the orbital elements as function of time for C plot with MATLAB routines on file 12 C ***************************************************************** WRITE(22,112)Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),THETALA(N),RLA,N WRITE(12,112)Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),THETALA(N),RLA,N NWRITE = NWRITE + 1 END IF 10 CONTINUE 113 FORMAT(/,1X,’SEMIMAJOR A’,3X,’ECCENT. E’,2X,’ORB. * INC. I’,3X,’Omega’,4X,’omega’,2X,’AVERA.ANO.CHI’,2X, ** ’THETA’,6X,’R’,/) 112 FORMAT(E12.4,F12.4,4F10.4,F12.4,F12.0,I10) WRITE(20,111) C ***************************************************************** C Compute the new orbit based on the disturbed orbital elements C ***************************************************************** DO 30 N = 1,NEND,100 P = ALA(N)*(1.D0-EABSLA(N)**2) EXOXE1 = COS(OMGLA(N))*COS(OMKLA(N)) * - SIN(OMGLA(N))*SIN(OMKLA(N))*COS(INCLA(N)) * + COS(OMGLA(N))*SIN(OMKLA(N))*COS(INCLA(N)) EXOYE1 = SIN(OMGLA(N))*COS(OMKLA(N)) 255 256 Appendix B FORTRAN Codes EXOZE1 = SIN(OMKLA(N))*SIN(INCLA(N)) EYOXE1 =-COS(OMGLA(N))*SIN(OMKLA(N)) * - SIN(OMGLA(N))*COS(OMKLA(N))*COS(INCLA(N)) * + COS(OMGLA(N))*COS(OMKLA(N))*COS(INCLA(N)) EYOYE1 =-SIN(OMGLA(N))*SIN(OMKLA(N)) EYOZE1 = COS(OMKLA(N))*SIN(INCLA(N)) RSCALAR1 = P/(1.D0 + EABSLA(N)*COS(THETALA(N))) RT1EXE(N) = RSCALAR1*(COS(THETALA(N))*EXOXE1 + * SIN(THETALA(N))*EYOXE1) * SIN(THETALA(N))*EYOYE1) * SIN(THETALA(N))*EYOZE1) * EABSLA(N)**2) RT1EYE(N) = RSCALAR1*(COS(THETALA(N))*EXOYE1 + RT1EZE(N) = RSCALAR1*(COS(THETALA(N))*EXOZE1 + VSCALAR1=SQRT(GAM/P)*SQRT(1.D0+2.D0*EABSLA(N)*COS(THETALA(N))+ C ***************************************************************** C Write the output of R(t) and V(t) for the disturbed orbit on C file 20 C ***************************************************************** WRITE(20,110)T(N),THETALA(N)/ARC,RT1EXE(N)/1000,RT1EYE(N)/1000, * RT1EZE(N)/1000,VSCALAR1 C ***************************************************************** C Output file 11 of R(t) and V(t) for plot with MATLAB routines C ***************************************************************** WRITE(11,110)T(N),THETALA(N)/ARC,RT1EXE(N)/1000,RT1EYE(N)/1000, * RT1EZE(N)/1000,VSCALAR1 110 FORMAT(F8.2,F8.2,4F12.2) 111 FORMAT(3X,’TIME’,4X,’THETA’,5X,’X-COORD’,5X,’Y-COORD’,5X, * ’Z-COORD’,4X,’VELOCITY’,/) 30 CONTINUE END SUBROUTINE FCN(NN,TT,Y,YPRIME) C ************************************************************* C Subprogram provides the relations of the set of ordinary C differential equations for the integration procedure C ***************************************************************** IMPLICIT REAL*8 (A-H,O-Z) PARAMETER (NEND = 582000) COMMON GAM,TP,T0,EE0 COMMON ALA(0:NEND),EABSLA(0:NEND),INCLA(0:NEND),OMGLA(0:NEND) COMMON OMKLA(0:NEND),CHILA(0:NEND),THETALA(0:NEND),N,KPERIOD2 DIMENSION Y(NN),YPRIME(NN) REAL*8 INCLA,J2 RE = 6.378D6 B.3 Lagrange’s Planet Equations J2 = 1082.63D-6 EPS = 1.D-6 PI = 3.141592653D0 TTLA = 2.D0*PI*SQRT(Y(1)**3/GAM) CO1 = 2.D0*PI*(TT-TP)/TTLA C ***************************************************************** C Computation of the eccentric anomaly E C C ***************************************************************** 20 FE = EE0 - Y(2)*SIN(EE0) - CO1 DFE = 1.D0 - Y(2)*COS(EE0) EE1 = EE0 - FE/DFE DIFF = ABS(EE1 - EE0) EE0 = EE1 IF(DIFF.GT.EPS)GOTO20 C ***************************************************************** C Determination of the true anomaly theta as function of the C eccentric anomaly E C ***************************************************************** THETA1 = 2.D0*ATAN(SQRT((1.D0+Y(2))/(1.D0-Y(2)))*TAN(EE0/2.D0)) IF(THETA1.GE.0.AND.KPERIOD2.EQ.1)THEN THETA1 = 2.D0*PI + THETA1 END IF IF(THETA1.LT.0)THEN THETA1 = 2.D0*PI + THETA1 KPERIOD2 = 1 END IF VORB = SQRT(GAM/Y(1)**3) RLA = Y(1)*(1.D0-Y(2)**2)/(1.D0 + Y(2)*COS(THETA1)) COEF1 = GAM*J2*RE**2 COEF2 = COS(2.D0*(THETA1 + Y(5))) COEF3 = 0.5D0 - 0.75D0*SIN(Y(3))**2 + 0.75D0*SIN(Y(3))**2*COEF2 COEF4 = 3.D0*Y(2)*SIN(THETA1)/ * (RLA**3*(1.D0 + Y(2)*COS(THETA1))) COEF5 = -2.D0*SIN(2.*(THETA1 + Y(5))) COEF6 = 0.75D0*SIN(Y(3))**2/RLA**3 C ***************************************************************** C Numerical approximation of the derivatives of theta with respect C to the orbital elements C ***************************************************************** IF(N.GT.1)THEN DTHE = THETALA(N) - THETALA(N-1) DTHDA = DTHE/(ALA(N) - ALA(N-1)) DTHDE = DTHE/(EABSLA(N) - EABSLA(N-1)) DTHDI = DTHE/(INCLA(N) - INCLA(N-1)) DTHDOG = DTHE/(OMGLA(N) - OMGLA(N-1)) 257 258 Appendix B FORTRAN Codes DTHDOK = DTHE/(OMKLA(N) - OMKLA(N-1)) DTHDCHI = DTHE/(CHILA(N) - CHILA(N-1)) ELSE DTHDA = 0.D0 DTHDE = 0.D0 DTHDI = 0.D0 DTHDOG = 0.D0 DTHDOK = 0.D0 DTHDCHI = 0.D0 END IF C C ***************************************************************** C Numerical approximation of Lagrange’s planet equations C C ***************************************************************** D1R3DA = -3.D0/(RLA**3*Y(1)) - COEF4*DTHDA DCOSDA = COEF5*DTHDA DWDA =-COEF1*(COEF3*D1R3DA + COEF6*DCOSDA) D1R3DE = 3.D0*(2.D0*Y(2)*Y(1)/RLA + COS(THETA1))/ * (RLA**3*(1.D0 + Y(2)*COS(THETA1))) - COEF4*DTHDE DCOSDE = COEF5*DTHDE DWDE =-COEF1*(COEF3*D1R3DE + COEF6*DCOSDE) D1R3DI =-COEF4*DTHDI DCOSDI = COEF5*DTHDI DWDI =-COEF1*(COEF3*D1R3DI + COEF6*DCOSDI + * 0.75D0*2.D0*SIN(Y(3))*COS(Y(3))/RLA**3*(COEF2-1.D0)) D1R3DOG =-COEF4*DTHDOG DCOSDOG = COEF5*DTHDOG DWDOG =-COEF1*(COEF3*D1R3DOG + COEF6*DCOSDOG) D1R3DOK =-COEF4*DTHDOK DCOSDOK = COEF5*(DTHDOK + 1.D0) DWDOK =-COEF1*(COEF3*D1R3DOK + COEF6*DCOSDOK) D1R3DCHI =-COEF4*DTHDCHI DCOSDCHI = COEF5*DTHDCHI DWDCHI =-COEF1*(COEF3*D1R3DCHI + COEF6*DCOSDCHI) COEF7 = (1.D0 - Y(2)**2)/(VORB*Y(1)**2*Y(2)) COEF8 = SQRT(1.D0 - Y(2)**2)/(VORB*Y(1)**2*Y(2)) COEF9 = 1.D0/(SQRT(1.D0 - Y(2)**2)*VORB*Y(1)**2) COEF10 = 2.D0/(VORB*Y(1)) YPRIME(1) = -COEF10*DWDCHI YPRIME(2) = -COEF7 *DWDCHI + COEF8*DWDOK YPRIME(3) = -COEF9 *DWDOK/TAN(Y(3)) + COEF9*DWDOG/SIN(Y(3)) YPRIME(4) = -COEF9 *DWDI /SIN(Y(3)) YPRIME(5) = -COEF8 *DWDE + COEF9*DWDI/TAN(Y(3)) YPRIME(6) = COEF7 *DWDE + COEF10*DWDA RETURN END References 259 References 1. Vinh, N.X., Busemann, A., Culp, R.D.: Hypersonic and Planetary Entry Flight Mechanics. The University of Michigan Press, Ann Arbor (1980) 2. Escobal, P.R.: Methods of Orbit Determination. John Wiley & Sons, New York (1965) 3. Steiner, W., Schagerl, M.: Raumflugmechanik. Springer, Heidelberg (2004) 4. Sterne, T.E.: An Introduction to Celestial Mechanics. Interscience Publisher, New York (1960) 5. Chobotov, V.A. (ed.): Orbital Mechanics. 3rd edn. AIAA Education Series, Reston, VA (2002)