当前位置: 首页>>代码示例>>Python>>正文


Python secondquant.apply_operators函数代码示例

本文整理汇总了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;未经允许,请勿转载。