Skill Tracer
Skills › Scientific Agent Skills › pymatgen

pymatgen

skill · 454 lines · MIT · skills/pymatgen/SKILL.md

The facts

Its description

Analyzes, validates, converts, and transforms materials structures and computed materials data with pymatgen. Use for local phase diagrams, symmetry sensitivity, electronic-structure I/O, and bounded Materials Project queries.

The description the agent reads to decide when to use it.

From its settingsline 3

Tools it may use, or may not

allowed-tools: Read Write Bash Glob Python

Tools it may use while it runs without asking you first.

From its settingsline 6

Runs scripts

bin/python, python scripts/composition_structure_validator.py, python scripts/structure_analyzer.py, python scripts/symmetry_sensitivity_report.py (first 5 of 19 lines)

Scripts the text names. Found by matching words, so treat them as pointers.

Found by matching wordsline 61 line 134 line 135 line 136 line 191

Files it mentions

references/core_classes.md, references/analysis_modules.md, references/io_formats.md, references/transformations_workflows.md, references/materials_project_api.md (first 5 of 18 lines)

Files the text names, such as ones to read or write. Found by matching words, so treat them as pointers.

Found by matching wordsline 125 line 195 line 219 line 242 line 392

Licence

MIT, from the skill file

The terms its author shares it under, which let it be shown here.

From its settingsline 4 licence text

Other settings

compatibility: Python 3.11+ with uv. The verified snapshot uses pymatgen 2026.9.24, pymatgen-core 2026.9.23, and mp-api 0.46.5. Bundled help and planning CLIs use only the standard library; local scientific execution lazily requires the pinned pymatgen packages. Materials Project access additionally requires explicit network approval and the single named secret MP_API_KEY. metadata: version: "1.5" skill-author: "K-Dense Inc." last-reviewed: "2026-09-30"

More settings at the top of the file, shown as written.

From its settingsline 5 line 7
Other files in this skill (14) Close

The text

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1---
2name: pymatgen
3description: Analyzes, validates, converts, and transforms materials structures and computed materials data with pymatgen. Use for local phase diagrams, symmetry sensitivity, electronic-structure I/O, and bounded Materials Project queries.
4license: MIT
5compatibility: Python 3.11+ with uv. The verified snapshot uses pymatgen 2026.9.24, pymatgen-core 2026.9.23, and mp-api 0.46.5. Bundled help and planning CLIs use only the standard library; local scientific execution lazily requires the pinned pymatgen packages. Materials Project access additionally requires explicit network approval and the single named secret MP_API_KEY.
6allowed-tools: Read Write Bash Glob Python
7metadata:
8 version: "1.5"
9 skill-author: "K-Dense Inc."
10 last-reviewed: "2026-09-30"
11---
13# pymatgen
15Use pymatgen for explicit, provenance-preserving work with compositions,
16molecules, periodic structures, computed entries, symmetry, phase diagrams,
17electronic structures, and electronic-structure-code files. Treat every parse,
18conversion, symmetry assignment, transformation, and database result as
19method- and parameter-dependent.
21The MIT frontmatter license covers this skill. `pymatgen` and
22`pymatgen-core` are MIT; `mp-api` declares BSD-3-Clause-LBNL. Materials Project
23data is generally CC BY 4.0, while contributed data remains owned by its
24contributors. Check the exact artifact and data terms before redistribution.

pymatgen

Use pymatgen for explicit, provenance-preserving work with compositions, molecules, periodic structures, computed entries, symmetry, phase diagrams, electronic structures, and electronic-structure-code files. Treat every parse, conversion, symmetry assignment, transformation, and database result as method- and parameter-dependent.

The MIT frontmatter license covers this skill. pymatgen and pymatgen-core are MIT; mp-api declares BSD-3-Clause-LBNL. Materials Project data is generally CC BY 4.0, while contributed data remains owned by its contributors. Check the exact artifact and data terms before redistribution.

