# Gaussian DFT (BLYP) optimisation

from chemsh       import *
from chemsh.utils import testutils

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

gaussian = Gaussian(frag=water, method='dft', functional='blyp', basis='3-21g')

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

ecalc = opt.result.energy

# Test result
# NWChem
eref = -75.95124901
# Tcl-ChemShell/Gaussian09
eref = -75.951249340500


testutils.validate(ecalc, eref)
