Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sympy.physics.quantum import *
- from sympy.physics.cartesian import *
- from sympy.physics.piab import *
- from sympy.physics.spin import *
- # Basic manipulations with operators, bras, kets and commutators
- psi, phi = Ket('psi'), Ket('phi')
- psi, phi
- A, B, C = Operator('A'), Operator('B'), Operator('C')
- Dagger(phi)*Commutator(2*A+B,I*C)*psi
- _.expand(commutator=True) # '_' = last result
- _.doit().expand()
- Dagger(_)
- # Basic 1D position and momentum
- Commutator(X, Px)
- _.doit()
- Commutator(X, X)
- X**2*XKet('y')
- apply_operators(_)
- XBra('xp')*XKet('x')
- _.doit()
- # The 1D PIAB
- H = PIABHamiltonian('H')
- boxket = PIABKet('n')
- H*boxket
- apply_operators(_)
- represent(boxket, X)
- # Spin commutation relations and operator identities
- Commutator(Jx, Jy)
- _.doit()
- Commutator(J2, Jz)
- _.doit()
- Dagger(Jx), Dagger(Jy), Dagger(Jz)
- J2.rewrite('plusminus')
- # A crazy tensor product representation
- H = TensorProduct(Jx,Jx)+TensorProduct(Jy,Jy)+TensorProduct(Jz, Jz)
- H
- represent(H, Jz, j=Rational(1,2))
- # Applying spin operators and looking at R
- k = JzKet(('j','m'))
- Jx*k
- apply_operators(_)
- Jplus*Jminus*k
- apply_operators(_)
- # Rotation operator
- R = Rotation((0, pi/2, 0)) # Rotation operator (Wigner D-Function)
- R
- represent(R, Jz, j=Rational(1,2)) # Represent for j=1/2
- represent(R, Jz, j=1) # Now for j=1
Add Comment
Please, Sign In to add comment