constants.py: unit conversions

Former-commit-id: 61ecddf9bb1d4c4a0355bad5edcae435a160aeb2
This commit is contained in:
Marek Nečada 2018-12-25 22:15:23 +02:00
parent d2b34f9407
commit 536301fddc
1 changed files with 33 additions and 0 deletions

33
qpms/constants.py Normal file
View File

@ -0,0 +1,33 @@
# unit conversions, mostly for standalone usage
# TODO avoid importing the "heavy" qpms parts
from scipy.constants import epsilon_0 as ε_0, c, pi as π, e as eV, hbar as , mu_0 as μ_0
pi = π
μm = 1e-6
nm = 1e-9
# "SCUFF FREQUENCY UNIT"
SU = 3e14
SCUFF_OMEGAUNIT = SU
#freqs = freqs_weirdunits * c / μm
def nm2eV(lambda_nm, n = 1):
return 2*π*c/(n * lambda_nm * nm) / (eV / )
def eV2nm(e_eV, n = 1):
return 2*π*c/(n * e_eV * (eV/)) / nm
def SU2eV(e_SU):
'''
Scuff frequency units to eV.
'''
return e_SU * SU / (eV / )
def eV2SU(e_eV):
return e_eV * (eV / ) / SU
def SU2nm(e_SU, n = 1):
return 2*π*c/(n * e_SU * SU) / nm
def nm2SU(lambda_nm, n = 1):
return 2*π*c/(n * lambda_nm * nm) / SU