示例#1
0
def test_p():
    assert Px.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
    assert apply_operators(Px*PxKet(px)) == px*PxKet(px)
    assert PxKet(px).dual_class == PxBra
    assert PxBra(x).dual_class == PxKet
    assert (Dagger(PxKet(py))*PxKet(px)).doit() == DiracDelta(px-py)
    assert (XBra(x)*PxKet(px)).doit() ==\
        exp(I*x*px/hbar)/sqrt(2*pi*hbar)
    assert represent(PxKet(px)) == px
示例#2
0
def test_x():
    assert X.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
    assert Commutator(X, Px).doit() == I*hbar
    assert apply_operators(X*XKet(x)) == x*XKet(x)
    assert XKet(x).dual_class == XBra
    assert XBra(x).dual_class == XKet
    assert (Dagger(XKet(y))*XKet(x)).doit() == DiracDelta(x-y)
    assert (PxBra(px)*XKet(x)).doit() ==\
        exp(-I*x*px/hbar)/sqrt(2*pi*hbar)
    assert represent(XKet(x)) == x
    assert XBra(x).position == x
示例#3
0
def test_H():
    assert PIABHamiltonian('H').hilbert_space ==\
        L2(Interval(S.NegativeInfinity,S.Infinity))
    assert apply_operators(PIABHamiltonian('H')*PIABKet(n)) ==\
        (n**2*pi**2*hbar**2)/(2*m*L**2)*PIABKet(n)
示例#4
0
def test_jplus():
    assert Commutator(Jplus, Jminus).doit() == 2*hbar*Jz
    assert apply_operators(Jplus*JzKet(1,1)) == 0
    assert Jplus.matrix_element(1,1,1,1) == 0
    assert Jplus.rewrite('xyz') == Jx + I*Jy
示例#5
0
def test_H():
    assert PIABHamiltonian('H').hilbert_space ==\
        L2(Interval(S.NegativeInfinity,S.Infinity))
    assert apply_operators(PIABHamiltonian('H')*PIABKet(n)) ==\
        (n**2*pi**2*hbar**2)/(2*m*L**2)*PIABKet(n)