(sec:essentialelements.numericalgradients)= # Numerical Gradients If the analytic gradient is not available, the numerical gradient can simply be requested via: ```orca ! NumGrad ``` as in the following example: ```{literalinclude} ../../orca_working_input/C05S02_121.inp :language: orca ``` NOTE - Be aware that the numerical gradient is quite expensive. The time for one gradient calculation is equal to 6 $\times$ (number of atoms) $\times$ (time for one single point calculation). - The numerical gradient can be calculated in a multi-process run, using a maximum of three times the number of atoms (see section {ref}`sec:essentialelements.parallel.calling`). More details on various options, geometry convergence criteria and the like are found in section {ref}`sec:structurereactivity.optimization`. (sec:essentialelements.numericalgradients.optimization.notes)= ## Some Notes and Tricks :::{note} - `TightSCF` in the SCF part is set as default to avoid the buildup of too much numerical noise in the gradients. - Even if the optimization does not converge, the ORCA output may still end with \"\*\*\*\*ORCA TERMINATED NORMALLY\*\*\*\*\". Therefore do not rely on the presence of this line as an indicator of whether the geometry optimization is converged! Rather, one should instead rely on the fact that, an optimization job that terminates because the maximum number of iterations has been reached, will generate the following output message: ::: :::{Warning} The optimization did not converge but reached the maximum number of optimization cycles. Please check your results very carefully. ::: While a successfully converged job will generate the following message instead: ``` ***********************HURRAY******************** *** THE OPTIMIZATION HAS CONVERGED *** ************************************************* ``` :::{tip} - In rare cases the redundant internal coordinate optimization fails. In this case, you may try to use `COPT` (optimization in Cartesian coordinates). This will likely take many more steps to converge but should be stable. - For optimizations in Cartesian coordinates the initial guess Hessian is constructed in internal coordinates and thus these optimizations should converge only slightly slower than those in internal coordinates. Nevertheless, if you observe a slow convergence behaviour, it may be a good idea to compute a Hessian initially (perhaps at a lower level of theory) and use `InHess read` in order to improve convergence. - At the beginning of a TS optimization more information on the curvature of the PES is needed than a model Hessian can give. The best choice is analytic Hessian, available for HF, DFT and MP2. In other cases (e.g. CAS-SCF), the numerical evaluation is necessary. Nevertheless you do not need to calculate the full Hessian when starting such a calculation. With ORCA we have good experience with approximations to the exact Hessian. Here it is recommended to either directly combine the TS optimization with the results of a relaxed surface scan or to use the Hybrid Hessian as the initial Hessian, depending on the nature of the TS mode. Note that these approximate Hessians do never replace the exact Hessian at the end of the optimization, which is always needed to verify the minimum or first order saddle point nature of the obtained structure. ::: (sec:essentialelements.numericalgradients.numgrads)= ## Numerical Gradients If you want to use numerical instead of analytic gradients you have to use ```orca ! NumGrad ``` in your input file. Additionally the settings for the numerical differentiation can be changed: ```orca %numgrad CentralDiff true # You should use two-sided numerical differentiation, but it # is possible to switch to one-sided numerical differentiation. DX 0.005 # Increment in Bohr for the differentiation. TransInvar true # Take advantage of translation invariance end ```