# Gaussian NO2 doublet unrestricted 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="uhf", mult=2, threshold=1E-12, grid='high')

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

ecalc = opt.result.energy

# Test result from Tcl-ChemShell
# NWChem
eref = -203.907945966204
# Tcl-ChemShell/Gaussian09
eref = -203.907947108000

testutils.validate(ecalc, eref)
