#! Intercalls among python wrappers- database, cbs, optimize, energy, etc.
#! Though each call below functions individually, running them all in sequence or
#! mixing up the sequence is aspirational at present.
#! Also aspirational is using the intended types of gradients.



molecule h2 {
    H
    H 1 1.00
}

set {
    BASIS 3-21G
    REFERENCE RHF
    SCF_TYPE PK
    PRINT 1
    E_CONVERGENCE 9
    D_CONVERGENCE 8
    R_CONVERGENCE 8
    JOBTYPE SP
    GUESS CORE
}


banner('Test [1] optimize(cbs(energy()))')
E, wfn = optimize(cbs, corl_wfn='mp2', corl_basis='cc-pv[dt]z', delta_wfn='ccsd', delta_basis='3-21g', return_wfn=True, dertype=0)
wfn.gradient().print_out()

banner('Test [2] database(energy())')
set basis_guess sto-3g
set mp2_type conv
set df_scf_guess false
db('mp2','RGC10',subset=['HeHe-0.85','HeHe-1.0'],tabulate=['mp2 total energy'])
revoke_global_option_changed('BASIS_GUESS')

banner('Test [3] database(cbs(energy()))')
db(cbs, 'RGC10', corl_wfn='mp2', subset=['HeHe-0.85','HeHe-1.0'],tabulate=['cbs total energy','current energy'],corl_basis='cc-pV[DT]Z',corl_scheme=corl_xtpl_helgaker_2,delta_wfn='ccsd(t)',delta_basis='3-21g')
db('mp2/cc-pV[DT]Z + d:ccsd(t)/3-21g', 'RGC10', subset=['HeHe-0.85','HeHe-1.0'],tabulate=['current correlation energy','current energy'])


banner('Test [4] cbs(energy())')
# for h2 geom after optimization in [1]
energy(cbs, corl_wfn='mp2',corl_basis='cc-pv[dt]z',corl_scheme=corl_xtpl_helgaker_2,delta_wfn='ccsd',delta_basis='3-21g',delta2_wfn='ccsd(t)',delta2_wfn_lesser='ccsd',delta2_basis='3-21g')

banner('Test [5] opt(energy())')
# TODO switch to mp2 once gradients thoroughly working again
optimize('mp2',dertype='none')

banner('Test [6] opt(energy())')
optimize('scf')

banner('Test [7] opt(energy())')
h2.reset_point_group('c1')
h2.fix_orientation(True)
h2.update_geometry()
# By pure chance there is a funny false super-tight convergence in the
# SCF below if we read the previous SCF orbitals.  I seem to have avoided
# it by upping E_CONVERGENCE to 9 above, we'll see if that holds -CDS
optimize('mp2')

banner('Test [8] database(opt(energy()))')
db('mp2','S22',db_func=optimize,subset=[1],tabulate=['mp2 total energy','current energy'])

banner('Test [9] alias(cbs(energy()))')
energy(sherrill_gold_standard)
