/atomistic-skills:mat-defect-energyfrom Atomistic Skills
Calculates formation energies of point defects (vacancies, substitutions, interstitials) using Machine Learning Interatomic Potentials (MLIPs) like MACE.
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 mlip python -m src.mcp_server.cli mace load_model key=value relax_structure key=value
To calculate the formation energy ($E_f$) of neutral point defects (vacancies, substitutions, and interstitials) using Machine Learning Interatomic Potentials (MLIPs). Formation energy is defined as:
$$E_f = E_\mathrm{defect} - \frac{n_\mathrm{defect}}{n_\mathrm{bulk}} E_\mathrm{bulk} + \sum_i \Delta n_i \mu_i$$
where $E_\mathrm{defect}$ and $E_\mathrm{bulk}$ are the total energies of the defective and pristine supercells, $n$ is the number of atoms, $\Delta n_i$ is the change in number of species $i$, and $\mu_i$ is the chemical potential of species $i$.
Choose an MLIP model. See ml-foundation-potentials for guidance.
MACE-MH-1 with matpes_r2scan head).Start with a relaxed bulk primitive cell. You can retrieve one from Materials Project:
base.search_materials_project_by_formula(formula="MgO", save_to_file="MgO.cif")
Relax the bulk unit cell to get the reference energy:
mace.load_model(model_name="MACE-MH-1", task_name="matpes_r2scan")
mace.relax_structure(
structure_data="MgO.cif",
relax_cell=True,
fmax=0.01,
output_dir="bulk_relaxation/"
)
Record the final energy per atom from the output.
Use the defect generation script with pymatgen-analysis-defects:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/generate_defects.py \
--bulk bulk_relaxation/relaxed_structure.cif \
--supercell_size 2 2 2 \
--defect_type vacancy \
--output defect_structures/
Options for --defect_type:
vacancy — removes each symmetry-unique atomsubstitution — replaces atoms with --substitute_element at each unique siteinterstitial — inserts --interstitial_element at Voronoi interstitial sitesall — generates all vacancy typesRelax without cell relaxation (fixed supercell volume). This applies to the defect
supercells only -- the bulk cell in step 3 and the elemental references in step 6 are
both relaxed with relax_cell=True:
mace.relax_structure(
structure_data="defect_structures/",
relax_cell=False, # Fixed cell for defect calculations
fmax=0.02,
output_dir="defect_relaxations/"
)
Compute defect formation energies:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/calculate_defect_energy.py \
--bulk_dir bulk_relaxation/ \
--defect_dir defect_relaxations/ \
--supercell_size 2 2 2 \
--output defect_energies.json
The script automatically:
If you derive $\mu_i$ yourself instead of reading the library, relax the elemental
reference cell and coordinates (relax_cell=True) with the same potential. A
chemical potential is only meaningful at the reference phase's own minimum for that
potential: evaluating an MP structure at its DFT geometry leaves it above the
potential's minimum and that error passes straight into every formation energy.
For O with TensorNet-PES-MatPES-PBE-2025.2, positions-only relaxation of mp-12957
gives -4.968 eV/atom versus -5.118 fully relaxed -- a 0.15 eV/atom error.
# 1. Get MgO structure
base.search_materials_project_by_formula(formula="MgO")
# 2. Relax bulk
mace.load_model(model_name="MACE-MH-1", task_name="matpes_r2scan")
mace.relax_structure(structure_data="MgO.cif", relax_cell=True, fmax=0.01, output_dir="bulk/")
# 3. Generate O vacancy supercells
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/generate_defects.py \
--bulk bulk/relaxed_structure.cif --supercell_size 3 3 3 --defect_type vacancy --output vacancies/
# 4. Relax defect structures
mace.relax_structure(structure_data="vacancies/", relax_cell=False, fmax=0.02, output_dir="vac_relax/")
# 5. Compute formation energies
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/calculate_defect_energy.py \
--bulk_dir bulk/ --defect_dir vac_relax/ --supercell_size 3 3 3 --output vac_energies.json
Expected: O vacancy formation energy ~6–8 eV (DFT reference: ~7.2 eV for neutral O vacancy in MgO).
cpu.Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/MgO_vacancy/README.md (opens in a new tab)examples/MgO_vacancy/defect_energies.json (opens in a new tab)examples/MgO_vacancy/pristine_supercell.cif (opens in a new tab)examples/MgO_vacancy/vac_Mg_0.cif (opens in a new tab)examples/MgO_vacancy/vac_O_1.cif (opens in a new tab)scripts/calculate_defect_energy.py (opens in a new tab)scripts/generate_defects.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, mlip, materials-science, point-defects, mace
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