Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new LibXC interface and new MC-DCFT code #70

Merged
merged 36 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
045023e
new libxc interface
Dayou-Zhang Aug 14, 2024
7aefa6a
add cffi dependency
Dayou-Zhang Aug 14, 2024
187384c
fix cffi dependency
Dayou-Zhang Aug 14, 2024
56c75f8
bug fix
Dayou-Zhang Aug 16, 2024
a796ea9
improve libxc interface - migrate all ctypes interfaces to cffi
Dayou-Zhang Aug 17, 2024
f442388
bug fix
Dayou-Zhang Aug 17, 2024
d551987
optimize performance for libxc interface
Dayou-Zhang Aug 24, 2024
5e04f74
libxc interface enhancement
Dayou-Zhang Aug 24, 2024
79d484b
use new libxc interface for mcdcft
Dayou-Zhang Aug 27, 2024
9f2ed59
new mcdcft implementation
Dayou-Zhang Sep 13, 2024
2c39d48
clean up
Dayou-Zhang Sep 13, 2024
b22f5f5
clean up
Dayou-Zhang Sep 13, 2024
2518eb7
Merge branch 'pyscf:master' into mc-dcft
Dayou-Zhang Sep 14, 2024
fe54aa1
use Python 3.8 for automated test - trexio no longer publish wheels f…
Dayou-Zhang Sep 14, 2024
576f381
improve mcdcft __init__
Dayou-Zhang Sep 17, 2024
6be6af6
clean up and performance enhancement
Dayou-Zhang Sep 21, 2024
cdb8913
add mcdcft preset
Dayou-Zhang Sep 24, 2024
02952d8
clean up, improve comments, and fix examples
Dayou-Zhang Sep 25, 2024
59edbde
fix edge case: natorb from molden file may not be square matrix
Dayou-Zhang Sep 25, 2024
1515355
improve example and test; enhance chkfile handling
Dayou-Zhang Sep 26, 2024
fd476ee
Merge branch 'pyscf:master' into mc-dcft
Dayou-Zhang Sep 26, 2024
ac3029d
Merge branch pyscf:master into mc-dcft
Dayou-Zhang Sep 26, 2024
27eee5f
update libxc interface according to PySCF 2.7 (commit 410d960)
Dayou-Zhang Sep 27, 2024
f7d9c7f
Revert "use Python 3.8 for automated test - trexio no longer publish …
Dayou-Zhang Sep 27, 2024
2d45d55
Merge branch 'pyscf:master' into mc-dcft
Dayou-Zhang Sep 27, 2024
0d2fec4
add comments to files adapted from PySCF core modules
Dayou-Zhang Sep 27, 2024
d36df2e
implement LibXC interface using CFFI ABI mode
Dayou-Zhang Sep 29, 2024
4479a33
add example to set MC-DCFT functional parameters
Dayou-Zhang Sep 30, 2024
c8a456b
new LibXC interface based on ctypes
Dayou-Zhang Nov 27, 2024
fe96ca5
resolve conflict
Dayou-Zhang Nov 27, 2024
c9e0fc4
Merge branch 'pyscf:master' into mc-dcft
Dayou-Zhang Nov 27, 2024
84b762e
bug fix
Dayou-Zhang Nov 28, 2024
4204fdc
clean up and enhance comments
Dayou-Zhang Dec 3, 2024
f05a52d
enhance comment
Dayou-Zhang Dec 3, 2024
3d12660
Merge branch 'pyscf:master' into mc-dcft
Dayou-Zhang Dec 3, 2024
db925d1
minor enhancement
Dayou-Zhang Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ include pyscf/lib/*.so
# macos dynamic libraries
include pyscf/lib/*.dylib

# include libxc_cffi
include pyscf/dft2/libxc_cffi.*

# source code
prune pyscf/lib/build
recursive-include pyscf/lib *.c *.h CMakeLists.txt
14 changes: 6 additions & 8 deletions examples/mcdcft/01_h2_potential_curve.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import pyscf
from pyscf import scf, gto, mcscf, lib
from pyscf import scf, gto, lib, mcscf, mcdcft
import numpy as np
#from pyscf.fci import csf_solver
from pyscf.mcdcft import mcdcft

'''
This input file performs a potential energy scan of H2 using cBLYP (density
coherence functional without reparameterization).
'''

xc_preset = dict(args=dict(f=mcdcft.dcfnal.f_v1, negative_rho=True))

def run(r, chkfile=None, mo_coeff=None):
r /= 2
mol = gto.M(atom=f'H 0 0 {r}; H 0 0 -{r}', basis='cc-pvtz',
r *= 0.5
mol = gto.M(atom=f'H 0 0 {r}; H 0 0 -{r}', basis='cc-pvtz',
symmetry=False, verbose=3, unit='angstrom')
mf = scf.RHF(mol)
mf.kernel()
mc = mcdcft.CASSCF(mf, 'BLYP', 2, 2, ot_name='cBLYP',
mc = mcdcft.CASSCF(mf, 'BLYP', 2, 2, xc_preset=xc_preset,
grids_level=6)
#mc.fcisolver = csf_solver(mol, smult=1)
mc.fix_spin_(ss=0)
Expand All @@ -39,7 +38,6 @@ def scan():
if mc and mc.converged:
mo_coeff = mc.mo_coeff
e_tot = mc.e_tot
mc.dump_mcdcft_chk(chkfile)
else:
print(f"Warning: bond distance {r:02.2f} not converged")

Expand Down
22 changes: 10 additions & 12 deletions examples/mcdcft/02_h2_potential_curve_restart.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import pyscf
from pyscf import scf, gto, mcscf, lib
from pyscf import scf, gto, mcscf, lib, mcdcft
import numpy as np
#from pyscf.fci import csf_solver
from pyscf.mcdcft import mcdcft

'''
This input file performs a potential energy scan of H2 using cBLYP-2 (density coherence functional with reparameterization). It will read the checkpoint files generated by example 01.
This input file performs a potential energy scan of H2 using cBLYP-2 (density coherence functional
with reparameterization). It will read the checkpoint files generated by example 01.
'''

xc_preset = dict(args=dict(f=mcdcft.dcfnal.f_v1, negative_rho=True), display_name='cBLYP-2')

def run(chkfile):
mol = lib.chkfile.load_mol(chkfile)
mol.verbose = 3
mf = scf.RHF(mol)
mc = mcdcft.CASSCF(mf, None, 2, 2, grids_level=6)
mc = mcdcft.DCFT_base(mol, grids_level=6)
mc.load_mcdcft_chk(chkfile)
mc.recalculate_with_xc('0.92 * B88 , 1.59 * LYP',
ot_name='cBLYP-2', dump_chk=chkfile)
mc.recalculate_with_xc('0.92 * B88 , 1.59 * LYP',
xc_preset=xc_preset, dump_chk=chkfile)
return mc


def scan():
mo_coeff = None
method = 'MC-DCFT'

rrange = np.arange(0.5, 6.1, 0.1)

for r in rrange:
chkfile = f'{method}_{r:02.2f}.chk'
mc = run(chkfile)
run(chkfile)


if __name__ == '__main__':
lib.num_threads(2)
Expand Down
14 changes: 14 additions & 0 deletions examples/mcdcft/03_DC24_single_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pyscf import scf, gto, mcdcft

'''
This input file performs a single point energy calculation of H2 with DC24.
'''

mol = gto.M(atom='H 0 0 0; H 0 0 0.74', basis='def2-tzvp',
symmetry=False, verbose=3, unit='angstrom')
mf = scf.RHF(mol)
mf.kernel()
mc = mcdcft.CASSCF(mf, 'DC24', 2, 2, grids_level=(99, 590))
mc.chkfile = 'H2_DC24.chk'
mc.kernel()

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "cmake", "pyscf", "numpy"]
requires = ["setuptools", "wheel", "cmake", "pyscf", "numpy", "cffi"]
16 changes: 16 additions & 0 deletions pyscf/dft2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# Copyright 2014-2022 The PySCF Developers. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from pyscf.dft2 import libxc
Loading
Loading