Geometry optimization

Basic usage

Optimizing a geometry means finding the geometry that minimizes the total energy for a given method.

Now, suppose you want to calculate the optimized geometry of the amino acid alanine for a given method. The first step is to have some kind of guess geometry. You can use Avogadro to draw its structure and run the simple optimizer to get a reasonable atom arrangement:

../_images/alanine.png

and with those coordinates, you can already set up your ORCA input!

Note

One can use Avogadro itself to make the input, save the molecule as a .xyz and read it (see Reading from external file), or add the coordinates directly to the Structure section of the input using the "xyz" flag.

If you want to optimize the geometry, for instance using DFT, all you have to do is to choose a functional and a basis set and add OPT to the main input:

!B3LYP DEF2-SVP OPT
* xyz 0 1
N         -0.83911        0.76325       -0.31843
C          0.61442        0.72014       -0.25075
C          1.01669       -0.56167        0.49740
O          0.20095       -1.36984        0.93753
H         -1.37884        0.05803        0.17605
H          1.00414        0.66192       -1.27362
C          1.17285        1.95192        0.45211
H          0.87124        2.87150       -0.05988
H          0.81191        2.01288        1.48492
H          2.26726        1.92903        0.48485
H         -1.30551        1.57618       -0.71069
O          2.33980       -0.77979        0.66176
H          3.04559       -0.08055        0.28096
*

If everything is right, you should first see on the output, after the main header:

                    *****************************
                    * Geometry Optimization Run *
                    *****************************

Geometry optimization settings:
Update method            Update   .... BFGS
Choice of coordinates    CoordSys .... Z-matrix Internals
Initial Hessian          InHess   .... Almoef's Model

Convergence Tolerances:
Energy Change            TolE     ....  5.0000e-06 Eh
Max. Gradient            TolMAXG  ....  3.0000e-04 Eh/bohr
RMS Gradient             TolRMSG  ....  1.0000e-04 Eh/bohr
Max. Displacement        TolMAXD  ....  4.0000e-03 bohr
RMS Displacement         TolRMSD  ....  2.0000e-03 bohr
Strict Convergence                ....  False
[...]

where some of the parameters for the optimization are written.

Then the SCF runs, followed by the calculation of a gradient and information related the current step is given:

                      .--------------------.
----------------------|Geometry convergence|-------------------------
Item                value                   Tolerance       Converged
---------------------------------------------------------------------
RMS gradient        0.0125516277            0.0001000000      NO
MAX gradient        0.0693728096            0.0003000000      NO
RMS step            0.0324468165            0.0020000000      NO
MAX step            0.1852949368            0.0040000000      NO
........................................................
Max(Bonds)      0.0981      Max(Angles)    4.19
Max(Dihed)        2.11      Max(Improp)    0.00
---------------------------------------------------------------------

Since the guess geometry was far from good, none of the criteria for convergence are achieved on the first step. The geometry is then modified according to the default algorithm (a quasi-Newton method) and you can see the changes in geometry next:

---------------------------------------------------------------------------
                     Redundant Internal Coordinates
                        (Angstroem and degrees)

    Definition                    Value    dE/dq     Step     New-Value
----------------------------------------------------------------------------
 1. B(C   1,N   0)                1.4557  0.013403 -0.0155    1.4403
 2. B(C   2,C   1)                1.5377  0.004146 -0.0057    1.5320
 3. B(O   3,C   2)                1.2297  0.045759 -0.0236    1.2062
 4. B(H   4,N   0)                1.0164  0.006262 -0.0075    1.0089
 5. B(H   5,C   1)                1.0961 -0.009891  0.0141    1.1102
 6. B(C   6,C   1)                1.5242 -0.009350  0.0123    1.5365
 7. B(H   7,C   6)                1.0949 -0.003989  0.0057    1.1005
 8. B(H   8,C   6)                1.0958 -0.003520  0.0050    1.1008
 9. B(H   9,C   6)                1.0951 -0.006870  0.0097    1.1049
