Scientific machine learning system predicting physical and thermodynamic properties of solid-state crystalline materials directly from Crystallographic Information Files (CIF) using Crystal Graph Convolutional Neural Networks (CGCNN).
Traditional materials discovery relies on computationally demanding Density Functional Theory (DFT) calculations, requiring hours to days of compute per crystal structure.
CrystalMind refactors and packages the Crystal Graph Convolutional Neural Network (CGCNN) framework (pioneered by Xie & Grossman) into an offline prediction and visualization suite. By representing infinite periodic crystal lattices as multigraphs with atom-level feature vectors and distance-expanded edge tensors, the system maps crystal geometry directly to 8 fundamental physical, mechanical, and electronic properties in milliseconds.
flowchart TD
CIF[".cif Structure File (Lattice Vectors & Fractional Coordinates)"] --> Parser[pymatgen Structure Parser]
subgraph Graph Construction
Parser --> Nodes[Atom Nodes: Initialized with 92-dim Feature Vectors]
Parser --> Periodic[Periodic Boundary Neighbor Search: r <= 8.0 Angstroms]
Periodic --> Edges[Edge Tensors: 41 Gaussian Expanded Distance Bins]
end
Nodes & Edges --> ConvLayers[Gated Graph Convolutional Layers: 3-5 Layers]
subgraph CGCNN Forward Pass
ConvLayers --> GatedConv["v_i^(t+1) = v_i^(t) + Sum( σ(z_ij W_f + b_f) ⊙ g(z_ij W_s + b_s) )"]
GatedConv --> Pool[Global Normalized Mean Pooling]
end
Pool --> Hidden[Hidden Dense Layer: 128-dim + Softplus]
Hidden --> MultiHead{8 Pretrained Target Heads}
subgraph Predicted Properties
MultiHead --> P1[Band Gap in eV]
MultiHead --> P2[Formation Energy per Atom in eV]
MultiHead --> P3[Final Energy per Atom in eV]
MultiHead --> P4[Fermi Energy in eV]
MultiHead --> P5[Bulk Modulus in GPa]
MultiHead --> P6[Shear Modulus in GPa]
MultiHead --> P7[Poisson Ratio]
MultiHead --> P8[Semi-Metal Binary Classification]
end
The pipeline interfaces with 8 distinct model checkpoints targeting different physical domains:
| Property | Symbol | Units | Prediction Type |
|---|---|---|---|
| Band Gap | eV | Regression | |
| Formation Energy per Atom | eV/atom | Regression | |
| Final Energy per Atom | eV/atom | Regression | |
| Fermi Energy | eV | Regression | |
| Bulk Modulus (Voigt-Reuss-Hill) | GPa | Regression | |
| Shear Modulus (Voigt-Reuss-Hill) | GPa | Regression | |
| Poisson Ratio | Dimensionless | Regression | |
| Semi-Metal Classification | - | Binary | Classification (Softmax Logits) |
Outputs generated from sample CIF structures during validation:
- Silicon (mp-149):
- Formation energy per atom:
1.6944 eV/atom(Example inference output) - Successfully parsed lattice with 41-bin distance expansion.
- Formation energy per atom:
- Batch Processing: Evaluated across multiple mineral and semiconductor CIFs (Alumina, Rutile, Nickel, MoS2) demonstrating sub-second forward-pass throughput per structure.
Note: Because published model weights were trained on normalized target distributions without embedded normalizer parameters in the checkpoints, raw modulus values reflect normalized scales unless denormalization offsets are provided.
- Classification Logit Handling: Resolved a fatal PyTorch crash (
RuntimeError: a Tensor with 2 elements cannot be converted to Scalar) by replacing.item()withtorch.softmax()andtorch.argmax()evaluation. - Model Caching: Refactored the inference loop to preload and cache all 8 model checkpoints into memory at server startup rather than reading
.pth.tarweights from disk on every prediction. - Removed Heuristic NLP: Cleaned out pseudo-random text analysis routines present in exploratory notebooks, maintaining strict scientific integrity.
- Deep Learning: PyTorch
- Materials Informatics:
pymatgen(Python Materials Genomics),ase(Atomic Simulation Environment) - 3D Molecular Graphics:
py3Dmol, Matplotlib - Web Interface: Gradio
- Language: Python 3.10+
crystalmind/
├── README.md
├── LICENSE
├── .gitignore
├── requirements.txt
├── app.py # Gradio web application
├── configs/
│ └── atom_init.json # 92-dimensional elemental feature embeddings
├── src/
│ └── crystalmind/
│ ├── __init__.py
│ ├── model.py # CrystalGraphConvNet & ConvLayer architecture
│ ├── data.py # CIFData parser, GaussianDistance, collate_pool
│ ├── predictor.py # ModelManager service with memory caching
│ └── visualizer.py # 3D structure rendering via ASE and py3Dmol
├── notebooks/
│ └── crystalmind_experiments.ipynb
└── tests/
└── test_data.py # Unit tests for CIF parsing and feature vectors
# Clone the repository
git clone https://github.com/Ayush-Sharma99/crystalmind.git
cd crystalmind
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Download atomic feature definitions
curl -o configs/atom_init.json https://raw.githubusercontent.com/txie-93/cgcnn/master/data/sample-regression/atom_init.jsonpython app.pypytest tests/- Checkpoints Dependency: The repository contains the complete network architecture and data ingestion pipeline; execution requires pointing
CRYSTALMIND_MODEL_DIRto the pretrained.pth.tarweights. - Normalization Inversion: Modulus models output raw normalized predictions because normalization statistics (mean/std) were external to the original serialized checkpoints.
- Syntactic Parsing: Irregular or non-standard CIF formatting lacking fractional atomic coordinates may require pre-cleaning via
pymatgen.io.cif.
MIT License. See LICENSE for details.
Developed by Ayush Sharma.