Skip to content

Commit

Permalink
add the example of tddft gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
puzhichen committed Feb 25, 2025
1 parent afbafdf commit 8f1d05c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/26-tddft.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
print('------------------- TDDFT -----------------------------')
td = mf.TDDFT().set(nstates=5)
assert td.device == 'gpu'
e_tddft = td.kernel()[0] # [ 7.51061148 9.42243504 9.76601005 11.74384344 13.5974535 ]
e_tddft = td.kernel()[0] # [ 7.51061679 9.42244054 9.76601486 11.7438481 13.59746126]
print('5 TDDFT excitation energy by GPU4PySCF')

print('------------------- TDA -----------------------------')
Expand Down
18 changes: 15 additions & 3 deletions examples/27-tddft_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@
print('------------------- TDDFT -----------------------------')
td = mf.TDDFT().set(nstates=5)
assert td.device == 'gpu'
td.lindep=1.0E-6
e_tddft = td.kernel()[0] # [ 7.51061148 9.42243504 9.76601005 11.74384344 13.5974535 ]
e_tddft = td.kernel()[0] # [ 7.51061679 9.42244054 9.76601486 11.7438481 13.59746126]
print('The gradient of first TDDFT excitation energy by GPU4PySCF')
g = td.nuc_grad_method()
g.kernel()
"""
--------- TDDFT gradients for state 1 ----------
x y z
0 O -0.0000000000 -0.0000000000 -0.0905260686
1 H 0.0605260326 0.0000000000 0.0452632584
2 H -0.0605260326 0.0000000000 0.0452632584
----------------------------------------------
"""

print('------------------- TDA -----------------------------')
Expand All @@ -54,4 +59,11 @@
print('The gradient of first TDA excitation energy by GPU4PySCF')
g = td.nuc_grad_method()
g.kernel()

"""
--------- TDA gradients for state 1 ----------
x y z
0 O -0.0000000000 0.0000000000 -0.0901093713
1 H 0.0598455827 -0.0000000000 0.0450549086
2 H -0.0598455827 -0.0000000000 0.0450549086
----------------------------------------------
"""

0 comments on commit 8f1d05c

Please sign in to comment.