10. B(H  10,N   0)                1.0160  0.007909 -0.0095    1.0065

and the process is repeated until the criteria are met:

                      .--------------------.
----------------------|Geometry convergence|-------------------------
Item                value                   Tolerance       Converged
---------------------------------------------------------------------
Energy change      -0.0000009421            0.0000050000      YES
RMS gradient        0.0000326782            0.0001000000      YES
MAX gradient        0.0001152425            0.0003000000      YES
RMS step            0.0007124988            0.0020000000      YES
MAX step            0.0017837746            0.0040000000      YES
........................................................
Max(Bonds)      0.0001      Max(Angles)    0.02
Max(Dihed)        0.10      Max(Improp)    0.00
---------------------------------------------------------------------

          ***********************HURRAY********************
          ***        THE OPTIMIZATION HAS CONVERGED     ***
          *************************************************

Here you can see how the geometry changes during the optimization:

../_images/opt.gif

Although the initial guess appeared to be good, as one can see, the B3LYP functional predicts the geometry somewhat different from the input given. The initial guess had the amine group in a more planar configuration that was fixed by the optimization, along with corrections in the bond lengths.

Important

After a geometry optimization run, a file named basename.xyz is printed with the final geometry coordinates that can be later used in following calculation

You can also see how the energy of the molecule goes down as the optimization progresses, leaning towards convergence:

../_images/enconv.png

Is this a real minimum?

How can one know if this is a real minimum? The norm of the gradient is also zero at saddle points, or maybe the gradient was low, but not sufficiently low.

It is possible to check that by calculating the vibrational frequencies on the final geometry, adding a FREQ keyword on the main input:

!B3LYP DEF2-SVP OPT RIJCOSX FREQ
* xyzfile 0 1 alanine_guess.xyz

Then, after computing the exact Hessian, the frequencies will be printed:

-----------------------
VIBRATIONAL FREQUENCIES
-----------------------

Scaling factor for frequencies =  1.000000000  (already applied!)

   0:         0.00 cm**-1
   1:         0.00 cm**-1
   2:         0.00 cm**-1
   3:         0.00 cm**-1
   4:         0.00 cm**-1
   5:         0.00 cm**-1
   6:        59.59 cm**-1
   7:       231.28 cm**-1
   8:       245.18 cm**-1
   9:       254.63 cm**-1
  10:       321.35 cm**-1
[...]

and you can see, all frequencies besides the first translations and rotations are positive, that means we do have a true minimum.

Important

All positive frequencies guarantee a local minimum, but not necessarily a global minimum!

Numerical gradients

The quality of the final geometry depends on the quality of the method you choose. In case you want to optimize the geometry for a method to which there is currently no analytical gradient, you can ask for the numerical gradient using the NUMGRAD flag:

!DLPNO-CCSD(T) cc-pVTZ cc-pVTZ/C OPT NUMGRAD

Warning

Take care when using numerical gradients, the calculation will take much longer if the system is large.

How to remove negative frequencies?

It is not uncommon that, after a geometry optimization run, you end up with one or more negative frequencies, notably if your system has weak intermolecular interactions. It might be that you are stuck on a saddle point or that the optimization criteria was just not good enough.

If you have many small negative frequencies, you probably just need a tighter convergence:

!TIGHTOPT

or, in drastic cases:

!VERYTHIGHTOPT

and it should do it.

If your system has one large negative frequency, it might be closer to a saddle point than a minimum. Then, the best solution would be to take your final structure and displace it in the direction of that mode. For more info check Removing negative frequencies.

A comment on DFT and OPT

DFT is known to perform poorly with intermolecular or weak interactions. In general it is advisable to use the D3 [Goerigk2011] or the charge-dependent D4 [Grimme2017] corrections:

!B3LYP DEF2-SVP OPT D3

or:

!B3LYP DEF2-SVP OPT D4

These will correct both the energies and gradients and lead to much better results.