Agent skill

Mat Magnetic Density

by learningmatter-mit in learningmatter-mit/AtomisticSkills

Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP.

MITAuto-check passed

Install Mat Magnetic Density

skills CLI
$ npx skills add learningmatter-mit/AtomisticSkills --skill mat-magnetic-density -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install learningmatter-mit/AtomisticSkills mat-magnetic-density --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/learningmatter-mit/AtomisticSkills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/mat-magnetic-density .claude/skills/mat-magnetic-density && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mat-magnetic-density
GitHub stars
176
Token cost
~2.7k tokens
SKILL.md length
979 words
Files
8 (incl. scripts)
Skills in repo
129
Repo updated
First seen
Licence
MIT

At a glance

Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP.

  • Works in 7 steps: Structure Preparation → Run Spin-Polarized DFT Calculation → Monitor Job Status → …
  • SKILL.md covers Goal, Instructions, Examples and Functional Selection Guide, plus 2 more sections
  • Runs Python scripts from its folder

What it does

Mat Magnetic Density is an agent skill from learningmatter-mit/AtomisticSkills. Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including scripts (for example `examples/Fe_example.md`, `examples/Fe_moments.json` and `examples/README.md`).

It works with Model Context Protocol. The repository describes itself as: Integrating AtomisticSkills into Agentic IDEs (Cursor, Claude Code, Codex, Google Antigravity, Hermes Agent, etc). The licence is MIT.

Example prompts

  • “/mat-magnetic-density”

Requirements

  • Python 3

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Structure Preparation
  2. Run Spin-Polarized DFT Calculation
  3. Monitor Job Status
  4. Extract Magnetic Moments
  5. Parse and Analyze Results
  6. Extract Spin Density (Optional)
  7. Visualize Magnetic Ordering (Optional)

What it can do on your machine

Read from SKILL.md and the folder at commit 6257444. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • doi.org
    • vasp.at
    • pymatgen.org
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mat Magnetic Density loads about 2.7k tokens when it runs. Until then it costs about 28 tokens; SKILL.md has 979 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from learningmatter-mit/AtomisticSkills at commit 6257444, republished under its MIT licence (© learningmatter-mit). 979 words, ~2,702 tokens.

Download SKILL.mdSave it as .claude/skills/mat-magnetic-density/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
mat-magnetic-density
description
Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP.
metadata.category
materials
metadata.venv
cpu

Magnetic Density

<!-- mcp-tools-note -->

