算符#

量子力学算符。

TODO:

  • 修复applyu运算符中的早期0。

  • 调试和测试应用运算符。

  • 让cse处理这个文件中的类。

  • 内积、换向器、反交换器、表示、应用运算符的特殊方法的文档和文档。

class sympy.physics.quantum.operator.DifferentialOperator(*args, **kwargs)[源代码]#

表示微分算子的一种运算符,即d/dx

它通过传递两个参数来初始化。第一种是包含函数的任意表达式,例如 Derivative(f(x), x) . 第二个是功能(例如。 f(x) )我们要用 Wavefunction 这个 DifferentialOperator 应用于。

参数:

expr :表达式

将适当的波函数代入的任意表达式

func :表达式

当应用微分算子时,用适当的波函数代替的函数(如f(x))

实例

您可以定义一个完全任意的表达式,并指定要替换波函数的位置

>>> from sympy import Derivative, Function, Symbol
>>> from sympy.physics.quantum.operator import DifferentialOperator
>>> from sympy.physics.quantum.state import Wavefunction
>>> from sympy.physics.quantum.qapply import qapply
>>> f = Function('f')
>>> x = Symbol('x')
>>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x))
>>> w = Wavefunction(x**2, x)
>>> d.function
f(x)
>>> d.variables
(x,)
>>> qapply(d*w)
Wavefunction(2, x)
property expr#

返回要将波函数替换到其中的任意表达式

实例

>>> from sympy.physics.quantum.operator import DifferentialOperator
>>> from sympy import Function, Symbol, Derivative
>>> x = Symbol('x')
>>> f = Function('f')
>>> d = DifferentialOperator(Derivative(f(x), x), f(x))
>>> d.expr
Derivative(f(x), x)
>>> y = Symbol('y')
>>> d = DifferentialOperator(Derivative(f(x, y), x) +
...                          Derivative(f(x, y), y), f(x, y))
>>> d.expr
Derivative(f(x, y), x) + Derivative(f(x, y), y)
property free_symbols#

返回表达式的自由符号。

property function#

返回要用Wavefunction替换的函数

实例

>>> from sympy.physics.quantum.operator import DifferentialOperator
>>> from sympy import Function, Symbol, Derivative
>>> x = Symbol('x')
>>> f = Function('f')
>>> d = DifferentialOperator(Derivative(f(x), x), f(x))
>>> d.function
f(x)
>>> y = Symbol('y')
>>> d = DifferentialOperator(Derivative(f(x, y), x) +
...                          Derivative(f(x, y), y), f(x, y))
>>> d.function
f(x, y)
property variables#

返回用于计算指定任意表达式中函数的变量

实例

>>> from sympy.physics.quantum.operator import DifferentialOperator
>>> from sympy import Symbol, Function, Derivative
>>> x = Symbol('x')
>>> f = Function('f')
>>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x))
>>> d.variables
(x,)
>>> y = Symbol('y')
>>> d = DifferentialOperator(Derivative(f(x, y), x) +
...                          Derivative(f(x, y), y), f(x, y))
>>> d.variables
(x, y)
class sympy.physics.quantum.operator.HermitianOperator(*args, **kwargs)[源代码]#

满足H==Dagger(H)的厄米算符。

参数:

args :元组

唯一指定运算符的数字或参数的列表。对于依赖时间的运算符,这将包括时间。

实例

>>> from sympy.physics.quantum import Dagger, HermitianOperator
>>> H = HermitianOperator('H')
>>> Dagger(H)
H
class sympy.physics.quantum.operator.IdentityOperator(*args, **kwargs)[源代码]#

满足op的恒等算子I * I == I * op==op表示任何运算符op。

参数:

N :整数

可选参数,指定运算符的Hilbert空间的维数。这是在生成矩阵表示时使用的。

实例

>>> from sympy.physics.quantum import IdentityOperator
>>> IdentityOperator()
I
class sympy.physics.quantum.operator.Operator(*args, **kwargs)[源代码]#

非交换量子算符的基类。

An operator maps between quantum states [R764]. In quantum mechanics, observables (including, but not limited to, measured physical values) are represented as Hermitian operators [R765].

参数:

args :元组

唯一指定运算符的数字或参数的列表。对于依赖时间的运算符,这将包括时间。

实例

创建运算符并检查其属性:

>>> from sympy.physics.quantum import Operator
>>> from sympy import I
>>> A = Operator('A')
>>> A
A
>>> A.hilbert_space
H
>>> A.label
(A,)
>>> A.is_commutative
False

创建另一个运算符并执行一些算术运算:

>>> B = Operator('B')
>>> C = 2*A*A + I*B
>>> C
2*A**2 + I*B

Operators do not commute:

>>> A.is_commutative
False
>>> B.is_commutative
False
>>> A*B == B*A
False

算子的多元多项式尊重交换性质:

>>> e = (A+B)**3
>>> e.expand()
A*B*A + A*B**2 + A**2*B + A**3 + B*A*B + B*A**2 + B**2*A + B**3

运算符反转是符号化的处理方式:

>>> A.inv()
A**(-1)
>>> A*A.inv()
1

工具书类

class sympy.physics.quantum.operator.OuterProduct(*args, **old_assumptions)[源代码]#

文胸和文胸之间未经估价的外部产品。

This constructs an outer product between any subclass of KetBase and BraBase as |a><b|. An OuterProduct inherits from Operator as they act as operators in quantum expressions. For reference see [R766].

参数:

ket :番茄酱

外部产品左侧的ket。

bar :BraBase数据库

在胸罩的右边。

实例

用手制作一个简单的外部产品,然后拿起它的匕首:

>>> from sympy.physics.quantum import Ket, Bra, OuterProduct, Dagger
>>> from sympy.physics.quantum import Operator

>>> k = Ket('k')
>>> b = Bra('b')
>>> op = OuterProduct(k, b)
>>> op
|k><b|
>>> op.hilbert_space
H
>>> op.ket
|k>
>>> op.bra
<b|
>>> Dagger(op)
|b><k|

在简单的kets和bras产品中,外部产品将被自动识别和创建:

>>> k*b
|k><b|

但在更复杂的表达式中,外部产品不会自动创建:

>>> A = Operator('A')
>>> A*k*b
A*|k>*<b|

用户可以通过使用括号将ket和bra分组来强制在复杂表达式中创建外部积:

>>> A*(k*b)
A*|k><b|

工具书类

property bra#

将胸罩放回产品右侧。

property ket#

返回外部产品左侧的ket。

class sympy.physics.quantum.operator.UnitaryOperator(*args, **kwargs)[源代码]#

满足U*Dagger(U)==1的酉算子。

参数:

args :元组

唯一指定运算符的数字或参数的列表。对于依赖时间的运算符,这将包括时间。

实例

>>> from sympy.physics.quantum import Dagger, UnitaryOperator
>>> U = UnitaryOperator('U')
>>> U*Dagger(U)
1