Problem with geometry optimization while using constrained DFT

Hi there,

I’m running into issues using Q-CHEM v5.4 to optimize the locations of the protons on hydronium ion above a carbon flake adsorbed metalloporphyrin (203 atoms) while using constrained DFT to enforce charge localization on the graphitic flake. I’m freezing all of the atoms except for the protons on the hydronium ion in the optimization. The first SCF cycle seems to finish fine and the coordinates get updated, but then the this error is printed:

" Q-Chem fatal error occurred in module libmdc/newfileman.C, line 384:

FileMan error: End of file reached prematurely reading (6930168) bytes in file FILE_SPARSE_DENSITY_MATRIX"

This only seems to happen on a handful of jobs, but the inputs only differ in the coordinates of the atoms and not the REM variables. I have put a sample input below without the atomic coordinates to save space (I can provide those if needed). Any advice will be very helpful. Thank you.

$rem
JOBTYPE = OPT
ECP = General
BASIS = General
METHOD = BP86
DFT_D = D3
SCF_Guess = AUTOSAD
SCF_ALGORITHM = RCA_DIIS
MAX_SCF_CYCLES = 1000
THRESH = 14
SCF_CONVERGENCE = 8
CDFT = TRUE
CDFT_THRESH = 8
BECKE_SHIFT = UNSHIFTED
SYM_IGNORE = TRUE
SYMMETRY = FALSE
$end

$cdft
1.0
1.0 79 200
$end

$basis

N 0

6-31g(d,p)


C 0

6-31g(d,p)


O 0

6-31g(d,p)


Co 0

lanl2dz


H 0

6-31g(d,p)


$end

$ecp

Co 0

fit-lanl2dz


$end

Do you get any warnings about linear dependencies or about the number of linearly-independent orbitals? I can imagine a scenario in that case…

(Unrelated: please use the preformatted text button </> to paste inputs/outputs. Otherwise some characters get dropped, which makes it hard to copy/paste your input, or you get a bunch of markup due to special characters.)

Hi there,

Thanks for the quick response. I don’t see any warnings about linear dependencies, only an expected warning about the constrained geometry optimization not being able to use internal coordinates. I can share my output file or specific portions of it if that will help diagnose the problem.

Hmm, okay, that was a guess. In a small example that I cooked up for this purpose, you would see something like the following:

 Linear dependence detected in AO basis
 Tighter screening thresholds may be required for diffuse basis sets
 Use S2THRESH > 12 and THRESH = 14 in case of SCF convergence issues
 Number of orthogonalized atomic orbitals = 48

whereas a few lines above, Q-Chem had told you there were 49 basis functions:

 There are 25 shells and 49 basis functions

This is because this example has one numerical (below threshold) linear dependence. This example is small but with an extremely diffuse basis set, but another scenario for linear dependencies is large molecules (even if the basis set isn’t diffuse). If the number of basis functions changes along the optimization, it might give you a problem like this and the solution would be to (a) increase THRESH, which often leads to faster convergence anyway (I think the default is too loose, prefer THRESH=12) ,or (b) increase BASIS_LIN_DEP_THRESH (default is 6) to keep those linear dependencies from being removed.

This may not be the problem, though, it is a guess.

Okay, I’ll try working with BASIS_LIN_DEP_THRESH and see what happens. Thank you for the advice.

Interestingly, I’m still not getting linear dependencies in the outputs and I’m getting a few geometry optimization steps in before QCHEM stops with the same error message. I’ve been setting BASIS_LIN_DEP_THRESH = 9. I’m getting the same behavior when I run a standard DFT calculation on the metalloporrphyrin without the graphitic surface or charge constraints, which leads me to believe that the cDFT protocol is not the issue. I have provided that sample input below.

$comment
CoTPP w H3O
$end

