PyPI version PyPI version

ドキュメント

CrySPY(クリスピー)は機械学習を利用したPython製の結晶構造探索ツールであり,クリスピーと読む. 難しい操作を必要とせず,入力ファイルを準備するだけで以下の事が自動で行える.

  • 構造生成
  • 構造最適化のジョブの実行
  • 構造最適化データの収集
  • 機械学習による候補の選択

最新バージョン

CrySPY 1.2.5 (2024年5月10日)

ニュース

Discussions

Discussions in GitHub (質問やコメント)

ライセンス

CrySPY is distributed under the MIT License
Copyright (c) 2018 CrySPY Development Team

コード開発貢献者

  • 山下 智樹および研究室メンバー (長岡技術科学大学)
  • 佐藤 暢哉 (産業技術総合研究所)
  • 木野 日織 (物質・材料研究機構)
  • 寺山 慧 (横浜市立大学)
  • 澤端 日華瑠 (金沢大学)
  • 兼平 慎一 (大阪大学)

関連文献

  • CrySPY(ソフトウェア)

    • T. Yamashita, S. Kanehira, N. Sato, H. Kino, H. Sawahata, T. Sato, F. Utsuno, K. Tsuda, T. Miyake, and T. Oguchi,
      “CrySPY: a crystal structure prediction tool accelerated by machine learning”,
      Sci. Technol. Adv. Mater. Meth. 1, 87 (2021). Link
  • ベイズ最適化

    • T. Yamashita, N. Sato, H. Kino, T. Miyake, K. Tsuda, and T. Oguchi,
      “Crystal structure prediction accelerated by Bayesian optimization”,
      Phys. Rev. Mater. 2, 013803 (2018). Link
    • N. Sato, T. Yamashita, T. Oguchi, K. Hukushima, and T. Miyake,
      “Adjusting the descriptor for a crystal structure search using Bayesian optimization”,
      Phys. Rev. Mater. 4, 033801 (2020). Link
  • ベイズ最適化と進化的アルゴリズム

    • T. Yamashita, H. Kino, K. Tsuda, T. Miyake, and T. Oguchi,
      “Hybrid algorithm of Bayesian optimization and evolutionary algorithm in crystal structure prediction”,
      Sci. Technol. Adv. Mater. Meth. 2, 67 (2022). Link
  • LAQA

    • K.Terayama, T. Yamashita, T. Oguchi, and K. Tsuda,
      Fine-grained optimization method for crystal structure prediction",
      npj Comput. Mater. 4, 32 (2018). Link
    • T. Yamashita and H. Sekine,
      “Improvement of look ahead based on quadratic approximation for crystal structure prediction”,
      Sci. Technol. Adv. Mater. Meth. 2, 84 (2022). Link

GitHub repo GitHub discussions CrySPY utility

のサブセクション

CrySPYについてのサブセクション

結晶構造探索

fig_csp fig_csp

Input

  • 元素
  • 原子数

Output

  • 最安定構造(グローバルミニマム)

探索アルゴリズム

CrySPYでは以下の探索アルゴリズムが使用可能.

  • ランダムサーチ (RS)
  • 進化的アルゴリズム (EA)
  • ベイズ最適化 (BO)
  • LAQA

概略

ランダムサーチ (RS)

ランダム.

進化的アルゴリズム (EA)

進化的アルゴリズムを用いた結晶構造探索手法はOganovグループによって開発された.
CrySPYでも効率的な探索が可能な進化的アルゴリズムを採用した.以下のようなことができる.

  • 親の選択方法
    • トーナメント選択
    • ルーレット選択
    • エリート選択
  • 進化的操作
    • 交叉
    • 置換
    • ひずみ
  • etc.
    • 適者生存
    • 適者生存の中で重複した構造の排除

ベイズ最適化 (BO)

選択型アルゴリズムの一種.

fig_BO fig_BO

LAQA

選択型アルゴリズムの一種.

fig_LAQA fig_LAQA

fig_LAQA fig_LAQA

インターフェース

CrySPYはエネルギー計算や構造最適化に外部のソフトウェアを利用する. 以下のソフトウェアを利用可能.

少なくともどれか一つは必要.

ロゴ

PNG (背景透明)

logo_png1 logo_png1

logo_png2 logo_png2

logo_png3 logo_png3

logo_png4 logo_png4

JPG

logo_jpg1 logo_jpg1

logo_jpg2 logo_jpg2

logo_jpg3 logo_jpg3

logo_jpg4 logo_jpg4

バージョン情報のサブセクション

Version 1.2.5

Bug fix

  • simple bug fix

Version 1.2.2

エンタルピー

VASPとQEでは全エネルギーの代わりにエンタルピーが利用可能.

See also

Version 1.2.1

ASE interface

Bug fixed for multiple stages.

Version 1.1.1

spg_errorのバグ修正

ランダム構造生成時,ある空間群で構造生成ができない時にsgp_errorという変数にその空間群番号を記録し,以降その番号はスキップするようにしていたが,ごく稀に間違って登録されてしまうバグが見つかった.よってこのspg_errorという機能は削除した.

Version 1.1.0

MPI並列

MPIを用いたランダム構造生成が利用可能.

詳細は下記を参照.

LAQA

ストレス項を考慮に入れたスコアが利用できるように更新 (T. Yamashita and H. Sekine, Sci. Technol. Adv. Mater. Meth. 2, 84 (2022).).

詳細は下記を参照.

Backup

日付でディレクトリを作ることでバックアップの履歴が残るように変更. 詳細はfeatures/backup

Version 1.0.0

Install and run

CrySPY is now available in PyPI. You can install by

pip install csp-cryspy

The executable script, cryspy is automatically installed in your PATH. To run CrySPY, just type cryspy:

cryspy &

CrySPY stops once before going to next selection (BO, LAQA) or next generation (EA). For example, EA case:

[old version]

  • cryspy run
    • check jobs (finish current generation?)
    • structure generation by EA automatically starts

[CrySPY 1.0.0]

  • cryspy run
    • check jobs (finish current generation?)
    • stop
  • cryspy run
    • auto backup
    • structure generation by EA automatically starts

Auto and manual backup

Automatically backup:

  • before going to next selection or next generation
  • structure generation

To manually back up:

cryspy -b

See features/backup in detail.

Clean

cryspy -c

See features/clean in detail.

Directory tree

Changed the directory tree.

  • genstruc/RS –> RS/
  • genstruc/EA –> EA/
  • genstruc/struc_util.py –> util/
  • utility.py –> util/

IO

  • Fixed standard output file and standard error file: log_cryspy and err_cryspy
  • cryspy.out is obsoleted

Moved to CrySPY Utility

With the change in installation method, examples and cal_fingerprint have been moved to the CrySPY Utility.

COMBO

The python library COMBO is now optional in CrySPY. If you do not use Bayesian optimizaion, you do not need to install it.

New calc_code

cryspy.in

fppath

New input variable for cal_fingerprint. See Instllation/cryspy/cryspy_1.0

fwpath

New input variable for find_wy. See Instllation/requirements/find_wy

mindist

  • mindist can be omitted in cryspy.in
  • mindist_ea is obsoleted
  • added mindist_mol_bs and mindist_mol_bs_factor in cryspy.in

Version 0.10.3 or earlier

  • [2022 May 17] version 0.10.3 released
    • Bug fixed: LAMMPS IO.
  • [2022 January 24] version 0.10.2 released
    • Added nrot: maximum number of times to rotate molecules in mol_bs
  • [2021 September 30] version 0.10.1 released
    • Fixed the problem of numpy.random.seed in multiprocessing
  • [2021 July 25] version 0.10.0 released
    • Support PyXtal 0.2.9 or later
    • LAQA can be used with QE
    • Upper and lower limits of energy for EA and BO
  • [2021 July 13] paper published
    • Our paper on CrySPY software has been published in STAM:Methods
  • [2021 March 18] version 0.9.2 released
    • Support pymatgen v2022.
  • [2021 February 7] version 0.9.0 released
    • Interfaced with OpenMX
    • Employ PyXtal library to generate initial structures
    • If you use PyXtal (default), find_wy program is not required
    • LAQA can be used with soiap
    • Change the name: [lattice] section –> [structure] section
    • Several input variables move to [structure] section
      • natot: [basic] –> [structure]
      • atype: [basic] –> [structure]
      • nat: [basic] –> [structure]
      • maxcnt: [option] –> [structure]
      • symprec: [option] –> [structure]
      • spgnum: [option] –> [structure]
    • New features
      • Molecular crystal structure generation
      • Scale volume
  • [2020 March 19] paper published
  • [2020 February 16] version 0.8.0 released
    • Migrate to Python 3
    • CrySPY logo created
    • Change several variable names and data formats
    • Change style of output for energy: eV/cell –> eV/atom
    • IDs of working directories corresponds to structure IDs
    • New features
      • recalculation
      • manual select in BO
  • [2018 December 5] version 0.7.0 released
    • New features
      • Evolutionary algorithm
  • [2018 August 20] version 0.6.4 released
  • [2018 July 2] version 0.6.3 released
  • [2018 June 26] Version 0.6.2 released
  • [2018 March 1] Version 0.6.1 released
  • [2018 January 9] paper published

インストールのサブセクション

動作環境のサブセクション

Python

Python

CrySPY 1.1.0 or later

  • Python >= 3.8
    • PyXtal (>= 0.5.3)
    • (optional) mpi4py
    • (optional, required if algo is BO) COMBO

If you install cryspy with pip, necessary libraries such as PyXtal will be installed automatically. Go to Installation > CrySPY. Manual installation of COMBO is required when using Bayesian optimization.

CrySPY 1.0.0

  • Python >= 3.8
    • PyXtal (>= 0.5.3)
    • (optional, required if algo is BO) COMBO
情報

[2023 April 22] PyXtal (pyshtools)をarm64のMacOSにインストールする方法がわかった.Arm64 on MacOS (without Rosseta 2)を参照.
[2023 March 15] MacOSのarm64環境でのpyxtalのインストールが難しいので,Rosetta 2を使用してx86_64環境での利用が推奨.

CrySPY 0.10.0 – 0.10.3

Tested with Homebrew Python 3.8.x and 3.9.x on Mac and Python 3.8.x on Linux.

CrySPY 0.9.2

Tested with Homebrew Python 3.8.x and 3.9.x on Mac and Python 3.8.x on Linux.

情報

[2021 July 15] PyXtal 0.2.9以上を使う場合は,CrySPYを0.10.0以上にアップデートすること.

情報

[2021 March 18] pymatgen 2022.x.x.でbreaking changeがあって,importの書き方等が変わった. CrySPY 0.9.2とPyXtal 0.2.2はpymatgen 2022をサポート.

情報

[2021 Feb. 5] PyXtalを使うにはnumbaが必要だが,numbaは現在のところPython 3.9に対応していないのでしばらくはPython 3.9ではなくPython 3.8を利用する.
[2021 March 18] numbaがPython 3.9.xをサポート.CrySPYもPython 3.9で動作可能

情報

[2021 Feb. 7] PyXtalではSciPyが使われているが, 最新のSciPy(v1.6.0)ではdeepcopyを使うとバグが出る. SciPyはv1.5.4を利用する.
[2021 March 18] 上記バグはSciPy 1.6.1で修正された.

CrySPY 0.9.0 – 0.9.1

CrySPY 0.8.0 or earlier

CrySPY本体に同梱されている古いドキュメントを見ること.

構造最適化ソフト

構造最適化ソフト

少なくとも1つは必要.

find_wy (オプション)

CrySPYではこれまで,任意の空間群(対称性)持つ構造を生成するためにfind_wyを利用してきた.しかし,CrySPY 0.9.0からはデフォルトではPyXtalライブラリを採用している. CrySPY 0.9.0 以上で構造生成にPyXtalを使う場合は,find_wyのインストールはスキップできる. 従来通りfind_wyを利用することももちろん可能である. CrySPY 0.8.0 以前のものでは,空間群を考慮した構造生成にはfind_wyのインストールが必要となる.

情報

CrySPY 0.9.0 以上ではfind_wyのインストールはスキップできる.

find_wyのインストール

m_tspace

find_wyをコンパイルするためには,まずはm_tspaceをコンパイルして,ライブラリを生成する必要がある.詳細は以下のm_tspaceのサイトを参照すること.

m_tspace のソースをgitでダウンロードしてくる.ダウンロード先は例えば

$ mkdir -p ~/local
$ cd ~/local
$ git clone https://github.com/nim-hrkn/m_tspace.git

m_tspace のコンパイルにはさらに二つのファイルが必要となる.

TSPASE から下記ファイルを~/local/m_tspaceにダウンロードする:

$ cd m_tspace
$ wget http://phoenix.mp.es.osaka-u.ac.jp/~tspace/tspace_main/tsp07/tsp98.f
$ wget http://phoenix.mp.es.osaka-u.ac.jp/~tspace/tspace_main/tsp07/prmtsp.f

makefileをコンパイラに合わせて編集して,makeする. コンパイラにifortを使う場合は,-check allオプションを消さないとうまく動かない.また-O2オプションを設定する.

$ emacs makefile
$ head -n 4 makefile
#FC=gfortran
#FFLAGS=-g -cpp -DUSE_GEN -ffixed-line-length-255
FC=ifort
FFLAGS=-O2 -g -traceback -cpp -DUSE_GEN -132
$ make

gfortranを使う場合は,以下のようなエラーに遭遇するかもしれない.

tsp98.f:9839:32:

       CALL SUBGRP(MG,JG,MGT,JGT,NTAB,IND)
                                1
Error: Actual argument contains too few elements for dummy argument 'ntab' (12/48) at (1)
make: *** [tsp98.o] Error 1

その時はtsp98.fを以下のように書き換える(9925行目):

Before:

9913: C SUBROUTINE SUBGRP ====*====3====*====4====*====5====*====6====*====7
9914: C
9915: C    IF (JG(I),I=1,MG) IS A SUBGROUP OF (JGT(J),J=1,MGT) THEN
9916: C          TABLE (NTAB(I),I=1,MG) IS MADE HERE AND IND=0
9917: C    ELSE
9918: C          IND=-1
9919: C
9920: C                 1993/12/25
9921: C                   BY  S.TANAKA AND A. YANASE
9922: C---*----1----*----2----*----3----*----4----*----5----*----6----*----7
9923: C
9924:       SUBROUTINE SUBGRP(MG,JG,MGT,JGT,NTAB,IND)
9925:       DIMENSION NTAB(48),JG(48),JGT(48)

After:

9913: C SUBROUTINE SUBGRP ====*====3====*====4====*====5====*====6====*====7
9914: C
9915: C    IF (JG(I),I=1,MG) IS A SUBGROUP OF (JGT(J),J=1,MGT) THEN
9916: C          TABLE (NTAB(I),I=1,MG) IS MADE HERE AND IND=0
9917: C    ELSE
9918: C          IND=-1
9919: C
9920: C                 1993/12/25
9921: C                   BY  S.TANAKA AND A. YANASE
9922: C---*----1----*----2----*----3----*----4----*----5----*----6----*----7
9923: C
9924:       SUBROUTINE SUBGRP(MG,JG,MGT,JGT,NTAB,IND)
9925:       DIMENSION NTAB(12),JG(48),JGT(48)

コンパイルに成功すればm_tsp.aというライブラリができる.

find_wy

詳細はfind_wyのサイトをチェックすること:

find_wyのソースをgitでクローンしてくる.例えば:

$ mkdir -p ~/local
$ cd ~/local
$ git clone https://github.com/nim-hrkn/find_wy.git

make.incを編集して,先ほど用意したm_tsp.aのパスを設定する.

$ cd find_wy
$ emacs make.inc
$ head -n 4 make.inc
TSPPATH=~/local/m_tspace
#INCPATH = -I $(TSPPATH)
TSP=$(TSPPATH)/m_tsp.a

ここでも-check allを削除して-O2オプションを付けた方が良い. 準備できたらmakeする.

$ make

コンパイルできてfind_wyの実行ファイルが得られたら,実行してテストする.

$ ./find_wy input_sample/input_si4o8.txt

問題なければPOS_WY_SKEL_ALL.jsonなどのファイルが生成される.

find_wyの実行ファイル

CrySPY 1.0.0 or later

PATHが通ったところにfind_wyの実行ファイルを置く.もしくは下記のようにcryspy.inで実行ファイルのpathを指定する.

[structure]
use_find_wy = True
fwpath = /xxx/xxx/xxx/find_wy

CrySPY 0.10.3 or earlier

CrySPYでfind_wyを構造生成に用いる場合は所定の位置にfind_wyの実行ファイルを置いておく必要がるので,CrySPY本体をダウンロード後にfind_wyの実行ファイルをコピーしておく.CrySPYは任意のディレクトリに設置できるので,例えば~/CrySPY_root/CrySPY-x.x.x/CrySPY/find_wy/find_wy

CrySPYのサブセクション

CrySPY 1.0.0 or later

CrySPY

pip

CrySPY 1.0.0以降はpipを使ってインストール可能になった.

pip install csp-cryspy

pipでインストールすると,実行スクリプトのcryspyが自動的にPATHが通ったところにインストールされる. 下記コマンドでチェックできる.

which cryspy

編集可能モード

CrySPYのソースコードを編集したい時は,pipの編集可能モード(-e オプション)を使うのが便利.

git clone https://github.com/Tomoki-YAMASHITA/CrySPY.git
pip install -e ./CrySPY

git cloneの代わりに,release pageから圧縮ファイルをダウンロードしてもよい.

cal_fingerprint (optional)

cal_fingerprintプログラムは構造記述子を計算するためのもので,アルゴリズにベイズ最適化を使う場合は必須. CrySPY 1.0.0からはcal_fingerprintプログラムはCrySPY utilityに含まれている. コンパイルについてはこちらを参照:Instllation/CrySPY_utility/Compile cal_fingerprint

実行ファイルcal_fingerprintをPATHが通ったところに置く,もしくは下記のようにcryspy.inで実行ファイルのpathを指定する.

[BO]
fppath = /xxx/xxx/xxx/cal_fingerprint

Arm64 on MacOS (without Rosseta 2)

情報

PyXtalではversion 0.6.3からpyshtoolsが必須ではなくなったので,最近のバージョンのpyxtalを使う場合は以下に書いてあることは無視して良い

  1. miniforge3をインストール(homebrew pythonでpyshtoolsをインストールする方法が今のところ不明)
  2. condaでpymatgen,pyshtoolsをインストール(最近のバージョンのpyshtoolsはconda-forgeからインストール可能になった)
conda install pymatgen
conda install pyshtools
  1. CrySPYをインストール
pip3 install csp-cryspy

CrySPY 0.10.3 or earlier

CrySPYのインストールはシンプルで,ダウンロードするだけで良い.

ダウンロード

CrySPYは任意の場所に置いて良い.ここでは例として~/CrySPY_root/CrySPY-x.x.x (x.x.x はバージョン番号)にダウンロードすることにする. gitコマンドを使うか,リリースページから圧縮ファイルをダウンロードする.

Git

mkdir ~/CrySPY_root
cd ~/CrySPY_root
git clone https://github.com/Tomoki-YAMASHITA/CrySPY.git CrySPY-x.x.x

zip or tar.gz file

zip または tar.gz ファイルをここからダウンロードする. GitHub release .
ダウンロードして展開したソースを~/CrySPY_root/CrySPY-x.x.xに置く.

ディレクトリ構成

~/CrySPY_root/CrySPY-x.x.x/のディレクトリ構成:

CrySPY-x.x.x
├── CHANGELOG.md
├── CrySPY/
│   ├── BO/
│   ├── EA/
│   ├── IO/
│   ├── LAQA/
│   ├── RS/
│   ├── __init__.py
│   ├── calc_dscrpt/
│   ├── f-fingerprint/
│   ├── find_wy/
│   ├── gen_struc/
│   ├── interface/
│   ├── job/
│   └── start/
│   └── utility.py
├── LICENSE
├── README.md
├── cryspy.py
├── docs/
├── example/
└── utility/
情報

cryspy.pyがメインスクリプト.

セットアップ (オプション)

find_wy (オプション)

find_wyを使う時は,find_wyの実行ファイルを(例えば)~/CrySPY_root/CrySPY-x.x.x/CrySPY/find_wy/以下に置く必要がある. つまり~/CrySPY_root/CrySPY-x.x.x/CrySPY/find_wy/find_wy.

cd ~/CrySPY_root/CrySPY-x.x.x/CrySPY/find_wy
cp ~/local/find_wy/find_wy .

cal_fingerprintのコンパイル (オプション)

ベイズ最適化を使う場合は,構造の記述子を計算するためのプログラムであるcal_fingerpirntをコンパイルする必要がある.

cd ~/CrySPY_root/x.x.x/CrySPY/f-fingerprint
emacs Makefile
make

cal_fingerprintの実行ファイルが例えば~/CrySPY_root/x.x.x/CrySPY/f-fingerprint/以下にあるようにする. コンパイルすれば自動的にそうなるはず.

CrySPYユーティリティ (オプション)

ローカルPCにPython環境を構築しておくと,計算結果の解析および可視化を行うのに便利である. jupyter notebookやPythonスクリプトなどのユーティリティツールが利用できる. 入力ファイルのexamplesもCrySPYユーティリティに含まれている.

情報

ユーティリティツールを使うには以下のライブラリ等が必要になる.

ユーティリティツールのダウンロード

Git

$ git clone https://github.com/Tomoki-YAMASHITA/CrySPY_utility.git

zip

CrySPY utilityへ飛んで,緑のCodeと書かれたボタンをクリック,Download ZIPを選んでダウンロード.

Compile cal_fingerprint

ベイズ最適化を使うときは構造記述子を計算するためのcal_fingerpirntプログラムをコンパイルする. Fortranコンパイラが必要になる. ワークステーションやスパコンなどのCrySPYを用いる環境にインストールする.

cd CrySPY_utility/f-fingerprint
emacs Makefile
make

実行ファイルの扱いに関してはInstallation/CrySPYも参照.

チュートリアルのサブセクション

ランダムサーチ (RS)

情報

最初はASEから始めるのが簡単なのでお勧めです.CrySPY (csp-cryspy)をインストールすると,ASEも自動的にインストールされます.

入力ファイルの準備

下記のどれか一つを従って,その後"CrySPYを実行"のセクションに移ってください.

CrySPY実行

  1. Check cryspy.in
  2. (version 0.10.3 or earlier) Script to run
  3. First run
  4. Submit job
  5. Check results
  6. Append structures
  7. Analysis and visualization

Loading external data

calc_code == extを使う場合のみ.

ランダムサーチ (RS)のサブセクション

ASE in your local PC

2023 July 10

ASEは様々なコードのインターフェースを提供しているPythonライブラリであり, Pure Python EMT calculatorというシンプルなEMTの計算も実行できる.CrySPYさえインストールしてあれば,精度はともかく簡単に計算できるので,CrySPYのテストにちょうど良い.

このチュートリアルでは,MacやLinuxなどのOSのローカルPCを用いてCu 8原子の構造探索を試す.

Assumption

ここでは次のような条件を想定している:

  • CrySPY 1.2.0 or later in your local PC
  • CrySPY job filename: job_cryspy
  • ase input filename: ase_in.py

Input files

どこか適当なワーキングディレクトリに移動して,まずはexampleをコピーしてくる.下記のどちらからコピーしてきても良い.

cd ase_Cu8_RS
tree
.
├── calc_in
│   ├── ase_in.py_1
│   └── job_cryspy
└── cryspy.in

cryspy.in

cryspy.inはCrySPYの入力ファイル.

[basic]
algo = RS
calc_code = ASE
tot_struc = 5
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Cu
nat = 8

[ASE]
ase_python = ase_in.py

[option]

[basic] セクションのjobcmd = zshは環境に合わせてjobcmd = shjobcmd = bash等に変更する. CrySPYは内部でバックグラウンドジョブとしてzsh job_cryspyを実行する.

ASEを使う場合は,[ASE]セクションが必要. 下記の二つのファイル名は好きなように変えても良い.

  • jobfile: job_cryspy
  • ase_python: ase_in.py

他の入力変数については後で説明を行う.

calc_in directory

ASEのジョブファイルや入力ファイルはこのディレクトリに準備する.

Job file

ジョブファイルの名前はcryspy.injobfileに一致させる必要がある. ジョブファイルの例は下記の通り.

#!/bin/sh

# ---------- ASE
python3 ase_in.py

# ---------- CrySPY
sed -i -e '3 s/^.*$/done/' stat_job

ase_in.pyというファイル名も自由に変えられるが, cryspy.inase_pythonの値と一致させておく必要がある. CrySPYではジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobとしておくルールになっている.

メモ

ジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobと書いておく.

ヒント

CrySPYのジョブファイルのCrySPY_IDという文字列は自動的に構造IDに置き換わるようになっている. PBSやSLURMといったジョブスケジューラーを使う場合,ジョブ名にCrySPY_IDと書いておくとどの構造のジョブなのかが分かり便利である. 例えば,PBSでは#PBS -N Si_CrySPY_IDのように書いておくと,ジョブをサブミットする際,#PBS -N Si_10のように置き換わる. 注意点として,ジョブ名を数字から始めるとエラーとなることが多いので,Si_のように何か文字列を頭につけておくこと.

Input for ASE

ステージ数(nstage in cryspy.in)に応じた数のインプットファイルが必要となる. インプットファイル名の語尾に_xをつけて準備する. ここでxはステージ数.

ASEのチュートリアルではnstage = 1を用いるので,ASEのインプットファイルはase_in.py_1の一つだけが必要. ase_in.py_1は例えば下記の通り(ASEの使い方の詳細は公式のドキュメントを見ること).

from ase.constraints import ExpCellFilter, StrainFilter
from ase.calculators.emt import EMT
from ase.calculators.lj import LennardJones
from ase.optimize.sciopt import SciPyFminCG
from ase.optimize import BFGS
from ase.spacegroup.symmetrize import FixSymmetry
import numpy as np
from ase.io import read, write

# ---------- input structure
# CrySPY outputs 'POSCAR' as an input file in work/xxxxxx directory
atoms = read('POSCAR', format='vasp')

# ---------- setting and run
atoms.calc = EMT()
atoms.set_constraint([FixSymmetry(atoms)])
atoms = ExpCellFilter(atoms, hydrostatic_strain=False)
opt = BFGS(atoms)
#opt=SciPyFminCG(atoms)
opt.run()

# ---------- opt. structure and energy
# [rule in ASE interface]
# output file for energy: 'log.tote' in eV/cell
#                         CrySPY reads the last line of 'log.tote'
# output file for structure: 'CONTCAR' in vasp format
e = atoms.atoms.get_total_energy()
with open('log.tote', mode='w') as f:
    f.write(str(e))

write('CONTCAR', atoms.atoms, format='vasp')

ASEはVASPやQEなどと違って,入力ファイル(python script)は自分で書くことになるので自由度がある. CrySPYでは2つのルールを設けている.

  1. エネルギーはeV/cellの単位でlog.toteというファイルに出力する.CrySPYはこのファイルの最後の行を読む.
  2. 最適化後の構造データはCONTCARというファイルにVASPフォーマットで出力する.

CrySPY実行

ここまで準備ができたらCrySPY実行へ進む.

soiap in your local PC

2024年4月21日 日本語化

soiapは原子間ポテンシャルを使用した計算ができるソフトウェアであり,計算が軽いのでCrySPYのテストにちょうど良い. soiapのインストールや詳細はinstructionsを参照.

このチュートリアルでは,MacやLinuxのローカルPC上でCrySPYを試す. テストシステムはSi 8原子.

Assumption

ここでは次のような条件を想定している:

  • (only version 0.10.3 or earlier) CrySPY main script: ~/CrySPY_root/CrySPY-0.9.0/cryspy.py
  • CrySPY job filename: job_cryspy
  • soiap executable file: ~/local/soiap-0.3.0/src/soiap
  • soiap input filename: soiap.in
  • soiap output filename: soiap.out
  • soiap input structure filename: initial.cif

Input files

どこか適当なワーキングディレクトリに移動して,まずはexampleをコピーしてくる.下記のどちらからコピーしてきても良い.

  • Download from cryspy_utility/examples/soiap_Si8_RS
  • Copy from CrySPY utility that you installed
  • (only version 0.10.3 or earlier) cp -r ~/CrySPY_root/CrySPY-0.9.0/example/v0.9.0/soiap_RS_Si8 .
cd soiap_RS_Si8
tree
.
├── calc_in
│   ├── job_cryspy
│   └── soiap.in_1
└── cryspy.in

cryspy.in

cryspy.inがCrySPYの入力ファイル.

[basic]
algo = RS
calc_code = soiap
tot_struc = 5
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8

[soiap]
soiap_infile = soiap.in
soiap_outfile = soiap.out
soiap_cif = initial.cif

[option]

[basic] セクションのjobcmd = zshは環境に合わせてjobcmd = shjobcmd = bash等に変更する. CrySPYは内部でバックグラウンドジョブとしてzsh job_cryspyを実行する.

soiapを使う場合は[soiap]セクションが必要となる.下記のファイル名は好きなように変えても良い.

  • jobfile
  • soiap_infile
  • soiap_outfile
  • soiap_cif

他の入力変数については後で説明を行う.

calc_in directory

soiapのジョブファイルや入力ファイルはこのディレクトリに準備する.

Job file

ジョブファイルの名前はcryspy.injobfileに一致させる必要がある. ジョブファイルの例は下記の通り.

#!/bin/sh

# ---------- soiap
EXEPATH=/path/to/soiap
$EXEPATH/soiap soiap.in 2>&1 > soiap.out

# ---------- CrySPY
sed -i -e '3 s/^.*$/done/' stat_job

/path/to/soiapはsoiapの実行ファイルのpathに変えること. 入力ファイル(soiap.in)と出力ファイル(soiap.out)はcryspy.inで指定したsoiap_infilesoiap_outfileに合わせること. 最後の行以外は普段使っているようなジョブスクリプトで良いが, CrySPYではジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobとしておくルールになっている.

メモ

ジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobと書いておく.

ヒント

CrySPYのジョブファイルのCrySPY_IDという文字列は自動的に構造IDに置き換わるようになっている. PBSやSLURMといったジョブスケジューラーを使う場合,ジョブ名にCrySPY_IDと書いておくとどの構造のジョブなのかが分かり便利である. 例えば,PBSでは#PBS -N Si_CrySPY_IDのように書いておくと,ジョブをサブミットする際,#PBS -N Si_10のように置き換わる. 注意点として,ジョブ名を数字から始めるとエラーとなることが多いので,Si_のように何か文字列を頭につけておくこと.

Input for soiap

ステージ数(nstage in cryspy.in)に応じた数のインプットファイルが必要となる. インプットファイル名の語尾に_xをつけて準備する. ここでxはステージ数.

soiapのチュートリアルではnstage = 1を用いるので,インプットファイルはsoiap.in_1の一つだけが必要. soiap.in_1は例えば下記の通り.

crystal initial.cif ! CIF file for the initial structure
symmetry 1 ! 0: not symmetrize displacements of the atoms or 1: symmetrize

md_mode_cell 3 ! cell-relaxation method
               ! 0: FIRE, 2: quenched MD, or 3: RFC5
number_max_relax_cell 100 ! max. number of the cell relaxation
number_max_relax 1 ! max. number of the atom relaxation
max_displacement 0.1 ! max. displacement of atoms in Bohr

external_stress_v 0.0 0.0 0.0 ! external pressure in GPa

th_force 5d-5 ! convergence threshold for the force in Hartree a.u.
th_stress 5d-7 ! convergence threshold for the stress in Hartree a.u.

force_field 1 ! force field
              ! 1: Stillinger-Weber for Si, 2: Tsuneyuki potential for SiO2,
              ! 3: ZRL for Si-O-N-H, 4: ADP for Nd-Fe-B, 5: Jmatgen, or
              ! 6: Lennard-Jones

1行目に書く初期構造ファイル(initial.cif)はcryspy.insoiap_cifの値と揃える.

CrySPY実行

ここまで準備ができたらCrySPY実行へ進む.

VASP

2024 April 24

このチュートリアルでは,PBSなどのジョブスケジューラーを備えたPCクラスターを想定してCrySPYを試す.第一原理計算のVASPを用いて,Na8Cl8(16原子)の構造探索を行う.

Assumption

ここでは次のような条件を想定している:

  • CrySPY 1.2.0 or later in your PC cluster
  • CrySPY job command: qsub
  • CrySPY job filename: job_cryspy
  • executable file, vasp_std in your PC cluster

Input files

どこか適当なワーキングディレクトリに移動して,まずはexampleをコピーしてくる.下記のどちらからコピーしてきても良い.

cd vasp_Na8Cl8_RS
tree
.
├── calc_in
│   ├── INCAR_1
│   ├── INCAR_2
│   ├── POTCAR
│   ├── POTCAR_is_dummy
│   └── job_cryspy
└── cryspy.in

cryspy.in

cryspy.inはCrySPYの入力ファイル.

[basic]
algo = RS
calc_code = VASP
tot_struc = 5
nstage = 2
njob = 2
jobcmd = qsub
jobfile = job_cryspy

[structure]
natot = 16
atype = Na Cl
nat = 8 8
mindist_1 = 2.5 1.5
mindist_2 = 1.5 2.5

[VASP]
kppvol = 40 80

[option]

[basic] セクションのjobcmd = qsubは環境に合わせて変更する. CrySPYは内部でバックグラウンドジョブとしてqsub job_cryspyを実行する. 下記のファイル名は好きなように変えても良い.

  • jobfile

構造最適化計算はステージ制を採用しており,ここではnstage = 2を用いている. 例えば,最初のステージでは,セルを固定し内部座標だけ緩和する設定で,k点も少ない計算を実行し,2ステージ目でセルも含めてフルに構造緩和して,精度も高めるようなことが可能となっている.

VASPを使う場合は,[VASP]セクションが必要. ここでは各ステージにおけるk点のグリッド密度(Å^-3)をkppvolに指定する必要がある.

情報

kppvolの詳細はこちら –> Input file > Kpoint

他のインプット変数に関しては後ほど説明する.

calc_in directory

ジョブファイルやVASPのインプットをこのディレクトリに置く.

Job file

ジョブファイルの名前はcryspy.injobfileに一致させる必要がある. ジョブファイルの例は下記の通り.

#!/bin/sh
#$ -cwd
#$ -V -S /bin/bash
####$ -V -S /bin/zsh
#$ -N Na8Cl8_CrySPY_ID
#$ -pe smp 20
####$ -q ibis1.q
####$ -q ibis2.q
####$ -q ibis3.q
####$ -q ibis4.q

# ---------- vasp
VASPROOT=/usr/local/vasp/vasp.6.4.2/bin
mpirun -np $NSLOTS $VASPROOT/vasp_std

# ---------- CrySPY
sed -i -e '3 s/^.*$/done/' stat_job

VASPROOTは環境に合わせて変更する.普段VASPのジョブを流しているジョブファイルを使えば良い.ただし,CrySPYではジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobとしておくルールになっている.

メモ

ジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobと書いておく.

ヒント

CrySPYのジョブファイルのCrySPY_IDという文字列は自動的に構造IDに置き換わるようになっている. PBSやSLURMといったジョブスケジューラーを使う場合,ジョブ名にCrySPY_IDと書いておくとどの構造のジョブなのかが分かり便利である. 例えば,PBSでは#PBS -N Si_CrySPY_IDのように書いておくと,ジョブをサブミットする際,#PBS -N Si_10のように置き換わる. 注意点として,ジョブ名を数字から始めるとエラーとなることが多いので,Si_のように何か文字列を頭につけておくこと.

Input for VASP

ステージ数(nstage in cryspy.in)に応じた数のインプットファイルが必要となる. インプットファイル名の語尾に_xをつけて準備する. ここでxはステージ数.

今はnstage = 2を用いているので,INCAR_1INCAR_2が必要となる. ここでは,INCAR_1はセルを固定して内部座標だけ緩和する設定,INCAR_2はセルも含めてフルに緩和する設定になっている.

INCAR_1

SYSTEM = NaCl
!!!LREAL = Auto
Algo = Fast
NSW = 40

LWAVE = .FALSE.
!LCHARG = .FALSE.

ISPIN =  1

ISMEAR = 0
SIGMA = 0.1

IBRION = 2
ISIF = 2

EDIFF = 1e-5
EDIFFG = -0.01

INCAR_2

SYSTEM = NaCl
!!LREAL = Auto
Algo = Fast
NSW = 200

ENCUT = 341

!!LWAVE = .FALSE.
!!LCHARG = .FALSE.


ISPIN =  1

ISMEAR = 0
SIGMA = 0.1

IBRION = 2
ISIF = 3

EDIFF = 1e-5
EDIFFG = -0.01

CrySPYはPOSCARKPOINTSファイルを自動生成する. POTCARファイルはユーザーが準備する必要がある. このexampleに含まれているPOTCARは空のファイルなので,各自で準備すること.

警告

exampleに含まれているPOTCARは空のファイル.配布できない.

CrySPY実行

ここまで準備ができたらCrySPY実行に進む.

QE

2024 April 24,日本語化

このチュートリアルでは,PBSなどのジョブスケジューラーを備えたPCクラスターを想定してCrySPYを試す.第一原理計算のQUANTUM ESPRESSOを用いて,Si 8原子の構造探索を行う.

Assumption

