# Gaussian NO2 doublet restricted open-shell DFT (BLYP) optimisation

from chemsh       import *
from chemsh.utils import testutils

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

# default functional is 'blyp'
gaussian = Gaussian(frag=no2, method="dft", basis="3-21g", scftype="rohf", mult=2, grid='high', threshold=1E-12)

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

ecalc = opt.result.energy

# Test result from Tcl-ChemShell
# NWChem
eref = -203.907386617284
# Tcl-ChemShell/Gaussian09
eref = -203.907387861000

testutils.validate(ecalc, eref)
