# Silicon single point energy

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

si = Fragment(coords="Si2_frac.cjson")
#si.cell.convention='crystal'

obj = CP2K(frag=si, functional='lda', 
basis='DZVP-GTH-PADE-CONFINED',ngrids=5, 
precision_all='1.0E-8',
grid_cutoff = 200,
grid_real_cutoff = 30,
)

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

#sp.run(dryrun=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)}')

eref = -7.033815883
testutils.validate(ecalc, eref)
