# A matrix form used in the Quantum Annealer Eigensolver (QAE)

In the paper "Computing molecular excited states on a D‑Wave quantum annealer", PySCF is employed to compute the TDA matrix. Then a few of the lowest eigenvalues and eigenvectors of a TDA matrix are computed using the Quantum Annealer Eigensolver (QAE). How can I get the specific "A matrix" mentioned, which appears to be the singular matrix for the TDA computation?" @Nike Dattani

# Introduction

The TDA (Tamm-Dancoff approximation) uses only the $$A$$ matrix, which is the upper-left block of the full TD-DFT matrix that was provided by Tyberius here, in his answer to your question about how to interpret the $$A$$ matrix output from this Python script as a 2D array. Now it seems that you not only want to interpret the $$A$$ matrix as a 2D array, but you also want to "get" the $$A$$ matrix:

"How can I get this specific 'A matrix' mentioned"

I was able to obtain an $$A$$ matrix from exactly that same Python script (called 21-matrix_A_B.py and titled A, B matrices of TDDFT method) , and I have simplified it further so that you only get the A and B matrices (see below).

# Import some basic modules

First import some basic modules that tend to be used for TD-DFT calculations:

import numpy
from pyscf import gto, scf, dft, tddft


# Specify the molecule, geometry and basis set

Then "build" an HF (hydrogen fluoride) molecule with a bond length of 0.917 in PySCF's default distance units, and the 6-311G* basis set:

mol = gto.Mole()
mol.atom = [
['H' , (0. , 0. , .917)],
['F' , (0. , 0. , 0.)], ]
mol.basis = '6311g*'
mol.build()


# Run an SCF calculation

In the above-linked example Python script provided with PySCF, an RHF calculation is done first (but examples using UHF and UKS are provided later, and we can just choose one of them):

mf = scf.RHF(mol).run()


Notice that I skipped some lines from the example script:

def diagonalize(a, b, nroots=5):
nocc, nvir = a.shape[:2]
a = a.reshape(nocc*nvir,nocc*nvir)
b = b.reshape(nocc*nvir,nocc*nvir)
e = numpy.linalg.eig(numpy.bmat([[a        , b       ],
[-b.conj(),-a.conj()]]))[0]
lowest_e = numpy.sort(e[e > 0])[:nroots]
return lowest_e


I skipped those lines because we are not actually going to use that diagonalize function, and in the paper that you mentioned, the function of the "diagonalization" (which in this case is to give us the eigenvalues), is attempted by the D-Wave annealer rather than by PySCF.

# Get the A and B matrices

a, b = tddft.TDHF(mf).get_ab()


Let's also borrow the following lines from the function diagonalize that we removed, since this will actually reshape the a array (which is a 4-dimensional array when obtained directly from get_ab() in the above line of code) into a more familiar 2D matrix:

nocc, nvir = a.shape[:2]
a = a.reshape(nocc*nvir,nocc*nvir)


# Putting it all together

After entering the command python or python3 in a terminal, assuming that it is installed with one of those names, and that suitable versions of numpy and pyscf are installed properly, you can run the following commands:

import numpy
from pyscf import gto, scf, dft, tddft

mol = gto.Mole()
mol.atom = [
['H' , (0. , 0. , .917)],
['F' , (0. , 0. , 0.)], ]
mol.basis = '6311g*'
mol.build()

mf = scf.RHF(mol).run()
a, b = tddft.TDHF(mf).get_ab()
nocc, nvir = a.shape[:2]
a = a.reshape(nocc*nvir,nocc*nvir)



Then when I enter the command a in the Python console, I get the following 2D matrix:

