Skip to content

Commit

Permalink
Adds r2SCAN hybrids; r2SCAN-3c and B97-3c (psi4#2842)
Browse files Browse the repository at this point in the history
* adds couple of r2scan based functionals

* 3c update, + scan hybrid functionals

* dft printing doi formatting

* allow omitting default disp params; turn gcp on

* cleanup

* adds basis set files

* add <optional> header

* prevent r2scan3c dict from building; get new QCEngine

* allow custom qcng in CI

* py packaging wants to control us

* right number

* ok, setuptools via packaging wants to control us

* they're working together

* one back

* more errors

* fix bib

* full spec

* add some tests

* touchups

* check everything

* fixup

* fixups

* condense another fctl

* fixes

---------

Co-authored-by: Lori A. Burns <[email protected]>
  • Loading branch information
hokru and loriab authored Dec 5, 2023
1 parent 8e4ee09 commit 6c81789
Show file tree
Hide file tree
Showing 44 changed files with 15,048 additions and 67 deletions.
5 changes: 3 additions & 2 deletions .azure-pipelines/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

pool:
vmImage: $(vmImage)

steps:
- bash: |
[[ "${APT_REPOSITORY}" ]] && echo "Add Repo ${APT_REPOSITORY}" && sudo add-apt-repository "${APT_REPOSITORY}"
Expand Down Expand Up @@ -99,7 +99,6 @@ jobs:
echo " - psi4::gcp" >> env_p4env.yaml
echo " - psi4::dftd3" >> env_p4env.yaml
fi
sed -i "s;- libxc-c;- psi4::libxc=5;g" env_p4env.yaml
sed -i "s;- conda-forge/label/libint_dev;#- conda-forge/label/libint_dev;g" env_p4env.yaml
sed -i "s;#- psi4/label/testing::libint2;- psi4/label/testing::libint=2.8.0dev2;g" env_p4env.yaml
echo "\n<<< env_p4env.yaml >>>\n"
Expand Down Expand Up @@ -158,3 +157,5 @@ jobs:
source activate p4env
PYTHONPATH=stage/lib/ pytest -v -rws --durations=15 --durations-min=40 --strict-markers --color yes -n 2 -m "$PYTEST_MARKER_EXPR" stage/lib/psi4/tests/
displayName: 'PyTest Tests'
# setuptools v66 (vendors packaging v23) incompatible with arb. tarballs. thinks the branch names are versions
1 change: 1 addition & 0 deletions .azure-pipelines/azure-pipelines-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ jobs:
# Build package
- script: |
set INSTALL_DIR=$(Build.BinariesDirectory)\install
conda config --set channel_priority flexible
conda build --python %PYTHON_VERSION% ^
conda\win
copy /y C:\tools\miniforge3\conda-bld\win-64\psi4-*.bz2 $(Build.ArtifactStagingDirectory)
Expand Down
2 changes: 1 addition & 1 deletion codedeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ data:
commit: 6.2.2
#cmake:
# name: Libxc
# constraint: 5.1.2 # two calls: catch v5, v6
# constraint: 6.0.0
# target: Libxc::xc
components:
- C
Expand Down
6 changes: 6 additions & 0 deletions doc/sphinxman/source/basissets_tables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ Appendix :ref:`apdx:basisElement`.
+--------------+-------------+
| def2-QZVPP | def2-QZVPPD |
+--------------+-------------+
| def2-mSVP | |
+--------------+-------------+
| def2-mTZVP | |
+--------------+-------------+
| def2-mTZVPP | |
+--------------+-------------+

|
|
Expand Down
16 changes: 16 additions & 0 deletions doc/sphinxman/source/bibliography.rst
Original file line number Diff line number Diff line change
Expand Up @@ -725,3 +725,19 @@ Bibliography
F. Weigend,
*Phys. Chem. Chem. Phys.* **4**, 4285-4291 (2002).
https://doi.org/10.1039/B204199P
.. [Brandenburg:2018:b973c]
J. G. Brandenburg, C.Bannwarth, A. Hansen, S. Grimme,
*J. Chem. Phys.* **148**, 064104, (2018).
https://doi.org/10.1063/1.5012601
.. [Muller:2023:014103]
M. M\ |u_dots|\ ller and A. Hansen and S. Grimme
*J. Chem. Phys.* **158**, 014103 (2023).
https://doi.org/10.1063/5.0133026
.. [Grimme:2021:064103]
S. Grimme and A. Hansen and S. Ehlert and J.-M. Mewes
*J. Chem. Phys.* **154**, 064103 (2021).
https://doi.org/10.1063/5.0040021
4 changes: 3 additions & 1 deletion doc/sphinxman/source/build_planning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Compiling and Installing from Source
.. warning:: As of v1.8, primary binary distribution has moved from
the psi4 channel to the conda-forge channel. Neither install docs
for users nor compile docs for developers have been updated yet to
reflect new patterns. Please consult :psicode:`psicode downloads
reflect new patterns. Please consult :source:`conda/psi4-path-advisor.py`
(extensive help menu at ``conda/psi4-path-advisor.py -h``)
or :psicode:`psicode downloads
page <installs/latest/>` for the latest guides.

This section fulfills the duty of every Linux project to have an INSTALL
Expand Down
4 changes: 3 additions & 1 deletion doc/sphinxman/source/dftd3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Installation
* There are two implementations of DFTD3; see :ref:`table:empdispimpl` . The newer
"s-dftd3" one is preferred, while the older "classic" one will work for the immediate future.
|PSIfour| will automatically select whichever is available.
Starting with v1.9, only "s-dftd3" is supported, though the "classic" continues to work for many applications.

* DFTD3 is available as a conda package for Linux and macOS and Windows.

Expand Down Expand Up @@ -222,6 +223,7 @@ available only through the ``DFTD3`` or ``DFTD4`` programs. Once installed, the
``dftd3``/|PSIfour| and ``dftd4``/|PSIfour| interfaces are transparent, and all corrections are
interfaced exactly alike.
The -D3 interface can use classic or simple-dftd3 programs interchangeably and will prefer the latter.
Starting in v1.9, the classic program is no longer supported or tested, though it isn't deliberately disabled.

Despite different defaults in these programs when run independently,
when run through |PSIfour| as EmpiricalDispersion engine, each should
Expand Down Expand Up @@ -308,7 +310,7 @@ the ``dftd3``/|PSIfour| interface enables computations of three-body dispersion
corrections. In ``DFT-D3``, three-body dispersion is approximated with the
Axilrod-Teller-Muto model:

.. math:: E_{disp}^{(3)}=-\frac{1}{6}\sum_{A\neqB\neqC}\frac{C_{9}^{ABC}(3\cos{\theta_a}\cos{\theta_b}\cos{\theta_c}+1)}{(r_{AB}r_{BC}r_{AC})^{3}}f_{damp}(\bar{r}_{ABC})
.. math:: E_{disp}^{(3)}=-\frac{1}{6}\sum_{A\neq B\neq C}\frac{C_{9}^{ABC}(3\cos{\theta_a}\cos{\theta_b}\cos{\theta_c}+1)}{(r_{AB}r_{BC}r_{AC})^{3}}f_{damp}(\bar{r}_{ABC})

where :math:`\theta_a` is the angle at atom A corresponding to the triangle formed by atoms A, B, and C,
and :math:`\bar{r}_{ABC}` is the geometric mean of the corresponding atomic-pair distances.
Expand Down
33 changes: 17 additions & 16 deletions doc/sphinxman/source/gcp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Installation
* There are two implementations of gCP; see :ref:`table:empdispimpl` . The newer
"mctc" one is preferred, while the older "classic" one will work for the immediate future.
|PSIfour| will automatically select whichever is available.
Starting with v1.9, only "mctc-gcp" is supported, though the now untested
"classic" continues to work for many applications.

* gCP is available as a conda package for Linux and macOS and Windows.

Expand Down Expand Up @@ -98,15 +100,19 @@ Running gCP
~~~~~~~~~~~

At present there is a limited interface to gCP that is used
only to implement the "HF-3c" [Sure:2013:1672]_ and "PBEh-3c"
[Grimme:2015:054107]_ methods (both energy and gradient). The interface
can use classic or mctc-gcp executables interchangeably and will prefer the latter.
A :ref:`DFTD3 <sec:dftd3>` executable, classic or simple-dftd3,
must also be available for these methods to
run. Unlike every other method in |PSIfour|, if a basis set has not been
set, these will default to their intended basis sets: MINIX for HF-3c
and def2-mSVP for PBEh-3c. If a basis has previously been set, but you
want to use the default basis, use the slash syntax to "empty" the basis
only to implement the "HF-3c" [Sure:2013:1672]_, "PBEh-3c"
[Grimme:2015:054107]_, "B97-3c" [Brandenburg:2018:b973c]_, "r2SCAN-3c" [Grimme:2021:064103]_,
and "wB97X-3c" [Muller:2023:014103]_ methods (both energy and gradient).
The interface can use classic or mctc-gcp executables but only the latter implements "B97-3c" and "r2SCAN-3c".
The newest wB97X-3c method doesn't use a gcp correction (it does use ECPs down to first row elements)
but is listed here for completeness of the "3c" family.
A :ref:`DFTD3 <sec:dftd3>` executable, classic or simple-dftd3, must also be available for
the HF-3c, PBEh-3c, or B97-3c methods to run.
A :ref:`DFTD4 <sec:dftd3>` python module must also be available for
the r2SCAN-3c or wB97X-3c methods to run.
These method are defined with their own basis set and thus no basis set should be set by the user.
|PSIfour| will select the intended basis sets: HF-3c/MINIX, PBEh-3c/def2-mSVP, B97-3c/def2-mTZVP, r2SCAN-3c/def2-mTZVPP, wB97X-3c/vDZP.
If a basis has previously been set for another calculation, use the slash syntax to "empty" the basis
option for the scope of the current calculation, ``energy("hf3c/")``.

A few practical examples:
Expand All @@ -119,15 +125,10 @@ A few practical examples:

optimize('pbeh3c')

* HF-3c with non-standard basis ::
* r2SCAN-3c with default basis after basis set ::

set basis cc-pvdz
energy('hf3c')

* PBEh-3c with default basis after basis set ::

set basis cc-pvdz
energy('pbeh3c/')
energy('r2scan3c/')

If only BSSE/basis set corrections (rather than total energies) are of
interest, the ``gcp`` program can be run independently of the scf
Expand Down
9 changes: 5 additions & 4 deletions doc/sphinxman/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,11 @@ Architectures
principle, it should work on any Unix system. The latest version of the
|PSIfour| program package may be obtained at `psicode.org <http://psicode.org>`_.
The package is available as a binary (:ref:`Installing from Binary
<sec:conda>`) for Linux, macOS (not arm64), or Windows (both native and via Windows Subsystem for
<sec:conda>`) for Linux, macOS (both Intel and Apple Silicon), or Windows (both native and via Windows Subsystem for
Linux aka `Bash on Ubuntu on Windows
<https://docs.microsoft.com/en-us/windows/wsl/about>`_)
or as source code (git repository or zipped archive from
https://github.com/psi4/psi4.
At least initially, |PSIfour| 1.7 will not have binary packages for Mac.
Compilers
|PSIfour| has been successfully compiled using Intel, GCC, and Clang
compilers. :ref:`Compiler requirements <faq:approvedcxx>` are primarily
Expand All @@ -620,9 +619,10 @@ Python
|PSIfour| 1.6 supports Python 3.8, 3.9, and 3.10.
|PSIfour| 1.7 supports Python 3.8, 3.9, 3.10, and 3.11 (no binary packages for 3.11).
|PSIfour| 1.8 supports Python 3.8, 3.9, 3.10, and 3.11.
|PSIfour| 1.9 supports Python 3.8, 3.9, 3.10, 3.11, and 3.12.
The future plan is to (1) be compatible with 3.8 and above until there is a good reason to drop
older versions but (2) only build and test for versions conda-forge supports.
The current master supports 3.8, 3.9, 3.10, and 3.11.
The current master supports 3.8, 3.9, 3.10, 3.11, and 3.12.

.. index:: license

Expand Down Expand Up @@ -761,7 +761,8 @@ For more tables with capabilities details:
+-------------------------+-------------------+-------------------+------------+------------+------------+------------+
| ❖ with :ref:`DFTD3, DFTD4<sec:dftd3>`, and :ref:`gCP<sec:gcp>` |
+-------------------------+-------------------+-------------------+------------+------------+------------+------------+
| HF-3c, PBEh-3c | R/U/ROHF, R/UKS | | E/G | | | |
| HF-3c, PBEh-3c, B97-3C, | R/U/ROHF, R/UKS | | E/G | | | |
| r2SCAN-3c, wB97X-3c | | | | | | |
+-------------------------+-------------------+-------------------+------------+------------+------------+------------+
| DFT-D3, DFT-D4 | RKS/UKS | | E/G | | | |
+-------------------------+-------------------+-------------------+------------+------------+------------+------------+
Expand Down
4 changes: 0 additions & 4 deletions external/upstream/libxc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
find_package(Libxc 6.0.0 CONFIG QUIET COMPONENTS C)
if(NOT ${Libxc_FOUND})
# LibxcConfig.cmake encodes searching only within major version, so need two calls to allow v5 or v6
find_package(Libxc 5.1.2 CONFIG QUIET COMPONENTS C)
endif()

if(${Libxc_FOUND})
get_property(_loc TARGET Libxc::xc PROPERTY LOCATION)
Expand Down
3 changes: 3 additions & 0 deletions external/upstream/qcengine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ else()
# Note: Without downgrading setuptools or `sed`ing "git_refnames" (_version.py for versioneer-generated),
# pip will strenuously resist ("Invalid version: <branch or commit>") arbitrary branch or commit refs from GH.
# Make a proper PEP440 tag (e.g., `git tag -a v0.26.0.dev1 -m "v0.26.0.dev1"`), push it, and use in URL below.
#
# With downgrading to (setuptools"<66.0.0" packaging"<23.0" ; former vendors latter), one can use arbitrary
# branch or commit tarballs without the tagging procedure described above.

ExternalProject_Add(qcengine_external
DEPENDS qcelemental_external
Expand Down
5 changes: 1 addition & 4 deletions psi4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@ else()
message(STATUS "Disabled BrianQC ${BrianQC_DIR}")
endif()

find_package(Libxc 6.0.0 CONFIG QUIET COMPONENTS C)
if(NOT ${Libxc_FOUND})
find_package(Libxc 5.1.2 CONFIG REQUIRED COMPONENTS C)
endif()
find_package(Libxc 6.0.0 CONFIG REQUIRED COMPONENTS C)
get_property(_loc TARGET Libxc::xc PROPERTY LOCATION)
list(APPEND _addons ${_loc})
message(STATUS "${Cyan}Using Libxc${ColourReset}: ${_loc} (version ${Libxc_VERSION})")
Expand Down
8 changes: 7 additions & 1 deletion psi4/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,16 @@ def energy(name, **kwargs):
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| qchf | quadratically-convergent HF |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| hf3c | HF with dispersion, BSSE, and basis set corrections :ref:`[manual] <sec:gcp>` |
| hf3c | HF with dispersion, BSSE, SRB, and basis set corrections :ref:`[manual] <sec:gcp>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| pbeh3c | PBEh with dispersion, BSSE, and basis set corrections :ref:`[manual] <sec:gcp>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| b973c | B97(GGA) with dispersion, SRB, and basis set corrections :ref:`[manual] <sec:gcp>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| r2scan3c | r2SCAN with dispersion, BSSE, and basis set corrections :ref:`[manual] <sec:gcp>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| wb97x3c | wB97X with dispersion and basis set corrections :ref:`[manual] <sec:gcp>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| dct | density cumulant (functional) theory :ref:`[manual] <sec:dct>` |
+-------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| mp2 | 2nd-order |MollerPlesset| perturbation theory (MP2) :ref:`[manual] <sec:dfmp2>` :ref:`[details] <dd_mp2>` |
Expand Down
2 changes: 2 additions & 0 deletions psi4/driver/driver_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def _alternative_methods_message(method_name: str, dertype: str, *, messages: Di
stats = messages[0]
conditions2 = [stats[k][1] for k in ["method_type", "reference", "fcae", "qc_module"]]
return f"Method={stats['method']} is not available for {dertype} derivative level under conditions {', '.join(conditions2)}. See {stats['link']}.{alternatives}"
elif "-d" in method_name or "3c" in method_name:
return f"""Method={method_name} is not available for {dertype} derivative level. Some methods need dftd4-python>=3.5.0 and gcp-correction installed. Please `conda install "dftd4-python>=3.5" gcp-correction -c conda-forge` .{alternatives}"""
else:
return f"Method={method_name} is not available for {dertype} derivative level.{alternatives}"

Expand Down
19 changes: 15 additions & 4 deletions psi4/driver/procrouting/dft/dft_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import collections
import copy

from qcengine.programs.empirical_dispersion_resources import dashcoeff, get_dispersion_aliases
from qcengine.programs.empirical_dispersion_resources import dashcoeff, get_dispersion_aliases, new_d4_api

from psi4 import core

Expand All @@ -97,6 +97,9 @@
dict_functionals.update(hyb_functionals.functional_list)
dict_functionals.update(dh_functionals.functional_list)

# remove r2scan-3c from dictionary if dftd4 <= v3.5.0
if new_d4_api is False:
dict_functionals.pop("r2scan3c")

def get_functional_aliases(functional_dict):
if "alias" in functional_dict:
Expand Down Expand Up @@ -125,6 +128,10 @@ def get_functional_aliases(functional_dict):
for formal in functional_aliases:
# "bless" the original functional dft/*_functionals dispersion definition including aliases
dashcoeff_supplement[disp['type']]['definitions'][formal] = disp
# add omitted default parameters of the dispersion correction
for p,val in dashcoeff[disp['type']]['default'].items():
if p not in dashcoeff_supplement[disp['type']]['definitions'][formal]['params'].keys():
dashcoeff_supplement[disp['type']]['definitions'][formal]['params'][p]=val
# generate dispersion aliases for every functional alias
for nominal_dispersion_level, resolved_dispersion_level in _dispersion_aliases.items():
if resolved_dispersion_level == disp["type"]:
Expand Down Expand Up @@ -235,7 +242,7 @@ def check_consistency(func_dictionary):
allowed_params = sorted(dashcoeff[_dispersion_aliases[disp["type"]]]["default"].keys())
if "params" not in disp or sorted(disp["params"].keys()) != allowed_params:
raise ValidationError(
f"SCF: Dispersion params ({list(disp['params'].keys())}) must include all ({allowed_params})")
f"SCF: Dispersion params for {name} ({list(disp['params'].keys())}) must include all ({allowed_params})")
# 3d) check formatting for dispersion citation
if "citation" in disp:
cit = disp["citation"]
Expand All @@ -258,7 +265,11 @@ def build_superfunctional_from_dictionary(func_dictionary, npoints, deriv, restr
if "xc_functionals" in func_dictionary:
for xc_key in func_dictionary["xc_functionals"]:
xc_name = ("XC_" + xc_key).upper()
sup = core.SuperFunctional.XC_build(xc_name, restricted)
xc_params = func_dictionary["xc_functionals"][xc_key]
if "tweak" in xc_params:
sup = core.SuperFunctional.XC_build(xc_name, restricted, xc_params["tweak"])
else:
sup = core.SuperFunctional.XC_build(xc_name, restricted)
descr = " " + func_dictionary["name"] + " "
if sup.is_gga():
if sup.x_alpha() > 0:
Expand Down Expand Up @@ -382,7 +393,7 @@ def build_superfunctional_from_dictionary(func_dictionary, npoints, deriv, restr
sup.set_citation(func_dictionary["citation"])
if "description" in func_dictionary:
if "doi" in func_dictionary:
sup.set_description(func_dictionary["description"] + "(" + func_dictionary["doi"] + ")")
sup.set_description(func_dictionary["description"].replace("\n", "") + " (" + func_dictionary["doi"].lstrip() + ")")
else:
sup.set_description(func_dictionary["description"])

Expand Down
22 changes: 22 additions & 0 deletions psi4/driver/procrouting/dft/gga_functionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,28 @@
' BP86 GGA XC Functional based on VWN5 corr. & more accurate ftilde value\n',
})

# B97-3c = modified B97(GGA) + D3BJ + SRB(through mctc-gcp)
funcs.append({
"name": "B973c",
"alias": ["B97-3c"],
"xc_functionals": {
"GGA_XC_B97_3C": {}
},
"description": ' B97-3c GGA-based 3C composite method with a TZ basis set, D3 and short-range basis set correction.\n',
"citation": ' J. G. Brandenburg, C.Bannwarth, A. Hansen, S. Grimme J. Chem. Phys. 148, 064104, 2018\n',
"doi": "10.1063/1.5012601",
"dispersion": {
"type": "d3bjatm",
"params": {
's6': 1.000,
's8': 1.500,
'a1': 0.370,
'a2': 4.100,
},
},
})


functional_list = {}
for functional in funcs:
functional_list[functional["name"].lower()] = functional
Loading

0 comments on commit 6c81789

Please sign in to comment.