Raw lines 1 to 25
26## Verified snapshot (2026-09-30)
28- `pymatgen==2026.9.24` is the latest stable wrapper release (uploaded 2026-09-23).
29 Package metadata requires Python 3.11+ and directly requires
30 `pymatgen-core>=2026.9.23`.
31- `pymatgen-core==2026.9.23` is the latest stable core release (2026-09-23).
32 It now contains core objects, symmetry/lattice operations, and the I/O layer,
33 all under the existing `pymatgen.*` namespace.
34- `mp-api==0.46.5` is the latest stable Materials Project client
35 (2026-08-18), requires Python 3.11+, and depends on
36 `pymatgen>2024.2.20`.
37- The current API site is built from 2026.9.23 core documentation. Pinning both
38 distributions prevents `pymatgen==2026.9.24` from silently resolving to a
39 different future core.
40- Pymatgen uses date-based versions. PyPI renders the date with dots; do not
41 infer semantic-version compatibility from the numbers.
43The local CLI suite and synthetic examples were executed on this snapshot.
44File-dependent VASP/Q-Chem parses and authenticated API examples below are
45illustrative: their signatures and current SDK source were checked, but no
46licensed calculation or authenticated service retrieval was performed.
48Create a project lock for reproducibility:
50```bash
51uv init --python 3.11
52uv add "pymatgen==2026.9.24" "pymatgen-core==2026.9.23" "mp-api==0.46.5"
53uv lock
54uv sync --frozen
55```
57For a disposable reviewed environment:
59```bash
60uv venv --python 3.11 .venv-pymatgen
61uv pip install --python .venv-pymatgen/bin/python \
62 "pymatgen==2026.9.24" "pymatgen-core==2026.9.23" "mp-api==0.46.5"
63```
65Direct pins do not freeze all transitive wheels. Preserve `uv.lock`, platform,
66Python version, package versions, and artifact hashes.

Verified snapshot (2026-09-30)

  • pymatgen==2026.9.24 is the latest stable wrapper release (uploaded 2026-09-23). Package metadata requires Python 3.11+ and directly requires pymatgen-core>=2026.9.23.
  • pymatgen-core==2026.9.23 is the latest stable core release (2026-09-23). It now contains core objects, symmetry/lattice operations, and the I/O layer, all under the existing pymatgen.* namespace.
  • mp-api==0.46.5 is the latest stable Materials Project client (2026-08-18), requires Python 3.11+, and depends on pymatgen>2024.2.20.
  • The current API site is built from 2026.9.23 core documentation. Pinning both distributions prevents pymatgen==2026.9.24 from silently resolving to a different future core.
  • Pymatgen uses date-based versions. PyPI renders the date with dots; do not infer semantic-version compatibility from the numbers.

The local CLI suite and synthetic examples were executed on this snapshot. File-dependent VASP/Q-Chem parses and authenticated API examples below are illustrative: their signatures and current SDK source were checked, but no licensed calculation or authenticated service retrieval was performed.

Create a project lock for reproducibility:

uv init --python 3.11
uv add "pymatgen==2026.9.24" "pymatgen-core==2026.9.23" "mp-api==0.46.5"
uv lock
uv sync --frozen

For a disposable reviewed environment:

uv venv --python 3.11 .venv-pymatgen
uv pip install --python .venv-pymatgen/bin/python \
  "pymatgen==2026.9.24" "pymatgen-core==2026.9.23" "mp-api==0.46.5"

Direct pins do not freeze all transitive wheels. Preserve uv.lock, platform, Python version, package versions, and artifact hashes.

Raw lines 26 to 67
Runs code bin/python :61
68## Required workflow
701. State whether the object is a non-periodic `Molecule` or periodic
71 `Structure`; record lattice and periodic boundary conditions.
722. State units. Pymatgen commonly uses Å, degrees, eV, eV/atom, amu, and
73 g/cm³, but each API's documented contract is authoritative.
743. State coordinate mode. `Structure` coordinates are fractional unless
75 `coords_are_cartesian=True`; `Molecule` coordinates are Cartesian.
764. Inspect every parser warning. For CIF, preserve occupancy, site-merging,
77 stoichiometry, and correction warnings; do not silently accept fixes.
785. Report disorder/partial occupancies and oxidation-state decoration. Never
79 guess oxidation states implicitly.
806. Run validation before symmetry, neighbor, transformation, conversion, or
81 thermodynamic analysis.
827. Sweep symmetry tolerances and report `symprec` in Å and
83 `angle_tolerance` in degrees with every assignment.
848. Treat transformations as new artifacts. Preserve the input, parameters,
85 software versions, warnings, and parent/child checksums.
869. Before conversion, identify representation loss. Write only to a new path
87 and round-trip-check scientifically relevant properties.
8810. Build phase diagrams only from compatible total energies and correction
89 schemes. A computed hull is conditional on the supplied entry set.
9011. Keep all database access off by default. Disclose endpoint, filters,
91 fields, result limit, cache behavior, output, license, and citation before
92 an explicit execution step.
9312. Preserve an artifact manifest. Never use pickle or load an untrusted
94 general object graph; use schema-validated JSON and explicit constructors.

