Cloudy
Spectral Synthesis Code for Astrophysics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physconst_template.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 // >>>>>>>> WARNING: do not #define PHYSCONST_TEMPLATE_H_
5 
6 // >>>>>>>> WARNING: This is a header template file, designed to be included
7 // on more than one occasion, with the macro NEW_CONSTANT defined to achieve
8 // different actions on each include, and no include guard
9 //
10 // Do not include anything here which isn't required for this single purpose
11 
21 /*********************************************************************
22  * first come math constants *
23  *********************************************************************/
24 
25 // Define macros for mathematical operations, undefined at foot of file
26 // Can be converted back when constexpr() can be relied on (C++11)
27 
28 #define pow2(a) ((a)*(a))
29 #define pow3(a) ((a)*(a)*(a))
30 
32 NEW_CONSTANT( EE, 2.718281828459045235360287 );
33 
35 NEW_CONSTANT( EULER, 0.577215664901532860606512090082 );
36 
38 NEW_CONSTANT( EXPEULER2, 0.74930600128844902360587 );
39 
41 NEW_CONSTANT( PI, 3.141592653589793238462643 );
42 
44 NEW_CONSTANT( PI2, 6.283185307179586476925287 );
45 
47 NEW_CONSTANT( PI4, 12.56637061435917295385057 );
48 
50 NEW_CONSTANT( PI8, 25.13274122871834590770115 );
51 
53 NEW_CONSTANT( SQRT2, 1.414213562373095048801689 );
54 
56 NEW_CONSTANT( SQRTPI, 1.772453850905516027298167 );
57 
59 NEW_CONSTANT( SQRTPIBY2, 1.253314137315500251207883 );
60 
62 NEW_CONSTANT( LN_TWO, 0.6931471805599453094172321 );
63 
65 NEW_CONSTANT( LN_TEN, 2.302585092994045684017991 );
66 
68 NEW_CONSTANT( LOG10_E, 0.4342944819032518276511289 );
69 
72 NEW_CONSTANT( OPTDEP2EXTIN, 1.085736204758129569127822 );
73 
75 NEW_CONSTANT( RADIAN, 57.29577951308232087679815 );
76 
77 /*********************************************************************
78  * astronomical constants go here *
79  *********************************************************************/
80 
83 NEW_CONSTANT( SOLAR_MASS, 1.98848e33 );
84 
87 NEW_CONSTANT( SOLAR_LUMINOSITY, 3.828e33 );
88 
91 NEW_CONSTANT( MBOL_ZERO_LUMINOSITY, 3.0128e35 );
92 
95 /* >>refer phys const http://pdg.lbl.gov/2019/reviews/rpp2018-rev-astrophysical-constants.pdf */
96 NEW_CONSTANT( AU, 1.49597870700e13 );
97 
98 /*********************************************************************
99  * fundamental constants go next, eventually rest should be defined *
100  * in terms of these, these are CODATA 2018 values. *
101  *********************************************************************/
102 
104 NEW_CONSTANT( ELECTRON_MASS, 9.1093837015e-28 );
105 
107 NEW_CONSTANT( ELECTRON_MASS_U, 5.48579909065e-4 );
108 
110 NEW_CONSTANT( PROTON_MASS, 1.67262192369e-24 );
111 
113 NEW_CONSTANT( PROTON_MASS_U, 1.007276466621 );
114 
116 NEW_CONSTANT( ALPHA_MASS_U, 4.001506179127 );
117 
119 NEW_CONSTANT( BOLTZMANN, 1.380649e-16 );
120 
122 NEW_CONSTANT( SPEEDLIGHT, 2.99792458e10 );
123 
125 NEW_CONSTANT( HPLANCK, 6.62607015e-27 );
126 
128 NEW_CONSTANT( AVOGADRO, 6.02214076e23 );
129 
131 NEW_CONSTANT( GRAV_CONST, 6.67430e-8 );
132 
134 NEW_CONSTANT( ELEM_CHARGE, 1.602176634e-19 );
135 
137 NEW_CONSTANT( RYD_INF, 1.0973731568160e5 );
138 
141 NEW_CONSTANT( HIONPOT, 0.999466508345 );
142 
145 NEW_CONSTANT( HE2IONPOT, 3.99963199547 );
146 
149 NEW_CONSTANT( HMINUSIONPOT, 0.055432956 );
150 
152 NEW_CONSTANT( ATOMIC_MASS_UNIT, 1.66053906660e-24 );
153 
154 /*********************************************************************
155  * below here should be derived constants *
156  * *
157  * NB - explicit values in comments are approximate *
158  * and are not maintained ! *
159  *********************************************************************/
160 
162 NEW_CONSTANT( MOL_MASS_CONST, AVOGADRO*ATOMIC_MASS_UNIT );
163 
165 NEW_CONSTANT( AS1RAD, RADIAN*3600. );
166 
168 NEW_CONSTANT( SQAS1SR, pow2(AS1RAD) );
169 
171 NEW_CONSTANT( SQAS_SKY, PI4*SQAS1SR );
172 
174 NEW_CONSTANT( PARSEC, AU*AS1RAD );
175 
177 NEW_CONSTANT( MEGAPARSEC, 1.e6*PARSEC );
178 
180 NEW_CONSTANT( H_BAR, HPLANCK/(2.*PI) );
181 
183 NEW_CONSTANT( ELEM_CHARGE_ESU, ELEM_CHARGE*SPEEDLIGHT/10. );
184 
186 NEW_CONSTANT( ELECTRIC_CONST, 1.e11/(PI4*pow2(SPEEDLIGHT)) );
187 
193 NEW_CONSTANT( HION_LTE_POP, pow2(HPLANCK)/(PI2*BOLTZMANN*ELECTRON_MASS) );
194 
197 #ifdef HAVE_CONSTEXPR
198 NEW_CONSTANT( SAHA, sqrt(pow3(HION_LTE_POP)) );
199 #else
200 // Need to use explicit constant rather than formula as sqrt() isn't
201 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
202 // in t_physconst::t_physconst() in physconst.cpp
203 NEW_CONSTANT( SAHA, 4.1413302848114741e-16 );
204 #endif
205 
207 NEW_CONSTANT( ERG1CM, HPLANCK*SPEEDLIGHT );
208 
210 NEW_CONSTANT( T1CM, HPLANCK*SPEEDLIGHT/BOLTZMANN );
211 
213 NEW_CONSTANT( KJMOL1CM, ERG1CM*AVOGADRO/1e10 );
214 
216 NEW_CONSTANT( H_RYD_FACTOR, 1./(1.+ELECTRON_MASS_U/PROTON_MASS_U) );
217 
219 NEW_CONSTANT( HE_RYD_FACTOR, 1./(1.+ELECTRON_MASS_U/ALPHA_MASS_U) );
220 
222 NEW_CONSTANT( WAVNRYD, 1./RYD_INF );
223 
225 NEW_CONSTANT( RYDLAM, 1.e8/RYD_INF );
226 
228 NEW_CONSTANT( EN1RYD, HPLANCK*SPEEDLIGHT*RYD_INF );
229 
232 NEW_CONSTANT( TE1RYD, HPLANCK*SPEEDLIGHT*RYD_INF/BOLTZMANN );
233 
235 NEW_CONSTANT( EVDEGK, ELEM_CHARGE*1.e7/BOLTZMANN );
236 
238 NEW_CONSTANT( EVRYD, HPLANCK*SPEEDLIGHT*RYD_INF/ELEM_CHARGE*1.e-7 );
239 
241 NEW_CONSTANT( EN1EV, EN1RYD/EVRYD );
242 
244 NEW_CONSTANT( FR1RYD, SPEEDLIGHT*RYD_INF );
245 
247 NEW_CONSTANT( HNU3C2, 2.*HPLANCK*SPEEDLIGHT*pow3(RYD_INF) );
248 
250 NEW_CONSTANT( FR1RYDHYD, SPEEDLIGHT*RYD_INF*HIONPOT );
251 
253 NEW_CONSTANT( HBAReV, H_BAR/EN1EV );
254 
256 NEW_CONSTANT( RYDLAMHYD, RYDLAM/HIONPOT );
257 
259 NEW_CONSTANT( STEFAN_BOLTZ, pow2(PI*pow2(BOLTZMANN))/(60.*pow3(H_BAR)*pow2(SPEEDLIGHT)) );
260 
262 NEW_CONSTANT( FREQ_1EV, SPEEDLIGHT*RYD_INF/EVRYD );
263 
265 NEW_CONSTANT( FINE_STRUCTURE, pow2(ELEM_CHARGE_ESU)/SPEEDLIGHT/H_BAR );
266 
268 NEW_CONSTANT( FINE_STRUCTURE2, pow2(FINE_STRUCTURE) );
269 
271 NEW_CONSTANT( BOHR_RADIUS_CM, FINE_STRUCTURE/(PI4*RYD_INF) );
272 
274 NEW_CONSTANT( TWO_PHOT_CONST, 9.*pow3(FINE_STRUCTURE2)*FR1RYD/2048. );
275 
278 NEW_CONSTANT( COLL_CONST, SAHA*BOLTZMANN/HPLANCK );
279 
282 #ifdef HAVE_CONSTEXPR
283 NEW_CONSTANT( MILNE_CONST, SPEEDLIGHT*sqrt(pow3(FINE_STRUCTURE2)*pow3(TE1RYD)/PI) );
284 #else
285 // Need to use explicit constant rather than formula as sqrt() isn't
286 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
287 // in t_physconst::t_physconst() in physconst.cpp
288 NEW_CONSTANT( MILNE_CONST, 4.1234755895831189e+11 );
289 #endif
290 
293 NEW_CONSTANT( TRANS_PROB_CONST, PI4*HPLANCK*FINE_STRUCTURE/ELECTRON_MASS );
294 
300 NEW_CONSTANT( ABSOR_COEFF_CONST, SQRTPI*pow2(ELEM_CHARGE_ESU)/(ELECTRON_MASS*SPEEDLIGHT) );
301 
303 NEW_CONSTANT( SIGMA_THOMSON, PI8/3.*pow2(FINE_STRUCTURE*H_BAR/(ELECTRON_MASS*SPEEDLIGHT)) );
304 
307 NEW_CONSTANT( HC_ERG_ANG, HPLANCK*SPEEDLIGHT*1e8 );
308 
310 NEW_CONSTANT( JEANS, PI*BOLTZMANN/(GRAV_CONST*ATOMIC_MASS_UNIT) );
311 
312 /* Free-free emission constant.
313  * This is defined as the constant in the FF cooling equation (5.14a) in Rybicki & Lightman
314  * divided by the Planck constant. This is obtained by integrating equation (5.14a) over
315  * frequency and changing variables to energy in units of R_inf. A factor R_inf*c comes out
316  * of the integral, which is accounted for by multiplying the constant by EN1RYD = R_inf * h * c,
317  * but we need to correct for the extra h.
318  * The exact equation is:
319  * 32*pi * e^6 / (3 * h * m_e * c^3) * sqrt(2*pi / (3 * k_Boltzmann * m_e))
320  */
321 #ifdef HAVE_CONSTEXPR
322 NEW_CONSTANT( FREE_FREE_EMIS,
323  32. * PI * pow(ELEM_CHARGE_ESU, 6.) /
324  (3. * pow3(SPEEDLIGHT) * ELECTRON_MASS * HPLANCK ) *
325  sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) );
326 #else
327 // Need to use explicit constant rather than formula as sqrt() isn't
328 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
329 // in t_physconst::t_physconst() in physconst.cpp
330 NEW_CONSTANT( FREE_FREE_EMIS, 1.0325265080202923e-11 );
331 #endif
332 
333 /* Free-free absorption constant.
334  * The constant is obtained by considering the integral of absorption over frequency
335  * to compute the total heating rate. The logic is similar to that for the emission
336  * constant above. NB The radiation field is already expressed as dnu*Inu, so that
337  * leaves 3 powers of (R_inf * c) in the denominator, from the nu^-3 dependence --
338  * see Rybicki & Lightman eqn (5.18a).
339  *
340  * The exact constant is:
341  * 4 * e^6 / (3 * h * m * c) * sqrt(2*pi / (3 * k_Boltzmann * m_e)) / (R_inf * c)^3
342  */
343 #ifdef HAVE_CONSTEXPR
344 NEW_CONSTANT( FREE_FREE_ABS,
345  4. * pow(ELEM_CHARGE_ESU, 6.) /
346  (3. * HPLANCK * ELECTRON_MASS * SPEEDLIGHT ) *
347  sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) /
348  pow3(SPEEDLIGHT * RYD_INF) );
349 #else
350 // Need to use explicit constant rather than formula as sqrt() isn't
351 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
352 // in t_physconst::t_physconst() in physconst.cpp
353 NEW_CONSTANT( FREE_FREE_ABS, 1.0369973575937702e-38 );
354 #endif
#define pow3(a)
Definition: physconst_template.h:29
NEW_CONSTANT(EE, 2.718281828459045235360287)
#define pow2(a)
Definition: physconst_template.h:28
double pow(double x, int i)
Definition: cddefines.h:782