[!NOTE] Steps written server.tool are MCP tool calls: atomate2.run_atomate2_vasp_calculation is the run_atomate2_vasp_calculation tool of the atomate2 server (mcp__atomate2__run_atomate2_vasp_calculation, or mcp__plugin_atomistic-skills_atomate2__run_atomate2_vasp_calculation when 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 by load_model stays loaded:

bash
${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

Goal

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.

Instructions

1. Structure Preparation

Obtain or prepare the structure of the magnetic material you want to study. You can:

  • Query from Materials Project using the base MCP tools (recommended - already DFT-optimized)
  • Load from a local CIF/POSCAR file
  • Use a previously relaxed structure

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:

  • New/hypothetical structures
  • Surfaces, interfaces, or defects
  • Systems where you need accurate total energies (not just magnetic moments)
  • Strongly correlated oxides with significant magnetic-structural coupling
2. Run Spin-Polarized DFT Calculation

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.

python
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:

  • For metallic ferromagnets (Fe, Co, Ni): Use mp preset (MPStaticSet with PBE). PBE provides excellent accuracy for magnetic moments (typically within ~2% of experimental values)[1].
  • For strongly correlated oxides (NiO, CoO, FeO): Use 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].
  • Avoid r2SCAN for metallic ferromagnets: r2SCAN significantly overestimates magnetic moments in itinerant ferromagnets like Fe (by ~24% compared to experimental values)[2].

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.

3. Monitor Job Status

After submitting the calculation, monitor its progress:

python
atomate2.get_atomate2_job_status(
    job_id="<job_id_from_step_2>"  # Job ID returned from step 2
)
4. Extract Magnetic Moments

Once the calculation is complete, retrieve the results to extract magnetic moments:

python
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:

  • Total magnetization: Net magnetic moment of the unit cell
  • Site magnetic moments: Magnetic moment on each atom
  • Energy: Total energy of the magnetic configuration
5. Parse and Analyze Results

Use the provided script to parse the magnetic moments from the results:

bash
${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:

  • Extract site-resolved magnetic moments
  • Calculate the total magnetization
  • Identify the magnetic ordering pattern
  • Generate a summary report
6. Extract Spin Density (Optional)

For detailed analysis of spin density distribution, use the spin density extraction script:

bash
${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:

  • Read the spin density from CHGCAR
  • Calculate integrated spin moments
  • Optionally generate 3D visualization data
Show full SKILL.md (395 more words)Show less
7. Visualize Magnetic Ordering (Optional)

Visualize the magnetic ordering by creating a structure with magnetic moment vectors:

bash
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/visualize_magnetic_structure.py structure.cif magnetic_analysis.json --output magnetic_structure.png

Examples

Example 1: Calculate magnetic moments for bulk Fe
python
# 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"
)
bash
# 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
Example 2: NiO with automatic GGA+U
python
# 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"
)

Functional Selection Guide

Choosing the right exchange-correlation functional is critical for accurate magnetic property calculations:

For Metallic Ferromagnets (Fe, Co, Ni, etc.)

Recommended: PBE (use preset_type="mp" for MPStaticSet)

  • PBE underestimates magnetic moments by only ~1.8% for Fe
  • Provides excellent agreement with experimental spin magnetization
  • Computational efficiency superior to meta-GGA functionals
  • Do NOT use: r2SCAN overestimates by ~24% for Fe

Example: Bulk Fe experimental value = 2.2 μB/atom

  • PBE prediction: ~2.15 μB/atom (2% error) ✓
  • r2SCAN prediction: ~2.73 μB/atom (24% error) ✗
For Transition Metal Oxides and Strongly Correlated Systems

Recommended: PBE with automatic +U (use preset_type="mp" - MPStaticSet handles this automatically)

When to use PBE+U:

  1. Localized d-electrons: Systems where d-electrons exhibit strong correlation (NiO, CoO, Fe₂O₃)
  2. Band gap issues: Standard PBE underestimates band gaps significantly
  3. Magnetic ground states: PBE gives incorrect magnetic ordering or underestimates moments
  4. Redox chemistry: Systems involving oxidation state changes

U parameter selection:

  • U values are material-dependent and typically calibrated against experimental band gaps or magnetic moments
  • Common values: U = 3-5 eV for 3d transition metals in oxides
  • For NiO: U = 5-6 eV is typical
  • Consult literature for your specific system

Why standard GGA fails for oxides:

  • Self-interaction error artificially delocalizes d-electrons
  • Underestimates band gaps and magnetic exchange interactions
  • May predict incorrect magnetic ground states

Constraints

  • Spin Polarization: The mp preset (MPStaticSet) automatically enables spin polarization (ISPIN=2) for magnetic systems. MAGMOM values are also automatically initialized (default 0.6 per magnetic atom).
  • Initial Magnetic Moments: For complex magnetic ordering (e.g., antiferromagnetic), you should provide initial MAGMOM values through the config parameter to help convergence.
  • Environment: The parsing scripts require the cpu environment with pymatgen installed.
  • Remote Execution: DFT calculations are computationally expensive and should typically be run on remote clusters using execution_mode="remote".
  • CHGCAR Access: Extracting spin density requires access to the CHGCAR file, which may not be automatically retrieved. You may need to manually download it from the remote execution directory.
  • Convergence: Magnetic systems can be challenging to converge. If calculations fail to converge, try:
    • Adjusting MAGMOM initial values
    • Increasing NELM (max electronic steps)
    • Using a denser k-point mesh
    • Enabling LDAU for strongly correlated systems

References



Author: Bowen Deng Contact: GitHub @learningmatter-mit

© learningmatter-mit, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (scripts) in skills/mat-magnetic-density of learningmatter-mit/AtomisticSkills.

  • SKILL.md
  • examples/Fe_bulk.cif
  • examples/Fe_example.md
  • examples/Fe_moments.json
  • examples/README.md
  • scripts/extract_spin_density.py
  • scripts/parse_magnetic_moments.py
  • scripts/visualize_magnetic_structure.py

Open the folder on GitHubat commit 6257444

Compare with similar skills

Mat Magnetic Density next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mat Magnetic Density compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mat Magnetic Density this skilllearningmatter-mit/AtomisticSkills176—~2.7kAutomated safety check: PassMIT
MCP Server Builderanthropics/skills180k64 repos~2.3kAutomated safety check: PassApache-2.0
MCP Server BuildershareAI-lab/learn-claude-code78k5 repos~1.2kAutomated safety check: PassMIT
MCP Integration for Pluginsanthropics/claude-plugins-official38k11 repos~3.1kAutomated safety check: PassApache-2.0
Figma use_figma Plugin API Ruleswarpdotdev/warp65k4 repos~4.4kAutomated safety check: PassAGPL-3.0
Stitch to Remotion Walkthrough Videosgoogle-labs-code/stitch-skills8.4k6 repos~3.2kAutomated safety check: NotesApache-2.0

Similar skills

  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 64 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • MCP Server Builder

    shareAI-lab/learn-claude-code

    Walks through building MCP servers in Python or TypeScript that expose tools, resources and prompts to Claude, with templates, registration and testing.

    78k GitHub starsUsed in 5 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • MCP Integration for Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to bundle Model Context Protocol servers in a Claude Code plugin, covering config files, stdio, SSE, HTTP and WebSocket server types, and authentication.

    38k GitHub starsUsed in 11 repos~3.1k tokens
    Agent WorkflowsAuto-check passed
  • Required groundwork before any use_figma call: the rules and reference files for running JavaScript in a Figma file through the Plugin API without common failures.

    65k GitHub starsUsed in 4 repos~4.4k tokens
    Frontend & DesignAuto-check passed
  • Stitch to Remotion Walkthrough Videos

    google-labs-code/stitch-skills

    Official

    Builds walkthrough videos from Stitch design projects using Remotion, with transitions, zoom effects and text overlays on each screen.

    8.4k GitHub starsUsed in 6 repos~3.2k tokens
    Media & CreativeAuto-check: notes
  • MCP Development

    coollabsio/coolify

    A skill your agent uses for Laravel MCP development. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 1 repo~949 tokens
    Frontend & DesignAuto-check passed

More from learningmatter-mit/AtomisticSkills

All 129 skills in this repo
  • Drug Binding Site Definition

    learningmatter-mit/AtomisticSkills

    Define a docking search box (center coordinates + box dimensions in Angstroms) from a co-crystal ligand, binding-site residues, or a saved JSON specification.

    176 GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Drug Complex System Builder

    learningmatter-mit/AtomisticSkills

    Build a solvated, charge-neutralized protein-ligand complex for OpenMM molecular dynamics simulation.

    176 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Drug Pocket Detection

    learningmatter-mit/AtomisticSkills

    Identify and rank ligandable pockets on a protein structure or model using geometry (fpocket) or an ML predictor (P2Rank).

    176 GitHub stars~4k tokensUpdated today
    Auto-check passed
  • Chem Bond Dissociation

    learningmatter-mit/AtomisticSkills

    Calculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation.

    176 GitHub stars~2.5k tokensUpdated today
    Auto-check passed
  • Chem Conformer Search

    learningmatter-mit/AtomisticSkills

    Generate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting.

    176 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Chem DB Mof

    learningmatter-mit/AtomisticSkills

    Query multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al.

    176 GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Questions about Mat Magnetic Density

What does Mat Magnetic Density do?

Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP. Mat Magnetic Density is an agent skill from learningmatter-mit/AtomisticSkills. Calculate magnetic moments and spin density from spin-polarized DFT calculations using VASP.

How do I install Mat Magnetic Density in Claude Code?

Run `npx skills add learningmatter-mit/AtomisticSkills --skill mat-magnetic-density -a claude-code`. Or copy the skill folder (skills/mat-magnetic-density in learningmatter-mit/AtomisticSkills) into .claude/skills/mat-magnetic-density in your project. Claude Code loads it when a task matches its description.

How do I install Mat Magnetic Density in Codex?

Run `npx skills add learningmatter-mit/AtomisticSkills --skill mat-magnetic-density -a codex`. Or copy the skill folder (skills/mat-magnetic-density in learningmatter-mit/AtomisticSkills) into .agents/skills/mat-magnetic-density in your project. Codex loads it when a task matches its description.

Can I use Mat Magnetic Density in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add learningmatter-mit/AtomisticSkills --skill mat-magnetic-density -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mat-magnetic-density, .gemini/skills/mat-magnetic-density, .github/skills/mat-magnetic-density and .opencode/skills/mat-magnetic-density in your project.

What does Mat Magnetic Density need to run?

Going by SKILL.md and its folder, Mat Magnetic Density needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Mat Magnetic Density access the network?

SKILL.md names 4 domains. As links in the text: doi.org, vasp.at, pymatgen.org and github.com. This is read from the text; nothing was executed.

Is Mat Magnetic Density safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Mat Magnetic Density use?

Mat Magnetic Density is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mat Magnetic Density use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mat Magnetic Density?

Skills that share tags, products or a category with Mat Magnetic Density: MCP Server Builder (anthropics/skills, 180k stars), MCP Server Builder (shareAI-lab/learn-claude-code, 78k stars), MCP Integration for Plugins (anthropics/claude-plugins-official, 38k stars) and Figma use_figma Plugin API Rules (warpdotdev/warp, 65k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mat Magnetic Density?

learningmatter-mit (a GitHub organization) maintains it in learningmatter-mit/AtomisticSkills, which has 176 GitHub stars. The repository holds 129 skills in this directory. The repository was last updated on October 7, 2026.

Source: learningmatter-mit/AtomisticSkills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.