Skip to content

Instantly share code, notes, and snippets.

@jasinjames
Created March 7, 2020 15:11
Show Gist options
  • Save jasinjames/a4772b158ab0d1a8e3dcf8307b08653c to your computer and use it in GitHub Desktop.
Save jasinjames/a4772b158ab0d1a8e3dcf8307b08653c to your computer and use it in GitHub Desktop.
Include this file in your python interpreter (or scripts) so you can calculate physics problems without looking up the constants.
#
# physconsts.py
# Scientific and Physical Constants
#
# This file can be included so that the constants can be used without always
# looking them up. This is mostly intended to be used in an interactive command
# line environment so that you can easily use the python interpreter as a calculator
# for physics problems. All are in SI.
#
# Author: James O'Brien 2019
#
# Speed of light
C = 299792458 # m / s
# Vacuum permittivity, permeability
E0 = 8.8541878e-12 # F / m
U0 = 1.256637062e-6 # H / m
# Planck's constant
H = 6.62607004e-34 # m^2 kg / s
HBAR = 1.0545718e-34 # m^2 kg / s
# Rydberg constant
R = 1.09677e7 # / m
# Electron charge, electron mass
QE = 1.6021765e-19 # C
ME = 9.10938356e-31 # kg
# Proton mass
MP = 1.6726219e-27 # kg
# Boltzmann constant
KB = 1.38064852e-23 # m^2 kg / s^2 / K
# Avagadro's number
NA = 6.0221409e23 # (dimensionless)
# Fine structure constant
A = 0.0072973525693 # (dimensionless)
# Gravitational constant (big G)
BIG_G = 6.67408e-11 # m^3 / kg / s^2
# Average gravitational acceleration on Earth (little g)
LITTLE_G = 9.807 # m / s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment