Exemple #1
0
 def __init__(self, dm, pos):
     self.dm = dm
     self.pos = pos
     self.n = dm.shape[0]
     X = qt.position(self.n)
     L, V = X.eigenstates()
     self.projectors = [v * v.dag() for v in V]
     probs = [(self.dm * p).tr().real for p in self.projectors]
     spaced = L / max(L)
     self.vpts = [vp.sphere(pos=self.pos+vp.vector(spaced[i], 0, 0),\
             radius=0.5*probs[i],#0.7/self.n,\
             opacity=probs[i])\
         for i in range(self.n)]
     self.vexp = vp.sphere(pos=self.pos+vp.vector(qt.expect(X, dm).real/max(L),0,0),\
            radius=0.1, color=vp.color.yellow, opacity=0.9)
Exemple #2
0
 def __init__(self, dm, pos):
     self.dm = dm.copy()
     self.pos = pos
     self.n = dm.shape[0]
     self.osc_n = int(np.sqrt(self.n))
     self.dm.dims = [[self.osc_n, self.osc_n], [self.osc_n, self.osc_n]]
     X = qt.position(self.osc_n)
     L, V = X.eigenstates()
     self.projectors = [
         [qt.tensor(v1 * v1.dag(), v2 * v2.dag()) for v2 in V] for v1 in V
     ]
     probs = [[(self.dm * p).tr().real for p in row]
              for row in self.projectors]
     spaced = L / max(L)
     self.vpts = [[vp.sphere(pos=self.pos+vp.vector(spaced[i], spaced[j], 0),\
              radius=0.5*probs[i][j],#0.7/self.n,\
              opacity=probs[i][j])\
         for j in range(self.osc_n)]
          for i in range(self.osc_n)]
     self.vexp = vp.sphere(pos=self.pos+vp.vector(qt.expect(qt.tensor(X, qt.identity(self.osc_n)), self.dm).real/max(L),\
                 qt.expect(qt.tensor(qt.identity(self.osc_n), X), self.dm).real/max(L),\
                     0),\
            radius=0.1, color=vp.color.yellow, opacity=0.9)
Exemple #3
0
# -*- coding: utf-8 -*-
"""
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):
Exemple #4
0
def test_position_type():
    "Operator CSR Type: position"
    op = position(5)
    assert_equal(isspmatrix_csr(op.data), True)
Exemple #5
0
def test_commutator_type():
    "Operator CSR Type: commutator"
    op = commutator(position(5), momentum(5))
    assert_equal(isspmatrix_csr(op.data), True)
def test_position_type():
    "Operator CSR Type: position"
    op = position(5)
    assert_equal(isspmatrix_csr(op.data), True)
def test_commutator_type():
    "Operator CSR Type: commutator"
    op = commutator(position(5), momentum(5))
    assert_equal(isspmatrix_csr(op.data), True)
Exemple #8
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)
Exemple #9
0
####################################################################################

state = qt.basis(n * n, 0)  #qt.rand_ket(n*n)
state.dims = [[n, n], [1, 1]]

spin = qt.rand_ket(4)
state = upgrade_state(spin, a) * state

H = N + 1  #X#qt.rand_herm(n*n)
H.dims = [[n, n], [n, n]]
U = (-1j * H * dt).expm()

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

Q = [qt.tensor(qt.position(n), qt.identity(n)),\
     qt.tensor(qt.identity(n), qt.position(n))]
Q_ = qt.position(n)
QL, QV = Q_.eigenstates()
Qstates = [[qt.tensor(QV[i], QV[j]) for j in range(n)] for i in range(n)]
Qprojs = [[Qstates[i][j] * Qstates[i][j].dag() for j in range(n)]
          for i in range(n)]

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

vorig_sph = vp.sphere(pos=vp.vector(0, 5, 0), color=vp.color.red, opacity=0.5)
voring_stars = [vp.sphere(pos=vorig_sph.pos + vp.vector(*xyz), radius=0.2, emissive=True)\
                    for xyz in spin_XYZ(spin)]

print(spin_XYZ(spin))
import qutip as qt
import numpy as np
import vpython as vp
vp.scene.width = 1000
vp.scene.height = 800

dt = 0.001
n = 101
a = qt.destroy(n)
Q = qt.position(n)
QL, QV = Q.eigenstates()
N = qt.num(n)
NL, NV = N.eigenstates()
H = N + 1 / 2
U = (-1j * dt * H).expm()

state = qt.basis(n, 0)
amps = [state.overlap(v) for v in QV]
vamps = [vp.arrow(pos=vp.vector(QL[i], 0, 0),\
       axis=vp.vector(amps[i].real, amps[i].imag, 0)) for i in range(n)]
vprobs = [vp.sphere(radius=0.1, color=vp.color.red,\
        pos=vp.vector(QL[i], 1+3*(amps[i]*np.conjugate(amps[i])).real, 0))\
      for i in range(n)]
vexp = vp.sphere(color=vp.color.yellow, radius=0.3,\
     pos=vp.vector(qt.expect(Q, state), 0, 0))


def coherent(s):
    global n, a
    return np.exp(-s * np.conjugate(s) / 2) * (s * a.dag()).expm() * (
        -np.conjugate(s) * a).expm() * qt.basis(n, 0)
Exemple #11
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)])
Exemple #12
0
 def _phi_lc(self):
     """Phase operator in the LC basis."""
     return (8 * self.E_C / self.E_L)**(0.25) * qt.position(self.nlev_lc)
Exemple #13
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)
Exemple #14
0
def test_position():
    operator = qutip.position(N)
    expected = (np.diag((np.arange(1, N) / 2)**0.5, k=-1) + np.diag(
        (np.arange(1, N) / 2)**0.5, k=1))
    np.testing.assert_allclose(operator.full(), expected)
 def _x_ops(self, kappa, alpha, p):
     return self._ops(kappa, alpha, p, op=qutip.position(self._nfock))