$molecule
1 2
N 0.4519020175 1.5178454465 2.2645739761
N -2.6345629840 -0.8498759077 1.7918282036
N -2.2655044154 1.8949260440 1.8340475692
N 0.1152431359 -1.2100956814 1.8877243088
C 0.4281092678 2.9009635872 2.4908732146
C 1.7766226178 1.1354332272 2.5215605046
C -3.9876873022 -0.4864203128 1.8489325846
C -2.6361429222 -2.2427498028 1.8902448546
C -0.6532933922 3.7447948772 2.2228976446
C 2.3227760578 -0.1284777528 2.2668463346
C -4.4921243822 0.8055571572 1.6637635346
C -1.5197431222 -3.0709509328 1.7381746946
C -1.8923480322 3.2420219172 1.8197597246
C 1.5213213078 -1.2059787928 1.8736191646
C -3.6399115922 1.9108893972 1.5719936146
C -0.2277442522 -2.5448162228 1.6428455246
C 1.6892282278 3.3429046672 3.0190753746
C 2.5205762378 2.2513354472 3.0418024046
C -4.8053385622 -1.6446270628 2.1074897646
C -3.9697976422 -2.7304831628 2.1362110046
C -0.5209356522 5.1994716072 2.4749980646
C 3.7718434278 -0.3550549728 2.4958015846
C -5.9579105322 1.0260134472 1.6404293346
C -1.6901591522 -4.5436573828 1.7882450146
C -3.0077962622 4.0790017972 1.4563084446
C 2.0301339178 -2.5162721028 1.5458359546
C -4.0905329422 3.2561086072 1.3047185646
C 0.9494617978 -3.3458009228 1.4077461546
C -1.4472664622 5.8425328872 3.3246524846
C 4.7481848978 0.5207300872 1.9769158346
C 0.5279935478 5.9540130472 1.9153497446
C 4.2009671878 -1.4463776728 3.2826233846
C -6.8119090822 0.2425207072 0.8363398146
C -0.9325080822 -5.2961036428 2.7118952646
C -6.5285941422 2.0254543672 2.4587973946
C -2.6164996722 -5.2167744528 0.9682296046
C -1.3238873322 7.2058087972 3.6148771546
C 6.1116833978 0.2886930072 2.1993089346
C 0.6469480978 7.3204198172 2.1995996346
C 5.5620338578 -1.6720723528 3.5175707246
C -8.1928845922 0.4749786472 0.8274557446
C -1.0847226122 -6.6838619128 2.8057871446
C -7.9083133322 2.2544260872 2.4542868446
C -2.7623027622 -6.6075922428 1.0561547946
C -0.2744976622 7.9497802072 3.0519384246
C 6.5247738778 -0.8129116028 2.9633798946
C -8.7449026322 1.4848505672 1.6295903746
C -1.9969905722 -7.3472172828 1.9715366546
H 1.8989481278 4.3605507672 3.3358039546
H 3.5482958178 2.1981373372 3.3876438846
H -5.8789957822 -1.6120980828 2.2647024846
H -4.2195962822 -3.7715637828 2.3207552346
H -2.9426245022 5.1532637572 1.3086175946
H 3.0836899378 -2.7576946628 1.4329375346
H -5.1066130622 3.5218049172 1.0238782146
H 0.9357738678 -4.4040170828 1.1591640746
H -2.2624196822 5.2534323572 3.7565451246
H 4.4322851678 1.3800830972 1.3816798346
H 1.2374004078 5.4683693972 1.2424059346
H 3.4478100278 -2.1069095428 3.7231275846
H -6.3825199322 -0.5364924728 0.2037762346
H -0.2294727922 -4.7724855528 3.3686491646
H -5.8699570822 2.6098813572 3.1072292846
H -3.2190747122 -4.6480732228 0.2566534846
H -2.0386207122 7.6824493072 4.2941982346
H 6.8514761578 0.9711077172 1.7676248546
H 1.4606228278 7.8934692072 1.7423014146
H 5.8670885578 -2.5112156728 4.1527431946
H -8.8383059222 -0.1309011728 0.1843432846
H -0.5021762322 -7.2418787428 3.5464822246
H -8.3304715722 3.0219607672 3.1118336646
H -3.4774992122 -7.1131545128 0.3977518646
H -0.1763007722 9.0162593872 3.2779840546
H 7.5891256778 -0.9950811528 3.1383894246
H -9.8245473222 1.6638316072 1.6237976546
H -2.1173961722 -8.4322273828 2.0421259446
Co -1.0818084014 0.3403084153 1.8658673704
O -1.1786571184 0.3377660690 4.6725617767
H -0.6211339144 -0.4615118462 4.4594790140
H -2.0732477855 0.1135720822 4.2803413359
H -0.8202912172 1.0124517828 3.9494318931
$end

