Skip to content

Commit

Permalink
L-PDFT Nuclear Gradients (pyscf#43)
Browse files Browse the repository at this point in the history
* add lpdft grad

* some basic skeleton stuff

* modify lpdft to cache CI vectors etc and grad/mcpdft for gfock sym build

* might have get_wfn_response completed

* fixed? maybe the get_ci_adiabats finally?

* added some tests for wfn_response, not getting correct CI terms I know since they are not zero for fully variational case..

* fixed CI projection issue

* won't try and test wfn_response...moving on to ham_response

* need to add the EX component to derivative I think

* got to evaluating eot, vot, and fot

* need to fix vot contraction

* moved xc_response to function

* might have everything????

* trying to test h2 with no parameters

* fix coulomb and weight derivaive contribution

* agggggg off by a little

* maybe progress made?

* IT WORKS!!!!!

Signed-off-by: Matthew Hennefarth <[email protected]>

* error with core orbitals or something

* merge

* adding tests

* test but also fix lpdft log printing

* maybe some printing, but still have CI issues for lagrange...

* no update, just checking tests

* confused still

* might hvae fixed itgit status

* add tests

* remove df test and uncomment slow stuff

* add git tag info for tests

* add scanner test

* add some details for multi_state_mix...but leaving for now..

* add doc strings to some functions

* fix lint

* fix lint

* fix lint

* remove print from test

* fix np warning

* try and fix test

* clean imports for lpdft

* explicitily add _e_states

* update lpdft grad test, add mo hhe

* add hhe ci only

* add final test for hhe

* add lih ci only

* modify a comment...

* fixed for mo?

* add all lda tests

* add ftpbe test

* slight improvement, but think I can do better

* made it faster finally

* fix lint

* add pdft_feff test for delta

* add examples

* update readme

* update to include slow tests

* add space

* remove space

* add lpdft doi

---------

Signed-off-by: Matthew Hennefarth <[email protected]>
  • Loading branch information
matthew-hennefarth authored Mar 26, 2024
1 parent 5351178 commit f817911
Show file tree
Hide file tree
Showing 17 changed files with 1,198 additions and 265 deletions.
128 changes: 66 additions & 62 deletions doc/mcpdft/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Multi-configuration pair-density functional theory module for PySCF
=========================
# Multi-configuration pair-density functional theory module for PySCF

2022-11-27
2024-01-26

* Version 1.0
- Version 1.0

Install
-------
* Install to python site-packages folder
```
## Install

- Install to python site-packages folder

```sh
pip install git+https://github.com/pyscf/pyscf-forge
```

* Install in a custom folder for development
```
- Install in a custom folder for development

```sh
git clone https://github.com/pyscf/pyscf-forge /home/abc/local/path

# Set pyscf extended module path
Expand All @@ -27,64 +28,67 @@ cmake ..
make
```

Features
-------
* Multi-configuration pair-density functional theory (MC-PDFT) total electronic
## Features

- Multi-configuration pair-density functional theory (MC-PDFT) total electronic
energy calculations for wave functions of various types.
- CASCI
- CASSCF
- State-averaged CASSCF (including "mixed" solver with different spins
and/or point groups)
- Extended multi-state MC-PDFT (XMS-PDFT): [*Faraday Discuss* **2020**, 224, 348-372]
- Compressed multi-state MC-PDFT (CMS-PDFT): [*JCTC* **2020**, *16*, 7444]
- Linearized PDFT (L-PDFT): [*JCTC* **2023**, *19*, 3172]
* On-the-fly generation of on-top density functionals from underlying KS-DFT
- CASCI
- CASSCF
- State-averaged CASSCF (including "mixed" solver with different spins
and/or point groups)
- Extended multi-state MC-PDFT (XMS-PDFT): [*Faraday Discuss* **2020**, 224, 348-372]
- Compressed multi-state MC-PDFT (CMS-PDFT): [*JCTC* **2020**, *16*, 7444]
- Linearized PDFT (L-PDFT): [*JCTC* **2023**, *19*, 3172]
- On-the-fly generation of on-top density functionals from underlying KS-DFT
'LDA' or 'GGA' exchange-correlation functionals as defined in Libxc.
- Translated functionals: [*JCTC* **2014**, *10*, 3669]
- Fully-translated functionals: [*JCTC* **2015**, *11*, 4077]
- Global hybrid functionals: [*JPCL* **2020**, *11*, 10158] and
[*JCTC* **2020**, *16*, 2274]
- Notes:
1. Translation of 'meta' KS-DFT functionals which depend on the
kinetic energy density and/or Laplacian is not supported.
2. Range-separated hybrid on-top functionals are not supported.
3. Translation of functionals defined as global hybrids at the Libxc or
PySCF level is not supported, except for 'tPBE0' and 'ftPBE0'.
Other global hybrid functionals are specified using PySCF's [custom
functional parser]; see [examples/mcpdft/02-hybrid_functionals.py].
* Additional properties
- Decomposition of total electronic energy into core, Coulomb, on-top
components
- Analytical nuclear gradients (non-hybrid functionals only) for:
1. Single-state CASSCF wave function: [*JCTC* **2018**, *14*, 126]
2. State-averaged CASSCF wave functions: [*JCP* **2020**, *153*, 014106]
3. CMS-PDFT: [*Mol Phys* **2022**, 120]
- Permanent electric dipole moment (non-hybrid functionals only) for:
1. Single-state CASSCF wave function: [*JCTC* **2021**, *17*, 7586]
2. State-averaged CASSCF wave functions
3. CMS-PDFT
- Transition electric dipole moment (non-hybrid functionals only) for:
1. CMS-PDFT
- Derivative couplings for:
1. CMS-PDFT [*JPC A* **2024**]
* Multi-configuration density-coherence functional theory (MC-DCFT)
- Translated functionals: [*JCTC* **2014**, *10*, 3669]
- Fully-translated functionals: [*JCTC* **2015**, *11*, 4077]
- Global hybrid functionals: [*JPCL* **2020**, *11*, 10158] and
[*JCTC* **2020**, *16*, 2274]
- Notes:
1. Translation of 'meta' KS-DFT functionals which depend on the
kinetic energy density and/or Laplacian is not supported.
1. Range-separated hybrid on-top functionals are not supported.
1. Translation of functionals defined as global hybrids at the Libxc or
PySCF level is not supported, except for 'tPBE0' and 'ftPBE0'.
Other global hybrid functionals are specified using PySCF's [custom
functional parser][custom functional parser]; see [examples/mcpdft/02-hybrid_functionals.py].
- Additional properties
- Decomposition of total electronic energy into core, Coulomb, on-top
components
- Analytical nuclear gradients (non-hybrid functionals only) for:
1. Single-state CASSCF wave function: [*JCTC* **2018**, *14*, 126]
1. State-averaged CASSCF wave functions: [*JCP* **2020**, *153*, 014106]
1. CMS-PDFT: [*Mol Phys* **2022**, 120]
1. L-PDFT: [*JCTC* **2024**]
- Permanent electric dipole moment (non-hybrid functionals only) for:
1. Single-state CASSCF wave function: [*JCTC* **2021**, *17*, 7586]
1. State-averaged CASSCF wave functions
1. CMS-PDFT
- Transition electric dipole moment (non-hybrid functionals only) for:
1. CMS-PDFT
- Derivative couplings for:
1. CMS-PDFT [*JPC A* **2024**]
- Multi-configuration density-coherence functional theory (MC-DCFT)
total energy: [*JCTC* **2021**, *17*, 2775]

