# FHI-aims DFT (PBE) geometry optimisation 

from chemsh       import *
from chemsh.utils import testutils

water = Fragment(coords="water.cjson")
# Structure file from tcl-chemshell
#water = Fragment(coords="water.c")

# default functional is blyp
fhiaims = FHIaims(frag=water, basis='fhiaims.basis', functional='pbe') # settings='fhiaims.settings')

opt = Opt(theory=fhiaims,
          algorithm='lbfgs', tolerance=0.0003, trust_radius='energy',
          maxcycle=100, maxene=100, maxstep=1.0)

opt.run()

ecalc = opt.result.energy
eref = -76.383353955858 
# Energy using tcl-chemshell structure
#eref = -76.383346860000

# Test result
testutils.validate(ecalc, eref)