array([[ 2.60456133e+01, -1.43048216e-01,  9.17722977e-17, ...,
-1.35695829e-02, -1.44171241e-17, -1.80327561e-17],
[-1.43048216e-01,  2.62987754e+01,  5.04602697e-16, ...,
-8.91049840e-03, -1.75270105e-17, -1.19651301e-17],
[ 9.17722977e-17,  5.04602697e-16,  2.66653809e+01, ...,
-2.05590505e-16,  1.36131946e-04, -1.30126224e-02],
...,
[-1.35695829e-02, -8.91049840e-03, -2.05590505e-16, ...,
6.55286894e+00,  5.26486912e-17,  5.92386345e-17],
[-1.44171241e-17, -1.75270105e-17,  1.36131946e-04, ...,
5.26486912e-17,  6.56828103e+00, -5.35839140e-04],
[-1.80327561e-17, -1.19651301e-17, -1.30126224e-02, ...,
5.92386345e-17, -5.35839140e-04,  6.80976592e+01]])


Without including the last two lines of the code in this section, there will be an enormous amount of numbers that are not expressed in a clear way:

array([[[[ 2.60456133e+01, -1.43048216e-01,  2.52247100e-16, ...,
1.18048394e-16, -1.02366899e-01, -2.99273826e-03],
[ 5.63225509e-03,  8.76294620e-03, -2.72961492e-17, ...,
-9.29391367e-18,  1.21119261e-02,  1.50477775e-02],
[-5.47818937e-03, -1.00965081e-02,  2.32057657e-17, ...,
1.14199267e-17, -1.63499987e-02, -8.27876810e-03],
[-1.53313386e-17, -1.21786734e-17, -1.17585782e-02, ...,
-1.43825277e-02, -2.26920292e-17, -3.12834270e-17],
[ 4.52641078e-17,  2.05773995e-17,  1.63839318e-03, ...,
2.65783872e-03,  2.02358655e-17,  7.37224457e-19]],

[[-1.43048216e-01,  2.62987754e+01,  1.85559485e-16, ...,
8.69255890e-18, -1.80038437e-01,  2.76640714e-03],
[ 1.06229812e-02,  1.51471459e-02, -3.25023819e-17, ...,
-3.42704358e-18,  2.10369804e-02,  9.47115809e-03],
[-3.26220325e-03, -1.36594196e-02,  1.34144430e-17, ...,
7.48984986e-18, -1.53972648e-02, -9.58464325e-03],
[-5.04372963e-18, -2.65822744e-17, -5.55759927e-03, ...,
-9.44432054e-03, -2.60031530e-17, -2.52199046e-17],
[ 1.91883698e-17,  6.69254025e-17,  7.74373617e-04, ...,
1.74527603e-03,  3.11500512e-17,  9.65125128e-19]],

[[ 2.52247100e-16,  1.85559485e-16,  2.66653809e+01, ...,
-4.14258055e-01,  3.88019883e-16, -1.68771690e-16],
[-5.49768644e-17, -5.27252681e-17,  4.73023040e-02, ...,
4.07441054e-02, -4.20031262e-17,  6.34145865e-17],
[-2.36590108e-17, -2.52329213e-17, -1.25044647e-02, ...,
-1.01253886e-02, -5.33239060e-17,  6.85749494e-18],
[ 3.07973972e-03,  8.05746451e-03, -1.11839463e-16, ...,
-9.51809153e-17,  1.59090454e-04, -1.52071873e-02],
[-4.29118594e-04, -1.12269482e-03,  1.19373172e-16, ...,
7.41740010e-17, -2.21670265e-05,  2.11890856e-03]],

...,

[[ 1.18048394e-16,  8.69255890e-18, -4.14258055e-01, ...,
3.13177514e+01, -1.06879611e-16,  4.89758197e-16],
[-2.40137843e-17, -1.45581683e-17,  1.01366432e-01, ...,
1.08418144e-01,  8.40920174e-18,  1.99334109e-17],
[-2.25365451e-17, -3.09943397e-17, -2.68050363e-02, ...,
-2.66715970e-02, -5.84272882e-17,  1.20879344e-17],
[ 1.85007711e-02,  1.99998116e-02, -6.27379629e-17, ...,
-1.46358495e-16,  1.95846665e-04, -3.08303159e-02],
[-3.41887510e-03, -3.69589233e-03,  8.57034652e-17, ...,
2.29138501e-16, -3.61917502e-05,  5.69733006e-03]],

[[-1.02366899e-01, -1.80038437e-01,  3.88019883e-16, ...,
-1.06879611e-16,  3.14873810e+01, -2.71828309e-03],
[ 4.38904519e-02,  6.16691287e-02, -1.01488685e-16, ...,
1.80700152e-17,  1.06739839e-01, -4.44639257e-03],
[ 4.34057139e-03, -2.36002189e-02,  1.71053614e-18, ...,
-6.42770021e-18, -2.76086222e-02, -2.51608621e-02],
[-2.83982709e-18, -2.29817728e-17,  2.20942868e-03, ...,
3.56382552e-03, -1.08377845e-16, -2.49025578e-17],
[ 1.38145177e-17,  3.29116066e-17, -3.07852940e-04, ...,
-6.58581972e-04,  2.14013831e-16,  1.62670658e-18]],

[[-2.99273826e-03,  2.76640714e-03, -1.68771690e-16, ...,
4.89758197e-16, -2.71828309e-03,  9.20697384e+01],
[ 6.74990646e-03,  5.38580972e-03,  5.11377035e-18, ...,
1.39336016e-17,  9.96971178e-03,  6.84327263e-04],
[ 6.70688000e-03,  1.26288908e-02, -4.39000556e-17, ...,
-7.18892160e-17,  8.88532442e-02,  1.82547204e-03],
[-1.55201670e-17, -2.92650713e-18,  2.83491517e-02, ...,
1.03861543e-01,  8.12772173e-17,  3.16651901e-16],
[-2.27258802e-18, -5.28719242e-18, -3.95005722e-03, ...,
-1.91932348e-02, -3.46312768e-17,  4.02013294e-16]]],

[[[ 5.63225509e-03,  1.06229812e-02, -5.49768644e-17, ...,
-2.40137843e-17,  4.38904519e-02,  6.74990646e-03],
[ 1.43064975e+00, -6.09615429e-02,  1.22200625e-16, ...,
5.19826520e-17, -2.87950614e-02, -8.67487755e-03],
[-1.35359294e-03,  1.48416197e-02, -8.84029921e-17, ...,
-2.54479702e-17,  3.96865233e-02,  3.40996999e-03],
[ 6.65558163e-18,  1.34296339e-17,  4.80030137e-02, ...,
4.60463491e-02,  4.02892829e-17,  3.66728694e-17],
[-4.57741656e-18, -9.69989436e-18, -6.68854761e-03, ...,
-8.50919755e-03, -2.57769958e-17,  2.64951838e-18]],

[[ 8.76294620e-03,  1.51471459e-02, -5.27252681e-17, ...,
-1.45581683e-17,  6.16691287e-02,  5.38580972e-03],
[-6.09615429e-02,  1.73075386e+00,  3.42004217e-17, ...,
-7.37769300e-18, -5.04545009e-02, -3.99341689e-03],
[ 1.21996710e-02, -8.32910442e-03, -6.73292146e-17, ...,
-1.66368347e-17,  3.35308950e-02,  1.71042301e-03],
[ 7.69442487e-18,  2.62887641e-19,  5.29991463e-02, ...,
2.85696738e-02,  2.80316603e-17,  2.49191624e-17],
[-3.59978088e-18, -9.52942963e-18, -7.38468872e-03, ...,
-5.27957162e-03, -2.31599852e-17,  1.32364578e-18]],

[[-2.72961492e-17, -3.25023819e-17,  4.73023040e-02, ...,
1.01366432e-01, -1.01488685e-16,  5.11377035e-18],
[ 1.22200625e-16,  3.42004217e-17,  2.25094001e+00, ...,
-1.47944383e-01,  1.40541678e-16, -7.95333140e-18],
[ 1.21471608e-17,  1.32223282e-17,  1.02704171e-02, ...,
1.37344572e-02,  1.17888453e-17,  1.41476791e-17],
[-9.07439459e-03,  1.43740515e-02,  2.27439404e-17, ...,
4.25652937e-17,  1.36933468e-03, -4.73928990e-03],
[ 1.26438979e-03, -2.00282275e-03, -8.68165242e-18, ...,
-2.70587404e-17, -1.90797609e-04,  6.60353668e-04]],

...,

[[-9.29391367e-18, -3.42704358e-18,  4.07441054e-02, ...,
1.08418144e-01,  1.80700152e-17,  1.39336016e-17],
[ 5.19826520e-17, -7.37769300e-18, -1.47944383e-01, ...,
7.36556571e+00, -4.39735115e-17,  2.43640327e-16],
[-8.04429959e-18, -1.24842003e-18,  1.60052076e-02, ...,
4.40198712e-02,  2.43777713e-17, -3.22449155e-17],
[ 8.01692312e-03, -9.04851396e-03,  3.77793961e-17, ...,
7.52233837e-17,  1.35174553e-03,  2.84855602e-02],
[-1.48149818e-03,  1.67213241e-03, -2.16513251e-17, ...,
-3.95632533e-17, -2.49797649e-04, -5.26402774e-03]],

[[ 1.21119261e-02,  2.10369804e-02, -4.20031262e-17, ...,
8.40920174e-18,  1.06739839e-01,  9.96971178e-03],
[-2.87950614e-02, -5.04545009e-02,  1.40541678e-16, ...,
-4.39735115e-17,  7.52836414e+00,  1.36660153e-03],
[ 1.79537429e-02,  4.07133045e-02,  1.07757677e-18, ...,
-4.92690958e-18,  5.39443678e-02,  2.97677086e-02],
[ 1.32749938e-17,  2.60329833e-17,  8.84724119e-03, ...,
1.52561546e-02,  5.91020123e-17,  3.25611936e-17],
[-3.02944995e-18, -6.65286767e-18, -1.23273914e-03, ...,
-2.81928179e-03, -4.17740399e-17, -5.40082544e-18]],

[[ 1.50477775e-02,  9.47115809e-03,  6.34145865e-17, ...,
1.99334109e-17, -4.44639257e-03,  6.84327263e-04],
[-8.67487755e-03, -3.99341689e-03, -7.95333140e-18, ...,
2.43640327e-16,  1.36660153e-03,  6.91485902e+01],
[-9.47212208e-03, -1.84883621e-02,  7.70047505e-17, ...,
1.34478914e-17, -3.48847080e-02,  5.40926289e-02],
[ 1.12904045e-18, -1.27254220e-17, -4.30316058e-02, ...,
-4.53776133e-02, -3.74021590e-17, -5.06419642e-17],
[ 3.82585897e-19,  4.14226871e-18,  5.99585156e-03, ...,
8.38561761e-03,  1.55155698e-17, -3.41171246e-17]]],

[[[-5.47818937e-03, -3.26220325e-03, -2.36590108e-17, ...,
-2.25365451e-17,  4.34057139e-03,  6.70688000e-03],
[-1.35359294e-03,  1.21996710e-02,  1.21471608e-17, ...,
-8.04429959e-18,  1.79537429e-02, -9.47212208e-03],
[ 6.09789250e-01, -1.86455048e-02,  1.39133141e-17, ...,
3.35324507e-17,  4.30784404e-03,  3.77835830e-03],
[ 6.84680539e-18,  3.32719551e-17,  7.33231010e-02, ...,
3.36192439e-02,  3.13760901e-17,  3.21225801e-17],
[ 5.34778447e-18, -2.74096172e-18, -1.02165471e-02, ...,
-6.21271380e-03, -1.27902235e-17,  4.73676722e-18]],

[[-1.00965081e-02, -1.36594196e-02, -2.52329213e-17, ...,
-3.09943397e-17, -2.36002189e-02,  1.26288908e-02],
[ 1.48416197e-02, -8.32910442e-03,  1.32223282e-17, ...,
-1.24842003e-18,  4.07133045e-02, -1.84883621e-02],
[-1.86455048e-02,  1.01481374e+00, -9.98893495e-17, ...,
-3.94572513e-17,  6.09524778e-03,  5.44665749e-03],
[ 3.51011460e-17,  5.98611131e-17,  1.03744415e-01, ...,
6.09961875e-02,  6.10726210e-17,  5.14665331e-17],
[ 6.91639776e-18, -1.03426735e-18, -1.44553312e-02, ...,
-1.12718732e-02, -1.55470256e-17,  1.09268624e-17]],

[[ 2.32057657e-17,  1.34144430e-17, -1.25044647e-02, ...,
-2.68050363e-02,  1.71053614e-18, -4.39000556e-17],
[-8.84029921e-17, -6.73292146e-17,  1.02704171e-02, ...,
1.60052076e-02,  1.07757677e-18,  7.70047505e-17],
[ 1.39133141e-17, -9.98893495e-17,  1.41802681e+00, ...,
-1.25562022e-01, -8.88889602e-17, -1.02861495e-17],
[ 4.45574189e-03, -1.11762802e-04, -3.42445837e-16, ...,
-2.38046403e-16,  5.73656461e-03,  9.55766799e-04],
[-6.20845224e-04,  1.55725811e-05,  6.67430243e-17, ...,
6.27926127e-17, -7.99309931e-04, -1.33172717e-04]],

...,

[[ 1.14199267e-17,  7.48984986e-18, -1.01253886e-02, ...,
-2.66715970e-02, -6.42770021e-18, -7.18892160e-17],
[-2.54479702e-17, -1.66368347e-17,  1.37344572e-02, ...,
4.40198712e-02, -4.92690958e-18,  1.34478914e-17],
[ 3.35324507e-17, -3.94572513e-17, -1.25562022e-01, ...,
6.59519507e+00, -1.26641103e-16,  2.36026923e-16],
[-1.44929563e-03,  2.69522248e-03, -8.13496236e-17, ...,
-1.06114358e-16,  3.33108195e-04, -6.58471582e-03],
[ 2.67824552e-04, -4.98067295e-04,  3.18508566e-17, ...,
7.22678661e-17, -6.15571808e-05,  1.21683149e-03]],

[[-1.63499987e-02, -1.53972648e-02, -5.33239060e-17, ...,
-5.84272882e-17, -2.76086222e-02,  8.88532442e-02],
[ 3.96865233e-02,  3.35308950e-02,  1.17888453e-17, ...,
2.43777713e-17,  5.39443678e-02, -3.48847080e-02],
[ 4.30784404e-03,  6.09524778e-03, -8.88889602e-17, ...,
-1.26641103e-16,  6.86839820e+00,  9.62470577e-03],
[-1.96578472e-18,  2.88324223e-17,  1.11512001e-01, ...,
1.39832846e-01,  1.07534704e-16,  1.12056604e-16],
[-5.05176956e-19, -7.31259464e-18, -1.55376354e-02, ...,
-2.58406006e-02,  9.49891379e-18, -3.17451065e-18]],

[[-8.27876810e-03, -9.58464325e-03,  6.85749494e-18, ...,
1.20879344e-17, -2.51608621e-02,  1.82547204e-03],
[ 3.40996999e-03,  1.71042301e-03,  1.41476791e-17, ...,
-3.22449155e-17,  2.97677086e-02,  5.40926289e-02],
[ 3.77835830e-03,  5.44665749e-03, -1.02861495e-17, ...,
2.36026923e-16,  9.62470577e-03,  6.83443677e+01],
[-1.54075432e-18, -7.77028709e-19,  1.15440493e-02, ...,
1.23731435e-02,  1.50073155e-17,  3.67158060e-17],
[-1.15520124e-18, -2.38172811e-18, -1.60850158e-03, ...,
-2.28651184e-03,  3.47233490e-18,  8.34355852e-17]]],

[[[-1.53313386e-17, -5.04372963e-18,  3.07973972e-03, ...,
1.85007711e-02, -2.83982709e-18, -1.55201670e-17],
[ 6.65558163e-18,  7.69442487e-18, -9.07439459e-03, ...,
8.01692312e-03,  1.32749938e-17,  1.12904045e-18],
[ 6.84680539e-18,  3.51011460e-17,  4.45574189e-03, ...,
-1.44929563e-03, -1.96578472e-18, -1.54075432e-18],
[ 4.60301317e-01, -8.14036526e-02,  1.78095753e-16, ...,
4.77920265e-17, -2.55815025e-02,  2.91869574e-03],
[ 7.69357549e-17,  3.95568941e-17, -9.16038717e-18, ...,
-3.68031176e-18,  1.34909040e-17, -1.54482510e-18]],

[[-1.21786734e-17, -2.65822744e-17,  8.05746451e-03, ...,
1.99998116e-02, -2.29817728e-17, -2.92650713e-18],
[ 1.34296339e-17,  2.62887641e-19,  1.43740515e-02, ...,
-9.04851396e-03,  2.60329833e-17, -1.27254220e-17],
[ 3.32719551e-17,  5.98611131e-17, -1.11762802e-04, ...,
2.69522248e-03,  2.88324223e-17, -7.77028709e-19],
[-8.14036526e-02,  7.71163480e-01,  1.21861621e-16, ...,
3.49655673e-17, -5.06584131e-02,  6.40882246e-03],
[ 2.85414463e-17,  1.32604673e-16, -7.54993775e-18, ...,
-1.71380598e-17,  3.86065675e-17,  5.28608203e-19]],

[[-1.17585782e-02, -5.55759927e-03, -1.11839463e-16, ...,
-6.27379629e-17,  2.20942868e-03,  2.83491517e-02],
[ 4.80030137e-02,  5.29991463e-02,  2.27439404e-17, ...,
3.77793961e-17,  8.84724119e-03, -4.30316058e-02],
[ 7.33231010e-02,  1.03744415e-01, -3.42445837e-16, ...,
-8.13496236e-17,  1.11512001e-01,  1.15440493e-02],
[ 1.78095753e-16,  1.21861621e-16,  1.47986648e+00, ...,
-9.88879943e-04,  2.62220010e-16,  1.27034545e-16],
[-1.10886189e-17, -2.68748156e-17, -2.94424850e-02, ...,
-2.65470468e-02, -5.64843710e-17,  1.08869356e-17]],

...,

[[-1.43825277e-02, -9.44432054e-03, -9.51809153e-17, ...,
-1.46358495e-16,  3.56382552e-03,  1.03861543e-01],
[ 4.60463491e-02,  2.85696738e-02,  4.25652937e-17, ...,
7.52233837e-17,  1.52561546e-02, -4.53776133e-02],
[ 3.36192439e-02,  6.09961875e-02, -2.38046403e-16, ...,
-1.06114358e-16,  1.39832846e-01,  1.23731435e-02],
[ 4.77920265e-17,  3.49655673e-17, -9.88879943e-04, ...,
6.57132771e+00,  9.11115149e-17,  4.00803440e-16],
[-4.57024983e-18, -1.95414769e-17, -2.05300777e-02, ...,
-3.10520949e-02, -5.30893022e-17,  2.67644214e-19]],

[[-2.26920292e-17, -2.60031530e-17,  1.59090454e-04, ...,
1.95846665e-04, -1.08377845e-16,  8.12772173e-17],
[ 4.02892829e-17,  2.80316603e-17,  1.36933468e-03, ...,
1.35174553e-03,  5.91020123e-17, -3.74021590e-17],
[ 3.13760901e-17,  6.10726210e-17,  5.73656461e-03, ...,
3.33108195e-04,  1.07534704e-16,  1.50073155e-17],
[-2.55815025e-02, -5.06584131e-02,  2.62220010e-16, ...,
9.11115149e-17,  6.56828103e+00, -5.35839140e-04],
[ 1.28679373e-17,  4.17923336e-17, -1.71985296e-17, ...,
-2.59620518e-17,  2.73187335e-16,  5.15672840e-19]],

[[-3.12834270e-17, -2.52199046e-17, -1.52071873e-02, ...,
-3.08303159e-02, -2.49025578e-17,  3.16651901e-16],
[ 3.66728694e-17,  2.49191624e-17, -4.73928990e-03, ...,
2.84855602e-02,  3.25611936e-17, -5.06419642e-17],
[ 3.21225801e-17,  5.14665331e-17,  9.55766799e-04, ...,
-6.58471582e-03,  1.12056604e-16,  3.67158060e-17],
[ 2.91869574e-03,  6.40882246e-03,  1.27034545e-16, ...,
4.00803440e-16, -5.35839140e-04,  6.80976592e+01],
[ 2.51073576e-20, -6.49867240e-18, -1.34571841e-17, ...,
-1.27197531e-17, -1.58327480e-18,  3.08637653e-16]]],

[[[ 4.52641078e-17,  1.91883698e-17, -4.29118594e-04, ...,
-3.41887510e-03,  1.38145177e-17, -2.27258802e-18],
[-4.57741656e-18, -3.59978088e-18,  1.26438979e-03, ...,
-1.48149818e-03, -3.02944995e-18,  3.82585897e-19],
[ 5.34778447e-18,  6.91639776e-18, -6.20845224e-04, ...,
2.67824552e-04, -5.05176956e-19, -1.15520124e-18],
[ 1.00578809e-16,  2.58339687e-18, -1.10886189e-17, ...,
-4.57024983e-18,  5.20359913e-18,  4.17752327e-18],
[ 4.60301317e-01, -8.14036526e-02,  1.37279292e-16, ...,
4.15740027e-17, -2.55815025e-02,  2.91869574e-03]],

[[ 2.05773995e-17,  6.69254025e-17, -1.12269482e-03, ...,
-3.69589233e-03,  3.29116066e-17, -5.28719242e-18],
[-9.69989436e-18, -9.52942963e-18, -2.00282275e-03, ...,
1.67213241e-03, -6.65286767e-18,  4.14226871e-18],
[-2.74096172e-18, -1.03426735e-18,  1.55725811e-05, ...,
-4.98067295e-04, -7.31259464e-18, -2.38172811e-18],
[ 6.23078709e-18,  1.77609190e-16, -2.68748156e-17, ...,
-1.95414769e-17,  2.65795987e-17, -7.30736039e-18],
[-8.14036526e-02,  7.71163480e-01,  4.81915926e-17, ...,
-2.25751979e-17, -5.06584131e-02,  6.40882246e-03]],

[[ 1.63839318e-03,  7.74373617e-04,  1.19373172e-16, ...,
8.57034652e-17, -3.07852940e-04, -3.95005722e-03],
[-6.68854761e-03, -7.38468872e-03, -8.68165242e-18, ...,
-2.16513251e-17, -1.23273914e-03,  5.99585156e-03],
[-1.02165471e-02, -1.44553312e-02,  6.67430243e-17, ...,
3.18508566e-17, -1.55376354e-02, -1.60850158e-03],
[-9.16038717e-18, -7.54993775e-18, -2.94424850e-02, ...,
-2.05300777e-02, -1.71985296e-17, -1.34571841e-17],
[ 1.37279292e-16,  4.81915926e-17,  1.27266321e+00, ...,
-1.42489553e-01,  1.37493221e-16,  1.07264061e-17]],

...,

[[ 2.65783872e-03,  1.74527603e-03,  7.41740010e-17, ...,
2.29138501e-16, -6.58581972e-04, -1.91932348e-02],
[-8.50919755e-03, -5.27957162e-03, -2.70587404e-17, ...,
-3.95632533e-17, -2.81928179e-03,  8.38561761e-03],
[-6.21271380e-03, -1.12718732e-02,  6.27926127e-17, ...,
7.22678661e-17, -2.58406006e-02, -2.28651184e-03],
[-3.68031176e-18, -1.71380598e-17, -2.65470468e-02, ...,
-3.10520949e-02, -2.59620518e-17, -1.27197531e-17],
[ 4.15740027e-17, -2.25751979e-17, -1.42489553e-01, ...,
6.40903189e+00, -3.51206002e-17,  2.60883987e-16]],

[[ 2.02358655e-17,  3.11500512e-17, -2.21670265e-05, ...,
-3.61917502e-05,  2.14013831e-16, -3.46312768e-17],
[-2.57769958e-17, -2.31599852e-17, -1.90797609e-04, ...,
-2.49797649e-04, -4.17740399e-17,  1.55155698e-17],
[-1.27902235e-17, -1.55470256e-17, -7.99309931e-04, ...,
-6.15571808e-05,  9.49891379e-18,  3.47233490e-18],
[ 3.94605342e-18,  2.33604087e-17, -5.64843710e-17, ...,
-5.30893022e-17,  2.56636736e-16, -2.78181454e-18],
[-2.55815025e-02, -5.06584131e-02,  1.37493221e-16, ...,
-3.51206002e-17,  6.56828103e+00, -5.35839140e-04]],

[[ 7.37224457e-19,  9.65125128e-19,  2.11890856e-03, ...,
5.69733006e-03,  1.62670658e-18,  4.02013294e-16],
[ 2.64951838e-18,  1.32364578e-18,  6.60353668e-04, ...,
-5.26402774e-03, -5.40082544e-18, -3.41171246e-17],
[ 4.73676722e-18,  1.09268624e-17, -1.33172717e-04, ...,
1.21683149e-03, -3.17451065e-18,  8.34355852e-17],
[ 2.66720636e-18, -3.05203045e-18,  1.08869356e-17, ...,
2.67644214e-19, -1.66373105e-18,  1.97142740e-16],
[ 2.91869574e-03,  6.40882246e-03,  1.07264061e-17, ...,
2.60883987e-16, -5.35839140e-04,  6.80976592e+01]]]])


