/atomistic-skills:mat-magnetic-densityfrom Atomistic Skills
Calculates magnetic moments and spin density from spin-polarized DFT calculations using VASP via atomate2. Handles structure preparation, functional selection, and result extraction for magnetic materials characterization.
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:atomate2.run_atomate2_vasp_calculationis therun_atomate2_vasp_calculationtool of theatomate2server (mcp__atomate2__run_atomate2_vasp_calculation, ormcp__plugin_atomistic-skills_atomate2__run_atomate2_vasp_calculationwhen 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 atomate2 run_atomate2_vasp_calculation key=value get_atomate2_job_status key=value ${CLAUDE_SKILL_DIR}/../../venv/run cpu python -m src.mcp_server.cli base search_materials_project_by_formula key=value
To calculate the magnetic moments and optionally extract the spin density ($\rho_{\text{spin}}$) of magnetic materials using spin-polarized DFT calculations. This skill enables the characterization of magnetic ordering, local magnetic moments on individual atoms, and spatial distribution of spin density.
Obtain or prepare the structure of the magnetic material you want to study. You can:
Note on relaxation: For magnetic moment calculations, relaxation is optional if using high-quality experimental or Materials Project structures. Magnetic moments are relatively insensitive to small structural variations. However, relaxation is recommended for:
Use the atomate2 MCP tool to run a spin-polarized static calculation. The mp preset (MPStaticSet) automatically enables spin polarization and applies appropriate settings for magnetic systems.
atomate2.run_atomate2_vasp_calculation(
structures_path="structure.cif", # Path to your structure file
output_dir="magnetic_calc", # Directory to save results
preset_type="mp", # MPStaticSet with PBE (includes spin polarization)
calculation_type="static", # Static calculation
)
Important - Functional Selection:
mp preset (MPStaticSet with PBE). PBE provides excellent accuracy for magnetic moments (typically within ~2% of experimental values)[1].mp preset (see Example 2 below). MPStaticSet automatically applies appropriate GGA+U corrections for transition metal oxides. Standard PBE fails to predict the correct insulating antiferromagnetic ground state and severely underestimates band gaps[3]. Note: +U corrections improve electronic structure but do not guarantee better magnetic moments (e.g., GGA+U may overestimate for NiO or underestimate for CoO due to missing orbital contributions)[4].References: [1] PBE underestimates Fe magnetization by only 1.8%: Zhang et al., Phys. Rev. Materials 6, 013801 (2022). DOI: 10.1103/PhysRevMaterials.6.013801 [2] r2SCAN and SCAN overestimate Fe magnetization by 24% and 17% respectively: ibid. [3] PBE+U opens band gaps and corrects ground state in transition metal oxides: Kulik, J. Chem. Phys. 142, 240901 (2015). DOI: 10.1063/1.4922693 [4] CoO magnetic moments: PBE+U underestimates due to missing orbital contributions: Radi et al., Z. Naturforsch. A 70, 789 (2015). DOI: 10.1515/zna-2015-0216
See the "Functional Selection Guide" section below for detailed recommendations.
After submitting the calculation, monitor its progress:
atomate2.get_atomate2_job_status(
job_id="<job_id_from_step_2>" # Job ID returned from step 2
)
Once the calculation is complete, retrieve the results to extract magnetic moments:
atomate2.get_atomate2_results_by_id(
job_ids=["<job_id>"], # List of job IDs
save_to_file="magnetic_results.json" # Save results to file
)
The results will include:
Use the provided script to parse the magnetic moments from the results:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/parse_magnetic_moments.py magnetic_results.json --output magnetic_analysis.json
This script will:
For detailed analysis of spin density distribution, use the spin density extraction script:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/extract_spin_density.py <output_dir> --output spin_density.json
This requires access to the CHGCAR file from the VASP calculation and will:
Visualize the magnetic ordering by creating a structure with magnetic moment vectors:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/visualize_magnetic_structure.py structure.cif magnetic_analysis.json --output magnetic_structure.png
# Step 1: Get Fe structure from Materials Project
base.search_materials_project_by_formula(
formula="Fe",
save_to_file="Fe_mp.cif"
)
# Step 2: Run spin-polarized static calculation
atomate2.run_atomate2_vasp_calculation(
structures_path="Fe_mp.cif",
output_dir="Fe_magnetic",
preset_type="mp", # MPStaticSet with PBE
calculation_type="static",
execution_mode="remote"
)
# Step 3: After completion, retrieve results
atomate2.get_atomate2_results_by_id(
job_ids=["<job_id>"],
save_to_file="Fe_magnetic_results.json"
)
# Step 4: Parse magnetic moments
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/parse_magnetic_moments.py Fe_magnetic_results.json --output Fe_moments.json
# For transition metal oxides like NiO, use 'mp' preset
# MPStaticSet automatically applies appropriate U parameters (e.g., U=6.2 eV for Ni in oxides)
# This ensures correct insulating antiferromagnetic ground state
atomate2.run_atomate2_vasp_calculation(
structures_path="NiO.cif",
output_dir="NiO_magnetic",
preset_type="mp", # MPStaticSet automatically handles +U for transition metal oxides
calculation_type="static",
execution_mode="remote"
)
Choosing the right exchange-correlation functional is critical for accurate magnetic property calculations:
Recommended: PBE (use preset_type="mp" for MPStaticSet)
Example: Bulk Fe experimental value = 2.2 μB/atom
Recommended: PBE with automatic +U (use preset_type="mp" - MPStaticSet handles this automatically)
When to use PBE+U:
U parameter selection:
Why standard GGA fails for oxides:
mp preset (MPStaticSet) automatically enables spin polarization (ISPIN=2) for magnetic systems. MAGMOM values are also automatically initialized (default 0.6 per magnetic atom).cpu environment with pymatgen installed.execution_mode="remote".Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/Fe_bulk.cif (opens in a new tab)examples/Fe_example.md (opens in a new tab)examples/Fe_moments.json (opens in a new tab)examples/README.md (opens in a new tab)scripts/extract_spin_density.py (opens in a new tab)scripts/parse_magnetic_moments.py (opens in a new tab)scripts/visualize_magnetic_structure.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
dft, vasp, magnetic-moments, spin-density, atomate2, materials-science
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