Created
April 9, 2024 18:28
-
-
Save mtesseracted/1cd1d5f8a8c095e8ee83da1320d1db94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bc config file, define constants and functions | |
# all units from physics.nist.gov (if available) | |
## math constants | |
pi=4.0*a(1.0) | |
phi=(1.+sqrt(5.))/2. | |
## physics constants | |
g=6.6743*(10^-11) # gravitational, (m3 kg-1 s-2) | |
h=6.62607015*(10^-34) # planck, (J s) | |
hbar=h/(2*pi) # reduced planck | |
e0=8.8541878128*(10^-12) # vacuum electric permittivity (F m-1) | |
k=1/(4*pi*e0) # Coloumb constant in vacuum | |
mub=9.2740100783*(10^-24) # bohr magneton (J T-1) | |
e=1.603176634*(10^-19) # electron charge (C) | |
c=2.99792458*(10^8) # speed of light in vacuum (m s-1) | |
## chemistry constants | |
na=6.02214076*(10^23) # avagadro's number | |
## length/distance converions | |
b2a=0.529177210903 # bohr to ang | |
a2b=1.0/b2a # ang to bohr | |
ft2m=0.3048 # feet to meters (defined as) | |
m2ft=1/ft2m # meters to feet | |
mi2ft=5280 # miles to feet | |
ft2mi=1/mi2ft # feet to miles | |
km2m=1000 # meters to kilometers | |
m2km=1/km2m # kilometers to meters | |
km2mi=km2m*m2ft*ft2mi # kilometers to miles | |
mi2km=mi2ft*ft2m*m2km # miles to kilometers | |
nmi2m=1852 # nautical mile to meters | |
nmi2km=nmi2m*m2km # nautical mile to kilometers | |
nmi2mi=nmi2km*km2mi # nautical mile to mile | |
mi2nmi=1/nmi2mi # mile to nautical mile | |
km2nmi=1/nmi2km # kilometer to nautical mile | |
ly2m=24*60*60*365.25*c # light year to meter | |
au2m=149597870700 # astronomical unit to meter | |
pc2au=648000/pi # parsec to astronomical unit (IAU B2) | |
## angle | |
deg2rad=2*pi/360 # degree to radian | |
rad2deg=360/(2*pi) # radian to degree | |
## energy conversions | |
ha2ev=27.211386245988 # hartree to eV | |
ev2ha=1.0/ha2ev # eV to hartree | |
kc2kj=4.184 # kiloCal to kiloJoule | |
ha2ry=2.0 # hartree to rydberg | |
ry2ha=0.5 # rydberg to hartree | |
ry2ev=ry2ha*ha2ev # rydberg to eV | |
ev2ry=1.0/ry2ev # eV to rydberg | |
kj2ha=2.2937122783963*(10^20) # kJ to Ha | |
kjpm2ha=2625.49963947985393 # kJ/mol to Ha = na/kj2ha | |
kcpm2ha=627.509474063062603 # kcal/mol to Ha = na/kj2ha/kc2kj | |
## mass/force conversions | |
lb2kg=0.45359237 # pound to kilogram | |
kg2lb=1/lb2kg # kilogram to pound | |
lb2oz=16 # pound to ounce | |
oz2lb=1/lb2oz # ounce to pount | |
kg2oz=kg2lb*lb2oz # kilogram to ounce | |
oz2kg=1/kg2oz # ounce to kilogram | |
lbf2n=4.448222 # pound-force to newton | |
## volume conversions (not NIST) | |
cup2qt=4 # cup to quart | |
cup2oz=8 # cup to ounce | |
cup2gal=16 # cup to gallon | |
ml2cup=236.588 # milliliter to cup | |
l2ml=1000 # liter to milliliter | |
ml2l=1/l2ml # milliliter to liter | |
l2cup=l2ml*ml2cup # liter to cup | |
## functions | |
define fact(x) { | |
# factorial | |
if( x>1 ) { | |
return( x * fact(x-1) ) | |
} | |
return(1) | |
} | |
define pow(x,y) { | |
# pow(x,y) = x^y | |
return( e( y*l(x) ) ) | |
} | |
define log(x,b) { | |
# log of base b | |
return( l(x) / l(b) ) | |
} | |
# trig functions and inverses | |
define sin(x) { | |
return s(x) | |
} | |
define cos(x) { | |
return c(x) | |
} | |
define tan(x) { | |
return s(x) / c(x) | |
} | |
define atan(x) { | |
return a(x) | |
} | |
define asin(x) { | |
return a(x / sqrt(1 - x*x)) | |
} | |
define acos(x) { | |
return a(sqrt(1 - x*x) / x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment