# AI use cases for Chgnet (CederGroupHub/chgnet)

Repo: [CederGroupHub/chgnet](https://github.com/CederGroupHub/chgnet) | Use cases: 3 | Page: https://dedupedai.com/use-cases/cedergrouphub-chgnet/

CHGNet is a pretrained universal neural network potential for charge-informed atomistic modeling. It is trained on Materials Project trajectories and predicts energy, forces, stress and magnetic moments of a crystal structure with near DFT accuracy, and runs structure relaxation and molecular dynamics through a Python API.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Predict energy, forces and magnetic moments of a crystal: https://dedupedai.com/use-cases/cedergrouphub-chgnet/predict-crystal-energy-forces-and-magmoms-with-chgnet/
- Pre-relax structures before a DFT run: https://dedupedai.com/use-cases/cedergrouphub-chgnet/pre-relax-structures-before-dft-with-chgnet/
- Run a short charge-informed molecular dynamics simulation: https://dedupedai.com/use-cases/cedergrouphub-chgnet/run-charge-informed-molecular-dynamics-with-chgnet/

## How to predict energy, forces and magnetic moments of a crystal with Chgnet

Repo: [CederGroupHub/chgnet](https://github.com/CederGroupHub/chgnet) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Load a pretrained CHGNet and run a static calculation on a CIF structure.

**Who it is for:** A materials scientist who needs a quick estimate before spending DFT time.

**The problem:** A DFT static calculation for every candidate structure is slow and costly.

**The outcome:** Predicted energy per atom, forces, stress and magnetic moments for your structure.

### Steps

1. Install with `pip install chgnet`
2. Load the default model with `chgnet = CHGNet.load()`
3. Read your structure with `Structure.from_file('examples/mp-18767-LiMnO2.cif')`, using your own CIF path
4. Call `chgnet.predict_structure(structure)` to get the prediction
5. Print energy (eV/atom), forces (eV/A), stress (GPa) and magmom (mu_B) from the result

### Prompt to paste into your agent

```text
Using CederGroupHub/chgnet, install it with `pip install chgnet`, load a CIF with pymatgen and run `chgnet.predict_structure(structure)`. Print energy, forces, stress and magmom with their units.
```

### Caveat

Predictions are model estimates, so check anything important against DFT.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/cedergrouphub-chgnet/predict-crystal-energy-forces-and-magmoms-with-chgnet/

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

Repo: [CederGroupHub/chgnet](https://github.com/CederGroupHub/chgnet) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

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

**Who it is for:** A computational chemist preparing inputs for a spin-polarized DFT calculation.

**The problem:** Starting DFT from an unrelaxed structure wastes many ionic steps.

**The outcome:** A relaxed structure and its total energy, ready to hand to your DFT workflow.

### 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 to paste into your agent

```text
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.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/cedergrouphub-chgnet/pre-relax-structures-before-dft-with-chgnet/

## How to run a short charge-informed molecular dynamics simulation with Chgnet

Repo: [CederGroupHub/chgnet](https://github.com/CederGroupHub/chgnet) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Drive an ASE molecular dynamics run with the pretrained model on a crystal.

**Who it is for:** A battery or ceramics researcher who wants to see atoms move at high temperature without DFT cost.

**The problem:** Ab initio molecular dynamics is too expensive for quick exploration.

**The outcome:** A trajectory file and log from an NVT run at the temperature you choose.

### Steps

1. Install with `pip install chgnet`
2. Load the structure and model as in the README example
3. Build `MolecularDynamics` with `ensemble="nvt"`, a temperature, a timestep, `trajectory="md_out.traj"` and `logfile="md_out.log"`
4. Start it with `md.run(50)`, a 0.1 ps simulation in the README example
5. Open md_out.traj and md_out.log to inspect the run

### Prompt to paste into your agent

```text
Using CederGroupHub/chgnet, run `MolecularDynamics` with ensemble nvt on my CIF at <temperature> K, timestep 2, then call `md.run(50)` and summarise md_out.log.
```

### Caveat

The README notes MatPES-trained models in MatGL are expected to do better for non ground state work like molecular dynamics.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/cedergrouphub-chgnet/run-charge-informed-molecular-dynamics-with-chgnet/
