SymPy 1.13 中文文档(三十八)
常数
原文:
docs.sympy.org/latest/modules/physics/quantum/constants.html
量子力学相关的常数(如 hbar)。
class sympy.physics.quantum.constants.HBar
数值和符号形式下的约化普朗克常数[R755]。
示例
>>> from sympy.physics.quantum.constants import hbar
>>> hbar.evalf()
1.05457162000000e-34
参考文献
[R755](1,2)
Dagger
原文链接:
docs.sympy.org/latest/modules/physics/quantum/dagger.html
Hermite 共轭。
class sympy.physics.quantum.dagger.Dagger(arg)
一般的 Hermitian 共轭操作。
参数:
arg:Expr
我们要对其取 Dagger 的 SymPy 表达式。
evaluate:bool
是否应直接评估结果表达式。
解释
取参数的 Hermetian 共轭[R756]。对于矩阵,此操作相当于转置和复共轭[R757]。
示例
各种量子对象的 Dagger 操作:
>>> from sympy.physics.quantum.dagger import Dagger
>>> from sympy.physics.quantum.state import Ket, Bra
>>> from sympy.physics.quantum.operator import Operator
>>> Dagger(Ket('psi'))
<psi|
>>> Dagger(Bra('phi'))
|phi>
>>> Dagger(Operator('A'))
Dagger(A)
内积和外积:
>>> from sympy.physics.quantum import InnerProduct, OuterProduct
>>> Dagger(InnerProduct(Bra('a'), Ket('b')))
<b|a>
>>> Dagger(OuterProduct(Ket('a'), Bra('b')))
|b><a|
幂、和及积:
>>> A = Operator('A')
>>> B = Operator('B')
>>> Dagger(A*B)
Dagger(B)*Dagger(A)
>>> Dagger(A+B)
Dagger(A) + Dagger(B)
>>> Dagger(A**2)
Dagger(A)**2
Dagger 也能无缝处理复数和矩阵:
>>> from sympy import Matrix, I
>>> m = Matrix([[1,I],[2,I]])
>>> m
Matrix([
[1, I],
[2, I]])
>>> Dagger(m)
Matrix([
[ 1, 2],
[-I, -I]])
参考文献
[R756] (1,2)
en.wikipedia.org/wiki/Hermitian_adjoint
[R757] (1,2)
en.wikipedia.org/wiki/Hermitian_transpose
内积
原文:
docs.sympy.org/latest/modules/physics/quantum/innerproduct.html
符号内积。
class sympy.physics.quantum.innerproduct.InnerProduct(bra, ket)
Bra 和 Ket 之间的未评估内积 [1]。
参数:
bra:BraBase 或其子类
内积在内积的左侧。
ket:KetBase 或其子类
内积右侧的 Ket。
例子
创建一个 InnerProduct 并检查其属性:
>>> from sympy.physics.quantum import Bra, Ket
>>> b = Bra('b')
>>> k = Ket('k')
>>> ip = b*k
>>> ip
<b|k>
>>> ip.bra
<b|
>>> ip.ket
|k>
在 kets 和 bras 的简单乘积中,内积将自动识别并创建:
>>> b*k
<b|k>
但在更复杂的表达式中,内积或外积的创建存在歧义:
>>> k*b*k*b
|k><b|*|k>*<b|
用户可以通过使用括号来分组 Bra 和 Ket 强制在复杂表达式中创建内积:
>>> k*(b*k)*b
<b|k>*|k>*<b|
注意内积 <b|k> 移到表达式的左侧,因为内积是可交换的复数。
参考文献
[R763]
en.wikipedia.org/wiki/Inner_product
张量积。
原文链接:
docs.sympy.org/latest/modules/physics/quantum/tensorproduct.html
抽象张量积。
class sympy.physics.quantum.tensorproduct.TensorProduct(*args)
两个或更多参数的张量积。
对于矩阵,这使用matrix_tensor_product来计算 Kronecker 或张量积矩阵。对于其他对象,返回一个符号的TensorProduct实例。张量积是一种非交换乘法,主要用于量子力学中的算符和态。
目前,张量积区分可交换和非可交换参数。可交换参数假定为标量,并且被拉出到TensorProduct的前面。非可交换参数保留在生成的TensorProduct中。
参数:
args:元组
一个需要进行张量积的对象序列。
示例。
从 SymPy 矩阵的简单张量积开始:
>>> from sympy import Matrix
>>> from sympy.physics.quantum import TensorProduct
>>> m1 = Matrix([[1,2],[3,4]])
>>> m2 = Matrix([[1,0],[0,1]])
>>> TensorProduct(m1, m2)
Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2],
[3, 0, 4, 0],
[0, 3, 0, 4]])
>>> TensorProduct(m2, m1)
Matrix([
[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 1, 2],
[0, 0, 3, 4]])
我们还可以构建非交换符号的张量积:
>>> from sympy import Symbol
>>> A = Symbol('A',commutative=False)
>>> B = Symbol('B',commutative=False)
>>> tp = TensorProduct(A, B)
>>> tp
AxB
我们可以对张量积进行伴随(请注意顺序不像普通乘积的伴随那样反转):
>>> from sympy.physics.quantum import Dagger
>>> Dagger(tp)
Dagger(A)xDagger(B)
可以使用Expand将张量积分布到加法之间:
>>> C = Symbol('C',commutative=False)
>>> tp = TensorProduct(A+B,C)
>>> tp
(A + B)xC
>>> tp.expand(tensorproduct=True)
AxC + BxC
sympy.physics.quantum.tensorproduct.tensor_product_simp(e, **hints)
尝试简化和组合 TensorProducts。
一般来说,这将尝试将表达式拉到TensorProducts内部。目前仅适用于相对简单的情况,其中乘积仅包含标量、原始的TensorProducts,而不是Add、Pow、Commutators的TensorProducts。最好通过示例看看它的表现。
示例。
>>> from sympy.physics.quantum import tensor_product_simp
>>> from sympy.physics.quantum import TensorProduct
>>> from sympy import Symbol
>>> A = Symbol('A',commutative=False)
>>> B = Symbol('B',commutative=False)
>>> C = Symbol('C',commutative=False)
>>> D = Symbol('D',commutative=False)
首先看看张量积乘积的情况:
>>> e = TensorProduct(A,B)*TensorProduct(C,D)
>>> e
AxB*CxD
>>> tensor_product_simp(e)
(A*C)x(B*D)
这是该函数的核心逻辑,它适用于内部、幂、求和、对易子和反对易子:
>>> tensor_product_simp(e**2)
(A*C)x(B*D)**2
笛卡尔算符和态
原文:
docs.sympy.org/latest/modules/physics/quantum/cartesian.html
一维笛卡尔位置和动量的算符和态。
待办事项:
- 在 operatorset.py 中将 3D 类添加到映射中
class sympy.physics.quantum.cartesian.PositionBra3D(*args, **kwargs)
三维笛卡尔位置本征矢
class sympy.physics.quantum.cartesian.PositionKet3D(*args, **kwargs)
三维笛卡尔位置本征矢
class sympy.physics.quantum.cartesian.PositionState3D(*args, **kwargs)
三维笛卡尔位置本征态的基类
property position_x
状态的 x 坐标
property position_y
状态的 y 坐标
property position_z
状态的 z 坐标
class sympy.physics.quantum.cartesian.PxBra(*args, **kwargs)
一维笛卡尔动量本征矢。
property momentum
状态的动量。
class sympy.physics.quantum.cartesian.PxKet(*args, **kwargs)
一维笛卡尔动量本征矢。
property momentum
状态的动量。
class sympy.physics.quantum.cartesian.PxOp(*args, **kwargs)
一维笛卡尔动量算符。
class sympy.physics.quantum.cartesian.XBra(*args, **kwargs)
一维笛卡尔位置本征矢。
property position
状态的位置。
class sympy.physics.quantum.cartesian.XKet(*args, **kwargs)
一维笛卡尔位置本征矢。
property position
状态的位置。
class sympy.physics.quantum.cartesian.XOp(*args, **kwargs)
一维笛卡尔位置算符。
class sympy.physics.quantum.cartesian.YOp(*args, **kwargs)
Y 笛卡尔坐标算符(适用于二维或三维系统)
class sympy.physics.quantum.cartesian.ZOp(*args, **kwargs)
Z 笛卡尔坐标算符(适用于三维系统)
希尔伯特空间
原文:
docs.sympy.org/latest/modules/physics/quantum/hilbert.html
量子力学的希尔伯特空间。
作者:* Brian Granger * Matt Curry
class sympy.physics.quantum.hilbert.ComplexSpace(dimension)
复数向量的有限维希尔伯特空间。
这个希尔伯特空间的元素是 n 维复值向量,具有常规内积,该内积会将右侧向量的复共轭。
这种类型希尔伯特空间的一个经典示例是自旋-1/2,即 ComplexSpace(2)。推广到自旋-s,该空间是 ComplexSpace(2*s+1)。用 N 个量子位做直积空间 ComplexSpace(2)**N。
示例
>>> from sympy import symbols
>>> from sympy.physics.quantum.hilbert import ComplexSpace
>>> c1 = ComplexSpace(2)
>>> c1
C(2)
>>> c1.dimension
2
>>> n = symbols('n')
>>> c2 = ComplexSpace(n)
>>> c2
C(n)
>>> c2.dimension
n
class sympy.physics.quantum.hilbert.DirectSumHilbertSpace(*args)
希尔伯特空间的直和[R758]。
这个类使用运算符 + 表示不同希尔伯特空间之间的直和。
DirectSumHilbertSpace 对象以任意数量的 HilbertSpace 对象作为其参数。此外,HilbertSpace 对象的加法将自动返回一个直和对象。
示例
>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> c = ComplexSpace(2)
>>> f = FockSpace()
>>> hs = c+f
>>> hs
C(2)+F
>>> hs.dimension
oo
>>> list(hs.spaces)
[C(2), F]
参考文献
[R758] (1,2)
zh.wikipedia.org/wiki/%E5%B8%8C%E5%B0%94%E4%BC%AF%E7%89%B9%E7%A9%BA%E9%97%B4#%E7%9B%B4%E5%92%8C
classmethod eval(args)
评估直积。
property spaces
这个直和的希尔伯特空间的元组。
class sympy.physics.quantum.hilbert.FockSpace
用于第二量子化的希尔伯特空间。
从技术上讲,这个希尔伯特空间是单粒子希尔伯特空间的无限直和直积[R759]。这是一个混乱的过程,所以我们有一个类来直接表示它。
示例
>>> from sympy.physics.quantum.hilbert import FockSpace
>>> hs = FockSpace()
>>> hs
F
>>> hs.dimension
oo
参考文献
[R759] (1,2)
zh.wikipedia.org/wiki/%E7%A6%8F%E5%85%8B%E7%A9%BA%E9%97%B4
class sympy.physics.quantum.hilbert.HilbertSpace
量子力学的抽象希尔伯特空间。
简而言之,希尔伯特空间是一个完备的抽象向量空间,其内积由定义[R760]。
示例
>>> from sympy.physics.quantum.hilbert import HilbertSpace
>>> hs = HilbertSpace()
>>> hs
H
参考文献
[R760] (1,2)
zh.wikipedia.org/wiki/%E5%B8%8C%E5%B0%94%E4%BC%AF%E7%89%B9%E7%A9%BA%E9%97%B4
property dimension
返回空间的希尔伯特维度。
class sympy.physics.quantum.hilbert.L2(interval)
一个在区间上具有平方可积函数的希尔伯特空间。
L2 对象接受一个 SymPy 区间参数,该参数表示其定义在上的函数(向量)的区间。
示例
>>> from sympy import Interval, oo
>>> from sympy.physics.quantum.hilbert import L2
>>> hs = L2(Interval(0,oo))
>>> hs
L2(Interval(0, oo))
>>> hs.dimension
oo
>>> hs.interval
Interval(0, oo)
class sympy.physics.quantum.hilbert.TensorPowerHilbertSpace(*args)
指数化的希尔伯特空间[R761]。
张量幂(重复张量积)由运算符 ** 表示。相同的希尔伯特空间相乘后将自动组合为单一的张量幂对象。
任何希尔伯特空间、乘积或和都可以被提升到张量幂。TensorPowerHilbertSpace 接受两个参数:希尔伯特空间和张量幂(数字)。
示例
>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> from sympy import symbols
>>> n = symbols('n')
>>> c = ComplexSpace(2)
>>> hs = c**n
>>> hs
C(2)**n
>>> hs.dimension
2**n
>>> c = ComplexSpace(2)
>>> c*c
C(2)**2
>>> f = FockSpace()
>>> c*f*f
C(2)*F**2
参考文献
[R761] (1,2)
class sympy.physics.quantum.hilbert.TensorProductHilbertSpace(*args)
希尔伯特空间的张量积[R762]。
希尔伯特空间之间的张量积由运算符 * 表示,同一希尔伯特空间的乘积将被合并为张量幂。
TensorProductHilbertSpace 对象将任意数量的 HilbertSpace 对象作为其参数。此外,HilbertSpace 对象的乘法将自动返回此张量积对象。
示例
>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> from sympy import symbols
>>> c = ComplexSpace(2)
>>> f = FockSpace()
>>> hs = c*f
>>> hs
C(2)*F
>>> hs.dimension
oo
>>> hs.spaces
(C(2), F)
>>> c1 = ComplexSpace(2)
>>> n = symbols('n')
>>> c2 = ComplexSpace(n)
>>> hs = c1*c2
>>> hs
C(2)*C(n)
>>> hs.dimension
2*n
参考文献
[R762] (1,2)
en.wikipedia.org/wiki/Hilbert_space#Tensor_products
classmethod eval(args)
评估直积。
property spaces
这个张量积中的 Hilbert 空间的元组。
算符
原文:
docs.sympy.org/latest/modules/physics/quantum/operator.html
量子力学算符。
待办事项:
-
修复早期在 apply_operators 中的 0。
-
调试和测试 apply_operators。
-
使此文件中的类与 CSE 协同工作。
-
InnerProduct、Commutator、AntiCommutator、represent、apply_operators 的 doctest 和特殊方法的文档。
class sympy.physics.quantum.operator.DifferentialOperator(*args, **kwargs)
用于表示微分算符的算符,即 d/dx
通过传递两个参数来初始化它。第一个是涉及函数的任意表达式,例如 Derivative(f(x), x)。第二个是我们将其替换为该 DifferentialOperator 应用的 Wavefunction 的函数(例如 f(x))。
参数:
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
返回要替换为波函数的函数
示例
>>> 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,使得 op * I == I * op == op。
参数:
N:整数
操作符的希尔伯特空间的维度的可选参数。在生成矩阵表示时使用。
示例
>>> from sympy.physics.quantum import IdentityOperator
>>> IdentityOperator()
I
class sympy.physics.quantum.operator.Operator(*args, **kwargs)
用于非对易量子算符的基类。
一个算符,用于映射量子态[R764]。在量子力学中,可观察量(包括但不限于测量的物理值)表示为厄米算符[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
算符不对易:
>>> 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
参考文献
[R764] (1,2)
zh.wikipedia.org/wiki/算子 _(物理学)
[R765] (1,2)
class sympy.physics.quantum.operator.OuterProduct(*args, **old_assumptions)
一个未评估的外积,介于 ket 和 bra 之间。
这构造了任何KetBase子类和BraBase之间的外积,如 |a><b|。OuterProduct从 Operator 继承,因为它们在量子表达式中充当操作符。有关详细信息,请参见[R766]。
参数:
ket : KetBase
左侧的外积的 ket。
bar : BraBase
右侧的外积的 bra。
示例
手动创建一个简单的外积并取其伴随:
>>> 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|
在 ket 和 bra 的简单乘积中,外积将被自动识别和创建:
>>> k*b
|k><b|
但在更复杂的表达式中,外积不会自动创建:
>>> A = Operator('A')
>>> A*k*b
A*|k>*<b|
用户可以通过使用括号来组合 ket 和 bra,在复杂表达式中强制创建外积:
>>> A*(k*b)
A*|k><b|
参考文献
[R766] (1,2)
en.wikipedia.org/wiki/Outer_product
property bra
返回外积右侧的 bra。
property ket
返回外积的左侧的 ket。
class sympy.physics.quantum.operator.UnitaryOperator(*args, **kwargs)
满足 U*Dagger(U) == 1 的酉算子。
参数:
args : tuple
一组唯一指定运算符的数字或参数列表。对于时变算符,这将包括时间。
示例
>>> from sympy.physics.quantum import Dagger, UnitaryOperator
>>> U = UnitaryOperator('U')
>>> U*Dagger(U)
1
算符/状态辅助函数
原文:
docs.sympy.org/latest/modules/physics/quantum/operatorset.html
一个模块,用于将算符映射到其相应的本征态,反之亦然
它包含一个全局字典,其中包含本征态-算符的配对关系。如果创建了新的状态-算符对,则还应更新此字典。
它还包含函数 operators_to_state 和 state_to_operators,用于在算符和状态之间进行映射。这些函数可以处理算符和状态的类和实例。有关详细信息,请参见各个函数描述。
TODO 列表:- 更新包含状态-算符对完整列表的字典
sympy.physics.quantum.operatorset.operators_to_state(operators, **options)
返回给定算符或算符集的本征态。
一个全局函数,用于将算符类映射到其关联的状态。它接受算符或算符集,并返回与这些算符关联的状态。
此函数可以处理给定算符的实例或仅类本身(即 XOp()和 XOp 都可以)
需要考虑多个用例:
-
传递类或类集:首先,我们尝试为这些算符实例化默认实例。如果失败,则简单返回类。如果成功实例化默认实例,则尝试在算符实例上调用 state._operators_to_state。如果失败,则返回类。否则,返回 _operators_to_state 返回的实例。
-
传递实例或实例集:在这种情况下,对传递的实例调用 state._operators_to_state。如果失败,则返回状态类。如果方法返回实例,则返回该实例。
在这两种情况下,如果状态映射字典中不存在算符类或集合,则返回 None。
参数:
arg: 算符或集合
算符或算符集的类或实例要映射到状态
示例
>>> from sympy.physics.quantum.cartesian import XOp, PxOp
>>> from sympy.physics.quantum.operatorset import operators_to_state
>>> from sympy.physics.quantum.operator import Operator
>>> operators_to_state(XOp)
|x>
>>> operators_to_state(XOp())
|x>
>>> operators_to_state(PxOp)
|px>
>>> operators_to_state(PxOp())
|px>
>>> operators_to_state(Operator)
|psi>
>>> operators_to_state(Operator())
|psi>
sympy.physics.quantum.operatorset.state_to_operators(state, **options)
返回给定本征态对应的算符或算符集
一个全局函数,用于将状态类映射到其关联的算符或算符集。它接受状态类或实例。
此函数可以处理给定状态的实例或仅类本身(即 XKet()和 XKet 都可以)。
需要考虑多个用例:
-
传递状态类:在这种情况下,首先尝试实例化类的默认实例。如果成功,则尝试在该实例上调用 state._state_to_operators。如果创建默认实例或调用 _state_to_operators 失败,则返回算符类或算符类集。否则,返回适当的算符实例。
-
返回状态实例:在这里,对实例调用 state._state_to_operators。如果失败,则返回类或算符类集。否则,返回实例。
无论哪种情况,如果状态的类在 state_mapping 中不存在,则返回 None。
参数:
arg: StateBase 类或实例(或其子类)
要映射到操作符或一组操作符的状态的类或实例
示例
>>> from sympy.physics.quantum.cartesian import XKet, PxKet, XBra, PxBra
>>> from sympy.physics.quantum.operatorset import state_to_operators
>>> from sympy.physics.quantum.state import Ket, Bra
>>> state_to_operators(XKet)
X
>>> state_to_operators(XKet())
X
>>> state_to_operators(PxKet)
Px
>>> state_to_operators(PxKet())
Px
>>> state_to_operators(PxBra)
Px
>>> state_to_operators(XBra)
X
>>> state_to_operators(Ket)
O
>>> state_to_operators(Bra)
O
Qapply
原文:
docs.sympy.org/latest/modules/physics/quantum/qapply.html
逻辑应用于状态操作符。
待办事项:*有时最终结果需要展开,我们应该手动执行此操作。
sympy.physics.quantum.qapply.qapply(e, **options)
在量子表达式中应用状态操作符。
参数:
e:表达式
包含操作符和状态的表达式。该表达式树将以符号方式查找操作符作用于状态。
options:字典
一组键值对,确定如何执行操作符的操作。
以下选项有效:
dagger:尝试将 Dagger 操作符应用于左侧(默认为 False)。ip_doit:遇到内积时调用.doit()(默认为 True)。
返回:
e:表达式
将操作符应用于状态的原始表达式。
例子
>>> from sympy.physics.quantum import qapply, Ket, Bra
>>> b = Bra('b')
>>> k = Ket('k')
>>> A = k * b
>>> A
|k><b|
>>> qapply(A * b.dual / (b * b.dual))
|k>
>>> qapply(k.dual * A / (k.dual * k), dagger=True)
<b|
>>> qapply(k.dual * A / (k.dual * k))
<k|*|k><b|/<k|k>
表示
原文链接:
docs.sympy.org/latest/modules/physics/quantum/represent.html
用于在各种基底中表示状态操作符的逻辑。
TODO:
-
获得与连续希尔伯特空间一起工作的表示工作。
-
文档默认基础功能。
sympy.physics.quantum.represent.enumerate_states(*args, **options)
返回附加了虚指数的给定状态的实例
在两种不同的模式下运行:
-
传递了两个参数。第一个是要索引的基态,第二个参数是要附加的索引列表。
-
传递了三个参数。第一个再次是要索引的基态。第二个是计数的起始索引。最后一个参数是您希望接收的 ket 的数量。
尝试调用 state._enumerate_state。如果失败,则返回一个空列表
参数:
args : 列表
查看上面的操作模式列表以获取解释
示例
>>> from sympy.physics.quantum.cartesian import XBra, XKet
>>> from sympy.physics.quantum.represent import enumerate_states
>>> test = XKet('foo')
>>> enumerate_states(test, 1, 3)
[|foo_1>, |foo_2>, |foo_3>]
>>> test2 = XBra('bar')
>>> enumerate_states(test2, [4, 5, 10])
[<bar_4|, <bar_5|, <bar_10|]
sympy.physics.quantum.represent.get_basis(expr, *, basis=None, replace_none=True, **options)
返回与 options=s 中指定的基础相对应的基态实例。如果未指定基础,则函数尝试形成给定表达式的默认基态。
有三种行为:
-
在选项中指定的基础已经是 StateBase 的实例。如果是这种情况,则简单地返回。如果指定了类但不是实例,则返回默认实例。
-
指定的基础是操作符或一组操作符。如果是这种情况,则使用 operator_to_state 映射方法。
-
没有指定基底。如果 expr 是一个状态,则返回其类的默认实例。如果 expr 是一个操作符,则将其映射到相应的状态。如果它既不是,则无法获得基态。
如果无法映射基础,则不会更改。
这将从 represent 内部调用,并且 represent 将只传递 QExpr。
TODO (?): 支持 Muls 和其他类型的表达式?
参数:
expr : 操作符或 StateBase
寻求其基底的表达式
示例
>>> from sympy.physics.quantum.represent import get_basis
>>> from sympy.physics.quantum.cartesian import XOp, XKet, PxOp, PxKet
>>> x = XKet()
>>> X = XOp()
>>> get_basis(x)
|x>
>>> get_basis(X)
|x>
>>> get_basis(x, basis=PxOp())
|px>
>>> get_basis(x, basis=PxKet)
|px>
sympy.physics.quantum.represent.integrate_result(orig_expr, result, **options)
返回在给定表达式中积分任何 unities (|x><x|) 的结果。用于在连续基底中积分表示的结果。
此函数在量子表达式中插入任何 unities 后进行积分并返回结果。它使用传递给它的基态的希尔伯特空间的区间来确定积分的限制。必须为此指定 unities 选项才能工作。
注意:这主要是由 represent()在内部使用。示例仅用于展示用例。
参数:
orig_expr : 量子表达式
最初要表示的表达式
result: Expr
我们希望对其进行积分的结果表示
示例
>>> from sympy import symbols, DiracDelta
>>> from sympy.physics.quantum.represent import integrate_result
>>> from sympy.physics.quantum.cartesian import XOp, XKet
>>> x_ket = XKet()
>>> X_op = XOp()
>>> x, x_1, x_2 = symbols('x, x_1, x_2')
>>> integrate_result(X_op*x_ket, x*DiracDelta(x-x_1)*DiracDelta(x_1-x_2))
x*DiracDelta(x - x_1)*DiracDelta(x_1 - x_2)
>>> integrate_result(X_op*x_ket, x*DiracDelta(x-x_1)*DiracDelta(x_1-x_2),
... unities=[1])
x*DiracDelta(x - x_2)
sympy.physics.quantum.represent.rep_expectation(expr, **options)
返回给定操作符的 <x'|A|x> 类型表示。
参数:
expr : 操作符
要在指定基础上表示的操作符
示例
>>> from sympy.physics.quantum.cartesian import XOp, PxOp, PxKet
>>> from sympy.physics.quantum.represent import rep_expectation
>>> rep_expectation(XOp())
x_1*DiracDelta(x_1 - x_2)
>>> rep_expectation(XOp(), basis=PxOp())
<px_2|*X*|px_1>
>>> rep_expectation(XOp(), basis=PxKet())
<px_2|*X*|px_1>
sympy.physics.quantum.represent.rep_innerproduct(expr, **options)
返回给定状态的内积表示(例如 <x'|x>)。
尝试计算与来自指定基组的 bra 的内积。只应传递 KetBase 或 BraBase 的实例。
参数:
expr:KetBase 或 BraBase
要表示的表达式
示例
>>> from sympy.physics.quantum.represent import rep_innerproduct
>>> from sympy.physics.quantum.cartesian import XOp, XKet, PxOp, PxKet
>>> rep_innerproduct(XKet())
DiracDelta(x - x_1)
>>> rep_innerproduct(XKet(), basis=PxOp())
sqrt(2)*exp(-I*px_1*x/hbar)/(2*sqrt(hbar)*sqrt(pi))
>>> rep_innerproduct(PxKet(), basis=XOp())
sqrt(2)*exp(I*px*x_1/hbar)/(2*sqrt(hbar)*sqrt(pi))
sympy.physics.quantum.represent.represent(expr, **options)
在给定基组中表示量子表达式。
在量子力学中,抽象状态和算符可以在各种基组中表示。在此操作下,发生以下转换:
-
Ket -> 列向量或函数
-
Bra -> 行向量或函数
-
Operator -> 矩阵或微分算符
此函数是此操作的顶级接口。
此函数遍历 SymPy 表达式树,查找具有 _represent 方法的 QExpr 实例。然后调用此方法,并用此方法返回的表示形式替换对象。默认情况下,_represent 方法将分派到处理特定基组表示逻辑的其他方法。这些方法的命名约定如下:
def _represent_FooBasis(self, e, basis, **options)
此函数将具有在名为 FooBasis 的类中具有基组集的类的实例的表示逻辑。
参数:
expr:Expr
要表示的表达式。
basis:Operator,基组集
包含有关基组的信息的对象。如果使用操作符,则假定基组是该操作符的标准正交特征向量。尽管如此,基组参数通常可以是包含基组信息的任何对象。
options:dict
传递给找到表示形式的基础方法的选项的键/值对。可以使用这些选项来控制如何进行表示。例如,这里可以设置基组大小。
返回:
e:Expr
表示的量子表达式的 SymPy 表达式。
示例
在这里,我们子类化 Operator 和 Ket 来创建 z 自旋算符及其自旋 1/2 上的本征态。通过定义 _represent_SzOp 方法,可以在 z 自旋基组中表示这个 ket。
>>> from sympy.physics.quantum import Operator, represent, Ket
>>> from sympy import Matrix
>>> class SzUpKet(Ket):
... def _represent_SzOp(self, basis, **options):
... return Matrix([1,0])
...
>>> class SzOp(Operator):
... pass
...
>>> sz = SzOp('Sz')
>>> up = SzUpKet('up')
>>> represent(up, basis=sz)
Matrix([
[1],
[0]])
在这里,我们看到在连续基组中的表示示例。我们看到代表笛卡尔位置算符和 ket 的各种组合的结果,给出了涉及 DiracDelta 函数的连续表达式。
>>> from sympy.physics.quantum.cartesian import XOp, XKet, XBra
>>> X = XOp()
>>> x = XKet()
>>> y = XBra('y')
>>> represent(X*x)
x*DiracDelta(x - x_2)
>>> represent(X*x*y)
x*DiracDelta(x - x_3)*DiracDelta(x_1 - y)
自旋
原文链接:
docs.sympy.org/latest/modules/physics/quantum/spin.html
量子力学角动量。
class sympy.physics.quantum.spin.J2Op(*args, **kwargs)
J² 操作符。
class sympy.physics.quantum.spin.JxBra(j, m)
Jx 的本征 bra。
查看 JzKet 以了解自旋特征态的使用。
另请参见
JzKet
自旋态的使用
class sympy.physics.quantum.spin.JxBraCoupled(j, m, jn, *jcoupling)
Jx 的耦合本征 bra。
查看 JzKetCoupled 以了解耦合自旋特征态的使用。
另请参见
JzKetCoupled
耦合自旋态的使用
class sympy.physics.quantum.spin.JxKet(j, m)
Jx 的本征 ket。
查看 JzKet 以了解自旋特征态的使用。
另请参见
JzKet
自旋态的使用
class sympy.physics.quantum.spin.JxKetCoupled(j, m, jn, *jcoupling)
Jx 的耦合本征 ket。
查看 JzKetCoupled 以了解耦合自旋特征态的使用。
另请参见
JzKetCoupled
耦合自旋态的使用
class sympy.physics.quantum.spin.JyBra(j, m)
Jy 的本征 bra。
查看 JzKet 以了解自旋特征态的使用。
另请参见
JzKet
自旋态的使用
class sympy.physics.quantum.spin.JyBraCoupled(j, m, jn, *jcoupling)
Jy 的耦合本征 bra。
查看 JzKetCoupled 以了解耦合自旋特征态的使用。
另请参见
JzKetCoupled
耦合自旋态的使用
class sympy.physics.quantum.spin.JyKet(j, m)
Jy 的本征 ket。
查看 JzKet 以了解自旋特征态的使用。
另请参见
JzKet
自旋态的使用
class sympy.physics.quantum.spin.JyKetCoupled(j, m, jn, *jcoupling)
Jy 的耦合特征态。
查看 JzKetCoupled 以了解耦合自旋特征态的使用。
另请参见
JzKetCoupled
耦合自旋态的使用
class sympy.physics.quantum.spin.JzBra(j, m)
Jz 的本征 bra。
查看 JzKet 以了解自旋特征态的使用。
另请参见
JzKet
自旋态的使用
class sympy.physics.quantum.spin.JzBraCoupled(j, m, jn, *jcoupling)
Jz 的耦合本征 bra。
查看 JzKetCoupled 以了解耦合自旋特征态的使用。
另请参见
JzKetCoupled
耦合自旋态的使用
class sympy.physics.quantum.spin.JzKet(j, m)
Jz 的本征 ket。
是 Jz 算符的本征态的自旋态。未耦合态,即表示多个独立自旋态相互作用的状态,被定义为状态的张量积。
参数:
j:数字,符号
总自旋角动量
m:数字,符号
Jz 自旋算符的本征值
示例
正常状态:
定义简单自旋态,包括数值和符号:
>>> from sympy.physics.quantum.spin import JzKet, JxKet
>>> from sympy import symbols
>>> JzKet(1, 0)
|1,0>
>>> j, m = symbols('j m')
>>> JzKet(j, m)
|j,m>
将 JzKet 重新写成 Jx 算符的本征 ket:注意:结果的本征态是 JxKet's
>>> JzKet(1,1).rewrite("Jx")
|1,-1>/2 - sqrt(2)*|1,0>/2 + |1,1>/2
获取状态的矢量表示,用 Jx 算符的基元素表示:
>>> from sympy.physics.quantum.represent import represent
>>> from sympy.physics.quantum.spin import Jx, Jz
>>> represent(JzKet(1,-1), basis=Jx)
Matrix([
[ 1/2],
[sqrt(2)/2],
[ 1/2]])
在状态之间应用内积:
>>> from sympy.physics.quantum.innerproduct import InnerProduct
>>> from sympy.physics.quantum.spin import JxBra
>>> i = InnerProduct(JxBra(1,1), JzKet(1,1))
>>> i
<1,1|1,1>
>>> i.doit()
1/2
未耦合态:
将未耦合态定义为两个 Jz 特征态之间的张量积:
>>> from sympy.physics.quantum.tensorproduct import TensorProduct
>>> j1,m1,j2,m2 = symbols('j1 m1 j2 m2')
>>> TensorProduct(JzKet(1,0), JzKet(1,1))
|1,0>x|1,1>
>>> TensorProduct(JzKet(j1,m1), JzKet(j2,m2))
|j1,m1>x|j2,m2>
TensorProduct 可以被重写,此时组成张量积的本征态将被重写为新的基础:
>>> TensorProduct(JzKet(1,1),JxKet(1,1)).rewrite('Jz')
|1,1>x|1,-1>/2 + sqrt(2)*|1,1>x|1,0>/2 + |1,1>x|1,1>/2
TensorProduct 的 represent 方法给出状态的向量表示。请注意,产品基础中的状态相当于组分本征态的张量积:
>>> represent(TensorProduct(JzKet(1,0),JzKet(1,1)))
Matrix([
[0],
[0],
[0],
[1],
[0],
[0],
[0],
[0],
[0]])
>>> represent(TensorProduct(JzKet(1,1),JxKet(1,1)), basis=Jz)
Matrix([
[ 1/2],
[sqrt(2)/2],
[ 1/2],
[ 0],
[ 0],
[ 0],
[ 0],
[ 0],
[ 0]])
另请参阅
JzKetCoupled
耦合的本征态
sympy.physics.quantum.tensorproduct.TensorProduct
用于指定未耦合的状态
uncouple
给定耦合参数,取消耦合状态
couple
耦合未耦合的状态
class sympy.physics.quantum.spin.JzKetCoupled(j, m, jn, *jcoupling)
Jz 的耦合本征态
表示 Jz 的本征态,表示单独旋转空间的耦合。
创建JzKetCoupled实例的参数是j、m、jn以及可选的jcoupling参数。j和m选项是总角动量量子数,如用于普通状态(例如 JzKet)。
jn中的另一个必需参数是一个元组,定义了乘积空间的(j_n)角动量量子数。例如,如果一个状态表示耦合产品基态(\left|j_1,m_1\right\rangle\times\left|j_2,m_2\right\rangle),那么这个状态的jn将是(j1,j2)。
最后一个选项是jcoupling,用于定义由jn指定的空间如何耦合,包括耦合这些空间的顺序和由此耦合产生的量子数。jcoupling参数本身是一个列表,其中每个子列表定义了旋转空间之间的单个耦合。如果有 N 个耦合的角动量空间,即jn有 N 个元素,则必须有 N-1 个子列表。组成jcoupling参数的每个子列表长度为 3。前两个元素是被认为耦合在一起的乘积空间的索引。例如,如果我们想要耦合(j_1)和(j_4),那么索引将是 1 和 4。如果一个状态已经被耦合,则通过耦合其最小的索引来引用它,因此如果(j_2)和(j_4)已经被耦合到某个(j_{24}),则可以通过索引 2 耦合这个值。子列表的最后一个元素是耦合态的量子数。因此,将所有内容放入jcoupling的有效子列表中,如果(j_1)和(j_2)与量子数(j_{12})的角动量空间耦合,则子列表将是(1,2,j12),在jcoupling的列表中使用 N-1 个这些子列表。
注意 jcoupling 参数是可选的,如果未指定,则采用默认耦合。默认值是按顺序耦合空间,并将耦合的量子数取为最大值。例如,如果自旋空间是 (j_1),(j_2),(j_3),(j_4),则默认耦合会将 (j_1) 和 (j_2) 耦合到 (j_{12}=j_1+j_2),然后将 (j_{12}) 和 (j_3) 耦合到 (j_{123}=j_{12}+j_3),最后将 (j_{123}) 和 (j_4) 耦合到 (j=j_{123}+j_4)。对应的 jcoupling 值如下:
((1,2,j1+j2),(1,3,j1+j2+j3))
参数:
args:tuple
必须传递的参数包括
j,m,jn和jcoupling。j值是总角动量。m值是 Jz 自旋算符的特征值。jn列表是耦合在一起的角动量空间的 j 值。jcoupling参数是一个可选参数,定义空间如何耦合在一起。查看上述描述以了解这些耦合参数的定义。
示例
定义简单的自旋态,包括数值和符号:
>>> from sympy.physics.quantum.spin import JzKetCoupled
>>> from sympy import symbols
>>> JzKetCoupled(1, 0, (1, 1))
|1,0,j1=1,j2=1>
>>> j, m, j1, j2 = symbols('j m j1 j2')
>>> JzKetCoupled(j, m, (j1, j2))
|j,m,j1=j1,j2=j2>
定义超过 2 个耦合空间的耦合自旋态,具有各种耦合参数:
>>> JzKetCoupled(2, 1, (1, 1, 1))
|2,1,j1=1,j2=1,j3=1,j(1,2)=2>
>>> JzKetCoupled(2, 1, (1, 1, 1), ((1,2,2),(1,3,2)) )
|2,1,j1=1,j2=1,j3=1,j(1,2)=2>
>>> JzKetCoupled(2, 1, (1, 1, 1), ((2,3,1),(1,2,2)) )
|2,1,j1=1,j2=1,j3=1,j(2,3)=1>
将 JzKetCoupled 重写为 Jx 算符的本征态:注意:结果的本征态是 JxKetCoupled
>>> JzKetCoupled(1,1,(1,1)).rewrite("Jx")
|1,-1,j1=1,j2=1>/2 - sqrt(2)*|1,0,j1=1,j2=1>/2 + |1,1,j1=1,j2=1>/2
重写方法可以用于将耦合态转换为非耦合态。通过向 rewrite 函数传递 coupled=False 来实现:
>>> JzKetCoupled(1, 0, (1, 1)).rewrite('Jz', coupled=False)
-sqrt(2)*|1,-1>x|1,1>/2 + sqrt(2)*|1,1>x|1,-1>/2
用 Jx 算符的基本元素的基础上获取一个状态的向量表示:
>>> from sympy.physics.quantum.represent import represent
>>> from sympy.physics.quantum.spin import Jx
>>> from sympy import S
>>> represent(JzKetCoupled(1,-1,(S(1)/2,S(1)/2)), basis=Jx)
Matrix([
[ 0],
[ 1/2],
[sqrt(2)/2],
[ 1/2]])
另见
JzKet
正常的自旋本征态
uncouple
耦合耦合自旋态
couple
耦合未耦合的自旋态
class sympy.physics.quantum.spin.JzOp(*args, **kwargs)
Jz 算符。
class sympy.physics.quantum.spin.Rotation(*args, **kwargs)
用欧拉角表示的 Wigner D 算符。
用 z-y-z 惯例定义的欧拉角旋转算符,用于被动变换。即首先围绕 z 轴旋转坐标轴,得到新的 x’-y’-z’ 坐标系。然后围绕新的 y’ 轴旋转这个新的坐标系,得到新的 x’’-y’’-z’’ 坐标系。最后围绕 z’’ 轴旋转这个新的坐标系。符号遵循 [R767] 中列出的惯例。
参数:
alpha:Number, Symbol
第一个欧拉角
beta:Number, Symbol
第二个欧拉角
gamma:Number, Symbol
第三个欧拉角
示例
一个简单的示例旋转算符:
>>> from sympy import pi
>>> from sympy.physics.quantum.spin import Rotation
>>> Rotation(pi, 0, pi/2)
R(pi,0,pi/2)
使用符号欧拉角计算逆旋转算符:
>>> from sympy import symbols
>>> a, b, c = symbols('a b c')
>>> Rotation(a, b, c)
R(a,b,c)
>>> Rotation(a, b, c).inverse()
R(-c,-b,-a)
另见
WignerD
符号 Wigner-D 函数
D
Wigner-D 函数
d
Wigner 小 d 函数
References
[R767] (1,2)
Varshalovich, D A, Quantum Theory of Angular Momentum. 1988.
classmethod D(j, m, mp, alpha, beta, gamma)
Wigner D-function.
Returns an instance of the WignerD class corresponding to the Wigner-D function specified by the parameters.
Parameters:
j : Number
Total angular momentum
m : Number
Eigenvalue of angular momentum along axis after rotation
mp : Number
Eigenvalue of angular momentum along rotated axis
alpha : Number, Symbol
First Euler angle of rotation
beta : Number, Symbol
Second Euler angle of rotation
gamma : Number, Symbol
Third Euler angle of rotation
Examples
Return the Wigner-D matrix element for a defined rotation, both numerical and symbolic:
>>> from sympy.physics.quantum.spin import Rotation
>>> from sympy import pi, symbols
>>> alpha, beta, gamma = symbols('alpha beta gamma')
>>> Rotation.D(1, 1, 0,pi, pi/2,-pi)
WignerD(1, 1, 0, pi, pi/2, -pi)
See also
WignerD
Symbolic Wigner-D function
classmethod d(j, m, mp, beta)
Wigner small-d function.
Returns an instance of the WignerD class corresponding to the Wigner-D function specified by the parameters with the alpha and gamma angles given as 0.
Parameters:
j : Number
Total angular momentum
m : Number
Eigenvalue of angular momentum along axis after rotation
mp : Number
Eigenvalue of angular momentum along rotated axis
beta : Number, Symbol
Second Euler angle of rotation
Examples
Return the Wigner-D matrix element for a defined rotation, both numerical and symbolic:
>>> from sympy.physics.quantum.spin import Rotation
>>> from sympy import pi, symbols
>>> beta = symbols('beta')
>>> Rotation.d(1, 1, 0, pi/2)
WignerD(1, 1, 0, 0, pi/2, 0)
See also
WignerD
Symbolic Wigner-D function
class sympy.physics.quantum.spin.WignerD(*args, **hints)
Wigner-D function
The Wigner D-function gives the matrix elements of the rotation operator in the jm-representation. For the Euler angles (\alpha), (\beta), (\gamma), the D-function is defined such that:
[<j,m| \mathcal{R}(\alpha, \beta, \gamma ) |j',m'> = \delta_{jj'} D(j, m, m', \alpha, \beta, \gamma)]
Where the rotation operator is as defined by the Rotation class [R768].
The Wigner D-function defined in this way gives:
[D(j, m, m', \alpha, \beta, \gamma) = e^{-i m \alpha} d(j, m, m', \beta) e^{-i m' \gamma}]
Where d is the Wigner small-d function, which is given by Rotation.d.
The Wigner small-d function gives the component of the Wigner D-function that is determined by the second Euler angle. That is the Wigner D-function is:
[D(j, m, m', \alpha, \beta, \gamma) = e^{-i m \alpha} d(j, m, m', \beta) e^{-i m' \gamma}]
Where d is the small-d function. The Wigner D-function is given by Rotation.D.
Note that to evaluate the D-function, the j, m and mp parameters must be integer or half integer numbers.
Parameters:
j : Number
Total angular momentum
m : Number
Eigenvalue of angular momentum along axis after rotation
mp : Number
Eigenvalue of angular momentum along rotated axis
alpha : Number, Symbol
First Euler angle of rotation
beta : Number, Symbol
Second Euler angle of rotation
gamma : Number, Symbol
Third Euler angle of rotation
Examples
Evaluate the Wigner-D matrix elements of a simple rotation:
>>> from sympy.physics.quantum.spin import Rotation
>>> from sympy import pi
>>> rot = Rotation.D(1, 1, 0, pi, pi/2, 0)
>>> rot
WignerD(1, 1, 0, pi, pi/2, 0)
>>> rot.doit()
sqrt(2)/2
Evaluate the Wigner-d matrix elements of a simple rotation
>>> rot = Rotation.d(1, 1, 0, pi/2)
>>> rot
WignerD(1, 1, 0, 0, pi/2, 0)
>>> rot.doit()
-sqrt(2)/2
See also
旋转
旋转算子
参考文献
[R768] (1,2)
Varshalovich, D A, Angular Momentum 的量子理论。 1988 年。
sympy.physics.quantum.spin.couple(expr, jcoupling_list=None)
耦合自旋态的张量积
此函数可用于耦合自旋态的非耦合张量积。要耦合的所有特征态必须属于相同类。它将返回由克莱布斯-戈登角动量耦合系数确定的耦合自旋态子类的线性组合。
参数:
expr : 表达式
涉及要耦合的自旋态张量积的表达式。每个状态必须是 SpinState 的子类,并且它们都必须是相同的类。
jcoupling_list : 列表或元组
此列表的元素是长度为 2 的子列表,指定自旋空间耦合的顺序。此列表的长度必须是 N-1,其中 N 是要耦合的张量积中状态的数量。这个子列表的元素与为 JzKetCoupled 定义的
jcoupling参数中每个子列表的前两个元素相同。如果未指定此参数,则采用默认值,该默认值耦合第一个和第二个产品基础空间,然后将这个新耦合空间耦合到第三个产品空间等等
示例
为两个空间的数值状态耦合张量积
>>> from sympy.physics.quantum.spin import JzKet, couple
>>> from sympy.physics.quantum.tensorproduct import TensorProduct
>>> couple(TensorProduct(JzKet(1,0), JzKet(1,1)))
-sqrt(2)*|1,1,j1=1,j2=1>/2 + sqrt(2)*|2,1,j1=1,j2=1>/2
使用默认耦合方法耦合三个空间的数值耦合,即首先耦合第一和第二空间,然后耦合到第三空间:
>>> couple(TensorProduct(JzKet(1,1), JzKet(1,1), JzKet(1,0)))
sqrt(6)*|2,2,j1=1,j2=1,j3=1,j(1,2)=2>/3 + sqrt(3)*|3,2,j1=1,j2=1,j3=1,j(1,2)=2>/3
进行相同的耦合,但我们定义耦合首先耦合第一个和第三个空间:
>>> couple(TensorProduct(JzKet(1,1), JzKet(1,1), JzKet(1,0)), ((1,3),(1,2)) )
sqrt(2)*|2,2,j1=1,j2=1,j3=1,j(1,3)=1>/2 - sqrt(6)*|2,2,j1=1,j2=1,j3=1,j(1,3)=2>/6 + sqrt(3)*|3,2,j1=1,j2=1,j3=1,j(1,3)=2>/3
耦合符号态的张量积:
>>> from sympy import symbols
>>> j1,m1,j2,m2 = symbols('j1 m1 j2 m2')
>>> couple(TensorProduct(JzKet(j1,m1), JzKet(j2,m2)))
Sum(CG(j1, m1, j2, m2, j, m1 + m2)*|j,m1 + m2,j1=j1,j2=j2>, (j, m1 + m2, j1 + j2))
sympy.physics.quantum.spin.uncouple(expr, jn=None, jcoupling_list=None)
解耦耦合自旋态
给出了耦合自旋态的非耦合表示。参数必须是耦合自旋态子类或自旋态子类以及给出要耦合的空间的 j 值的数组
参数:
expr : 表达式
包含要耦合的状态的表达式。如果状态是 SpinState 的子类,则必须定义
jn和jcoupling参数。如果状态是 CoupledSpinState 的子类,则将从状态中取出jn和jcoupling。
jn : 列表或元组
被耦合的 j 值列表。如果状态是 CoupledSpinState,则忽略此参数。如果状态不是 CoupledSpinState 的子类,则必须定义此参数。此参数的语法与 JzKetCoupled 的
jn参数相同。
jcoupling_list : 列表或元组
定义了如何耦合 j 值的列表。如果状态是 CoupledSpinState,则忽略此参数。如果状态不是 CoupledSpinState 的子类,则必须定义此参数。此参数的语法与 JzKetCoupled 的
jcoupling参数相同。
示例
使用 CoupledSpinState 状态解耦数值状态:
>>> from sympy.physics.quantum.spin import JzKetCoupled, uncouple
>>> from sympy import S
>>> uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2)))
sqrt(2)*|1/2,-1/2>x|1/2,1/2>/2 + sqrt(2)*|1/2,1/2>x|1/2,-1/2>/2
使用 SpinState 状态执行相同的计算:
>>> from sympy.physics.quantum.spin import JzKet
>>> uncouple(JzKet(1, 0), (S(1)/2, S(1)/2))
sqrt(2)*|1/2,-1/2>x|1/2,1/2>/2 + sqrt(2)*|1/2,1/2>x|1/2,-1/2>/2
使用 CoupledSpinState 状态解耦三个耦合空间的数值状态:
>>> uncouple(JzKetCoupled(1, 1, (1, 1, 1), ((1,3,1),(1,2,1)) ))
|1,-1>x|1,1>x|1,1>/2 - |1,0>x|1,0>x|1,1>/2 + |1,1>x|1,0>x|1,0>/2 - |1,1>x|1,1>x|1,-1>/2
使用 SpinState 状态执行相同的计算:
>>> uncouple(JzKet(1, 1), (1, 1, 1), ((1,3,1),(1,2,1)) )
|1,-1>x|1,1>x|1,1>/2 - |1,0>x|1,0>x|1,1>/2 + |1,1>x|1,0>x|1,0>/2 - |1,1>x|1,1>x|1,-1>/2
使用 CoupledSpinState 状态解耦符号状态:
>>> from sympy import symbols
>>> j,m,j1,j2 = symbols('j m j1 j2')
>>> uncouple(JzKetCoupled(j, m, (j1, j2)))
Sum(CG(j1, m1, j2, m2, j, m)*|j1,m1>x|j2,m2>, (m1, -j1, j1), (m2, -j2, j2))
使用 SpinState 状态执行相同的计算
>>> uncouple(JzKet(j, m), (j1, j2))
Sum(CG(j1, m1, j2, m2, j, m)*|j1,m1>x|j2,m2>, (m1, -j1, j1), (m2, -j2, j2))