8. ALPS チュートリアル: Introduction to ALPS Python
Running simulation
Running simulation on serial machine
>>> pyalps.runApplication('spinmc',
input_file,Tmin=5,writexml=True)
spinmc parm1.in.xml --Tmin 5 --write-xml
Generic classical Monte Carlo program using local or cluster
updates
...
Checkpointing Simulation 3
Finished with everything.
(0, 'parm1.out.xml')
実行が終了するとparm1.out.xml, parm1.task1.out.h5, と
いったファイルが出力されています.
7 / 15
16. ALPS チュートリアル: Introduction to ALPS Python
Plotting results
Plotting in Python using matplotlib
pyalps.plot.plot(plotdata) # データをプロット.
[matplotlib.lines.Line2D at 0x109425dd0]
plt.xlim(0,3) # x 軸の範囲を設定
plt.ylim(0,1) # y 軸の範囲を設定
plt.title('Ising model') # 図のタイトル
plt.savefig('ising.pdf') # ファイルへ出力
plt.show() # X11 などで画面に表示
1.0
0.8
0.6
0.4
0.2
0.0 0.5 1.0 1.5 2.0 2.5 3.0
T
0.0
|Magnetization|
Ising model
13 / 15
17. ALPS チュートリアル: Introduction to ALPS Python
Plotting results
Converting to other formats
ほかのデータフォーマットに変換できます
print pyalps.plot.convertToText(plotdata)
print pyalps.plot.makeGnuplotPlot(plotdata)
print pyalps.plot.makeGracePlot(plotdata)
text 形式の出力例
#
# X: T
# Y: |Magnetization|
1.5 0.986496240665 +/- 2.82049446481e-05
2.0 0.912126100521 +/- 0.000350201474667
2.5 0.603552651599 +/- 0.00146115425377
14 / 15
18. ALPS チュートリアル: Introduction to ALPS Python
Evaluating data
Example of evaluating data
binder 比 m2 = jmj 2 の計算をしてみます
binder = pyalps.DataSet()
binder.props = pyalps.dict_intersect([d[0].props for d in
data])
binder.x = [d[0].props['T'] for d in data]
binder.y = [d[1].y[0]/(d[0].y[0]*d[0].y[0]) for d in data]
print binder
空のデータセットを作ります
複数の辞書からkey:val ともに一致する項目を抜き出す
データからx 軸となる'T' の数列をとりだす.
d[0] からm2, d[1] からjmj を取り出してbinder 比を計算
15 / 15