ExpHP / rsp2

phonons in rust
Apache License 2.0
2 stars 1 forks source link

metastable (?) states do occur, and trip up Hager's linesearch #61

Closed ExpHP closed 5 years ago

ExpHP commented 6 years ago

067-b used to converge prior to me removing the 100 step CG_DESCENT limit; now it gets perpetually stuck with two imaginary frequencies at -2.1480 wavenumber.

Removing the limit only makes it run 106 steps initially; just 6 more than before. But debug output shows that when it chases those eigenvectors during the first steepest descent step, it finds a positive slope at alpha = ~1e-11, cutting off all larger values:

[ 114.081s][TRACE] Chasing 2 bad eigenvectors...
[ 114.195s][TRACE]  i:      0  v: -1987.17452262468805 dv:  +0.00e0  g: 2.4402943e-16                            22222222222222222222 2
[ 114.195s][DEBUG] Using steepest descent. (i: 1)
[ 114.365s][TRACE] LS: i:  1 (INI)  a: 1e-2                     s: +1.410643476859524e-7    v: -1987.1745226251464    
[ 114.448s][TRACE] LS: i:  3 (DS1)  a: 2.5394646157985182e-11   s: +1.0544941957351688e-15  v: -1987.1745226246871    
[ 114.531s][TRACE] LS: i:  4 (DS2)  a: -4.9358061966929465e-11  s: -1.969940852477739e-15   v: -1987.1745226246871    
[ 114.531s][DEBUG] update_interval: Exit by strange guess (U0),  (0e0, 2.5394646157985182e-11) vs -4.9358061966929465e-11
[ 114.616s][TRACE] LS: i:  6 (DS1)  a: 6.439391851190394e-12    s: +4.014716827720627e-16   v: -1987.1745226246874
...

whereas when it stops and diagonalizes on the 100th step, it finds an ever-so-ridiculously-slightly negative slope at alpha = 3e-13, and after a bisection locates a reasonably large negative force at alpha = 0.005.

[ 110.221s][TRACE] Chasing 2 bad eigenvectors...
[ 110.328s][TRACE]  i:      0  v: -1987.17452262468896 dv:  +0.00e0  g: 3.9219420e-16                            11111111112222222222 1
[ 110.328s][DEBUG] Using steepest descent. (i: 1)
[ 110.496s][TRACE] LS: i:  1 (INI)  a: 1e-2                     s: +1.248187846026306e-7    v: -1987.1745226253072    
[ 110.579s][TRACE] LS: i:  3 (DS1)  a: 3.0150402843128753e-13   s: -5.404398511693435e-17   v: -1987.1745226246892    
[ 110.661s][TRACE] LS: i:  4 (DS2)  a: -2.2566557733712302e-14  s: -4.4219671319259804e-17  v: -1987.1745226246894    
[ 110.661s][DEBUG] update_interval: Exit by strange guess (U0),  (3.0150402843128753e-13, 1e-2) vs -2.2566557733712302e-14
[ 110.741s][TRACE] LS: i:  5 (BSC)  a: 5.000000000150752e-3     s: -7.122244044879356e-8    v: -1987.1745226254409    
[ 110.823s][TRACE] LS: i:  7 (DS1)  a: 6.816516919690599e-3     s: -4.7170763492749486e-12  v: -1987.1745226255068    
[ 110.906s][TRACE] LS: i:  8 (DS2)  a: 6.816637235934835e-3     s: +6.406532141458349e-16   v: -1987.1745226255052    
[ 110.989s][TRACE] LS: i: 10 (DS1)  a: 6.816637219596214e-3     s: -7.878945263189362e-16   v: -1987.1745226255048    
[ 111.069s][TRACE] LS: i: 11 (DS2)  a: 6.816637239693297e-3     s: +7.186359244746227e-16   v: -1987.1745226255055
...

(aside: The 11111111112222222222 and 22222222222222222222 indicate that the "steepest descent" directions in the projected subspace of bad eigenvectors is slightly different; I'm not sure whether these linesearches are dealing with curves of fundamentally different shapes.)

The greater point, however, is that the slope at alpha = 0 is almost zero, yet there is a reasonably large negative slope a short distance away. This breaks the double-secant strategy which seems to be too good at closing in on areas it has discovered with nearly-zero slope.

ExpHP commented 6 years ago

Funny. I thought a smaller starting alpha of 1e-4 would fix this specific case, but in fact it does just the opposite! Apparently there is a largeish positive slope at that distance, so the search interval never gets expanded in either case

106 steps, starting alpha 1e-4

[ 141.294s][TRACE] Chasing 2 bad eigenvectors...
[ 141.405s][TRACE]  i:      0  v: -1987.17452262468805 dv:  +0.00e0  g: 2.4402943e-16                            22222222222222222222 2
[ 141.405s][DEBUG] Using steepest descent. (i: 1)
[ 141.573s][TRACE] LS: i:  1 (INI)  a: 1e-4                     s: +3.920387585408192e-9    v: -1987.1745226246862    
[ 141.657s][TRACE] LS: i:  3 (DS1)  a: 9.137563056492585e-12    s: +6.006901568439117e-16   v: -1987.1745226246878    
[ 141.740s][TRACE] LS: i:  4 (DS2)  a: -6.184651416134867e-12   s: -5.381187993033064e-16   v: -1987.1745226246874    
[ 141.740s][DEBUG] update_interval: Exit by strange guess (U0),  (0e0, 9.137563056492585e-12) vs -6.184651416134867e-12

100 steps, starting alpha = 1e-4

[ 137.057s][TRACE] Chasing 2 bad eigenvectors...
[ 137.166s][TRACE]  i:      0  v: -1987.17452262468896 dv:  +0.00e0  g: 3.9219420e-16                            11111111112222222222 1
[ 137.166s][DEBUG] Using steepest descent. (i: 1)
[ 137.344s][TRACE] LS: i:  1 (INI)  a: 1e-4                     s: +3.920673867376733e-9    v: -1987.1745226246842    
[ 137.427s][TRACE] LS: i:  3 (DS1)  a: 9.598698494088662e-14    s: -1.3042333611264825e-16  v: -1987.174522624689     
[ 137.508s][TRACE] LS: i:  4 (DS2)  a: -2.8519764623749952e-15  s: -3.986232514784425e-16   v: -1987.174522624689     
[ 137.508s][DEBUG] update_interval: Exit by strange guess (U0),  (9.598698494088662e-14, 1e-4) vs -2.8519764623749952e-15
[ 137.591s][TRACE] LS: i:  5 (BSC)  a: 5.000000004799349e-5     s: +1.9603362150786906e-9   v: -1987.174522624685     
[ 137.673s][TRACE] LS: i:  7 (DS1)  a: 3.4225420500120907e-12   s: -4.072460883268955e-16   v: -1987.1745226246892    
[ 137.756s][TRACE] LS: i:  8 (DS2)  a: -1.4712989620365761e-12  s: -1.2806685814311028e-16  v: -1987.174522624689     

(note: the similar values of s=+3.92e-9 in both cases suggest that my earlier note about "different directions in projected subspace" is probably irrelevant, and that the linesearches are on similarly-shaped curves)

What on earth is this?! Is the energy curve along this line some kind of capital-N shape?

ExpHP commented 6 years ago

The energy curve from alpha = 0 to 1e-2:

631-a-energy

It is that tiny bump at the beginning that catches it.

Making stuff like this work for changes on the order of 1e-10 eV is a collosal waste of time, and only impacts the ultra-low frequency modes. (and who's to say those are even physical when the energy barrier is so small? This is Lennard Jones all over again...)