cloudy  trunk
 All Data Structures 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( PI, 3.141592653589793238462643 );
39 
41 NEW_CONSTANT( PI2, 6.283185307179586476925287 );
42 
44 NEW_CONSTANT( PI4, 12.56637061435917295385057 );
45 
47 NEW_CONSTANT( PI8, 25.13274122871834590770115 );
48 
50 NEW_CONSTANT( SQRT2, 1.414213562373095048801689 );
51 
53 NEW_CONSTANT( SQRTPI, 1.772453850905516027298167 );
54 
56 NEW_CONSTANT( SQRTPIBY2, 1.253314137315500251207883 );
57 
59 NEW_CONSTANT( LN_TWO, 0.6931471805599453094172321 );
60 
62 NEW_CONSTANT( LN_TEN, 2.302585092994045684017991 );
63 
65 NEW_CONSTANT( LOG10_E, 0.4342944819032518276511289 );
66 
69 NEW_CONSTANT( OPTDEP2EXTIN, 1.085736204758129569127822 );
70 
72 NEW_CONSTANT( RADIAN, 57.29577951308232087679815 );
73 
74 /*********************************************************************
75  * astronomical constants go here *
76  *********************************************************************/
77 
80 NEW_CONSTANT( SOLAR_MASS, 1.9885e33 );
81 
84 NEW_CONSTANT( SOLAR_LUMINOSITY, 3.828e33 );
85 
88 NEW_CONSTANT( MBOL_ZERO_LUMINOSITY, 3.02e35 );
89 
92 /* >>refer phys const http://pdg.lbl.gov/2014/reviews/rpp2014-rev-astrophysical-constants.pdf */
93 NEW_CONSTANT( AU, 1.49597870700e13 );
94 
95 /*********************************************************************
96  * fundamental constants go next, eventually rest should be defined *
97  * in terms of these, these are CODATA 2014 values. *
98  *********************************************************************/
99 
101 NEW_CONSTANT( ELECTRON_MASS, 9.10938356e-28 );
102 
104 NEW_CONSTANT( PROTON_MASS, 1.672621898e-24 );
105 
107 NEW_CONSTANT( BOLTZMANN, 1.38064852e-16 );
108 
110 NEW_CONSTANT( SPEEDLIGHT, 2.99792458e10 );
111 
113 NEW_CONSTANT( HPLANCK, 6.626070040e-27 );
114 
116 NEW_CONSTANT( AVOGADRO, 6.022140857e23 );
117 
119 NEW_CONSTANT( GRAV_CONST, 6.67408e-8 );
120 
122 NEW_CONSTANT( ELEM_CHARGE, 1.6021766208e-19 );
123 
125 NEW_CONSTANT( RYD_INF, 1.0973731568508e5 );
126 
129 NEW_CONSTANT( HIONPOT, 0.999466508345 );
130 
133 NEW_CONSTANT( HE2IONPOT, 3.99963199547 );
134 
137 NEW_CONSTANT( HMINUSIONPOT, 0.055432956 );
138 
139 /*********************************************************************
140  * below here should be derived constants *
141  * *
142  * NB - explicit values in comments are approximate *
143  * and are not maintained ! *
144  *********************************************************************/
145 
147 NEW_CONSTANT( ATOMIC_MASS_UNIT, 1./AVOGADRO );
148 
150 NEW_CONSTANT( AS1RAD, RADIAN*3600. );
151 
153 NEW_CONSTANT( SQAS1SR, pow2(AS1RAD) );
154 
156 NEW_CONSTANT( SQAS_SKY, PI4*SQAS1SR );
157 
159 NEW_CONSTANT( PARSEC, AU*AS1RAD );
160 
162 NEW_CONSTANT( MEGAPARSEC, 1.e6*PARSEC );
163 
165 NEW_CONSTANT( H_BAR, HPLANCK/(2.*PI) );
166 
168 NEW_CONSTANT( ELEM_CHARGE_ESU, ELEM_CHARGE*SPEEDLIGHT/10. );
169 
171 NEW_CONSTANT( ELECTRIC_CONST, 1.e11/(PI4*pow2(SPEEDLIGHT)) );
172 
178 NEW_CONSTANT( HION_LTE_POP, pow2(HPLANCK)/(PI2*BOLTZMANN*ELECTRON_MASS) );
179 
182 #ifdef HAVE_CONSTEXPR
183 NEW_CONSTANT( SAHA, sqrt(pow3(HION_LTE_POP)) );
184 #else
185 // Need to use explicit constant rather than formula as sqrt() isn't
186 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
187 // in t_physconst::t_physconst() in physconst.cpp
188 NEW_CONSTANT( SAHA, 4.1413323347325398e-16 );
189 #endif
190 
192 NEW_CONSTANT( ERG1CM, HPLANCK*SPEEDLIGHT );
193 
195 NEW_CONSTANT( T1CM, HPLANCK*SPEEDLIGHT/BOLTZMANN );
196 
198 NEW_CONSTANT( KJMOL1CM, ERG1CM*AVOGADRO/1e10 );
199 
201 NEW_CONSTANT( WAVNRYD, 1./RYD_INF );
202 
204 NEW_CONSTANT( RYDLAM, 1.e8/RYD_INF );
205 
207 NEW_CONSTANT( EN1RYD, HPLANCK*SPEEDLIGHT*RYD_INF );
208 
211 NEW_CONSTANT( TE1RYD, HPLANCK*SPEEDLIGHT*RYD_INF/BOLTZMANN );
212 
214 NEW_CONSTANT( EVDEGK, ELEM_CHARGE*1.e7/BOLTZMANN );
215 
217 NEW_CONSTANT( EVRYD, HPLANCK*SPEEDLIGHT*RYD_INF/ELEM_CHARGE*1.e-7 );
218 
220 NEW_CONSTANT( EN1EV, EN1RYD/EVRYD );
221 
223 NEW_CONSTANT( FR1RYD, SPEEDLIGHT*RYD_INF );
224 
226 NEW_CONSTANT( HNU3C2, 2.*HPLANCK*SPEEDLIGHT*pow3(RYD_INF) );
227 
229 NEW_CONSTANT( FR1RYDHYD, SPEEDLIGHT*RYD_INF*HIONPOT );
230 
232 NEW_CONSTANT( HBAReV, H_BAR/EN1EV );
233 
235 NEW_CONSTANT( RYDLAMHYD, RYDLAM/HIONPOT );
236 
238 NEW_CONSTANT( STEFAN_BOLTZ, pow2(PI*pow2(BOLTZMANN))/(60.*pow3(H_BAR)*pow2(SPEEDLIGHT)) );
239 
241 NEW_CONSTANT( FREQ_1EV, SPEEDLIGHT*RYD_INF/EVRYD );
242 
244 NEW_CONSTANT( FINE_STRUCTURE, pow2(ELEM_CHARGE_ESU)/SPEEDLIGHT/H_BAR );
245 
247 NEW_CONSTANT( FINE_STRUCTURE2, pow2(FINE_STRUCTURE) );
248 
250 NEW_CONSTANT( BOHR_RADIUS_CM, FINE_STRUCTURE/(PI4*RYD_INF) );
251 
253 NEW_CONSTANT( TWO_PHOT_CONST, 9.*pow3(FINE_STRUCTURE2)*FR1RYD/2048. );
254 
257 NEW_CONSTANT( COLL_CONST, SAHA*BOLTZMANN/HPLANCK );
258 
261 #ifdef HAVE_CONSTEXPR
262 NEW_CONSTANT( MILNE_CONST, SPEEDLIGHT*sqrt(pow3(FINE_STRUCTURE2)*pow3(TE1RYD)/PI) );
263 #else
264 // Need to use explicit constant rather than formula as sqrt() isn't
265 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
266 // in t_physconst::t_physconst() in physconst.cpp
267 NEW_CONSTANT( MILNE_CONST, 4.1234776389939771e+11 );
268 #endif
269 
272 NEW_CONSTANT( TRANS_PROB_CONST, PI4*HPLANCK*FINE_STRUCTURE/ELECTRON_MASS );
273 
275 NEW_CONSTANT( SIGMA_THOMSON, PI8/3.*pow2(FINE_STRUCTURE*H_BAR/(ELECTRON_MASS*SPEEDLIGHT)) );
276 
279 NEW_CONSTANT( HC_ERG_ANG, HPLANCK*SPEEDLIGHT*1e8);
280 
282 NEW_CONSTANT( JEANS, PI*BOLTZMANN/(GRAV_CONST*ATOMIC_MASS_UNIT) );
283 
285 //NEW_CONSTANT( EXPEULER2, exp(-EULER/2.) );
286 NEW_CONSTANT( EXPEULER2, 0.74930600128844902361);
287 
288 /* Free-free emission constant.
289  * This is defined as the constant in the FF cooling equation (5.14a) in Rybicki & Lightman
290  * divided by the Planck constant. This is obtained by integrating equation (5.14a) over
291  * frequency and changing variables to energy in units of R_inf. A factor R_inf*c comes out
292  * of the integral, which is accounted for by multiplying the constant by EN1RYD = R_inf * h * c,
293  * but we need to correct for the extra h.
294  * The exact equation is:
295  * 32*pi * e^6 / (3 * h * m_e * c^3) * sqrt(2*pi / (3 * k_Boltzmann * m_e))
296  */
297 #ifdef HAVE_CONSTEXPR
298 NEW_CONSTANT( FREE_FREE_EMIS,
299  32. * PI * pow(ELEM_CHARGE_ESU, 6.) /
300  (3. * pow3(SPEEDLIGHT) * ELECTRON_MASS * HPLANCK ) *
301  sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) );
302 #else
303 // Need to use explicit constant rather than formula as sqrt() isn't
304 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
305 // in t_physconst::t_physconst() in physconst.cpp
306 NEW_CONSTANT( FREE_FREE_EMIS, 1.03252667766422e-11 );
307 #endif
308 
309 /* Free-free absorption constant.
310  * The constant is obtained by considering the integral of absorption over frequency
311  * to compute the total heating rate. The logic is similar to that for the emission
312  * constant above. NB The radiation field is already expressed as dnu*Inu, so that
313  * leaves 3 powers of (R_inf * c) in the denominator, from the nu^-3 dependence --
314  * see Rybicki & Lightman eqn (5.18a).
315  *
316  * The exact constant is:
317  * 4 * e^6 / (3 * h * m * c) * sqrt(2*pi / (3 * k_Boltzmann * m_e)) / (R_inf * c)^3
318  */
319 #ifdef HAVE_CONSTEXPR
320 NEW_CONSTANT( FREE_FREE_ABS,
321  4. * pow(ELEM_CHARGE_ESU, 6.) /
322  (3. * HPLANCK * ELECTRON_MASS * SPEEDLIGHT ) *
323  sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) /
324  pow3(SPEEDLIGHT * RYD_INF) );
325 #else
326 // Need to use explicit constant rather than formula as sqrt() isn't
327 // guaranteed to be evaluated at compile-time. Checked by an ASSERT
328 // in t_physconst::t_physconst() in physconst.cpp
329 NEW_CONSTANT( FREE_FREE_ABS, 1.0369975278736e-38 );
330 #endif
331 
332 #undef pow2
333 #undef pow3
#define pow3(a)
#define pow2(a)
#define NEW_CONSTANT(NAME, VALUE)
Definition: physconst.cpp:11