# Gaussian NO2+ 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", charge=1, grid='high', threshold=1E-12)

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 from Tcl-ChemShell
# NWChem
eref = -203.552971796015
# Tcl-ChemShell/Gaussian09
eref = -203.552972214000

testutils.validate(ecalc, eref)
