LoginSignup
13
11

More than 3 years have passed since last update.

Materials Projectのクエリ機能を使用して所望の計算材料データを大量に取得する。

Last updated at Posted at 2019-10-05

計算材料データ(化合物安定性やバンドギャップ値)についてAPIを利用して大量に取得する際、Materials Project のクエリ機能の使い方をいつも忘れるので、自分用のメモとしてここに書き記します。

Materials Project とは

image.png

物質材料の第一原理計算結果のデータベース。結晶構造、バンド構造、熱力学量、相図、磁気モーメントなどを提供する。MITの研究グループが運営を行っており、Li電池材料のデータが特に充実している。ウェブベースのユーザーインタフェースに加えて、httpベースのAPIも提供されており、ユーザ独自のスクリーニングが可能。無料であるが、要登録。
引用: MateriApps

クエリ使用例

下記の例では、pymatgen(Python Materials Genomics)というMaterials Project が開発した材料分析用のオープンソースPythonライブラリの MPRester をインポートしてクエリを実行します。

mp_query.py
from pymatgen import MPRester

# your API_KEY here: https://materialsproject.org/open
YOUR_API_KEY = "YOUR_API_KEY"
mp = MPRester(YOUR_API_KEY)

# Properties you need: mp-id; spacegroup number; composition formula; band gap
basic_properties = ['task_id', 'spacegroup.number', 'pretty_formula']
electronic_properties = ['band_gap']

all_properties = basic_properties + electronic_properties

# Query criteria: must include O element; less than 3 types of elements; space group is not equal to 1; band gap value exists
criteria = {"elements": {"$all": ["O"]}, "nelements": {"$lte": 3}, "spacegroup.number": {"$nin": 1}, "band_gap": {"$exists": True}}

# Retrieve material property data which satisfy query criteria
data = mp.query(criteria=criteria, properties=all_properties)

print(len(data))
# -> 21084

実際に取得できたデータの中身はこんな感じです:

[{...,                                                
 {'band_gap': 0.0,
  'pretty_formula': 'BiO2',
  'spacegroup.number': 160,
  'task_id': 'mp-1044722'},
 {'band_gap': 5.2101999999999995,
  'pretty_formula': 'SiO2',
  'spacegroup.number': 2,
  'task_id': 'mp-683947'},
 {'band_gap': 1.3498,
  'pretty_formula': 'Sb6O13',
  'spacegroup.number': 11,
  'task_id': 'mp-684679'},
...}]

3元系以下の酸化物について、Materials Project登録ID、空間群、バンドギャップの情報が得られていることが確認できます。

クエリの条件の記法について

上記の mp.query() 内の properties={...}criteria={...} の記法は、MongoDB というNoSQLデータベースの クエリ形式 に準拠するらしいです(詳細と使用例は ドキュメント を参照とのこと)。

Note that the criteria and properties follows the format (and richness) of MongoDB queries. You can refer to the MongoDB documentation for more information on how to customize queries.
引用: Materials Project · GitHub

感想

これだけ簡単に材料のデータを集められるなんて自分は恵まれた時代に生まれたなと思い、ありがたみが深いですね。
材料屋さんに限らず誰でも簡単に材料機械学習ができる時代になってきているあたり、Materials Project の存在を偉大に感じます。

参考

Materials Project · GitHub
Query and Projection Operators — MongoDB Manual

13
11
0

Register as a new user and use Qiita more conveniently

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