#!/usr/bin/env python

import os
import sys

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

test = TestRun(__file__, sys.argv)

# first batch - testing the diagonalization correctness
f = Filter()
f.add(from_re     = 'Output from ONEERG',
      num_lines   = 4,
      rel_tolerance   = 1.0e-9)

test.run(['dc.1el.2fs.inp'], ['X2.1s1p1d.asd.mol','X2.1s1p1d.D2h.mol'], f)


# second batch, FSCCSD calculations, starting from O2(2+) and O2(2-)
f = Filter()
f.add(from_re     = 'Sum of all contributions to the energy',
      num_lines   = 8,
      rel_tolerance   = 1.0e-9)
f.add(from_string = ' Energy eigenvalues in atomic units',
      to_re       = ' Relative real eigenvalues in other units',
      rel_tolerance = 1.0e-5)

test.run(['hf.inp', 'fsccsd.inp', 'fsccsd_IE2.inp'], ['O2.mol'], f)

# third batch, CCSD(T) calculations without and in the linear symmetry
f = Filter()
f.add(from_re     = 'Sum of all contributions to the energy',
      num_lines   = 8,
      rel_tolerance   = 1.0e-9)
f.add(from_string = ' Perturbative treatment of triple excitations',
      to_re       = ' Total CCSD-T  energy',
      rel_tolerance = 1.0e-5)

test.run(['uccsd.inp', 'uccsd_linsym.inp'], ['O2.mol'], f)

sys.exit(test.return_code)
