Package cosmolopy :: Module constants

Source Code for Module cosmolopy.constants

 1  """Various constants used by CosmoloPy code. 
 2   
 3  Unit abreviations are appended to the name, but powers are not 
 4  specified. For instance, the gravitational constant has units "Mpc^3 
 5  msun^-1 s^-2", but is called "G_const_Mpc_Msun_s". 
 6   
 7  Most of these numbers are from google calculator. 
 8   
 9  Constants are: 
10   
11  :: 
12   
13  """ 
14   
15  ### If you add a constant, make sure to add a description too. ### 
16   
17  doc = "" 
18   
19  doc += "  pc_cm: Parsec in cm\n" 
20  pc_cm = 3.08568025e18 #cm 
21   
22  doc += "  Mpc_cm: Megaparsec in cm\n" 
23  Mpc_cm = 3.08568025e24 # cm 
24   
25  doc += "  Mpc_km: Megaparsec in km\n" 
26  Mpc_km = Mpc_cm * 1.0e-5 # km 
27   
28  doc += "  angstrom_cm: Angstrom in cm\n" 
29  angstrom_cm = 1e-8 #cm 
30   
31  doc += "  yr_s: a year in s\n" 
32  yr_s = 365. * 24. * 60. * 60. 
33   
34  doc += "  Myr_s: Megayear in s\n" 
35  Myr_s = 1.e6 * yr_s  
36   
37  doc += "  Gyr_s: Gigayear in s\n" 
38  Gyr_s = 1.e9 * yr_s  
39   
40  doc += "  amu_g: atomic mass unit in g\n" 
41  amu_g = 1.66053886e-24 #g 
42   
43  doc += "  m_p_g: mass of a proton in g\n" 
44  m_p_g = 1.67262158e-24 # g 
45   
46  doc += "  m_H_g: mass of a hydrogen atom in g\n" 
47  m_H_g = 1.00794 * amu_g # g 
48   
49  doc += "  m_He_g: mass of a helium atom in g\n" 
50  m_He_g = 4.002602 * amu_g # g 
51   
52  doc += "  M_sun_g: Solar mass in grams.\n" 
53  M_sun_g = 1.98892e33 # g 
54   
55  doc += "  c_light_cm_s: Speed of light in Mpc/s (from google calculator)\n" 
56  c_light_cm_s = 29979245800. # cm/s 
57   
58  doc += "  c_light_Mpc_s: Speed of light in Mpc/s\n" 
59  c_light_Mpc_s = c_light_cm_s / Mpc_cm # Mpc / s 
60   
61  doc += "  c_light_Mpc_Gyr: Speed of light in Mpc/Gyr \n" 
62  c_light_Mpc_Gyr = Gyr_s * c_light_cm_s / Mpc_cm # Mpc / Gyr 
63   
64  doc += "  H100_s: 100 km s^-1 Mpc^-1 in s^-1\n" 
65  H100_s = 100. / Mpc_km # s^-1 
66   
67  doc += "  G_const_Mpc_Msun_s: Gravitational constant in Mpc^3 msun^-1 s^-2\n" 
68  G_const_Mpc_Msun_s = M_sun_g * (6.673e-8) / Mpc_cm**3. # Mpc^3 msun^-1 s^-2  
69   
70  doc += "  lambda_Lya_0: Central wavelength of H Lyman-alpha in Angstroms\n" 
71  lambda_Lya_0 = 1215.67 # Ang 
72   
73  doc += "  lambda_NY_0: Central wavelength of an NV doublet in Angstroms\n" 
74  lambda_NV_0 = 1240.81 # Ang 
75   
76  doc += "  alpha_B_cm_s_1e4: hydrogen recombination coefficient at T=10^4 K\n" 
77  alpha_B_cm_s_1e4 = 2.59e-13 # cm^3 s^-1 
78   
79  doc += "  sigma_T_cm: Thomson cross section in cm^2\n" 
80  sigma_T_cm = 6.6524586e-25 # cm^2  
81   
82  doc += "  sigma_T_cm: Thomson cross section in Mpc^2\n" 
83  sigma_T_Mpc = sigma_T_cm / (Mpc_cm ** 2.) # Mpc^2  
84   
85  __doc__ += "\n".join(sorted(doc.split("\n"))) 
86