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.

59 lines
1.4 KiB

7 months ago
  1. """Constants (like hbar) related to quantum mechanics."""
  2. from sympy.core.numbers import NumberSymbol
  3. from sympy.core.singleton import Singleton
  4. from sympy.printing.pretty.stringpict import prettyForm
  5. import mpmath.libmp as mlib
  6. #-----------------------------------------------------------------------------
  7. # Constants
  8. #-----------------------------------------------------------------------------
  9. __all__ = [
  10. 'hbar',
  11. 'HBar',
  12. ]
  13. class HBar(NumberSymbol, metaclass=Singleton):
  14. """Reduced Plank's constant in numerical and symbolic form [1]_.
  15. Examples
  16. ========
  17. >>> from sympy.physics.quantum.constants import hbar
  18. >>> hbar.evalf()
  19. 1.05457162000000e-34
  20. References
  21. ==========
  22. .. [1] https://en.wikipedia.org/wiki/Planck_constant
  23. """
  24. is_real = True
  25. is_positive = True
  26. is_negative = False
  27. is_irrational = True
  28. __slots__ = ()
  29. def _as_mpf_val(self, prec):
  30. return mlib.from_float(1.05457162e-34, prec)
  31. def _sympyrepr(self, printer, *args):
  32. return 'HBar()'
  33. def _sympystr(self, printer, *args):
  34. return 'hbar'
  35. def _pretty(self, printer, *args):
  36. if printer._use_unicode:
  37. return prettyForm('\N{PLANCK CONSTANT OVER TWO PI}')
  38. return prettyForm('hbar')
  39. def _latex(self, printer, *args):
  40. return r'\hbar'
  41. # Create an instance for everyone to use.
  42. hbar = HBar()