General layout of the core: where new C++ code should live

New integral operators

Most of the heavy lifting in PSI4 is handled by libmints, which can be found in the psi4/psi4/src/psi4/libmints directory. New types of one- and two-electron integral operators should be added here. The Wavefunction class psi4/psi4/src/psi4/libmints/wavefunction.h is also found here and is a key part of the infrastructure. Every energy calculation is performed by a class that derives from Wavefunction and is accessible as a return value in the Python layer. The Wavefunction class contains all pertinent calculation results, such as one-particle densities, molecular orbitals and gradients.

Completely new methods

A new method that is not a modification of existing code belongs in its own folder in psi4/psi4/src/psi4; see other folders in that exist in that location for examples of setting up CMake, and make sure that the new folder is added to psi4/psi4/src/psi4/CMakeLists.txt. There are also a number of variables that can be exported to be available to the user, as detailed in PSI Variables. To set these variables, the following member of Wavefunction should be called:

set_variable("Variable Name", variable_value);

The new variable should also be documented in psi4/doc/sphinxman/source/glossary_psivariables.rst. There are a number of different helpers to export various quantities from the wavefunction to external formats such as FCHK and MOLDEN. Because the Wavefunction makes its members available to the Python layer, any other similar export functions should be written in python.

Integral consuming technologies

The general philosophy in PSI4 is to try write two-electron integral driven tasks in methods like Hartree-Fock, CIS and CPHF in terms of generalized Fock-like matrices. From here, a single class can be used to construct these generalized Fock matrices, which is what libFock (psi4/psi4/src/psi4/libfock) accomplishes. A number of integral technologies – such as integral-direct, disk-based and density fitting – are supported in libFock, making them generally available to all elements of the code that use the generalized Fock matrix strategy.

Exposing C++ code to Python

The recent push to move sections of the code that are not a bottleneck into the Python layer requires that the C++ code is callable from Python and that its results are accessible. The result accessibility is addressed by populating the appropriate variables in the Wavefunction object. To make the code callable from Python, we rely on the excellent PyBind11 library to create the bindings. Existing code to export various PSI4 classes can be found in psi4/psi4/src in the files whose name begins with export_. The code to export functions that run entire calculations is usually found in psi4/psi4/src/core.cc.