mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
constants.hpp
Go to the documentation of this file.
1 /** \file constants.hpp
2  * \author Jared R. Males (jaredmales@gmail.com)
3  * \brief Constants for astronomy.
4  * \ingroup astrofiles
5  *
6  */
7 
8 #ifndef __mx_astro_constants_hpp__
9 #define __mx_astro_constants_hpp__
10 
11 
12 namespace mx
13 {
14 
15 namespace astro
16 {
17 
18 namespace constants
19 {
20 
21 
22 /** \defgroup dimensionless_constants Dimensionless Constants
23  * \ingroup astroconstants
24  * Constants without dimensions are provided with a template argument specifying the precision.
25  * @{
26  */
27 
28 ///Tangent of 1.0 arcsec
29 /** Calculated with 100 digits of precision, recorded here with 50 digits.
30  */
31 template<typename realT>
32 constexpr realT tan_arcsec()
33 {
34  return static_cast<realT>(4.8481368111333441675396429478852851658848753880815e-06);
35 }
36 
37 ///@} Dimensionless Constants
38 
39 
40 /** \defgroup dimensioned_constants Constants with Dimensions
41  * \ingroup astroconstants
42  * Constants with dimensions are provided with a template argument specifying the units system to use, see \ref astrounits.
43  * @{
44  */
45 
46 
47 ///Newton's Gravitational Constant
48 /** Source: 2014 CODATA recommended values \cite codata_2014, http://physics.nist.gov/cuu/Constants/index.html
49  */
50 template<typename units>
51 constexpr typename units::realT G()
52 {
53  return static_cast<typename units::realT>(6.67408e-11) * (units::length*units::length*units::length)/(units::mass * units::time*units::time);
54 }
55 
56 ///The speed of light.
57 /** Source: 2014 CODATA recommended values \cite codata_2014, http://physics.nist.gov/cuu/Constants/index.html
58  */
59 template<typename units>
60 constexpr typename units::realT c()
61 {
62  return static_cast<typename units::realT>(299792458)* (units::length/units::time);
63 }
64 
65 ///Boltzmann Constant
66 /** \f$ k = 1.38064852 \times 10^{-23} \: J \: K^{-1}\f$
67  *
68  * Source: 2014 CODATA recommended values \cite codata_2014, http://physics.nist.gov/cuu/Constants/index.html
69  */
70 template<typename units>
71 constexpr typename units::realT k()
72 {
73  return static_cast<typename units::realT>(1.38064852e-23) * units::energy / units::temperature;
74 }
75 
76 ///Stefan-Boltzmann Constant
77 /** \f$ \sigma = 5.670367 \times 10^{-8} \: W \: m^{-2} \: K^{-4} \f$
78  *
79  * Source: 2014 CODATA recommended values \cite codata_2014, http://physics.nist.gov/cuu/Constants/index.html
80  */
81 template<typename units>
82 constexpr typename units::realT sigma()
83 {
84  return static_cast<typename units::realT>(5.670367e-8) * (units::energy/units::time) / (units::length*units::length) / (units::temperature*units::temperature*units::temperature*units::temperature);
85 }
86 
87 ///Planck Constant
88 /** Source: 2014 CODATA recommended values \cite codata_2014, http://physics.nist.gov/cuu/Constants/index.html
89  */
90 template<typename units>
91 constexpr typename units::realT h()
92 {
93  return static_cast<typename units::realT>(6.626070040e-34) * units::energy * units::time;
94 }
95 
96 ///Length of day
97 /** As defined by IAU
98  */
99 template<typename units>
100 constexpr typename units::realT day()
101 {
102  return static_cast<typename units::realT>(86400.0)*units::time;
103 }
104 
105 ///Length of year
106 /** As defined by IAU
107  */
108 template<typename units>
109 constexpr typename units::realT year()
110 {
111  return (static_cast<typename units::realT>(365.25)*static_cast<typename units::realT>(86400.0))*units::time;
112 }
113 
114 ///Astronomical Unit
115 /** As defined by IAU Resolution 2012 B2
116  */
117 template<typename units>
118 constexpr typename units::realT au()
119 {
120  return static_cast<typename units::realT>(149597870700.0)*units::length;
121 }
122 
123 ///The parsec
124 template<typename units>
125 constexpr typename units::realT parsec()
126 {
127  return au<units>()/tan_arcsec<typename units::realT>();
128 }
129 
130 
131 ///Radius of the Sun
132 /** \f$ R_{sun} = 6.957\times 10^{8} \: m\f$
133  *
134  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
135  */
136 template<typename units>
137 constexpr typename units::realT radSun()
138 {
139  return static_cast<typename units::realT>(6.957e8)*units::length;
140 }
141 
142 ///Solar Irradiance at 1 au
143 /** \f$ S_{sun} = 1361 \: W \: m^{-2}\f$
144  *
145  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
146  */
147 template<typename units>
148 constexpr typename units::realT solarIrrad()
149 {
150  return static_cast<typename units::realT>(1361)*units::energy/units::time/(units::length*units::length);
151 }
152 
153 ///Luminosity of the Sun
154 /** \f$ L_{sun} = 3.828\times 10^{26} \: W\f$
155  *
156  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
157  */
158 template<typename units>
159 constexpr typename units::realT lumSun()
160 {
161  return static_cast<typename units::realT>(3.828e26)*units::energy/units::time;
162 }
163 
164 ///Effective Temperature of the Sun
165 /** \f$ T_{sun} = 5772 \: K \f$
166  *
167  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
168  */
169 template<typename units>
170 constexpr typename units::realT TeffSun()
171 {
172  return static_cast<typename units::realT>(5772.0)*units::temperature;
173 }
174 
175 /// Solar Mass Parameter
176 /** \f$ GM_{sun} = 1.3271244 \times 10^20 \: m^3 \: s^{-2} \f$
177  *
178  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
179  */
180 template<typename units>
181 constexpr typename units::realT GMSun()
182 {
183  return static_cast<typename units::realT>(1.3271244e20)*(units::length*units::length*units::length)/(units::time*units::time);
184 }
185 
186 /// Solar Mass
187 /** The mass of Sun is the \ref GMSun() "Solar mass parameter" divided by the \ref G() "graviational constant".
188  *
189  * \f$ M_{Sun} = GM_{Sun}/G \f$
190  *
191  */
192 template<typename units>
193 constexpr typename units::realT massSun()
194 {
195  return GMSun<units>()/G<units>();
196 }
197 
198 /// Radius of Earth (nominal equatorial)
199 /** \f$ R_{e} = 6.3781\times 10^6 \: m \f$
200  *
201  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
202  */
203 template<typename units>
204 constexpr typename units::realT radEarth()
205 {
206  return static_cast<typename units::realT>(6.3781e6)*units::length;
207 }
208 
209 /// Earth Mass Parameter
210 /** \f$ GM_{e} = 3.986004 \times 10^14 \: m^3 \: s^{-2} \f$
211  *
212  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
213  */
214 template<typename units>
215 constexpr typename units::realT GMEarth()
216 {
217  return static_cast<typename units::realT>(3.986004e14)*(units::length*units::length*units::length)/(units::time*units::time);
218 }
219 
220 /// Earth Mass
221 /** The mass of Earth is the \ref GMEarth() "mass parameter" divided by the \ref G() "gravitational constant".
222  *
223  * \f$ M_{e} = GM_{e}/G \f$
224  *
225  */
226 template<typename units>
227 constexpr typename units::realT massEarth()
228 {
229  return GMEarth<units>()/G<units>();
230 }
231 
232 /// Radius of Jupiter (nominal equatorial)
233 /** \f$ R_{J} = 7.1492\times 10^7 \: m \f$
234  *
235  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
236  */
237 template<typename units>
238 constexpr typename units::realT radJupiter()
239 {
240  return static_cast<typename units::realT>(7.1492e7)*units::length;
241 }
242 
243 /// Jupiter Mass Parameter
244 /** \f$ GM_{J} = 1.2668653 \times 10^17 \: m^3 \: s^{-2} \f$
245  *
246  * Source: IAU Resolution 2015 B2, <a href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a>
247  */
248 template<typename units>
249 constexpr typename units::realT GMJupiter()
250 {
251  return static_cast<typename units::realT>(1.2668653e17)*(units::length*units::length*units::length)/(units::time*units::time);
252 }
253 
254 /// Jupiter Mass
255 /** The mass of Jupiter is the \ref GMJupiter() "Jupiter mass parameter" divided by the \ref G() "gravitational constant".
256  *
257  * \f$ M_{J} = GM_{J}/G \f$
258  *
259  */
260 template<typename units>
261 constexpr typename units::realT massJupiter()
262 {
263  return GMJupiter<units>()/G<units>();
264 }
265 
266 
267 
268 /// Mass ratio of Mercury to the Sun.
269 /**
270  * \f$ M_{Sun}/M_{Me} = 6.023657330 \times 10^{6} \f$
271  *
272  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
273  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
274  *
275  */
276 template<typename units>
277 constexpr typename units::realT mrMercury()
278 {
279  return static_cast<typename units::realT>(6.023657330e6);
280 }
281 
282 /// Mass of Mercury.
283 /**
284  * The mass of Mercury is the \ref massSun() "mass of the Sun" divided by the \ref mrMercury() "mass ratio of Mercury to the Sun".
285  *
286  */
287 template<typename units>
288 constexpr typename units::realT massMercury()
289 {
290  return massSun<units>()/mrMercury<units>();
291 }
292 
293 /// Radius of Mercury.
294 /**
295  * \f$ = 2.4397 \times 10^{6}
296  *
297  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
298  *
299  */
300 template<typename units>
301 constexpr typename units::realT radMercury()
302 {
303  return static_cast<typename units::realT>(2.4397e6)*units::length;
304 }
305 
306 /// Mass ratio of Venus to the Sun.
307 /**
308  * \f$ M_{Sun}/M_{Ve} = 4.08523719 \times 10^{5}\f$
309  *
310  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
311  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
312  *
313  */
314 template<typename units>
315 constexpr typename units::realT mrVenus()
316 {
317  return static_cast<typename units::realT>(4.08523719e5);
318 }
319 
320 /// Mass of Venus.
321 /**
322  * The mass of Venus is the \ref massSun() "mass of the Sun" divided by the \ref mrVenus() "mass ratio of Venus to the Sun".
323  *
324  */
325 template<typename units>
326 constexpr typename units::realT massVenus()
327 {
328  return massSun<units>()/mrVenus<units>();
329 }
330 
331 /// Radius of Venus.
332 /**
333  * \f$ = 6.0518 \times 10^{6}
334  *
335  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
336  *
337  */
338 template<typename units>
339 constexpr typename units::realT radVenus()
340 {
341  return static_cast<typename units::realT>(6.0518e6)*units::length;
342 }
343 
344 /// Mass ratio of Mars to the Sun.
345 /**
346  * \f$ M_{Sun}/M_{Ma} = 3.09870359 \times 10^{6}\f$
347  *
348  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
349  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
350  *
351  */
352 template<typename units>
353 constexpr typename units::realT mrMars()
354 {
355  return static_cast<typename units::realT>( 3.09870359e6);
356 }
357 
358 /// Mass of Mars.
359 /**
360  * The mass of Mars is the mass of the Sun divided by the mass ratio of Mars to the Sun.
361  *
362  */
363 template<typename units>
364 constexpr typename units::realT massMars()
365 {
366  return massSun<units>()/mrMars<units>();
367 }
368 
369 /// Radius of Mars.
370 /**
371  * \f$ = 3.39619 \times 10^{6}
372  *
373  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
374  *
375  */
376 template<typename units>
377 constexpr typename units::realT radMars()
378 {
379  return static_cast<typename units::realT>(3.39619e6)*units::length;
380 }
381 
382 /// Mass ratio of Saturn to the Sun.
383 /**
384  * \f$ M_{Sun}/M_{Sa} = 3.4979018 \times 10^{3}\f$
385  *
386  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
387  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
388  *
389  */
390 template<typename units>
391 constexpr typename units::realT mrSaturn()
392 {
393  return static_cast<typename units::realT>( 3.4979018e3);
394 }
395 
396 /// Mass of Saturn.
397 /**
398  * The mass of Saturn is the mass of the Sun divided by the mass ratio of Saturn to the Sun.
399  *
400  */
401 template<typename units>
402 constexpr typename units::realT massSaturn()
403 {
404  return massSun<units>()/mrSaturn<units>();
405 }
406 
407 /// Radius of Saturn.
408 /**
409  * \f$ = 6.0268 \times 10^{7}
410  *
411  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
412  *
413  */
414 template<typename units>
415 constexpr typename units::realT radSaturn()
416 {
417  return static_cast<typename units::realT>(6.0268e7)*units::length;
418 }
419 
420 
421 /// Mass ratio of Uranus to the Sun.
422 /**
423  * \f$ M_{Sun}/M_{U} = 2.2902951 \times 10^{4}\f$
424  *
425  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
426  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
427  *
428  */
429 template<typename units>
430 constexpr typename units::realT mrUranus()
431 {
432  return static_cast<typename units::realT>( 2.2902951e4);
433 }
434 
435 /// Mass of Uranus.
436 /**
437  * The mass of Uranus is the mass of the Sun divided by the mass ratio of Uranus to the Sun.
438  *
439  */
440 template<typename units>
441 constexpr typename units::realT massUranus()
442 {
443  return massSun<units>()/mrUranus<units>();
444 }
445 
446 /// Radius of Uranus.
447 /**
448  * \f$ = 2.5559 \times 10^{7}
449  *
450  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
451  *
452  */
453 template<typename units>
454 constexpr typename units::realT radUranus()
455 {
456  return static_cast<typename units::realT>(2.5559e7)*units::length;
457 }
458 
459 /// Mass ratio of Neptune to the Sun.
460 /**
461  * \f$ M_{Sun}/M_{U} = 1.941226 \times 10^{4}\f$
462  *
463  * Source: IAU Resolution 2009 B2, <a href="https://www.iau.org/static/resolutions/IAU2009_English.pdf">https://www.iau.org/static/resolutions/IAU2009_English.pdf</a>.
464  * see also <a href="http://maia.usno.navy.mil/NSFA/NSFA_cbe.html">http://maia.usno.navy.mil/NSFA/NSFA_cbe.html</a>
465  *
466  */
467 template<typename units>
468 constexpr typename units::realT mrNeptune()
469 {
470  return static_cast<typename units::realT>( 1.941226e4);
471 }
472 
473 /// Mass of Neptune.
474 /**
475  * The mass of Neptune is the mass of the Sun divided by the mass ratio of Neptune to the Sun.
476  *
477  */
478 template<typename units>
479 constexpr typename units::realT massNeptune()
480 {
481  return massSun<units>()/mrNeptune<units>();
482 }
483 
484 /// Radius of Neptune.
485 /**
486  * \f$ = 2.4764 \times 10^{7}
487  *
488  * Source: Seidelmann et al. (2007) \cite seidelmann_2007
489  *
490  */
491 template<typename units>
492 constexpr typename units::realT radNeptune()
493 {
494  return static_cast<typename units::realT>(2.4764e7)*units::length;
495 }
496 
497 
498 ///@} Dimensioned constants
499 
500 } //namespace constants
501 } //namespace astro
502 } //namespace mx
503 
504 
505 #endif //__mx_astro_constants_hpp__
506 
constexpr units::realT G()
Newton's Gravitational Constant.
Definition: constants.hpp:51
constexpr units::realT radSaturn()
Radius of Mars.
Definition: constants.hpp:415
constexpr units::realT radNeptune()
Radius of Uranus.
Definition: constants.hpp:492
constexpr units::realT year()
Length of year.
Definition: constants.hpp:109
constexpr units::realT GMJupiter()
Jupiter Mass Parameter.
Definition: constants.hpp:249
constexpr units::realT radEarth()
Radius of Earth (nominal equatorial)
Definition: constants.hpp:204
constexpr units::realT c()
The speed of light.
Definition: constants.hpp:60
constexpr units::realT parsec()
The parsec.
Definition: constants.hpp:125
constexpr units::realT massUranus()
Mass of Uranus.
Definition: constants.hpp:441
constexpr units::realT radVenus()
Radius of Mercury.
Definition: constants.hpp:339
constexpr units::realT mrMercury()
Mass ratio of Mercury to the Sun.
Definition: constants.hpp:277
constexpr units::realT radSun()
Radius of the Sun.
Definition: constants.hpp:137
constexpr units::realT massMars()
Mass of Mars.
Definition: constants.hpp:364
constexpr units::realT GMEarth()
Earth Mass Parameter.
Definition: constants.hpp:215
constexpr units::realT mrUranus()
Mass ratio of Uranus to the Sun.
Definition: constants.hpp:430
constexpr units::realT massSun()
Solar Mass.
Definition: constants.hpp:193
constexpr units::realT radJupiter()
Radius of Jupiter (nominal equatorial)
Definition: constants.hpp:238
constexpr units::realT massMercury()
Mass of Mercury.
Definition: constants.hpp:288
constexpr units::realT lumSun()
Luminosity of the Sun.
Definition: constants.hpp:159
constexpr units::realT h()
Planck Constant.
Definition: constants.hpp:91
constexpr units::realT GMSun()
Solar Mass Parameter.
Definition: constants.hpp:181
constexpr units::realT sigma()
Stefan-Boltzmann Constant.
Definition: constants.hpp:82
constexpr units::realT day()
Length of day.
Definition: constants.hpp:100
constexpr units::realT mrMars()
Mass ratio of Mars to the Sun.
Definition: constants.hpp:353
constexpr units::realT massEarth()
Earth Mass.
Definition: constants.hpp:227
constexpr units::realT au()
Astronomical Unit.
Definition: constants.hpp:118
constexpr units::realT TeffSun()
Effective Temperature of the Sun.
Definition: constants.hpp:170
constexpr units::realT massJupiter()
Jupiter Mass.
Definition: constants.hpp:261
constexpr units::realT solarIrrad()
Solar Irradiance at 1 au.
Definition: constants.hpp:148
constexpr units::realT k()
Boltzmann Constant.
Definition: constants.hpp:71
constexpr realT tan_arcsec()
Tangent of 1.0 arcsec.
Definition: constants.hpp:32
The mxlib c++ namespace.
Definition: mxError.hpp:107