$rem
 JOBTYPE = OPT
 ECP = General
 BASIS = General
 METHOD = BP86
 DFT_D = D3
 SCF_Guess = AUTOSAD
 SCF_ALGORITHM = RCA_DIIS
 MAX_SCF_CYCLES = 4000
 SYMMETRY = FALSE
 SYMMETRY_IGNORE = 1
 THRESH = 14
 S2THRESH = 14
 SCF_CONVERGENCE = 8
 GEOM_OPT_MAX_CYCLES = 150
 BASIS_LIN_DEP_THRESH = 9
$end

$opt
FIXED
5   XYZ
6   XYZ
7   XYZ
8   XYZ
9   XYZ
10   XYZ
11   XYZ
12   XYZ
13   XYZ
14   XYZ
15   XYZ
16   XYZ
17   XYZ
18   XYZ
19   XYZ
20   XYZ
21   XYZ
22   XYZ
23   XYZ
24   XYZ
25   XYZ
26   XYZ
27   XYZ
28   XYZ
29   XYZ
30   XYZ
31   XYZ
32   XYZ
33   XYZ
34   XYZ
35   XYZ
36   XYZ
37   XYZ
38   XYZ
39   XYZ
40   XYZ
41   XYZ
42   XYZ
43   XYZ
44   XYZ
45   XYZ
46   XYZ
47   XYZ
48   XYZ
49   XYZ
50   XYZ
51   XYZ
52   XYZ
53   XYZ
54   XYZ
55   XYZ
56   XYZ
57   XYZ
58   XYZ
59   XYZ
60   XYZ
61   XYZ
62   XYZ
63   XYZ
64   XYZ
65   XYZ
66   XYZ
67   XYZ
68   XYZ
69   XYZ
70   XYZ
71   XYZ
72   XYZ
73   XYZ
74   XYZ
75   XYZ
76   XYZ
ENDFIXED
$end

$ecp
 Co 0
 fit-lanl2dz
 ****
$end 

$basis
 N 0
 6-31g(d,p)
 ****
 C 0
 6-31g(d,p)
 ****
 H 0
 6-31g(d,p)
 ****
 O 0
 6-31g(d,p)
 ****
 Co 0
 lanl2dz
 ****
$end

Using that input file, I can reproduce the crash and the error message after 3 optimization steps, using the latest trunk version of Q-Chem. I will investigate a little further and submit a bug ticket if I can’t figure out the reason.

Update: forget about BASIS_LIN_DEP_THRESH, this is not a linear dependency issue.

The proximate reason that Q-Chem is failing is because the number of function pairs is changing (you can see this by searching for “function pairs”). Q-Chem crashes when the number of function pairs is larger than it was at the previous geometry, so it’s trying to read more density matrix data than were written at the previous geometry.

I’m not sure why Q-Chem doesn’t catch this (I will submit a bug report), though it appears to be related to the use of constraints because when I remove the constraints, the optimization makes it through more steps (still running).

The workaround is to set SCF_GUESS_ALWAYS = TRUE in $rem. That will force Q-Chem to generate a new SCF guess at each geometry, rather than read it in from the previous step.

Ok great! I figured it was a problem with the geometry constraints given all of the different modifications I had tried, but it’s good to know that there is a workaround. Thank you for all of the help!