1import numpy as np 2 3# 4# Physical Constants and Units Conversion Factors 5# 6# Values for these constants, unless otherwise noted, are drawn from IAU, 7# IUPAC, NIST, and NASA data, whichever is newer. 8# http://maia.usno.navy.mil/NSFA/IAU2009_consts.html 9# http://goldbook.iupac.org/list_goldbook_phys_constants_defs.html 10# http://physics.nist.gov/cuu/Constants/index.html 11# http://nssdc.gsfc.nasa.gov/planetary/factsheet/jupiterfact.html 12 13# Elementary masses 14mass_electron_kg = 9.10938291e-31 15amu_kg = 1.660538921e-27 16amu_grams = amu_kg * 1.0e3 17mass_hydrogen_kg = 1.007947 * amu_kg 18mass_proton_kg = 1.672623110e-27 19 20# Solar values (see Mamajek 2012) 21# https://sites.google.com/site/mamajeksstarnotes/bc-scale 22mass_sun_kg = 1.98841586e30 23temp_sun_kelvin = 5870.0 24luminosity_sun_watts = 3.8270e26 25 26# Consistent with solar abundances used in Cloudy 27metallicity_sun = 0.01295 28 29# Conversion Factors: X au * mpc_per_au = Y mpc 30# length 31mpc_per_mpc = 1e0 32mpc_per_kpc = 1e-3 33mpc_per_pc = 1e-6 34mpc_per_au = 4.84813682e-12 35mpc_per_rsun = 2.253962e-14 36mpc_per_rearth = 2.06470307893e-16 37mpc_per_rjup = 2.26566120943e-15 38mpc_per_miles = 5.21552871e-20 39mpc_per_km = 3.24077929e-20 40mpc_per_m = 3.24077929e-23 41kpc_per_m = mpc_per_m / mpc_per_kpc 42pc_per_m = mpc_per_m / mpc_per_pc 43km_per_pc = 3.08567758e13 44cm_per_pc = 3.08567758e18 45cm_per_mpc = 3.08567758e21 46km_per_m = 1e-3 47km_per_cm = 1e-5 48m_per_cm = 1e-2 49ly_per_m = 1.05702341e-16 50rsun_per_m = 1.4378145e-9 51rearth_per_m = 1.56961033e-7 # Mean (volumetric) radius 52rjup_per_m = 1.43039006737e-8 # Mean (volumetric) radius 53au_per_m = 6.68458712e-12 54ang_per_m = 1.0e10 55 56m_per_fpc = 0.0324077929 57 58kpc_per_mpc = 1.0 / mpc_per_kpc 59pc_per_mpc = 1.0 / mpc_per_pc 60au_per_mpc = 1.0 / mpc_per_au 61rsun_per_mpc = 1.0 / mpc_per_rsun 62rearth_per_mpc = 1.0 / mpc_per_rearth 63rjup_per_mpc = 1.0 / mpc_per_rjup 64miles_per_mpc = 1.0 / mpc_per_miles 65km_per_mpc = 1.0 / mpc_per_km 66m_per_mpc = 1.0 / mpc_per_m 67m_per_kpc = 1.0 / kpc_per_m 68m_per_km = 1.0 / km_per_m 69cm_per_km = 1.0 / km_per_cm 70cm_per_m = 1.0 / m_per_cm 71pc_per_km = 1.0 / km_per_pc 72m_per_pc = 1.0 / pc_per_m 73m_per_ly = 1.0 / ly_per_m 74m_per_rsun = 1.0 / rsun_per_m 75m_per_rearth = 1.0 / rearth_per_m 76m_per_rjup = 1.0 / rjup_per_m 77m_per_au = 1.0 / au_per_m 78m_per_ang = 1.0 / ang_per_m 79 80# time 81# "IAU Style Manual" by G.A. Wilkins, Comm. 5, in IAU Transactions XXB (1989) 82sec_per_Gyr = 31.5576e15 83sec_per_Myr = 31.5576e12 84sec_per_kyr = 31.5576e9 85sec_per_year = 31.5576e6 86sec_per_day = 86400.0 87sec_per_hr = 3600.0 88sec_per_min = 60.0 89day_per_year = 365.25 90 91# velocities, accelerations 92speed_of_light_m_per_s = 2.99792458e8 93speed_of_light_cm_per_s = speed_of_light_m_per_s * 100.0 94standard_gravity_m_per_s2 = 9.80665 95 96# some constants 97newton_mks = 6.67408e-11 98planck_mks = 6.62606957e-34 99# permeability of Free Space 100mu_0 = 4.0e-7 * np.pi 101# permittivity of Free Space 102eps_0 = 1.0 / (speed_of_light_m_per_s ** 2 * mu_0) 103avogadros_number = 6.02214085774 * 10 ** 23 104 105# temperature / energy 106boltzmann_constant_J_per_K = 1.3806488e-23 107erg_per_eV = 1.602176562e-12 108J_per_eV = erg_per_eV * 1.0e-7 109erg_per_keV = erg_per_eV * 1.0e3 110J_per_keV = J_per_eV * 1.0e3 111K_per_keV = J_per_keV / boltzmann_constant_J_per_K 112keV_per_K = 1.0 / K_per_keV 113keV_per_erg = 1.0 / erg_per_keV 114eV_per_erg = 1.0 / erg_per_eV 115kelvin_per_rankine = 5.0 / 9.0 116watt_per_horsepower = 745.69987158227022 117erg_per_s_per_watt = 1e7 118 119# Solar System masses 120# Standish, E.M. (1995) "Report of the IAU WGAS Sub-Group on Numerical 121# Standards", in Highlights of Astronomy (I. Appenzeller, ed.), Table 1, 122# Kluwer Academic Publishers, Dordrecht. 123# REMARK: following masses include whole systems (planet + moons) 124mass_jupiter_kg = mass_sun_kg / 1047.3486 125mass_mercury_kg = mass_sun_kg / 6023600.0 126mass_venus_kg = mass_sun_kg / 408523.71 127mass_earth_kg = mass_sun_kg / 328900.56 128mass_mars_kg = mass_sun_kg / 3098708.0 129mass_saturn_kg = mass_sun_kg / 3497.898 130mass_uranus_kg = mass_sun_kg / 22902.98 131mass_neptune_kg = mass_sun_kg / 19412.24 132 133# flux 134jansky_mks = 1.0e-26 135# Cosmological constants 136# Calculated with H = 100 km/s/Mpc, value given in units of h^2 g cm^-3 137# Multiply by h^2 to get the critical density in units of g cm^-3 138rho_crit_g_cm3_h2 = 1.8788e-29 139primordial_H_mass_fraction = 0.76 140 141# Misc. Approximations 142mass_mean_atomic_cosmology = 1.22 143mass_mean_atomic_galactic = 2.3 144 145# Miscellaneous 146HUGE = 1.0e90 147TINY = 1.0e-40 148 149# Planck units 150hbar_mks = 0.5 * planck_mks / np.pi 151planck_mass_kg = np.sqrt(hbar_mks * speed_of_light_m_per_s / newton_mks) 152planck_length_m = np.sqrt(hbar_mks * newton_mks / speed_of_light_m_per_s ** 3) 153planck_time_s = planck_length_m / speed_of_light_m_per_s 154planck_energy_J = planck_mass_kg * speed_of_light_m_per_s * speed_of_light_m_per_s 155planck_temperature_K = planck_energy_J / boltzmann_constant_J_per_K 156planck_charge_C = np.sqrt(4.0 * np.pi * eps_0 * hbar_mks * speed_of_light_m_per_s) 157 158# Imperial and other non-metric units 159kg_per_pound = 0.45359237 160pascal_per_atm = 101325.0 161m_per_inch = 0.0254 162m_per_ft = 0.3048 163 164# logarithmic units 165# IEC 60027-3: https://webstore.iec.ch/publication/94 166# NIST Special Publication 811: https://www.nist.gov/pml/special-publication-811 167neper_per_bel = np.log(10) / 2 168