Skip to content

Commit

Permalink
clean up and enhance comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayou-Zhang committed Dec 3, 2024
1 parent 84b762e commit 4204fdc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 49 deletions.
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", "cffi"]
requires = ["setuptools", "wheel", "cmake", "pyscf", "numpy"]
42 changes: 0 additions & 42 deletions pyscf/dft2/_libxc_header.py

This file was deleted.

3 changes: 2 additions & 1 deletion pyscf/dft2/libxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# Authors: Qiming Sun <[email protected]>
# Susi Lehtola <[email protected]>
# Dayou Zhang <[email protected]>
# This file is adapted from `dft/libxc.py` of the PySCF core module
# commit 25eaa9572977b903de24d5c11ad345cecd744728

Expand Down Expand Up @@ -876,7 +877,7 @@ def _eval_xc(xc_code, rho, spin=0, deriv=1, omega=None):
if omega is not None:
raise NotImplementedError('use register_custom_functional_() to set omega')

if _needs_laplacian(xc.nfunc, xc.xc_arr):
if xc.needs_laplacian:
raise NotImplementedError('laplacian in meta-GGA method')

nvar, xlen = xc_deriv._XC_NVAR[xctype, spin]
Expand Down
2 changes: 0 additions & 2 deletions pyscf/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ else()
endif()
endif()

option(BUILD_CFFI_API_MODE "Compiling CFFI library with CFFI API mode support" OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Whether or not to compile with MKL
Expand Down
1 change: 1 addition & 0 deletions pyscf/lib/dft/libxc_itrf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Authors: Qiming Sun <[email protected]>
* Susi Lehtola <[email protected]>
* Xing Zhang <[email protected]>
* Dayou Zhang <[email protected]>
*
* libxc from
* http://www.tddft.org/programs/octopus/wiki/index.php/Libxc:manual
Expand Down
35 changes: 32 additions & 3 deletions pyscf/mcdcft/dcfnal.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ def get_converted_rho(natorb, occ, ao, type_id, f=f_v2, negative_rho=False):
_LIBXC_REGISTER_PREFIX = '_MC-DCFT_'

def register_dcfnal_(dc_code, preset):
'''
Register a new density coherence functional. Once registered,
users may use the functional by passing `dc_code` to any MC-DCFT module.
If `dc_code` has previously been registered, the older functional will
be replaced with the new definition. New `dcfnal` isinstances must be
re-constructed after updating a functional to avoid inconsistencies.
Args:
dc_code : str
The string identifier of the density coherence functional
preset : dict
A dict that defines the functional. It can contain the following keys-value pairs:
xc_code : int or str (required)
the xc_code of the underlying Kohn-Sham functional. It follows the format of
xc_code in LibXC interface
hyb_x : float (required)
mixing factor of MCSCF exchange-correlation energy
display_name : str
display name of the functional
ext_params : dict, with LibXC functional integer ID as key, and an array-like
object containing the functional parameters as value.
Set the external parameters of the LibXC functional componet from the dict.
args : dict
keyword arguments to be passed to `get_converted_rho`. See `get_converted_rho`
for a description of the keyword arguments.
'''
libxc_register_code = _LIBXC_REGISTER_PREFIX + dc_code
libxc_base_code = preset['xc_code']

Expand All @@ -127,6 +153,10 @@ def register_dcfnal_(dc_code, preset):
_REGISTERED_PRESETS[dc_code] = preset

def unregister_dcfnal_(dc_code):
'''
Unregister a density coherence functional with name `dc_code` that was previously registered
through `register_dcfnal_`.
'''
libxc_register_code = _LIBXC_REGISTER_PREFIX + dc_code
libxc.unregister_custom_functional_(libxc_register_code)
del _REGISTERED_PRESETS[dc_code]
Expand Down Expand Up @@ -171,15 +201,14 @@ def __init__ (self, mol, dc_code, grids_level=None, verbose=0, **kwargs):
self.ms = 0.0

def get_E_dc(self, natorb, occ, ao, weight):
''' E_xc[dm] = V_xc[rho_converted]
''' E_dc[dm] = V_xc[rho_converted]
Args:
natorb : ndarray of shape (nao, nao)
generated by natorb
occ : ndarray with shape (nao,)
occupation numbers of natorb
ao : ndarray of shape (ngrids, nao) for LDA or (4, ngrids, nao) for GGA
and MGGA
ao : ndarray of shape (ngrids, nao) for LDA or (4, ngrids, nao) for GGA and MGGA
magnitude of atomic basis function [and gradients]
weight : ndarray of shape (ngrids)
containing numerical integration weights
Expand Down

0 comments on commit 4204fdc

Please sign in to comment.