CCpy is a research-level Python package for performing non-relativistic electronic structure calculations for molecular systems using methods based on the ground-state coupled-cluster (CC) theory and its equation-of-motion (EOM) extension to electronic excited, attached, and ionized states. As a design philosophy, CCpy favors simplicity over efficiency, and this is reflected in the usage of computational routines that are transparent enough so that they can be easily used, modified, and extended, while still maintaining reasonable efficiency. To this end, CCpy employs a hybrid Python-Fortran programming approach made possible with the f2py package, which allows one to compile Fortran code into shared object libraries containing subroutines that are callable from Python and interoperable with Numpy arrays.
CCpy specializes in applying the CC(P;Q) and externally corrected (ec) CC methodologies developed in the Piecuch group at Michigan State University. In CC(P;Q), the energetics obtained by solving the ground- or excited-state CC/EOMCC equations in one subspace of the many-electron Hilbert space, called the P space, are corrected for the missing many-electron correlation effects captured with the help of a complementary subspace called the Q space using the state-selective, non-iterative, and non-perturbative energy corrections based on the CC moment expansion formalism. Currently, CCpy offers implementations of several CC(P;Q) methods, the majority of which are aimed at converging the high-level CCSDT and EOMCCSDT energetics. These include the completely-renormalized (CR) methods such as the CR-CC(2,3) and CR-CC(2,4) triples and quadruples corrections to CCSD, the active-space CCSDt and CC(t;3) approaches, which are based on a user-defined selection of active orbitals, and the black-box selected configuration interaction (CI) driven and adaptive CC(P;Q) methodologies, which construct the P and Q spaces entering the CC(P;Q) computations using information extracted from selected CI wave functions or the adaptive CC(P;Q) moment expansions themselves, respectively. The ec-CC approaches on the other hand seek to converge the exact, full CI energetics directly by solving for the T1 and T2 clusters in the presence of the leading T3 and T4 clusters extracted from an external non-CC wave function. Current implementations of the ec-CC approaches in CCpy are designed to iterate T1 and T2 clusters in the presence of T3 and T4 obtained from CI wave functions of the selected CI or multireference CI types, and correct the resulting energetics for the missing many-electron correlations using the generalized moment expansions of the ec-CC equations.
The CC with doubles (CCD) method truncates the cluster operator as T = T2. It has iterative computational costs that scale as no2nu4, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals. Due to the importance of pair correlations in the many-electron problem, the CCD approximation was first introduced in Prof. Čížek's landmark 1966 paper under the name coupled-pair many-electron theory, or CPMET. Although CCD is often superceeded by the more accurate CC with singles and doubles (CCSD) method, which has the same computational scaling, CCD is still relevant to modern CC calculations within the context of correlating orbital-optimized reference functions, as in Brückner CCD.
### Example Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCD calculation driver.run_cc(method="ccd") ``` ### Reference 1. J. Čížek, *J. Chem. Phys.* **45**, 4256 (1966).The CC with singles and doubles (CCSD) method approximates the cluster operator as T = T1 + T2. It is the most commonly used truncation level in the CC hierarchy and often forms the starting point for more sophisticated treatments of many-electron correlation effects. CCSD has iterative computational costs that scale as no2nu4, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals.
### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCSD calculation driver.run_cc(method="ccsd") ``` ### References 1. G. D. Purvis and R. J. Bartlett, *J. Chem. Phys.* **76**, 1910 (1982). 2. J. M. Cullen and M. C. Zerner, *J. Chem. Phys.* **77**, 4088 (1982). 3. G. E. Scuseria, A. C. Scheiner, T. J. Lee, J. E. Rice, and H. F. Schaefer, *J. Chem. Phys.* **86**, 2881 (1987). 4. P. Piecuch and J. Paldus, *Int. J. Quantum Chem.* **36**, 429 (1989).The CC with singles, doubles, and triples (CCSDT) method approximates the cluster operator as T = T1 + T2 + T3. CCSDT is a high-level method capable of providing nearly exact results for closed-shell molecules as well as chemically accurate energetics for single bond breaking and a variety of open-shell systems. CCSDT has iterative computational costs that scale as no3nu5, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals.
### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCSDT calculation driver.run_cc(method="ccsdt") ``` ### References 1. M. R. Hoffmann and H. F. Schaefer, *Adv. Quantum Chem.* **18**, 207 (1986). 2. J. Noga and R. J. Bartlett, *J. Chem. Phys.* **86**, 7041 (1987). 3. G. E. Scuseria and H. F. Schaefer, *Chem. Phys. Lett.* **152**, 382 (1988). 4. J. D. Watts and R. J. Bartlett, *J. Chem. Phys.* **93**, 6104 (1990).The CC with singles, doubles, triples, and quadruples (CCSDTQ) method approximates the cluster operator as T = T1 + T2 + T3 + T4. CCSDTQ is a very high-level method and is often capable of providing near-exact energetics for most problems of chemical interest, as long as the number of strongly correlated electrons is not too large (for methods designed to treat genuine strong correlations, see the approximate coupled-pair, or ACP approaches). CCSDTQ has iterative computational costs that scale as no4nu6, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals.
### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCSDTQ calculation driver.run_cc(method="ccsdtq") ``` ### References 1. N. Oliphant and L. Adamowicz, *J. Chem. Phys.* **95**, 6645 (1991). 2. S. A. Kucharski and R. J. Bartlett, *Theor. Chem. Acc.* **80**, 387 (1991). 3. S. A. Kucharski and R. J. Bartlett, *J. Chem. Phys.* **97**, 4282 (1992). 4. P. Piecuch and L. Adamowicz, *J. Chem. Phys.* **100**, 5792 (1994).The CCSD(T) method corrects the CCSD energy for the correlation effects due to T3 clusters using formulas derived using many-body perturbation theory (MBPT). In particular, the CCSD(T) correction includes the leading 4th-order energy correction for T3 along with 5th-order contribution due to disconnected triples. The inclusion of the latter term distinguishes CCSD(T) from its CCSD[T] precedessor. CCSD(T) has noniterative computational costs that scale as no3n44, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals.
### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCSD calculation driver.run_cc(method="ccsd") # perform CCSD(T) correction driver.run_ccp3(method="ccsd(t)") ``` ### References 1. K. Raghavachari, G. W. Trucks, J. A. Pople, and M. Head-Gordon, *Chem. Phys. Lett.* **157**, 479 (1989). 2. J. F. Stanton, *Chem. Phys. Lett.* **281**, 130 (1997). 3. S. A. Kucharski and R. J. Bartlett, *J. Chem. Phys.* **108**, 5243 (1998). 4. T. D. Crawford and J. F. Stanton, *Int. J. Quantum Chem.* **70**, 601 (1998).The CR-CC(2,3) approach is a nonperturbative and noniterative correction to the CCSD energetics that accounts for the correlation effects due to T3 clusters using formulas derived from the biorthogonal moment energy expansions of CC theory. In particular, CR-CC(2,3) represents the most robust scheme to noniteratively include the effects of connected triples on top of CCSD, and it is capable of providing an accurate description of closed-shell molecules in addition to commonly encountered multireference problems, such as single bond breaking and open-shell radical and diradical species, which are generally beyond the scope of perturbative methods like CCSD(T). The CR-CC(2,3) triples correction uses noniterative steps that scale as no3n44, where no is the number of correlated occupied orbitals and nu is the number of correlated unoccupied orbitals, however, due to the precise form of the expressions defining the CR-CC(2,3) triples correction, it is approximately twice as expensive as its CCSD(T) counterpart. One must also solve the companion left-CCSD system of linear equations (roughly as expensive as CCSD) prior to computing the CR-CC(2,3) correction. The CR-CC(2,3) calculation returns four distinct energetics, labelled as CR-CC(2,3)X, for X = A, B, C, and D, where each variant A-D corresponds to a different treatment of the energy denominators entering the formula for the CR-CC(2,3) triples correction. The variant CR-CC(2,3)A uses the simplest Møller-Plesset form of the energy denominator and is equivalent to the method called CCSD(2)T. Meanwhile, the CR-CC(2,3)D result, which employs the full Epstein-Nesbet energy denominator, is generally most accurate and often reported as the CR-CC(2,3) energy (or by its former name, CR-CCSD(T)L).
### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CCSD calculation driver.run_cc(method="ccsd") # build CCSD similarity-transformed Hamiltonian (this overwrites original MO integrals) driver.run_hbar(method="ccsd") # run companion left-CCSD calculation driver.run_leftcc(method="left_ccsd") # run CR-CC(2,3) triples correction driver.run_ccp3(method="crcc23") ``` ### References 1. P. Piecuch and M. Włoch, *J. Chem. Phys.* **123**, 224105 (2005). 2. P. Piecuch, M. Włoch, J. R. Gour, and A. Kinal, *Chem. Phys. Lett* **418**, 467 (2006). 3. M. Włoch, M. D. Lodriguito, P. Piecuch, and J. R. Gour, *Mol. Phys.* **104**, 2149 (2006), **104**, 2991 (2006) [Erratum]. 4. M. Włoch, J. R. Gour, and P. Piecuch, *J. Phys. Chem. A.* **111**, 11359 (2007). 5. P. Piecuch, J. R. Gour, and M. Włoch, *Int. J. Quantum Chem.* **108**, 2128 (2008).### Sample Code ```python3 from pyscf import gto, scf from ccpy.drivers.driver import Driver # build molecule using PySCF and run SCF calculation mol = gto.M( atom=[["O", (0.0, 0.0, -0.0180)], ["H", (0.0, 3.030526, -2.117796)], ["H", (0.0, -3.030526, -2.117796)]], basis="cc-pvdz", charge=0, spin=0, symmetry="C2V", cart=False, unit="Bohr", ) mf = scf.RHF(mol) mf.kernel() # get the CCpy driver object using PySCF meanfield driver = Driver.from_pyscf(mf, nfrozen=1) # set calculation parameters driver.options["energy_convergence"] = 1.0e-07 # (in hartree) driver.options["amp_convergence"] = 1.0e-07 driver.options["maximum_iterations"] = 80 # run CC4 calculation driver.run_cc(method="cc4") ``` ### References
Because CCpy is primarily used for CC method development work, we use interfaces to GAMESS and PySCF to obtain the mean-field (typically Hartree-Fock) reference state and associated one- and two-electron integrals in the molecular orbital basis prior to performing the correlated CC calculations. All implementations in CCpy are based on the spin-integrated spinorbital formulation and are compatible with RHF and ROHF references.
CCpy is currently run and tested on Linux and Mac OS devices. Linux users (including WSL users) can choose to install a pre-compiled version of CCpy from the PyPI server (simplest option) or download the source code and install it manually. For now, Mac OS users must download and install the source code (wheels for Mac OS will be uploaded to PyPI in the near future). ### Installing from PyPI For Linux machines, the latest version of CCpy available on PyPI is obtained by running ```commandline pip install coupled-cluster-py ``` ### Installing via Source Code Clone the CCpy repository and enter the `ccpy` directory: ```commandline git clone https://piecuch-group/ccpy.git cd ccpy ``` We recommend creating a new environment for CCpy by running the following command ```commandline conda create --name=ccpy_env python=3.12 ``` and installing all of the dependencies listed in `requirements-dev.txt` via ```commandline pip install -r requirements-dev.txt ``` Additionally, it is useful to install `cmake` and `pkgconfig` specific to your Conda environment by running ```commandline conda install pkgconfig cmake ``` Then, you can install CCpy using ```commandline pip install --no-build-isolation --verbose --editable . ``` The Meson backend will automatically locate the needed libraries. If you are having issues finding `openblas`, make sure that the environment variable `PKG_CONFIG_PATH` points to the directory that includes the `openblas.pc` file. This should be located within `openblas/lib`, or something similar. After installing in editable mode (via `--editable`), the package will automatically update with any changes you make without additional installation steps.
Karthik Gururangan\ Doctoral student, Department of Chemistry, Michigan State University e-mail: gururang@msu.edu\ (lead developer)
Dr. J. Emiliano Deustua\ COO and Co-founder, Examol\ (co-developer)
Professor Piotr Piecuch\ University Distinguished Professor and MSU Research Foundation Professor, Department of Chemistry, Michigan State University\ Adjunct Professor, Department of Physics and Astronomy, Michigan State University\ e-mail: piecuch@chemistry.msu.edu\ (co-developer and principal investigator)
Additional contributors: Tiange Deng (doctoral student, Department of Chemistry, Michigan State University; ACCD and ACCSD options).
We acknowledge support from the Chemical Sciences, Geosciences and Biosciences Division, Office of Basic Energy Sciences, Office of Science, U.S. Department of Energy (Grant No. DE-FG02-01ER15228 to Piotr Piecuch).
CCpy is an open-source code under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) license developed and maintained by the [Piecuch Group](https://www2.chemistry.msu.edu/faculty/piecuch/) at Michigan State University.