DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to pre-relax structures before a DFT run with Chgnet

Use StructOptimizer to relax a structure and get site-wise magnetic moments to seed spin-polarized DFT.

Short answer: Install with pip install chgnet; then create the optimizer with relaxer = StructOptimizer(); run result = relaxer.relax(structure) on your pymatgen structure. All steps.

Who it is forA computational chemist preparing inputs for a spin-polarized DFT calculation.

The problemStarting DFT from an unrelaxed structure wastes many ionic steps.

The outcomeA relaxed structure and its total energy, ready to hand to your DFT workflow.

What you need first

  • Python and pip
  • A crystal structure file such as a CIF
  • pymatgen for loading structures
  • CPU, NVIDIA GPU, Intel GPU or Apple silicon (device picked automatically)

Steps

  1. Install with pip install chgnet
  2. Create the optimizer with relaxer = StructOptimizer()
  3. Run result = relaxer.relax(structure) on your pymatgen structure
  4. Use result["final_structure"] as the relaxed structure
  5. Read the final energy from result['trajectory'].energies[-1]

Prompt for your agent

With CederGroupHub/chgnet, relax my CIF using `relaxer = StructOptimizer()` and `result = relaxer.relax(structure)`, then print the relaxed structure and total energy in eV.

Caveat. This card is written from the CederGroupHub/chgnet README, not from a test run by Deduped. Before you start, make sure you have Python and pip. Check the repo for newer instructions before you rely on these steps.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for CederGroupHub/chgnet and "Pre-relax structures before a DFT run"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer