Geometry optimization of water

# Perform a geometry optimization of a water molecule and compute
# the vibrational normal modes using GFN1-xTB.

# You could also load the geometry from an xyz file: 
# molecule = Molecule('path/my_molecule.xyz')
molecule = Molecule()
molecule.add_atom(Atom(symbol='O', coords=(0,0,0)))
molecule.add_atom(Atom(symbol='H', coords=(1,0,0)))
molecule.add_atom(Atom(symbol='H', coords=(0,1,0)))

settings = Settings()
settings.input.ams.Task = 'GeometryOptimization'
settings.input.ams.Properties.NormalModes = 'Yes'
settings.input.dftb.Model = 'GFN1-xTB'

job = AMSJob(molecule=molecule, settings=settings, name='water_optimization')
result = job.run()

energy = result.get_energy(unit='kcal/mol')
frequencies = result.get_frequencies(unit='cm^-1')
optimized_molecule = result.get_main_molecule()

# Unlike python lists, where the index of the first element is 0, 
# the index of the first atom in the molecule object is 1
bond_angle = optimized_molecule[1].angle(optimized_molecule[2], optimized_molecule[3])

print('== Results ==')
print('Optimized geometry:')
print(optimized_molecule)
print('Energy      : {:.3f} kcal/mol'.format(energy))
print('Bond angle  : {:.1f} degrees'.format(Units.convert(bond_angle, 'rad', 'degree')))
print('Frequencies : {} cm^-1'.format(frequencies))

Note

To execute this PLAMS script:

Output

[18:29:42] PLAMS working folder: /home/robert/workspace/jobs/fix2020/regtest/test.plams/rundir.plams.WaterOptimization/plams_workdir
[18:29:42] JOB water_optimization STARTED
[18:29:42] JOB water_optimization RUNNING
[18:29:43] JOB water_optimization FINISHED
[18:29:43] JOB water_optimization SUCCESSFUL
== Results ==
Optimized geometry:
  Atoms: 
    1         O      0.066921      0.066921      0.000000 
    2         H      1.012042     -0.078963      0.000000 
    3         H     -0.078963      1.012042      0.000000 

Energy      : -3618.400 kcal/mol
Bond angle  : 107.5 degrees
Frequencies : [1427.92370353 3674.50689571 3785.96039474] cm^-1
[18:29:43] PLAMS run finished. Goodbye
Test duration in seconds: 2