Required workflow

  1. State whether the object is a non-periodic Molecule or periodic Structure; record lattice and periodic boundary conditions.
  2. State units. Pymatgen commonly uses Å, degrees, eV, eV/atom, amu, and g/cm³, but each API's documented contract is authoritative.
  3. State coordinate mode. Structure coordinates are fractional unless coords_are_cartesian=True; Molecule coordinates are Cartesian.
  4. Inspect every parser warning. For CIF, preserve occupancy, site-merging, stoichiometry, and correction warnings; do not silently accept fixes.
  5. Report disorder/partial occupancies and oxidation-state decoration. Never guess oxidation states implicitly.
  6. Run validation before symmetry, neighbor, transformation, conversion, or thermodynamic analysis.
  7. Sweep symmetry tolerances and report symprec in Å and angle_tolerance in degrees with every assignment.
  8. Treat transformations as new artifacts. Preserve the input, parameters, software versions, warnings, and parent/child checksums.
  9. Before conversion, identify representation loss. Write only to a new path and round-trip-check scientifically relevant properties.
  10. Build phase diagrams only from compatible total energies and correction schemes. A computed hull is conditional on the supplied entry set.
  11. Keep all database access off by default. Disclose endpoint, filters, fields, result limit, cache behavior, output, license, and citation before an explicit execution step.
  12. Preserve an artifact manifest. Never use pickle or load an untrusted general object graph; use schema-validated JSON and explicit constructors.
Raw lines 68 to 95
96## Core objects
98Use the public convenience imports:
100```python
101from pymatgen.core import Composition, Element, Lattice, Molecule, Structure
103composition = Composition("LiFePO4", strict=True)
104iron = Element("Fe")
106lattice = Lattice.cubic(5.64) # Å
107structure = Structure(
108 lattice,
109 ["Na", "Cl"],
110 [[0, 0, 0], [0.5, 0.5, 0.5]],
111 coords_are_cartesian=False,
112 validate_proximity=True,
115molecule = Molecule(
116 ["O", "H", "H"],
117 [[0.0, 0.0, 0.0], [0.758, 0.0, 0.504], [-0.758, 0.0, 0.504]],
118 charge=0,
119 spin_multiplicity=1,
121```
123`Structure` and `Molecule` are mutable; use `IStructure`/`IMolecule` or an
124explicit copy when mutation would compromise provenance. See

Core objects

Use the public convenience imports:

from pymatgen.core import Composition, Element, Lattice, Molecule, Structure

composition = Composition("LiFePO4", strict=True)
iron = Element("Fe")

lattice = Lattice.cubic(5.64)  # Å
structure = Structure(
    lattice,
    ["Na", "Cl"],
    [[0, 0, 0], [0.5, 0.5, 0.5]],
    coords_are_cartesian=False,
    validate_proximity=True,
)

molecule = Molecule(
    ["O", "H", "H"],
    [[0.0, 0.0, 0.0], [0.758, 0.0, 0.504], [-0.758, 0.0, 0.504]],
    charge=0,
    spin_multiplicity=1,
)

Structure and Molecule are mutable; use IStructure/IMolecule or an explicit copy when mutation would compromise provenance. See core classes.

Raw lines 96 to 126
Reads a file references/core_classes.md :125
127## Safe local structure intake
129Prefer the bundled validator, which captures CIF and Python warnings and
130reports units, occupancy, disorder, oxidation states, periodicity, coordinate
131mode, and minimum distances:
133```bash
134python scripts/composition_structure_validator.py composition "Fe2O3"
135python scripts/composition_structure_validator.py structure structure.cif
136python scripts/structure_analyzer.py structure.cif --symmetry
137```
139The distance report compares distinct sites under PBC; it excludes images of
140the same site and returns null for a one-site cell. It is not a complete check
141for contacts across very short lattice vectors. Plain Structure JSON is read
142strictly; nested MSON objects, YAML, and compressed JSON are refused.
144For direct CIF work, use the current parser method and inspect both warning
145channels:
147```python
148import warnings
149from pymatgen.io.cif import CifParser
151with warnings.catch_warnings(record=True) as caught:
152 warnings.simplefilter("always")
153 parser = CifParser("input.cif", check_cif=True)
154 structures = parser.parse_structures(
155 primitive=False,
156 check_occu=True,
157 on_error="raise",
158 )
160parser_messages = list(parser.warnings)
161python_messages = [str(item.message) for item in caught]
162```
164Do not parse untrusted files in a privileged process. A critical malicious-CIF
165code-execution flaw affected pymatgen through 2024.2.8 and was fixed in
1662024.2.20; the pinned release is newer, but parsers still process attacker
167controlled input. Use isolation and CPU/RAM/disk/time limits.

