Skip to content

fix: read converged overlap matrix for SC groups #1

Open
laraujo-1 wants to merge 1 commit into
davidsousarj:mainfrom
laraujo-1:fix/overlap-matrix
Open

fix: read converged overlap matrix for SC groups #1
laraujo-1 wants to merge 1 commit into
davidsousarj:mainfrom
laraujo-1:fix/overlap-matrix

Conversation

@laraujo-1
Copy link
Copy Markdown

What was happening

I was getting a persistent problem where the interference density plots were showing only positive values for the π-space of aromatic systems, which is physically nonsense. I tested this with a simple SC(6) calculation for benzene (no guess) and confirmed the issue: plotting the π interference density at 0.3 Å above the molecular plane gave an entirely positive map.

What I found

The bug is in parse_overlaps. It turns out that for SC/GVB groups, VB2000 prints the overlap matrix twice in the output file, once before the orbital optimization starts (the initial LMO overlaps) and then after convergence (the final SC overlaps). The code was always grabbing the first one.

The problem is that the density matrix in the .dmatrix file is computed from the converged orbitals, so using the pre-optimization overlaps breaks the QC/INT density partition. The initial overlaps are all positive, which is why the interference density was coming out wrong.

Proposed fix

Two small changes:

core/parse_input.py — added support for pos=-1 in getLine to retrieve the
last occurrence of a string instead of the first:

def getLine(source, string, pos=0, none=True, comments=True):
    if pos == -1:
        result = None
        for index in range(len(source)):
            if string in source[index]:
                if comments and source[index][0] == "#":
                    continue
                result = index
        if result is not None:
            return result
    else:
        # original logic unchanged
        ...

core/parse_vb.py: added one extra argument to always read the converged matrix:

line = getLine(jobtext,
               "OVERLAP MATRIX OF VB ORBITALS FOR GROUP  {0:2d}".format(i+1), pos=-1) + 5

Refactor getLine function to handle last occurrence search.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant