Exemple #1
0
def test_SHOKet():
    assert SHOKet('k').dual_class() == SHOBra
    assert SHOBra('b').dual_class() == SHOKet
    assert InnerProduct(b, k).doit() == KroneckerDelta(k.n, b.n)
    assert k.hilbert_space == ComplexSpace(S.Infinity)
    assert k3_rep[k3.n, 0] == Integer(1)
    assert b3_rep[0, b3.n] == Integer(1)
Exemple #2
0
from sympy.functions.special.tensor_functions import KroneckerDelta
from sympy.physics.quantum.hilbert import ComplexSpace
from sympy.physics.quantum.represent import represent
from sympy.external import import_module
from sympy.testing.pytest import skip

from sympy.physics.quantum.sho1d import (RaisingOp, LoweringOp, SHOKet, SHOBra,
                                         Hamiltonian, NumberOp)

ad = RaisingOp('a')
a = LoweringOp('a')
k = SHOKet('k')
kz = SHOKet(0)
kf = SHOKet(1)
k3 = SHOKet(3)
b = SHOBra('b')
b3 = SHOBra(3)
H = Hamiltonian('H')
N = NumberOp('N')
omega = Symbol('omega')
m = Symbol('m')
ndim = Integer(4)

np = import_module('numpy')
scipy = import_module('scipy', __import__kwargs={'fromlist': ['sparse']})

ad_rep_sympy = represent(ad, basis=N, ndim=4, format='sympy')
a_rep = represent(a, basis=N, ndim=4, format='sympy')
N_rep = represent(N, basis=N, ndim=4, format='sympy')
H_rep = represent(H, basis=N, ndim=4, format='sympy')
k3_rep = represent(k3, basis=N, ndim=4, format='sympy')
Exemple #3
0
from sympy.physics.quantum import Commutator
from sympy.physics.quantum.qapply import qapply
from sympy.physics.quantum.innerproduct import InnerProduct
from sympy.physics.quantum.cartesian import X, Px
from sympy.functions.special.tensor_functions import KroneckerDelta
from sympy.physics.quantum.hilbert import ComplexSpace

from sympy.physics.quantum.sho1d import (RaisingOp, LoweringOp, SHOKet, SHOBra,
                                         Hamiltonian, NumberOp)

ad = RaisingOp('a')
a = LoweringOp('a')
k = SHOKet('k')
kz = SHOKet(0)
kf = SHOKet(1)
b = SHOBra('b')
H = Hamiltonian('H')
N = NumberOp('N')
omega = Symbol('omega')
m = Symbol('m')


def test_RaisingOp():
    assert Dagger(ad) == a
    assert Commutator(ad, a).doit() == Integer(-1)
    assert Commutator(ad, N).doit() == Integer(-1) * ad
    assert qapply(ad * k) == (sqrt(k.n + 1) * SHOKet(k.n + 1)).expand()
    assert qapply(ad * kz) == (sqrt(kz.n + 1) * SHOKet(kz.n + 1)).expand()
    assert qapply(ad * kf) == (sqrt(kf.n + 1) * SHOKet(kf.n + 1)).expand()
    assert ad().rewrite('xp').doit() == \
        (Integer(1)/sqrt(Integer(2)*hbar*m*omega))*(Integer(-1)*I*Px + m*omega*X)
Exemple #4
0
def test_SHOKet():
    assert SHOKet('k').dual_class() == SHOBra
    assert SHOBra('b').dual_class() == SHOKet
    assert InnerProduct(b, k).doit() == KroneckerDelta(k.n, b.n)
    assert k.hilbert_space == ComplexSpace(S.Infinity)
Exemple #5
0
from sympy.physics.quantum.sho1d import (
    RaisingOp,
    LoweringOp,
    SHOKet,
    SHOBra,
    Hamiltonian,
    NumberOp,
)

ad = RaisingOp("a")
a = LoweringOp("a")
k = SHOKet("k")
kz = SHOKet(0)
kf = SHOKet(1)
k3 = SHOKet(3)
b = SHOBra("b")
b3 = SHOBra(3)
H = Hamiltonian("H")
N = NumberOp("N")
omega = Symbol("omega")
m = Symbol("m")
ndim = Integer(4)

np = import_module("numpy")
scipy = import_module("scipy", import_kwargs={"fromlist": ["sparse"]})

ad_rep_sympy = represent(ad, basis=N, ndim=4, format="sympy")
a_rep = represent(a, basis=N, ndim=4, format="sympy")
N_rep = represent(N, basis=N, ndim=4, format="sympy")
H_rep = represent(H, basis=N, ndim=4, format="sympy")
k3_rep = represent(k3, basis=N, ndim=4, format="sympy")