# Crystal Structure Prediction by Joint Equivariant Diffusion (NeurIPS 2023) Implementation codes for Crystal Structure Prediction by Joint Equivariant Diffusion (DiffCSP). [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/jiaor17/DiffCSP/blob/main/LICENSE) [**[Paper]**](https://arxiv.org/abs/2309.04475) ![Overview](fig/overview.png "Overview") ![Demo](fig/demo.gif "Demo") ### Dependencies and Setup ``` python==3.8.13 torch==1.9.0 torch-geometric==1.7.2 pytorch_lightning==1.3.8 pymatgen==2023.8.10 ``` Rename the `.env.template` file into `.env` and specify the following variables. ``` PROJECT_ROOT: the absolute path of this repo HYDRA_JOBS: the absolute path to save hydra outputs WABDB_DIR: the absolute path to save wabdb outputs ``` ### Training For the CSP task ``` python diffcsp/run.py data= expname= ``` For the Ab Initio Generation task ``` python diffcsp/run.py data= model=diffusion_w_type expname= ``` The ```` tag can be selected from perov_5, mp_20, mpts_52 and carbon_24, and the ```` tag can be an arbitrary name to identify each experiment. Pre-trained checkpoints are provided [here](https://drive.google.com/drive/folders/11WOc9lTZN4hkIY7SKLCIrbsTMGy9TsoW?usp=sharing). ### Evaluation #### Stable structure prediction One sample ``` python scripts/evaluate.py --model_path --dataset python scripts/compute_metrics.py --root_path --tasks csp --gt_file data//test.csv ``` Multiple samples ``` python scripts/evaluate.py --model_path --dataset --num_evals 20 python scripts/compute_metrics.py --root_path --tasks csp --gt_file data//test.csv --multi_eval ``` #### Ab initio generation ``` python scripts/generation.py --model_path --dataset python scripts/compute_metrics.py --root_path --tasks gen --gt_file data//test.csv ``` #### Sample from arbitrary composition ``` python scripts/sample.py --model_path --save_path --formula --num_evals ``` #### Property Optimization ``` # train a time-dependent energy prediction model python diffcsp/run.py data= model=energy expname= data.datamodule.batch_size.test=100 # Optimization python scripts/optimization.py --model_path --uncond_path # Evaluation python scripts/compute_metrics.py --root_path --tasks opt ``` ### Acknowledgments The main framework of this codebase is build upon [CDVAE](https://github.com/txie-93/cdvae). For the datasets, Perov-5, Carbon-24 and MP-20 are from [CDVAE](https://github.com/txie-93/cdvae), and MPTS-52 is collected from its original [codebase](https://github.com/sparks-baird/mp-time-split). ### Citation Please consider citing our work if you find it helpful: ``` @article{jiao2023crystal, title={Crystal structure prediction by joint equivariant diffusion}, author={Jiao, Rui and Huang, Wenbing and Lin, Peijia and Han, Jiaqi and Chen, Pin and Lu, Yutong and Liu, Yang}, journal={arXiv preprint arXiv:2309.04475}, year={2023} } ``` ### Contact If you have any questions, feel free to reach us at: Rui Jiao: [jiaor21@mails.tsinghua.edu.cn](mailto:jiaor21@mails.tsinghua.edu.cn)