|
| 1 | +# torch-dftd |
| 2 | +pytorch implementation of dftd2 [1] & dftd3 [2, 3] |
| 3 | + |
| 4 | +## Install |
| 5 | + |
| 6 | +```bash |
| 7 | +git clone https://github.com/pfnet-research/torch-dftd |
| 8 | +pip install -e . |
| 9 | +``` |
| 10 | + |
| 11 | +## Quick start |
| 12 | + |
| 13 | +```python |
| 14 | +from ase.build import molecule |
| 15 | +from torch_dftd.torch_dftd3_calculator import TorchDFTD3Calculator |
| 16 | + |
| 17 | +atoms = molecule("CH3CH2OCH3") |
| 18 | +# device="cuda:0" for fast GPU computation. |
| 19 | +calc = TorchDFTD3Calculator(atoms=atoms, device="cpu", damping="bj") |
| 20 | + |
| 21 | +energy = atoms.get_potential_energy() |
| 22 | +forces = atoms.get_forces() |
| 23 | + |
| 24 | +print(f"energy {energy} eV") |
| 25 | +print(f"forces {forces}") |
| 26 | +``` |
| 27 | + |
| 28 | +## Dependency |
| 29 | + |
| 30 | +The library is tested under following environment. |
| 31 | + - python: 3.6 |
| 32 | + - CUDA: 10.2 |
| 33 | +```bash |
| 34 | +torch==1.5.1 |
| 35 | +ase==3.21.1 |
| 36 | +# Below is only for 3-body term |
| 37 | +cupy-cuda102==8.6.0 |
| 38 | +pytorch-pfn-extras==0.3.2 |
| 39 | +``` |
| 40 | + |
| 41 | +## Development tips |
| 42 | +### Formatting & Linting |
| 43 | +[pysen](https://github.com/pfnet/pysen) is used to format the python code of this repository.<br/> |
| 44 | +You can simply run below to get your code formatted :) |
| 45 | +```bash |
| 46 | +# Format the code |
| 47 | +$ pysen run format |
| 48 | +# Check the code format |
| 49 | +$ pysen run lint |
| 50 | +``` |
| 51 | + |
| 52 | +### CUDA Kernel function implementation with cupy |
| 53 | +[cupy](https://github.com/cupy/cupy) supports users to implement CUDA kernels within python code, |
| 54 | +and it can be easily linked with pytorch tensor calculations.<br/> |
| 55 | +Element wise kernel is implemented and used in some pytorch functions to accelerate speed with GPU. |
| 56 | + |
| 57 | +See [document](https://docs.cupy.dev/en/stable/user_guide/kernel.html) for details about user defined kernel. |
| 58 | + |
| 59 | +## Citation |
| 60 | + |
| 61 | +Please always cite original paper of DFT-D2 [1] or DFT-D3 [2, 3], if you used this software for your publication. |
| 62 | + |
| 63 | +DFT-D2:<br/> |
| 64 | +[1] S. Grimme, J. Comput. Chem, 27 (2006), 1787-1799. |
| 65 | +DOI: [10.1002/jcc.20495](https://doi.org/10.1002/jcc.20495) |
| 66 | + |
| 67 | +DFT-D3:<br/> |
| 68 | +[2] S. Grimme, J. Antony, S. Ehrlich and H. Krieg, J. Chem. Phys, 132 (2010), 154104. |
| 69 | +DOI: [10.1063/1.3382344](https://doi.org/10.1063/1.3382344) |
| 70 | + |
| 71 | +If BJ-damping is used in DFT-D3:<br/> |
| 72 | +[3] S. Grimme, S. Ehrlich and L. Goerigk, J. Comput. Chem, 32 (2011), 1456-1465. |
| 73 | +DOI: [10.1002/jcc.21759](https://doi.org/10.1002/jcc.21759) |
0 commit comments