操作符/状态辅助函数¶
一个用于将算符映射到其对应的本征态及其逆映射的模块
它包含一个全局字典,其中包含本征态-算符对。如果创建了一个新的本征态-算符对,这个字典也应相应更新。
它还包含用于在两者之间映射的函数 operators_to_state 和 state_to_operators。这些函数可以处理运算符和状态的类及其实例。详情请参见各个函数的描述。
待办事项列表: - 更新字典,包含完整的状态-操作符对列表
- sympy.physics.quantum.operatorset.operators_to_state(operators, **options)[源代码][源代码]¶
返回给定算符或一组算符的本征态
一个用于将操作符类映射到其关联状态的全局函数。它接受一个操作符或一组操作符,并返回与这些操作符关联的状态。
此函数可以处理给定操作符的实例或仅处理类本身(即 XOp() 和 XOp)
有多种使用场景需要考虑:
1) A class or set of classes is passed: First, we try to instantiate default instances for these operators. If this fails, then the class is simply returned. If we succeed in instantiating default instances, then we try to call state._operators_to_state on the operator instances. If this fails, the class is returned. Otherwise, the instance returned by _operators_to_state is returned.
2) An instance or set of instances is passed: In this case, state._operators_to_state is called on the instances passed. If this fails, a state class is returned. If the method returns an instance, that instance is returned.
在这两种情况下,如果操作符类或集合在 state_mapping 字典中不存在,则返回 None。
- 参数:
- 参数: 操作符或集合
要映射到状态的操作符的类或实例,或一组操作符
示例
>>> 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)
有多种使用场景需要考虑:
1) A state class is passed: In this case, we first try instantiating a default instance of the class. If this succeeds, then we try to call state._state_to_operators on that instance. If the creation of the default instance or if the calling of _state_to_operators fails, then either an operator class or set of operator classes is returned. Otherwise, the appropriate operator instances are returned.
2) A state instance is returned: Here, state._state_to_operators is called for the instance. If this fails, then a class or set of operator classes is returned. Otherwise, the instances are returned.
在任何情况下,如果状态的类在 state_mapping 中不存在,则返回 None。
- 参数:
- 参数: 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