In this tutorial, we will demonstrate how to perform the orbital refinement using pair natural orbitals (PNOs) as initial guess orbitals for a ground state FCI calculation. The tutorial is structured as follows:
Define the molecule and parameters for the calculation
Get the initial pair natural orbitals
Calculate the initial integrals
Perform the FCI calculation and extract the one-body and two-body reduced density matrices (rdms)
Perform the orbital refinement using the 1-body and 2-body rdms obtained from the FCI calculation
Repeat the orbital refinement until convergence is reached
Maximal number of iterations for orbital refinement
3
Size of the simulation box
4
Order of wavelet basis functions
5
Threshold for numerical precision of function representation
6
Energy convergence threshold for orbital refinement
Get pair natural orbitals (PNOs)
To get an initial guess for the FCI calculation, we use the pair natural orbitals (PNOs) generated with the FrayedEnds MadPNO class. First, the geometry of the H4 molecule is defined, and the numerical environment for the multiwavelet representation is set up using the MadWorld3D class. The PNOs are then computed and orthonormalized. Additionally, the nuclear repulsion energy and the nuclear potential are computed for later use in the FCI calculation.
MADNESS runtime initialized with 9 threads in the pool and affinity OFF
Define a linear H4 molecule geometry with 1.0 Angstrom spacing between adjacent atoms
Setting up the numerical environment for the MRA calculations by creating a frayedends world object with the specified parameters
Compute the pair natural orbitals (PNOs) for the H4 molecule using the MadPNO class in FrayedEnds
Orthonormalize the PNOs using the orthonormalization method in the Integrals3D class
Compute the nuclear repulsion energy
Compute the nuclear potential for the H4 molecule
Orbital Refinement using FCI
In each iteration of the orbital refinement, the two-body, kinetic, and potential integrals are first computed using the current orbitals. With these integrals, the FCI calculation is performed to obtain the electronic energy and the FCI vector. From the FCI vector, the 1-body and 2-body reduced density matrices (rdms) are constructed and used for the orbital refinement. The orbital refinement loop continues until the energy converges within the specified threshold.
import numpy as npfrom pyscf import fcicurrent =0.0for iteration inrange(iterations): integrals = fe.Integrals3D(world) G = integrals.compute_two_body_integrals(orbs, ordering="chem").elems T = integrals.compute_kinetic_integrals(orbs) V = integrals.compute_potential_integrals(orbs, Vnuc) e, fcivec = fci.direct_spin0.kernel(T + V, G, n_orbitals, n_electrons) rdm1, rdm2 = fci.direct_spin0.make_rdm12( fcivec, n_orbitals, n_electrons, ) rdm2 = np.swapaxes(rdm2, 1, 2) e_tot = e + nuc_repulsionprint("iteration {} FCI electronic energy {:+2.8f}, total energy {:+2.8f}".format(iteration, e, e_tot)) opti = fe.Optimization3D(world, Vnuc, nuc_repulsion) orbs = opti.get_orbitals( orbitals=orbs, rdm1=rdm1, rdm2=rdm2, opt_thresh=0.001, occ_thresh=0.001, )for i inrange(n_orbitals): world.cube_plot(f"orb{i}", orbs[i], molecule)if np.isclose(e_tot, current, atol=econv, rtol=0.0):break current = e_totfe.cleanup(globals())
iteration 0 FCI electronic energy -4.53404243, total energy -2.24094119
iteration 1 FCI electronic energy -4.53661359, total energy -2.24351234
iteration 2 FCI electronic energy -4.53672886, total energy -2.24362762
iteration 3 FCI electronic energy -4.53673548, total energy -2.24363423
iteration 4 FCI electronic energy -4.53673586, total energy -2.24363461
Create an integrals object to compute the initial integrals
Compute the two-body, kinetic and potential integrals using the orbitals obtained from NWChem
Perform the FCI calculation using the integrals
Compute the 1-body and 2-body reduced density matrices (rdms) from the FCI vector
Compute the total energy by adding the nuclear repulsion energy to the electronic energy obtained from the FCI calculation
Perform the orbital refinement using the 1-body and 2-body rdms obtained from the FCI calculation
Loop terminates as soon as the energy changes less than econv in one iteration step
The orbital refinement process is repeated until convergence is reached. At the end of the orbital refinement, the ground state energy should be improved compared to the initial FCI calculation with the PNO orbitals as guess orbitals.
The initial PNOs and the refined orbitals after the orbital optimization can be visualized using the cube files and plotted interactively using py3Dmol.