@nahisaho/satori 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,353 @@
1
+ ---
2
+ name: scientific-computational-materials
3
+ description: |
4
+ 計算材料科学スキル。pymatgen による結晶構造操作・対称性解析、
5
+ Materials Project API による材料データベース照会、
6
+ 相図計算 (凸包解析)、電子バンド構造・状態密度 (DOS) 可視化、
7
+ VASP/Quantum ESPRESSO 入出力、高スループットスクリーニングパイプライン。
8
+ ---
9
+
10
+ # Scientific Computational Materials
11
+
12
+ 無機結晶材料を中心に、結晶構造操作・物性データベース照会・
13
+ 第一原理計算入出力・相安定性解析・電子構造可視化を提供する
14
+ 計算材料科学パイプライン。
15
+
16
+ ## When to Use
17
+
18
+ - 結晶構造の生成・変換・対称性解析を行うとき
19
+ - Materials Project API で材料物性データを照会するとき
20
+ - 相図 (凸包) による安定性解析が必要なとき
21
+ - DFT 計算 (VASP/QE) の入力ファイル生成・出力解析をするとき
22
+ - バンド構造・状態密度 (DOS) を可視化するとき
23
+ - 高スループット材料スクリーニングを行うとき
24
+
25
+ ---
26
+
27
+ ## Quick Start
28
+
29
+ ## 1. 結晶構造操作
30
+
31
+ ```python
32
+ from pymatgen.core import Structure, Lattice
33
+ from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
34
+
35
+
36
+ def create_crystal_structure(lattice_params, species, coords,
37
+ output_file="results/structure.cif"):
38
+ """
39
+ pymatgen による結晶構造の生成と解析。
40
+
41
+ Parameters:
42
+ - lattice_params: (a, b, c, alpha, beta, gamma) or 3×3 matrix
43
+ - species: 元素リスト ["Si", "O", ...]
44
+ - coords: 分率座標 [[x,y,z], ...]
45
+ """
46
+ lattice = Lattice.from_parameters(*lattice_params)
47
+ structure = Structure(lattice, species, coords)
48
+
49
+ sga = SpacegroupAnalyzer(structure, symprec=0.1)
50
+
51
+ print(f" Crystal structure:")
52
+ print(f" Formula: {structure.composition.reduced_formula}")
53
+ print(f" Space group: {sga.get_space_group_symbol()} ({sga.get_space_group_number()})")
54
+ print(f" Crystal system: {sga.get_crystal_system()}")
55
+ print(f" Lattice: a={lattice.a:.3f}, b={lattice.b:.3f}, c={lattice.c:.3f}")
56
+ print(f" Volume: {structure.volume:.3f} ų")
57
+ print(f" Density: {structure.density:.3f} g/cm³")
58
+
59
+ # 慣用セルに変換
60
+ conventional = sga.get_conventional_standard_structure()
61
+ primitive = sga.get_primitive_standard_structure()
62
+
63
+ print(f" Conventional cell: {len(conventional)} atoms")
64
+ print(f" Primitive cell: {len(primitive)} atoms")
65
+
66
+ # CIF 出力
67
+ structure.to(filename=output_file)
68
+
69
+ return structure, sga
70
+
71
+
72
+ def analyze_structure_symmetry(structure, symprec=0.01):
73
+ """
74
+ 結晶対称性の詳細解析。
75
+
76
+ - 空間群・点群
77
+ - Wyckoff 位置
78
+ - サイト対称性
79
+ """
80
+ sga = SpacegroupAnalyzer(structure, symprec=symprec)
81
+
82
+ symmetry_info = {
83
+ "space_group_symbol": sga.get_space_group_symbol(),
84
+ "space_group_number": sga.get_space_group_number(),
85
+ "crystal_system": sga.get_crystal_system(),
86
+ "point_group": sga.get_point_group_symbol(),
87
+ "hall_symbol": sga.get_hall(),
88
+ "symmetry_operations": len(sga.get_symmetry_operations()),
89
+ }
90
+
91
+ # Wyckoff 位置
92
+ sym_struct = sga.get_symmetrized_structure()
93
+ wyckoff_sites = sym_struct.wyckoff_symbols
94
+
95
+ print(f" Symmetry analysis:")
96
+ for k, v in symmetry_info.items():
97
+ print(f" {k}: {v}")
98
+ print(f" Wyckoff sites: {wyckoff_sites}")
99
+
100
+ return symmetry_info
101
+ ```
102
+
103
+ ## 2. Materials Project API 照会
104
+
105
+ ```python
106
+ from mp_api.client import MPRester
107
+ import pandas as pd
108
+
109
+
110
+ def query_materials_project(formula=None, elements=None,
111
+ band_gap_range=None,
112
+ e_above_hull_max=0.025):
113
+ """
114
+ Materials Project API による材料データベース照会。
115
+
116
+ 検索条件:
117
+ - 化学式 (formula) — exact or reduced
118
+ - 構成元素 (elements) — 含む/排除
119
+ - バンドギャップ範囲 (band_gap_range) — eV
120
+ - 凸包上エネルギー (e_above_hull) — 安定性指標
121
+ """
122
+ with MPRester() as mpr:
123
+ criteria = {}
124
+ if formula:
125
+ criteria["formula"] = formula
126
+ if elements:
127
+ criteria["elements"] = elements
128
+
129
+ docs = mpr.materials.summary.search(
130
+ **criteria,
131
+ energy_above_hull=(0, e_above_hull_max) if e_above_hull_max else None,
132
+ band_gap=band_gap_range,
133
+ fields=[
134
+ "material_id", "formula_pretty", "volume",
135
+ "density", "band_gap", "energy_above_hull",
136
+ "formation_energy_per_atom", "is_stable",
137
+ "symmetry", "nsites",
138
+ ],
139
+ )
140
+
141
+ results = []
142
+ for doc in docs:
143
+ results.append({
144
+ "mp_id": doc.material_id,
145
+ "formula": doc.formula_pretty,
146
+ "space_group": doc.symmetry.symbol if doc.symmetry else None,
147
+ "band_gap_eV": doc.band_gap,
148
+ "e_above_hull_eV": doc.energy_above_hull,
149
+ "formation_energy_eV": doc.formation_energy_per_atom,
150
+ "density_g_cm3": doc.density,
151
+ "nsites": doc.nsites,
152
+ "is_stable": doc.is_stable,
153
+ })
154
+
155
+ df = pd.DataFrame(results)
156
+ print(f" Materials Project query:")
157
+ print(f" Found: {len(df)} materials")
158
+ if len(df) > 0:
159
+ print(f" Stable: {df['is_stable'].sum()}")
160
+ print(f" Band gap range: {df['band_gap_eV'].min():.2f}–{df['band_gap_eV'].max():.2f} eV")
161
+
162
+ return df
163
+ ```
164
+
165
+ ## 3. 相図・凸包解析
166
+
167
+ ```python
168
+ import numpy as np
169
+ import pandas as pd
170
+
171
+
172
+ def compute_phase_diagram(system_elements, output_file="figures/phase_diagram.png"):
173
+ """
174
+ 相図 (凸包) 計算。
175
+
176
+ 凸包 (Convex Hull):
177
+ - 安定相: 凸包上の点 (e_above_hull = 0)
178
+ - 準安定相: 凸包上方の点 (e_above_hull > 0)
179
+ - 分解反応: 凸包上の隣接安定相への分解
180
+ """
181
+ from mp_api.client import MPRester
182
+ from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter
183
+
184
+ with MPRester() as mpr:
185
+ entries = mpr.get_entries_in_chemsys(system_elements)
186
+
187
+ pd_obj = PhaseDiagram(entries)
188
+
189
+ print(f" Phase diagram: {'-'.join(system_elements)}")
190
+ print(f" Total entries: {len(entries)}")
191
+ print(f" Stable phases: {len(pd_obj.stable_entries)}")
192
+
193
+ for entry in pd_obj.stable_entries:
194
+ formula = entry.composition.reduced_formula
195
+ e_form = pd_obj.get_form_energy_per_atom(entry)
196
+ print(f" {formula}: ΔHf = {e_form:.4f} eV/atom")
197
+
198
+ # 可視化
199
+ plotter = PDPlotter(pd_obj)
200
+ plotter.get_plot().savefig(output_file, dpi=300, bbox_inches="tight")
201
+
202
+ return pd_obj
203
+ ```
204
+
205
+ ## 4. 電子バンド構造・DOS
206
+
207
+ ```python
208
+ import numpy as np
209
+
210
+
211
+ def plot_band_structure(material_id, output_file="figures/band_structure.png"):
212
+ """
213
+ 電子バンド構造の取得と可視化。
214
+
215
+ - 高対称 k-path (Setyawan-Curtarolo 規約)
216
+ - バンドギャップ判定 (直接/間接)
217
+ - フェルミレベル基準
218
+ """
219
+ from mp_api.client import MPRester
220
+ from pymatgen.electronic_structure.plotter import BSPlotter
221
+
222
+ with MPRester() as mpr:
223
+ bs = mpr.get_bandstructure_by_material_id(material_id)
224
+
225
+ if bs is None:
226
+ print(f" No band structure available for {material_id}")
227
+ return None
228
+
229
+ gap = bs.get_band_gap()
230
+ print(f" Band structure: {material_id}")
231
+ print(f" Band gap: {gap['energy']:.3f} eV")
232
+ print(f" Direct: {gap['direct']}")
233
+ print(f" Transition: {gap['transition']}")
234
+
235
+ plotter = BSPlotter(bs)
236
+ plotter.get_plot().savefig(output_file, dpi=300, bbox_inches="tight")
237
+
238
+ return bs
239
+
240
+
241
+ def plot_density_of_states(material_id, output_file="figures/dos.png"):
242
+ """
243
+ 電子状態密度 (DOS) の取得と可視化。
244
+
245
+ - Total DOS + projected DOS (元素分解)
246
+ - スピン偏極 (該当時)
247
+ """
248
+ from mp_api.client import MPRester
249
+ from pymatgen.electronic_structure.plotter import DosPlotter
250
+
251
+ with MPRester() as mpr:
252
+ dos = mpr.get_dos_by_material_id(material_id)
253
+
254
+ if dos is None:
255
+ print(f" No DOS available for {material_id}")
256
+ return None
257
+
258
+ print(f" DOS: {material_id}")
259
+ print(f" Efermi: {dos.efermi:.3f} eV")
260
+
261
+ plotter = DosPlotter()
262
+ plotter.add_dos("Total", dos)
263
+ plotter.get_plot().savefig(output_file, dpi=300, bbox_inches="tight")
264
+
265
+ return dos
266
+ ```
267
+
268
+ ## 5. VASP/Quantum ESPRESSO 入出力
269
+
270
+ ```python
271
+ from pymatgen.core import Structure
272
+
273
+
274
+ def generate_vasp_inputs(structure, output_dir="vasp_inputs",
275
+ calculation_type="relaxation"):
276
+ """
277
+ VASP 入力ファイル生成。
278
+
279
+ 計算タイプ:
280
+ - relaxation: 構造緩和 (ISIF=3)
281
+ - static: 静的計算 (NSW=0)
282
+ - band: バンド構造 (ICHARG=11)
283
+ - dos: 状態密度 (LORBIT=11)
284
+ """
285
+ from pymatgen.io.vasp.sets import (
286
+ MPRelaxSet, MPStaticSet,
287
+ )
288
+ import os
289
+ os.makedirs(output_dir, exist_ok=True)
290
+
291
+ if calculation_type == "relaxation":
292
+ vis = MPRelaxSet(structure)
293
+ elif calculation_type == "static":
294
+ vis = MPStaticSet(structure)
295
+ else:
296
+ vis = MPRelaxSet(structure)
297
+
298
+ vis.write_input(output_dir)
299
+
300
+ print(f" VASP inputs generated: {output_dir}")
301
+ print(f" Calculation: {calculation_type}")
302
+ print(f" Files: INCAR, POSCAR, POTCAR, KPOINTS")
303
+
304
+ return output_dir
305
+
306
+
307
+ def parse_vasp_output(vasprun_file="vasprun.xml"):
308
+ """
309
+ VASP 出力 (vasprun.xml) の解析。
310
+ """
311
+ from pymatgen.io.vasp.outputs import Vasprun
312
+
313
+ vr = Vasprun(vasprun_file, parse_dos=True, parse_eigen=True)
314
+
315
+ print(f" VASP output: {vasprun_file}")
316
+ print(f" Final energy: {vr.final_energy:.6f} eV")
317
+ print(f" Converged: {vr.converged}")
318
+ print(f" Band gap: {vr.get_band_structure().get_band_gap()['energy']:.3f} eV")
319
+
320
+ return vr
321
+ ```
322
+
323
+ ## References
324
+
325
+ ### Output Files
326
+
327
+ | ファイル | 形式 |
328
+ |---|---|
329
+ | `results/structure.cif` | CIF |
330
+ | `results/materials_query.csv` | CSV |
331
+ | `figures/phase_diagram.png` | PNG |
332
+ | `figures/band_structure.png` | PNG |
333
+ | `figures/dos.png` | PNG |
334
+ | `vasp_inputs/` | VASP input set |
335
+
336
+ ### 利用可能ツール
337
+
338
+ > [ToolUniverse](https://github.com/mims-harvard/ToolUniverse) SMCP 経由で利用可能な外部ツール。
339
+
340
+ なし — Materials Project API (mp-api) を直接利用。
341
+
342
+ ### 参照スキル
343
+
344
+ | スキル | 関連 |
345
+ |---|---|
346
+ | `scientific-quantum-chemistry` | DFT / 量子化学計算 |
347
+ | `scientific-molecular-dynamics` | 分子動力学シミュレーション |
348
+ | `scientific-visualization` | 構造可視化 |
349
+ | `scientific-data-analysis` | 材料データ統計解析 |
350
+
351
+ ### 依存パッケージ
352
+
353
+ `pymatgen`, `mp-api`, `pandas`, `numpy`, `matplotlib`