pring.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. from sympy.core.numbers import (I, pi)
  2. from sympy.core.singleton import S
  3. from sympy.functions.elementary.exponential import exp
  4. from sympy.functions.elementary.miscellaneous import sqrt
  5. from sympy.physics.quantum.constants import hbar
  6. def wavefunction(n, x):
  7. """
  8. Returns the wavefunction for particle on ring.
  9. Parameters
  10. ==========
  11. n : The quantum number.
  12. Here ``n`` can be positive as well as negative
  13. which can be used to describe the direction of motion of particle.
  14. x :
  15. The angle.
  16. Examples
  17. ========
  18. >>> from sympy.physics.pring import wavefunction
  19. >>> from sympy import Symbol, integrate, pi
  20. >>> x=Symbol("x")
  21. >>> wavefunction(1, x)
  22. sqrt(2)*exp(I*x)/(2*sqrt(pi))
  23. >>> wavefunction(2, x)
  24. sqrt(2)*exp(2*I*x)/(2*sqrt(pi))
  25. >>> wavefunction(3, x)
  26. sqrt(2)*exp(3*I*x)/(2*sqrt(pi))
  27. The normalization of the wavefunction is:
  28. >>> integrate(wavefunction(2, x)*wavefunction(-2, x), (x, 0, 2*pi))
  29. 1
  30. >>> integrate(wavefunction(4, x)*wavefunction(-4, x), (x, 0, 2*pi))
  31. 1
  32. References
  33. ==========
  34. .. [1] Atkins, Peter W.; Friedman, Ronald (2005). Molecular Quantum
  35. Mechanics (4th ed.). Pages 71-73.
  36. """
  37. # sympify arguments
  38. n, x = S(n), S(x)
  39. return exp(n * I * x) / sqrt(2 * pi)
  40. def energy(n, m, r):
  41. """
  42. Returns the energy of the state corresponding to quantum number ``n``.
  43. E=(n**2 * (hcross)**2) / (2 * m * r**2)
  44. Parameters
  45. ==========
  46. n :
  47. The quantum number.
  48. m :
  49. Mass of the particle.
  50. r :
  51. Radius of circle.
  52. Examples
  53. ========
  54. >>> from sympy.physics.pring import energy
  55. >>> from sympy import Symbol
  56. >>> m=Symbol("m")
  57. >>> r=Symbol("r")
  58. >>> energy(1, m, r)
  59. hbar**2/(2*m*r**2)
  60. >>> energy(2, m, r)
  61. 2*hbar**2/(m*r**2)
  62. >>> energy(-2, 2.0, 3.0)
  63. 0.111111111111111*hbar**2
  64. References
  65. ==========
  66. .. [1] Atkins, Peter W.; Friedman, Ronald (2005). Molecular Quantum
  67. Mechanics (4th ed.). Pages 71-73.
  68. """
  69. n, m, r = S(n), S(m), S(r)
  70. if n.is_integer:
  71. return (n**2 * hbar**2) / (2 * m * r**2)
  72. else:
  73. raise ValueError("'n' must be integer")