#!/usr/bin/env python

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from runtest_dirac import Filter, TestRun
from exacorr_environment import set_exacorr_environment

set_exacorr_environment()

test = TestRun(__file__, sys.argv)

f = Filter()
f.add(from_string = 'Final results from EXACORR',
      num_lines   = 8,
      abs_tolerance   = 5.0e-5)
f.add(from_string = 'Final CCSD energy',
      num_lines   = 1,
      abs_tolerance   = 1.0e-8)
f.add(from_string = 'Norm of Fock matrix (OO',
      num_lines   = 1,
      abs_tolerance   = 1.0e-4)
f.add(from_string = 'Norm of Fock matrix (OV',
      num_lines   = 1,
      abs_tolerance   = 1.0e-3)
f.add(from_string = 'Norm of Fock matrix (VV',
      num_lines   = 1,
      abs_tolerance   = 1.0e-2)

test.run(['talsh_ccsd_x2c_zdip.inp'], ['MgF_nosym.mol'], f)
test.run(['talsh_ccsd_x2c_eedm.inp'], ['MgF_nosym.mol'], f)

# dipole moments is close to the HF value
# eEDM seems reasonable

# RELCCSD test works, but the numbers are different to TALSH and not really meaningfull

f1 = Filter()
f1.add(from_string = 'Eigenvalues',
      num_lines   = 32,
      rel_tolerance   = 1.0e-5)
f1.add(from_string = ' Overview of calculated energies',
      num_lines   = 12,
      abs_tolerance   = 5.0e-5)
f1.add(from_string = 'Total CCSD energy',
      num_lines   = 1,
      abs_tolerance   = 5.0e-8)

#test.run(['relccsd_x2c.inp'], ['MgF_nosym.mol'], f1 )
#test.run(['relccsd_x2c_eedm.inp'], ['MgF_nosym.mol'], f1 )
#test.run(['relccsd_x2c_zdip.inp'], ['MgF_nosym.mol'], f1 )

sys.exit(test.return_code)
