|
| 1 | +# Copyright 2021-2025 The PySCF Developers. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +# Example of TDDFT-ris |
| 17 | + |
| 18 | + |
| 19 | +import pyscf |
| 20 | +from gpu4pyscf.dft import rks |
| 21 | +import gpu4pyscf.tdscf.ris as ris |
| 22 | + |
| 23 | +atom =''' |
| 24 | +C -4.89126 3.29770 0.00029 |
| 25 | +H -5.28213 3.05494 -1.01161 |
| 26 | +O -3.49307 3.28429 -0.00328 |
| 27 | +H -5.28213 2.58374 0.75736 |
| 28 | +H -5.23998 4.31540 0.27138 |
| 29 | +H -3.22959 2.35981 -0.24953 |
| 30 | +''' |
| 31 | + |
| 32 | +mol = pyscf.M(atom=atom, basis='def2-svp', verbose=4) |
| 33 | +mf = rks.RKS(mol, xc='wb97x').density_fit() |
| 34 | + |
| 35 | +e_dft = mf.kernel() |
| 36 | +print(f"total energy = {e_dft}") |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +''' TDDFT-ris''' |
| 41 | +td = ris.TDDFT(mf=mf.to_gpu(), nstates=10, spectra=True) |
| 42 | +td.kernel() |
| 43 | +# energies, X, Y, oscillator_strength, rotatory_strength = td.kernel() |
| 44 | + |
| 45 | +energies = td.energies |
| 46 | +# X = td.X |
| 47 | +# Y = td.Y |
| 48 | +oscillator_strength = td.oscillator_strength |
| 49 | +rotatory_strength = td.rotatory_strength |
| 50 | + |
| 51 | +print("TDDFT-ris ex energies", energies) |
| 52 | +print("TDDFT-ris oscillator_strength", oscillator_strength) |
| 53 | + |
| 54 | +''' TDA-ris''' |
| 55 | +td = ris.TDA(mf=mf.to_gpu(), nstates=10) |
| 56 | +td.kernel() |
| 57 | +# energies, X, oscillator_strength, rotatory_strength = td.kernel() |
| 58 | + |
| 59 | +energies = td.energies |
| 60 | +# X = td.X |
| 61 | +oscillator_strength = td.oscillator_strength |
| 62 | +rotatory_strength = td.rotatory_strength |
| 63 | + |
| 64 | +print("TDA-ris ex energies", energies) |
| 65 | +print("TDA-ris oscillator_strength", oscillator_strength) |
| 66 | + |
| 67 | + |
| 68 | + |
0 commit comments