#!/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)

f1 = Filter()
f1.add(from_string = 'Recanonized MP2 frozen virtual natural spinors',
      num_lines   = 21,
      rel_tolerance   = 1.0e-7)

# The test have two parts, the first run generates MP2 natural orbitals that are stored on the CHECKPOINT.h5 file
# The second run uses these orbitals to compute the CC nergy and property. 

test.run(['hf_get_no_ccpvdz_1.0d-4.inp'], ['hf.xyz'], f1, args='--outcmo')

f2 = Filter()

f2.add(from_string = '* Dipole moment:',
      num_lines   = 9,
      rel_tolerance   = 1.0e-6)
f2.add(from_string = '           Total contribution to principal components',
      num_lines   = 15,
      rel_tolerance   = 1.0e-6)

test.run(['hf_canonical_ccpvdz_16_test.inp'], ['hf.xyz'], f2, args='--incmo')

sys.exit(test.return_code)
