Introduction to

QuTiP: Quantum Toolbox in Python

Robert Johansson RIKEN In collaboration with Paul Nation Korea University

Chalmers December 2012

[email protected]

1

resonator as coupling bus qubits qubit-qubit NIST 2007 NIST 2002

UCSB 2012

UCSB 2009

high level of control of resonators UCSB 2009 Yale 2011 Delft 2003

Yale 2004

qubit-resonator

Saclay 1998

Yale 2008

ETH 2010 UCSB 2006

NEC 1999 Saclay 2002

2000 Chalmers December 2012

NEC 2003

NEC 2007

2005 [email protected]

Chalmers 2008

ETH 2008

2010 2

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)



Quite large number of users (>1000 downloads)

Suitable for –

theoretical modeling and simulations



modeling experiments



100% open source



Implemented in Python/Cython using SciPy, Numpy, and matplotlib

Chalmers December 2012

[email protected]

3

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

Repository:

http://github.com/qutip

Publication:

Comp. Phys. Comm. 183, 1760 (2012) arXiv:1211.6518 (2012)

Chalmers December 2012

[email protected]

4

What is Python? Python is a modern, general-purpose, interpreted programming language Modern Good support for object-oriented and modular programming, packaging and reuse of code, and other good programming practices.

General purpose Not only for scientific use. Huge number of top-quality packages for communication, graphics, integration with operating systems and other software packages.

Interpreted No compilation, automatic memory management and garbage collection, very easy to use and program. More information: http://www.python.org

Chalmers December 2012

[email protected]

5

More information at: http://www.scipy.org

Why use Python for scientific computing? ●

Widespread use and a strong position in the computational physics community



Excellent libraries and add-on packages –

numpy

for efficient vector, matrix, multidimensional array operations



scipy

huge collection of scientific routines ode, integration, sparse matrices, special functions, linear algebra, fourier transforms, …

– ●

for generating high-quality raster and vector graphics in 2D and 3D

Great performance due to close integration with time-tested and highly optimized compiled codes –



matplotlib

blas, atlas blas, lapack, arpack, Intel MKL, …

Modern general purpose programming language with good support for –

Parallel processing, interprocess communication (MPI), ...

Chalmers December 2012

[email protected]

6

What we want to accomplish with QuTiP Objectives To provide a powerful framework for quantum mechanics that closely resembles the standard mathematical formulation –

Efficient and easy to use



General framework, able to handle a wide range of different problems

QuTiP core class: Qobj

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

Chalmers December 2012

[email protected]

7

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], type = oper, isHerm = True Qobj data = [[ 0. 1.] [ 1. 0.]]

Quantum object: dims = [[5], [1]], shape = [5, 1], type = ket Qobj data = [[ 0.88249693] [ 0.44124785] [ 0.15601245] [ 0.04496584] [ 0.01173405]]

Chalmers December 2012

[email protected]

8

Calculating using Qobj instances Basic operations

Composite systems

Basis transformations

# operator arithmetic >> H = 2 * sigmaz() + 0.5 * sigmax()

# operators >> sx = sigmax() Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[ 0. 1.] [ 1. 0.]]

# eigenstates and values for a Hamiltonian >> H = sigmax() >> evals, evecs = H.eigenstates() >> evals

Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[ 2. 0.5] [ 0.5 -2. ]] # superposition states >> psi = (basis(2,0) + basis(2,1))/sqrt(2) Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket Qobj data = [[ 0.70710678] [ 0.70710678]] # expectation values >> expect(num(2), psi) 0.4999999999999999 >> N = 25 >> psi = (coherent(N,1) + coherent(N,3)).unit() >> expect(num(N), psi) 4.761589143572134

Chalmers December 2012

>> sxsx = tensor([sx,sx]) Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ 0. 0. 0. 1.] [ 0. 0. 1. 0.] [ 0. 1. 0. 0.] [ 1. 0. 0. 0.]] # states >> psi_a = fock(2,1); psi_b = fock(2,0) >> psi = tensor([psi_a, psi_b]) Quantum object: dims = [[2, 2], [1, 1]], shape = [4, 1], type = ket Qobj data = [[ 0.] [ 1.] [ 0.] [ 0.]] >> rho_a = ptrace(psi, [0]) Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[ 1. 0.] [ 0. 0.]]

[email protected]

array([-1.,

1.])

>> evecs array([ Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket Qobj data = [[-0.70710678] [ 0.70710678]], Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket Qobj data = [[ 0.70710678] [ 0.70710678]]], dtype=object) # transform an operator to the eigenbasis of H >> sx_eb = sigmax().transform(evecs) Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[-1. 0.] [ 0. 1.]]

9

Organization

Time evolution

Quantum objects

Entropy and entanglement

Gates

Visualization States Chalmers December 2012

Operators [email protected]

10

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 system



Unitary evolution: Schrödinger and von Neumann equations

ii. Create Qobj instances for operators and states



Lindblad master equations



Monte-Carlo quantum trajectory method



Bloch-Redfield master equation

iv. Choose a solver and evolve the system



Floquet-Markov master equation

v. Post-process, visualize the data, etc.



Propagators

iii. Create Hamiltonian, initial state and collapse operators, if any

Chalmers December 2012

[email protected]

11

Lindblad master equation Equation of motion for the density matrix environment:

for a quantum system that interacts with its

How do we solve this equation numerically? I. II. III.

Construct the matrix representation of all operators Evolve the ODEs for the unknown elements in the density matrix For example, calculate expectation values for some selected operators for each

Chalmers December 2012

[email protected]

12

Lindblad master equation Equation of motion for the density matrix environment:

for a quantum system that interacts with its

How do we solve this equation numerically in QuTiP? from qutip import * psi0 = ... H = ... c_op_list = [...] e_op_list = [...]

# # # #

initial state system Hamiltonian collapse operators expectation value operators

tlist = linspace(0, 10, 100) result = mesolve(H, psi0, tlist, c_op_list, e_op_list) Chalmers December 2012

[email protected]

13

Monte-Carlo quantum trajectory method Equation of motion for a single realization of the state vector interacts with its environment:

for a quantum system that

Comparison to the Lindblad master equation (LME) I. II. III.

MC uses state vectors instead of density matrices → huge advantage for large quantum systems MC give only one stochastic realization of the state vector dynamics → need to average over many trajectories to get the ensemble average that can be compared to the density matrix. MC is faster than LME for large system, but LME is faster for small system.

Chalmers December 2012

[email protected]

14

Monte-Carlo quantum trajectory method Equation of motion for a single realization of the state vector interacts with its environment:

for a quantum system that

Comparison to the Lindblad master equation (LME) in QuTiP code: from qutip import * psi0 = ... H = ... c_list = [...] e_list = [...]

from qutip import * # # # #

initial state system Hamiltonian collapse operators expectation value operators

tlist = linspace(0, 10, 100) result = mesolve(H, psi0, tlist, c_list, e_list) Chalmers December 2012

psi0 = ... H = ... c_list = [...] e_list = [...]

# # # #

initial state system Hamiltonian collapse operators expectation value operators

tlist = linspace(0, 10, 100) result = mcsolve(H, psi0, tlist, c_list, e_list, ntraj=500) [email protected]

15

Example: Jaynes-Cummings model (a two-level atom in a cavity)

Mathematical formulation: Hamiltonian

Initial state

Time evolution

QuTiP code: from qutip import * N = 10 tensor(destroy(N),qeye(2)) Qobj tensor(qeye(N),sigmaz()) instances tensor(qeye(N),destroy(2)) wq = 1.0 * 2 * pi 0.5 * 2 * pi wc * a.dag() * a - 0.5 * wq * sz + \ 0.5 * g * (a * s.dag() + a.dag() * s) psi0 = tensor(basis(N,1), basis(2,0)) tlist = linspace(0, 10, 100) out = mesolve(H, psi0, tlist, [], [a.dag()*a]) a sz s wc g H

