from __future__ import division
from sympy import cos, exp, expand, I, Matrix, pi, S, sin, sqrt, Sum, symbols
from sympy.abc import alpha, beta, gamma, j, m
from sympy.physics.quantum import hbar, represent, Commutator, InnerProduct
from sympy.physics.quantum.qapply import qapply
from sympy.physics.quantum.tensorproduct import TensorProduct
from sympy.physics.quantum.cg import CG
from sympy.physics.quantum.spin import (
Jx, Jy, Jz, Jplus, Jminus, J2,
JxBra, JyBra, JzBra,
JxKet, JyKet, JzKet,
JxKetCoupled, JyKetCoupled, JzKetCoupled,
couple, uncouple,
Rotation, WignerD
)
from sympy.utilities.pytest import raises
j1,j2,j3,j4,m1,m2,m3,m4 = symbols('j1:5 m1:5')
j12,j13,j24,j34,j123,j134,mi,mi1,mp = symbols('j12 j13 j24 j34 j123 j134 mi mi1 mp')
def test_represent_spin_operators():
assert represent(Jx) == hbar*Matrix([[0,1],[1,0]])/2
assert represent(Jx, j=1) == hbar*sqrt(2)*Matrix([[0,1,0],[1,0,1],[0,1,0]])/2
assert represent(Jy) == hbar*I*Matrix([[0,-1],[1,0]])/2
assert represent(Jy, j=1) == hbar*I*sqrt(2)*Matrix([[0,-1,0],[1,0,-1],[0,1,0]])/2
assert represent(Jz) == hbar*Matrix([[1,0],[0,-1]])/2
assert represent(Jz, j=1) == hbar*Matrix([[1,0,0],[0,0,0],[0,0,-1]])
def test_represent_spin_states():
# Jx basis
assert represent(JxKet(S(1)/2,S(1)/2), basis=Jx) == Matrix([1,0])
assert represent(JxKet(S(1)/2,-S(1)/2), basis=Jx) == Matrix([0,1])
assert represent(JxKet(1,1), basis=Jx) == Matrix([1,0,0])
assert represent(JxKet(1,0), basis=Jx) == Matrix([0,1,0])
assert represent(JxKet(1,-1), basis=Jx) == Matrix([0,0,1])
assert represent(JyKet(S(1)/2,S(1)/2), basis=Jx) == Matrix([exp(-I*pi/4),0])
assert represent(JyKet(S(1)/2,-S(1)/2), basis=Jx) == Matrix([0,exp(I*pi/4)])
assert represent(JyKet(1,1), basis=Jx) == Matrix([-I,0,0])
assert represent(JyKet(1,0), basis=Jx) == Matrix([0,1,0])
assert represent(JyKet(1,-1), basis=Jx) == Matrix([0,0,I])
assert represent(JzKet(S(1)/2,S(1)/2), basis=Jx) == sqrt(2)*Matrix([-1,1])/2
assert represent(JzKet(S(1)/2,-S(1)/2), basis=Jx) == sqrt(2)*Matrix([-1,-1])/2
assert represent(JzKet(1,1), basis=Jx) == Matrix([1,-sqrt(2),1])/2
assert represent(JzKet(1,0), basis=Jx) == sqrt(2)*Matrix([1,0,-1])/2
assert represent(JzKet(1,-1), basis=Jx) == Matrix([1,sqrt(2),1])/2
# Jy basis
assert represent(JxKet(S(1)/2,S(1)/2), basis=Jy) == Matrix([exp(-3*I*pi/4),0])
assert represent(JxKet(S(1)/2,-S(1)/2), basis=Jy) == Matrix([0,exp(3*I*pi/4)])
assert represent(JxKet(1,1), basis=Jy) == Matrix([I,0,0])
assert represent(JxKet(1,0), basis=Jy) == Matrix([0,1,0])
assert represent(JxKet(1,-1), basis=Jy) == Matrix([0,0,-I])
assert represent(JyKet(S(1)/2,S(1)/2), basis=Jy) == Matrix([1,0])
assert represent(JyKet(S(1)/2,-S(1)/2), basis=Jy) == Matrix([0,1])
assert represent(JyKet(1,1), basis=Jy) == Matrix([1,0,0])
assert represent(JyKet(1,0), basis=Jy) == Matrix([0,1,0])
assert represent(JyKet(1,-1), basis=Jy) == Matrix([0,0,1])
assert represent(JzKet(S(1)/2,S(1)/2), basis=Jy) == sqrt(2)*Matrix([-1,I])/2
assert represent(JzKet(S(1)/2,-S(1)/2), basis=Jy) == sqrt(2)*Matrix([I,-1])/2
assert represent(JzKet(1,1), basis=Jy) == Matrix([1,-I*sqrt(2),-1])/2
assert represent(JzKet(1,0), basis=Jy) == Matrix([-sqrt(2)*I,0,-sqrt(2)*I])/2
assert represent(JzKet(1,-1), basis=Jy) == Matrix([-1,-sqrt(2)*I,1])/2
# Jz basis
assert represent(JxKet(S(1)/2,S(1)/2), basis=Jz) == sqrt(2)*Matrix([1,1])/2
assert represent(JxKet(S(1)/2,-S(1)/2), basis=Jz) == sqrt(2)*Matrix([-1,1])/2
assert represent(JxKet(1,1), basis=Jz) == Matrix([1,sqrt(2),1])/2
assert represent(JxKet(1,0), basis=Jz) == sqrt(2)*Matrix([-1,0,1])/2
assert represent(JxKet(1,-1), basis=Jz) == Matrix([1,-sqrt(2),1])/2
assert represent(JyKet(S(1)/2,S(1)/2), basis=Jz) == sqrt(2)*Matrix([-1,-I])/2
assert represent(JyKet(S(1)/2,-S(1)/2), basis=Jz) == sqrt(2)*Matrix([-I,-1])/2
assert represent(JyKet(1,1), basis=Jz) == Matrix([1,sqrt(2)*I,-1])/2
assert represent(JyKet(1,0), basis=Jz) == sqrt(2)*Matrix([I,0,I])/2
assert represent(JyKet(1,-1), basis=Jz) == Matrix([-1,sqrt(2)*I,1])/2
assert represent(JzKet(S(1)/2,S(1)/2), basis=Jz) == Matrix([1,0])
assert represent(JzKet(S(1)/2,-S(1)/2), basis=Jz) == Matrix([0,1])
assert represent(JzKet(1,1), basis=Jz) == Matrix([1,0,0])
assert represent(JzKet(1,0), basis=Jz) == Matrix([0,1,0])
assert represent(JzKet(1,-1), basis=Jz) == Matrix([0,0,1])
def test_represent_uncoupled_states():
# Jx basis
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([1,0,0,0])
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([0,1,0,0])
assert represent(TensorProduct(JxKet(S(1)/2,-S(1)/2),JxKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([0,0,1,0])
assert represent(TensorProduct(JxKet(S(1)/2,-S(1)/2),JxKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([0,0,0,1])
assert represent(TensorProduct(JyKet(S(1)/2,S(1)/2),JyKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([-I,0,0,0])
assert represent(TensorProduct(JyKet(S(1)/2,S(1)/2),JyKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([0,1,0,0])
assert represent(TensorProduct(JyKet(S(1)/2,-S(1)/2),JyKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([0,0,1,0])
assert represent(TensorProduct(JyKet(S(1)/2,-S(1)/2),JyKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([0,0,0,I])
assert represent(TensorProduct(JzKet(S(1)/2,S(1)/2),JzKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([S(1)/2,-S(1)/2,-S(1)/2,S(1)/2])
assert represent(TensorProduct(JzKet(S(1)/2,S(1)/2),JzKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([S(1)/2,S(1)/2,-S(1)/2,-S(1)/2])
assert represent(TensorProduct(JzKet(S(1)/2,-S(1)/2),JzKet(S(1)/2,S(1)/2)), basis=Jx) == \
Matrix([S(1)/2,-S(1)/2,S(1)/2,-S(1)/2])
assert represent(TensorProduct(JzKet(S(1)/2,-S(1)/2),JzKet(S(1)/2,-S(1)/2)), basis=Jx) == \
Matrix([S(1)/2,S(1)/2,S(1)/2,S(1)/2])
# Jy basis
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([I,0,0,0])
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([0,1,0,0])
assert represent(TensorProduct(JxKet(S(1)/2,-S(1)/2),JxKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([0,0,1,0])
assert represent(TensorProduct(JxKet(S(1)/2,-S(1)/2),JxKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([0,0,0,-I])
assert represent(TensorProduct(JyKet(S(1)/2,S(1)/2),JyKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([1,0,0,0])
assert represent(TensorProduct(JyKet(S(1)/2,S(1)/2),JyKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([0,1,0,0])
assert represent(TensorProduct(JyKet(S(1)/2,-S(1)/2),JyKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([0,0,1,0])
assert represent(TensorProduct(JyKet(S(1)/2,-S(1)/2),JyKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([0,0,0,1])
assert represent(TensorProduct(JzKet(S(1)/2,S(1)/2),JzKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([S(1)/2,-I/2,-I/2,-S(1)/2])
assert represent(TensorProduct(JzKet(S(1)/2,S(1)/2),JzKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([-I/2,S(1)/2,-S(1)/2,-I/2])
assert represent(TensorProduct(JzKet(S(1)/2,-S(1)/2),JzKet(S(1)/2,S(1)/2)), basis=Jy) == \
Matrix([-I/2,-S(1)/2,S(1)/2,-I/2])
assert represent(TensorProduct(JzKet(S(1)/2,-S(1)/2),JzKet(S(1)/2,-S(1)/2)), basis=Jy) == \
Matrix([-S(1)/2,-I/2,-I/2,S(1)/2])
# Jz basis
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,S(1)/2)), basis=Jz) == \
Matrix([S(1)/2,S(1)/2,S(1)/2,S(1)/2])
assert represent(TensorProduct(JxKet(S(1)/2,S(1)/2),JxKet(S(1)/2,-S(1)/2)), basis=Jz) == \
Matrix([-S(1)/2,S(1)/2,-S(1)/2,S(1)/2])
assert represent(TensorProduct(JxKe
没有合适的资源?快使用搜索试试~ 我知道了~
sympy-0.7.2.tar.gz
0 下载量 190 浏览量
2024-03-20
00:43:10
上传
评论
收藏 5.23MB GZ 举报
温馨提示
GNU项目是一个自由软件集体协作项目,由理查德·斯托曼于1983年发起,旨在创建一个完全自由的操作系统,称为GNU操作系统。该项目强调软件的自由,即用户能够自由地运行、复制、分发、学习、改变和改进软件。GNU项目产生了许多重要的软件,例如GNU编译器集合(GCC)和GNU通用公共许可证(GPL),后者为开源软件提供了法律基础。 Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。
资源推荐
资源详情
资源评论
收起资源包目录
sympy-0.7.2.tar.gz (1134个子文件)
isympy.1 6KB
AUTHORS 8KB
apidoc.conf 233B
multable.dat 2KB
.DS_Store 12KB
.DS_Store 6KB
.DS_Store 6KB
SymPy-Favicon.ico 6KB
SymPy-Favicon-WithoutTail.ico 5KB
ipythonrc-sympy 1KB
isympy 11KB
LICENSE 1KB
LICENSE 1KB
Makefile 5KB
tutorial.mo 27KB
tutorial.mo 23KB
tutorial.mo 21KB
tutorial.mo 18KB
tutorial.mo 17KB
tutorial.mo 15KB
tutorial.mo 15KB
kin_1pt.pdf 13KB
vec_dot.pdf 10KB
simp_rot.pdf 9KB
vec_simp_der.pdf 9KB
kin_rolling.pdf 9KB
kin_2pt.pdf 9KB
kin_angvel2.pdf 8KB
kin_angvel1.pdf 8KB
vec_cross.pdf 7KB
kin_2.pdf 7KB
kin_angvel3.pdf 7KB
kin_4.pdf 6KB
vec_fix_notfix.pdf 6KB
vec_rep.pdf 6KB
ex_rd.pdf 6KB
kin_1.pdf 6KB
kin_3.pdf 6KB
vec_add.pdf 5KB
vec_mul.pdf 5KB
PKG-INFO 1KB
SymPy-500x500-Logo-No-Transparency.png 172KB
SymPy-500x500-Logo.png 172KB
SymPy-500x500-Logo -No-Text.png 163KB
SymPy-500x500-Logo-No-Transparency-No-Text.png 149KB
SymPy-Logo-NoTail.png 146KB
SymPy-NoTail-NoText.png 137KB
winpdb2.png 92KB
kleinj.png 76KB
bi_c.png 66KB
winpdb1.png 65KB
ai_c.png 61KB
kleinj2.png 60KB
gi_c.png 56KB
spherharm42.png 50KB
spherharm43.png 47KB
hi_c.png 46KB
coulombg_c.png 45KB
cplot.png 42KB
spherharm44.png 40KB
bessely_c.png 40KB
coulombf_c.png 39KB
spherharm41.png 37KB
besselj_c.png 37KB
hankel1_c.png 35KB
hankel2_c.png 35KB
besseli_c.png 34KB
coulombf.png 34KB
coulombg.png 33KB
chebyt.png 32KB
besselk_c.png 30KB
lambertw_c.png 28KB
pcfd.png 28KB
legendre.png 27KB
hankel2.png 26KB
hankel1.png 26KB
lommels1.png 26KB
ai.png 26KB
hermite.png 25KB
bi.png 25KB
ellipe.png 24KB
splot.png 23KB
spherharm40.png 23KB
besselj.png 23KB
chebyu.png 22KB
ellipf.png 22KB
ellippi.png 21KB
plot.png 20KB
sympylogo.png 19KB
bessely.png 19KB
ber.png 19KB
laguerre.png 19KB
besseli.png 19KB
gi.png 18KB
lommels2.png 17KB
lambertw.png 15KB
besselk.png 15KB
ker.png 14KB
ellipk.png 12KB
hi.png 10KB
共 1134 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
程序员Chino的日记
- 粉丝: 3680
- 资源: 5万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功