m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

7 months ago
  1. from sympy.physics.pring import wavefunction, energy
  2. from sympy.core.numbers import (I, pi)
  3. from sympy.functions.elementary.exponential import exp
  4. from sympy.functions.elementary.miscellaneous import sqrt
  5. from sympy.integrals.integrals import integrate
  6. from sympy.simplify.simplify import simplify
  7. from sympy.abc import m, x, r
  8. from sympy.physics.quantum.constants import hbar
  9. def test_wavefunction():
  10. Psi = {
  11. 0: (1/sqrt(2 * pi)),
  12. 1: (1/sqrt(2 * pi)) * exp(I * x),
  13. 2: (1/sqrt(2 * pi)) * exp(2 * I * x),
  14. 3: (1/sqrt(2 * pi)) * exp(3 * I * x)
  15. }
  16. for n in Psi:
  17. assert simplify(wavefunction(n, x) - Psi[n]) == 0
  18. def test_norm(n=1):
  19. # Maximum "n" which is tested:
  20. for i in range(n + 1):
  21. assert integrate(
  22. wavefunction(i, x) * wavefunction(-i, x), (x, 0, 2 * pi)) == 1
  23. def test_orthogonality(n=1):
  24. # Maximum "n" which is tested:
  25. for i in range(n + 1):
  26. for j in range(i+1, n+1):
  27. assert integrate(
  28. wavefunction(i, x) * wavefunction(j, x), (x, 0, 2 * pi)) == 0
  29. def test_energy(n=1):
  30. # Maximum "n" which is tested:
  31. for i in range(n+1):
  32. assert simplify(
  33. energy(i, m, r) - ((i**2 * hbar**2) / (2 * m * r**2))) == 0