def spin_coherent(j, theta, phi, type='ket'): r"""Generate the coherent spin state :math:`\lvert \theta, \phi\rangle`. Parameters ---------- j : float The spin of the state. theta : float Angle from z axis. phi : float Angle from x axis. type : string {'ket', 'bra', 'dm'} Type of state to generate. Returns ------- state : qobj Qobj quantum object for spin coherent state """ Sp = jmat(j, '+') Sm = jmat(j, '-') psi = (0.5 * theta * np.exp(1j * phi) * Sm - 0.5 * theta * np.exp(-1j * phi) * Sp).expm() * spin_state(j, j) if type == 'ket': return psi elif type == 'bra': return psi.dag() elif type == 'dm': return ket2dm(psi) else: raise ValueError("invalid value keyword argument 'type'")
def rand_super(dim=5): H = rand_herm(dim) return propagator( H, np.random.rand(), [create(dim), destroy(dim), jmat(float(dim - 1) / 2.0, 'z')])
def rand_super(N=5, dims=None): """ Returns a randomly drawn superoperator acting on operators acting on N dimensions. Parameters ---------- N : int Square root of the dimension of the superoperator to be returned. dims : list Dimensions of quantum object. Used for specifying tensor structure. Default is dims=[[[N],[N]], [[N],[N]]]. """ if dims is not None: # TODO: check! pass else: dims = [[[N], [N]], [[N], [N]]] H = rand_herm(N) S = propagator( H, np.random.rand(), [create(N), destroy(N), jmat(float(N - 1) / 2.0, 'z')]) S.dims = dims return S
def stochastic_noise_Yue(rho, t, normalization, hbar, gamma): temp = jmat(1) sum = 0 for i in range(0, 3): j = temp[i].full() sum += commutator(j, commutator(j, rho)) return -gamma / 2 * sum
def test_SuperChoiSuper(self): """ Superoperator: Converting superoperator to Choi matrix and back. """ h_5 = rand_herm(5) superoperator = propagator(h_5, scipy.rand(), [create(5), destroy(5), jmat(2, 'z')]) choi_matrix = super_to_choi(superoperator) test_supe = choi_to_super(choi_matrix) assert_((test_supe - superoperator).norm() < 1e-12)
def test_ChoiKrausChoi(self): """ Superoperator: Converting superoperator to Choi matrix and back. """ h_5 = rand_herm(5) superoperator = propagator(h_5, scipy.rand(), [create(5), destroy(5), jmat(2, 'z')]) choi_matrix = super_to_choi(superoperator) kraus_ops = choi_to_kraus(choi_matrix) test_choi = kraus_to_choi(kraus_ops) assert_((test_choi - choi_matrix).norm() < 1e-12)
def test_SuperChoiSuper(self): """ Superoperator: Converting superoperator to Choi matrix and back. """ h_5 = rand_herm(5) superoperator = propagator( h_5, scipy.rand(), [create(5), destroy(5), jmat(2, 'z')]) choi_matrix = super_to_choi(superoperator) test_supe = choi_to_super(choi_matrix) assert_((test_supe - superoperator).norm() < 1e-12)
def test_ChoiKrausChoi(self): """ Superoperator: Converting superoperator to Choi matrix and back. """ h_5 = rand_herm(5) superoperator = propagator( h_5, scipy.rand(), [create(5), destroy(5), jmat(2, 'z')]) choi_matrix = super_to_choi(superoperator) kraus_ops = choi_to_kraus(choi_matrix) test_choi = kraus_to_choi(kraus_ops) assert_((test_choi - choi_matrix).norm() < 1e-12)
def spin_coherent(j, theta, phi, type='ket'): """Generates the spin state |j, m>, i.e. the eigenstate of the spin-j Sz operator with eigenvalue m. Parameters ---------- j : float The spin of the state. theta : float Angle from z axis. phi : float Angle from x axis. type : string {'ket', 'bra', 'dm'} Type of state to generate. Returns ------- state : qobj Qobj quantum object for spin coherent state """ Sp = jmat(j, '+') Sm = jmat(j, '-') psi = (0.5 * theta * np.exp(1j * phi) * Sm - 0.5 * theta * np.exp(-1j * phi) * Sp).expm() * spin_state(j, j) if type == 'ket': return psi elif type == 'bra': return psi.dag() elif type == 'dm': return ket2dm(psi) else: raise ValueError("invalid value keyword argument 'type'")
def _init_operators(self): # lc resonator creation operator self.Aplus = tensor(create(self.nmax), qeye(self.fock_space_size)) # annihilation operators self.Aminus = tensor(destroy(self.nmax), qeye(self.fock_space_size)) self.sigmax = operators.jmat((self.fock_space_size - 1) / 2, 'x') * 2 self.sigmaz = operators.jmat((self.fock_space_size - 1) / 2, 'z') * 2 self.sigmap = operators.jmat((self.fock_space_size - 1) / 2, '+') self.sigmam = operators.jmat((self.fock_space_size - 1) / 2, '-') # pauli sigma matrix at x direction self.SigmaX = tensor(qeye(self.nmax), self.sigmax) # pauli sigma matrix at z direction self.SigmaZ = tensor(qeye(self.nmax), self.sigmaz) # creation operator self.SigmaP = tensor(qeye(self.nmax), self.sigmap) # annihilation operator self.SigmaN = tensor(qeye(self.nmax), self.sigmam) # particle number operator self.SigmaPopulation = tensor(qeye(self.nmax), self.sigmap * self.sigmam) self.Qeye = self.SigmaN = tensor(qeye(self.nmax), qeye(self.fock_space_size))
def rand_super(N=5, dims=None): """ Returns a randomly drawn superoperator acting on operators acting on N dimensions. Parameters ---------- N : int Square root of the dimension of the superoperator to be returned. dims : list Dimensions of quantum object. Used for specifying tensor structure. Default is dims=[[[N],[N]], [[N],[N]]]. """ if dims is not None: # TODO: check! pass else: dims = [[[N], [N]], [[N], [N]]] H = rand_herm(N) S = propagator(H, np.random.rand(), [create(N), destroy(N), jmat(float(N - 1) / 2.0, "z")]) S.dims = dims return S
def rand_super(self): h_5 = rand_herm(5) return propagator( h_5, scipy.rand(), [create(5), destroy(5), jmat(2, 'z')])
def _rotation_matrix(theta, phi, j): """Private function to calculate the rotation operator for the SU2 kernel. """ return la.expm(1j * phi * jmat(j, 'z').full()) @ \ la.expm(1j * theta * jmat(j, 'y').full())
def rand_super(): h_5 = rand_herm(5) return propagator(h_5, scipy.rand(), [ create(5), destroy(5), jmat(2, 'z') ])
def rand_super(dim=5): H = rand_herm(dim) return propagator(H, np.random.rand(), [ create(dim), destroy(dim), jmat(float(dim - 1) / 2.0, 'z') ])