ここでは次のような条件を想定している:

  • CrySPY job command: qsub
  • CrySPY job filename: job_cryspy
  • QE executable file: /usr/local/qe-6.5/bin/pw.x
  • QE input filename: pwscf.in
  • QE output filename: pwscf.out

Input files

どこか適当なワーキングディレクトリに移動して,まずはexampleをコピーしてくる.下記のどちらからコピーしてきても良い.

cd QE_RS_Si8
tree
.
├── calc_in
│   ├── job_cryspy
│   ├── pwscf.in_1
│   └── pwscf.in_2
└── cryspy.in

cryspy.in

cryspy.inはCrySPYの入力ファイル.

[basic]
algo = RS
calc_code = QE
tot_struc = 5
nstage = 2
njob = 2
jobcmd = qsub
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8

[QE]
qe_infile = pwscf.in
qe_outfile = pwscf.out
kppvol =  40  80

[option]

[basic] セクションのjobcmd = qsubは環境に合わせて変更する. CrySPYは内部でバックグラウンドジョブとしてqsub job_cryspyを実行する.

構造最適化計算はステージ制を採用しており,ここではnstage = 2を用いている. 例えば,最初のステージでは,セルを固定し内部座標だけ緩和する設定で,k点も少ない計算を実行し,2ステージ目でセルも含めてフルに構造緩和して,精度も高めるようなことが可能となっている.

QEを使う場合は,[QE]セクションが必要. ここでは各ステージにおけるk点のグリッド密度(Å^-3)をkppvolに指定する必要がある.

情報

kppvolの詳細はこちら –> Input file > Kpoint

下記のファイル名は好きなように変えても良い.

  • jobfile
  • qe_infile
  • qe_outfile

他のインプット変数に関しては後ほど説明する.

calc_in directory

ジョブファイルやQEのインプットをこのディレクトリに置く.

Job file

ジョブファイルの名前はcryspy.injobfileに一致させる必要がある. ジョブファイルの例は下記の通り.

#!/bin/sh
#$ -cwd
#$ -V -S /bin/bash
####$ -V -S /bin/zsh
#$ -N Si8_CrySPY_ID
#$ -pe smp 20
####$ -q ibis1.q
####$ -q ibis2.q

mpirun -np $NSLOTS /path/to/pw.x < pwscf.in > pwscf.out


if [ -e "CRASH" ]; then
    sed -i -e '3 s/^.*$/skip/' stat_job
    exit 1
fi

sed -i -e '3 s/^.*$/done/' stat_job

/path/to/pw.xは環境に合わせて変更する. 入力(pwscf.in)出力(pwscf.out)ファイルの名前は好きに変えて良いが,cryspy.inqe_infileqe_outfileに合わせる必要がある. 普段VASPのジョブを流しているジョブファイルを使えば良い.ただし,CrySPYではジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobとしておくルールになっている.

メモ

ジョブファイルの最後の行はsed -i -e '3 s/^.*$/done/' stat_jobと書いておく.

ヒント

CrySPYのジョブファイルのCrySPY_IDという文字列は自動的に構造IDに置き換わるようになっている. PBSやSLURMといったジョブスケジューラーを使う場合,ジョブ名にCrySPY_IDと書いておくとどの構造のジョブなのかが分かり便利である. 例えば,PBSでは#PBS -N Si_CrySPY_IDのように書いておくと,ジョブをサブミットする際,#PBS -N Si_10のように置き換わる. 注意点として,ジョブ名を数字から始めるとエラーとなることが多いので,Si_のように何か文字列を頭につけておくこと.

Input for QE

ステージ数(nstage in cryspy.in)に応じた数のインプットファイルが必要となる. インプットファイル名の語尾に_xをつけて準備する. ここでxはステージ数.

今はnstage = 2を用いているので,pwscf.in_1pwscf.in_2が必要となる. ここでは,pwscf.in_1はセルを固定して内部座標だけ緩和する設定,pwscf.in_2はセルも含めてフルに緩和する設定になっている.

pwscf.in_1

 &control
    title = 'Si8'
    calculation = 'relax'
    nstep = 100
    restart_mode = 'from_scratch',
    pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
    outdir='./out.d/'
 /

 &system
    ibrav = 0
    nat = 8
    ntyp = 1
    ecutwfc = 44.0
    occupations = 'smearing'
    degauss = 0.01
 /

 &electrons
 /

 &ions
 /

 &cell
 /

ATOMIC_SPECIES
  Si  28.086  Si.pbe-n-kjpaw_psl.1.0.0.UPF

pwscf.in_2

 &control
    title = 'Si8'
    calculation = 'vc-relax'
    nstep = 200
    restart_mode = 'from_scratch',
    pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
    outdir='./out.d/'
 /

 &system
    ibrav = 0
    nat = 8
    ntyp = 1
    ecutwfc = 44.0
    occupations = 'smearing'
    degauss = 0.01
 /

 &electrons
 /

 &ions
 /

 &cell
 /

ATOMIC_SPECIES
  Si  28.086  Si.pbe-n-kjpaw_psl.1.0.0.UPF

pseudo_dirは各自の環境に合わせて変更する. Inputs for structure data and k-point such as インプットファイルのATOMIC_POSITIONSK_POINTSはCrySPYがpymatgenを用いて自動生成するのでユーザーが書く必要はない.

CrySPY実行

ここまで準備ができたらCrySPY実行に進む.

OpenMX

Coming soon.

LAMMPS

Coming soon.

External program

Available from CrySPY 0.11.0.

If you use an external program not supported by CrySPY, the optimized energy and structure data can be loaded semi-manually in CrySPY. You have to prepare two files, ext_opt_struc_data.pkl and ext_energy_data.pkl.

Assumption

Here, we assume the following conditions:

  • (version 0.10.3 or earlier) CrySPY main script: ~/CrySPY_root/CrySPY-0.11.0/cryspy.py

(calc_in directory is not required.)

Input files

Move to your working directory, and copy input example files.

  • version 1.0.0 or later
    • Copy from CrySPY utility
  • version 0.10.3 or earlier
    • cp -r ~/CrySPY_root/CrySPY-0.9.0/example/ext_Si8_RS .
cd ext_Si8_RS
tree
.
└── cryspy.in

cryspy.in

cryspy.in is the input file of CrySPY.

[basic]
algo = RS
calc_code = ext
tot_struc = 5

[structure]
natot = 8
atype = Si
nat = 8

[option]

If calc_code == ext, nstage, njob, jobcmd, and jobfile are ignored.

Running CrySPY

This mode is different from the normal use of CrySPY. Go to Load external data.

Check cryspy.in

See Input file in detail.

Let’s take a look at cryspy.in again. This may be slightly different depending on calc_code you chose.

[basic]
algo = RS
calc_code = soiap
tot_struc = 5
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8

[soiap]
soiap_infile = soiap.in
soiap_outfile = soiap.out
soiap_cif = initial.cif

[option]

[basic] section

  • algo: Algorithm. Set RS for Random Search.
  • calc_code: Structure optimizer. Choose from VASP, QE, OMX, soiap, LAMMPS
  • tot_struc: The total number of structures. In this case, 5 random structures are generated at 1st run.
  • nstage: The number of stages. It’s up to you.
  • njob: The number of jobs running at the same time. In this example, CrySPY sets 2 slots for structure optimization, in other words, optimizes every 2 structures.
  • jobcmd: Command for jobs. Use bash, zsh, qsub, and so on.
  • jobfile: File name of the job file.

[structure] section

  • natot: The total number of atoms. e.g. for Na8Cl8: natot = 16.
  • atype: Atom type. e.g. for Na8Cl8: atype = Na Cl.
  • nat: The number of each atom. e.g. for Na8Cl8: nat = 8 8

Script to run

メモ

For version 1.0.0 or later, skip this page. The executable script is automatically installed.

Assumption

Here, we assume the following condition:

  • CrySPY main script: ~/CrySPY_root/CrySPY-0.9.0/cryspy.py

Make script

Let’s make a convenient shell script to avoid typing long commands over and over again. Here, we create the script, cryspy (any file name will do).

$ emacs cryspy
$ chmod 744 cryspy
$ cat cryspy
#!/bin/sh

python3 -u ~/CrySPY_root/CrySPY-0.9.0/cryspy.py 1>> log 2>> err

-u option (unbuffered option) can be omitted.

You can put this script in your $PATH, or just use like bash ./cryspy.

Firsrt run

2023 July 10, update

Make sure you have the following in your working directory.

  • calc_in/
  • (cryspy)
  • cryspy.in
$ ls
calc_in/  cryspy.in

Then, run CyrSPY!

cryspy

If you use old version (0.10.3 or earlier):

bash ./cryspy

At the first run, CrySPY goes into structure generation mode. CrySPY stops after 5 structure generation.

If it worked properly, the following output appears on the screen:

[2023-07-10 18:40:54,389][cryspy_init][INFO] 


Start CrySPY 1.2.0


[2023-07-10 18:40:54,389][cryspy_init][INFO] # ---------- Read input file, cryspy.in
[2023-07-10 18:40:54,390][read_input][INFO] Save input data in cryspy.stat
[2023-07-10 18:40:54,391][cryspy_init][INFO] # ---------- Initial structure generation
[2023-07-10 18:40:54,391][cryspy_init][INFO] Number of MPI processes: 1
[2023-07-10 18:40:54,391][gen_init_struc][INFO] # ------ mindist
[2023-07-10 18:40:54,395][struc_util][INFO] Cu - Cu: 1.32
[2023-07-10 18:40:54,395][gen_init_struc][INFO] # ------ generate structures
[2023-07-10 18:40:54,481][gen_pyxtal][INFO] Structure ID      0 was generated. Space group:   1 -->   1 P1
[2023-07-10 18:40:54,493][gen_pyxtal][INFO] Structure ID      1 was generated. Space group:  28 -->  28 Pma2
[2023-07-10 18:40:54,498][gen_pyxtal][INFO] Structure ID      2 was generated. Space group:  29 -->  29 Pca2_1
[2023-07-10 18:40:54,704][gen_pyxtal][INFO] Structure ID      3 was generated. Space group: 137 --> 137 P4_2/nmc
[2023-07-10 18:40:54,725][gen_pyxtal][INFO] Structure ID      4 was generated. Space group: 212 --> 214 I4_132
[2023-07-10 18:40:54,800][cryspy_init][INFO] Elapsed time for structure generation: 0:00:00.408367
cryspy  4.35s user 1.04s system 145% cpu 3.697 total

Several output files are also generated.

  • (cryspy.out): Short log. only version 0.10.3 or earlier.
  • cryspy.stat: Status file.
  • data/init_POSCARS: Initial struture file in POSCAR format. You can open this file using VESTA
  • data/pkl_data: Directory to save pickled data.
  • log_cryspy: log.
  • err_cryspy: error and warning.

Let’s take a look at cryspy.stat file.

...
(omit)
...
[status]
id_queueing = 0 1 2 3 4

Structure ID 0 – 4 are queueing because we just generated structures, and have not submitted yet.

ヒント

Check the initial structures, if the distance between atoms is too close, you should set the mindist in cryspy.in.

Submit job

2024年4月21日更新,日本語化

計算再開

CrySPYはcryspy.statファイルがあれば自動的に計算を再開する.

ヒント

crypy.statがあれば続きから再開.
はじめから計算をしたければcryspy.statを削除する.

ジョブの投入

cryspyをもう一度実行する.

cryspy

画面かlog_cryspyファイルに下記のように出力される.

[2023-07-10 18:52:51,859][cryspy_restart][INFO] 


Restart CrySPY 1.2.0


[2023-07-10 18:52:51,869][ctrl_job][INFO] # ---------- job status
[2023-07-10 18:52:51,904][ctrl_job][INFO] ID      0: submit job, Stage 1
[2023-07-10 18:52:51,931][ctrl_job][INFO] ID      1: submit job, Stage 1

cryspy.statでステータスが確認できる.

...
(omit)
...
[status]
id_queueing = 2 3 4
id      0 = Stage 1
id      1 = Stage 1

cryspy.innjob = 2に設定されているので,CrySPYは構造ID 0と1の二つのジョブをサブミットした. 計算はworkディレクトリの中で行われる.各構造IDのディレクトリが作られる.

tree -d work
work
├── 000000
├── 000001
└── fin

二つのジョブが終了したら,もう一度cryspyを実行する.

cryspy
[2023-07-10 18:55:01,053][cryspy_restart][INFO] 


Restart CrySPY 1.2.0


[2023-07-10 18:55:01,058][ctrl_job][INFO] # ---------- job status
[2023-07-10 18:55:01,058][ctrl_job][INFO] ID      0: Stage 1 Done!
[2023-07-10 18:55:01,093][ctrl_job][INFO]     collect results: E = -0.00696997755502915 eV/atom
[2023-07-10 18:55:01,132][ctrl_job][INFO] ID      1: Stage 1 Done!
[2023-07-10 18:55:01,133][ctrl_job][INFO]     collect results: E = 0.4934076667166454 eV/atom
[2023-07-10 18:55:01,144][cryspy][INFO] 

recheck 1

[2023-07-10 18:55:01,145][ctrl_job][INFO] # ---------- job status
[2023-07-10 18:55:01,153][ctrl_job][INFO] ID      2: submit job, Stage 1
[2023-07-10 18:55:01,161][ctrl_job][INFO] ID      3: submit job, Stage 1

もしnstage = 2のようにnstageを2以上に設定していれば,ID 0と1のstage 2のジョブがサブミットされる. 今回はnstage = 1なので,ID 0と1の計算データを収集して,次のIDのジョブをサブミットする. 計算が終わった構造のディレクトリはfinディレクトリに移動される.

5構造全ての計算が終わるまでcryspyを繰り返し実行する. すべての計算が終わって,計算結果の詳細が必要なければworkディレクトリを削除しても良い.

何度も何度もcryspyを繰り返し実行する時は,自動スクリプト(repeat_cryspy)が役に立つ.

Check results

Move to data directory. There should be a few more files.

$ cd data
$ ls
cryspy_rslt  cryspy_rslt_energy_asc  init_POSCARS  opt_POSCARS  pkl_data/
  • cryspy_rslt: Result file.
  • cryspy_rslt_energy_asc: Result file sorted in energy ascending order.
  • init_POSCARS: Initial struture file in POSCAR format.
  • opt_POSCARS: Optimized structure file in POSCAR format.
  • pkl_data/: Directory to save pickled data.

The results are written to text files, cryspy_rslt and cryspy_rslt_energy_asc (and also saved in pickle data in pkl_data directory).

Each result appends to cryspy_rslt file in the order in which one finished earlier.

cat cryspy_rslt
   Spg_num Spg_sym  Spg_num_opt Spg_sym_opt  E_eV_atom  Magmom      Opt
0      139  I4/mmm          139      I4/mmm  -3.000850     NaN     done
1       98  I4_122           12        C2/m  -3.978441     NaN  not_yet
2       16    P222           16        P222  -3.348616     NaN  not_yet
3       36  Cmc2_1           36      Cmc2_1  -3.520306     NaN  not_yet
4       36  Cmc2_1            4        P2_1  -3.304168     NaN  not_yet
情報

Not ID order in cryspy_rslt

In cryspy_rslt_energy_asc file, the results are sorted in energy ascending order.

cat cryspy_rslt_energy_asc
   Spg_num Spg_sym  Spg_num_opt Spg_sym_opt  E_eV_atom  Magmom      Opt
1       98  I4_122           12        C2/m  -3.978441     NaN  not_yet
3       36  Cmc2_1           36      Cmc2_1  -3.520306     NaN  not_yet
2       16    P222           16        P222  -3.348616     NaN  not_yet
4       36  Cmc2_1            4        P2_1  -3.304168     NaN  not_yet
0      139  I4/mmm          139      I4/mmm  -3.000850     NaN     done

Spg_num and Spg_sym show space group information on initial structures. Spg_num_opt and Spg_sym_opt are those of optimized structures. The last column Opt indicates whether or not optimization reached required accuracy.

Append structures

Of course only 5 structures are not enough to find stable structures. You can append structures whenever you want. Here let’s append more 5 structures.

For Si-Si mindist, the default value of 1.11 Å is used in the first structure generation (see log_cryspy), which is a little too close. Let us try to set the mindist to 2.0 Å.

Edit cryspy.in and change the value of tot_struc into 10, and add mindist_1 = 2.0

emacs cryspy.in
cat cryspy.in
[basic]
algo = RS
calc_code = soiap
tot_struc = 10
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8
mindist_1 = 2.0

[soiap]
soiap_infile = soiap.in
soiap_outfile = soiap.out
soiap_cif = initial.cif

[option]

Then run cryspy, and check log_cryspy file.

cryspy &
cat log_cryspy
...
(omit)
...

2023/03/19 00:01:47
CrySPY 1.0.0
Restart cryspy.py


Changed tot_struc from 5 to 10
Changed mindist from None to [[2.0]]

Backup data

# ---------- Append structures
# ------ mindist
Si - Si 2.0
Structure ID      5 was generated. Space group: 218 --> 221 Pm-3m
Structure ID      6 was generated. Space group:  86 --> 129 P4/nmm
Structure ID      7 was generated. Space group: 129 --> 129 P4/nmm
Structure ID      8 was generated. Space group: 191 --> 191 P6/mmm
Structure ID      9 was generated. Space group:  31 -->  31 Pmn2_1

Remember that CrySPY goes into structure generation mode whenever you change the value of tot_struc. In this mode, CrySPY does not do any other action such as collecting data, submitting jobs, and so on.

メモ

Structure generation mode whenever you change the value of tot_struc.
From version 1.0.0, CrySPY automatically backs up when adding structures. See features/backup.

Repeat cryspy & several times until all appended structures are done. The auto script may help you.

repeat_cryspy

Analysis and visualization

Download the data

It is assumed here that you analyze and visualize CrySPY data in your local PC. If you use CrySPY in super computers or workstations, download the data in your local PC. You can delete the work and backup directory if you do not need it because the file size could be very large.

jupyter notebook

Move to the data/ directory in results you just download. Then copy cryspy_analyzer_RS.ipynb from CrySPY utility.

$ ls
calc_in/ cryspy.in cryspy.stat  data/  err_cryspy  log_cryspy
$ cd data
$ ls
cryspy_rslt  cryspy_rslt_energy_asc  init_POSCARS  opt_CIFS.cif  opt_POSCARS  pkl_data/
cp /path/to/CrySPY_utility/cryspy_analyzer_RS.ipynb .

Run jupyter. (VScode, jupyter lab, jupyter notebook, and so on.) You can get the following figure by simply running the steps in order.

RS for Si8 RS for Si8

Load external data

You need only cryspy.in.

$ ls
cryspy.in

Then, run CyrSPY.

cryspy &

At the first run, CrySPY goes into structure generation mode as usual. CrySPY stops after 5 structure generation.

If it worked properly, log_cryspy would look like this.

2022/07/14 19:41:41
CrySPY 1.0.0
Start cryspy.py

