/atomistic-skills:mat-defect-energy-dftfrom Atomistic Skills
Calculates charged defect formation energies and transition level diagrams using pymatgen-analysis-defects and atomate2 VASP workflows. Generates defect supercells, runs DFT calculations, and applies finite-size corrections.
Ships in Atomistic Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
[!NOTE] Steps written
server.toolare MCP tool calls:base.search_materials_project_by_formulais thesearch_materials_project_by_formulatool of thebaseserver (mcp__base__search_materials_project_by_formula, ormcp__plugin_atomistic-skills_base__search_materials_project_by_formulawhen installed as a plugin). Without a connected server, run the same tools from the shell. Tools named in one command share a process, so a model loaded byload_modelstays loaded:${CLAUDE_SKILL_DIR}/../../venv/run cpu python -m src.mcp_server.cli base search_materials_project_by_formula key=value ${CLAUDE_SKILL_DIR}/../../venv/run cpu python -m src.mcp_server.cli atomate2 run_atomate2_vasp_calculation key=value
To calculate the formation energy of point defects (vacancies, substitutions, interstitials) including charged defect states and finite-size corrections using DFT (VASP) via atomate2 workflows. This produces formation energy diagrams showing defect charge transition levels as a function of Fermi energy.
$$E_f[D^q] = E[D^q] - E[\text{bulk}] + \sum_i \Delta n_i \mu_i + q(E_\text{VBM} + \Delta E_F) + E_\text{corr}$$
where $q$ is the charge state, $E_\text{VBM}$ is the valence band maximum, $\Delta E_F$ is the Fermi energy relative to VBM, and $E_\text{corr}$ is the finite-size correction (Freysoldt/FNV).
Start with a relaxed primitive cell:
base.search_materials_project_by_formula(formula="MgO", save_to_file="MgO.cif")
Use pymatgen-analysis-defects to generate all symmetry-unique defect supercells with charge states:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/generate_defect_structures.py \
--bulk MgO.cif \
--supercell_size 3 3 3 \
--defect_type vacancy \
--charge_range -2 2 \
--output dft_defects/
This generates:
defect_index.json mapping defect names to charge states and structuresSubmit calculations via the atomate2 MCP tool:
# Bulk supercell reference
atomate2.run_atomate2_vasp_calculation(
structures_path="dft_defects/pristine_supercell.cif",
output_dir="./dft_bulk/",
calculation_type="static",
preset_type="matpes-pbe",
execution_mode="remote"
)
# All defect structures
atomate2.run_atomate2_vasp_calculation(
structures_path="dft_defects/",
output_dir="./dft_defect_calcs/",
calculation_type="relaxation",
preset_type="matpes-pbe",
execution_mode="remote"
)
FormationEnergyMakerFor fully automated defect workflows with built-in corrections:
# (Python API)
from atomate2.vasp.flows.defect import FormationEnergyMaker
from pymatgen.analysis.defects.generators import VacancyGenerator
from pymatgen.core import Structure
bulk = Structure.from_file("MgO.cif")
vac_gen = VacancyGenerator()
defects = vac_gen.generate(bulk)
maker = FormationEnergyMaker()
# Submit via jobflow-remote for each defect
After DFT calculations complete:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/parse_defect_results.py \
--bulk_dir dft_bulk/ \
--defect_dir dft_defect_calcs/ \
--defect_index dft_defects/defect_index.json \
--dielectric 9.8 \
--output formation_energies.json \
--plot formation_energy_diagram.png
The script:
The formation energy diagram shows:
# 1. Get MgO
base.search_materials_project_by_formula(formula="MgO")
# 2. Generate defects with charges -2 to +2
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/generate_defect_structures.py \
--bulk MgO.cif --supercell_size 3 3 3 --defect_type vacancy --charge_range -2 2 --output mgo_defects/
# 3. Run DFT (remote)
atomate2.run_atomate2_vasp_calculation(
structures_path="mgo_defects/", output_dir="./mgo_dft/",
calculation_type="relaxation", preset_type="matpes-pbe", execution_mode="remote"
)
# 4. Parse and plot (after DFT completes)
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/parse_defect_results.py \
--bulk_dir mgo_dft/pristine_supercell/ --defect_dir mgo_dft/ \
--defect_index mgo_defects/defect_index.json --dielectric 9.8 --output mgo_fe.json
PMG_VASP_PSP_DIR, atomate2/jobflow-remote configured).cpu (pymatgen-analysis-defects)cpu (via MCP tool)cpuAuthor: Bowen Deng Contact: GitHub @learningmatter-mit
examples/MgO_charged_vacancy/README.md (opens in a new tab)examples/MgO_charged_vacancy/build_diagram.py (opens in a new tab)examples/MgO_charged_vacancy/charged_formation_energies.json (opens in a new tab)examples/MgO_charged_vacancy/charged_formation_energy_diagram.png (opens in a new tab)examples/MgO_charged_vacancy/defect_index.json (opens in a new tab)examples/MgO_charged_vacancy/dft_energies.json (opens in a new tab)examples/MgO_charged_vacancy/formation_energy_diagram_PBE.png (opens in a new tab)examples/MgO_charged_vacancy/full_results.json (opens in a new tab)scripts/generate_defect_structures.py (opens in a new tab)scripts/parse_defect_results.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
defect-formation-energy, vasp, dft, pymatgen, atomate2, transition-level-diagrams
npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skills133 skills in this plugin
/chem-bond-dissociationCalculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation./chem-conformer-searchGenerate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting./chem-db-mofQuery multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al. via Materials Cloud) and download CIF structures with optional element or identifier filters.Other plugins' skills for the same job