[comment]: <> (Reference hyperlinks)
[*JCTC* **2020**, *16*, 7444]: http://dx.doi.org/10.1021/acs.jctc.0c00908
[*JCTC* **2014**, *10*, 3669]: http://dx.doi.org/10.1021/ct500483t
[*JCTC* **2015**, *11*, 4077]: http://dx.doi.org/10.1021/acs.jctc.5b00609
[*JPCL* **2020**, *11*, 10158]: http://dx.doi.org/10.1021/acs.jpclett.0c02956
[*JCTC* **2020**, *16*, 2274]: http://dx.doi.org/10.1021/acs.jctc.9b01178
[*JCTC* **2018**, *14*, 126]: http://dx.doi.org/10.1021/acs.jctc.7b00967
[*JCP* **2020**, *153*, 014106]: http://dx.doi.org/10.1063/5.0007040
[*JCTC* **2021**, *17*, 7586]: http://dx.doi.org/10.1021/acs.jctc.1c00915
[*JCTC* **2021**, *17*, 2775]: http://dx.doi.org/10.1021/acs.jctc.0c01346
[*Mol Phys* **2022**, 120]: http://dx.doi.org/10.1080/00268976.2022.2110534
[*Faraday Discuss* **2020**, 224, 348-372]: http://dx.doi.org/10.1039/D0FD00037J
[*JCTC* **2023**, *19*, 3172]: https://dx.doi.org/10.1021/acs.jctc.3c00207
[*arxiv* 2401.12933]: https://dx.doi.org/10.48550/arXiv.2401.12933
[*faraday discuss* **2020**, 224, 348-372]: http://dx.doi.org/10.1039/D0FD00037J
[*jcp* **2020**, *153*, 014106]: http://dx.doi.org/10.1063/5.0007040
[*jctc* **2014**, *10*, 3669]: http://dx.doi.org/10.1021/ct500483t
[*jctc* **2015**, *11*, 4077]: http://dx.doi.org/10.1021/acs.jctc.5b00609
[*jctc* **2018**, *14*, 126]: http://dx.doi.org/10.1021/acs.jctc.7b00967
[*jctc* **2020**, *16*, 2274]: http://dx.doi.org/10.1021/acs.jctc.9b01178
[*jctc* **2020**, *16*, 7444]: http://dx.doi.org/10.1021/acs.jctc.0c00908
[*jctc* **2021**, *17*, 2775]: http://dx.doi.org/10.1021/acs.jctc.0c01346
[*jctc* **2021**, *17*, 7586]: http://dx.doi.org/10.1021/acs.jctc.1c00915
[*jctc* **2023**, *19*, 3172]: https://dx.doi.org/10.1021/acs.jctc.3c00207
[*jpcl* **2020**, *11*, 10158]: http://dx.doi.org/10.1021/acs.jpclett.0c02956
[*mol phys* **2022**, 120]: http://dx.doi.org/10.1080/00268976.2022.2110534
[*JCTC* **2024**]: https://dx.doi.org/10.1021/acs.jctc.4c00095
[*JPC A* **2024**]: https://dx.doi.org/10.1021/acs.jpca.3c07048