Read input file, cryspy.in
Write input data in cryspy.out
Save input data in cryspy.stat

# --------- Generate initial structures
# ------ mindist
Si - Si 1.11
Structure ID      0 was generated. Space group:  88 --> 141 I4_1/amd
Structure ID      1 was generated. Space group: 101 --> 101 P4_2cm
Structure ID      2 was generated. Space group: 204 --> 229 Im-3m
Structure ID      3 was generated. Space group: 199 --> 199 I2_13
Structure ID      4 was generated. Space group:  12 -->  12 C2/m

Unlike normal use, a directory named ext was created. Only the stat_job file exists in ext/.

$ cat ext/stat_job
out

If you run cryspy when “out” is written in the stat_job file, queueing structure files (cif format) are exported in ext/queue.

cryspy &
$ ls ext/queue
0.cif  1.cif  2.cif  3.cif  4.cif

The number in the file name is structure ID. The fist line of stat_job was automatically changed.

$ cat ext/stat_job
submitted

Perform structure optimization and energy evaluation in an external program using the output cif files. Once that calculation is done, prepare the optimized structure and energy data in the pickle data format, ext_opt_struc_data.pkl and ext_energy_data.pkl.

The data format of ext_opt_struc_data.pkl is the same as init_struc_data.pkl and opt_struc_data.pkl, see Data format/Initial and optimized structure data.

The data format of ext_energy_data.pkl is similar to ext_opt_struc_data.pkl. Just change the value from the structure data into the energy. An example of the energy data (dict type) is shown below.

  • key: structure ID
  • value: energy
{0: -0.7139331910805997,
 1: -0.5643404689832622,
 2: -0.5832404287259171,
 3: -0.535037327286169,
 4: -0.6316663459586607}

The ext/calc_data directory should be automatically generated, so put the two pickle files here.

$ ls ext/calc_data
ext_energy_data.pkl  ext_opt_struc_data.pkl

When ready, replace the first line of the stat_job file with “done” and run CrySPY.

$ emacs /ext/stat_job
$ cat /ext/stat_job
done
cryspy &

CrySPY collects the result data.

Evolutionary Algorithm (EA)

EA

Bayesian Optimization (BO)

BO

LAQA

May 15th, 2023

情報

CrySPYの基本的な使い方に関してははじめにTutorial > Random Search (RS)を見ること.
ここではCrySPY 1.1.0以上を想定している.

ここで利用しているファイルはCrySPY Utility > Examples > qe_Si16_LAQAからダウンロードできる. このチュートリアルでは,50個だけ初期構造を生成しているが,本来LAQAでは,もっと多くの構造を生成しておいてそこから良い候補を選択することでシミュレーションを進める.

Input

cryspy.in

cryspy.inの例.

[basic]
algo = LAQA
calc_code = QE
tot_struc = 50
nstage = 1
njob = 10
jobcmd = qsub
jobfile = job_cryspy

[structure]
natot = 16
atype = Si
nat = 16
mindist_1 = 1.5

[QE]
qe_infile = pwscf.in
qe_outfile = pwscf.out
kppvol =  80

[LAQA]
nselect_laqa = 4

[option]
  • LAQAではnstageは1にする必要がある.
  • [LAQA]セクションのnselect_laqaだけ新しく設定する必要がある. nselect_laqaは一回の選択で選ばれる候補の数.

下記のようにwfwsを指定すれば,LAQAのスコアにおける重みも変えられる. 省略した場合,デフォルトでは0.1と10.0がそれぞれ使われる. スコアの詳細についてはSearching algorithms > LAQAを見ること.

[LAQA]
nselect_laqa = 4
wf = 0.1
ws = 10.0

calc_in/pwscf.in_1

&control
    calculation = 'vc-relax'
    pseudo_dir = '/usr/local/gbrv/all_pbe_UPF_v1.5/'
    outdir='./outdir/'
    nstep = 10
/

&system
    ibrav = 0
    nat = 16
    ntyp = 1
    ecutwfc = 40
    ecutrho = 200
    occupations = 'smearing'
    degauss = 0.01
/

&electrons
/

&ions
/

&cell
/

ATOMIC_SPECIES
  Si -1.0 si_pbe_v1.uspp.F.UPF
  • nstepで1回の選択で何ステップ構造最適化を進めるかをコントロールする.(VASPではNSW)

calc_in/job_cryspy

#!/bin/sh
#$ -cwd
#$ -V -S /bin/bash
####$ -V -S /bin/zsh
#$ -N Si_CrySPY_ID
#$ -pe smp 20
####$ -q ibis1.q
####$ -q ibis2.q

mpirun -np $NSLOTS pw.x -nk 4 < pwscf.in > pwscf.out

if [ -e "CRASH" ]; then
    sed -i -e '3 s/^.*$/skip/' stat_job
    exit 1
fi

sed -i -e '3 s/^.*$/done/' stat_job
  • ジョブスクリプトはいつも使っているものと同じ

Run

ヒント

自動化スクリプトも用意してある.このページの最下部参照.

cryspyと打って1回目の実行.

cryspy &

この入力ファイルではまず50構造生成されるのでlog_cryspyを見て確認する.

2023/05/13 13:02:07
CrySPY 1.1.0
Start cryspy.py
Number of MPI processes: 1

Read input file, cryspy.in
Save input data in cryspy.stat

# --------- Generate initial structures
# ------ mindist
Si - Si 1.5
Structure ID      0 was generated. Space group: 165 --> 165 P-3c1
Structure ID      1 was generated. Space group:  66 -->  66 Cccm
Structure ID      2 was generated. Space group: 146 --> 146 R3
Structure ID      3 was generated. Space group:  82 -->  82 I-4
Structure ID      4 was generated. Space group: 162 --> 162 P-31m
...
...
...
Structure ID     47 was generated. Space group:  90 -->  90 P42_12
Structure ID     48 was generated. Space group: 214 --> 214 I4_132
Structure ID     49 was generated. Space group:  23 -->  23 I222

Elapsed time for structure generation: 0:00:10.929030


# ---------- Initialize LAQA
# ---------- Selection 0
selected_id: 50 IDs

LAQAでは,はじめに全ての初期構造の最適化ジョブを実行する. 完全に最適化を終わらせるわけではなく,ここではnstep = 10にしているので,10ステップだけ実行される. cryspyコマンドを繰り返して,初期構造全てについて10ステップの最適化を完了させる. 必要であれば,njobの値を上げておけば一度に多くのジョブがサブミットされる.

初めの最適化が全て終わると, log_cryspyの最後にLAQA is readyと表示される.

2023/05/13 13:23:31
CrySPY 1.1.0
Restart cryspy.py
Number of MPI processes: 1



# ---------- job status
ID     41: Stage 1 Done!

LAQA is ready

この状態でcryspy を実行すると,最初の選択が始まる.

2023/05/13 13:23:33
CrySPY 1.1.0
Restart cryspy.py
Number of MPI processes: 1



# ---------- job status

Backup data

# ---------- Selection 1
selected_id: 37 8 10 48

nselect_laqaで設定された構造の数だけ選択される. cryspyをもう一度実行するとそれらのジョブ(次の10ステップ)がサブミットされる.

cryspy &
2023/05/13 13:23:36
CrySPY 1.1.0
Restart cryspy.py
Number of MPI processes: 1



# ---------- job status
ID     37: submit job, Stage 1
ID      8: submit job, Stage 1
ID     10: submit job, Stage 1
ID     48: submit job, Stage 1

あとはこれを何度も繰り返し行うことでスコアに応じて選択された構造の最適化が10ステップずつ進行する. ある程度の構造の最適化が完全に完了するまで進めて,止めたいタイミングでストップする.

Status

シミュレーションの途中でスコアの確認がしたければ次のファイルを見ると良い:

  • ./data/LAQA_status

他にもLAQAに関数ファイルがいくつか出力される:

  • ./data_LAQA_bias
  • ./data_LAQA_energy
  • ./data_LAQA_score
  • ./data_LAQA_selected_id
  • ./data_LAQA_step

Analysis and visualization

ここではCrySPYのデータをローカルPCで解析する. スパコンやワークステーションで計算を行ったら,ローカルPCにデータをダウンロードしておく. 今後必要なければ,ファイルサイズが大きいworkbackupディレクトリは削除しておいて良い. pklデータはgzipしておくとファイルサイズを減らすことができる.

jupyter notebook

ダウンロードした結果のdata/ディレクトリに移動して,cryspy_analyzer_LAQA.ipynbCrySPY utilityからコピーする.

このjupyter notebookを順番に実行していけば下記のようなグラフとgif画像が作成できる. この例では,アニメーションのために全ての構造の最適化を完全に完了させた. (全て最適化を完了させるとランダムサーチと計算量が変わらないのでLAQAの優位性はない)

fig_LAQA fig_LAQA

このグラフはエネルギーを最適化ステップの関数として示している. 赤い線は最終的にエネルギーが低かった3つの構造を表しており,中でも一番安定だった構造はダイアモンド構造に到達している. 安定になる構造はかなり早い段階で選択されて構造最適化が完了していることがわかる.

情報

algo = LAQAでは[option]セクションの下記の二つは自動的にTrueになる.

  • force_step_flag = True
  • stress_step_flag = True

原子に働く力とストレスのデータは1ステップごとに収集される. エネルギーと構造データは1ステップごとではなく,選択ごとに収集される. つまり,この場合は10ステップおきにエネルギーと構造データは保存される. もし1ステップごとのデータが欲しいのであれば,手動で下記の設定を追加すること.

[option]
energy_step_flag = True
struc_step_flag = True

Auto script

何度も繰り返しcryspyを実行するのは面倒に感じたかもしれない. 下記のようなスクリプトを使えば自動化できる.

repeat_cryspy

Molecular crystal structure prediction

情報

First, see Tutorial > Random Search (RS) for basic usage of CrySPY.

In this section, we give a tutorial on the molecular structure generation part only. Since version 0.9.0, CrySPY has been able to generate random molecular crystal structures using PyXtal.

