.. tip:: All input and output files can be downloaded :download:`here <_static/geoopt/geoopt.zip>`. Geometry Optimization ============================ Geometry optimization intends to find a minimum on the potential energy surface from a starting geometry. All energy calculation methods, including quantum mechanics (QM), molecular mechanics (MM), and QM/MM, can be used for geometry optimization, as long as you change ``energy`` to ``opt`` in the input files. Three Optimizations -------------------------- QM Geometry Optimization ++++++++++++++++++++++++++++++ For water in :doc:`qmenergy`, the geometry optimization is: .. code-block:: :caption: water.inp basis def2-tzvp end scf charge 0 spin2p1 1 type R end grimmedisp type bj end mol O 0. 0.00000000 -0.11081188 H 0. -0.78397589 0.44324751 H 0. 0.78397589 0.44324751 end task opt b3lyp # Just change energy to opt. end After optimization, you will find two additional files: - ``water-opt.xyz`` The last optimized structure. It is updating during the optimization. - ``water-opt-traj.xyz`` All intermediate structures during the optimization. MM Geometry Optimization ++++++++++++++++++++++++++++++ The protein example in :doc:`mmenergy` can be easily changed for geometry optimization: .. code-block:: :caption: protein.inp charmm parameters par_all36m_prot.prm toppar_water_ions.str topology step2_solvator.psf scaling14 1.0 rcutoff 12.0 rswitch 10.0 use_PBC Lbox 64 64 64 electrostatic pme PMEk 64 64 64 end mol step2_solvator.pdb end task opt charmm end QM/MM Geometry Optimization ++++++++++++++++++++++++++++++ Both examples in :doc:`qmmmenergy` can be easily changed for geometry optimization, as long as you change ``energy`` to ``opt``. For example: .. code-block:: :caption: protein-qmmm.inp charmm parameters par_all36m_prot.prm topology step1_pdbreader.psf scaling14 1.0 rcutoff 12.0 rswitch 13.0 end basis def2-svp end scf charge 0 spin2p1 1 type R end grimmedisp type bj end qmmm qm_region 779 792-815 end mol step1_pdbreader.pdb end task opt b3lyp/charmm end Some Options -------------------------- There are some options for geometry optimization. For example, the following example: .. code-block:: :caption: c3h8o2.inp basis def2-svp end scf charge 0 spin2p1 1 type R end grimmedisp type bj end opt num_steps 1000 epsilon 1.E-5 fix 1-9 end mol C -4.08368628 0.86864405 0.00000000 H -3.72701344 1.37304224 -0.87365150 H -5.15368628 0.86865724 0.00000000 C -3.57037057 -0.58328810 0.00000000 H -3.92704565 -1.08768708 -0.87365013 H -3.92704123 -1.08768606 0.87365253 C -2.03037057 -0.58330630 -0.00000339 H -1.67371614 -1.59211630 -0.00000091 H -1.67370018 -0.07891023 -0.87365712 O -3.60701136 1.54274631 1.16759033 H -4.11695915 2.34433532 1.30546096 O -1.55369311 0.09080013 1.16758349 H -2.04104440 -0.21550578 1.93587082 end task opt b3lyp end The geometry optimization control block is ``opt ... end``: - ``num_steps`` The maximum number of geometry steps. Default is ``1000``. - ``epsilon`` A convergence label. Usually, you do not need to change it. - ``fix`` The atoms that you want to fix during geometry optimization. In the above example, we fix the alkyl chain and only relax the hydroxyl groups. The final optimization result can be seen in ``c3h8o2-opt.xyz`` and ``c3h8o2-opt-traj.xyz``. The animation of the optimization is shown below. Obviously, atoms ``1-9`` have been fixed. .. image:: _static/geoopt/p1.gif :align: center