# H2O single point energy

import chemsh
from chemsh       import *
from chemsh.utils import testutils
from datetime import datetime
begin=datetime.now()

water = Fragment(coords="water.cjson")

# default functional is 'lda'
obj = CP2K(frag=water,
functional='lda',
#basis={'H': 'DZVP-MOLOPT-GTH','O':'DZVP-MOLOPT-GTH'},
basis = 'DZVP-MOLOPT-GTH',
ngrids=5,
grid_cutoff = 200,
grid_real_cutoff = 30,
)

sp = SP(theory=obj, gradients=True)

sp.run(dryrun=False)

ecalc = sp.result.energy[0]
gradients = sp.result.gradients

print(f"Final energy is {ecalc}")

print(f"Gradients: \n{gradients}\n")
end=datetime.now()
print(f'Total elapsed time={(end-begin)}')

# Test result
eref = -17.137412146
testutils.validate(ecalc, eref)