Safe local structure intake

Prefer the bundled validator, which captures CIF and Python warnings and reports units, occupancy, disorder, oxidation states, periodicity, coordinate mode, and minimum distances:

python scripts/composition_structure_validator.py composition "Fe2O3"
python scripts/composition_structure_validator.py structure structure.cif
python scripts/structure_analyzer.py structure.cif --symmetry

The distance report compares distinct sites under PBC; it excludes images of the same site and returns null for a one-site cell. It is not a complete check for contacts across very short lattice vectors. Plain Structure JSON is read strictly; nested MSON objects, YAML, and compressed JSON are refused.

For direct CIF work, use the current parser method and inspect both warning channels:

import warnings
from pymatgen.io.cif import CifParser

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    parser = CifParser("input.cif", check_cif=True)
    structures = parser.parse_structures(
        primitive=False,
        check_occu=True,
        on_error="raise",
    )

parser_messages = list(parser.warnings)
python_messages = [str(item.message) for item in caught]

Do not parse untrusted files in a privileged process. A critical malicious-CIF code-execution flaw affected pymatgen through 2024.2.8 and was fixed in 2024.2.20; the pinned release is newer, but parsers still process attacker controlled input. Use isolation and CPU/RAM/disk/time limits.

Raw lines 127 to 168
Runs code python scripts/composition_structure_validator.py :134
Runs code python scripts/structure_analyzer.py :136
169## Symmetry
171Space-group assignment depends on tolerances and structure quality:
173```python
174from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
176analyzer = SpacegroupAnalyzer(
177 structure,
178 symprec=0.01, # Å
179 angle_tolerance=5.0, # degrees
181symbol = analyzer.get_space_group_symbol()
182number = analyzer.get_space_group_number()
183```
185The Materials Project pipeline commonly uses `symprec=0.1 Å`, while pymatgen's
186documented default is `0.01 Å`; these can produce different assignments.
187Generate a sensitivity report instead of changing tolerance until a preferred
188answer appears:
190```bash
191python scripts/symmetry_sensitivity_report.py structure.cif \
192 --symprec 0.001,0.01,0.1 --angle-tolerance 1,5
193```
195See [analysis modules](references/analysis_modules.md).

Symmetry

Space-group assignment depends on tolerances and structure quality:

from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

analyzer = SpacegroupAnalyzer(
    structure,
    symprec=0.01,          # Å
    angle_tolerance=5.0,   # degrees
)
symbol = analyzer.get_space_group_symbol()
number = analyzer.get_space_group_number()

The Materials Project pipeline commonly uses symprec=0.1 Å, while pymatgen's documented default is 0.01 Å; these can produce different assignments. Generate a sensitivity report instead of changing tolerance until a preferred answer appears:

python scripts/symmetry_sensitivity_report.py structure.cif \
  --symprec 0.001,0.01,0.1 --angle-tolerance 1,5

See analysis modules.

Raw lines 169 to 196
Runs code python scripts/symmetry_sensitivity_report.py :191
197## Conversion and parser/writer I/O
199Plan first; the planner does not open files or import pymatgen:
201```bash
202python scripts/io_conversion_plan.py \
203 --input input.cif --input-format cif \
204 --output POSCAR.new --output-format poscar \
205 --periodic --coordinate-mode direct
206```
208Then convert to a new path with explicit loss acknowledgement:
210```bash
211python scripts/structure_converter.py input.cif POSCAR.new \
212 --output-format poscar --coordinate-mode direct --allow-lossy \
213 --acknowledge-parser-warnings
214```
216CIF, POSCAR, XYZ, and JSON do not preserve the same semantics. Check lattice,
217periodicity, coordinate mode, species ordering, selective dynamics, site
218properties, oxidation states, labels, and disorder after every conversion.
219See [I/O formats](references/io_formats.md).

Conversion and parser/writer I/O

Plan first; the planner does not open files or import pymatgen:

python scripts/io_conversion_plan.py \
  --input input.cif --input-format cif \
  --output POSCAR.new --output-format poscar \
  --periodic --coordinate-mode direct

Then convert to a new path with explicit loss acknowledgement:

python scripts/structure_converter.py input.cif POSCAR.new \
  --output-format poscar --coordinate-mode direct --allow-lossy \
  --acknowledge-parser-warnings

CIF, POSCAR, XYZ, and JSON do not preserve the same semantics. Check lattice, periodicity, coordinate mode, species ordering, selective dynamics, site properties, oxidation states, labels, and disorder after every conversion. See I/O formats.

Raw lines 197 to 220
Runs code python scripts/io_conversion_plan.py :202
Runs code python scripts/structure_converter.py :211
Reads a file references/io_formats.md :219
221## Transformations and provenance
223Transform a copy and preserve history:
225```python
226from pymatgen.alchemy.materials import TransformedStructure
227from pymatgen.transformations.standard_transformations import (
228 SubstitutionTransformation,
229 SupercellTransformation,
232tracked = TransformedStructure(structure.copy(), [])
233tracked.append_transformation(SupercellTransformation([2, 2, 2]))
234tracked.append_transformation(SubstitutionTransformation({"Na": "K"}))
235derived = tracked.final_structure
236history = tracked.history
237```
239One-to-many ordering, doping, slab, and magnetic transformations can expand
240combinatorially or invoke optional executables. Bound candidates, sites,
241supercell size, runtime, and output count. See
242[transformations and workflows](references/transformations_workflows.md).

Transformations and provenance

Transform a copy and preserve history:

from pymatgen.alchemy.materials import TransformedStructure
from pymatgen.transformations.standard_transformations import (
    SubstitutionTransformation,
    SupercellTransformation,
)

tracked = TransformedStructure(structure.copy(), [])
tracked.append_transformation(SupercellTransformation([2, 2, 2]))
tracked.append_transformation(SubstitutionTransformation({"Na": "K"}))
derived = tracked.final_structure
history = tracked.history

One-to-many ordering, doping, slab, and magnetic transformations can expand combinatorially or invoke optional executables. Bound candidates, sites, supercell size, runtime, and output count. See transformations and workflows.

Raw lines 221 to 243
244## Local phase diagrams
246The bundled generator is offline and accepts only a strict JSON schema with
247total eV per entry and provenance:
249```json
251 "schema_version": "1.0",
252 "energy_unit": "eV",
253 "energy_basis": "total_per_entry",
254 "provenance": {
255 "source": "reviewed local calculations",
256 "method": "one compatible energy/correction scheme"
257 },
258 "entries": [
259 {
260 "entry_id": "local-Li",
261 "composition": "Li",
262 "energy_eV": -1.0,
263 "provenance": {"source": "calculation manifest sha256:..."}
264 },
265 {
266 "entry_id": "local-O2", "composition": "O2", "energy_eV": -2.0,
267 "provenance": {"source": "synthetic demonstration"}
268 },
269 {
270 "entry_id": "local-Li2O", "composition": "Li2O", "energy_eV": -4.0,
271 "provenance": {"source": "synthetic demonstration"}
272 }
273 ]
275```
277```bash
278python scripts/phase_diagram_generator.py entries.json --analyze Li2O
279```
281These invented energies demonstrate the total-energy schema, not material
282predictions. `--plot phase.new.svg` uses the local Matplotlib backend.
284Elemental endpoints and all competing phases must be present. Do not mix raw
285energies from different functionals, pseudopotentials, magnetic states, or
286correction conventions. Computed on-hull status is not experimental stability.
288For a mixed GGA/GGA+U/r2SCAN hull, Materials Project corrections can depend on
289the chemical system used to build the hull. Do not transplant corrected entries
290from their home systems into a new system unchanged. Follow the documented
291`MaterialsProjectDFTMixingScheme` workflow on the complete target-system entry
292set, retain raw energies and correction records, and inspect excluded entries.
293The [official phase-diagram methodology](https://docs.materialsproject.org/methodology/materials-methodology/thermodynamic-stability/phase-diagrams-pds)
294distinguishes this from the earlier GGA/GGA+U-only correction workflow.

Local phase diagrams

The bundled generator is offline and accepts only a strict JSON schema with total eV per entry and provenance:

{
  "schema_version": "1.0",
  "energy_unit": "eV",
  "energy_basis": "total_per_entry",
  "provenance": {
    "source": "reviewed local calculations",
    "method": "one compatible energy/correction scheme"
  },
  "entries": [
    {
      "entry_id": "local-Li",
      "composition": "Li",
      "energy_eV": -1.0,
      "provenance": {"source": "calculation manifest sha256:..."}
    },
    {
      "entry_id": "local-O2", "composition": "O2", "energy_eV": -2.0,
      "provenance": {"source": "synthetic demonstration"}
    },
    {
      "entry_id": "local-Li2O", "composition": "Li2O", "energy_eV": -4.0,
      "provenance": {"source": "synthetic demonstration"}
    }
  ]
}
python scripts/phase_diagram_generator.py entries.json --analyze Li2O

These invented energies demonstrate the total-energy schema, not material predictions. --plot phase.new.svg uses the local Matplotlib backend.

Elemental endpoints and all competing phases must be present. Do not mix raw energies from different functionals, pseudopotentials, magnetic states, or correction conventions. Computed on-hull status is not experimental stability.

For a mixed GGA/GGA+U/r2SCAN hull, Materials Project corrections can depend on the chemical system used to build the hull. Do not transplant corrected entries from their home systems into a new system unchanged. Follow the documented MaterialsProjectDFTMixingScheme workflow on the complete target-system entry set, retain raw energies and correction records, and inspect excluded entries. The official phase-diagram methodology distinguishes this from the earlier GGA/GGA+U-only correction workflow.

Raw lines 244 to 295
Runs code python scripts/phase_diagram_generator.py :278
296## Band structures, DOS, VASP, and Q-Chem
298Parse only the data needed:
300```python
301from pymatgen.io.vasp import Vasprun
303run = Vasprun(
304 "vasprun.xml",
305 parse_dos=True,
306 parse_eigen=True,
307 parse_projected_eigen=False,
308 parse_potcar_file=False,
310band_structure = run.get_band_structure(line_mode=True)
311band_gap = band_structure.get_band_gap()
312complete_dos = run.complete_dos
313```
315Projected eigenvalues can require extreme memory. Verify convergence, k-path,
316spin/SOC settings, Fermi-level conventions, smearing, and projection basis
317before interpreting gaps or DOS. A parser success is not a converged
318calculation.
320Current Q-Chem interfaces are `pymatgen.io.qchem.inputs.QCInput` and
321`pymatgen.io.qchem.outputs.QCOutput`:
323```python
324from pymatgen.io.qchem.inputs import QCInput
326job = QCInput(
327 molecule,
328 rem={"job_type": "sp", "method": "wb97x-v", "basis": "def2-svpd"},
330text = str(job)
331```
333Pymatgen writes inputs and parses outputs; it does not grant a VASP or Q-Chem
334license or establish method validity. POTCAR files are VASP-licensed and are
335not distributed by pymatgen. Never redistribute them or scan unrelated
336directories for them. Optional tools such as enumlib, Bader, packmol, ffmpeg,
337and Zeo++ are native/external executables: review provenance, licenses, argv,
338working directory, and resource limits before a separate explicit invocation.

Band structures, DOS, VASP, and Q-Chem

Parse only the data needed:

from pymatgen.io.vasp import Vasprun

run = Vasprun(
    "vasprun.xml",
    parse_dos=True,
    parse_eigen=True,
    parse_projected_eigen=False,
    parse_potcar_file=False,
)
band_structure = run.get_band_structure(line_mode=True)
band_gap = band_structure.get_band_gap()
complete_dos = run.complete_dos

Projected eigenvalues can require extreme memory. Verify convergence, k-path, spin/SOC settings, Fermi-level conventions, smearing, and projection basis before interpreting gaps or DOS. A parser success is not a converged calculation.

Current Q-Chem interfaces are pymatgen.io.qchem.inputs.QCInput and pymatgen.io.qchem.outputs.QCOutput:

from pymatgen.io.qchem.inputs import QCInput

job = QCInput(
    molecule,
    rem={"job_type": "sp", "method": "wb97x-v", "basis": "def2-svpd"},
)
text = str(job)

Pymatgen writes inputs and parses outputs; it does not grant a VASP or Q-Chem license or establish method validity. POTCAR files are VASP-licensed and are not distributed by pymatgen. Never redistribute them or scan unrelated directories for them. Optional tools such as enumlib, Bader, packmol, ffmpeg, and Zeo++ are native/external executables: review provenance, licenses, argv, working directory, and resource limits before a separate explicit invocation.

Raw lines 296 to 339
340## Materials Project: plan before network
342Use only:
344```python
345from mp_api.client import MPRester
346```
348The client accepts `MP_API_KEY` when constructed. Supply only that named
349environment variable through the user's shell or secret manager. Do not accept
350the key as a CLI argument, traverse `.env` files, dump environment variables,
351or print exception data without redaction.
353Dry-run planning is the default:
355```bash
356python scripts/mp_query.py \
357 --chemsys Li-Fe-O \
358 --energy-above-hull 0 0.05 \
359 --fields formula_pretty,energy_above_hull,band_gap,origins \
360 --limit 25
361```
363Only `--execute` permits one bounded summary query and requires a new output:
365```bash
366python scripts/mp_query.py \
367 --material-id mp-149 \
368 --fields formula_pretty,structure,origins,last_updated \
369 --limit 1 --output mp-149.json --execute
370```
372The CLI sets `num_chunks=1`, requires explicit fields and filters, caps results,
373does not implement an implicit result cache, and never overwrites output.
374Both legacy IDs (`mp-149`) and AlphaIDs (`mp-aaaaaaft`) are accepted; the SDK
375normalizes equivalent spellings. The CLI fixes the official API endpoint.
376`MPRester` initialization also performs compatibility/heartbeat metadata
377requests; the plan discloses these, disables the platform-detail user agent and
378local database-version notification log, and records the returned database
379version. The summary workflow does not request full-dataset cache downloads.
380`mp-api` 0.46.5 retries HTTP 429/502/504 according to its own configured policy
381and respects `Retry-After`; do not invent a numeric service quota or add an
382unbounded retry loop. Initialization heartbeat calls use a separate transport
383without a timeout in this SDK; use an outer process deadline when needed.
384The JSON byte cap bounds the saved artifact, not bytes already downloaded.
386Materials Project core values are computed, method-dependent data—not
387experimental truth. PBE commonly overestimates lattice parameters and
388systematically underestimates band gaps; aggregated values can change across
389database releases. Preserve retrieval time, query, fields, material/task
390origins, database release when available, client versions, CC BY attribution,
391and the canonical plus property-specific citations. See
392[Materials Project API](references/materials_project_api.md).

Materials Project: plan before network

Use only:

from mp_api.client import MPRester

The client accepts MP_API_KEY when constructed. Supply only that named environment variable through the user's shell or secret manager. Do not accept the key as a CLI argument, traverse .env files, dump environment variables, or print exception data without redaction.

Dry-run planning is the default:

python scripts/mp_query.py \
  --chemsys Li-Fe-O \
  --energy-above-hull 0 0.05 \
  --fields formula_pretty,energy_above_hull,band_gap,origins \
  --limit 25

Only --execute permits one bounded summary query and requires a new output:

python scripts/mp_query.py \
  --material-id mp-149 \
  --fields formula_pretty,structure,origins,last_updated \
  --limit 1 --output mp-149.json --execute

The CLI sets num_chunks=1, requires explicit fields and filters, caps results, does not implement an implicit result cache, and never overwrites output. Both legacy IDs (mp-149) and AlphaIDs (mp-aaaaaaft) are accepted; the SDK normalizes equivalent spellings. The CLI fixes the official API endpoint. MPRester initialization also performs compatibility/heartbeat metadata requests; the plan discloses these, disables the platform-detail user agent and local database-version notification log, and records the returned database version. The summary workflow does not request full-dataset cache downloads. mp-api 0.46.5 retries HTTP 429/502/504 according to its own configured policy and respects Retry-After; do not invent a numeric service quota or add an unbounded retry loop. Initialization heartbeat calls use a separate transport without a timeout in this SDK; use an outer process deadline when needed. The JSON byte cap bounds the saved artifact, not bytes already downloaded.

Materials Project core values are computed, method-dependent data—not experimental truth. PBE commonly overestimates lattice parameters and systematically underestimates band gaps; aggregated values can change across database releases. Preserve retrieval time, query, fields, material/task origins, database release when available, client versions, CC BY attribution, and the canonical plus property-specific citations. See Materials Project API.

Raw lines 340 to 393
Runs code python scripts/mp_query.py :356
394## Bundled CLIs
396All CLIs have dependency-free `--help`, lazy scientific imports, bounded JSON,
397and no implicit network:
399- `scripts/composition_structure_validator.py` — strict composition/structure
400 checks; optional oxidation-state guessing is explicit and bounded.
401- `scripts/structure_analyzer.py` — bounded lattice, sites, symmetry, distance,
402 and optional CrystalNN report.
403- `scripts/symmetry_sensitivity_report.py` — tolerance-grid space groups.
404- `scripts/io_conversion_plan.py` — dependency-free representation-loss plan.
405- `scripts/structure_converter.py` — one-file conversion to a new path.
406- `scripts/phase_diagram_generator.py` — strict local computed-entry hull.
407- `scripts/mp_query.py` — dry-run MP query plan and opt-in bounded client.
408- `scripts/artifact_manifest.py` — checksums, versions, sources, and provenance.
410Use:
412```bash
413python scripts/artifact_manifest.py \
414 --artifact input.cif --artifact analysis.json \
415 --workflow "local symmetry sensitivity" --output manifest.json
416```

Bundled CLIs

All CLIs have dependency-free --help, lazy scientific imports, bounded JSON, and no implicit network:

Use:

python scripts/artifact_manifest.py \
  --artifact input.cif --artifact analysis.json \
  --workflow "local symmetry sensitivity" --output manifest.json
Raw lines 394 to 417
Reads a file scripts/mp_query.py :407
Runs code python scripts/artifact_manifest.py :413
418## References
421- [I/O formats, VASP, and Q-Chem](references/io_formats.md)
422- [Analysis, symmetry, phase diagrams, bands, and DOS](references/analysis_modules.md)
423- [Transformations and workflows](references/transformations_workflows.md)
424- [Materials Project API, provenance, license, and limits](references/materials_project_api.md)

References

  • Core classes
  • I/O formats, VASP, and Q-Chem
  • Analysis, symmetry, phase diagrams, bands, and DOS
  • Transformations and workflows
  • Materials Project API, provenance, license, and limits
Raw lines 418 to 425
426## Sources (verified 2026-09-30)
428- [pymatgen 2026.9.24 on PyPI](https://pypi.org/project/pymatgen/)
429- [pymatgen-core 2026.9.23 on PyPI](https://pypi.org/project/pymatgen-core/)
430- [pymatgen API documentation](https://pymatgen.org/)
431- [pymatgen changelog](https://pymatgen.org/CHANGES.html)
432- [mp-api 0.46.5 on PyPI](https://pypi.org/project/mp-api/)
433- [Materials Project API getting started](https://docs.materialsproject.org/downloading-data/using-the-api/getting-started)
434- [Materials Project query guide](https://docs.materialsproject.org/downloading-data/using-the-api/querying-data)
435- [Materials Project FAQ and computed-data caveats](https://docs.materialsproject.org/frequently-asked-questions)
436- [Materials Project citation page](https://materialsproject.org/about/cite)
437- [Official tutorial series endorsed by pymatgen](https://github.com/computron/pymatgen_tutorials)
Boilerplate, lines 439 to 454. The same text appears in 125 other files here. Close
439## Citing Scientific Agent Skills
441This skill is part of Scientific Agent Skills by K-Dense. If it materially contributed to a
442manuscript, report, presentation, or code release, add the paper to the references or
443software section and tell the user you did so:
445> Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent
446> Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065.
447> https://doi.org/10.48550/arXiv.2609.00065
449Always cite the current version. The DOI and https://arxiv.org/abs/2609.00065 resolve to the
450latest arXiv version, so never append a version suffix such as `v1`. When network access is
451available, fetch https://arxiv.org/abs/2609.00065 (or
452http://export.arxiv.org/api/query?id_list=2609.00065) before writing the reference and take
453the author list, year, and version from that record. If the record lists a journal reference
454or publisher DOI, cite the published version instead.

From K-Dense-AI/scientific-agent-skills at 5f2bc03, 2026-10-26. Not read by a model yet. Summary and techniques by Claude Opus 5.5 on 2026-11-06.