• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python secondquant.apply_operators函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.physics.secondquant.apply_operators函数的典型用法代码示例。如果您正苦于以下问题:Python apply_operators函数的具体用法?Python apply_operators怎么用?Python apply_operators使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了apply_operators函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_commutation

def test_commutation():
    n, m = symbols("n,m", above_fermi=True)
    c = Commutator(B(0), Bd(0))
    assert c == 1
    c = Commutator(Bd(0), B(0))
    assert c == -1
    c = Commutator(B(n), Bd(0))
    assert c == KroneckerDelta(n, 0)
    c = Commutator(B(0), Bd(0))
    e = simplify(apply_operators(c*BKet([n])))
    assert e == BKet([n])
    c = Commutator(B(0), B(1))
    e = simplify(apply_operators(c*BKet([n, m])))
    assert e == 0

    c = Commutator(F(m), Fd(m))
    assert c == +1 - 2*NO(Fd(m)*F(m))
    c = Commutator(Fd(m), F(m))
    assert c == -1 + 2*NO(Fd(m)*F(m))

    C = Commutator
    X, Y, Z = symbols('X,Y,Z', commutative=False)
    assert C(C(X, Y), Z) != 0
    assert C(C(X, Z), Y) != 0
    assert C(Y, C(X, Z)) != 0

    i, j, k, l = symbols('i,j,k,l', below_fermi=True)
    a, b, c, d = symbols('a,b,c,d', above_fermi=True)
    p, q, r, s = symbols('p,q,r,s')
    D = KroneckerDelta

    assert C(Fd(a), F(i)) == -2*NO(F(i)*Fd(a))
    assert C(Fd(j), NO(Fd(a)*F(i))).doit(wicks=True) == -D(j, i)*Fd(a)
    assert C(Fd(a)*F(i), Fd(b)*F(j)).doit(wicks=True) == 0
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:34,代码来源:test_secondquant.py


示例2: test_commutation

def test_commutation():
    c = commutator(B(0), Bd(0))
    e = simplify(apply_operators(c*Ket([n])))
    assert e == Ket([n])
    c = commutator(B(0), B(1))
    e = simplify(apply_operators(c*Ket([n,m])))
    assert e == 0
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:7,代码来源:test_secondquant.py


示例3: test_symbolic_matrix_elements

def test_symbolic_matrix_elements():
    n, m = symbols('n m')
    s1 = BBra([n])
    s2 = BKet([m])
    o = B(0)
    e = apply_operators(s1*o*s2)
    assert e == sqrt(m)*KroneckerDelta(n, m-1)
开发者ID:bibile,项目名称:sympy,代码行数:7,代码来源:test_secondquant.py


示例4: test_commutation

def test_commutation():
    n, m = symbols("n,m", above_fermi=True)
    c = Commutator(B(0), Bd(0))
    assert c == 1
    c = Commutator(Bd(0), B(0))
    assert c == -1
    c = Commutator(B(n), Bd(0))
    assert c == KroneckerDelta(n, 0)
    c = Commutator(B(0), B(0))
    assert c == 0
    c = Commutator(B(0), Bd(0))
    e = simplify(apply_operators(c*BKet([n])))
    assert e == BKet([n])
    c = Commutator(B(0), B(1))
    e = simplify(apply_operators(c*BKet([n, m])))
    assert e == 0

    c = Commutator(F(m), Fd(m))
    assert c == +1 - 2*NO(Fd(m)*F(m))
    c = Commutator(Fd(m), F(m))
    assert c.expand() == -1 + 2*NO(Fd(m)*F(m))

    C = Commutator
    X, Y, Z = symbols('X,Y,Z', commutative=False)
    assert C(C(X, Y), Z) != 0
    assert C(C(X, Z), Y) != 0
    assert C(Y, C(X, Z)) != 0

    i, j, k, l = symbols('i,j,k,l', below_fermi=True)
    a, b, c, d = symbols('a,b,c,d', above_fermi=True)
    p, q, r, s = symbols('p,q,r,s')
    D = KroneckerDelta

    assert C(Fd(a), F(i)) == -2*NO(F(i)*Fd(a))
    assert C(Fd(j), NO(Fd(a)*F(i))).doit(wicks=True) == -D(j, i)*Fd(a)
    assert C(Fd(a)*F(i), Fd(b)*F(j)).doit(wicks=True) == 0

    c1 = Commutator(F(a), Fd(a))
    assert Commutator.eval(c1, c1) == 0
    c = Commutator(Fd(a)*F(i),Fd(b)*F(j))
    assert latex(c) == r'\left[a^\dagger_{a} a_{i},a^\dagger_{b} a_{j}\right]'
    assert repr(c) == 'Commutator(CreateFermion(a)*AnnihilateFermion(i),CreateFermion(b)*AnnihilateFermion(j))'
    assert str(c) == '[CreateFermion(a)*AnnihilateFermion(i),CreateFermion(b)*AnnihilateFermion(j)]'
开发者ID:bjodah,项目名称:sympy,代码行数:43,代码来源:test_secondquant.py


示例5: test_number_operator

def test_number_operator():
    n = symbols("n")
    o = Bd(0)*B(0)
    e = apply_operators(o*BKet([n]))
    assert e == n*BKet([n])
开发者ID:bibile,项目名称:sympy,代码行数:5,代码来源:test_secondquant.py


示例6: test_complex_apply

def test_complex_apply():
    n, m = symbols("n m")
    o = Bd(0)*B(0)*Bd(1)*B(0)
    e = apply_operators(o*BKet([n,m]))
    answer = sqrt(n)*sqrt(m+1)*(-1+n)*BKet([-1+n,1+m])
    assert expand(e) == expand(answer)
开发者ID:bibile,项目名称:sympy,代码行数:6,代码来源:test_secondquant.py


示例7: test_basic_apply

def test_basic_apply():
    n = symbols("n")
    e = B(0)*BKet([n])
    assert apply_operators(e) == sqrt(n)*BKet([n-1])
    e = Bd(0)*BKet([n])
    assert apply_operators(e) == sqrt(n+1)*BKet([n+1])
开发者ID:bibile,项目名称:sympy,代码行数:6,代码来源:test_secondquant.py


示例8: test_basic_apply

def test_basic_apply():
    e = B(0)*Ket([n])
    assert apply_operators(e) == sqrt(n)*Ket([n-1])
    e = Bd(0)*Ket([n])
    assert apply_operators(e) == sqrt(n+1)*Ket([n+1])
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:5,代码来源:test_secondquant.py


示例9: test_number_operator

def test_number_operator():
    o = Bd(0)*B(0)
    e = apply_operators(o*Ket([n]))
    assert e == n*Ket([n])
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:4,代码来源:test_secondquant.py



注:本文中的sympy.physics.secondquant.apply_operators函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python secondquant.substitute_dummies函数代码示例发布时间:2022-05-27
下一篇:
Python represent.represent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap