
QuTiP: Quantum Toolbox in Python Robert Johansson [email protected] RIKEN Paul Nation [email protected] RIKEN / Korea University SciPy 2012 Robert Johansson and Paul Nation 1 What is QuTiP? ● Framework for computational quantum dynamics – Efficient and easy to use for quantum physicists – Thoroughly tested (100+ unit tests) – Well documented (200+ pages, 50+ examples) ● Suitable for – theoretical work – modeling experiments on engineered quantum systems ● 100% open source ● Implemented in Python/Cython using SciPy, Numpy, and matplotlib SciPy 2012 Robert Johansson and Paul Nation 2 Project information Authors: Paul Nation and Robert Johansson Web site: http://qutip.googlecode.com Discussion: Google group “qutip” Blog: http://qutip.blogspot.com Platforms: Linux and Mac License: GPLv3 Download: http://code.google.com/p/qutip/downloads SVN Repository: https://qutip.googlecode.com/svn/ Publication: Comp. Phys. Comm. 183, 1760 (2012) SciPy 2012 Robert Johansson and Paul Nation 3 What can QuTiP be used for? Simulate engineered quantum devices Superconducting circuits Semiconducting circuits Nanomechanical devices Ion traps Monroe group at Maryland Martinis group at UCSB Petta group at at Princeton Roukes group at Caltech SciPy 2012 Robert Johansson and Paul Nation 4 Quantum mechanics in one slide … … not as difficult as one might think: It's only linear algebra ! Key concepts Practical representation Wavefunction / state: Vectors or matrices: Probability amplitude describing the state of a Complex elements, unitary norm/trace. quantum system. Hamiltonian / operators: Matrices: The Hamiltonian is the total energy function of a Hermitian, complex elements, usually sparse. system, describes the energies of the possible states. Operators represents physical observables, and are used to construct Hamiltonians. Equation of motion: Ordinary differential equations (ODEs) Describes how the states of a system evolve in time Systems of coupled ODEs in matrix form. In general for a given Hamiltonian. Examples: Schrödinger time-dependent. Sometimes including stochastic equation, Master equations and Monte-Carlo. processes. Observables and expectation values: Inner product Observable physical quantities correspond to Measurement outcomes are calculated as inner product operators. Measurement outcomes are “stochastic”, between state vectors and operator matrices, resulting expectation values calculated using the wavefunction. in a real number for physical observables. SciPy 2012 Robert Johansson and Paul Nation 5 What we want to accomplish with QuTiP Objectives To provide a powerful framework for quantum mechanics that QuTiP core class: Qobj closely resembles the standard mathematical formulation – Efficient and easy to use – General framework, able to handle a wide range of different problems Design and implementation – Object-oriented design – Qobj class used to represent quantum objects ● Operators ● State vectors ● Density matrices – Library of utility functions that operate on Qobj instances SciPy 2012 Robert Johansson and Paul Nation 6 Quantum object class: Qobj Abstract representation of quantum states and operators – Matrix representation of the object – Structure of the underlaying state space, Hermiticity, type, etc. – Methods for performing all common operations on quantum objects: eigs(),dag(),norm(),unit(),expm(),sqrt(),tr(), ... – Operator arithmetic with implementations of: +. -, *, ... Example: built-in operator Example: built-in state >>> sigmax() >>> coherent(5, 0.5) Quantum object: dims = [[2], [2]], shape = [2, 2], Quantum object: dims = [[5], [1]], shape = [5, 1], type = ket type = oper, isHerm = True Qobj data = Qobj data = [[ 0.88249693] [[ 0. 1.] [ 0.44124785] [ 1. 0.]] [ 0.15601245] [ 0.04496584] [ 0.01173405]] SciPy 2012 Robert Johansson and Paul Nation 7 Calculating using Qobj instances Basic operations Composite systems Basis transformations # operator arithmetic # operators # eigenstates and values for a Hamiltonian >> H = 2 * sigmaz() + 0.5 * sigmax() >> sx = sigmax() >> H = sigmax() Quantum object: dims = [[2], [2]], >> evals, evecs = H.eigenstates() Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True >> evals shape = [2, 2], type = oper, isHerm = True Qobj data = Qobj data = [[ 0. 1.] array([-1., 1.]) [[ 2. 0.5] [ 1. 0.]] [ 0.5 -2. ]] >> evecs >> sxsx = tensor([sx,sx]) # superposition states Quantum object: dims = [[2, 2], [2, 2]], array([ >> psi = (basis(2,0) + basis(2,1))/sqrt(2) shape = [4, 4], type = oper, isHerm = True Quantum object: dims = [[2], [1]], Qobj data = shape = [2, 1], type = ket Quantum object: dims = [[2], [1]], [[ 0. 0. 0. 1.] Qobj data = shape = [2, 1], type = ket [ 0. 0. 1. 0.] [[-0.70710678] Qobj data = [ 0. 1. 0. 0.] [ 0.70710678]], [[ 0.70710678] [ 1. 0. 0. 0.]] Quantum object: dims = [[2], [1]], [ 0.70710678]] shape = [2, 1], type = ket # states Qobj data = >> psi_a = fock(2,1); psi_b = fock(2,0) [[ 0.70710678] # expectation values >> psi = tensor([psi_a, psi_b]) [ 0.70710678]]], dtype=object) >> expect(num(2), psi) Quantum object: dims = [[2, 2], [1, 1]], shape = [4, 1], type = ket # transform an operator to the eigenbasis of H 0.4999999999999999 Qobj data = >> sx_eb = sigmax().transform(evecs) [[ 0.] >> N = 25 [ 1.] Quantum object: dims = [[2], [2]], >> psi = (coherent(N,1) + coherent(N,3)).unit() [ 0.] shape = [2, 2], type = oper, isHerm = True >> expect(num(N), psi) [ 0.]] Qobj data = [[-1. 0.] 4.761589143572134 >> rho_a = ptrace(psi, [0]) [ 0. 1.]] Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[ 1. 0.] [ 0. 0.]] SciPy 2012 Robert Johansson and Paul Nation 8 Organization ● States ● Operators ● Time evolution ● Visualization ● Gates ● Core/Utility functions SciPy 2012 Robert Johansson and Paul Nation 9 Evolution of quantum systems The main use of QuTiP is quantum evolution. A number of solvers are available. Typical simulation workflow: Available evolution solvers: i. Define parameters that characterize the – Unitary evolution: Schrödinger and von system Neumann equations ii. Create Qobj instances for operators and – Lindblad master equations states – Monte-Carlo quantum trajectory method iii. Create Hamiltonian, initial state and collapse operators, if any – Bloch-Redfield master equation iv. Choose a solver and evolve the system – Floquet-Markov master equation v. Post-process, visualize the data, etc. – Propagators SciPy 2012 Robert Johansson and Paul Nation 10 Example: Jaynes-Cummings model (a two-level atom in a cavity) Mathematical formulation: QuTiP code: from qutip import * Hamiltonian N = 10 a = tensor(destroy(N),qeye(2)) Qobj sz = tensor(qeye(N),sigmaz()) instances s = tensor(qeye(N),destroy(2)) wc = wq = 1.0 * 2 * pi Initial state g = 0.5 * 2 * pi H = wc * a.dag() * a - 0.5 * wq * sz + \ 0.5 * g * (a * s.dag() + a.dag() * s) psi0 = tensor(basis(N,0), basis(2,0)) tlist = linspace(0, 10, 100) Time evolution out = mesolve(H, psi0, tlist, [], [a.dag()*a]) from pylab import * plot(tlist, out.expect[0]) show() Expectation values SciPy 2012 Robert Johansson and Paul Nation 11 Example: time-dependence Multiple Landau-Zener transitions from qutip import * # Parameters epsilon = 0.0 delta = 1.0 # Initial state: start in ground state psi0 = basis(2,0) # Hamiltonian H0 = - delta * sigmaz() - epsilon * sigmax() H1 = - sigmaz() h_t = [H0, [H1, 'A * cos(w*t)']] args = {'A': 10.017, 'w': 0.025*2*pi} # No dissipation c_ops = [] # Expectation values e_ops = [sigmax(), sigmay(), sigmaz()] # Evolve the system tlist = linspace(0, 160, 500) output = mesolve(h_t, psi0, tlist, c_ops, e_ops, args) # Process and plot result # ... SciPy 2012 Robert Johansson and Paul Nation 12 Example: open quantum system Dissipative two-qubit iSWAP gate from qutip import * g = 1.0 * 2 * pi # coupling strength g1 = 0.75 # relaxation rate g2 = 0.25 # dephasing rate n_th = 1.5 # environment temperature T = pi/(4*g) H = g * (tensor(sigmax(), sigmax()) + tensor(sigmay(), sigmay())) c_ops = [] # qubit 1 collapse operators s r sm1 = tensor(sigmam(), qeye(2)) o t sz1 = tensor(sigmaz(), qeye(2)) a r c_ops.append(sqrt(g1 * (1+n_th)) * sm1) e p c_ops.append(sqrt(g1 * n_th) * sm1.dag()) o c_ops.append(sqrt(g2) * sz1) e s # qubit 2 collapse operators p sm2 = tensor(qeye(2), sigmam()) a l l sz2 = tensor(qeye(2), sigmaz()) o c_ops.append(sqrt(g1 * (1+n_th)) * sm2) C c_ops.append(sqrt(g1 * n_th) * sm2.dag()) c_ops.append(sqrt(g2) * sz2) U = propagator(H, T, c_ops) qpt_plot(qpt(U, op_basis), op_labels) SciPy 2012 Robert Johansson and Paul Nation 13 from qutip import * Advanced example def system_ops(N, h, J, gamma): # pre-compute operators ● 21 spin-½ with nearest-neighbor interaction si = qeye(2); sx = sigmax(); sz = sigmaz() sx_list = []; sz_list = [] ● ~40 lines of code for n in range(N): ● op_list = [si for m in range(N)] 2’097’152 basis states op_list[n] = sx ● simulation time: ~7 hours sx_list.append(tensor(op_list)) op_list[n] = sz sz_list.append(tensor(op_list)) # construct the hamiltonian H = 0 for n in range(N): # energy splitting terms H += - 0.5 * h[n] * sz_list[n] for n in range(N-1): # interaction terms H += - 0.5 * J[n] * sx_list[n] * sx_list[n+1] # collapse operators for spin dephasing c_op_list = [] for n in range(N): if gamma[n] > 0.0: c_op_list.append(sqrt(gamma[n]) * sz_list[n]) # initial state # first and last spin in state |1>, rest in state |0> psi_list = [basis(2,0) for n in range(N-2)] psi_list.insert(0, basis(2,1)) # first psi_list.append(basis(2,1)) # last psi0 = tensor(psi_list) return H, c_op_list, sz_list, psi0 N = 21 # number of
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages20 Page
-
File Size-