MRChemSoft / mrchem

MultiResolution Chemistry
GNU Lesser General Public License v3.0
27 stars 21 forks source link

bug in disjoin and adjoin when spin is not paired #461

Closed gitpeterwind closed 1 year ago

gitpeterwind commented 1 year ago

There was a big bug when running parallel jobs with unpaired electrons. When splitting the orbitalvector (or joining them) into alpha beta, the ownership was getting wrong, since ownership is determined by the rank in the vector. Now the orbital::adjoin and orbital::disjoin explicitly send the orbitals if needed.

stigrj commented 1 year ago

I added two small changes in driver.cpp:

  1. Removed the Phi.distribute() in scf::guess_energy() since the OrbitalVector should already be in a consistent state at this point.
  2. Moved diagonalize() below the calculation of the initial Fock matrix. The asymmetry wrt the localize() case is intentional: if localizing we want to do it before the Fock matrix is build (for efficiency); if diagonalizing we want to do it after the Fock matrix is available (no use in diagonalizing a zero matrix)