= = = = = =

from pylab import * plot(tlist, out.expect[0]) show()

Expectation values

Chalmers December 2012

[email protected]

16

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 # ... Chalmers December 2012

[email protected]

17

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)

Collapse operators

H = g * (tensor(sigmax(), sigmax()) + tensor(sigmay(), sigmay())) c_ops = [] # qubit 1 collapse operators sm1 = tensor(sigmam(), qeye(2)) sz1 = tensor(sigmaz(), qeye(2)) c_ops.append(sqrt(g1 * (1+n_th)) * sm1) c_ops.append(sqrt(g1 * n_th) * sm1.dag()) c_ops.append(sqrt(g2) * sz1) # qubit 2 collapse operators sm2 = tensor(qeye(2), sigmam()) sz2 = tensor(qeye(2), sigmaz()) c_ops.append(sqrt(g1 * (1+n_th)) * sm2) 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) Chalmers December 2012

[email protected]

18

Visualization ●



Objectives of visualization in quantum mechanics: –

Visualize the composition of complex quantum states (superpositions and statistical mixtures).



Distinguish between quantum and classical states. Example: Wigner function.

In QuTiP: –

Wigner and Q functions, Bloch spheres, process tomography, ...



most common visualization techniques used in quantum mechanics are implemented

Chalmers December 2012

[email protected]

19

More information at: http://qutip.googlecode.com

Summary ●





QuTiP: framework for numerical simulations of quantum systems –

Generic framework for representing quantum states and operators



Large number of dynamics solvers

Main strengths: –

Ease of use: complex quantum systems can programmed rapidly and intuitively



Flexibility: Can be used to solve a wide variety of problems



Performance: Near C-code performance due to use of Cython for time-critical functions

Future developments: –

Stochastic master equations? Non-markovian master equations?

Chalmers December 2012

[email protected]

20

QuTiP: Quantum Toolbox in Python - GitHub

Good support for object-oriented and modular programming, packaging and reuse of code, ... integration with operating systems and other software packages.

2MB Sizes 40 Downloads 356 Views

Recommend Documents

A CTF Hackers Toolbox - GitHub
Page 10 ... http://www.javadecompilers.com/. Android apps/Dalvik bytecode apktool, smali/baksmali, jadx. Xposed .NET bytecode. ILSpy, Jetbrains dotPeek ...

Annotated Algorithms in Python - GitHub
Jun 6, 2017 - 2.1.1 Python versus Java and C++ syntax . . . . . . . . 24. 2.1.2 help, dir ..... 10 years at the School of Computing of DePaul University. The lectures.

Quantum Statistical Physics - GitHub
We often call this model as a model of degenerate electron gas or a model for ..... When “t0” approaches - infinity, ˆH become ˆH0, the state vector in the ...... To study this B.S. equation, let us first introduce the total center of mass wave

Introduction to Scientific Computing in Python - GitHub
Apr 16, 2016 - 1 Introduction to scientific computing with Python ...... Support for multiple parallel back-end processes, that can run on computing clusters or cloud services .... system, file I/O, string management, network communication, and ...

Python Cryptography Toolkit - GitHub
Jun 30, 2008 - 1 Introduction. 1.1 Design Goals. The Python cryptography toolkit is intended to provide a reliable and stable base for writing Python programs that require cryptographic functions. ... If you're implementing an important system, don't

Covers Python 3 and Python 2 - GitHub
Setting a custom figure size. You can make your plot as big or small as you want. Before plotting your data, add the following code. The dpi argument is optional ...

Covers Python 3 and Python 2 - GitHub
You can add as much data as you want when making a ... chart.add('Squares', squares) .... Some built-in styles accept a custom color, then generate a theme.

