1 /*
2  *  - - - - - - - - - -
3  *   g a l _ m a f m s
4  *  - - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *     This routine calculates the parameters for the Mars
11  *     Fictitious Mean Sun and related parameters.
12  *
13  *  Status:
14  *
15  *     support routine.
16  *
17  *  Given:
18  *
19  *     tt1                 d        TT date part 1 ( see Note 1 )
20  *     tt2                 d        TT date part 2 ( see Note 1 )
21  *
22  *  Returned:
23  *
24  *     *m                  d        Mean anomaly ( radians )
25  *     *fms                d        Fictitious Maen Sun Angle ( radians )
26  *     *pbs                d        Sum of angular perturbations in longitude ( radians )
27  *     *ls                 d        Aerocentric solar longitude ( radians )
28  *     *eot                d        Equation of Time ( radians )
29  *
30  *  Notes:
31  *
32  *  1) The Julian Date is apportioned in any convenient way between
33  *     the arguments tt1 and tt2.  For example, JD=2450123.7 could
34  *     be expressed in any of these ways, among others:
35  *
36  *               tt1          tt2
37  *
38  *         2450123.7          0.0   (JD method)
39  *         2451545.0      -1421.3   (J2000 method)
40  *         2400000.5      50123.2   (MJD method)
41  *         2450123.5          0.2   (date & time method)
42  *
43  *  Called:
44  *
45  *     gal_anp             Normalize angle to 0 <= a < pi
46  *
47  *  References:
48  *
49  *     A post-Pathfinder evaluation of areocentric solar coordinates with
50  *     improved timing recipes for Mars seasonal/diurnal climate studies
51  *     by Michael Allison, Megan McEwen,
52  *     Planetary and Space Science 48 (2000) 215-235
53  *
54  *     Mars24 URL: http://www.giss.nasa.gov/tools/mars24/help/algorithm.html
55  *     The referenced URL contains corrections to the referenced article.
56  *
57  *  This revision:
58  *
59  *     2009 January 5
60  *
61  *  Copyright (C) 2009 Paul C. L. Willmott. See notes at end.
62  *
63  *-----------------------------------------------------------------------
64  */
65 
66 #include <math.h>
67 #include "gal_mafms.h"
68 #include "gal_const.h"
69 #include "gal_anp.h"
70 
71 void
gal_mafms(double tt1,double tt2,double * m,double * fms,double * pbs,double * ls,double * eot)72 gal_mafms
73  (
74     double tt1,
75     double tt2,
76     double *m,
77     double *fms,
78     double *pbs,
79     double *ls,
80     double *eot
81  )
82 
83 {
84 
85   double dt, x, p0, p1, p2, p3, p4, p5, p6, p7, vmm, a ;
86 
87   int i ;
88 
89 /*
90  * Primary short-term perturbations for the aerocentric solar longitude.
91  * From Table 5 equivalent in URL referenced.
92  */
93 
94   const double pert[7][3] = {
95     { 0.0071,  2.2353,  49.409, } ,
96     { 0.0057,  2.7543, 168.173, } ,
97     { 0.0039,  1.1177, 191.837, } ,
98     { 0.0037, 15.7866,  21.736, } ,
99     { 0.0021,  2.1354,  15.704, } ,
100     { 0.0020,  2.4694,  95.528, } ,
101     { 0.0018, 32.8493,  49.095, } ,
102   } ;
103 
104 
105 /*
106  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107  */
108 
109 /*
110  * Calculate delta tt since J2000
111  */
112 
113   dt = ( tt1 - GAL_J2000 ) + tt2 ;
114 
115 /*
116  * Determine Mars mean anomaly. (AM2000, eq. 16)
117  */
118 
119   *m = gal_anp ( GAL_D2R * ( 19.3870 + 0.52402075 * dt ) ) ;
120 
121 /*
122  * Determine angle of Fiction Mean Sun. (AM2000, eq. 17)
123  */
124 
125   *fms = gal_anp ( GAL_D2R * (270.3863 + 0.52403840 * dt ) ) ;
126 
127 /*
128  * Determine perturbers. (AM2000, eq. 18)
129  */
130 
131   *pbs = 0.0 ;
132 
133   for ( i = 0; i < 7; i++ ) {
134     a   = GAL_D2R * pert[i][0] ;
135     x = GAL_D2R * ( 360.0 / 365.25 * dt / pert[i][1] + pert[i][2] ) ;
136     *pbs += a * cos ( x ) ;
137   }
138 
139 /*
140  * Determine Equation of Center. (Bracketed term in AM2000, eqs. 19 and 20)
141  * The equation of center is the true anomaly minus mean anomaly.
142  */
143 
144   p0 = GAL_D2R * ( 10.691 + 3.0e-7 * dt ) ;
145   p1 = GAL_D2R * 0.623 ;
146   p2 = GAL_D2R * 0.050 ;
147   p3 = GAL_D2R * 0.005 ;
148   p4 = GAL_D2R * 0.0005 ;
149 
150   vmm = p0 * sin ( (*m) ) +
151         p1 * sin ( 2.0 * (*m) ) +
152         p2 * sin ( 3.0 * (*m) ) +
153         p3 * sin ( 4.0 * (*m) ) +
154         p4 * sin ( 5.0 * (*m) ) +
155         (*pbs) ;
156 
157 /*
158  * Determine areocentric solar longitude. (AM2000, eq. 19)
159  */
160 
161   *ls = gal_anp ( *fms + vmm ) ;
162 
163 /*
164  * Determine Equation of Time. (AM2000, eq. 20)
165  */
166 
167   p5 = GAL_D2R * 2.861 ;
168   p6 = GAL_D2R * 0.071 ;
169   p7 = GAL_D2R * 0.002 ;
170 
171   *eot = p5 * sin ( 2.0 * (*ls) ) -
172          p6 * sin ( 4.0 * (*ls) ) +
173          p7 * sin ( 6.0 * (*ls) ) -
174          vmm ;
175 
176 /*
177  * Finished.
178  */
179 
180 }
181 
182 /*
183  *  gal - General Astrodynamics Library
184  *  Copyright (C) 2009 Paul C. L. Willmott
185  *
186  *  This program is free software; you can redistribute it and/or modify
187  *  it under the terms of the GNU General Public License as published by
188  *  the Free Software Foundation; either version 2 of the License, or
189  *  (at your option) any later version.
190  *
191  *  This program is distributed in the hope that it will be useful,
192  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
193  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
194  *  GNU General Public License for more details.
195  *
196  *  You should have received a copy of the GNU General Public License along
197  *  with this program; if not, write to the Free Software Foundation, Inc.,
198  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
199  *
200  *  Contact:
201  *
202  *  Paul Willmott
203  *  vp9mu@amsat.org
204  */
205 
206