Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
physconst_template.h
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2025 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
20
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 to accept sqrt()
27
28#define pow2(a) ((a)*(a))
29#define pow3(a) ((a)*(a)*(a))
30
32NEW_CONSTANT( EE, 2.718281828459045235360287 );
33
35NEW_CONSTANT( EULER, 0.577215664901532860606512090082 );
36
38NEW_CONSTANT( EXPEULER2, 0.74930600128844902360587 );
39
41NEW_CONSTANT( PI, 3.141592653589793238462643 );
42
44NEW_CONSTANT( PI2, 6.283185307179586476925287 );
45
47NEW_CONSTANT( PI4, 12.56637061435917295385057 );
48
50NEW_CONSTANT( PI8, 25.13274122871834590770115 );
51
53NEW_CONSTANT( SQRT2, 1.414213562373095048801689 );
54
56NEW_CONSTANT( SQRTPI, 1.772453850905516027298167 );
57
59NEW_CONSTANT( SQRTPIBY2, 1.253314137315500251207883 );
60
62NEW_CONSTANT( LN_TWO, 0.6931471805599453094172321 );
63
65NEW_CONSTANT( LN_TEN, 2.302585092994045684017991 );
66
68NEW_CONSTANT( LOG10_E, 0.4342944819032518276511289 );
69
72NEW_CONSTANT( OPTDEP2EXTIN, 1.085736204758129569127822 );
73
75NEW_CONSTANT( RADIAN, 57.29577951308232087679815 );
76
77/*********************************************************************
78 * astronomical constants go here *
79 *********************************************************************/
80
83NEW_CONSTANT( SOLAR_MASS, 1.98841e33 );
84
87NEW_CONSTANT( SOLAR_LUMINOSITY, 3.828e33 );
88
91NEW_CONSTANT( MBOL_ZERO_LUMINOSITY, 3.0128e35 );
92
95/* >>refer phys const https://pdg.lbl.gov/2021/reviews/rpp2021-rev-astrophysical-constants.pdf */
96NEW_CONSTANT( AU, 1.49597870700e13 );
97
98/*********************************************************************
99 * fundamental constants go next, eventually rest should be defined *
100 * in terms of these, these are CODATA 2022 values. *
101 *********************************************************************/
102
104NEW_CONSTANT( ELECTRON_MASS, 9.1093837139e-28 );
105
107NEW_CONSTANT( ELECTRON_MASS_U, 5.485799090441e-4 );
108
110NEW_CONSTANT( PROTON_MASS, 1.67262192595e-24 );
111
113NEW_CONSTANT( PROTON_MASS_U, 1.0072764665789 );
114
116NEW_CONSTANT( ALPHA_MASS_U, 4.001506179129 );
117
119NEW_CONSTANT( BOLTZMANN, 1.380649e-16 );
120
122NEW_CONSTANT( SPEEDLIGHT, 2.99792458e10 );
123
125NEW_CONSTANT( HPLANCK, 6.62607015e-27 );
126
128NEW_CONSTANT( AVOGADRO, 6.02214076e23 );
129
131NEW_CONSTANT( GRAV_CONST, 6.67430e-8 );
132
134NEW_CONSTANT( ELEM_CHARGE, 1.602176634e-19 );
135
137NEW_CONSTANT( RYD_INF, 1.0973731568157e5 );
138
141NEW_CONSTANT( HIONPOT, 0.999466508345 );
142
145NEW_CONSTANT( HE2IONPOT, 3.99963199547 );
146
149NEW_CONSTANT( HMINUSIONPOT, 0.055432956 );
150
152NEW_CONSTANT( ATOMIC_MASS_UNIT, 1.66053906892e-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 * use the PRINT CONSTANTS command to get precise values *
161 *********************************************************************/
162
164NEW_CONSTANT( MOL_MASS_CONST, AVOGADRO*ATOMIC_MASS_UNIT );
165
167NEW_CONSTANT( AS1RAD, RADIAN*3600. );
168
170NEW_CONSTANT( SQAS1SR, pow2(AS1RAD) );
171
173NEW_CONSTANT( SQAS_SKY, PI4*SQAS1SR );
174
176NEW_CONSTANT( PARSEC, AU*AS1RAD );
177
179NEW_CONSTANT( MEGAPARSEC, 1.e6*PARSEC );
180
182NEW_CONSTANT( H_BAR, HPLANCK/(2.*PI) );
183
185NEW_CONSTANT( ELEM_CHARGE_ESU, ELEM_CHARGE*SPEEDLIGHT/10. );
186
188NEW_CONSTANT( ELECTRIC_CONST, 1.e11/(PI4*pow2(SPEEDLIGHT)) );
189
195NEW_CONSTANT( HION_LTE_POP, pow2(HPLANCK)/(PI2*BOLTZMANN*ELECTRON_MASS) );
196
199#ifdef HAVE_CONSTEXPR
200NEW_CONSTANT( SAHA, sqrt(pow3(HION_LTE_POP)) );
201#else
202// Need to use explicit constant rather than formula as sqrt() isn't
203// guaranteed to be evaluated at compile-time. Checked by an ASSERT
204// in t_physconst::t_physconst() in physconst.cpp
205NEW_CONSTANT( SAHA, 4.141330276355497e-16 );
206#endif
207
209NEW_CONSTANT( ERG1CM, HPLANCK*SPEEDLIGHT );
210
212NEW_CONSTANT( T1CM, HPLANCK*SPEEDLIGHT/BOLTZMANN );
213
215NEW_CONSTANT( KJMOL1CM, ERG1CM*AVOGADRO/1e10 );
216
218NEW_CONSTANT( H_RYD_FACTOR, 1./(1.+ELECTRON_MASS_U/PROTON_MASS_U) );
219
221NEW_CONSTANT( HE_RYD_FACTOR, 1./(1.+ELECTRON_MASS_U/ALPHA_MASS_U) );
222
224NEW_CONSTANT( WAVNRYD, 1./RYD_INF );
225
227NEW_CONSTANT( RYDLAM, 1.e8/RYD_INF );
228
230NEW_CONSTANT( EN1RYD, HPLANCK*SPEEDLIGHT*RYD_INF );
231
234NEW_CONSTANT( TE1RYD, HPLANCK*SPEEDLIGHT*RYD_INF/BOLTZMANN );
235
237NEW_CONSTANT( EVDEGK, ELEM_CHARGE*1.e7/BOLTZMANN );
238
240NEW_CONSTANT( EVRYD, HPLANCK*SPEEDLIGHT*RYD_INF/ELEM_CHARGE*1.e-7 );
241
243NEW_CONSTANT( EN1EV, EN1RYD/EVRYD );
244
246NEW_CONSTANT( FR1RYD, SPEEDLIGHT*RYD_INF );
247
249NEW_CONSTANT( HNU3C2, 2.*HPLANCK*SPEEDLIGHT*pow3(RYD_INF) );
250
252NEW_CONSTANT( FR1RYDHYD, SPEEDLIGHT*RYD_INF*HIONPOT );
253
255NEW_CONSTANT( HBAReV, H_BAR/EN1EV );
256
258NEW_CONSTANT( RYDLAMHYD, RYDLAM/HIONPOT );
259
261NEW_CONSTANT( STEFAN_BOLTZ, pow2(PI*pow2(BOLTZMANN))/(60.*pow3(H_BAR)*pow2(SPEEDLIGHT)) );
262
264NEW_CONSTANT( FREQ_1EV, SPEEDLIGHT*RYD_INF/EVRYD );
265
267NEW_CONSTANT( FINE_STRUCTURE, pow2(ELEM_CHARGE_ESU)/SPEEDLIGHT/H_BAR );
268
270NEW_CONSTANT( FINE_STRUCTURE2, pow2(FINE_STRUCTURE) );
271
273NEW_CONSTANT( BOHR_RADIUS_CM, FINE_STRUCTURE/(PI4*RYD_INF) );
274
276NEW_CONSTANT( TWO_PHOT_CONST, 9.*pow3(FINE_STRUCTURE2)*FR1RYD/2048. );
277
280NEW_CONSTANT( COLL_CONST, SAHA*BOLTZMANN/HPLANCK );
281
284#ifdef HAVE_CONSTEXPR
285NEW_CONSTANT( MILNE_CONST, SPEEDLIGHT*sqrt(pow3(FINE_STRUCTURE2)*pow3(TE1RYD)/PI) );
286#else
287// Need to use explicit constant rather than formula as sqrt() isn't
288// guaranteed to be evaluated at compile-time. Checked by an ASSERT
289// in t_physconst::t_physconst() in physconst.cpp
290NEW_CONSTANT( MILNE_CONST, 4.123475589581428e+11 );
291#endif
292
295NEW_CONSTANT( TRANS_PROB_CONST, PI4*HPLANCK*FINE_STRUCTURE/ELECTRON_MASS );
296
302NEW_CONSTANT( ABSOR_COEFF_CONST, SQRTPI*pow2(ELEM_CHARGE_ESU)/(ELECTRON_MASS*SPEEDLIGHT) );
303
305NEW_CONSTANT( SIGMA_THOMSON, PI8/3.*pow2(FINE_STRUCTURE*H_BAR/(ELECTRON_MASS*SPEEDLIGHT)) );
306
309NEW_CONSTANT( HC_ERG_ANG, HPLANCK*SPEEDLIGHT*1e8 );
310
312NEW_CONSTANT( JEANS, PI*BOLTZMANN/(GRAV_CONST*ATOMIC_MASS_UNIT) );
313
314/* Free-free emission constant.
315 * This is defined as the constant in the FF cooling equation (5.14a) in Rybicki & Lightman
316 * divided by the Planck constant. This is obtained by integrating equation (5.14a) over
317 * frequency and changing variables to energy in units of R_inf. A factor R_inf*c comes out
318 * of the integral, which is accounted for by multiplying the constant by EN1RYD = R_inf * h * c,
319 * but we need to correct for the extra h.
320 * The exact equation is:
321 * 32*pi * e^6 / (3 * h * m_e * c^3) * sqrt(2*pi / (3 * k_Boltzmann * m_e))
322 */
323#ifdef HAVE_CONSTEXPR
324NEW_CONSTANT( FREE_FREE_EMIS,
325 32. * PI * pow2(pow3(ELEM_CHARGE_ESU)) /
326 (3. * pow3(SPEEDLIGHT) * ELECTRON_MASS * HPLANCK ) *
327 sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) );
328#else
329// Need to use explicit constant rather than formula as sqrt() isn't
330// guaranteed to be evaluated at compile-time. Checked by an ASSERT
331// in t_physconst::t_physconst() in physconst.cpp
332NEW_CONSTANT( FREE_FREE_EMIS, 1.032526505912028e-11 );
333#endif
334
335/* Free-free absorption constant.
336 * The constant is obtained by considering the integral of absorption over frequency
337 * to compute the total heating rate. The logic is similar to that for the emission
338 * constant above. NB The radiation field is already expressed as dnu*Inu, so that
339 * leaves 3 powers of (R_inf * c) in the denominator, from the nu^-3 dependence --
340 * see Rybicki & Lightman eqn (5.18a).
341 *
342 * The exact constant is:
343 * 4 * e^6 / (3 * h * m * c) * sqrt(2*pi / (3 * k_Boltzmann * m_e)) / (R_inf * c)^3
344 */
345#ifdef HAVE_CONSTEXPR
346NEW_CONSTANT( FREE_FREE_ABS,
347 4. * pow2(pow3(ELEM_CHARGE_ESU)) /
348 (3. * HPLANCK * ELECTRON_MASS * SPEEDLIGHT ) *
349 sqrt(2. * PI / (3. * BOLTZMANN * ELECTRON_MASS ) ) /
350 pow3(SPEEDLIGHT * RYD_INF) );
351#else
352// Need to use explicit constant rather than formula as sqrt() isn't
353// guaranteed to be evaluated at compile-time. Checked by an ASSERT
354// in t_physconst::t_physconst() in physconst.cpp
355NEW_CONSTANT( FREE_FREE_ABS, 1.036997355477227e-38 );
356#endif
#define NEW_CONSTANT(NAME, VALUE)
Definition physconst.cpp:11
#define pow2(a)
Definition physconst_template.h:28
#define pow3(a)
Definition physconst_template.h:29