Move MIN,MAX,SQ macros to a common header
[qpms.git] / qpms / constants.py
blobbbdcec65f15239f0cd859e59f25d704ce859b618
1 # unit conversions, mostly for standalone usage
2 # TODO avoid importing the "heavy" qpms parts
3 from scipy.constants import epsilon_0 as ε_0, c, pi as π, e as eV, hbar, hbar as, mu_0 as μ_0
4 pi = π
5 μm = 1e-6
6 nm = 1e-9
7 # "SCUFF FREQUENCY UNIT"
8 SU = 3e14
9 SCUFF_OMEGAUNIT = SU
11 #freqs = freqs_weirdunits * c / μm
13 def nm2eV(lambda_nm, n = 1):
14 return 2*π*c/(n * lambda_nm * nm) / (eV /)
16 def eV2nm(e_eV, n = 1):
17 return 2*π*c/(n * e_eV * (eV/)) / nm
19 def SU2eV(e_SU):
20 '''
21 Scuff frequency units to eV.
22 '''
23 return e_SU * SU / (eV /)
25 def eV2SU(e_eV):
26 return e_eV * (eV /) / SU
28 def SU2nm(e_SU, n = 1):
29 return 2*π*c/(n * e_SU * SU) / nm
31 def nm2SU(lambda_nm, n = 1):
32 return 2*π*c/(n * lambda_nm * nm) / SU