from chemsh import *
from chemsh.utils import testutils

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

pyscf = PySCF(frag=no2, method="dft", scftype="uhf", functional="blyp", basis="3-21g", mult=2)

opt = Opt(
    theory=pyscf,
    algorithm="lbfgs",
    tolerance=0.0003,
    trust_radius="energy",
    maxcycle=100,
    maxene=100,
    maxstep=1.0,
)

opt.run()

ecalc = opt.result.energy

# Tcl-ChemShell 3.7.1/ORCA 4.2.1 result
# convergence=tightscf from Tcl-ChemShell
# eref = -203.907940297032
# ORCA 5.0.3 - pyscf requires gridsize=3
#eref = -203.90794196

#pyscf reference
eref = -203.907946995492

testutils.validate(ecalc, eref, tol=3e-6)
