Guest User

Untitled

a guest
Jun 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. from sympy.physics.quantum import *
  2. from sympy.physics.cartesian import *
  3. from sympy.physics.piab import *
  4. from sympy.physics.spin import *
  5.  
  6. # Basic manipulations with operators, bras, kets and commutators
  7.  
  8. psi, phi = Ket('psi'), Ket('phi')
  9. psi, phi
  10. A, B, C = Operator('A'), Operator('B'), Operator('C')
  11. Dagger(phi)*Commutator(2*A+B,I*C)*psi
  12. _.expand(commutator=True) # '_' = last result
  13. _.doit().expand()
  14. Dagger(_)
  15.  
  16. # Basic 1D position and momentum
  17.  
  18. Commutator(X, Px)
  19. _.doit()
  20. Commutator(X, X)
  21. X**2*XKet('y')
  22. apply_operators(_)
  23. XBra('xp')*XKet('x')
  24. _.doit()
  25.  
  26. # The 1D PIAB
  27.  
  28. H = PIABHamiltonian('H')
  29. boxket = PIABKet('n')
  30. H*boxket
  31. apply_operators(_)
  32. represent(boxket, X)
  33.  
  34. # Spin commutation relations and operator identities
  35.  
  36. Commutator(Jx, Jy)
  37. _.doit()
  38. Commutator(J2, Jz)
  39. _.doit()
  40. Dagger(Jx), Dagger(Jy), Dagger(Jz)
  41. J2.rewrite('plusminus')
  42.  
  43. # A crazy tensor product representation
  44.  
  45.  
  46. H = TensorProduct(Jx,Jx)+TensorProduct(Jy,Jy)+TensorProduct(Jz, Jz)
  47. H
  48. represent(H, Jz, j=Rational(1,2))
  49.  
  50. # Applying spin operators and looking at R
  51.  
  52. k = JzKet(('j','m'))
  53. Jx*k
  54. apply_operators(_)
  55. Jplus*Jminus*k
  56. apply_operators(_)
  57.  
  58. # Rotation operator
  59.  
  60. R = Rotation((0, pi/2, 0)) # Rotation operator (Wigner D-Function)
  61. R
  62. represent(R, Jz, j=Rational(1,2)) # Represent for j=1/2
  63. represent(R, Jz, j=1) # Now for j=1
Add Comment
Please, Sign In to add comment