HamGNN
An E(3) equivariant Graph Neural Network for predicting electronic Hamiltonian matrix
Install / Use
/learn @QuantumLab-ZY/HamGNNREADME
🚀 HamGNN v2.1 Now Available!
Getting Started with HamGNN: Online Documentation
Table of Contents
- 1. Introduction to HamGNN
- 2. Environment Configuration Requirements
- 3. HamGNN Installation Steps
- 4. Construction Method for graph_data.npz Files
- 5. Model Training Process
- 6. Model Prediction Operations
- 7. Band Structure Calculation
- 8. Introduction to and Usage of Uni-HamGNN Universal Model
- 9. HamGNN Parameter Details
- setup (Basic Settings)
- dataset_params (Dataset Parameters)
- losses_metrics (Loss Functions and Evaluation Metrics)
- optim_params (Optimizer Parameters)
- output_nets.HamGNN_out (Output Network Parameters)
- representation_nets.HamGNN_pre (Representation Network Parameters)
- Parameter Adjustment Recommendations
- References
- Code contributors
- Project leaders
1. Introduction to HamGNN
HamGNN (Hamiltonian Graph Neural Network) is an E(3) equivariant graph neural network framework designed specifically for quantum materials simulation. Its core functionality is to train and predict ab initio tight-binding Hamiltonians, which are fundamental quantum mechanical operators describing the electronic structure of materials.
Key features of HamGNN include:
- Support for a wide range of physical scenarios: Applicable to molecules, solids, and multi-dimensional material systems with Spin-Orbit Coupling (SOC) effects, capable of handling structures from zero to three dimensions.
- Compatibility with multiple DFT software: Supports integration with mainstream density functional theory software based on Numerical Atomic Orbitals (NAO), including OpenMX, SIESTA/HONPAS, and ABACUS.
- Theoretical foundation: Employs a graph neural network architecture with E(3) rotational and translational equivariance, ensuring the predicted Hamiltonian matrices satisfy fundamental physical symmetries.
- High fidelity: Capable of approximating density functional theory (DFT) calculation results with high precision, while maintaining good cross-material structure prediction capabilities.
- Computational efficiency: Significantly improves computational efficiency for large-scale systems (such as systems containing thousands of atoms) compared to traditional DFT methods.
HamGNN's application domains primarily focus on high-throughput material design and discovery, large-scale electronic structure calculations, and quantum material property predictions, providing an efficient research tool for materials science, condensed matter physics, and computational chemistry.
According to recent research advances, HamGNN has been extended to a universal model called Uni-HamGNN, which can predict spin-orbit coupling effects across the periodic table without the need for retraining for new material systems, significantly accelerating the discovery and design process of quantum materials.
2. Environment Configuration Requirements
Python Environment
The HamGNN framework recommends Python 3.9 and depends on the following key Python libraries:
numpy == 1.21.2PyTorch == 1.11.0PyTorch Geometric == 2.0.4pytorch_lightning == 1.5.10e3nn == 0.5.0pymatgen == 2022.3.7tensorboard == 2.8.0tqdmscipy == 1.7.3yaml
Third-party DFT Tool Support
OpenMX
- OpenMX: HamGNN requires tight-binding Hamiltonians generated by OpenMX. Users should be familiar with basic OpenMX parameter settings and usage methods. Available for download from OpenMX official website.
- openmx_postprocess: This is a modified version of OpenMX used to parse calculated overlap matrices and other Hamiltonian matrices. It stores computational data in a binary file named
overlap.scfout. - read_openmx: This is a binary executable used to export matrices from the
overlap.scfoutfile toHS.json.
SIESTA/HONPAS
- honpas_1.2_H0: This is a modified version of HONPAS used to parse calculated overlap matrices and non-self-consistent Hamiltonian matrices
H0, similar to theopenmx_postprocesstool. The output is a binary file containing Hamiltonian data (overlap.HSX). - hsxdump: This is a binary executable that generates intermediate Hamiltonian files, essential for converting HONPAS output to HamGNN-readable format.
ABACUS
- abacus_postprocess: A tool used to export Hamiltonian matrices
H0.
Compiling openmx_postprocess and read_openmx
To install openmx_postprocess:
- First, install the GSL library.
- Modify the
makefilein theopenmx_postprocessdirectory:- Set
GSL_libto the path of the GSL library. - Set
GSL_includeto the include path of GSL. - Set
MKLROOTto the Intel MKL path. - Set
CMPLR_ROOTto the Intel compiler path. After modifying themakefile, executemaketo generate the executable programs:openmx_postprocessandread_openmx.
- Set
3. HamGNN Installation Steps
Step One: Install Conda Environment
To avoid library version conflicts, it is recommended to use one of the following two methods:
Method 1: Use Pre-built Environment (Recommended)
- Download the pre-built HamGNN Conda environment (
ML.tar.gz) from Zenodo - Extract it to the
envsfolder in your Conda installation directory:tar -xzvf ML.tar.gz -C $HOME/miniconda3/envs/ - Activate the environment:
conda activate ML
Method 2: Create Environment Using Configuration File
- Create an environment using the YAML configuration file provided by HamGNN:
conda env create -f ./HamGNN.yaml
Step Two: Install HamGNN from Source
- Clone the HamGNN repository:
git clone https://github.com/QuantumLab-ZY/HamGNN.git - Enter the HamGNN directory and execute the installation:
cd HamGNN python setup.py install - Verify that the installation was successful:
python -c "import hamgnn; print('HamGNN installed successfully')" - To upgrade HamGNN version, first uninstall the old version:
Ensure that related files in thepip uninstall HamGNNsite-packagesdirectory (such asHamGNN-x.x.x-py3.9.egg/HamGNN) have been completely removed, then reinstall the new version.
4. Construction Method for graph_data.npz Files
graph_data.npz is the core input format for HamGNN, containing material structure information and Hamiltonian matrix data. Below is an introduction to its construction method.
General Process
Regardless of which DFT software is used, the basic process for constructing graph_data.npz is as follows:
- Structure File Conversion: Convert material structure files (such as POSCAR, CIF) to the input format of the corresponding DFT software
- Non-self-consistent Hamiltonian Calculation: Use post-processing tools to generate files containing non-self-consistent Hamiltonian H0 (matrices that do not depend on self-consistent charge density, such as kinetic energy matrices)
- DFT Calculation (optional): Run a complete DFT calculation to obtain the true Hamiltonian (needed for training set construction, can be skipped for pure prediction)
- Data Packaging: Call the adapted
graph_data_genscript to package the structure and Hamiltonian matrix data intograph_data.npz
OpenMX Process
- Structure Conversion: Edit the
poscar2openmx.yamlconfiguration file, set appropriate paths and DFT parameters (for non-SOC data, setscf.SpinPolarization: Offandscf.SpinOrbit.Coupling: off; for SOC data, setscf.SpinPolarization: ncandscf.SpinOrbit.Coupling: on):system_name: 'Si' poscar_path: "/path/to/poscar/*.vasp" # Path to POSCAR or CIF files filepath: '/path/to/save/dat/file' # Directory to save OpenMX files basic_command: |+ # OpenMX calculation parameters #
