#
# Water dimer optimisation
#

from chemsh       import *
from chemsh.utils import testutils

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

# TODO check/revise default rcut so it does not need to be overridden here
mm = DL_POLY(frag=water, ff='h2o_dimer.ff', rcut=9.99)

opt = Opt(theory=mm,
          algorithm="lbfgs", tolerance=0.0003, trust_radius="energy",
          maxcycle=400, maxene=300).run()

ecalc = opt.result.energy

# Test result from Tcl-ChemShell
# cf GULP -0.010988967809
eref = -0.010988711926
tolerance = 1.0e-6

testutils.validate(ecalc, eref, tol=tolerance)