You need to use a pre-defined molecular by PyXtal’s database (see, https://pyxtal.readthedocs.io/en/latest/Usage.html?highlight=benzene#pyxtal-molecule-pyxtal-molecule)) or create molecule files that define molecular structures.

Pre-defined molecule

PyXtal currently supports C60, H2O, CH4, NH3, benzene, naphthalene, anthracene, tetracene, pentacene, coumarin, resorcinol, benzamide, aspirin, ddt, lindane, glycine, glucose, and ROY.

Let us generate molecular crystal structures that consist of 2 benzenes.

Move to your working directory, and copy input example files by one of the following methods.

Take a look at cryspy.in.

$ cat cryspy.in
[basic]
algo = RS
calc_code = QE
tot_struc = 6
nstage = 2
njob = 2
jobcmd = qsub
jobfile = job_cryspy

[structure]
struc_mode = mol
natot = 24
atype = H C
nat = 12 12
mol_file = benzene
nmol = 2

[QE]
qe_infile = pwscf.in
qe_outfile = pwscf.out
kppvol = 40  60

[option]

In generating molecular crystal structures, you have to set struc_mode = mol in the [structure] section. Molecule file(s) and the number of molecule(s) are specified as:

  • mol_file = benzene
  • nmol = 2

Run CrySPY and see the initial structures (./data/init_POSCARS).

User-defined molecule

Move to your working directory, and copy input example files for 2 formula units of Li3PS4.

  • version 1.0.0 or later
    • Copy from CrySPY utility
  • version 0.10.3 or earlier
    • cp -r ~/CrySPY_root/CrySPY-0.9.0/example/QE_Li3PS4_2fu_RS_mol .
$ cd QE_Li3PS4_2fu_RS_mol
$ ls
Li.xyz  PS4.xyz  calc_in/  cryspy.in

Molecule files of Li and PS4 are included. Supported formats in PyXtal are .xyz, .gjf, .g03, .g09, .com, .inp, .out, and pymatgen’s JSON serialized molecules.

$ cat Li.xyz
1
New structure
 Li  0.000  0.000  0.000
$ cat PS4.xyz
5
New structure
 P    0.000000    0.000000    0.000000
 S    1.200000    1.200000   -1.200000
 S    1.200000   -1.200000    1.200000
 S   -1.200000    1.200000    1.200000
 S   -1.200000   -1.200000   -1.200000

Check cryspy.in.

$ cat cryspy.in
[basic]
algo = RS
calc_code = QE
tot_struc = 4
nstage = 2
njob = 1
jobcmd = qsub
jobfile = job_cryspy

[structure]
struc_mode = mol
natot = 16
atype = Li P S
nat = 6 2 8
mol_file = ./Li.xyz  ./PS4.xyz
nmol = 6 2

[QE]
qe_infile = pwscf.in
qe_outfile = pwscf.out
kppvol = 40  60

[option]

A single atom (Li atom in this case) is treated as a molecule in the molecular crystal structure generation mode. In this example, a random molecular structure is composed of six Li molecules (atoms) and two PS4 molecules specified as:

  • mol_file = ./Li.xyz ./PS4.xyz
  • nmol = 6 2

In mol_file, set relative path of molecule files from cryspy.in. Here the molecule files are placed in the same directory.

Run CrySPY and see the initial structures (./data/init_POSCARS).

timeout_mol

Molecular crystal structure generation can be time consuming because PyXtal calculates the molecule directions according to a specified space group. Sometimes molecular crystal structure generation gets stuck. So we set a time limit on the single structure generation. The time limit (timeout_mol) is set to 120 seconds by default. If the limit is insufficient, you have to increase it as (see last line):

struc_mode = mol
natot = 16
atype = Li P S
nat = 6 2 8
mol_file = ./Li.xyz  ./PS4.xyz
nmol = 6 2
timeout_mol = 300.0

Volume of unit cell

You can control the volume of unit cells by changing the value(s) of scaling factor, vol_factor, in cryspy.in. By default, vol_factor is set to 1.0. It is also possible to specify a range of factors. Set minimum and maximum values as follows:

struc_mode = mol
natot = 16
atype = Li P S
nat = 6 2 8
mol_file = ./Li.xyz  ./PS4.xyz
nmol = 6 2
timeout_mol = 300.0
vol_factor = 0.8 1.5

Random structure generation with MPI

2023/10/21 update

情報

CrySPYの基本的な使い方に関してはチュートリアル > Random Search (RS)を見ること.

情報

動作環境:

  • CrySPY 1.1.0 1.2.3 or later
  • mpi4py
  • MPI library (Open MPI, Intel MPI, MPICH, etc.)
警告

1.1.0 <= CrySPY <=1.2.2ではバグがあった. MPIを使ったジョブをbashやzshで実行するとき(e.g., jobcmd = zsh, jobfile = job_cryspy),MPIのジョブが流れない. qsubやsbatchでジョブスケジューラーを使う場合は問題ない。 このバグはバージョン1.2.3で修正.

mpi4py

mpi4pyのインストールがまだであればインストールする.

pip install mpi4py

入力ファイル

cryspy.inはいつもと同じで変更する必要はない.ここでは下記の設定でMPIを使った構造生成を行う.

[basic]
algo = RS
calc_code = soiap
tot_struc = 100
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8

[soiap]
soiap_infile = soiap.in
soiap_outfile = soiap.out
soiap_cif = initial.cif

[option]

tot_strucnatotatypenat以外の変数は構造生成に関係がないのでここでは無視して良い.

実行

4並列で実行する場合,mpiexec -nを使う.-pオプションも必要.

mpiexec -n 4 cryspy -p

In 1.1.0 <= CrySPY <= 1.2.2では下記のコマンド (-pオプションは使用しない)

mpiexec -n 4 cryspy

ジョブスケジューラーなどにサブミットするときは自分でジョブファイルを作る.下記は一例.

#!/bin/sh
#$ -cwd
#$ -V -S /bin/bash
#$ -N n_nproc
#$ -pe smp 4

mpirun -np $NSLOTS ~/.local/bin/cryspy

実行スクリプトcryspyのpathなどは適宜編集すること.

結果

CrySPYはシンプルに構造生成タスクをプロセス数で分割している.

  • Rank 0: IDs 0 – 24
  • Rank 1: IDs 25 – 49
  • Rank 2: IDs 50 – 74
  • Rank 3: IDs 75 – 99

構造が生成された順番でログが出力される.

2023/04/24 22:47:51
CrySPY 1.1.0
Start cryspy.py
Number of MPI processes: 4

Read input file, cryspy.in
Save input data in cryspy.stat

# --------- Generate initial structures
# ------ mindist
Si - Si 1.11
Structure ID     25 was generated. Space group: 138 --> 123 P4/mmm
Structure ID     75 was generated. Space group:  99 -->  99 P4mm
Structure ID      0 was generated. Space group: 127 --> 123 P4/mmm
Structure ID      1 was generated. Space group:  61 -->  61 Pbca
Structure ID     50 was generated. Space group:  38 -->  38 Amm2
Structure ID     51 was generated. Space group: 134 --> 123 P4/mmm
Structure ID     26 was generated. Space group: 111 --> 123 P4/mmm
Structure ID      2 was generated. Space group:   9 -->   9 Cc
Structure ID      3 was generated. Space group:  80 -->  80 I4_1
Structure ID      4 was generated. Space group: 107 --> 107 I4mm
Structure ID      5 was generated. Space group:  75 -->  75 P4
Structure ID     76 was generated. Space group: 108 --> 108 I4cm
Structure ID     77 was generated. Space group: 100 --> 100 P4bm
Structure ID     27 was generated. Space group: 207 --> 221 Pm-3m

しかし,init_POSCARSでは,構造生成が全て終わった後に出力しているのでID順になっている.

ID_0
1.0
   2.9636956737951818    0.0000000000000002    0.0000000000000002
   0.0000000000000000    2.9636956737951818    0.0000000000000002
   0.0000000000000000    0.0000000000000000    6.2634106638053080
Si
8
direct
  -0.1602734164607877   -0.1602734164607877   -0.0000000000000000 Si
   0.1602734164607877    0.1602734164607877    0.5000000000000000 Si
   0.6602734164607877    0.3397265835392123    0.7500000000000000 Si
   0.3397265835392122    0.6602734164607877    0.2500000000000000 Si
   0.4469739273741755    0.4469739273741755   -0.0000000000000000 Si
   0.5530260726258245    0.5530260726258244    0.5000000000000000 Si
   0.0530260726258245    0.9469739273741754    0.7500000000000000 Si
   0.9469739273741754    0.0530260726258245    0.2500000000000000 Si
ID_1
1.0
   7.2751506682509657    0.0000000000000004    0.0000000000000004
   0.0000000000000000    7.2751506682509657    0.0000000000000004
   0.0000000000000000    0.0000000000000000    5.1777634169924873
Si
8
direct
  -0.3845341807505553   -0.3845341807505553    0.4999999999999999 Si
   0.3845341807505553    0.3845341807505553    0.5000000000000000 Si
   0.3845341807505553   -0.3845341807505553    0.0000000000000000 Si
  -0.3845341807505553    0.3845341807505553   -0.0000000000000000 Si
   0.0000000000000000    0.5000000000000000    0.2500000000000000 Si
   0.5000000000000000    0.0000000000000000    0.7500000000000000 Si
   0.0000000000000000    0.5000000000000000    0.7500000000000000 Si
   0.5000000000000000    0.0000000000000000    0.2500000000000000 Si
ID_2
1.0
  -4.3660398676292269   -4.3660398676292269    0.0000000000000000
  -4.3660398676292269   -0.0000000000000003   -4.3660398676292269
   0.0000000000000000   -4.3660398676292269   -4.3660398676292269
Si
8
direct
   0.8700001548800920    0.8700001548800920    0.1299998451199080 Si
   0.1299998451199080    0.1299998451199080    0.8700001548800920 Si
   0.8700001548800920    0.1299998451199080    0.8700001548800920 Si
   0.1299998451199080    0.8700001548800920    0.1299998451199080 Si
   0.1299998451199080    0.8700001548800920    0.8700001548800920 Si
   0.8700001548800920    0.1299998451199080    0.1299998451199080 Si
   0.7500000000000000    0.7500000000000000    0.7500000000000000 Si
   0.2500000000000000    0.2500000000000000    0.2500000000000000 Si
メモ

ランダム構造生成以外の部分はMPIを使っても並列化されていないので意味はない.

探索アルゴリズム

目次

探索アルゴリズムのサブセクション

LAQA

Score $ L $

$$ L = -E + w_F \frac{F^2}{2\Delta F} + w_S S. $$
SymbolNote
$$ E $$エネルギー(eV/atom)
$$ w_F $$力の項の重み. Default: $ w_F = 0.1$
$$ F $$原子に働く力の平均ノルム(eV/Å)
$$ \Delta F $$一つ前のステップからの $ F $の差の絶対値.はじめのステップでは $ \Delta F = 1$$ \Delta F = 10^{-6}$ if $ \Delta F \le 10^{-6} $.
$$ w_S $$ストレス項の重み.Default: $ w_S = 10.0$
$$ S $$ストレステンソルにおける成分の絶対値平均(eV/Å^3).

Reference

構造生成のサブセクション

struc_mode = crystal

under construction

struc_mode = mol

under construction

struc_mode = mol_bs

CrySPY uses pyxtal in normal molecular crystal structure generation mode (struc_mode = mol). The molecules are arranged to fit a point group at a selected Wykoff position in the space group to keep the symmetry. (Sometimes it takes a long time to generate.)

In mol_bs mode (bs means break symmetry), dummy atoms are placed in Wykoff positions as in ordinary crystals, and then the dummy atoms are replaced by molecules without considering symmetry and rotated randomly. The structure generation is relatively fast.

under construction

機能のサブセクション

Logging

2023 July 10

CrySPY 1.2.0からPython標準ライブラリのloggingを採用. CrySPYのログは画面とファイル(log_cryspy and err_cryspy)の両方に出力される.

  • log –> screen and log_cryspy
  • error and warning –> screen and err_cryspy

ログの例:

[2023-07-10 18:40:54,389][cryspy_init][INFO] 


Start CrySPY 1.2.0


[2023-07-10 18:40:54,389][cryspy_init][INFO] # ---------- Read input file, cryspy.in
[2023-07-10 18:40:54,390][read_input][INFO] Save input data in cryspy.stat
[2023-07-10 18:40:54,391][cryspy_init][INFO] # ---------- Initial structure generation
[2023-07-10 18:40:54,391][cryspy_init][INFO] Number of MPI processes: 1
[2023-07-10 18:40:54,391][gen_init_struc][INFO] # ------ mindist
[2023-07-10 18:40:54,395][struc_util][INFO] Cu - Cu: 1.32
[2023-07-10 18:40:54,395][gen_init_struc][INFO] # ------ generate structures
[2023-07-10 18:40:54,481][gen_pyxtal][INFO] Structure ID      0 was generated. Space group:   1 -->   1 P1
[2023-07-10 18:40:54,493][gen_pyxtal][INFO] Structure ID      1 was generated. Space group:  28 -->  28 Pma2
[2023-07-10 18:40:54,498][gen_pyxtal][INFO] Structure ID      2 was generated. Space group:  29 -->  29 Pca2_1
[2023-07-10 18:40:54,704][gen_pyxtal][INFO] Structure ID      3 was generated. Space group: 137 --> 137 P4_2/nmc
[2023-07-10 18:40:54,725][gen_pyxtal][INFO] Structure ID      4 was generated. Space group: 212 --> 214 I4_132
[2023-07-10 18:40:54,800][cryspy_init][INFO] Elapsed time for structure generation: 0:00:00.408367

CrySPYをバックグラウンドジョブとして実行する場合や,自動スクリプト(repeat_cryspy)を使う場合などで,画面に出力させたくないときは下記のように-n オプションをつけて実行する.

cryspy -n

バックアップ

CrySPYはシンプルなバックアップ機能を備えている. バックアップの対象は以下のファイル:

  • cryspy.in
  • cryspy.stat
  • log_cryspy
  • err_cryspy
  • calc_in/*
  • data/*
  • ext/*

work/* は含まれいないので注意.

  • (v1.1.0以降) 上記ファイルが日付と時間で名前づけられたディレクトリにコピーされる.以前のバックアップは自動的には削除されない.
  • (v1.0.0) バックアップは1世代分のみであり,それより古いものは削除される.

自動バックアップ

自動的にバックアップされるタイミングは次の通り:

  • 次の選択に移るとき(BO, LAQA)か世代交代を行うとき (EA)
  • 構造を追加するとき

手動バックアップ

手動でバックアップを行いたい場合は,-b または --backup オプションをつけて次のようにcryspyを実行する:

cryspy -b

このコマンドは通常の実行とは異なり,バックアップだけを行います.

クリーン

CrySPYはシンプルなクリーン機能を備えている. 初めからやり直したい時に便利となる. 以下のファイルがクリーン(実際はファイルを移動するだけ)される.

  • cryspy.stat
  • log_cryspy
  • err_cryspy
  • lock_cryspy
  • data/*
  • work/*
  • ext/*
  • tmp_calc_FP/*
  • tmp_gen_struc/*

クリーンする場合は-c または --clean オプションをつけてcryspyを実行する:

$ ls
calc_in  cryspy.in  cryspy.stat  data  err_cryspy  log_cryspy
$ cryspy -c
Are you sure you want to clean the data? 'yes' or 'no' [y/n]: y
$ ls
calc_in  cryspy.in  trash
$ ls trash
20230318_100728

calc_in/*cryspy.in 以外のファイルがtrashの中の日付と時間で名前づけられたディレクトリに移動します. 必要なければ手動で削除してください.

Restriction on interatomic distances

2024年4月23日 更新

構造生成時に原子間距離の制限を行うことができる. 下記はA-B 2元系における[structure]セクションの最低原子間距離の設定例.

[structure]
natot = 8
atype = A B
nat = 4 4
mindist_1 = 2.0 1.8
mindist_2 = 1.8 1.5

原子A-A,B-BおよびA-B間の最低原子間距離がそれぞれ2.0,1.8および1.5 Åに設定されている. 原子間距離がこの値よりも小さい構造は自動的に棄却される.

3元系では mindist_1mindist_2およびmindist_3が必要になる. mindistの行列は対称行列でなければならない.

Example: Na8Cl8

Without mindist

cryspy.in

[basic]
algo = RS
calc_code = VASP
tot_struc = 5
nstage = 2
njob = 2
jobcmd = qsub
jobfile = job_cryspy

[structure]
natot = 16
atype = Na Cl
nat = 8 8

[VASP]
kppvol = 40 80

[option]

log_cryspy

[2024-04-23 13:46:28,598][cryspy_init][INFO] 


Start CrySPY 1.2.3


[2024-04-23 13:46:28,598][cryspy_init][INFO] # ---------- Read input file, cryspy.in
[2024-04-23 13:46:28,598][read_input][INFO] Save input data in cryspy.stat
[2024-04-23 13:46:28,599][gen_init_struc][INFO] # ------ mindist
[2024-04-23 13:46:28,601][struc_util][INFO] Na - Na: 1.66
[2024-04-23 13:46:28,602][struc_util][INFO] Na - Cl: 1.3399999999999999
[2024-04-23 13:46:28,602][struc_util][INFO] Cl - Cl: 1.02
...

fig_mindist fig_mindist

PyXtalのデフォルト設定では,上の図のように原子同士が近すぎる場合があるので,mindistを設定することをすすめる. DFT計算もやりやすくなるであろう.

With mindist

cryspy.in

[basic]
algo = RS
calc_code = VASP
tot_struc = 5
nstage = 2
njob = 2
jobcmd = qsub
jobfile = job_cryspy

[structure]
natot = 16
atype = Na Cl
nat = 8 8
mindist_1 = 2.5 1.5
mindist_2 = 1.5 2.5

[VASP]
kppvol = 40 80

[option]

log_cryspy

[2024-04-23 14:06:21,955][cryspy_init][INFO] 


Start CrySPY 1.2.3


[2024-04-23 14:06:21,955][cryspy_init][INFO] # ---------- Read input file, cryspy.in
[2024-04-23 14:06:21,956][read_input][INFO] Save input data in cryspy.stat
[2024-04-23 14:06:21,956][gen_init_struc][INFO] # ------ mindist
[2024-04-23 14:06:21,956][struc_util][INFO] Na - Na: 2.5
[2024-04-23 14:06:21,956][struc_util][INFO] Na - Cl: 1.5
[2024-04-23 14:06:21,956][struc_util][INFO] Cl - Cl: 2.5

イオン結晶のような場合には,カチオン同士,アニオン同士が離れるような設定をしておくと良い.

ジョブファイルのCrySPY_ID

CrySPYのジョブファイルで,“CrySPY_ID"という文字列は自動的に構造IDに置換される. PBSやSLURMなどのジョブスケジューラーを使う時,ジョブ名に構造IDを使うと便利である. 例えばPBSでは, #PBS -N Si_CrySPY_ID#PBS -N Si_10に置き換わる 大抵の場合,ジョブ名は数字から始められないことが多いので,Si_のように英字から始めておくと良い.

#!/bin/sh
#$ -cwd
#$ -V -S /bin/bash
####$ -V -S /bin/zsh
#$ -N Si8_CrySPY_ID
#$ -pe smp 8
####$ -q ibis1.q
####$ -q ibis2.q

mpirun -np $NSLOTS pw.x -nk 4 -nb 2 < pwscf.in > pwscf.out


if [ -e "CRASH" ]; then
    exit 1
fi

sed -i -e '3 s/^.*$/done/' stat_job

MPI並列化を用いた構造生成

2023/10/21 update

CrySPYのバージョン1.1.0(1.2.3以上の利用を推奨)からは,MPIを用いたランダム構造生成が可能になった. MPIを使うにはPython環境にmpi4pyをインストールする必要がある. 当然,計算に利用するワークステーション等にMPIライブラリ(Open MPI,Intel MPI,MPICHなど)も必要である.

情報

MPIを使うのに下記が必要

  • CrySPY 1.1.0 1.2.3 or later
  • mpi4py
  • MPI library (Open MPI, Intel MPI, MPICH, etc.)
警告

1.1.0 <= CrySPY <=1.2.2ではバグがあった. MPIを使ったジョブをbashやzshで実行するとき(e.g., jobcmd = zsh, jobfile = job_cryspy),MPIのジョブが流れない. qsubやsbatchでジョブスケジューラーを使う場合は問題ない。 このバグはバージョン1.2.3で修正.

下の図にSi8原子1000構造をランダムに生成するのにかかった時間とMPIプロセス数の関係を示す.下記のセッティングを使った.

[basic]
algo = RS
calc_code = soiap
tot_struc = 1000
nstage = 1
njob = 2
jobcmd = zsh
jobfile = job_cryspy

[structure]
natot = 8
atype = Si
nat = 8
mindist_1 = 2.2

mindset_1 = 2.2のように厳し目に設定して,わざと時間がかかるようにしてある. それぞれのプロセス数において10回ずつ実行して,平均を線で結んでいる.

fig_MPI fig_MPI

Run

mpiexec -n 4 cryspy -p

Enthalpy

2023/10/18

情報

Requirements:

  • CrySPY 1.2.2 or later
  • VASP or QE

高圧化における構造探索を行う時に, エネルギーの代わりにエンタルピーを使うことができる. VASPとQE以外はまだ未対応.

cryspy_rsltcryspy_rslt_energy_ascE_eV_atomの箇所がエンタルピー(eV/atom)に変わる. 下記は40 GPaにおけるSr4O4の構造探索の結果の例. 高圧下ではCsCl型構造(ID 5)がNaCl型構造よりも安定になっている.

   Spg_num Spg_sym  Spg_num_opt Spg_sym_opt  E_eV_atom  Magmom      Opt
5       26  Pmc2_1          221       Pm-3m  -2.276790     NaN     done
6      225   Fm-3m          225       Fm-3m  -2.244800     NaN     done
1      101  P4_2cm          107        I4mm  -2.181115     NaN     done
4      123  P4/mmm          123      P4/mmm  -2.034509     NaN  not_yet
3       20  C222_1           63        Cmcm  -0.686541     NaN     done
2       75      P4           75          P4  -0.008713     NaN  not_yet
9       51    Pmma           47        Pmmm   0.096430     NaN     done
8       65    Cmmm          123      P4/mmm   1.099657     NaN     done
0      187   P-6m2          187       P-6m2   1.292124     NaN     done
7       53    Pmna           53        Pmna   5.153504     NaN  not_yet

VASP

CrySPYではOSZICARからエネルギー(エンタルピー)を読んでいる. これはPSTRESSINCAR_xで以下のようにセットされると自動的にエンタルピーに変わる:

PSTRESS = 400

cryspy.inでは特に何もする必要はない. energy_step_flagのオプションも使用可能でエンタルピーを読み込める.

Example: CrySPY Utility > Examples > vasp_Sr4O4_RS_pv_term

QE

エンタルピーを読むためにはcryspy.inのQEセクションでpv_term = Trueをつける:

[QE]
qe_infile = pwscf.in
qe_outfile = pwscf.out
kppvol =  40  80
pv_term = True

QEの入力ファイルでもpressの設定を忘れずに:

 &cell
    press = 400
 /
警告

QEではenergy_step_flagオプションでエンタルピーを読むことにまだ未対応.

Example: CrySPY Utility > Examples > qe_Sr4O4_RS_pv_term

入力ファイルのサブセクション

File format

CrySPY uses the configparser module to read input file, cryspy.in . cryspy.in consists of sections, led by a [section] header and followed by name = value or name : value entries. Section names and values are case sensitive, but names are not. Lines beginning with # or ; are ignored and may be used to provide comments. Accepted bool values are 1, yes, true, and on, which cause this method to return True, and 0, no, false, and off, which cause it to return False. These string values for bool are checked in a case-insensitive manner. Some values are given in a space-separated manner.

情報

See configparser in detail.

メモ

section name: case sensitive
name: case insensitive
value: case sensitive except for bool

[basic] section

NameValueDefaultDescription
algoRS, EA, BO, LAQAAlgorithm
calc_codeVASP, QE, OMX, soiap, LAMMPSCaluculation code for structure optimization
tot_strucintThe total number of structures
nstageintThe number of stages
njobintThe number of jobs running at the same time.
jobcmdstrCommand to submit jobs such as qsub and sbatch.
jobfilestrFile name of the job file.

[structure] section

NameValueDefaultDescription
struc_modecrystal, mol, mol_bscrystalStructure generation mode
natotintThe total number of atoms.
atypeatomic symbol [atomic symbol …]Atom type. e.g. atype = Na Cl.
natint [int …]The number of atoms in each atom type. e.g. nat = 8 8.
mol_filestr [str …], NoneNonePath of molecule files or molecule names.
nmolint [int …], NoneNoneThe number of molecules.
timeout_molfloat120.0Time out for molecular structure generation.
rot_molrandom, random_mol, random_wyckoffrandom_wyckoffMode for rotation of molecules.
nrotint20Maximum number of trials to rotate molecules in mol_bs
vol_factorfloat float1.0 1.0Minimum and maximum values of volume factor.
vol_mufloat, NoneNoneMean of volume if you want specify the volume of cells.
vol_sigmafloat, NoneNoneStandard deviation of volume if you want specify the volume of cells.
mindist (mindist_?)float [float …], NoneNoneConstraint on minimum interatomic distance [Å].
mindist_factorfloat1.0Scaling factor for mindist.
mindist_mol_bs (mindist_mol_bs_?)float [float …], NoneNoneConstraint on minimum intermolecular distance [Å].
mindist_mol_bs_factorfloat1.0Scaling factor for mindist_mol_bs.
symprecfloat,0.01Precision for symmetry finding.
spgnumall, space group number, 0allConstraint on space group. If all, 1–230. If 0, random structure without space group information (no symmetry).
use_find_wyboolFalseStructure generation with find_wy.
fwpathstr, NoneNonePath of find_wy
minlenfloat, NoneNoneOnly used with find_wy or spgnum = 0. Minimum length of lattice vector [Å].
maxlenfloat, NoneNoneOnly used with find_wy or spgnum = 0. Maximum length of lattice vector [Å].
danglefloat, NoneNoneOnly used with find_wy or spgnum = 0. Delta angle for alpha, beta, and gamma in degree unit.
maxcntint50Only used with find_wy or spgnum = 0. Maximum number of trials to determine atom positions.

mindist

[VASP] section

VASPを使う場合は(calc_code = VASP)[VASP]セクションが必要になる.

NameValueDefaultDescription
kppvolint [int …]各ステージにおける逆格子空間でのÅ**(-3)あたりのグリッド密度.
force_gammaboolFalseTrueなら常にガンマ点を通るメッシュを使う.

kppvol and force gamma

[QE] section

[QE] section is required only if you use QE (calc_code = QE)

NameValueDefaultDescription
kppvolint [int …]Grid density per Å**(-3) of reciprocal cell in each stage
qe_infilestrFile name of QE input file.
qe_outfilestrFile name of QE output file.
pv_termboolFalseIf true, read enthalpy instead of total energy.

kppvol

pv_term

[OMX] section

[OMX] section is required only if you use OpenMX (calc_code = OMX)

NameValueDefaultDescription
kppvolint [int …]Grid density per Å**(-3) of reciprocal cell in each stage
OMX_infilestrFile name of OpenMX input file.
OMX_outfilestrFile name of OpenMX output file.
ValenceElectronsstr float float [str float float …]The number of initial charges for up and down spin states.

kppvol

ValenceElectrons

e.g. in NaCl: ValenceElectrons = Na 4.5 4.5 Cl 3.5 3.5.

[soaip] section

[soiap] section is required only if you use soiap (calc_code = soiap)

NameValueDefaultDescription
soiap_infilestrFile name of soiap input file.
soiap_outfilestrFile name of soiap output file.
soiap_cifstrFile name of soiap CIF-formatted initial structure.

[LAMMPS] section

[LAMMPS] section is required only if you use LAMMPS (calc_code = LAMMPS)

NameValueDefaultDescription
lammps_infilestrFile name of LAMMPS input file.
lammps_outfilestrFile name of LAMMPS output file.
lammps_potentialstr [str …], NoneNonePotential.
lammps_datastrFile name of LAMMPS data file.

[ASE] section

[ASE] section is required only if you use ASE (calc_code = ASE)

NameValueDefaultDescription
ase_pythonstrFile name of ASE input file.

[EA] section

2024年5月7日 更新

[EA] section is required only if you use EA (algo = EA)

NameValueDefaultDescription
n_popintPopulation from second generation.
n_crsovintThe number of structures generated by crossover.
n_permintThe number of structures generated by permutation.
n_strainintThe number of structures generated by strain.
n_randintThe number of structures generated randomly.
n_eliteintThe number of elite structures.
fit_reverseboolFalseIf False, minimal search.
n_fittestintNoneThe number of structures which can survive.
slct_funcTNM, RLTSelect function.
t_sizeint3Only used with slct_func = TNM. Tournament size.
a_rltfloat10.0Only used with slct_func = RLT. Parameter for linear scaling.
b_rltfloat1.0Only used with slct_func = RLT. Parameter for linear scaling.
crs_latequal, randomrandomHow to mix lattice vectors.
nat_diff_toleint4Tolerance for difference in the number of atoms in crossover.
ntimesint1The number of times in permutation.
sigma_stfloat0.5Standard deviation for strain.
maxcnt_eaint50Maximum number of trials in EA.
maxgen_eaint0Maximum generation.
emax_eafloatNoneUpper limit of energy in selecting parents.
emin_eafloatNoneLower limit of energy in selecting parents.

[BO] section

[BO] section is required only if you use BO (algo = BO)

NameValueDefaultDescription
nselect_bointThe number of structures to be selected at once.
scoreTS, EI, PIAcquisition function.
num_rand_basisintIf 0, Gaussian process. The number of basis function.
cdevfloat0.001Cutoff of deviation for standardization.
dscrptFPDescriptor for structures.
fppathstr, NoneNoneOnly used with dscrpt = FP. Path of cal_fingerprint.
fp_rminfloat0.5Only used with dscrpt = FP. Minimum cutoff of r in fingerprint.
fp_rmaxfloat5.0Only used with dscrpt = FP. Maximum cutoff of r in fingerprint.
fp_npointsint20Only used with dscrpt = FP. Number of discretized points for each pair in fingerprint.
fp_sigmafloat1.0Only used with dscrpt = FP. Sigma parameter [Å] in Gaussian smearing function.
max_select_boint0Maximum number of selection.
manual_select_boint [int …][]Structure IDs to be selected manually.
emax_bofloatNoneUpper limit of energy in BO.
emin_bofloatNoneLower limit of energy in BO.

[LAQA] section

LAQA (algo = LAQA)を使う場合,[LAQA]セクションが必要.

NameValueDefaultDescription
nselect_laqaint1度の選択で選ばれる構造の数.
wffloat0.1力の項の重み.
wsfloat10.0ストレス項の重み.
情報

algo = LAQAでは[option]セクションの下記の二つは自動的にTrueになる.

  • force_step_flag = True
  • stress_step_flag = True

原子に働く力とストレスのデータは1ステップごとに収集される. エネルギーと構造データは1ステップごとではなく,選択ごとに収集される. つまり,この場合は10ステップおきにエネルギーと構造データは保存される. もし1ステップごとのデータが欲しいのであれば,手動で下記の設定を追加すること.

[option]
energy_step_flag = True
struc_step_flag = True

[option] section

NameValueDefaultDescription
stop_chkptint0CrySPY stops at a specified check point.
load_struc_flagboolFalseIf True, load initial structures from ./data/pkl_data/init_struc_data.pkl.
stop_next_strucboolFalseIf True, CrySPY does not submit jobs for next structures, but jobs for next stage are submitted.
recalcint [int …](empty list)Specify structure IDs if you want to recalculate or continue optimization.
append_struc_eaboolFalseIf True, append structures by EA.
energy_step_flagboolFalseIf True, save energy_step_data in ./data/pkl_data/energy_step_data.pkl.
struc_step_flagboolFalseIf True, save struc_step_data in ./data/pkl_data/struc_step_data.pkl.
force_step_flagboolFalseIf True, save force_step_data in ./data/pkl_data/force_step_data.pkl.
stress_step_flagboolFalseIf True, save stress_step_data in ./data/pkl_data/stress_step_data.pkl.

Kpoint

2024年4月22日

CrySPYではk-pointのセッティングはpymatgenpymatgen.io.vasp.Kpoints.automatic_density_by_vol関数を使って自動生成している. 以下はcryspy.innstage = 2の場合の例:

[VASP]
kppvol = 40 120
  • stage 1: kppvol = 40
  • stage 2: kppvol = 120

kppvolは逆格子空間でのÅ ${}^{-3} $あたりのグリッド密度.
VASP:hexagonalとface-centeredセルではガンマ点を通るメッシュが使われ,それ以外ではMonkhorst-Packが使われる.
QE and OMX:kメッシュだけ利用,オフセットは設定しない.

kppvolの値はどれくらいが適切か?

下記を参考に.結晶構造の画像はVESTAを使用.

Primitive cell of diamond Si

fig_prim_diamond fig_prim_diamond

a = b = c = 3.836 Å

kppvolk-mesh
0[1, 1, 1]
20[4, 4, 4]
40[6, 6, 6]
60[7, 7, 7]
80[7, 7, 7]
100[8, 8, 8]
120[9, 9, 9]
140[9, 9, 9]
160[9, 9, 9]
180[10, 10, 10]
200[10, 10, 10]
400[13, 13, 13]
600[15, 15, 15]
800[17, 17, 17]

Conventional cell of diamond Si

fig_conv_diamond fig_conv_diamond

a = b = c = 5.431 Å

kppvolk-mesh
0[1, 1, 1]
20[3, 3, 3]
40[3, 3, 3]
60[4, 4, 4]
80[4, 4 ,4]
100[5, 5, 5]
120[5, 5, 5]
140[6, 6, 6]
160[6, 6, 6]
180[6, 6, 6]
200[6, 6, 6]
400[8, 8, 8]
600[9, 9, 9]
800[10, 10, 10]

Nd2Fe14B

fig_Nd2Fe12B fig_Nd2Fe12B

a = b = 8.804 Å
c = 12.205 Å

kppvolk-mesh
0[1, 1, 1]
20[1, 1, 1]
40[2, 2, 1]
60[2, 2, 2]
80[3, 3 ,2]
100[3, 3, 2]
120[3, 3, 2]
140[3, 3, 2]
160[3, 3, 2]
180[4, 4, 2]
200[4, 4, 3]
400[5, 5, 3]
600[6, 6, 4]
800[6, 6, 4]

データフォーマットのサブセクション

Common dataのサブセクション

Initial and optimized structure data

Initial and optimized structure data are saved in init_struc_data.pkl and opt_struc_data.pkl, respectively. pymatgen library is required to analyze these data files.

Data format

  • type: dict
    • key: structure ID
    • value: structure data
  • string form
    • {0: Structure Summary …,
      1: Structure Summary …,
      …}
  • structure data format

How to access

import pickle
with open('init_struc_data.pkl', 'rb') as f:
   init_struc_data = pickle.load(f)
with open('opt_struc_data.pkl', 'rb') as f:
   opt_struc_data = pickle.load(f)

# struc_step_data[ID]
#
#

# ---------- structure step data of ID 0
cid = 0      # ID
init_struc_data[cid]    # to show initial structure of ID 0
Structure Summary
Lattice
    abc : 5.727301 5.727301 4.405757
 angles : 90.0 90.0 90.0
 volume : 144.5175386563631
      A : 5.727301 0.0 0.0
      B : 0.0 5.727301 0.0
      C : 0.0 0.0 4.405757
PeriodicSite: Si (0.2506, 5.4767, 1.1014) [0.0438, 0.9562, 0.2500]
PeriodicSite: Si (2.6130, 3.1143, 1.1014) [0.4562, 0.5438, 0.2500]
PeriodicSite: Si (3.1143, 0.2506, 1.1014) [0.5438, 0.0438, 0.2500]
PeriodicSite: Si (5.4767, 2.6130, 1.1014) [0.9562, 0.4562, 0.2500]
PeriodicSite: Si (5.4767, 0.2506, 3.3043) [0.9562, 0.0438, 0.7500]
PeriodicSite: Si (3.1143, 2.6130, 3.3043) [0.5438, 0.4562, 0.7500]
PeriodicSite: Si (2.6130, 5.4767, 3.3043) [0.4562, 0.9562, 0.7500]
PeriodicSite: Si (0.2506, 3.1143, 3.3043) [0.0438, 0.5438, 0.7500]

Result data

Common result data such as space group, energies, etc. are saved in rslt_data.pkl. pandas library is required to analyze this data file.

Data format

  • type: pandas.core.frame.DataFrame
    • row lable: structure ID
  • string form
    • see blow

How to access

import pickle
with open('rslt_data.pkl', 'rb') as f:
   rslt_data = pickle.load(f)


# ---------- sort by Energy
# top 5
rslt_data.sort_values(by=['E_eV_atom']).head(5)
   Spg_num Spg_sym  Spg_num_opt Spg_sym_opt  E_eV_atom  Magmom      Opt
1       98  I4_122           12        C2/m  -3.978441     NaN  not_yet
3       36  Cmc2_1           36      Cmc2_1  -3.520306     NaN  not_yet
2       16    P222           16        P222  -3.348616     NaN  not_yet
4       36  Cmc2_1            4        P2_1  -3.304168     NaN  not_yet
0      139  I4/mmm          139      I4/mmm  -3.000850     NaN     done

Random Search (RS)

Table of contents

    Evolutionary algorithm (EA)

    Table of contents

      Bayesian Optimization (BO)

      Table of contents

        LAQA

        Table of contents

          オプションデータのサブセクション

          Energy step data

          Energy step data is saved in energy_step_data.pkl if you set energy_step_flag = True in [option] section of cryspy.in. NumPy library is required to analyze this data file.

          警告

          energy_step_flag = True is currently available only with VASP, QE, and soiap.

          情報

          In soiap, energy_step_data is collected only if loopa == 1. This is because other data (struc, force, and stress) are output only when loopa == 1. See, https://github.com/nbsato/soiap/blob/master/doc/instructions.md

          Data format

          • type: dict
            • key: structure ID
            • value: list of energy step data in each stage
          • string form
            • {0: [array([-3.4439912 , -3.55040935, -3.66697038, ..]), array([-4.0613393 , -4.05445631, -4.06159641, …]), …],
              1: [array([-2.68209823, -2.69012487, -2.68364907, ..]), array([-2.79140967, -2.79183827, -2.79206508, …]), …],
              …}
          • unit of energy
            • eV/atom

          How to access

          import pickle
          with open('energy_step_data.pkl', 'rb') as f:
              energy_step_data = pickle.load(f)
          
          # energy_step_data[ID][stage][step]
          # energy_step_data[ID][0] <-- stage 1
          # energy_step_data[ID][1] <-- stage 2
          #
          # in LAQA
          # energy_step_data[ID][selection][step]
          # energy_step_data[ID][0] <-- 1st selection
          # energy_step_data[ID][1] <-- 2nd selection
          
          # ---------- energy step data of ID 3, stage 1
          cid = 3      # ID
          stage = 1    # stage
          energy_step_data[cid][stage-1][:10]    # show only 10 enegies in jupyter
          
          array([-3.4439912 , -3.55040935, -3.66697038, -3.77192063, -3.84320717,
                 -3.80679245, -3.84633935, -3.87374706, -3.89123193, -3.90422926])
          

          Structure step data

          Structure step data is saved in struc_step_data.pkl if you set struc_step_flag = True in [option] section of cryspy.in. pymatgen library is required to analyze this data file.

          警告

          struc_step_flag = True is currently available only with VASP, QE, and soiap.

          情報

          struc_step_data includes initial structures. For example, struc_step_data[cid][0][0] is the initial structure of ID = cid.

          Data format

          • type: dict
            • key: structure ID
            • value: list of structure step data in each stage
          • string form
            • {0: [[Structure Summary …, Structure Summary, …], […], …],
              1: [[Structure Summary …, Structure Summary, …], […], …],
              …}
          • structure data format

          How to access

          import pickle
          with open('struc_step_data.pkl', 'rb') as f:
              struc_step_data = pickle.load(f)
          
          # struc_step_data[ID][stage][step]
          # struc_step_data[ID][0] <-- stage 1
          # struc_step_data[ID][1] <-- stage 2
          #
          #
          # in LAQA
          # struc_step_data[ID][selection][step]
          # struc_step_data[ID][0] <-- 1st selection
          # struc_step_data[ID][1] <-- 2nd selection
          
          # ---------- structure step data of ID 3, stage 1, step 4
          cid = 0      # ID
          stage = 1    # stage
          step = 0     # step index (start from 0)
          struc_step_data[cid][stage-1][step]    # to show initial structure of ID 0 at stage 1 in jupyter
          
          Structure Summary
          Lattice
              abc : 5.727301 5.727301 4.405757
           angles : 90.0 90.0 90.0
           volume : 144.5175386563631
                A : 5.727301 0.0 0.0
                B : 0.0 5.727301 0.0
                C : 0.0 0.0 4.405757
          PeriodicSite: Si (0.2506, 5.4767, 1.1014) [0.0438, 0.9562, 0.2500]
          PeriodicSite: Si (2.6130, 3.1143, 1.1014) [0.4562, 0.5438, 0.2500]
          PeriodicSite: Si (3.1143, 0.2506, 1.1014) [0.5438, 0.0438, 0.2500]
          PeriodicSite: Si (5.4767, 2.6130, 1.1014) [0.9562, 0.4562, 0.2500]
          PeriodicSite: Si (5.4767, 0.2506, 3.3043) [0.9562, 0.0438, 0.7500]
          PeriodicSite: Si (3.1143, 2.6130, 3.3043) [0.5438, 0.4562, 0.7500]
          PeriodicSite: Si (2.6130, 5.4767, 3.3043) [0.4562, 0.9562, 0.7500]
          PeriodicSite: Si (0.2506, 3.1143, 3.3043) [0.0438, 0.5438, 0.7500]
          

          Force step data

          Force step data is saved in force_step_data.pkl if you set force_step_flag = True in [option] section of cryspy.in. NumPy library is required to analyze this data file.

          警告

          force_step_flag = True is currently available only with VASP, QE, and soiap.

          Data format

          • type: dict
            • key: structure ID
            • value: list of force step data in each stage
          • string form
            • {0: [array([[ 0.26314927, -0.26314927, -0. ], […], …[…]]), array([[…], …, […]]), …],
              1: [array([[ 0. , 0. , 0. ], […], …[…]]), array([[…], …, […]]), …],
              …}
          • unit of force
            • eV/Å

          How to access

          import pickle
          with open('force_step_data.pkl', 'rb') as f:
              force_step_data = pickle.load(f)
          
          # force_step_data[ID][stage][step][atom]
          # force_step_data[ID][0] <-- stage 1
          # force_step_data[ID][1] <-- stage 2
          #
          # in LAQA
          # force_step_data[ID][selection][step][atom]
          # force_step_data[ID][0] <-- 1st selection
          # force_step_data[ID][1] <-- 2nd selection
          
          # ---------- force step data of ID 3, stage 1
          cid = 0      # ID
          stage = 1    # stage
          force_step_data[cid][stage-1][:3]    # to show only 3 steps in jupyter 
          
          [array([[ 0.26314927, -0.26314927, -0.        ],
                  [-0.26314927,  0.26314927, -0.        ],
                  [ 0.26314927,  0.26314927,  0.        ],
                  [-0.26314927, -0.26314927, -0.        ],
                  [-0.26314927,  0.26314927, -0.        ],
                  [ 0.26314927, -0.26314927,  0.        ],
                  [-0.26314927, -0.26314927, -0.        ],
                  [ 0.26314927,  0.26314927,  0.        ]]),
           array([[-0.12103692,  0.12103692,  0.        ],
                  [ 0.12103692, -0.12103692, -0.        ],
                  [-0.12103692, -0.12103692, -0.        ],
                  [ 0.12103692,  0.12103692,  0.        ],
                  [ 0.12103692, -0.12103692, -0.        ],
                  [-0.12103692,  0.12103692,  0.        ],
                  [ 0.12103692,  0.12103692,  0.        ],
                  [-0.12103692, -0.12103692, -0.        ]]),
           array([[-0.29801618,  0.29801618,  0.        ],
                  [ 0.29801618, -0.29801618, -0.        ],
                  [-0.29801618, -0.29801618, -0.        ],
                  [ 0.29801618,  0.29801618,  0.        ],
                  [ 0.29801618, -0.29801618, -0.        ],
                  [-0.29801618,  0.29801618,  0.        ],
                  [ 0.29801618,  0.29801618,  0.        ],
                  [-0.29801618, -0.29801618, -0.        ]])]
          
          step = 0     # step index (start from 0)
          atom = 2     # atom index (start from 0)
          force_step_data[cid][stage-1][step][atom]
          
          array([0.26314927, 0.26314927, 0.        ])
          

          Stress step data

          Stress step data is saved in stress_step_data.pkl if you set stress_step_flag = True in [option] section of cryspy.in. NumPy library is required to analyze this data file.

          警告

          stress_step_flag = True is currently available only with VASP, QE, and soiap.

          Data format

          • type: dict
            • key: structure ID
            • value: list of stress step data in each stage
          • string form
            • {0: [array([[-0.16770062, 0. , 0. ], […], […]]), array([[…], ]…], […]]), …],
              1: [array([[ 0.39260083, -0. , -0. ], […], […]]), array([[…], […], […]]), …],
              …}
          • unit of stress
            • eV/(Å**3)

          How to access

          import pickle
          with open('stress_step_data.pkl', 'rb') as f:
              stress_step_data = pickle.load(f)
          
          # stress_step_data[ID][stage][step][atom]
          # stress_step_data[ID][0] <-- stage 1
          # stress_step_data[ID][1] <-- stage 2
          #
          # in LAQA
          # stress_step_data[ID][selection][step][atom]
          # stress_step_data[ID][0] <-- 1st selection
          # stress_step_data[ID][1] <-- 2nd selection
          
          # ---------- stress step data of ID 3, stage 1
          cid = 0      # ID
          stage = 1    # stage
          stress_step_data[cid][stage-1][:3]    # to show only 3 steps in jupyter 
          
          [array([[-0.16770062,  0.        ,  0.        ],
                  [ 0.        , -0.16770062, -0.        ],
                  [ 0.        ,  0.        ,  0.21823358]]),
           array([[-0.16020785, -0.        , -0.        ],
                  [-0.        , -0.16020785,  0.        ],
                  [-0.        ,  0.        ,  0.18646321]]),
           array([[-0.13572003, -0.        ,  0.        ],
                  [-0.        , -0.13572003,  0.        ],
                  [-0.        ,  0.        ,  0.15953926]])]
          

          CrySPY Utilityのサブセクション

          Examplesのサブセクション

          ase_chgnet_Sr4Co4O12

          Download

          ase_chgnet_RS_Sr4Co4O12.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = ASE
          tot_struc = 10
          nstage = 1
          njob = 2
          jobcmd = bash
          jobfile = job_cryspy
          
          [structure]
          natot = 20
          atype = Sr Co O
          nat = 4  4  12
          mindist_1 = 2.2  2.0  1.8
          mindist_2 = 2.0  2.2  1.5
          mindist_3 = 1.8  1.5  2.0
          
          [ASE]
          ase_python = chgnet_in.py
          
          [option]
          

          calc_in/

          chgnet_in.py_1

          from chgnet.model import StructOptimizer
          from pymatgen.core import Structure
          
          
          # ---------- input structure
          # CrySPY outputs 'POSCAR' as an input file in work/xxxxxx directory
          structure = Structure.from_file('POSCAR')
          
          # ---------- relax
          relaxer = StructOptimizer()
          result = relaxer.relax(atoms=structure, fmax=0.01, steps=2000)
          
          # ---------- opt. structure and energy
          # [rule in ASE interface]
          # output file for energy: 'log.tote' in eV/cell
          #                         CrySPY reads the last line of 'log.tote'
          # output file for structure: 'CONTCAR' in vasp format
          # ------ energy
          traj = result['trajectory']
          e = traj.compute_energy()   # eV/cell
          with open('log.tote', mode='w') as f:
              f.write(str(e))
          # ------ struc
          opt_struc = result["final_structure"]
          opt_struc.to(fmt='poscar', filename='CONTCAR')
          

          job_cryspy

          #!/bin/sh
          
          # ---------- ASE
          python3 chgnet_in.py > out.log
          
          # ---------- for error
          if [ ! -f "log.tote" ]; then
              sed -i -e '3 s/^.*$/skip/' stat_job
              exit 1
          fi
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          ase_Cu8_RS

          Download

          ase_Cu8_RS.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = ASE
          tot_struc = 5
          nstage = 1
          njob = 2
          jobcmd = zsh
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Cu
          nat = 8
          
          [ASE]
          ase_python = ase_in.py
          
          [option]
          

          calc_in/

          ase_in.py_1

          from ase.constraints import ExpCellFilter, StrainFilter
          from ase.calculators.emt import EMT
          from ase.calculators.lj import LennardJones
          from ase.optimize.sciopt import SciPyFminCG
          from ase.optimize import BFGS
          from ase.spacegroup.symmetrize import FixSymmetry
          import numpy as np
          from ase.io import read, write
          
          # ---------- input structure
          # CrySPY outputs 'POSCAR' as an input file in work/xxxxxx directory
          atoms = read('POSCAR', format='vasp')
          
          # ---------- setting and run
          atoms.calc = EMT()
          atoms.set_constraint([FixSymmetry(atoms)])
          atoms = ExpCellFilter(atoms, hydrostatic_strain=False)
          opt = BFGS(atoms)
          #opt=SciPyFminCG(atoms)
          opt.run()
          
          # ---------- opt. structure and energy
          # [rule in ASE interface]
          # output file for energy: 'log.tote' in eV/cell
          #                         CrySPY reads the last line of 'log.tote'
          # output file for structure: 'CONTCAR' in vasp format
          e = atoms.atoms.get_total_energy()
          with open('log.tote', mode='w') as f:
              f.write(str(e))
          
          write('CONTCAR', atoms.atoms, format='vasp')
          

          job_cryspy

          #!/bin/sh
          
          # ---------- ASE
          python3 ase_in.py
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          soiap_Si8_RS

          Download

          soiap_Si8_RS.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = soiap
          tot_struc = 5
          nstage = 1
          njob = 2
          jobcmd = zsh
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Si
          nat = 8
          
          [soiap]
          soiap_infile = soiap.in
          soiap_outfile = soiap.out
          soiap_cif = initial.cif
          
          [option]
          

          calc_in/

          soiap.in_1

          crystal initial.cif ! CIF file for the initial structure
          symmetry 1 ! 0: not symmetrize displacements of the atoms or 1: symmetrize
          
          md_mode_cell 3 ! cell-relaxation method
                         ! 0: FIRE, 2: quenched MD, or 3: RFC5
          number_max_relax_cell 1000 ! max. number of the cell relaxation
          number_max_relax 1 ! max. number of the atom relaxation
          max_displacement 0.1 ! max. displacement of atoms in Bohr
          
          external_stress_v 0.0 0.0 0.0 ! external pressure in GPa
          
          th_force 5d-5 ! convergence threshold for the force in Hartree a.u.
          th_stress 5d-7 ! convergence threshold for the stress in Hartree a.u.
          
          force_field 1 ! force field
                        ! 1: Stillinger-Weber for Si, 2: Tsuneyuki potential for SiO2,
                        ! 3: ZRL for Si-O-N-H, 4: ADP for Nd-Fe-B, 5: Jmatgen, or
                        ! 6: Lennard-Jones
          

          job_cryspy

          #!/bin/sh
          
          # ---------- soiap
          EXEPATH=/path/to/soiap
          $EXEPATH/soiap soiap.in > soiap.out 2>&1
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          soiap_Si8_RS_mindist

          Download

          soiap_Si8_RS_mindist.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = soiap
          tot_struc = 5
          nstage = 1
          njob = 2
          jobcmd = zsh
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Si
          nat = 8
          mindist_1 = 2.0
          
          [soiap]
          soiap_infile = soiap.in
          soiap_outfile = soiap.out
          soiap_cif = initial.cif
          
          [option]
          

          calc_in/

          soiap.in_1

          crystal initial.cif ! CIF file for the initial structure
          symmetry 1 ! 0: not symmetrize displacements of the atoms or 1: symmetrize
          
          md_mode_cell 3 ! cell-relaxation method
                         ! 0: FIRE, 2: quenched MD, or 3: RFC5
          number_max_relax_cell 1000 ! max. number of the cell relaxation
          number_max_relax 1 ! max. number of the atom relaxation
          max_displacement 0.1 ! max. displacement of atoms in Bohr
          
          external_stress_v 0.0 0.0 0.0 ! external pressure in GPa
          
          th_force 5d-5 ! convergence threshold for the force in Hartree a.u.
          th_stress 5d-7 ! convergence threshold for the stress in Hartree a.u.
          
          force_field 1 ! force field
                        ! 1: Stillinger-Weber for Si, 2: Tsuneyuki potential for SiO2,
                        ! 3: ZRL for Si-O-N-H, 4: ADP for Nd-Fe-B, 5: Jmatgen, or
                        ! 6: Lennard-Jones
          

          job_cryspy

          #!/bin/sh
          
          # ---------- soiap
          EXEPATH=/path/to/soiap
          $EXEPATH/soiap soiap.in > soiap.out 2>&1
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          vasp_Na8Cl8_RS

          Download

          vasp_Na8Cl8_RS.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = VASP
          tot_struc = 5
          nstage = 2
          njob = 2
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          natot = 16
          atype = Na Cl
          nat = 8 8
          mindist_1 = 2.5 1.5
          mindist_2 = 1.5 2.5
          
          [VASP]
          kppvol = 40 80
          
          [option]
          

          calc_in/

          INCAR_1

          SYSTEM = NaCl
          !!!LREAL = Auto
          Algo = Fast
          NSW = 40
          
          LWAVE = .FALSE.
          !LCHARG = .FALSE.
          
          ISPIN =  1
          
          ISMEAR = 0
          SIGMA = 0.1
          
          IBRION = 2
          ISIF = 2
          
          EDIFF = 1e-5
          EDIFFG = -0.01
          

          INCAR_2

          SYSTEM = NaCl
          !!LREAL = Auto
          Algo = Fast
          NSW = 200
          
          ENCUT = 341
          
          !!LWAVE = .FALSE.
          !!LCHARG = .FALSE.
          
          
          ISPIN =  1
          
          ISMEAR = 0
          SIGMA = 0.1
          
          IBRION = 2
          ISIF = 3
          
          EDIFF = 1e-5
          EDIFFG = -0.01
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N Na8Cl8_CrySPY_ID
          #$ -pe smp 20
          ####$ -q ibis1.q
          ####$ -q ibis2.q
          ####$ -q ibis3.q
          ####$ -q ibis4.q
          
          # ---------- vasp
          VASPROOT=/usr/local/vasp/vasp.6.4.2/bin
          mpirun -np $NSLOTS $VASPROOT/vasp_std
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          vasp_Sr4O4_RS_pv_term

          Download

          vasp_Sr4O4_RS_pv_term.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = VASP
          tot_struc = 10
          nstage = 2
          njob = 4
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Sr O
          nat = 4 4
          
          [VASP]
          kppvol = 40 80
          
          [option]
          

          calc_in/

          INCAR_1

          SYSTEM = SrO
          Algo = Fast
          NSW = 60
          
          LWAVE = .FALSE.
          !LCHARG = .FALSE.
          
          ISPIN =  1
          
          ISMEAR = 0
          SIGMA = 0.1
          
          IBRION = 2
          ISIF = 2
          
          EDIFF = 1e-5
          EDIFFG = -0.01
          
          PSTRESS = 400
          

          INCAR_2

          SYSTEM = NaCl
          LREAL = Auto
          Algo = Fast
          NSW = 200
          
          ENCUT = 520
          
          !!LWAVE = .FALSE.
          !!LCHARG = .FALSE.
          
          
          ISPIN =  1
          
          ISMEAR = 0
          SIGMA = 0.1
          
          IBRION = 2
          ISIF = 3
          
          EDIFF = 1e-5
          EDIFFG = -0.01
          
          PSTRESS = 400
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N SrO_CrySPY_ID
          #$ -pe smp 20
          ####$ -q ibis1.q
          ####$ -q ibis2.q
          ####$ -q ibis3.q
          ####$ -q ibis4.q
          
          # ---------- vasp
          VASPROOT=/usr/local/vasp/vasp.6.4.2/bin
          mpirun -np $NSLOTS $VASPROOT/vasp_std
          
          # ---------- CrySPY
          sed -i -e '3 s/^.*$/done/' stat_job
          

          qe_Si8_RS

          Download

          qe_Si8_RS.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = QE
          tot_struc = 5
          nstage = 2
          njob = 2
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Si
          nat = 8
          
          [QE]
          qe_infile = pwscf.in
          qe_outfile = pwscf.out
          kppvol =  40  80
          
          [option]
          

          calc_in/

          pwscf.in_1

           &control
              title = 'Si8'
              calculation = 'relax'
              nstep = 100
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
              outdir='./out.d/'
           /
          
           &system
              ibrav = 0
              nat = 8
              ntyp = 1
              ecutwfc = 44.0
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
           /
          
          ATOMIC_SPECIES
            Si  28.086  Si.pbe-n-kjpaw_psl.1.0.0.UPF
          

          pwscf.in_2

           &control
              title = 'Si8'
              calculation = 'vc-relax'
              nstep = 200
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
              outdir='./out.d/'
           /
          
           &system
              ibrav = 0
              nat = 8
              ntyp = 1
              ecutwfc = 44.0
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
           /
          
          ATOMIC_SPECIES
            Si  28.086  Si.pbe-n-kjpaw_psl.1.0.0.UPF
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N Si8_CrySPY_ID
          #$ -pe smp 20
          ####$ -q ibis1.q
          ####$ -q ibis2.q
          
          mpirun -np $NSLOTS /path/to/pw.x < pwscf.in > pwscf.out
          
          
          if [ -e "CRASH" ]; then
              sed -i -e '3 s/^.*$/skip/' stat_job
              exit 1
          fi
          
          sed -i -e '3 s/^.*$/done/' stat_job
          

          qe_benzene_2_RS_mol

          Download

          qe_benzene_2_RS_mol.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = QE
          tot_struc = 6
          nstage = 2
          njob = 2
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          struc_mode = mol
          natot = 24
          atype = H C
          nat = 12 12
          mol_file = benzene
          nmol = 2
          
          [QE]
          qe_infile = pwscf.in
          qe_outfile = pwscf.out
          kppvol = 40  60
          
          [option]
          

          calc_in/

          pwscf.in_1

           &control
              title = '2 benzene'
              calculation = 'relax'
              nstep = 30
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
              outdir='./outdir/'
           /
          
           &system
              ibrav = 0
              nat = 24
              ntyp = 2
              ecutwfc = 35.00
              ecutrho = 300.00
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
           /
          
          ATOMIC_SPECIES
             H  1.008  H.pbe-kjpaw_psl.1.0.0.UPF
             C  12.01  C.pbe-n-kjpaw_psl.1.0.0.UPF
          

          pwscf.in_2

           &control
              title = '2 benzene'
              calculation = 'vc-relax'
              nstep = 200
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/pslibrary.1.0.0/pbe/PSEUDOPOTENTIALS/'
              outdir='./outdir/'
           /
          
           &system
              ibrav = 0
              nat = 24
              ntyp = 2
              ecutwfc = 46.00
              ecutrho = 326.00
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
           /
          
          ATOMIC_SPECIES
             H  1.008  H.pbe-kjpaw_psl.1.0.0.UPF
             C  12.01  C.pbe-n-kjpaw_psl.1.0.0.UPF
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N bz_CrySPY_ID
          #$ -pe smp 20
          
          # ---------- qe run
          mpirun -np $NSLOTS /path/to/pw.x  < pwscf.in > pwscf.out
          
          # ---------- qe if crash
          if [ -e "CRASH" ]; then
              sed -i -e '3 s/^.*$/skip/' stat_job
              exit 1
          fi
          
          # ---------- cryspy
          sed -i -e '3 s/^.*$/done/' stat_job
          

          qe_Sr4O4_RS_pv_term

          Download

          qe_Sr4O4_RS_pv_term.tar.gz

          cryspy.in

          [basic]
          algo = RS
          calc_code = QE
          tot_struc = 10
          nstage = 2
          njob = 4
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          natot = 8
          atype = Sr O
          nat = 4 4
          
          [QE]
          qe_infile = pwscf.in
          qe_outfile = pwscf.out
          kppvol =  40  80
          pv_term = True
          
          [option]
          

          calc_in/

          pwscf.in_1

           &control
              title = 'SrO'
              calculation = 'relax'
              nstep = 100
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/gbrv/all_pbe_UPF_v1.5/'
              outdir='./out.d/'
           /
          
           &system
              ibrav = 0
              nat = 8
              ntyp = 2
              ecutwfc = 40
              ecutrho = 200
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
              press = 400
           /
          
          ATOMIC_SPECIES
            Sr  -1.0  sr_pbe_v1.uspp.F.UPF
             O  -1.0  o_pbe_v1.2.uspp.F.UPF
          

          pwscf.in_2

           &control
              title = 'SrO'
              calculation = 'vc-relax'
              nstep = 200
              restart_mode = 'from_scratch',
              pseudo_dir = '/usr/local/gbrv/all_pbe_UPF_v1.5/'
              outdir='./out.d/'
           /
          
           &system
              ibrav = 0
              nat = 8
              ntyp = 2
              ecutwfc = 40
              ecutrho = 200
              occupations = 'smearing'
              degauss = 0.01
           /
          
           &electrons
           /
          
           &ions
           /
          
           &cell
              press = 400
           /
          
          ATOMIC_SPECIES
            Sr  -1.0  sr_pbe_v1.uspp.F.UPF
             O  -1.0  o_pbe_v1.2.uspp.F.UPF
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N SrO_CrySPY_ID
          #$ -pe smp 20
          ####$ -q ibis1.q
          ####$ -q ibis2.q
          
          # ---------- qe run
          mpirun -np $NSLOTS /path/to/pw.x  < pwscf.in > pwscf.out
          
          # ---------- qe if crash
          if [ -e "CRASH" ]; then
              sed -i -e '3 s/^.*$/skip/' stat_job
              exit 1
          fi
          
          # ---------- cryspy
          sed -i -e '3 s/^.*$/done/' stat_job
          

          qe_Si16_LAQA

          Download

          qe_Si16_LAQA.tar.gz

          cryspy.in

          [basic]
          algo = LAQA
          calc_code = QE
          tot_struc = 50
          nstage = 1
          njob = 10
          jobcmd = qsub
          jobfile = job_cryspy
          
          [structure]
          natot = 16
          atype = Si
          nat = 16
          mindist_1 = 1.5
          
          [QE]
          qe_infile = pwscf.in
          qe_outfile = pwscf.out
          kppvol =  80
          
          [LAQA]
          nselect_laqa = 4
          
          [option]
          

          calc_in/

          pwscf.in_1

          &control
              calculation = 'vc-relax'
              pseudo_dir = '/usr/local/gbrv/all_pbe_UPF_v1.5/'
              outdir='./outdir/'
              nstep = 10
          /
          
          &system
              ibrav = 0
              nat = 16
              ntyp = 1
              ecutwfc = 40
              ecutrho = 200
              occupations = 'smearing'
              degauss = 0.01
          /
          
          &electrons
          /
          
          &ions
          /
          
          &cell
          /
          
          ATOMIC_SPECIES
            Si -1.0 si_pbe_v1.uspp.F.UPF
          

          job_cryspy

          #!/bin/sh
          #$ -cwd
          #$ -V -S /bin/bash
          ####$ -V -S /bin/zsh
          #$ -N Si_CrySPY_ID
          #$ -pe smp 20
          ####$ -q ibis1.q
          ####$ -q ibis2.q
          
          # ---------- qe run
          mpirun -np $NSLOTS /path/to/pw.x  < pwscf.in > pwscf.out
          
          # ---------- qe if crash
          if [ -e "CRASH" ]; then
              sed -i -e '3 s/^.*$/skip/' stat_job
              exit 1
          fi
          
          # ---------- cryspy
          sed -i -e '3 s/^.*$/done/' stat_job
          

          Scriptsのサブセクション

          extract_struc.py

          2023 April 16 update

          init_struc_data.pklopt_struc_data.pklから構造ごとにcifファイルを出力するスクリプト. ファイル出力せず,構造情報を画面にプリントすることも可能.

          -iオプションでインデックス(構造ID)を(複数)指定できる. -tオプションでエネルギーが低い順番に指定した構造数のcifファイルを出力可能. -aオプションの場合は全ての構造をcifファイルに出力する.数が多い場合はディレクトリを作成してそこに移動してから実行したほうが良い. -sオプションをつけると対称性(空間群)の情報を付けられる.ただし,セルや原子数が変わるので注意. 対称性の情をつける際,--toleranceオプションでtoleranceを変えられる(デフォルトは0.01). -pオプションをつけるとファイル出力せずに,画面にプリントする. gzipしたファイルもそのまま読み込み可能(e.g., opt_struc_data.pkl.gz).

          更新履歴

          • 2024 April 16: –tolerance option, gzip
          • 2023 July 21: –print option

          使い方

          python3 extract_struc.py -h
          

          このスクリプトをPATHが通ったところにおけばpython3を省略できる

          extract_struc.py -h
          
          usage: extract_struc.py [-h] [-p] [-a] [-i [INDEX ...]] [-t TOP] [-r] [-s] [--tolerance TOLERANCE] infile
          
          positional arguments:
            infile                input file
          
          options:
            -h, --help            show this help message and exit
            -p, --print           just print, e.g., extract_struc.py opt_struc_data.pkl -i 7 10 12 -ps
            -a, --all_id          all structures, e.g., extract_struc.py opt_struc_data.pkl -as
            -i [INDEX ...], --index [INDEX ...]
                                  structure ID, e.g., extract_struc.py opt_struc_data.pkl -i 7 10 12 -s
            -t TOP, --top TOP     top k structures, e.g. (k = 3), extract_struc.py opt_struc_data.pkl -t 3 -s
            -r, --rank            add rank in file names, e.g., extract_struc.py opt_struc_data.pkl -t 3 -rs
            -s, --symmetrized     symmetrized structure, e.g., extract_struc.py opt_struc_data.pkl -i 7 10 12 -s
            --tolerance TOLERANCE
                                  tolerance for symmetrization (default 0.01), e.g., extract_struc.py opt_struc_data.pkl -i 0 1 -s --tolerance 0.01
          

          プリント

          -pオプションは-s以外のオプションと組み合わせて使用することができる.

          extract_struc.py -p opt_struc_data.pkl -i 0 1
          
          ID 0
          Full Formula (Na8 Cl8)
          Reduced Formula: NaCl
          abc   :   6.823618   6.823618   7.566454
          angles:  90.000000  90.000000  96.650518
          pbc   :       True       True       True
          Sites (16)
            #  SP           a         b         c
          ---  ----  --------  --------  --------
            0  Na    0         0         1
            1  Na    0         0         0.5
            2  Na    0.704707  0.295293  0.75
            3  Na    0.295293  0.704707  0.25
            4  Na    0.5       0         1
            5  Na    0.5       0         0.5
            6  Na    0         0.5       0.5
            7  Na    0         0.5       0
            8  Cl    0.5       0.5       0
            9  Cl    0.5       0.5       0.5
           10  Cl    0.484753  0.515247  0.75
           11  Cl    0.515247  0.484753  0.25
           12  Cl    0.828247  0.171753  0.851096
           13  Cl    0.171753  0.828247  0.351096
           14  Cl    0.828247  0.171753  0.648904
           15  Cl    0.171753  0.828247  0.148904
          
          ID 1
          Full Formula (Na8 Cl8)
          Reduced Formula: NaCl
          abc   :   8.145021   8.145021   4.324235
          angles:  90.000000  90.000000 120.000000
          pbc   :       True       True       True
          Sites (16)
            #  SP            a          b         c
          ---  ----  ---------  ---------  --------
            0  Na     0.666667   0.333333  0.736206
            1  Na     0.666667   0.333333  0.263794
            2  Na     0.913147   0.086853  0.5
            3  Na     0.913147   0.826295  0.5
            4  Na     0.173705   0.086853  0.5
            5  Na     0.77711    0.22289   0
            6  Na     0.77711    0.55422   0
            7  Na     0.44578    0.22289   0
            8  Cl     0.027675   0.423376  0.5
            9  Cl    -0.423376  -0.395701  0.5
           10  Cl     0.395701  -0.027675  0.5
           11  Cl    -0.423376  -0.027675  0.5
           12  Cl     0.395701   0.423376  0.5
           13  Cl     0.027675  -0.395701  0.5
           14  Cl     0.333333   0.666667  0.5
           15  Cl     0          0         0
          

          構造ID

          extract_struc.py opt_struc_data.pkl -i 7 10 12
          

          以下のファイルが出力される.

          7.cif10.cif12.cif

          対称性の情報ありの場合は-sオプションをつける.

          extract_struc.py opt_struc_data.pkl -i 7 10 12 -s
          

          2024 April 16
          toleranceパラメーター(デフォルトは0.01)を指定する場合

          extract_struc.py opt_struc_data.pkl -i 7 10 12 -s --tolerance 0.01
          

          Top k 構造

          情報

          rslt_data.pkl がインプット(init_struc_data.pklopt_struc_data.pkl)と同じディレクトリに必要.

          ここでは以下のようにファイルが存在して,

          • ./data/pkl_data/opt_struc_data.pkl
          • ./data/pkl_data/rslt_data.pkl

          cryspy_rslt_energy_ascの中身が下記のものを仮定すると

              Spg_num     Spg_sym  Spg_num_opt Spg_sym_opt    E_eV_atom  Magmom      Opt
          9       110      I4_1cd          110      I4_1cd -1284.708037     NaN  not_yet
          16        4        P2_1            4        P2_1 -1284.693651     NaN     done
          97       92    P4_12_12           91      P4_122 -1284.692494     NaN     done
          8        57        Pbcm           57        Pbcm -1284.668504     NaN     done
          81       19  P2_12_12_1           19  P2_12_12_1 -1284.635684     NaN     done
          ...
          

          トップk (ここではk=3) の構造は下記コマンドで出力できる.

          extract_struc.py ./data/pkl_data/opt_struc_data.pkl -t 3
          

          ここではrlst_data.pkl./data/pkl_data/の中に存在しなければならない. 9.cif, 16.cif, 97.cifというファイルが出力される.

          -rオプションを使うと,ファイル名に順位を含めることができる.

          extract_struc.py ./data/pkl_data/opt_struc_data.pkl -t 3 -r
          

          ファイル名は1_9.cif, 2_16.cif, 3_97.cifのようになる.

          対称化されたcifの場合は下記のようにする.

          extract_struc.py ./data/pkl_data/opt_struc_data.pkl -t 3 -rs
          

          全構造

          構造が多い場合はディレクトリを先に作った方が良い.

          mkdir init_cifs
          cd init_cifs
          extract_struc.py /path/to/opt_struc_data.pkl -a
          

          対称化する場合,

          extract_struc.py /path/to/init_struc_data.pkl -as
          

          gzipファイル

          2024 April 16
          gzipされたファイル(拡張子が.gz)も読み込み可能:

          extract_struc.py opt_struc_data.pkl.gz -i 0 1 -s
          

          pos2pkl.py

          2023年7月23日更新

          あらかじめ用意した構造のテキストデータをinit_struc_data.pklに変換するスクリプト. 入力のデフォルトはinit_POSCARS形式.オプションでPOSCARやcifファイルなどのシングル構造データも変換可能. 出力はinit_struc_data.pkl. すでに存在するinit_struc_data.pklに構造データを追加することもできる. 構造IDは考慮されず,新しく割り振られる. 原子数が異なる場合はエラーが出る.

          init_struc_data.pklはCrySPYでシミュレーション開始時にロードすることが可能.

          -fオプションで原子種の削除とソートが可能.このオプションを指定しないとpymatgenが勝手に電気陰性度の順番で並び替えるので注意!

          使い方

          usage: pos2pkl.py [-h] [-s [SINGLE ...]] [-f [FILTER ...]] [-p] [infile ...]
          
          positional arguments:
            infile                input file: init_POSCARS
          
          options:
            -h, --help            show this help message and exit
            -s [SINGLE ...], --single [SINGLE ...]
                                  input file: single structure file (POSCAR, cif)
            -f [FILTER ...], --filter [FILTER ...]
                                  filter (sort): remove species and sort
            -p, --permit_diff_comp
                                  flag for permitting different composition
          

          init_POSCARS –> init_struc_data.pkl

          CrySPYで構造生成後に出力されるinit_POSCARSをスパコン等の別のマシンに移すような場合に使える.複数のファイルを変換可能.

          python3 pos2pkl.py init_POSCARS
          

          pos2pkl.pyをPATHが通ったところにおけば,python3は省略可能.

          pos2pkl.py init_POSCARS
          
          Composition: Na8 Cl8
          
          Converted. The number of structures: 4
          Save init_struc_data.pkl
          

          複数の入力ファイルの場合.

          python3 pos2pkl.py init_POSCARS init_POSCARS2 init_POSCARS3
          
          Composition: Na8 Cl8
          
          Converted. The number of structures: 12
          Save init_struc_data.pkl
          

          カレントディレクトリにすでにinit_struc_data.pklが存在し,それに追加する場合.

          python3 pos2pkl.py init_POSCARS
          
          init_struc_data.pkl already exists.
          Append to init_struc_data.pkl? [y/n]: y
          
          Load init_struc_data
          Composition: Na8 Cl8
          The number of structures: 12
          
          Converted. The number of structures: 16
          Save init_struc_data.pkl
          

          POSCAR or cif –> init_struc_data.pkl

          POSCARファイルやcifファイル等の構造が一つだけのデータも変換可能.-s/--singleオプションが必要.

          python3 pos2pkl.py -s POSCAR test.cif
          
          Composition: Na8 Cl8
          
          Converted. The number of structures: 2
          Save init_struc_data.pkl
          

          init_POSCARS, POSCAR –> init_struc_data.pkl

          python3 pos2pkl.py init_POSCARS -s POSCAR
          
          Composition: Na8 Cl8
          
          Converted. The number of structures: 5
          Save init_struc_data.pkl
          
          警告

          下記は間違い.init_POSCARSもシングル構造として取り扱われてしまう.

          python3 pos2pkl.py -s POSCAR init_POSCARS
          

          Filter (remove and sort)

          次のような組成のcifファイルを考える:Sr8 Co8 O20 X4.これはダミー原子(X4)を4原子含んでいる. -f/--filterオプションは原子種を削除したり,ソートするのに使える. cryspy.inatypeと同じように指定する.

          python3 pos2pkl.py -s Sr8Co8O20X4.cif -f Sr Co O
          
          Removed species: {'X0+'}
          Composition: Sr8 Co8 O20
          
          Converted. The number of structures: 1
          Save init_struc_data.pkl
          

          extract_struc.pyを使えば, init_struc_data.pklにどのように登録されたのか確認できる.

          python3 extract_struc.py init_struc_data.pkl -pa
          
          ID 0
          Full Formula (Sr8 Co8 O20)
          Reduced Formula: Sr2Co2O5
          ...
          

          -fオプションでソートもできる.

          python3 pos2pkl.py -s Sr8Co8O20X4.cif -f O Co 
          
          Removed species: {'Sr', 'X0+'}
          Composition: O20 Co8
          
          Converted. The number of structures: 1
          Save init_struc_data.pkl
          

          kpt_check.py

          kpt_check.pykppvolを入力した際にkメッシュがどれくらいになるかをチェックすることができる. POSCARCONTCAR,およびinit_struc_data.pklが読み込み可能. pymatgenライブラリが必要.

          初期構造を生成後に,kppvolの値をどれくらいにしたら良いか色々試すことができる.(下記の最後の例を参照)

          使い方

          python3 kpt_check.py -h
          

          このスクリプトをPATHが通ったところにおけばpython3を省略できる

          kpt_check.py -h
          
          usage: kpt_check.py [-h] [-w] [-n NSTRUC] infile kppvol
          
          positional arguments:
            infile                input file: POSCAR, CONTCAR, or init_struc_data.pkl
            kppvol                kppvol
          
          options:
            -h, --help            show this help message and exit
            -w, --write           write KPOINTS
            -n NSTRUC, --nstruc NSTRUC
                                  number of structure to check
          

          POSCARとkppvol

          kpt_check.py POSCAR 100
          
          a = 10.689217
          b = 10.689217
          c = 10.730846
              Lattice vector
          10.689217 0.000000 0.000000
          0.000000 10.689217 0.000000
          0.000000 0.000000 10.730846
          
          kppvol:  100
          k-points:  [2, 2, 2]
          

          KPOINTSファイルの生成

          POSCARおよびCONTCARを入力とする際は,-wオプションを使用することでKPOINTSファイルを生成できる.

          kpt_check.py -w POSCAR 100
          
          $ cat KPOINTS
          pymatgen 4.7.6+ generated KPOINTS with grid density = 607 / atom
          0
          Monkhorst
          2 2 2
          

          init_struc_data.pklとkppvol

          init_struc_data.pklの初期構造データに任意のkppvolの値を適用した場合のkメッシュを調べることが可能. デフォルト設定でははじめの5構造をチェックする. -nを使うとチェックする構造数も変えられる.

          kpt_check.py -n 3 init_struc_data.pkl 100
          
          # ---------- 0th structure
          a = 8.0343076893
          b = 8.03430768936
          c = 9.1723323373
              Lattice vector
          8.034308 0.000000 0.000000
          -4.017154 6.957915 0.000000
          0.000000 0.000000 9.172332
          
          kppvol:  100
          k-points:  [3, 3, 3]
          
          
          # ---------- 1th structure
          a = 9.8451944096
          b = 9.84519440959
          c = 6.8764313585
              Lattice vector
          9.845194 0.000000 0.000000
          -4.922597 8.526188 0.000000
          0.000000 0.000000 6.876431
          
          kppvol:  100
          k-points:  [3, 3, 4]
          
          
          # ---------- 2th structure
          a = 7.5760383679
          b = 7.57603836797
          c = 6.6507478296
              Lattice vector
          7.576038 0.000000 0.000000
          -3.788019 6.561042 0.000000
          0.000000 0.000000 6.650748
          
          kppvol:  100
          k-points:  [4, 4, 4]
          

          repeat_cryspy

          cryspyを何度も実行するのが面倒な時は,下記の自動スクリプトが便利. これは5分間に1回cryspyを実行する例.

          #!/bin/bash
          
          set -e
          
          while :
          do
              cryspy -n
              LOG_LASTLINE=`tail -n 1 log_cryspy`
              if  [ "$LOG_LASTLINE" = "Done all structures!" ]
              then
                  exit 0
              # ---------- for EA
              elif [ "${LOG_LASTLINE:0:17}" = "Reached maxgen_ea" ]
              then
                  exit 0
              elif [ "$LOG_LASTLINE" = "EA is ready" ]
              then
                  cryspy -n    # EA
                  LOG_LASTLINE=`tail -n 1 log_cryspy`
                  if [ "${LOG_LASTLINE:0:17}" = "Reached maxgen_ea" ]
                  then
                      exit 0
                  fi
                  cryspy -n    # submit jobs
              # ---------- for BO
              elif [ "${LOG_LASTLINE:0:21}" = "Reached max_select_bo" ]
              then
                  exit 0
              elif [ "$LOG_LASTLINE" = "BO is ready" ]
              then
                  cryspy -n    # selection
                  LOG_LASTLINE=`tail -n 1 log_cryspy`
                  if [ "${LOG_LASTLINE:0:21}" = "Reached max_select_bo" ]
                  then
                      exit 0
                  fi
                  cryspy -n    # submit jobs
              # ---------- for LAQA
              elif [ "$LOG_LASTLINE" = "LAQA is ready" ]
              then
                  cryspy -n    # selection
                  cryspy -n    # submit jobs
              fi
              sleep 300    # seconds
          done
          

          FAQのサブセクション

          シミュレーションの途中でnjobを変えることはできますか?

          2024年5月7日

          シミュレーションの途中でnjobを変えることはできますか?

          いつでも変えられます.

          下記はnjobを減らした時の例です.

          警告

          CriSPYのバージョンが1.2.3以下ではバグがあるので,njobを減らすのは避けること.

          今,njob = 4でID 0, 1, 2, 3のジョブが流れているところで,njobを4から2に変更したとする.

          $ cryspy
          [2024-04-28 18:27:41,847][cryspy_restart][INFO] 
          
          
          Restart CrySPY 1.2.4
          
          
          [2024-04-28 18:27:41,848][read_input][INFO] Changed njob from 4 to 2
          [2024-04-28 18:27:42,335][ctrl_job][INFO] # ---------- job status
          [2024-04-28 18:27:42,335][ctrl_job][INFO] ID      0: still queueing or running
          [2024-04-28 18:27:42,335][ctrl_job][INFO] ID      1: still queueing or running
          

          njobを2に減らしたので,ID 0, 1だけチェックして,ID 2, 3は無視.

          $ cryspy
          [2024-04-28 18:29:25,250][cryspy_restart][INFO] 
          
          
          Restart CrySPY 1.2.4
          
          
          [2024-04-28 18:29:25,744][ctrl_job][INFO] # ---------- job status
          [2024-04-28 18:29:25,744][ctrl_job][INFO] ID      0: Stage 1 Done!
          [2024-04-28 18:29:25,757][ctrl_job][INFO]     submitted job, ID      0 Stage 2
          [2024-04-28 18:29:25,758][ctrl_job][INFO] ID      1: Stage 1 Done!
          [2024-04-28 18:29:25,767][ctrl_job][INFO]     submitted job, ID      1 Stage 2
          

          ID 1, 2のジョブが終わったので,次の2つのジョブ(ID 2, 3)をチェックしに行く.

          $ cryspy
          [2024-04-28 18:31:30,830][cryspy_restart][INFO]
          
          
          Restart CrySPY 1.2.4
          
          
          [2024-04-28 18:31:31,329][ctrl_job][INFO] # ---------- job status
          [2024-04-28 18:31:31,329][ctrl_job][INFO] ID      0: Stage 2 Done!
          [2024-04-28 18:31:31,329][collect_vasp][WARNING]     Structure ID 0, could not obtain energy from OSZICAR
          [2024-04-28 18:31:31,333][ctrl_job][INFO]     collect results: E = nan eV/atom
          [2024-04-28 18:31:31,341][ctrl_job][INFO] ID      1: Stage 2 Done!
          [2024-04-28 18:31:31,341][collect_vasp][WARNING]     Structure ID 1, could not obtain energy from OSZICAR
          [2024-04-28 18:31:31,342][ctrl_job][INFO]     collect results: E = nan eV/atom
          [2024-04-28 18:31:31,347][cryspy][INFO] 
          
          recheck 1
          
          [2024-04-28 18:31:31,347][ctrl_job][INFO] # ---------- job status
          [2024-04-28 18:31:31,347][ctrl_job][INFO] ID      2: Stage 1 Done!
          [2024-04-28 18:31:31,358][ctrl_job][INFO]     submitted job, ID      2 Stage 2
          [2024-04-28 18:31:31,358][ctrl_job][INFO] ID      3: Stage 1 Done!
          [2024-04-28 18:31:31,368][ctrl_job][INFO]     submitted job, ID      3 Stage 2