[comment]: <> (Code hyperlinks)
[examples/mcpdft/02-hybrid_functionals.py]: examples/mcpdft/02-hybrid_functionals.py
[custom functional parser]: https://github.com/pyscf/pyscf/blob/master/examples/dft/24-custom_xc_functional.py
[examples/mcpdft/02-hybrid_functionals.py]: examples/mcpdft/02-hybrid_functionals.py
38 changes: 25 additions & 13 deletions examples/grad/02-multi_state_mcpdft_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@
from pyscf import gto, scf, mcpdft

mol = gto.M(
atom = [
['Li', ( 0., 0. , 0. )],
['H', ( 0., 0., 1.7)]
], basis = 'sto-3g',
symmetry = 0 # symmetry enforcement is not recommended for MS-PDFT
)
atom=[
['Li', (0., 0., 0.)],
['H', (0., 0., 1.7)]
], basis='sto-3g',
symmetry=0 # symmetry enforcement is not recommended for MS-PDFT
)

mf = scf.RHF(mol)
mf.kernel()

mc = mcpdft.CASSCF(mf, 'tpbe', 2, 2)
mc.fix_spin_(ss=0) # often necessary!
mc = mc.multi_state ([.5,.5]).run ()
mc.fix_spin_(ss=0) # often necessary!

mc_grad = mc.nuc_grad_method ()
de0 = mc_grad.kernel (state=0)
de1 = mc_grad.kernel (state=1)
print ("Gradient of ground state:\n",de0)
print ("Gradient of first singlet excited state:\n",de1)
# For CMS-PDFT Gradients
cms = mc.multi_state([.5, .5], method='cms').run()

mc_grad = cms.nuc_grad_method()
de0 = mc_grad.kernel(state=0)
de1 = mc_grad.kernel(state=1)
print("CMS-PDFT Gradients")
print("Gradient of ground state:\n", de0)
print("Gradient of first singlet excited state:\n", de1)

# For L-PDFT Gradients
lpdft = mc.multi_state([0.5, 0.5], method='lin').run()

mc_grad = lpdft.nuc_grad_method()
de0 = mc_grad.kernel(state=0)
de1 = mc_grad.kernel(state=1)
print("L-PDFT Gradients")
print("Gradient of ground state:\n", de0)
print("Gradient of first singlet excited state:\n", de1)
2 changes: 1 addition & 1 deletion pyscf/df/grad/mcpdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from pyscf import lib, mcpdft
from pyscf import lib
from pyscf.grad import mcpdft as mcpdft_grad
from pyscf.df.grad import sacasscf as dfsacasscf_grad
from pyscf.df.grad import rhf as dfrhf_grad
Expand Down
4 changes: 1 addition & 3 deletions pyscf/df/grad/mspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from pyscf import lib, mcpdft
from pyscf.grad import casscf as casscf_grad
from pyscf import lib
from pyscf.grad import sacasscf as sacasscf_grad
from pyscf.grad import mspdft as mspdft_grad
from pyscf.grad import mcpdft as mcpdft_grad
from pyscf.df.grad import mcpdft as dfmcdpft_grad
from pyscf.df.grad import casscf as dfcasscf_grad
from pyscf.df.grad import sacasscf as dfsacasscf_grad
from pyscf.df.grad import rhf as dfrhf_grad
Expand Down
Loading

0 comments on commit f817911

Please sign in to comment.