forked from prhuft/rubidium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqphys.py
More file actions
53 lines (39 loc) · 1.3 KB
/
qphys.py
File metadata and controls
53 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Various functions for my quantum/amo simulations, etc.
Preston Huft, Fall 2019
Deprecated. See amophys.py instead
"""
# libraries
from numpy import *
from sympy import MatrixSymbol,MatAdd,MatMul,Identity,I,Matrix,symbols,Function
from sympy.physics.wigner import wigner_6j,wigner_3j,clebsch_gordan
# quantum physics functions
def comm(A,B):
""" Returns the commutator of A,B: [A,B]=A.B-B.A. Assumes 'A','B' are sympy
matrices."""
return (MatMul(A,B)-MatMul(B,A))
def hf_coupling(F,mF,J,q,FF,mFF,JJ,I,RME=None):
""" Returns the matrix element <F,mF,J|T_q|F',mF',J'>.
'RME': the reduced matrix element, e.g. the D2 line matrix
element. If RME=None, the
matrix element is in units of [RME].
I is the nuclear spin of the atom.
"""
rme = 1
if RME!=None:
rme = RME
## From Mark's notes, eqs. A-50,51
mat_elem = rme*pow(-1,F+JJ+1+I)*sqrt((2*F+1)*(2*JJ+1)) \
*wigner_6j(J,I,F,FF,1,JJ) \
*clebsch_gordan(1,F,FF,q,mF,mFF)
return mat_elem
# syntactic sugar and convenience functions
def czeros(num):
""" return array of complex zeros """
c = empty(num,complex)
for i in range(num):
c[i] = 0+0j
return c
def cc(z):
""" return numpy.conj(z)"""
return conj(z)