''' CASTEP Geometry Optimisation of butanol '''

from chemsh       import *
from chemsh.utils import testutils

butanol = Fragment(coords='butanol.cjson')

castep_obj = CASTEP(frag=butanol, functional='pbe',
cut_off_energy='150 eV',maxiter=60,
mixing_scheme='pulay',elec_energy_tol='1.0e-08 eV', 
rand_seed='123654',
)

sp = SP(theory=castep_obj,
gradients='True')
          
sp.run()

ecalc = sp.result.energy[0]

print(f'Optimised Energy:{ecalc}')

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