〈q|pic〉: Quantum Circuit Diagrams in LATEX - GitHub
28. 5 qpic and LATEX. 28. 5.1 Include 〈q|pic〉 Diagrams as PDF Graphics in a LATEX File . ... A Python script, which we call1 qpic, parses .... Figure 3: Quantum Fourier transform on three bits: diagram and code. It is worth .... discarded. Line 9

Simulating a two dimensional particle in a square quantum ... - GitHub
5.3.12 void runCuda(cudaGraphicsResource **resource) . . . . . 17 ... the probabilities of the position and the energy of the particle at each state. ..... 2PDCurses is an alternative suggested by many http://pdcurses.sourceforge.net/. The.

Scientific python + IPython intro - GitHub
2. Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, ... written for Python 2, and it is still the most wide- ... Generate html and pdf reports.

Matrices and matrix operations in R and Python - GitHub
To calculate matrix inverses in Python you need to import the numpy.linalg .... it for relatively small subsets of variables (maybe up to 7 or 8 variables at a time).

Track memory leaks in Python - Pycon Montreal 2014 - GitHub
Track memory leaks in Python. Page 2. Python core developer since 2010 github.com/haypo/ bitbucket.org/haypo/. Working for eNovance. Victor Stinner. Page 3 ...

PyMVPA: a Python Toolbox for Multivariate Pattern ... - Springer Link
Jan 28, 2009 - Standard univariate fMRI analy- sis methods, which correlate cognitive and perceptual function with the blood oxygenation-level dependent.

Optimizations which made Python 3.6 faster than Python 3.5 - GitHub
Benchmarks rewritten using perf: new project performance ... in debug hooks. Only numy misused the API (fixed) ... The Python test suite is now used, rather than ...

Dan Dietz Greenville Django + Python Meetup - GitHub
Awaken your home: Python and the. Internet of Things. PyCon 2016. • Architecture. • Switch programming. • Automation component. Paulus Schoutsen's talk: ...

Beyond Hive – Pig and Python - GitHub
Pig performs a series of transformations to data relations based on Pig Latin statements. • Relations are loaded using schema on read semantics to project table structure at runtime. • You can run Pig Latin statements interactively in the Grunt s

Quantum Electrodynamics and Quantum Gravity in an ...
Apr 27, 2006 - Lee Glashow got their Nobel prize for a unified description of the electromagnetic and weak nuclear forces ... the electroweak theory could serve as a blueprint on how to unify different forces, no such solution ..... In general it is

Quantum Information in the Framework of Quantum ...
quantum mechanical point of view, this is a valid description of an electron with spin down or up. ... physical objects within the framework of quantum field theory.

Exploiting Locality in Quantum Computation for Quantum Chemistry
Nov 25, 2014 - where rA is the vector from a point A that defines the center of ...... approach, which we will call Hamiltonian averaging, and bound its costs in .... exponential decline in the quality of trial wave functions, as measured by overlap 

Neural Network Toolbox
[email protected] .... Simulation With Concurrent Inputs in a Dynamic Network . ... iii. Incremental Training (of Adaptive and Other Networks) . . . . 2-20.

Neural Network Toolbox
to the government's use and disclosure of the Program and Documentation, and ...... tool for industry, education and research, a tool that will help users find what .... Once there, you can download the TRANSPARENCY MASTERS with a click.

Better Stubbing in Python
Jan 22, 2007 - def testFoo(self):. # Somewhere in your unit test class old_exists = os.path.exists try: os.path.exists = lambda x: True self.assertEqual(Foo('bar'), something) os.path.exists = lambda x: False self.assertEqual(Foo('bar'), something_el

Concepts in Crypto - GitHub
to check your email. ○. Enigmail: Thunderbird addon that adds OpenPGP ... you its certificate, which includes its public key ... iOS, Android: ChatSecure ...