|
17 | 17 | # Shirong Wang <srwang20@fudan.edu.cn> |
18 | 18 | # |
19 | 19 |
|
20 | | -"""Example: DFDH initialization — mol, SCF object, and to_dh conversion.""" |
| 20 | +"""Example: DFDH initialization""" |
21 | 21 |
|
22 | 22 | from pyscf import gto, dft |
23 | 23 | from pyscf.dh import DFDH, to_dh |
|
29 | 29 |
|
30 | 30 | print(f"B2PLYP via mol: {mf.e_tot:.8f}") |
31 | 31 |
|
32 | | -# 2. Init with converged KS SCF — reuses orbitals, skips SCF |
| 32 | +# 2. Init with converged KS SCF |
| 33 | +# DFDH allows initialization mf_or_mol, but it only accepts and reuses mf |
| 34 | +# when its xc exactly matches the DH's SCF part ("0.53*HF + 0.47*B88, 0.73*LYP" for B2PLYP) |
| 35 | +# It refuses to continue when SCF mismatches |
33 | 36 | mf_ks = dft.KS(mol, xc="0.53*HF + 0.47*B88, 0.73*LYP").density_fit().run() |
34 | 37 | mf = DFDH(mf_ks, xc="B2PLYP").run() |
35 | 38 | print(f"B2PLYP via KS: {mf.e_tot:.8f}") |
36 | 39 |
|
37 | | -# For xDH — pre-converge B3LYPg SCF for XYG3 (Proc. Natl. Acad. Sci. 2009, 106 (13), 4963–4968.) |
| 40 | +# example for xDH — pre-converge B3LYPg SCF for XYG3 (Proc. Natl. Acad. Sci. 2009, 106 (13), 4963–4968.) |
38 | 41 | mf_ks = dft.KS(mol, xc="B3LYPg").density_fit().run() |
39 | 42 | mf = DFDH(mf_ks, xc="XYG3").run() |
40 | 43 | print(f"XYG3 via B3LYPg: {mf.e_tot:.8f}") |
41 | 44 |
|
42 | | -# 3. to_dh — reuse when SCF matches |
| 45 | +# 3. to_dh — reuse when SCF matches (the same as DFDH initialization) |
43 | 46 | mf_ks = dft.KS(mol, xc="B3LYPg").density_fit().run() |
44 | 47 | mf = to_dh(mf_ks, xc="XYG3").run() |
45 | 48 | print(f"to_dh reuse XYG3: {mf.e_tot:.8f}") |
46 | 49 |
|
47 | | -# to_dh — auto-convert when SCF mismatches |
| 50 | +# to_dh also supports auto-convert when SCF mismatches |
48 | 51 | mf_ks = dft.KS(mol, xc="PBE0").density_fit().run() |
49 | 52 | mf = to_dh(mf_ks, xc="B2PLYP").run() |
50 | 53 | print(f"to_dh conv PBE0 -> B2PLYP: {mf.e_tot:.8f}") |
|
0 commit comments