Spinor bases#

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

import gqcpy
import numpy as np
np.set_printoptions(precision=3)

GQCP offers the capability to its users to work with different kinds of spinor bases. Let’s explore the API of the spinor bases with a small example.

molecule = gqcpy.Molecule.ReadXYZ("../../gqcp/tests/data/h2_szabo.xyz" , 0)  # create a neutral molecule

Restricted spinor bases#

The one everyone is familiar with is a spinor basis whose alpha- and beta- expansion coefficients are equal. We call this spinor basis a restricted spinor basis RSpinOrbitalBasis.

r_spinor_basis = gqcpy.RSpinOrbitalBasis_d(molecule=molecule, basisset_name="STO-3G")

Constructing a spinor basis from a molecule and a basisset specification yields a non-orthogonal spinor basis, where the underlying scalar bases have been constructed by placing GTO shells on every atom of the molecule.

S_r = r_spinor_basis.quantize(gqcpy.OverlapOperator()).parameters()
print(S_r)
[[1.    0.659]
 [0.659 1.   ]]

Since this initial basis is non-orthogonal, we should first try to orthonormalize it.

r_spinor_basis.lowdinOrthonormalize()

S_r = r_spinor_basis.quantize(gqcpy.OverlapOperator()).parameters()
print(S_r)
[[1.00e+00 1.11e-16]
 [1.11e-16 1.00e+00]]
T = np.random.rand(2, 2)
g = r_spinor_basis.quantize(gqcpy.CoulombRepulsionOperator())
print(g.parameters())
g.transform(gqcpy.RTransformation_d(T))
print(g.parameters())
[[[[ 0.856 -0.006]
   [-0.006  0.494]]

  [[-0.006  0.011]
   [ 0.011 -0.006]]]


 [[[-0.006  0.011]
   [ 0.011 -0.006]]

  [[ 0.494 -0.006]
   [-0.006  0.856]]]]
[[[[1.026e+00 1.313e-01]
   [1.313e-01 2.552e-02]]

  [[1.313e-01 1.918e-02]
   [1.918e-02 3.849e-03]]]


 [[[1.313e-01 1.918e-02]
   [1.918e-02 3.849e-03]]

  [[2.552e-02 3.849e-03]
   [3.849e-03 7.831e-04]]]]
g_r = r_spinor_basis.quantize(gqcpy.CoulombRepulsionOperator()).parameters()
print(g_r)
[[[[ 0.856 -0.006]
   [-0.006  0.494]]

  [[-0.006  0.011]
   [ 0.011 -0.006]]]


 [[[-0.006  0.011]
   [ 0.011 -0.006]]

  [[ 0.494 -0.006]
   [-0.006  0.856]]]]

General spinor bases#

General(ized) spinor bases have no restrictions on the expansion coefficients for the alpha- and beta spinors.

We can create them from a basisset specification in the same way as restricted spinor bases.

g_spinor_basis = gqcpy.GSpinorBasis_d(molecule, "STO-3G")

Similarly as in the restricted case, the spinor basis that is initialized here, is non-orthogonal.

S_g = g_spinor_basis.quantize(gqcpy.OverlapOperator()).parameters()
print(S_g)
[[1.    0.659 0.    0.   ]
 [0.659 1.    0.    0.   ]
 [0.    0.    1.    0.659]
 [0.    0.    0.659 1.   ]]

We may, however, proceed by orthonormalizing it using a Löwdin orthonormalization step.

g_spinor_basis.lowdinOrthonormalize()

S_g = g_spinor_basis.quantize(gqcpy.OverlapOperator()).parameters()
print(S_g)
[[1.00e+00 1.11e-16 0.00e+00 0.00e+00]
 [1.11e-16 1.00e+00 0.00e+00 0.00e+00]
 [0.00e+00 0.00e+00 1.00e+00 1.11e-16]
 [0.00e+00 0.00e+00 1.11e-16 1.00e+00]]
g_g = g_spinor_basis.quantize(gqcpy.CoulombRepulsionOperator()).parameters()
print(g_g)
[[[[ 0.856 -0.006  0.     0.   ]
   [-0.006  0.494  0.     0.   ]
   [ 0.     0.     0.856 -0.006]
   [ 0.     0.    -0.006  0.494]]

  [[-0.006  0.011  0.     0.   ]
   [ 0.011 -0.006  0.     0.   ]
   [ 0.     0.    -0.006  0.011]
   [ 0.     0.     0.011 -0.006]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]]


 [[[-0.006  0.011  0.     0.   ]
   [ 0.011 -0.006  0.     0.   ]
   [ 0.     0.    -0.006  0.011]
   [ 0.     0.     0.011 -0.006]]

  [[ 0.494 -0.006  0.     0.   ]
   [-0.006  0.856  0.     0.   ]
   [ 0.     0.     0.494 -0.006]
   [ 0.     0.    -0.006  0.856]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]]


 [[[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[ 0.856 -0.006  0.     0.   ]
   [-0.006  0.494  0.     0.   ]
   [ 0.     0.     0.856 -0.006]
   [ 0.     0.    -0.006  0.494]]

  [[-0.006  0.011  0.     0.   ]
   [ 0.011 -0.006  0.     0.   ]
   [ 0.     0.    -0.006  0.011]
   [ 0.     0.     0.011 -0.006]]]


 [[[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]
   [ 0.     0.     0.     0.   ]]

  [[-0.006  0.011  0.     0.   ]
   [ 0.011 -0.006  0.     0.   ]
   [ 0.     0.    -0.006  0.011]
   [ 0.     0.     0.011 -0.006]]

  [[ 0.494 -0.006  0.     0.   ]
   [-0.006  0.856  0.     0.   ]
   [ 0.     0.     0.494 -0.006]
   [ 0.     0.    -0.006  0.856]]]]