Fanpy: A Python Library for Prototyping Multideterminant Methods in Ab Initio Quantum Chemistry
Taewon David Kim, Michael Richer, Gabriela Sánchez-Díaz, Farnaz Heidar-Zadeh, Toon Verstraelen, Ramón Alain Miranda-Quintana, Paul W. Ayers
aa r X i v : . [ phy s i c s . c h e m - ph ] F e b Fanpy : A Python Library for Prototyping MultideterminantMethods in
Ab Initio
Quantum Chemistry
Taewon D. Kim Michael Richer Gabriela S´anchez-D´ıaz Farnaz Heidar-Zadeh Toon Verstraelen Ram´on Alain Miranda-Quintana Paul W. Ayers February 3, 2021 Department of Chemistry and Chemical Biology, McMaster University, Hamilton, Ontario, L8S-4L8, Canada Department of Chemistry, Queen’s University, Kingston, Ontario, K7L-3N6, Canada Center for Molecular Modeling (CMM), Ghent University, Technologiepark-Zwijnaarde 46, B-9052,Zwijnaarde, Belgium Department of Chemistry, University of Florida, Gainesville, FL 32603, USA
Abstract
Fanpy is a free and open-source Python library for developing and testing multideterminantwavefunctions and related ab initio methods in electronic structure theory. The main use of
Fanpy is to quickly prototype new methods by making it easier to transfer the mathemati-cal conception of a new wavefunction ans¨atze to a working implementation.
Fanpy uses theframework of our recently introduced Flexible Ansatz for N-electron Configuration Interaction(FANCI), where multideterminant wavefunctions are represented by their overlaps with Slaterdeterminants of orthonormal spin-orbitals. In the simplest case, a new wavefunction ansatz canbe implemented by simply writing a function for evaluating its overlap with an arbitrary Slaterdeterminant.
Fanpy is modular in both implementation and theory: the wavefunction model,the system’s Hamiltonian, and the choice of objective function are all independent modules.This modular structure makes it easy for users to mix and match different methods and fordevelopers to quickly try new ideas.
Fanpy is written purely in Python with standard depen-dencies, making it accessible for most operating systems; it adheres to principles of modernsoftware development, including comprehensive documentation, extensive testing, and continu-ous integration and delivery protocols. This article is considered to be the official release notesfor the
Fanpy library.
Fanpy ? Fanpy is a free and open-source Python 3 library for ab initio electronic structure calculations.The key innovation is the adoption of the Flexible Ansatz for N-electron Configuration Interaction(FANCI) mathematical framework[1]. By adopting this framework, ab initio electronic structuremethods are represented as a collection of four parts, each of which is represented by an independentmodule of
Fanpy : (a) the (multideterminant) wavefunction model (b) the system Hamiltonian, as1epresented by its one- and two-electron integrals (c) an equation (or system of equations) tosolve that is equivalent to the Schr¨odinger equation, (d) an algorithm for optimizing the objectivefunction(s). Section 4 details the features of each module, though the main advantage of
Fanpy isthat new methods can be implemented easily.Although the FANCI framework allows overlaps with any convenient set of reference states (e.g.,Richardson eigenfunctions[2]) to be used, in
Fanpy the aforementioned components are expressedexplicitly in terms of Slater determinants and the wavefunction ans¨atze of interest are multideter-minant wavefunctions with parameterized coefficients, | Ψ FANCI i = X m ∈ S m f ( m , ~P ) | m i (1)where | m i = | m m . . . m N − m N i = a † m a † m . . . a † m N − a † m N |i (2)denotes a Slater determinant, S m is the set of Slater determinants included in the wavefunction, and f is a function that determines the coefficient of each Slater determinant, m , using the parameters, ~P . Note that f is simply the overlap of the parameterized wavefunction with the Slater determinant, f ( m , ~P ) = h m | Ψ FANCI i (3)Similarly, the Hamiltonian is expressed in terms of its CI matrix elements, h m | ˆ H | n i = h m | X ij h ij a † i a j + 12 X ijkl g ijkl a † i a † j a l a k | n i (4)The objective functions supported by Fanpy combine the overlaps and the CI matrix elements toapproximate the Schr¨odinger equation.
Fanpy
The source code of
Fanpy is maintained on GitHub; see https://github.com/quantumelephant/fanpy ,and its documentation is hosted on Read the Docs; see https://fanpy.readthedocs.io/en/latest/index.html .We strive to ensure that the
Fanpy source code and its associated website are comprehensively doc-umented, including useful tests, scripts, and examples. As that documentation is maintained withthe software, providing detailed (and eventually outdated) release notes here seems unwise. Instead,we will briefly list the distinguishing features and key capabilities of
Fanpy in section 4 to establishits philosophy and framework, and exemplify them in section 5.
Fanpy ? Many quantum chemistry packages enable computations using multideterminant methods. Most ofthese packages (e.g. Gaussian[3] and MolPro[4]) are closed-source, making it nearly impossible todevelop new methods without special permission. Even for packages whose source code is available,the code is often monolithic, making it difficult to implement new fundamental methods without2horoughly understanding nearly the entire code base. Moreover, the low-level code is often highlyoptimized, abstracts away critical components of ab initio methods, and not intended to be sub-sequently read or modified. Such code can, and does, remain unchanged for decades, has littledocumentation, and rarely follows modern software development principles. Though some packagestry to address this issue, the development of post-HF methods remains difficult. For example,Psi4Numpy[5] is a collection of Python scripts and Jupyter notebooks that implement several post-HF methods using Psi4 to generate necessary inputs, such as CI matrices and one- and two-electronintegrals. Though these scripts are excellent tools for learning about standard quantum chemistrymethods or implementing minor embellishments of standard methods, developing a novel method(e.g. a new wavefunction ansatz) requires all related processes to be implemented in Psi4, whichrequires a thorough understanding of the Psi4 package as a whole[6]. In particular, implementinga new objective function and its associated optimization algorithm, or implementing the action ofthe Hamiltonian on a new wavefunction ansatz, is difficult and time-consuming.Due to the difficulty of developing new methods in these legacy codes, we developed our ownHelpful Open-Source Research TOol for N-electron systems (HORTON)[7]. The first two versionsof HORTON were monolithic, and wavefunction models that were simple on paper were difficultto implement. HORTON 3 is strictly modular, with separate modules for input/output, numericalintegration, Gaussian-basis-set evaluation and integrals, geometry optimization, and self-consistentfield calculations.
Fanpy is the correlated wavefunction module of HORTON 3.
Fanpy was envisioned as a development tool for new correlated-wavefunction methods; the goalis to help researchers quickly implement and test their ideas. Towards this goal,
Fanpy is designedto be modular and general. Its modularity helps to isolate and minimize the amount of codethat needs to be understood, and perhaps modified, to implement a new method. For example,implementing a new wavefunction ansatz requires modifying only the wavefunction module, anddoes not require explicit consideration of how the Hamiltonian will act upon that wavefunction norof how the orbitals and parameters within the wavefunction will be optimized. The modules of
Fanpy are designed to be as general as possible, so that features from one module are compatiblewith features from the other modules. The compatibility between the modules ensures that anydeveloped method (e.g. a wavefunction ansatz) can be used in conjunction with the other methods(e.g. orbital optimization, model Hamiltonians, the projected Schr¨odinger equation, etc). Weprovide comprehensive documentation and examples to further aid the development of new methodsin
Fanpy . Fanpy
We display various features of
Fanpy by discussing each module and their intended purposes: • The wavefunction module is developed in accordance with the FANCI framework[1]. In theFANCI framework, the wavefunction is entirely represented by its overlaps with Slater deter-minants built from orthonormal orbitals. Similarly, each wavefunction in
Fanpy is defined byits parameters and a function that returns an overlap for the given Slater determinant. Theoverlap can be provided as a standalone function or defined within a class structure, templatedfrom an abstract base class. The following wavefunctions have already been implemented:configuration interaction (CI) with single and double excitations (CISD)[8]; doubly-occupiedconfiguration interaction (DOCI)[9–12]; full CI[13]; selected CI wavefunctions with a user-specified set of Slater determinants; antisymmetrized products of geminals (APG)[14–24]; an-3isymmetrized products of geminals with disjoint orbital sets (APsetG)[25]; antisymmetrizedproduct of interacting geminals (APIG)[25–53]; antisymmetric product of 1-reference-orbitalinteracting geminals (AP1roG; equivalent to pair-coupled-cluster doubles)[54]; antisymmetricproduct of rank-two interacting geminals (APr2G)[2]; determinant ratio wavefunctions[1]; an-tisymmetrized products of tetrets (4-electron wavefunctions)[1]; matrix product states (MPS)[55];neural network wavefunctions; coupled-cluster (CC) with arbitrary excitations (including, butnot limited to, CCSD, CCSDT, and CC with seniority-specific excitations)[1, 56–61], geminalcoupled-cluster wavefunctions[33–35, 37, 54], generalized CC, and seniority-increasing CC.We also support these wavefunctions with nonorthogonal orbitals, and linear combinations ofany of the aforementioned wavefunctions. • The Hamiltonian module contains Hamiltonians commonly used in electronic structure theory.Similar to the wavefunctions, each Hamiltonian in
Fanpy is defined by its representation inorbital basis set (i.e. one- and two-electron integrals) and a function that returns the integralof the Hamiltonian with respect to the given Slater determinants. The following Hamiltonianshave already been implemented: the electronic Hamiltonian in the restricted, unrestricted,and generalized basis; the seniority-zero electronic Hamiltonian[62]; and the Fock operator inthe restricted basis. In addition, the Pariser-Parr-Pople[63–66], Hubbard[66, 67], H¨uckel[66,68], Ising[66, 69, 70], Heisenberg[66, 70, 71], and Richardson[72, 73] model Hamiltoniansare available as restricted electronic Hamiltonians through the ModelHamiltonian GitHubrepository[74]. Orbital optimization is available if a function returning the derivative withrespect to orbital rotation parameters is provided. At the moment, only restricted electronicHamiltonians support orbital optimization. • The objective module is responsible for combining the wavefunction and the Hamiltonianto form an equation or a system of equations that represents the Schr¨odinger equation. In
Fanpy , the objective function can be the variational optimization of the expectation value ofthe energy[75–79], the projected Schr¨odinger equation[25, 37, 50], or a local energy expressionto be sampled (as in variational quantum Monte Carlo)[80–85]. • The solver module contains algorithms that optimize/solve the equations from the objectivemodule. It supports optimizers from
SciPy [86], which includes constrained/unconstrained lo-cal/global optimizers for multivariate scalar functions (i.e. energy) and algorithms for solvingnonlinear least-squares problems and for finding roots of a system of nonlinear equations (i.e.,projected Schr¨odinger equation). For CI wavefunctions, we also support brute-force eigen-value decomposition. In addition,
Fanpy interfaces to several algorithms for derivative-freeglobal optimization problems including the Covariance Matrix Adaptation Evolution Strategy(CMA-ES) algorithm[87] from pycma [88] and algorithms using decision trees and Bayesian op-timization from scikit-optimize [89]. At the moment, no in-house optimization algorithmsspecialized for electronic structure theory problems are included. However,
Fanpy ’s modulardesign makes it easier to develop sophisticated domain-specific optimization algorithms. Theobjective module provides high-level control over the parameters involved in the optimization(e.g., active and frozen parameters) and can be changed dynamically throughout the optimiza-tion process. These parameters can be saved as a checkpoint throughout the optimization.(The default is to checkpoint at each function evaluation.) Furthermore, the objective moduleprovides flexibility to add additional parameters (e.g., model hyperparameters) and to addnonlinear constraints to the Projected Schr¨odinger equation.4
The tool module provides various utility functions used throughout the
Fanpy package.Though some tools have specialized uses, the tools for manipulating and generating Slater de-terminants are used frequently throughout
Fanpy . These tools are essential when developingmethods in
Fanpy because Slater determinants are the common language of the independentmodules. The slater module provides functions for manipulating Slater determinants andconverting them from one form to another. Within
Fanpy , Slater determinants are representedas a binary number, where the positions of 1’s are the indices of the occupied spin-orbitals.The slater module can, for example, provide the occupied spin orbital indices from the givenSlater determinant. The sdlist module provides easy ways to generate Slater determinantsof the desired characteristics (e.g. order of excitation from ground state, spin, seniority). Thismodule is frequently used to construct the projection space by which the objective functionis evaluated. In addition, the tool module provides wrappers to other modules of
HORTON and other quantum chemistry software, including
Gaussian [3],
PySCF [90], and
Psi4 [6]. Theseprograms can then be used to generate one- and two-electron integrals for
Fanpy . For the most updated documentation and examples on how to use
Fanpy , please refer to the
Fanpy website. Here, we showcase several ways
Fanpy can be used and incorporated into variousworkflows. Please note that these examples are based on version 1.0 of
Fanpy , and the user mightneed to modify them if using a future major release of the
Fanpy library. Within minor and bug-fixreleases, backward compatibility is guaranteed.
Running a calculation:
A calculation in
Fanpy can be run by creating and executing aPython script and by running its command-line tool, fanpy_run_calc . For ease of use, fanpy_run_calc provides limited access to
Fanpy ’s features using sensible default settings. However, it is recom-mended to create and execute a Python script because it provides a transparent record of thecalculation (and its settings) and the full range of
Fanpy ’s features. For assistance in creating aPython script,
Fanpy provides a command-line tool, fanpy_make_script . This tool creates a scriptfrom the given specifications, which can then be modified if a desired feature is not available in thetool.The following example of a Python script runs an AP1roG calculation for oxygen molecule in adouble zeta basis set: import numpy as np from fanpy.wfn.geminal.ap1rog import AP1roG from fanpy.ham.restricted_chemical import RestrictedMolecularHamiltonian from fanpy.eqn.projected import ProjectedSchrodinger from fanpy.solver.system import least_squares from fanpy.tools.sd_list import sd_list nelec = 16 oneint = np.load('one_oxygen.npy') twoint = np.load('two_oxygen.npy') ham = RestrictedMolecularHamiltonian(oneint, twoint) wfn = AP1roG(nelec, ham.nspin) pspace = sd_list(nelec, ham.nspin, exc_orders=[2], seniority=0) eqns = ProjectedSchrodinger(wfn, ham, pspace=pspace) results = least_squares(eqns) print('AP1roG electronic energy (Hartree):', results['energy']) Since
Fanpy targets post-HF methods, the orbitals (and the corresponding system specific infor-mation) must be provided in the form of one- and two-electron integrals. The one- and two-electronintegrals must be provided as two- and four-dimensional numpy arrays, respectively, whose indicesare in the same order as the integrals in the physicists’ notation. To generate the integrals froma single-determinant calculation,
Fanpy provides wrappers for
HORTON , PySCF , and
Psi4 via the fanpy.tools.wrapper module. The Gaussian .fchk file can be converted into .npy file using theHORTON wrapper, which will also compute the required one- and two-electron integrals.
Implementing a wavefunction:
New wavefunctions can be implemented in
Fanpy by makinga subclass of the wavefunction base class or by providing the overlap function to a utility function.The subclass requires the method get_overlap to be defined.As a simple example, recall that expansion of a Slater determinant of nonorthogonal orbitals inorthogonal Slater determinants is given by: | Ψ i = N Y i =1 2 K X j C ij a † j | θ i = X m | C ( m ) | − | m i (5)In Fanpy , this corresponds to: import numpy as np from fanpy.wfn.base import BaseWavefunction from fanpy.tools.slater import occ_indices class NonorthogonalSlaterDeterminant(BaseWavefunction): def get_overlap(self, sd, deriv=None): occs = occ_indices(sd) params = self.params.reshape(self.nelec, self.nspin) if deriv is None: return np.linalg.det(params[:, occs]) output = np.zeros(params.shape) for deriv_row in range(self.nelec): for j, deriv_col in enumerate(occs): sign = (-1)**(deriv_row + j) row_inds = np.arange(self.nelec) row_inds = row_inds[row_inds != deriv_row] col_inds = occs[occs != deriv_col] minor = np.linalg.det(params[row_inds[:, None], col_inds[None, :]]) output[deriv_row, deriv_col] = sign * minor return output.ravel()[deriv] The method get_overlap returns the overlap of the given Slater determinant when deriv=None and returns its gradient with respect to the parameters specified by deriv otherwise ( deriv is aone-dimensional numpy array of parameter indices). Further details on the API of get_overlap are provided in the online documentation. Unlike the wavefunctions already implemented in
Fanpy ,this wavefunction does not have default initial parameters, which means that they must be suppliedwhen instantiating the wavefunction. For example, the following code block shows how to initializeto the ground-state (orthogonal) Slater determinant. from fanpy.tools.slater import ground, occ_indices ground_indices = occ_indices(ground(16, 36)) hf_params = np.zeros((16, 36)) hf_params[np.arange(16), ground_indices] = 1 wfn = NonorthogonalSlaterDeterminant(16, 36) wfn.assign_params(hf_params) Alternatively, the wavefunction can be constructed using the utility function: wfn_factory . import numpy as np from fanpy.wfn.utils import wfn_factory def olp(sd, params): occs = occ_indices(sd) nelc = 16 nspin = 36 params = params.reshape(nelec, nspin) return np.linalg.det(params[:, occs]) def olp_deriv(sd, params): occs = occ_indices(sd) nelc = 16 nspin = 36 params = params.reshape(nelec, nspin) return output.ravel() wfn = wfn_factory(olp, olp_deriv, 16, 36, hf_params) It is recommended to implement wavefunctions using the class structure because it helps make8he code cleaner by limiting repetitions and makes the code easier to unit test by breaking it intosmaller pieces. For a quick and dirty implementation, however, the utility function may be easier.
Implementing a Hamiltonian:
Similar to the wavefunction, new Hamiltonians can be im-plemented in
Fanpy by making a subclass of the Hamiltonian base class or by passing a functionthat evaluates the integrals to a utility function. In addition to the general Hamiltonian base class,
Fanpy provides base classes according to the type of orbitals used in the Hamiltonian: restricted,unrestricted, and generalized. The subclass to the orbital specific Hamiltonian base class requiresthe method integrate_sd_sd to be defined.For example, to implement the H¨uckel Hamiltonian:[66]ˆ H = X ij X σ h ij a † iσ a jσ h ij = α i if i = jβ ij if spatial orbitals i and j belong to atoms that participate in a bond0 else (6) from fanpy.ham.base import BaseHamiltonian from fanpy.tools import slater class HuckelHamiltonian(BaseHamiltonian): def __init__(self, one_int): self.one_int = one_int @property def nspin(self): return self.one_int.shape[0] * 2 def integrate_sd_wfn(self, wfn, sd, wfn_deriv=None, ham_deriv=None): return super().integrate_sd_wfn( wfn, sd, wfn_deriv=wfn_deriv, ham_deriv=ham_deriv, orders=(1,) ) def integrate_sd_sd(self, sd1, sd2, deriv=None, components=False): diff_sd1, diff_sd2 = slater.diff_orbs(sd1, sd2) if deriv: raise NotImplementedError if len(diff_sd1) >= 2 or len(diff_sd2) >= 2: return 0.0 if len(diff_sd1) != len(diff_sd2): return 0.0 if len(diff_sd1) == 0: shared_alpha_sd, shared_beta_sd = slater.split_spin( slater.shared_sd(sd1, sd2), self.nspatial ) shared_alpha = slater.occ_indices(shared_alpha_sd) shared_beta = slater.occ_indices(shared_beta_sd) output = np.sum(self.one_int[shared_alpha, shared_alpha]) output += np.sum(self.one_int[shared_beta, shared_beta]) return output spatial_ind1 = slater.spatial_index(diff_sd1[0], self.nspatial) spatial_ind2 = slater.spatial_index(diff_sd2[0], self.nspatial) return self.one_int[spatial_ind1, spatial_ind2] Though it is not necessary, the subclass defines integrate_sd_wfn to specify that the Hamiltonianonly contains one-body operators. By default, integrate_sd_wfn assumes that the Hamiltoniancontains one- and two-body operators.Alternatively, the hamiltonian can be constructed using the utility function from fanpy.ham.utils.factory import ham_factory from fanpy.tools import slater def integrate_sd_sd(sd1, sd2, one_int): diff_sd1, diff_sd2 = slater.diff_orbs(sd1, sd2) nspatial = one_int.shape[0] ham = ham_factory(integrate_sd_sd, oneint, 36, orders=(1,)) Again, using the class structure is encouraged because its structure can be cleaner and more trans-parent and because it provides finer control over the Hamiltonian. For example, if integrate_sd_wfn is directly implemented rather than integrate_sd_sd , then integrate_sd_wfn can be vectorizedover the given Slater determinant and its excitations associated with the application of the Hamil-tonian. When the derivative of the integral is not provided, orbital optimization is only availablethrough relatively inefficient gradient-free optimization algorithms, such as CMA-ES.Since the H¨uckel Hamiltonian is defined by its one-electron integrals, this class can be usedto describe any Hamiltonian with only one-body operators. The integrals for the H¨uckel Hamil-tonian (and other model Hamiltonians) can be generated using the ModelHamiltonian GitHubrepository[74].
Implementing an Objective:
New objectives can be implemented in
Fanpy by making asubclass of the objective base class. The subclass requires the method objective to be defined.To use the gradient (or Jacobian) in the optimization algorithm, the subclass must also containthe method gradient (or jacobian ). These objectives can then be solved using the appropriatemethods in the solver module. For example, the energy related objectives can be solved viaminimization and the projected Schr¨odinger equation related objectives can be solved via root-finding and least-squares algorithms.For example, consider the local energy used in the orbital-space variational Quantum MonteCarlo[82], E L = X i h Φ i | ˆ H | Ψ ih Φ i | Ψ i (7)where the Slater determinant, Φ i , is sampled according to the distribution p (Φ i ) = h Ψ | Φ i i P k h Ψ | Φ j i . Thiscorresponds to: from fanpy.eqn.base import BaseSchrodinger class LocalEnergy(BaseSchrodinger): def __init__(self, wfn, ham, pspace, param_selection=None): super().__init__(wfn, ham, param_selection=param_selection) self.pspace = pspace @property def num_eqns(self): return 1 def objective(self, params): self.assign_params(params) output = 0.0 for sd in self.pspace: output += self.ham.integrate_sd_wfn(sd, self.wfn) / self.wfn.get_overlap(sd) return output def gradient(self, params): self.assign_params(params) output = np.zeros(params.size) for sd in self.pspace: wfn_inds_component = self.indices_component_params[self.wfn] if wfn_inds_component.size > 0: wfn_inds_objective = self.indices_objective_params[self.wfn] output[wfn_inds_objective] += ( self.ham.integrate_sd_wfn(sd, self.wfn, wfn_deriv=wfn_inds_component) / self.wfn.get_overlap(sd) ) output[wfn_inds_objective] -= ( self.ham.integrate_sd_wfn(sd, self.wfn) * self.wfn.get_overlap(sd, deriv=wfn_inds_component) / self.wfn.get_overlap(sd) ** 2 ) ham_inds_component = self.indices_component_params[self.ham] if ham_inds_component.size > 0: ham_inds_objective = self.indices_objective_params[self.ham] output[ham_inds_objective] += ( self.ham.integrate_sd_wfn(sd, self.wfn, ham_deriv=ham_inds_component) / self.wfn.get_overlap(sd) ) return output Though it is not required, providing the indices in the gradient ensures that users can specify theparameters that are active during the optimization via the attribute param_selection . Who is
Fanpy for?
Fanpy was designed to be used by developers of post-HF methods, es-pecially those interested in new multireference wavefunction ans¨atze. Extensive programming ex-perience is not necessary:
Fanpy ’s modular design and extensive documentation make it easy tounderstand and extend the existing methods and base classes. The base classes serve as templatesto help ensure that the developed method fits together with the rest of
Fanpy seamlessly. Devel-opers with programming experience but a limited background in post-HF methods should have aneasier time understanding the code because the methods are documented with the correspondingequations (and their derivations) and are implemented in a simple and straight-forward fashion.
What is the mission of
Fanpy ? Our goal is to develop a platform where developers ofnew ab initio methods can quickly implement and test their ideas. We hope to make it easier forresearchers—whether they are seasoned professors or new graduate students—to test their ideaswithout being burdened by undocumented code conventions, mysterious equations, or cumbersomeinstallation processes.
What does
Fanpy do?
As elaborated in Sections 4 and 5,
Fanpy provides independent mod-ules that facilitate the development of new multideterminant wavefunctions, Hamiltonians, rep-resentations of the Schr¨odinger equation (objective functions), and optimization algorithms. Wedesigned these modules to be compatible with one another so that researchers can easily customizetheir calculations and experiment with different combinations of methods and algorithms.
What are the limits of
Fanpy ? At present,
Fanpy is not designed for high performance. Infact, its performance was often deliberately compromised to prioritize ease of use and development.For accessibility,
Fanpy was written in pure Python even though other languages, such as C++ andJulia, are often better suited for high-performance parallel computing. Moreover, while
Fanpy ’smodular design is important for its extendibility and customizability, it prevents some types ofalgorithmic improvements. Since a method in its early stages of development is often intractablyexpensive, calculations in
Fanpy are often limited to small model systems with small basis sets. Someof the more efficient methods (e.g. AP1roG, which could be extended to thousands of electrons in13n efficient implementation) are limited to about 100 electrons in
Fanpy . Consistent with the overallmission of HORTON 3, therefore,
Fanpy should be viewed as a research tool that allows developersto quickly implement and test their ideas, rather than a comprehensive quantum chemistry suitethat can simulate large chemical systems. The intention is that after a researcher establishes thata method is of practical utility, a more efficient implementation can be developed.
How do I install
Fanpy ? The
Fanpy library can be installed directly from its source codeavailable on GitHub or through the pip and conda package-management systems. Since
Fanpy is purely Python and depends mainly on common Python libraries (NumPy and SciPy), it canbe installed by simply copying the source code onto the desired directory (though this is notrecommended). For the most updated instructions on how to install
Fanpy , please refer to the
Fanpy website.
What is the future direction of
Fanpy ? In addition to developing additional methodsrelevant to our scientific interests, the next iteration of
Fanpy will focus on improving its perfor-mance. Its computationally critical components will be outsourced to highly optimized libraries,such as our in-house CI software, PyCI. Some of the performance bottlenecks will be removed byreimplementing some features in Cython or C++. As these improvements may cause problems forsome users in terms of ease of use and installation, the pure Python implementation of
Fanpy willcontinue to be available.In terms of features, modules for (arbitrary-order) perturbation theory, equations-of-motion,and quantum-mechanical embedding are in various stages of development.
This brief paper introduces
Fanpy as a library for developing new post-Hartree-Fock ab initio methods.
Fanpy ’s goal is to help researchers quickly test ideas for new correlated electronic structuretheory methods and, to achieve this goal,
Fanpy contains many methods that can be used incountless combinations with one another. These methods are of intrinsic interest but, moreover,they serve as examples to be extended upon. Base classes are available as templates to help usersdevelop a structure that is compatible with the rest of
Fanpy . Acknowledgements
We wish to acknowledge various refinements to
Fanpy library from Matthew Chan, Cristina E.Gonz´alez-Espinoza, Xiaotian D. Yang, Stijn Fias, Caitlin Lanssens, and the HORTON developmentteam.P.W.A. and F.H.Z. acknowledges Natural Sciences and Engineering Research Council (NSERC)of Canada,Compute Canada, and CANARIE for financial and computational support. P.W.A.acknowledge support from the Canada Research Chairs. T.V. acknowledges support from theResearch Foundation – Flanders (FWO) (Belgium) and the Research Board of Ghent University.R.A.M.Q. acknowledges financial support from the University of Florida in the form of a start-upgrant. 14
References (1) Kim, T. D.; Miranda-Quintana, R. A.; Richer, M.; Ayers, P. W. Flexible Ansatz for N-bodyConfiguration Interaction, Unpublished Manuscript, 2020.(2) Johnson, P.; Ayers, P.; Limacher, P.; De Baerdemacker, S.; Van Neck, D.; Bultinck, P.
Com-putational and Theoretical Chemistry , , 101–13.(3) Frisch, M. J. et al. Gaussian 16 Revision C.01, Gaussian Inc. Wallingford CT, 2016.(4) Werner, H.-J.; Knowles, P. J.; Knizia, G.; Manby, F. R.; Sch¨utz, M. Wiley InterdisciplinaryReviews: Computational Molecular Science , , 242–253.(5) Smith, D. G.; Burns, L. A.; Sirianni, D. A.; Nascimento, D. R.; Kumar, A.; James, A. M.;Schriber, J. B.; Zhang, T.; Zhang, B.; Abbott, A. S., et al. Journal of chemical theory andcomputation , , 3504–3511.(6) Smith, D. G.; Burns, L. A.; Simmonett, A. C.; Parrish, R. M.; Schieber, M. C.; Galvelis, R.;Kraus, P.; Kruse, H.; Di Remigio, R.; Alenaizan, A., et al. The Journal of Chemical Physics , , 184108.(7) Verstraelen, T.; Tecmer, P.; Heidar-Zadeh, F.; Boguslawski, K.; Chan, M.; Zhao, Y.; Kim,T. D.; Vandenbrande, S.; Yang, D.; Gonz´alez-Espinoza, C. E.; Fias, S.; Limacher, P. A.;Berrocal, D.; Malek, A.; Ayers, P. W. HORTON, version 2.0.1, 2015.(8) Pople, J.; Seeger, R.; Krishnan, R. International Journal of Quantum Chemistry: QuantumChemistry Symposium , , 149–163.(9) Bytautas, L.; Henderson, T.; Jim´enez-Hoyos, C.; Ellis, J.; Scuseria, G. Journal of ChemicalPhysics , .(10) Alcoba, D.; Torre, A.; Luis, L.; O˜na, O.; Capuzzi, P.; Van Raemdonck, M.; Bultinck, P.;Van Neck, D. Journal of Chemical Physics , .(11) Cook, D. Molecular Physics , , 733–743.(12) Weinhold, F.; Wilson Jr, E. The Journal of Chemical Physics , , 2752–58.(13) Boys, S. Proceedings of the Royal Society of London A , , 542–554.(14) Hurley, A.; Lennard-Jones, J.; Pople, J. A theory of paired-electrons in polyatomic moleculesProceedings of the Royal Society of London Series A , , 446–455.(15) Parr, R.; Ellison, F.; Lykos, P. Journal of Chemical Physics , , 1106.(16) Parks, J.; Parr, R. Journal of Chemical Physics , , 335–345.(17) McWeeny, R.; Sutcliffe, B. Proceedings of the Royal Society of London Series A , ,103–116.(18) Surjan, P. In Correlation and Localization , Surjan, P., Ed., 1999, pp 63–88.(19) Allen, T.; Shull, H.
Journal of Physical Chemistry , , 2281–2283.(20) Tecmer, P.; Boguslawski, K.; Johnson, P.; Limacher, P.; Chan, M.; Verstraelen, T.; Ayers, P. Journal of Physical Chemistry A , , 9058–9068.(21) Paldus, J.; Cizek, J.; Sengupta, S. Journal of Chemical Physics , , 2452–2462.(22) Paldus, J.; Sengupta, S.; Cizek, J. Journal of Chemical Physics , , 652–666.1523) Shull, H. The Journal of Chemical Physics , , 1405–13.(24) Kutzelnigg, W. The Journal of Chemical Physics , , 3640–47.(25) Johnson, P.; Limacher, P.; Kim, T.; Richer, M.; Miranda-Quintana, R.; Heidar-Zadeh, F.;Ayers, P.; Bultinck, P.; De Baerdemacker, S.; Van Neck, D. Computational and TheoreticalChemistry , , 207–219.(26) Surjan, P.; Szabados, ´A.; Jeszenszki, P.; Zoboki, T. Journal of Mathematical Chemistry , , 534–551.(27) Rassolov, V. Journal of Chemical Physics , , 5978–5987.(28) Rassolov, V.; Xu, F.; Garashchuk, S. Journal of Chemical Physics , , 10385–10394.(29) Rassolov, V.; Xu, F. Journal of Chemical Physics , , 234112.(30) Cassam-Chena¨ı, P. Journal of Chemical Physics , , 194109.(31) Cassam-Chena¨ı, P.; Rassolov, V. Chemical Physics Letters , , 147–152.(32) Cassam-Chena¨ı, P.; Ilmane, A. Journal of Mathematical Chemistry , , 652–667.(33) Stein, T.; Henderson, T.; Scuseria, G. Journal of Chemical Physics , , 214113.(34) Henderson, T.; Scuseria, G.; Dukelsky, J.; Signoracci, A.; Duguet, T. Physical Review C , , 054305.(35) Henderson, T.; Bulik, I.; Stein, T.; Scuseria, G. Journal of Chemical Physics , ,244104.(36) Bulik, I.; Henderson, T.; Scuseria, G. Journal of Chemical Theory and Computation , , 3171–3179.(37) Cullen, J. Chemical Physics , , 217–229.(38) Miller, K.; Ruedenberg, K. Journal of Chemical Physics , , S88–S90.(39) Miller, K.; Ruedenberg, K. Journal of Chemical Physics , , 3414–3443.(40) Silver, D.; Mehler, E.; Ruedenberg, K. Journal of Chemical Physics , , 1174–1180.(41) Mehler, E.; Ruedenberg, K.; Silver, D. Journal of Chemical Physics , , 1181–1205.(42) Silver, D.; Ruedenberg, K.; Mehler, E. Journal of Chemical Physics , , 1206–1227.(43) Coleman, A. Journal of Mathematical Physics , , 1425–1431.(44) Coleman, A. International Journal of Quantum Chemistry , , 23–30.(45) Bajdich, M.; Drobn´y, G.; Wagner, L.; Schmidt, K. Physical Review Letters , , 130201.(46) Bajdich, M.; Mitas, L.; Wagner, L.; Schmidt, K. Physical Review B , , 115112.(47) Pernal, K. Journal of Chemical Theory and Computation , , 4332–4341.(48) Pastorczak, E.; Pernal, K. Physical Chemistry Chemical Physics , , 8622–8626.(49) Limacher, P.; Kim, T.; Ayers, P.; Johnson, P.; De Baerdemacker, S.; Van Neck, D. MolecularPhysics , , 853–862.(50) Limacher, P. Journal of Chemical Physics , , 194102.(51) Boguslawski, K.; Tecmer, P.; Ayers, P.; Bultinck, P.; De Baerdemacker, S.; Van Neck, D. Physical Review B , , 201106. 1652) Boguslawski, K.; Tecmer, P.; Bultinck, P.; De Baerdemacker, S.; Van Neck, D.; Ayers, P. Journal of Chemical Theory and Computation , , 4873–4882.(53) Silver, D. The Journal of Chemical Physics , , 5108–16.(54) Limacher, P.; Ayers, P.; Johnson, P.; De Baerdemacker, S.; Van Neck, D.; Bultinck, P. Journalof Chemical Theory and Computation , , 1394–1401.(55) Schollw¨ock, U. Annals of Physics , , 96–192.(56) Paldus, J.; Li, X. In Advances in Chemical Physics , Prigogine, I., Rice, S., Eds., 1999; Vol. 110,pp 1–175.(57) Cizek, J.
Journal of Chemical Physics , , 4256–4266.(58) Shavitt, I.; Bartlett, R., Many-body methods in chemistry and physics: MBPT and coupled-cluster theory ; Cambridge: Cambridge, 2009.(59) Bartlett, R.; Musia l, M.
Reviews of Modern Physics , , 291–352.(60) Evangelista, F. A.; Chan, G. K. L.; Scuseria, G. E. Journal of Chemical Physics , ,244112.(61) Evangelista, F. A. Journal of Chemical Physics , , 224102.(62) Richardson, R. Physical Review , , 792–805.(63) Pariser, R.; Parr, R. G. The Journal of Chemical Physics , , 466–471.(64) Pariser, R.; Parr, R. G. The Journal of Chemical Physics , , 767–776.(65) Pople, J. A. Transactions of the Faraday Society , , 1375–1385.(66) Surj´an, P. R., Second quantized approach to quantum chemistry: an elementary introduction ;Springer Science & Business Media: 2012.(67) Hubbard, J.
Proceedings of the Royal Society of London A , , 238–257.(68) Planelles, J.; Zicovich-Wilson, C.; Jaskolski, W.; Corma, A. International journal of quantumchemistry , , 971–981.(69) Ising, E. Zeitschrift f¨ur Physik , , 253–258.(70) Capelle, K.; Campo Jr, V. L. Physics Reports , , 91–159.(71) Heisenberg, W. In Original Scientific Papers Wissenschaftliche Originalarbeiten ; Springer:1985, pp 580–597.(72) Richardson, R. .(73) Dukelsky, J.; Pittel, S.; Sierra, G.
Reviews of modern physics , , 643.(74) Adams, W.; Zhao, Y.; Ayers, P. W. ModelHamiltonian, version 0.0.0, 2020.(75) Piela, L., Ideas of quantum chemistry ; Elsevier: 2013.(76) Jensen, F.,
Introduction to computational chemistry ; John wiley & sons: 2017.(77) Cramer, C. J.,
Essentials of computational chemistry: theories and models ; John Wiley &Sons: 2013.(78) Helgaker, T.; Jørgensen, P.; Olsen, J.,
Modern electronic structure theory ; Wiley: Chichester,2000. 1779) Szabo, A.; Ostlund, N.,
Modern Quantum Chemistry - Introduction to Advanced ElectronicStructure Theory ; McGraw-Hill Inc.: 1989, pp 43–107.(80) Nightingale, M. P.; Umrigar, C. J.,
Quantum Monte Carlo methods in physics and chemistry ;525; Springer Science & Business Media: 1998.(81) Umrigar, C.
The Journal of chemical physics , , 164105.(82) Sabzevari, I.; Sharma, S. Journal of chemical theory and computation , , 6276–6286.(83) Neuscamman, E. The Journal of chemical physics , , 194105.(84) Neuscamman, E. Journal of chemical theory and computation , , 3149–3159.(85) Kurita, M.; Yamaji, Y.; Morita, S.; Imada, M. Physical Review B , , 035122.(86) Virtanen, P.; Gommers, R.; Oliphant, T. E.; Haberland, M.; Reddy, T.; Cournapeau, D.;Burovski, E.; Peterson, P.; Weckesser, W.; Bright, J., et al. Nature methods , , 261–272.(87) Hansen, N.; Auger, A. In Theory and Principled Methods for the Design of Metaheuristics ,Borenstein, Y., Moraglio, A., Eds.; Springer Berlin Heidelberg: Berlin, Heidelberg, 2014,pp 145–180.(88) Hansen, N.; Akimoto, Y.; Baudis, P. CMA-ES/pycma on Github, Zenodo, DOI:10.5281/zenodo.2559634,2019.(89) Head, T. et al. scikit-optimize/scikit-optimize: v0.5.2, version v0.5.2, 2018.(90) Sun, Q.; Berkelbach, T. C.; Blunt, N. S.; Booth, G. H.; Guo, S.; Li, Z.; Liu, J.; McClain,J. D.; Sayfutyarova, E. R.; Sharma, S., et al.
Wiley Interdisciplinary Reviews: ComputationalMolecular Science ,8