|
| 1 | +#!/usr/bin/env python |
| 2 | +# Copyright 2021-2025 The PySCF Developers. All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +''' |
| 17 | +NACV for TDDFT-RIS |
| 18 | +''' |
| 19 | + |
| 20 | +# This example will gives the derivative coupling (DC), |
| 21 | +# also known as NACME (non-adiabatic coupling matrix element) |
| 22 | +# between ground and excited states. |
| 23 | + |
| 24 | +import numpy as np |
| 25 | +import pyscf |
| 26 | +import gpu4pyscf |
| 27 | +from gpu4pyscf.dft import rks |
| 28 | +from gpu4pyscf.tdscf import ris |
| 29 | + |
| 30 | +atom = ''' |
| 31 | +O 0.0000000000 -0.0000000000 0.1174000000 |
| 32 | +H -0.7570000000 -0.0000000000 -0.4696000000 |
| 33 | +H 0.7570000000 0.0000000000 -0.4696000000 |
| 34 | +''' |
| 35 | + |
| 36 | +mol = pyscf.M(atom=atom, basis='def2tzvp') |
| 37 | + |
| 38 | +mf = rks.RKS(mol, xc='pbe0') # -76.3773133945678 |
| 39 | +mf.conv_tol = 1e-10 |
| 40 | +mf.kernel() |
| 41 | + |
| 42 | +td = mf.TDA().set(nstates=5) |
| 43 | +td.kernel() # [ 7.81949919 9.71029362 10.13398432 12.10163229 13.93675959] |
| 44 | + |
| 45 | +nac = td.nac_method() |
| 46 | +nac.states=(1,2) |
| 47 | +nac.kernel() |
| 48 | +""" |
| 49 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2---------- |
| 50 | + x y z |
| 51 | +0 O -0.0975602441 -0.0000000000 -0.0000000000 |
| 52 | +1 H 0.0548213338 -0.0000000000 0.0360881697 |
| 53 | +2 H 0.0548213338 0.0000000000 -0.0360881697 |
| 54 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 after E scaled (divided by E)---------- |
| 55 | + x y z |
| 56 | +0 O -1.4040391809 -0.0000000000 -0.0000000000 |
| 57 | +1 H 0.7889617464 -0.0000000000 0.5193632370 |
| 58 | +2 H 0.7889617464 0.0000000000 -0.5193632370 |
| 59 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 with ETF---------- |
| 60 | + x y z |
| 61 | +0 O -0.0965494688 -0.0000000000 -0.0000000000 |
| 62 | +1 H 0.0482746550 -0.0000000000 0.0378920920 |
| 63 | +2 H 0.0482746550 0.0000000000 -0.0378920920 |
| 64 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 with ETF after E scaled (divided by E)---------- |
| 65 | + x y z |
| 66 | +0 O -1.3894925990 -0.0000000000 -0.0000000000 |
| 67 | +1 H 0.6947451570 -0.0000000000 0.5453244023 |
| 68 | +2 H 0.6947451570 0.0000000000 -0.5453244023 |
| 69 | +---------------------------------------------- |
| 70 | +""" |
| 71 | + |
| 72 | +td_ris = ris.TDA(mf=mf.to_gpu(), nstates=5, spectra=False, single=False, gram_schmidt=True, Ktrunc=0.0) |
| 73 | +td_ris.conv_tol = 1.0E-6 |
| 74 | +td_ris.kernel() # [ 7.56352157 9.65590898 10.12364072 12.09873136 13.921372 ] |
| 75 | +print(td_ris.energies.get()) |
| 76 | + |
| 77 | +nac_ris = td_ris.nac_method() |
| 78 | +nac_ris.states=(1,2) |
| 79 | +nac_ris.kernel() |
| 80 | +""" |
| 81 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2---------- |
| 82 | + x y z |
| 83 | +0 O 0.1009731844 0.0000000000 -0.0000000014 |
| 84 | +1 H -0.0575662857 -0.0000000000 -0.0380920213 |
| 85 | +2 H -0.0575662879 0.0000000000 0.0380920227 |
| 86 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 after E scaled (divided by E)---------- |
| 87 | + x y z |
| 88 | +0 O 1.3131508452 0.0000000000 -0.0000000181 |
| 89 | +1 H -0.7486464564 -0.0000000000 -0.4953846935 |
| 90 | +2 H -0.7486464849 0.0000000000 0.4953847117 |
| 91 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 with ETF---------- |
| 92 | + x y z |
| 93 | +0 O 0.1006324741 0.0000000000 -0.0000000015 |
| 94 | +1 H -0.0503161533 -0.0000000000 -0.0395091578 |
| 95 | +2 H -0.0503161556 0.0000000000 0.0395091592 |
| 96 | +--------- TDA nonadiabatic derivative coupling for states 1 and 2 with ETF after E scaled (divided by E)---------- |
| 97 | + x y z |
| 98 | +0 O 1.3087199253 0.0000000000 -0.0000000189 |
| 99 | +1 H -0.6543588731 -0.0000000000 -0.5138144769 |
| 100 | +2 H -0.6543589035 0.0000000000 0.5138144958 |
| 101 | +---------------------------------------------- |
| 102 | +""" |
| 103 | + |
| 104 | +print("defference for excitation energy between TDA and TDA-ris (in eV)") |
| 105 | +print(td.e*27.21138602 - td_ris.energies.get()) |
| 106 | +print() |
| 107 | +""" |
| 108 | +[0.25597762 0.05438464 0.01034359 0.00290093 0.01538759] |
| 109 | +""" |
| 110 | +print("CIS derivative coupling without ETF") |
| 111 | +print(np.abs(nac.de_scaled) - np.abs(nac_ris.de_scaled)) |
| 112 | +print("norm of difference", np.linalg.norm(np.abs(nac.de_scaled) - np.abs(nac_ris.de_scaled))) |
| 113 | +print() |
| 114 | +""" |
| 115 | +[[ 9.08883357e-02 7.20409145e-15 -1.80700507e-08] |
| 116 | + [ 4.03152900e-02 1.15468620e-14 2.39785435e-02] |
| 117 | + [ 4.03152615e-02 1.77621884e-16 2.39785253e-02]] |
| 118 | + 0.11252232092869598 |
| 119 | +""" |
| 120 | +print("difference for CIS derivative coupling with ETF") |
| 121 | +print(np.abs(nac.de_etf_scaled) - np.abs(nac_ris.de_etf_scaled)) |
| 122 | +print("norm of difference", np.linalg.norm(np.abs(nac.de_etf_scaled) - np.abs(nac_ris.de_etf_scaled))) |
| 123 | +print() |
| 124 | +""" |
| 125 | +[[ 8.07726737e-02 1.38040250e-14 -1.88986440e-08] |
| 126 | + [ 4.03862838e-02 1.32300610e-14 3.15099254e-02] |
| 127 | + [ 4.03862535e-02 -6.54111691e-16 3.15099065e-02]] |
| 128 | +0.10849919731015174 |
| 129 | +""" |
| 130 | + |
0 commit comments