Skip to content

Commit faa5414

Browse files
committed
update comments in example
1 parent 0fa3f27 commit faa5414

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎examples/dh/01-init.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Shirong Wang <srwang20@fudan.edu.cn>
1818
#
1919

20-
"""Example: DFDH initialization — mol, SCF object, and to_dh conversion."""
20+
"""Example: DFDH initialization"""
2121

2222
from pyscf import gto, dft
2323
from pyscf.dh import DFDH, to_dh
@@ -29,22 +29,25 @@
2929

3030
print(f"B2PLYP via mol: {mf.e_tot:.8f}")
3131

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
3336
mf_ks = dft.KS(mol, xc="0.53*HF + 0.47*B88, 0.73*LYP").density_fit().run()
3437
mf = DFDH(mf_ks, xc="B2PLYP").run()
3538
print(f"B2PLYP via KS: {mf.e_tot:.8f}")
3639

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.)
3841
mf_ks = dft.KS(mol, xc="B3LYPg").density_fit().run()
3942
mf = DFDH(mf_ks, xc="XYG3").run()
4043
print(f"XYG3 via B3LYPg: {mf.e_tot:.8f}")
4144

42-
# 3. to_dh — reuse when SCF matches
45+
# 3. to_dh — reuse when SCF matches (the same as DFDH initialization)
4346
mf_ks = dft.KS(mol, xc="B3LYPg").density_fit().run()
4447
mf = to_dh(mf_ks, xc="XYG3").run()
4548
print(f"to_dh reuse XYG3: {mf.e_tot:.8f}")
4649

47-
# to_dh — auto-convert when SCF mismatches
50+
# to_dh also supports auto-convert when SCF mismatches
4851
mf_ks = dft.KS(mol, xc="PBE0").density_fit().run()
4952
mf = to_dh(mf_ks, xc="B2PLYP").run()
5053
print(f"to_dh conv PBE0 -> B2PLYP: {mf.e_tot:.8f}")

0 commit comments

Comments
 (0)