In some instances, the generated energy expression is not Hermitian. I tracked this down to cofactor returning zero determinantal overlap between Slater determinants a and b, but non-zero for the conjugate case b and a:
using EnergyExpressions
import EnergyExpressions: nonzero_minors, cofactor
using Combinatorics
function test_case(N,nn)
orbitals = 1:N
excite = i -> i+100
virtuals = map(excite, orbitals)
configurations = [SlaterDeterminant(vcat(1:i-1,excite(i),i+1:N))
for i=1:N]
overlaps = map(((a,b),) -> OrbitalOverlap(a,b),
reduce(vcat, [collect(combinations(virtuals,2)),
[[a,a] for a in virtuals]]))
for (i,j) = [(N-nn,N),(N,N-nn)]
println(repeat("-", 100))
a = configurations[i]
b = configurations[j]
S = overlap_matrix(a, b, overlaps)
@info "Overlap matrix" S
ks,ls = nonzero_minors(1, S)
for (k,l) in zip(ks,ls)
@show k,l
Dkl = cofactor(k, l, S)
@show Dkl
end
end
end
In some instances, the generated energy expression is not Hermitian. I tracked this down to
cofactor
returning zero determinantal overlap between Slater determinantsa
andb
, but non-zero for the conjugate caseb
anda
:E.g. this example fails:
whereas this very similar case works as expected: