Bug #332

Can not invert matrix, determinant =

Added by Igor Leontyev about 11 years ago. Updated about 11 years ago.

Erik Lindahl
Target version:
Affected version - extra info:
Affected version:


The error appears each time when I am trying to minimize structure
protein+internal+external solvent). The initial structure is far away
from the minimum (there are some large forces), but it should not be a
problem, isn't it? I am able to do minimization of the same system by
gmx3.3.1 version but gmx4.0.4 fails in both domain and particle decomposition mode. Below is the error message for particle decomposition mode (-pd) :

Reading file CcO_4hcav_3Dch_E242side_OH-_O2-_PM.tpr, VERSION 4.0.4
Steepest Descents:
Tolerance (Fmax) = 1.00000e+01
Number of steps = 1000

Program mdrun, VERSION 4.0.4
Source code file: ../../include/vec.h, line: 706

Fatal error:
Can not invert matrix, determinant = (987 KB) output and tpr-file Igor Leontyev, 05/28/2009 09:59 AM
csettle.c (15.3 KB) csettle.c fixed src/mdlib/csettle.c Berk Hess, 05/28/2009 11:11 AM
minimize.c (82.9 KB) minimize.c fixed src/mdlib/minimize.c Berk Hess, 05/29/2009 02:40 PM

Related issues

Has duplicate GROMACS - Bug #331: Minimization error "Can not invert matrix, determinant ="Closed05/28/2009


#1 Updated by Igor Leontyev about 11 years ago

Created an attachment (id=378)
output and tpr-file

#2 Updated by Berk Hess about 11 years ago

The problem was caused by frozen water molecules,
for which I set the inverse mass to 1e-30.
This is only a problem with energy minimization.
I have fixed it for 4.0.6 and 4.1.
I will attach the corrected csettle.c.


#3 Updated by Berk Hess about 11 years ago

Created an attachment (id=379)
fixed src/mdlib/csettle.c

#5 Updated by Igor Leontyev about 11 years ago

Guys, the minimization with corrected "csettle.c" seems to be running now, but output configuration as well as all intermediate configurations are the same as the initial configuration. The goal of the minimization is the final structure, isn't it?

#6 Updated by Erik Lindahl about 11 years ago

"invalid" means the bug report would be incorrect, so I've reopened it for you until Berk has a chance to comment. However, of you have frozen water molecules it seems quite reasonable that they shouldn't move ;-)

#7 Updated by Berk Hess about 11 years ago

You froze the whole system, except for 166 atoms.
So only those 166 atoms will move, and these will move
very little, since they still interact with the rest
of the system which is completely frozen.


#8 Updated by Igor Leontyev about 11 years ago

The system is quite complex and its dynamics depends on the quilaity of the minimized structure due to long relaxation time. The minimization should be done in few steps. On the first minimization step there are only few residues allowed to optimize positions. This step, however, results to a significant energy change. The output obtained with corrected "csettle.c" is given bellow. The energy change in -8e+07 Kj/mol should lead to a shift of the released atoms at least 1A. However, all atoms of the initial and final structures as well as all intermediate steps are identical.

Step           Time         Lambda
0 0.00000 0.00000
Step           Time         Lambda
1 1.00000 0.00000
Energies (kJ/mol)
Bond Angle Proper Dih. Ryckaert-Bell. LJ-14
1.35230e+04 1.86168e+04 2.17942e+02 2.76666e+04 1.61981e+04
Coulomb-14 LJ (SR) Coulomb (SR) Position Rest. Potential
1.45153e+05 7.91281e+07 -6.45074e+05 7.98086e+00 7.87044e+07
Pressure (bar) Cons. rmsd ()
5.88856e+33 1.89108e-06


Steepest Descents converged to machine precision in 32 steps,
but did not reach the requested Fmax < 10.
Potential Energy = -2.8848306e+05
Maximum force = 4.2317715e+03 on atom 1035
Norm of force = 3.2447533e+01

#9 Updated by Berk Hess about 11 years ago

I ran your simulation.
The energy indeed changes by 10^7.
But the input and output coordinates are NOT indentical.
Most of them are, since they are frozen.
But the few residues you leave free do move a bit.

Only one atom that lies on top of another can give an energy
change of 10^7 when it moves by even less than an Angstrom.


#10 Updated by Igor Leontyev about 11 years ago

In my simulation the initial and final configurations are identical for all atoms with a machine precision. Could be the reason for this contradiction between your and mine results that my binary was created recompiling just the "csettle.c" object file with untouched other object files?

#11 Updated by Berk Hess about 11 years ago

Ah, you are using 4.0.4.

I fixed a bug with energy minimization in serial (not parallel),
where are trajectory frames, except the last one would be identical
to the first one. I forgot to add this to the release notes.
You should upgrade to 4.0.5.

But the last frame and confout.gro should have the modified coordinates.


#12 Updated by Igor Leontyev about 11 years ago

I used gmx 4.0.5 (parallel on 4 cpu) for this calculation.

#13 Updated by Berk Hess about 11 years ago

Ah, I introduced a new bug in 4.0.5, which makes all energy minimization
output coordinates zero with particles decomposition.
I assume you use particle decomposition, since your system crashes
with domain decomposition.
Not running in parallel should work fine.
Or use my attached minimize.c.


#14 Updated by Berk Hess about 11 years ago

Created an attachment (id=380)
fixed src/mdlib/minimize.c

Also available in: Atom PDF