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

f = Filter()
f.add(from_string = ' Energy eigenvalues in atomic units',
      to_re       = 'Relative real eigenvalues in other units;',
# tolerance here is for differencees in absolute terms because for the complex
# cases relative changes could be very large for the complex part of the energy
# even though its magnitude is tiny (e.g. 5x10-9 vs 1x10-9)
      abs_tolerance = 1.0e-7)

# 1. run tests without overlap selection and using vectors from a unit matrix (so no pivoting) as trial vectors. in this case, calculate
# the pairs of eigenvalues. 

test.run(['eom_ea_dc_noinv_full_nooverlap_6roots.inp'], ['f2_c2v.mol', 'f2_d2.mol', 'f2_c2.mol', 'f2_cs.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_noinv_full_nooverlap_c1_6roots.inp'], ['f2_c1.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_noinv_full_nooverlap_c_oo_v_Omega.inp','eom_ea_dc_noinv_full_nooverlap_c_oo_v_-Omega.inp'], ['f2_c_oo_v.mol'], f, args='--mw=110')

test.run(['eom_ea_dc_inv_full_nooverlap_6roots.inp'], ['f2_d2h.mol', 'f2_c2h.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_inv_full_nooverlap_ci_6roots.inp'], ['f2_ci.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_inv_full_nooverlap_d_oo_h_Omega.inp','eom_ea_dc_inv_full_nooverlap_d_oo_h_-Omega.inp'], ['f2_d_oo_h.mol'], f, args='--mw=110')

# 2. runt tests with overlap and using pivoted unit vectors as trial vectors. for all but c1 and ci, calculate for the moment 
# only the first of the doubly degenerate roots (due to incomplete code in the trial vector generation for the other member of the pair) 

test.run(['eom_ea_dc_noinv_overlap_6roots.inp'], ['f2_c2v.mol', 'f2_d2.mol', 'f2_c2.mol', 'f2_cs.mol'], f, args='--mw=110')
# commenting out the overlap test for c1 symmetry because, for certain compiler/machine combinations, we see some of the doubly degenerate  
# states split. this must be reactivated after the overlap code is verified and validated (see issues for the eom-ee testset).
#test.run(['eom_ea_dc_noinv_overlap_c1_6roots.inp'], ['f2_c1.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_noinv_overlap_c_oo_v_Omega.inp', 'eom_ea_dc_noinv_overlap_c_oo_v_-Omega.inp'], ['f2_c_oo_v.mol'], f, args='--mw=110')

test.run(['eom_ea_dc_inv_overlap_6roots.inp'], ['f2_d2h.mol', 'f2_c2h.mol'], f, args='--mw=110')
# aspg, 18/03/2018
# removing the ci/overlap test from the runs until the overlap code is verified, as it is showing 
# a slight symmetry breaking in some machines and thus giving a false failure 
#test.run(['eom_ea_dc_inv_overlap_ci.inp'], ['f2_ci.mol'], f, args='--mw=110')
test.run(['eom_ea_dc_inv_overlap_d_oo_h_Omega.inp','eom_ea_dc_inv_overlap_d_oo_h_-Omega.inp'], ['f2_d_oo_h.mol'], f, args='--mw=110')

#
# below are test runs that take too much time for the standard timeout. they could be used for a finer comparison or in setting up longer tests. 
# 
# 3. same as (1) but asking for more roots

#test.run(['eom_ea_dc_noinv_full_nooverlap.inp'], ['f2_c2v.mol', 'f2_d2.mol', 'f2_c2.mol', 'f2_cs.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_noinv_full_nooverlap_c1.inp'], ['f2_c1.mol'], f, args='--mw=110')

#test.run(['eom_ea_dc_inv_full_nooverlap.inp'], ['f2_d2h.mol', 'f2_c2h.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_inv_full_nooverlap_ci.inp'], ['f2_ci.mol'], f, args='--mw=110')

# 4. same as (2) but asking for more roots

#test.run(['eom_ea_dc_noinv_overlap.inp'], ['f2_c2v.mol', 'f2_d2.mol', 'f2_c2.mol', 'f2_cs.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_noinv_overlap_c1.inp'], ['f2_c1.mol'], f, args='--mw=110')

#test.run(['eom_ea_dc_inv_overlap.inp'], ['f2_d2h.mol', 'f2_c2h.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_inv_overlap_ci.inp'], ['f2_ci.mol'], f, args='--mw=110')

# 5. same as (1) but asking for 32 roots in total for the abelina groups and more than than for the linear symmetry cases. 

#test.run(['eom_ea_dc_noinv_nooverlap_32roots.inp'], ['f2_c2v.mol', 'f2_d2.mol', 'f2_c2.mol', 'f2_cs.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_noinv_nooverlap_c1_32oots.inp'], ['f2_c1.mol'], f, args='--mw=110')

#test.run(['eom_ea_dc_inv_nooverlap_32roots.inp'], ['f2_d2h.mol', 'f2_c2h.mol'], f, args='--mw=110')
#test.run(['eom_ea_dc_inv_nooverlap_ci_32roots.inp'], ['f2_ci.mol'], f, args='--mw=110')



sys.exit(test.return_code)
