# Optimization

### Geometry Optimization

The energy and properties of a single molecular geometry of a system are of limited interest, especially as the size of the system increases. In consequence, a wide range of techniques has been developed to explore the conformations that are accessible to a system. Some of the most basic of these are local geometry optimization algorithms that aim to locate structures of low potential energy. pDynamo has a number of geometry optimization methods, one of which — a conjugate gradient algorithm — is illustrated in the program `Example10.py`:

``# . Define the molecule and its QC model.``
``molecule = XYZFile_ToSystem ( os.path.join ( xyzPath, "bala_c7eq.xyz" ) )``
``molecule.DefineQCModel ( QCModelMNDO ( "am1" ) )``
``molecule.Summary ( )``

``# . Save a copy of the starting coordinates.``
``coordinates3 = Clone ( molecule.coordinates3 )``

``# . Determine the starting energy.``
``eStart = molecule.Energy ( )``

``# . Optimization.``
``ConjugateGradientMinimize_SystemGeometry ( molecule                    ,``
``                                           logFrequency         =  100 ,``
``                                           maximumIterations    = 2000 ,``
``                                           rmsGradientTolerance =  0.1 )``

``# . Determine the final energy.``
``eStop = molecule.Energy ( )``

``# . Determine the RMS coordinate deviation between the optimized and unoptimized structures.``
``masses = molecule.atoms.GetItemAttributes ( "mass" )``
``coordinates3.Superimpose ( molecule.coordinates3, weights = masses )``
``rms = coordinates3.RMSDeviation ( molecule.coordinates3, weights = masses )``

``# . Print the results.``
``table = logFile.GetTable ( columns = [ 30, 30 ] )``
``table.Start ( )``
``table.Title ( "Minimization Results" )``
``table.Entry ( "Energy Change", alignment = "l" )``
``table.Entry ( "%20.4f" % ( eStop - eStart, ) )``
``table.Entry ( "RMS Coordinate Deviation", alignment = "l" )``
``table.Entry ( "%20.4f" % ( rms, ) )``
``table.Stop ( ) ``

The program employs a semi-empirical QC method to geometry optimize a conformation of the bALA molecule. After the optimization, the difference in energy between the starting, unoptimized and final, optimized structures is printed along with their RMS coordinate deviation.

### Exercises

1. The bALA molecule has a number of different stable conformations. One way of exploring these is to generate a two-dimensional map of the molecule's conformational space as a function of its φ and ψ dihedral angles. Using pDynamo's dihedral soft constraint capability, generate such a φ/ψ map by performing geometry optimizations with different constrained values of the φ and ψ angles. Identify the stable regions on the surface and the low energy paths that go between them. Examples of how to use soft constraints may be found in the programs `Example18.py` and `Example23.py`.