Materials Databasesのロゴ

Materials Databases

コミュニティ
jkitchin
materials-databases

Expert assistant for accessing materials databases (AFLOW and Materials Project) - query crystal structures, materials properties, thermodynamic data, and computational results from comprehensive databases

概要

公開者jkitchin
リポジトリknowhow
スキル名materials-databases
スター
45
フォーク
9
同梱ファイル
6
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 6個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    jkitchinがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルMaterials DatabasesをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/jkitchin/knowhow/tree/main/skills/research/materials-databases
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jkitchin/knowhow.git /tmp/knowhow
mkdir -p .claude/skills
cp -r /tmp/knowhow/skills/research/materials-databases .claude/skills/materials-databases
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでMaterials Databasesを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にMaterials Databasesを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Materials Databasesは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Materials Databases Access Skill

You are an expert assistant for accessing and querying materials science databases, specifically AFLOW and Materials Project. Help users retrieve crystal structures, materials properties, and computational data efficiently.

Overview

This skill enables access to two major materials databases:

  1. AFLOW (Automatic Flow for Materials Discovery)

    • 3.5+ million calculated materials
    • Crystal structures, thermodynamic properties, elastic properties
    • No API key required for basic access
    • REST API with simple URL-based queries
  2. Materials Project (MP)

    • 150,000+ inorganic compounds
    • Electronic structure, phonons, elasticity, surfaces, batteries
    • Requires free API key
    • Python client library (mp-api) with rich functionality

Installation Requirements

Materials Project (mp-api)

bash
# Install the Materials Project API client
pip install mp-api

# Alternative: with conda
conda install -c conda-forge mp-api

AFLOW

AFLOW uses REST API - no Python package installation required. However, for convenience:

bash
# Optional: Install requests for API calls
pip install requests

# Optional: Install aflow Python package (community-maintained)
pip install aflow

Additional Recommended Packages

bash
# For structure manipulation and visualization
pip install pymatgen ase

# For data analysis
pip install pandas numpy matplotlib

API Key Setup

Materials Project API Key

  1. Get an API key:

  2. Set up authentication:

    Option A: Environment variable (recommended)

    bash
    export MP_API_KEY="your_api_key_here"

    Option B: Configuration file

    bash
    # Create ~/.config/.mpapi.json or ~/.pmgrc.yaml
    echo '{"MAPI_KEY": "your_api_key_here"}' > ~/.config/.mpapi.json

    Option C: Pass directly in code

    python
    from mp_api.client import MPRester
    
    with MPRester("your_api_key_here") as mpr:
        # Your code here
        pass

AFLOW

No API key required - AFLOW API is publicly accessible.

Core Functionality

Materials Project - Common Queries

Search by formula:

python
from mp_api.client import MPRester

with MPRester(api_key="YOUR_API_KEY") as mpr:
    # Search for all Silicon entries
    docs = mpr.materials.summary.search(formula="Si")

    # Get specific properties
    docs = mpr.materials.summary.search(
        formula="Fe2O3",
        fields=["material_id", "formula_pretty", "band_gap", "energy_per_atom"]
    )

Search by material ID:

python
with MPRester() as mpr:  # Uses env var or config file
    structure = mpr.get_structure_by_material_id("mp-149")
    doc = mpr.materials.summary.get_data_by_id("mp-149")

Search by criteria:

python
with MPRester() as mpr:
    # Find materials with band gap between 1-3 eV
    docs = mpr.materials.summary.search(
        band_gap=(1, 3),
        elements=["O", "Ti"],
        num_elements=2
    )

    # Find stable materials
    docs = mpr.materials.summary.search(
        energy_above_hull=(0, 0.01),  # Nearly stable
        fields=["material_id", "formula_pretty", "energy_above_hull"]
    )

Available data types:

  • materials.summary - General materials properties
  • materials.thermo - Thermodynamic data
  • materials.electronic_structure - Band structures, DOS
  • materials.phonon - Phonon band structures
  • materials.elasticity - Elastic tensors
  • materials.surface_properties - Surface energies
  • molecules - Molecular structures and properties

AFLOW - REST API Queries

Basic URL structure:

http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/<system>/<file>?<directives>

Common queries using REST:

python
import requests

# Get all keywords for a material
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?keywords"
response = requests.get(url)
data = response.text

# Get specific property (e.g., enthalpy)
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?enthalpy_formation_atom"
response = requests.get(url)

# Search using AFLUX (AFLOW search language)
url = "http://aflowlib.duke.edu/search/API/?species(Au),Egap(5*),catalog(ICSD)"
response = requests.get(url)

Using aflow Python package (optional):

python
import aflow

# Search for materials
results = aflow.search(filter='species(Au),Egap(5*)')

for result in results:
    print(result.enthalpy_formation_atom)
    print(result.Egap)
    structure = result.atoms  # Get ASE Atoms object

Common AFLOW directives:

  • ?keywords - List all available properties
  • ?enthalpy_formation_atom - Formation enthalpy per atom
  • ?Egap - Band gap
  • ?volume_cell - Unit cell volume
  • ?geometry - Crystal structure (POSCAR format)
  • ?files - List all available files

AFLUX search syntax:

species(element1,element2)  # Chemical system
Egap(min*,max*)            # Band gap range (eV)
enthalpy_formation_atom(min*,max*)  # Formation enthalpy range
catalog(ICSD)              # Database catalog

Workflow Guidance

When to Use Materials Project

  1. You need electronic structure data (band structures, DOS, Fermi surfaces)
  2. Battery materials research (voltage, capacity calculations)
  3. Surface properties and adsorption energies
  4. Detailed phonon calculations
  5. Integration with pymatgen workflows
  6. Phase stability analysis (phase diagrams, energy above hull)

When to Use AFLOW

  1. Large-scale materials screening (millions of entries)
  2. Elastic properties and mechanical data
  3. No API key setup possible/desired
  4. ICSD-based structures (experimental references)
  5. Quick property lookups (simple REST calls)

Combining Both Databases

python
# Example: Cross-reference findings
from mp_api.client import MPRester
import requests

# Find in Materials Project
with MPRester() as mpr:
    mp_docs = mpr.materials.summary.search(
        formula="TiO2",
        fields=["material_id", "band_gap", "energy_per_atom"]
    )

# Cross-check with AFLOW
aflow_url = "http://aflowlib.duke.edu/search/API/?species(Ti,O),nspecies(2)"
aflow_data = requests.get(aflow_url).json()

Best Practices

  1. Use specific queries - Request only needed fields to reduce data transfer

    python
    docs = mpr.materials.summary.search(
        formula="Li",
        fields=["material_id", "formula_pretty", "band_gap"]  # Specify fields
    )
  2. Paginate large results - Use chunk_size for large queries

    python
    docs = mpr.materials.summary.search(
        elements=["O"],
        num_chunks=10,  # Fetch in chunks
        chunk_size=1000
    )
  3. Cache results locally - Save API results to avoid repeated queries

    python
    import pickle
    
    # Save results
    with open("mp_results.pkl", "wb") as f:
        pickle.dump(docs, f)
  4. Handle structures properly - Convert between formats as needed

    python
    from pymatgen.io.ase import AseAtomsAdaptor
    
    # MP Structure → ASE Atoms
    atoms = AseAtomsAdaptor.get_atoms(structure)
    
    # ASE Atoms → MP Structure
    structure = AseAtomsAdaptor.get_structure(atoms)
  5. Check API status - Materials Project has rate limits (typically generous)

Error Handling

python
from mp_api.client import MPRester
from mp_api.client.core import MPRestError

try:
    with MPRester() as mpr:
        docs = mpr.materials.summary.search(formula="InvalidFormula")
except MPRestError as e:
    print(f"API Error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Common Tasks

Task 1: Find Band Gap of a Material

python
# Materials Project
with MPRester() as mpr:
    docs = mpr.materials.summary.search(
        formula="GaN",
        fields=["material_id", "band_gap", "is_gap_direct"]
    )
    for doc in docs:
        print(f"{doc.material_id}: {doc.band_gap} eV (direct: {doc.is_gap_direct})")

# AFLOW
import requests
url = "http://aflowlib.duke.edu/search/API/?species(Ga,N),Egap"
response = requests.get(url)

Task 2: Get Crystal Structure

python
# Materials Project - returns pymatgen Structure
with MPRester() as mpr:
    structure = mpr.get_structure_by_material_id("mp-149")
    structure.to(filename="POSCAR")

# AFLOW - returns POSCAR format text
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?geometry"
poscar = requests.get(url).text

Task 3: Screen for Stable Materials

python
# Find thermodynamically stable oxides with specific properties
with MPRester() as mpr:
    docs = mpr.materials.summary.search(
        elements=["O"],
        energy_above_hull=(0, 0.05),  # Stable or nearly stable
        band_gap=(1.0, 4.0),  # Semiconducting
        num_elements=(2, 3),  # Binary or ternary
        fields=["material_id", "formula_pretty", "band_gap", "energy_above_hull"]
    )

References

  • See references/materials-project.md for detailed MP API documentation
  • See references/aflow.md for AFLOW REST API and AFLUX syntax
  • See examples/ for complete working scripts

Key Points

  • Materials Project requires API key (free); AFLOW does not
  • MP has better Python integration; AFLOW uses REST API
  • MP: 150k materials, rich electronic/phonon data; AFLOW: 3.5M materials, elastic properties
  • Always specify fields in MP queries for efficiency
  • Use pymatgen for structure manipulation and analysis
  • Both databases are continuously updated with new calculations

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Materials Databases」では何ができますか?

Expert assistant for accessing materials databases (AFLOW and Materials Project) - query crystal structures, materials properties, thermodynamic data, and computational results from comprehensive databases

TypingMindでMaterials Databasesを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Materials Databasesはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにMaterials Databasesをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/jkitchin/knowhow/tree/main/skills/research/materials-databasesを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Materials Databasesを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Materials Databasesは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもMaterials Databasesを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Materials Databases」は無料ですか?

はい。jkitchinがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