1 | C============================================================= |
---|
2 | C Subroutine to return distance, longitude, and declination of |
---|
3 | C the sun in planetocentric coordinates from orbital elements |
---|
4 | C |
---|
5 | C INPUTS: |
---|
6 | C edays = time since perihelion (earth days) |
---|
7 | C a = semimajor axis (AU) |
---|
8 | C ecc = eccentricity |
---|
9 | C omega = Ls of perihelion, relative to equinox (radians) |
---|
10 | C eps = obliquity (radians) |
---|
11 | C |
---|
12 | C OUTPUTS: |
---|
13 | C Ls = areocentric longitude (radians) |
---|
14 | C dec = planetocentric solar declination (radians) |
---|
15 | C r = heliocentric distance (AU) |
---|
16 | C============================================================= |
---|
17 | |
---|
18 | SUBROUTINE generalorbit(edays,a,ecc,omega,eps,Ls,dec,r) |
---|
19 | implicit none |
---|
20 | real*8 edays,a,ecc,omega,eps ! input |
---|
21 | real*8 Ls,dec,r ! output |
---|
22 | real*8 pi,d2r |
---|
23 | parameter (pi=3.1415926535897932,d2r=pi/180.d0) |
---|
24 | integer j |
---|
25 | real*8 M,E,nu,T,Eold |
---|
26 | |
---|
27 | c T = orbital period (days) |
---|
28 | T = sqrt(4*pi**2/(6.674e-11*1.989e30)*(a*149.598e9)**3)/86400. |
---|
29 | |
---|
30 | c M = mean anomaly (radians) |
---|
31 | M = 2.*pi*edays/T ! M=0 at perihelion |
---|
32 | |
---|
33 | c E = eccentric anomaly |
---|
34 | c solve M = E - ecc*sin(E) by newton method |
---|
35 | E = M |
---|
36 | do j=1,10 |
---|
37 | Eold = E |
---|
38 | E = E - (E - ecc*sin(E) - M)/(1.-ecc*cos(E)) |
---|
39 | if (abs(E-Eold)<1.e-8) exit |
---|
40 | enddo |
---|
41 | |
---|
42 | c nu = true anomaly |
---|
43 | !nu = acos(cos(E)-ecc/(1.-ecc*cos(E))) |
---|
44 | !nu = sqrt(1-ecc^2)*sin(E)/(1.-ecc*cos(E)) |
---|
45 | !nu = atan(sqrt(1-ecc^2)*sin(E)/(1-cos(E))) |
---|
46 | nu = 2.*atan(sqrt((1.+ecc)/(1.-ecc))*tan(E/2.)) |
---|
47 | |
---|
48 | !r = a*(1.-ecc**2)/(1.+ecc*cos(nu)) |
---|
49 | r = a*(1-ecc*cos(E)) |
---|
50 | Ls = mod(nu + omega,2.*pi) |
---|
51 | dec = asin(sin(eps)*sin(Ls)) |
---|
52 | |
---|
53 | END |
---|
54 | |
---|