# Force the local gqcpy to be imported
import sys
sys.path.insert(0, '../../build/gqcpy/')

import gqcpy
import numpy as np

Setup the basis and the overlap#

molecule = gqcpy.Molecule.HChain(2, 2.5, 0)  
N = molecule.numberOfElectrons()

spinor_basis = gqcpy.GSpinorBasis_d(molecule, "6-31G")
S = spinor_basis.quantize(gqcpy.OverlapOperator())

Define two non-orthogonal states#

state_1 = gqcpy.GTransformation_d(np.array([[-0.07443693,  0.12036042, -0.13557067,  0.15517005,  0.133151,   -0.03074946, -0.92997876, -0.93718779],
                                            [-0.07874922,  0.15086478, -0.68085546,  0.77423311,  0.08712373,  0.25266303,  0.848079  ,  0.89108911],
                                            [-0.24580188,  0.26338108,  0.09556297, -0.12178159,  0.91319299,  0.90475733, -0.03994767,  0.12839983],
                                            [-0.38944259,  0.4101685 ,  0.45214166, -0.58335985, -0.90125958, -0.93270816, -0.16410814, -0.32074956],
                                            [-0.26338108, -0.24580188, -0.12178159, -0.09556297, -0.90475733,  0.91319299, -0.12839983, -0.03994767],
                                            [-0.4101685 , -0.38944259, -0.58335985, -0.45214166,  0.93270817, -0.90125958,  0.32074956, -0.16410814],
                                            [-0.12036042, -0.07443693,  0.15517005,  0.13557067,  0.03074946,  0.13315101,  0.93718779, -0.92997876],
                                            [-0.15086478, -0.07874922,  0.77423311,  0.68085546, -0.25266303,  0.08712373, -0.89108911,  0.848079  ]]))

state_2 = gqcpy.GTransformation_d(np.array([[ 0.25851329, -0.14539151, -0.17177142, -0.01126487,  0.81289875, -0.77260907,  0.50167389, -0.44422385],
                                            [ 0.36593356, -0.28669343, -0.84796858, -0.13503625, -0.62437698,  0.96771154, -0.55231929,  0.30317456],
                                            [ 0.25853403,  0.14539669,  0.17176599, -0.01126146,  0.81450567,  0.7709918 , -0.501289  , -0.44451308],
                                            [ 0.36597032,  0.28670189,  0.847938  , -0.13501526, -0.62639487, -0.96647128,  0.5520554 ,  0.30349133],
                                            [ 0.10076798, -0.23874662,  0.04823423,  0.17685836,  0.42013282, -0.48352714, -0.79642816,  0.8239984 ],
                                            [ 0.16561668, -0.35007843,  0.19502141,  0.90182842, -0.55545195,  0.39170258,  0.56753639, -0.94408827],
                                            [-0.10075937, -0.23872464,  0.0482368 , -0.17686313, -0.42104909, -0.4826058 , -0.79588057, -0.82460595],
                                            [-0.16560552, -0.35003836,  0.19503259, -0.9018579 ,  0.55619574,  0.39048771,  0.56690551,  0.94451894]]))

Create the biorthogonal space of the two non-orthogonal determinants#

We can define a Löwdin pairing basis using two non-orthogonal states, the overlap in AO basis and the number of occupied orbitals.

lp_basis = gqcpy.GLowdinPairingBasis_d(state_1, state_2, S, N)
biorth_bra_expansion = lp_basis.biorthogonalBraExpansion()
biorth_ket_expansion = lp_basis.biorthogonalKetExpansion()
print("Biorthogonal Bra")
print("----------------")
print(biorth_bra_expansion)
print("")
print("Biorthogonal Ket")
print("----------------")
print(biorth_ket_expansion)
Biorthogonal Bra
----------------
[[-0.14038635 -0.01786507]
 [-0.16993508 -0.00914819]
 [-0.34156389 -0.11455247]
 [-0.53468019 -0.18444736]
 [ 0.11455247 -0.34156389]
 [ 0.18444736 -0.53468019]
 [ 0.01786507 -0.14038635]
 [ 0.00914819 -0.16993508]]

Biorthogonal Ket
----------------
[[ 0.18680645 -0.23037179]
 [ 0.23464362 -0.40130146]
 [ 0.29390833  0.03997422]
 [ 0.44583031  0.13178613]
 [ 0.0057684  -0.25907694]
 [ 0.02506212 -0.38646563]
 [-0.18158893 -0.18484417]
 [-0.28286936 -0.26445598]]

Furthermore, the biorthogonal basis is capable of calculating the different co-density and weighted co-density matrices needed for a NOCI calculation.

W = lp_basis.weightedCoDensity()
np.set_printoptions(linewidth=800)
print(W.matrix())
[[ 0.03326887  0.03688621  0.10023033  0.15829074  0.06947715  0.10772049  0.03447101  0.04425258]
 [ 0.04414342  0.04753796  0.14099828  0.22314075  0.13229605  0.20579061  0.06180499  0.07798674]
 [ 0.04387607  0.05369857  0.10340514  0.1616278  -0.05256822 -0.08392318 -0.01229957 -0.01091407]
 [ 0.06505878  0.08068895  0.14725696  0.22971843 -0.10836118 -0.17210519 -0.0304205  -0.03079477]
 [ 0.00632852  0.00385361  0.03708684  0.05962     0.10349962  0.16198506  0.04272209  0.0517923 ]
 [ 0.0119442   0.0087794   0.06141465  0.09847184  0.15234745  0.23834366  0.06340999  0.07709552]
 [-0.02373907 -0.03145185 -0.04228304 -0.06507302  0.09689903  0.15269387  0.03407656  0.03879353]
 [-0.03747352 -0.049247   -0.06903443 -0.10646852  0.14149733  0.22307043  0.04919991  0.05573053]]

The biorthogonal basis can also be created for restricted and unrestricted states.