molpro / iterative-solver

MIT License
0 stars 3 forks source link

Machine-dependent drift to complex solutions #509

Open pjknowles opened 3 months ago

pjknowles commented 3 months ago

From https://www.molpro.net/bugzilla/show_bug.cgi?id=6445

Qianli Ma 2022-04-29 14:26:54 BST

In a simple multi calculation of water (attached) I encountered errors from LinearAlgebra:

terminate called after throwing an instance of 'std::runtime_error' what(): unexpected complex solution found

On two computers with almost identical software environment it always happened in one of them (11th gen Intel CPU) and never happened in the other (6th gen CPU). Both computers run latest Arch Linux, using gcc 11.2, eigen and MKL from the distro. I compile Molpro with "-O2 -march=native". The error does not show when compiling everything with -O0.

The calculation runs fine after commenting out the throw statement in LinearAlgebra/src/molpro/linalg/itsolv/helper-implementation.h. In this calculation (subspaceEigenvectors - subspaceEigenvectors.real()).norm() are big numbers (at least 2), and (subspaceEigenvalues - subspaceEigenvalues.real()).norm() are zero.

memory, 32, m

geometry={
O,, 0.000000,    0.000000,    0.465140
H,, 0.000000,    1.415022,    1.558516
H,, 0.000000,   -1.415022,    1.558516
}
basis=vdz
hf
{multi;occ,5,2,2,1;closed,2;wf,sym=1;state,2}

The calculation runs fine after removing "-march=native" from CPPFLAGS. So it is likely to be something related to compiler optimization.

pjknowles commented 3 months ago

Yes, notwithstanding the compiler issue, I already had it in mind to make the code robust to finding a complex eigenvalue - to just condone it, and hope that in the next iteration the space will be sufficiently complete that the eigensolution is once again real.