# cedergrouphub/chgnet architecture

> Architecture diagram of the GitHub repository cedergrouphub/chgnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cedergrouphub/chgnet
- Repository: https://github.com/cedergrouphub/chgnet

## Overview

CHGNet is a pretrained crystal-graph neural-network potential for atomistic materials modeling. A typical workflow supplies a crystal structure, converts it into a graph, and predicts energy and optionally forces, stress, magnetic moments, or site features. Those predictions also support ASE-based relaxation and molecular dynamics. Separate product branches cover supervised fine-tuning from labeled structures and parsing VASP outputs. The graph preserves the principal model and training layers; unsampled capabilities and their links are included only where the README documents them.

Main entry points: [`chgnet/model/model.py`](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/model.py) (CHGNet predictor), [`chgnet/model/dynamics.py`](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py) (ASE calculator), [`chgnet/graph/converter.py`](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/converter.py) (Graph converter), [`chgnet/data/dataset.py`](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/data/dataset.py) (Labeled datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_graph["Crystal graphs"]
  node_converter["Graph converter<br/>[converter.py]"]
  node_crystalgraph["Crystal graph<br/>[crystalgraph.py]"]
  node_graphcore["Graph primitives<br/>[graph.py]"]
  node_fastgraph["Fast graph builder<br/>[create_graph.c]"]
  node_uthash["Hash-table support<br/>[uthash.h]"]
end

subgraph group_model["Potential model"]
  node_chgnet["CHGNet predictor<br/>[model.py]"]
  node_composition["Composition reference"]
  node_encoders["Feature encoders<br/>[encoders.py]"]
  node_basis["Radial-angular basis<br/>[basis.py]"]
  node_layers["Graph convolution layers<br/>[layers.py]"]
  node_functions["Neural-network functions<br/>[functions.py]"]
  node_pretrained["Pretrained checkpoints"]
end

subgraph group_simulation["Atomistic simulation"]
  node_calculator["ASE calculator<br/>[dynamics.py]"]
  node_relaxation["Structure relaxation<br/>[dynamics.py]"]
  node_md["Molecular dynamics<br/>[dynamics.py]"]
  node_eos["Equation of state<br/>[dynamics.py]"]
end

subgraph group_training["Training and data"]
  node_dataset["Labeled datasets<br/>[dataset.py]"]
  node_trainer["Model trainer<br/>[trainer.py]"]
end

subgraph group_utilities["Materials utilities"]
  node_vasp["VASP parser<br/>[vasp_utils.py]"]
end

node_user(("Materials user"))
node_structure["Crystal structure"]
node_predictions["Predicted properties"]
node_simulationresults["Simulation results"]

node_user -->|"provides"| node_structure
node_structure -->|"converts"| node_converter
node_converter -->|"builds"| node_crystalgraph
node_converter -->|"uses"| node_graphcore
node_converter -->|"dispatches"| node_fastgraph
node_fastgraph -->|"uses"| node_uthash
node_chgnet -->|"batches"| node_crystalgraph
node_chgnet -->|"uses"| node_composition
node_chgnet -->|"uses"| node_encoders
node_encoders -->|"uses"| node_basis
node_chgnet -->|"uses"| node_layers
node_layers -->|"uses"| node_functions
node_crystalgraph -->|"predicts from"| node_chgnet
node_pretrained -->|"initializes"| node_chgnet
node_chgnet -->|"returns"| node_predictions
node_user -->|"requests properties"| node_calculator
node_calculator -->|"evaluates"| node_chgnet
node_calculator -->|"provides properties"| node_predictions
node_user -->|"requests relaxation"| node_relaxation
node_relaxation -->|"uses"| node_calculator
node_relaxation -->|"produces"| node_simulationresults
node_user -->|"requests dynamics"| node_md
node_md -->|"uses"| node_calculator
node_md -->|"produces"| node_simulationresults
node_user -->|"requests equation of state"| node_eos
node_eos -->|"uses"| node_calculator
node_user -->|"supplies labels"| node_dataset
node_dataset -->|"converts structures"| node_converter
node_dataset -.->|"provides training data"| node_trainer
node_trainer -->|"trains"| node_chgnet
node_user -->|"provides VASP files"| node_vasp

click node_converter "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/converter.py"
click node_crystalgraph "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/crystalgraph.py"
click node_graphcore "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/graph.py"
click node_fastgraph "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/fast_converter_libraries/create_graph.c"
click node_uthash "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/fast_converter_libraries/uthash.h"
click node_chgnet "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/model.py"
click node_composition "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/composition_model.py"
click node_encoders "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/encoders.py"
click node_basis "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/basis.py"
click node_layers "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/layers.py"
click node_functions "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/functions.py"
click node_calculator "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py"
click node_relaxation "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py"
click node_md "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py"
click node_eos "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py"
click node_dataset "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/data/dataset.py"
click node_trainer "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/trainer/trainer.py"
click node_vasp "https://github.com/cedergrouphub/chgnet/blob/main/chgnet/utils/vasp_utils.py"
click node_pretrained "https://github.com/cedergrouphub/chgnet/tree/main/chgnet/pretrained"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_converter,node_crystalgraph,node_graphcore,node_fastgraph,node_uthash,node_user toneBlue
class node_chgnet,node_composition,node_encoders,node_basis,node_layers,node_functions,node_pretrained toneAmber
class node_calculator,node_relaxation,node_md,node_eos toneMint
class node_dataset,node_trainer toneRose
class node_vasp,node_structure,node_predictions,node_simulationresults toneIndigo
```

## Components

### Crystal graphs

- [Graph converter](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/converter.py): `chgnet/graph/converter.py`
- [Crystal graph](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/crystalgraph.py): `chgnet/graph/crystalgraph.py`
- [Graph primitives](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/graph.py): `chgnet/graph/graph.py`
- [Fast graph builder](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/fast_converter_libraries/create_graph.c): `chgnet/graph/fast_converter_libraries/create_graph.c`
- [Hash-table support](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/graph/fast_converter_libraries/uthash.h): `chgnet/graph/fast_converter_libraries/uthash.h`

### Potential model

- [CHGNet predictor](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/model.py): `chgnet/model/model.py`
- [Composition reference](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/composition_model.py): `chgnet/model/composition_model.py`
- [Feature encoders](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/encoders.py): `chgnet/model/encoders.py`
- [Radial-angular basis](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/basis.py): `chgnet/model/basis.py`
- [Graph convolution layers](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/layers.py): `chgnet/model/layers.py`
- [Neural-network functions](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/functions.py): `chgnet/model/functions.py`
- [Pretrained checkpoints](https://github.com/cedergrouphub/chgnet/tree/main/chgnet/pretrained): `chgnet/pretrained`

### Atomistic simulation

- [ASE calculator](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py): `chgnet/model/dynamics.py`
- [Structure relaxation](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py): `chgnet/model/dynamics.py`
- [Molecular dynamics](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py): `chgnet/model/dynamics.py`
- [Equation of state](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/model/dynamics.py): `chgnet/model/dynamics.py`

### Training and data

- [Labeled datasets](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/data/dataset.py): `chgnet/data/dataset.py`
- [Model trainer](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/trainer/trainer.py): `chgnet/trainer/trainer.py`

### Materials utilities

- [VASP parser](https://github.com/cedergrouphub/chgnet/blob/main/chgnet/utils/vasp_utils.py): `chgnet/utils/vasp_utils.py`

### Other components

- **Materials user**
- **Crystal structure**
- **Predicted properties**
- **Simulation results**

## Connections

- Materials user → Crystal structure: provides (evidence: `README.md`)
- Crystal structure → Graph converter: converts (evidence: `chgnet/graph/converter.py`)
- Graph converter → Crystal graph: builds (evidence: `chgnet/graph/converter.py`)
- Graph converter → Graph primitives: uses (evidence: `chgnet/graph/converter.py`)
- Graph converter → Fast graph builder: dispatches (evidence: `chgnet/graph/converter.py`)
- Fast graph builder → Hash-table support: uses (evidence: `chgnet/graph/fast_converter_libraries/create_graph.c`)
- CHGNet predictor → Crystal graph: batches (evidence: `chgnet/model/model.py`)
- CHGNet predictor → Composition reference: uses (evidence: `chgnet/model/model.py`)
- CHGNet predictor → Feature encoders: uses (evidence: `chgnet/model/model.py`)
- Feature encoders → Radial-angular basis: uses (evidence: `chgnet/model/encoders.py`)
- CHGNet predictor → Graph convolution layers: uses (evidence: `chgnet/model/model.py`)
- Graph convolution layers → Neural-network functions: uses (evidence: `chgnet/model/layers.py`)
- Crystal graph → CHGNet predictor: predicts from (evidence: `README.md`)
- Pretrained checkpoints → CHGNet predictor: initializes (evidence: `chgnet/model/model.py`)
- CHGNet predictor → Predicted properties: returns (evidence: `README.md`)
- Materials user → ASE calculator: requests properties (evidence: `README.md`)
- ASE calculator → CHGNet predictor: evaluates (evidence: `chgnet/model/dynamics.py`)
- ASE calculator → Predicted properties: provides properties (evidence: `README.md`)
- Materials user → Structure relaxation: requests relaxation (evidence: `README.md`)
- Structure relaxation → ASE calculator: uses (evidence: `chgnet/model/dynamics.py`)
- Structure relaxation → Simulation results: produces (evidence: `README.md`)
- Materials user → Molecular dynamics: requests dynamics (evidence: `README.md`)
- Molecular dynamics → ASE calculator: uses (evidence: `chgnet/model/dynamics.py`)
- Molecular dynamics → Simulation results: produces (evidence: `README.md`)
- Materials user → Equation of state: requests equation of state (evidence: `chgnet/model/dynamics.py`)
- Equation of state → ASE calculator: uses (evidence: `chgnet/model/dynamics.py`)
- Materials user → Labeled datasets: supplies labels (evidence: `README.md`)
- Labeled datasets → Graph converter: converts structures (evidence: `chgnet/data/dataset.py`)
- Labeled datasets → Model trainer: provides training data
- Model trainer → CHGNet predictor: trains (evidence: `chgnet/trainer/trainer.py`)
- Materials user → VASP parser: provides VASP files (evidence: `chgnet/utils/vasp_utils.py`)
