LoginSignup
5
3

More than 5 years have passed since last update.

WindowsでQuTiPを使う

Last updated at Posted at 2016-07-18

WindowsでQuTiPを使うためのTips

QuTiPとは

  • 量子状態をシミュレート、量子トモグラフィーなどに特化したpython用パッケージ
  • Python2.7+で動く。

qutip.orgより引用

QuTiP is open-source software for simulating the dynamics of open quantum systems. The QuTiP library depends on the excellent Numpy, Scipy, and Cython numerical packages. In addition, graphical output is provided by Matplotlib. QuTiP aims to provide user-friendly and efficient numerical simulations of a wide variety of Hamiltonians, including those with arbitrary time-dependence, commonly found in a wide range of physics applications such as quantum optics, trapped ions, superconducting circuits, and quantum nanomechanical resonators. QuTiP is freely available for use and/or modification on all major platforms such as Linux, Mac OSX, and Windows*. Being free of any licensing fees, QuTiP is ideal for exploring quantum mechanics and dynamics in the classroom.

QuTiPはオープン量子系のダイナミクスをシミュレートするためのオープンソースソフトウェアです。QuTiPライブラリーは、優れた数値計算ライブラリであるNumpy, Scipy, Cythonに依存しています。また、描画出力はMatplotlibにより提供されます。QuTiPは、量子光学、イオントラップ、超電導回路、量子名の共振器といった物理応用の広範囲によくみられる、任意の時間依存を含む多種多様なハミルトニアンを使いやすく効率的に数値シミュレーションを提供すること目的としている。QuTiPは、Linux、Mac OS X、Windows*など、すべての主要なプラットフォーム上での使用および/​​または変更に対して自由に利用可能です。任意のライセンス料を含まないQuTiPは、講義などにおいて量子力学とダイナミクスを探索するのに理想的です。

Anacondaのインストール

  • python3を使おうとしたが、うまくいかないのでpython2を使う必要がある
  • 理由: condaでサポートしているQuTiPのバージョンはpython2のみ

QuTiPのインストール

  • Anaconda Promptを開き以下のコマンドでQuTiPをインストールするための情報を得る
$ anaconda search -t conda qutip
$ conda install -c https://conda.anaconda.org/ajgpitch qutip

mayaviのインストール

  • Bloch3d()を使うために必要
$ conda install -c https://conda.anaconda.org/menpo mayavi

PyCharmのインストール

  • IPythonを使えば、プロンプト上で計算を行うことも可能だが、毎回関数を定義するのは面倒。
  • scriptを書いて実行するためのIDEとしてPyCharmがおすすめ。
  • 学生なら無料で使えるので、学生の方にもおすすめ。

さいごに

  • サンプルコード
from mayavi import mlab
import numpy as np
from qutip import *
import matplotlib.pyplot as plt

mlab.test_contour3d()
b = Bloch()
b3d = Bloch3d()
vec = [0, 1, 0]
pnt = [1/np.sqrt(3), 1/np.sqrt(3), 1/np.sqrt(3)]
up = basis(2, 0)
b.add_vectors(vec)
b.add_points(pnt)
b.add_states(up)
b.show()

# state generation
N = 20
rho_coherent = coherent_dm(N, np.sqrt(2))
rho_thermal = thermal_dm(N, 2)
rho_fock = fock_dm(N, 2)
xvec = np.linspace(-5,5,200)
W_coherent = wigner(rho_coherent, xvec, xvec)
W_thermal = wigner(rho_thermal, xvec, xvec)
W_fock = wigner(rho_fock, xvec, xvec)

# fig config
fig, axes = plt.subplots(1, 3, figsize=(12, 3))
cont0 = axes[0].contourf(xvec, xvec, W_coherent, 100)
lbl0 = axes[0].set_title("Coherent state")
cont1 = axes[1].contourf(xvec, xvec, W_thermal, 100)
lbl1 = axes[1].set_title("Thermal state")
cont2 = axes[2].contourf(xvec, xvec, W_fock, 100)
lbl2 = axes[2].set_title("Fock state")
plt.show()

無事プロットできました:sushi:
figure_1.png

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3