Esempio n. 1
0
def test_momentum_type():
    "Operator CSR Type: momentum"
    op = momentum(5)
    assert_equal(isspmatrix_csr(op.data), True)
Esempio n. 2
0
"""
Created on Tue Apr 24 17:22:47 2018

@author: andre
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import qutip as qt

N = 20
n = 5
a = qt.destroy(N)
x = qt.position(N)
p = qt.momentum(N)
H = a.dag() * a
psi0 = qt.coherent(N, n**0.5)
#psi0=qt.fock(N,n)
time = np.linspace(0, 100, 1000)
sol = qt.mesolve(H, psi0, time, [], [])

fig, ax = plt.subplots(2, 1)
xvec = np.linspace(-10, 10, 100)
#ax.plot(qt.expect(x,sol.states),qt.expect(p,sol.states))
line, = ax[1].plot([0], [qt.expect(H, psi0)])
im = ax[0].imshow(qt.wigner(psi0, xvec, xvec))


def updatefig(i):
    psi = sol.states[i]
Esempio n. 3
0
def test_momentum_type():
    "Operator CSR Type: momentum"
    op = momentum(5)
    assert_equal(isspmatrix_csr(op.data), True)
Esempio n. 4
0
def test_commutator_type():
    "Operator CSR Type: commutator"
    op = commutator(position(5), momentum(5))
    assert_equal(isspmatrix_csr(op.data), True)
Esempio n. 5
0
V_q = V
V_p = V

MaxN = 30

NFock = 200

Stabilizer_q = qt.displace(NFock, 1j * np.sqrt(2 * np.pi))
Stabilizer_p = qt.displace(NFock, np.sqrt(2 * np.pi))
Z = qt.displace(NFock, 1j * np.sqrt(np.pi / 2))
X = qt.displace(NFock, np.sqrt(np.pi / 2))

a = qt.destroy(NFock)
a_dag = a.dag()

H_free = E / 2 * (qt.position(NFock)**2 + qt.momentum(NFock)**2)
H_K = K * qt.num(NFock)**2
H_Cass = K * (a**4 - offset**4).dag() * (a**4 - offset**4
                                         )  #+K*np.abs(offset)**2

H_stab = -V_q * (2 * np.sqrt(np.pi) * qt.position(NFock)).cosm() - V_p * (
    2 * np.sqrt(np.pi) * qt.momentum(NFock)).cosm()


def g_0n(D, Num_max, NFock):
    """
    returns a D-squeezed 0-ancilla
    """

    r = np.log(1 / D)
    psi0 = qt.squeeze(NFock, r) * qt.basis(NFock, 0)
Esempio n. 6
0
def test_commutator_type():
    "Operator CSR Type: commutator"
    op = commutator(position(5), momentum(5))
    assert_equal(isspmatrix_csr(op.data), True)
Esempio n. 7
0
##############################################################################

n_pos = 6
n_max = 2
d = (n_max**n_pos)**2
n_osc = 2 * n_pos

##############################################################################

a = [qt.tensor([qt.destroy(n_max) if i == j else qt.identity(n_max)\
        for j in range(n_osc)])\
         for i in range(n_osc)]

Q = qt.position(n_pos)
QL, QV = Q.eigenstates()
P = qt.momentum(n_pos)
PL, PV = P.eigenstates()

Z = qt.sigmaz()
ZL, ZV = Z.eigenstates()

##############################################################################


def a_pos(x, m):
    global a, Q, QL, QV, P, PL, PV
    B = qt.tensor(QV[list(QL).index(x)], ZV[list(ZL).index(m)]).full().T[0]
    return sum([c * a[i] for i, c in enumerate(B)])


def a_mo(p, m):
Esempio n. 8
0
 def _n_lc(self):
     """Charge operator in the LC basis."""
     return (self.E_L / (8 * self.E_C))**(0.25) * qt.momentum(self.nlev_lc)
Esempio n. 9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May  1 13:16:47 2018

@author: andre
"""

import numpy as np
import matplotlib.pyplot as plt
import qutip as qt
import matplotlib.animation as animation

N = 2
ket0 = qt.fock(N, 0)
ket1 = qt.fock(N, 1)

time = np.linspace(0, 100, 1000)
sol = qt.mcsolve(H, psi0, time, [a * 0.25, a.dag() * 0.1],
                 [H, qt.position(N), qt.momentum(N)], 1)
Esempio n. 10
0
def test_momentum():
    operator = qutip.momentum(N)
    expected = (np.diag((np.arange(1, N) / 2)**0.5, k=-1) - np.diag(
        (np.arange(1, N) / 2)**0.5, k=1)) * 1j
    np.testing.assert_allclose(operator.full(), expected)
 def _p_ops(self, kappa, alpha, p):
     return self._ops(kappa, alpha, p, op=qutip.momentum(self._nfock))