forked from pyscf/gpu4pyscf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
accelerated DFUHF hessian && smoke test
- Loading branch information
Showing
11 changed files
with
229 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: nightly build on self-hosted machine | ||
|
||
on: | ||
schedule: | ||
- cron: "0 3 * * *" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install flake8 pytest coverage gpu4pyscf-libxc-cuda11x pytest-cov dftd3 dftd4 | ||
pip3 install pyscf --upgrade | ||
git config --global core.compression 9 | ||
- name: Build GPU4PySCF | ||
run: | | ||
export CUDA_HOME=/usr/local/cuda | ||
export PATH=${CUDA_HOME}/bin:${PATH} | ||
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH | ||
sh build.sh | ||
- name: Smoke Test | ||
run: | | ||
echo $GITHUB_WORKSPACE | ||
export PYTHONPATH="${PYTHONPATH}:$(pwd)" | ||
pytest -m smoke --durations=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# Copyright 2024 The GPU4PySCF Authors. All Rights Reserved. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import numpy as np | ||
import pyscf | ||
import pytest | ||
import cupy | ||
|
||
atom = ''' | ||
C -0.07551087 1.68127663 -0.10745193 | ||
O 1.33621755 1.87147409 -0.39326987 | ||
C 1.67074668 2.95729545 0.49387976 | ||
C 0.41740763 3.77281969 0.78495878 | ||
C -0.60481480 3.07572636 0.28906224 | ||
H -0.19316298 1.01922455 0.72486113 | ||
O 0.35092043 5.03413298 1.45545728 | ||
H 0.42961487 5.74279041 0.81264173 | ||
O -1.95331750 3.53349874 0.15912025 | ||
H -2.55333895 2.78846397 0.23972698 | ||
O 2.81976302 3.20110148 0.94542226 | ||
C -0.81772499 1.09230218 -1.32146482 | ||
H -0.70955636 1.74951833 -2.15888136 | ||
C -2.31163857 0.93420736 -0.98260166 | ||
H -2.72575463 1.89080093 -0.74107186 | ||
H -2.41980721 0.27699120 -0.14518512 | ||
O -0.26428017 -0.18613595 -1.64425697 | ||
H -0.72695910 -0.55328886 -2.40104423 | ||
O -3.00083741 0.38730252 -2.10989934 | ||
H -3.93210821 0.28874990 -1.89865997 | ||
''' | ||
|
||
mol = pyscf.M(atom=atom, basis='def2-tzvpp', max_memory=32000, cart=0) | ||
mol.output = '/dev/null' | ||
mol.build() | ||
mol.verbose = 1 | ||
|
||
@pytest.mark.smoke | ||
def test_DFRKS(): | ||
print('-------- DFRKS with D3(BJ) -------') | ||
from gpu4pyscf.dft import rks | ||
mf = rks.RKS(mol, xc='b3lyp').density_fit(auxbasis='def2-tzvpp-jkfit') | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-10 | ||
mf.conv_tol_cpscf = 1e-8 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0326965348272) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.17498362161082373) < 1e-6 | ||
|
||
h = mf.Hessian().kernel() | ||
assert np.abs(cupy.linalg.norm(h) - 3.7684319231335377) < 1e-4 | ||
|
||
@pytest.mark.smoke | ||
def test_DFUKS(): | ||
print('------- DFUKS with D3(BJ) -------') | ||
from gpu4pyscf.dft import uks | ||
mf = uks.UKS(mol, xc='b3lyp').density_fit(auxbasis='def2-tzvpp-jkfit') | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-10 | ||
mf.conv_tol_cpscf = 1e-8 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0326965349493) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.17498264516108836) < 1e-6 | ||
|
||
h = mf.Hessian().kernel() | ||
assert np.abs(cupy.linalg.norm(h) - 3.768429871470736) < 1e-4 | ||
|
||
@pytest.mark.smoke | ||
def test_RKS(): | ||
print('-------- RKS with D3(BJ) -------') | ||
from gpu4pyscf.dft import rks | ||
mf = rks.RKS(mol, xc='b3lyp') | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-12 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0325611822375) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.1750368231223345) < 1e-6 | ||
|
||
@pytest.mark.smoke | ||
def test_UKS(): | ||
print('--------- UKS with D3(BJ) -------') | ||
from gpu4pyscf.dft import uks | ||
mf = uks.UKS(mol, xc='b3lyp') | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-12 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0325611823603) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.17503584692057772) < 1e-6 | ||
|
||
@pytest.mark.smoke | ||
def test_DFRKS_with_SMD(): | ||
print('----- DFRKS with SMD -----') | ||
from gpu4pyscf.dft import rks | ||
mf = rks.RKS(mol, xc='b3lyp').density_fit(auxbasis='def2-tzvpp-jkfit') | ||
mf = mf.SMD() | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-10 | ||
mf.conv_tol_cpscf = 1e-8 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0579697676872) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.16832696143145143) < 1e-6 | ||
|
||
h = mf.Hessian().kernel() | ||
assert np.abs(cupy.linalg.norm(h) - 3.750511574920911) < 1e-4 | ||
|
||
@pytest.mark.smoke | ||
def test_DFUKS_with_SMD(): | ||
print('------- DFUKS with SMD ---------') | ||
from gpu4pyscf.dft import uks | ||
mf = uks.UKS(mol, xc='b3lyp').density_fit(auxbasis='def2-tzvpp-jkfit') | ||
mf = mf.SMD() | ||
mf.grids.atom_grid = (99,590) | ||
mf.conv_tol = 1e-10 | ||
mf.conv_tol_cpscf = 1e-8 | ||
mf.disp = 'd3bj' | ||
e_dft = mf.kernel() | ||
assert np.abs(e_dft - -685.0579697677729) < 1e-8 | ||
|
||
g = mf.nuc_grad_method().kernel() | ||
assert np.abs(cupy.linalg.norm(g) - 0.16832715562574982) < 1e-6 | ||
|
||
h = mf.Hessian().kernel() | ||
assert np.abs(cupy.linalg.norm(h) - 3.7505074541182823) < 1e-4 |