# If you want only A and not B

Since you're doing the TDA approximation instead of a full TD-DFT calculation, you are probably trying to save RAM or CPU time by not using the $$B$$ matrix, so you might not want to calculate it at all. Hopefully there is a better way to do this, but based on looking at the get_ab function in PySCF's tdscf/uhf.py, one way that I can see to avoiding calculating the $$B$$ matrix is to remove or comment all lines leading to the obtaining of the b output. For I would remove the last line, and all lines related to b_aa, b_ab, or b_bb out of the following lines:

    a_aa = numpy.diag(e_ia_a.ravel()).reshape(nocc_a,nvir_a,nocc_a,nvir_a)
a_bb = numpy.diag(e_ia_b.ravel()).reshape(nocc_b,nvir_b,nocc_b,nvir_b)
a_ab = numpy.zeros((nocc_a,nvir_a,nocc_b,nvir_b))
b_aa = numpy.zeros_like(a_aa)
b_ab = numpy.zeros_like(a_ab)
b_bb = numpy.zeros_like(a_bb)
a = (a_aa, a_ab, a_bb)
b = (b_aa, b_ab, b_bb)

• How can I confirm the correctness of this A-matrix? I attempted to utilize the A-matrix computed using the sto3g method within the AQAE script (github.com/randylewis/QuantumAnnealing/blob/main/AQAE.py). It resulted in a minimum eigenvalue of value=0.5, which significantly contrasts with the output from the following script: import pyscf mol = pyscf.M(atom = ‘H 0 0 0.917; F 0 0 0', basis = 'sto3g', symmetry = True,); myhf = mol.RHF().run(); cisolver = pyscf.fci.FCI(myhf); print('E(FCI) = %.12f' % cisolver.kernel()[0]); Jan 5 at 10:37
• @HadeelMoustafa please post a new question, so that you can get an answer from someone else if I am unavailable. I'm driving to Hamilton then Mississauaga today. Jan 5 at 13:24