Skip to content

Commit

Permalink
Merge branch 'master' into dsrg-mrpt
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhangli98 committed Jan 13, 2025
2 parents 9f9c1b4 + 0c25868 commit 2165465
Show file tree
Hide file tree
Showing 14 changed files with 1,015 additions and 28 deletions.
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MC-PDFT module within this package was developed by:

(in chronological order of first commit)
Qiming Sun
Matthew R Hermes (University of Chicago)
Dayou Zhang (University of Minnesota)
Aleksandr Lykhin (University of Chicago)
Expand All @@ -12,3 +13,4 @@ Bhavnesh Jangid
Shirong Wang
Jiachen Li <[email protected]>
Jincheng Yu <[email protected]>
Peng Bao
30 changes: 30 additions & 0 deletions examples/mcpdft/03-metaGGA_functionals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env/python
from pyscf import gto, scf, mcpdft

mol = gto.M (
atom = 'O 0 0 0; O 0 0 1.2',
basis = 'ccpvdz',
spin = 2)

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

# The translation of Meta-GGAs and hybrid-Meta-GGAs [PNAS, 122, 1, 2025, e2419413121; https://doi.org/10.1073/pnas.2419413121]

# Translated-Meta-GGA
mc = mcpdft.CASCI(mf, 'tM06L', 6, 8).run ()

# Hybrid-Translated-Meta-GGA
tM06L0 = 't' + mcpdft.hyb('M06L',0.25, hyb_type='average')
mc = mcpdft.CASCI(mf, tM06L0, 6, 8).run ()

# MC23: meta-hybrid on-top functional [PNAS, 122, 1, 2025, e2419413121; https://doi.org/10.1073/pnas.2419413121]

# State-Specific
mc = mcpdft.CASCI(mf, 'MC23', 6, 8)
mc.kernel()

# State-average
nroots=2
mc = mcpdft.CASCI(mf, 'MC23', 6, 8)
mc.fcisolver.nroots=nroots
mc.kernel()[0]
34 changes: 34 additions & 0 deletions examples/msdft/01-simple-noci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env/python

# Author: Peng Bao <[email protected]>
# Edited by: Qiming Sun <[email protected]>

from pyscf import gto, msdft

mol = gto.M(atom='''
H 1.080977 -2.558832 0.000000
H -1.080977 2.558832 0.000000
H 2.103773 -1.017723 0.000000
H -2.103773 1.017723 0.000000
H -0.973565 -1.219040 0.000000
H 0.973565 1.219040 0.000000
C 0.000000 0.728881 0.000000
C 0.000000 -0.728881 0.000000
C 1.117962 -1.474815 0.000000
C -1.117962 1.474815 0.000000
''', basis='sto-3g')

mf = msdft.NOCI(mol)
mf.xc = 'pbe0'

h = homo = mol.nelec[0] - 1
l = h + 1
# Single excitation orbital pair
mf.s = [[h,l],[h-1,l],[h,l+1],[h-1,l+1]]
# Double excitation orbital pair
mf.d = [[h,l]]

mf.run()
# reference:
#[-153.93158107 -153.8742658 -153.82198958 -153.69666086 -153.59511111
# -153.53734913 -153.5155775 -153.47367943 -153.40221993 -153.37353437]
3 changes: 2 additions & 1 deletion pyscf/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ if(NOT PYSCF_SOURCE_DIR)
endif()
message(STATUS "Include pyscf source dir: ${PYSCF_SOURCE_DIR}")
include_directories(${PYSCF_SOURCE_DIR}/lib ${PYSCF_SOURCE_DIR}/lib/deps/include)
include_directories(${CINT_DIR}/include)
include_directories(${CMAKE_INSTALL_PREFIX}/include)
configure_file(
"${PYSCF_SOURCE_DIR}/lib/config.h.in"
"${PYSCF_SOURCE_DIR}/lib/config.h")
# to find config.h
link_directories(${PYSCF_SOURCE_DIR}/lib/deps/lib ${PYSCF_SOURCE_DIR}/lib/deps/lib64)
link_directories(${PYSCF_SOURCE_DIR}/lib)
link_directories(${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64)
message(STATUS "${PYSCF_SOURCE_DIR}/lib may need to be put in the environment LD_LIBRARY_PATH")

# See also https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
Expand Down
4 changes: 2 additions & 2 deletions pyscf/lrdf/test/test_lrdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_get_jk_sr(self):
vj, vk = with_df._get_jk_sr(dm[None])
with mol.with_range_coulomb(-0.15):
jref, kref = hf.get_jk(mol, dm)
self.assertAlmostEqual(abs(jref-vj[0]).max(), 0, 11)
self.assertAlmostEqual(abs(kref-vk[0]).max(), 0, 11)
self.assertAlmostEqual(abs(jref-vj[0]).max(), 0, 8)
self.assertAlmostEqual(abs(kref-vk[0]).max(), 0, 8)

if __name__ == "__main__":
print('Full Tests for LRDF')
Expand Down
18 changes: 18 additions & 0 deletions pyscf/mcpdft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@
from pyscf.lib import logger
from pyscf.mcscf import mc1step, casci

def _sanity_check_of_mol(mc_or_mf_or_mol):
'''
Sanity check to ensure input is a mol object, not a cell object.
Raises an error for cell objects.
'''
from pyscf.pbc import gto as pbcgto
if isinstance(mc_or_mf_or_mol, (mc1step.CASSCF, casci.CASCI)):
mol = mc_or_mf_or_mol._scf.mol
elif isinstance(mc_or_mf_or_mol, gto.Mole):
mol = mc_or_mf_or_mol
else:
mol = mc_or_mf_or_mol.mol

if isinstance(mol, pbcgto.cell.Cell):
raise NotImplementedError("MCPDFT not implemented for PBC")

# NOTE: As of 02/06/2022, initializing PySCF mcscf classes with a symmetry-enabled molecule
# doesn't work.

def _MCPDFT (mc_class, mc_or_mf_or_mol, ot, ncas, nelecas, ncore=None, frozen=None,
**kwargs):
# Raise an error if mol is a cell object.
_sanity_check_of_mol(mc_or_mf_or_mol)
if isinstance (mc_or_mf_or_mol, (mc1step.CASSCF, casci.CASCI)):
mc0 = mc_or_mf_or_mol
mf_or_mol = mc_or_mf_or_mol._scf
Expand Down
4 changes: 2 additions & 2 deletions pyscf/mcpdft/_libxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from pyscf.dft.libxc import XC_ALIAS, XC_CODES, XC_KEYS
from pyscf.dft.libxc import hybrid_coeff, rsh_coeff
from pyscf.dft2.libxc import XC_ALIAS, XC_CODES, XC_KEYS
from pyscf.dft2.libxc import hybrid_coeff, rsh_coeff
from pyscf import lib

XC_ALIAS_KEYS = set (XC_ALIAS.keys ())
Expand Down
Loading

0 comments on commit 2165465

Please sign in to comment.