# SAPT0(ROHF) script for the oxygen dimer (two triplets making a quintet)
# The code is transparent but not optimized in any way, and this test might take up to a couple minutes.
#
# Created by: <NAME>
# Date: 12/1/14
# License: GPL v3.0
#

import time
import numpy as np
from helper_SAPT import *
np.set_printoptions(precision=5, linewidth=200, threshold=2000, suppress=True)
import psi4

# Set Psi4 & NumPy Memory Options
psi4.set_memory('2 GB')
psi4.core.set_output_file('output.dat', False)

numpy_memory = 2

# Set molecule to dimer
dimer = psi4.geometry("""
#Set the spin of A
0 3
O    0.000000000   0.000000000   2.605000000
O    0.000000000   0.000000000   1.395000000
--
#Set the spin of A
0 3
O    0.000000000   0.000000000  -1.395000000
O    0.000000000   0.000000000  -2.605000000
symmetry c1
""")

psi4.set_options({'basis': 'jun-cc-pVDZ',
                  'e_convergence': 1e-8,
                  'd_convergence': 1e-8,
                  'scf_type': 'pk',
                  'reference': 'rohf'})

sapt = helper_SAPT(dimer, memory=8, reference='ROHF')

### Start E100 Electostatics
elst_timer = sapt_timer('electrostatics')
Elst10 = 4 * np.einsum('ijij', sapt.vt('ijij'))
Elst10 += 2 * np.einsum('ajaj', sapt.vt('ajaj'))
Elst10 += 2 * np.einsum('ibib', sapt.vt('ibib'))
Elst10 += np.einsum('abab', sapt.vt('abab'))
elst_timer.stop()
### End E100 Electrostatics

### Start E100 Exchange
exch_timer = sapt_timer('exchange')
s_ij = sapt.s('ij')
s_ib = sapt.s('ib')
s_is = sapt.s('is')
s_aj = sapt.s('aj')
s_ab = sapt.s('ab')
s_as = sapt.s('as')
s_rj = sapt.s('rj')
s_rb = sapt.s('rb')

vt_ijji = sapt.vt('ijji')
vt_ajja = sapt.vt('ajja')
vt_ibbi = sapt.vt('ibbi')
vt_abba = sapt.vt('abba')

Exch100 = -2 * np.einsum('ijji', vt_ijji)
Exch100 -= np.einsum('ajja', vt_ajja)
Exch100 -= np.einsum('ibbi', vt_ibbi)
Exch100 -= np.einsum('abba', vt_abba)
#znacznik

vt_ijii = sapt.vt('ijii')
temp = -2 * vt_ijii + vt_ijii.swapaxes(2,3)
Exch100 += 2 * np.einsum('ijiI,Ij',temp,s_ij)
vt_ibii = sapt.vt('ibii')
temp = -2 * vt_ibii + vt_ibii.swapaxes(2,3)
Exch100 += np.einsum('ibiI,Ib',temp,s_ib)
vt_ijia = sapt.vt('ijia')
vt_ijai = sapt.vt('ijai')
Exch100 -= 2 * np.einsum('ijia,aj',vt_ijia,s_aj)
Exch100 += np.einsum('ijai,aj',vt_ijai,s_aj)
vt_ibia = sapt.vt('ibia')
vt_ibai = sapt.vt('ibai')
Exch100 -= 2 * np.einsum('ibia,ab',vt_ibia,s_ab)
Exch100 += np.einsum('ibai,ab',vt_ibai,s_ab)

vt_ajai = sapt.vt('ajai')
vt_ajia = sapt.vt('ajia')
Exch100 -= 2 * np.einsum('ajai,ij',vt_ajai,s_ij)
Exch100 += np.einsum('ajia,ij',vt_ajia,s_ij)
vt_abai = sapt.vt('abai')
vt_abia = sapt.vt('abia')
Exch100 -= np.einsum('abai,ib',vt_abai,s_ib)
Exch100 += np.einsum('abia,ib',vt_abia,s_ib)
vt_ajaa = sapt.vt('ajaa')
temp = - vt_ajaa + vt_ajaa.swapaxes(2,3)
Exch100 += np.einsum('ajaA,Aj',temp,s_aj)
vt_abaa = sapt.vt('abaa')
temp = - vt_abaa + vt_abaa.swapaxes(2,3)
Exch100 += np.einsum('abaA,Ab',temp,s_ab)

vt_ijjj = sapt.vt('ijjj')
temp = -2 * vt_ijjj + vt_ijjj.swapaxes(2,3)
Exch100 += 2 * np.einsum('ijJj,iJ',temp,s_ij)
vt_ajjj = sapt.vt('ajjj')
temp = -2 * vt_ajjj + vt_ajjj.swapaxes(2,3)
Exch100 += np.einsum('ajJj,aJ',temp,s_aj)
vt_ibjb = sapt.vt('ibjb')
vt_ibbj = sapt.vt('ibbj')
Exch100 -= 2 * np.einsum('ibjb,ij',vt_ibjb,s_ij)
Exch100 += np.einsum('ibbj,ij',vt_ibbj,s_ij)
vt_abjb = sapt.vt('abjb')
vt_abbj = sapt.vt('abbj')
Exch100 -= np.einsum('abjb,aj',vt_abjb,s_aj)
Exch100 += np.einsum('abbj,aj',vt_abbj,s_aj)

vt_ijbj = sapt.vt('ijbj')
vt_ijjb = sapt.vt('ijjb')
Exch100 -= 2 * np.einsum('ijbj,ib',vt_ijbj,s_ib)
Exch100 += np.einsum('ijjb,ib',vt_ijjb,s_ib)
vt_ajbj = sapt.vt('ajbj')
vt_ajjb = sapt.vt('ajjb')
Exch100 -= 2 * np.einsum('ajbj,ab',vt_ajbj,s_ab)
Exch100 += np.einsum('ajjb,ab',vt_ajjb,s_ab)
vt_ibbb = sapt.vt('ibbb')
temp = - vt_ibbb + vt_ibbb.swapaxes(2,3)
Exch100 += np.einsum('ibBb,iB',temp,s_ib)
vt_abbb = sapt.vt('abbb')
temp = - vt_abbb + vt_abbb.swapaxes(2,3)
Exch100 += np.einsum('abBb,aB',temp,s_ab)

vt_ijij = sapt.vt('ijij')
Exch100 += 4 * np.einsum('ijiJ,Ij,IJ',vt_ijij,s_ij,s_ij)
Exch100 += 2 * np.einsum('ijiJ,aj,aJ',vt_ijij,s_aj,s_aj)
Exch100 += 4 * np.einsum('ijIj,IJ,iJ',vt_ijij,s_ij,s_ij)
Exch100 += 2 * np.einsum('ijIj,Ib,ib',vt_ijij,s_ib,s_ib)
Exch100 -= 2 * np.einsum('ijIJ,Ij,iJ',vt_ijij,s_ij,s_ij)

vt_ibij = sapt.vt('ibij')
Exch100 += 4 * np.einsum('ibij,Ib,Ij',vt_ibij,s_ib,s_ij)
Exch100 += 4 * np.einsum('ibij,ab,aj',vt_ibij,s_ab,s_aj)
Exch100 -= 2 * np.einsum('ibIj,Ib,ij',vt_ibij,s_ib,s_ij)

vt_ajij = sapt.vt('ajij')
Exch100 += 4 * np.einsum('ajij,iJ,aJ',vt_ajij,s_ij,s_aj)
Exch100 += 4 * np.einsum('ajij,ib,ab',vt_ajij,s_ib,s_ab)
Exch100 -= 2 * np.einsum('ajiJ,ij,aJ',vt_ajij,s_ij,s_aj)

vt_abij = sapt.vt('abij')
Exch100 -= 2 * np.einsum('abij,ib,aj',vt_abij,s_ib,s_aj)
Exch100 -= 2 * np.einsum('abij,ij,ab',vt_abij,s_ij,s_ab)

vt_ibib = sapt.vt('ibib')
Exch100 += 2 * np.einsum('ibiB,Ib,IB',vt_ibib,s_ib,s_ib)
Exch100 += 2 * np.einsum('ibiB,ab,aB',vt_ibib,s_ab,s_ab)
Exch100 += 2 * np.einsum('ibIb,Ij,ij',vt_ibib,s_ij,s_ij)
Exch100 += np.einsum('ibIb,IB,iB',vt_ibib,s_ib,s_ib)
Exch100 -= np.einsum('ibIB,Ib,iB',vt_ibib,s_ib,s_ib)

vt_ajaj = sapt.vt('ajaj')
Exch100 += 2 * np.einsum('ajAj,AJ,aJ',vt_ajaj,s_aj,s_aj)
Exch100 += 2 * np.einsum('ajAj,Ab,ab',vt_ajaj,s_ab,s_ab)
Exch100 += 2 * np.einsum('ajaJ,ij,iJ',vt_ajaj,s_ij,s_ij)
Exch100 += np.einsum('ajaJ,Aj,AJ',vt_ajaj,s_aj,s_aj)
Exch100 -= np.einsum('ajAJ,Aj,aJ',vt_ajaj,s_aj,s_aj)

vt_abaj = sapt.vt('abaj')
Exch100 += 2 * np.einsum('abaj,ib,ij',vt_abaj,s_ib,s_ij)
Exch100 += 2 * np.einsum('abaj,Ab,Aj',vt_abaj,s_ab,s_aj)
Exch100 -= 2 * np.einsum('abAj,Ab,aj',vt_abaj,s_ab,s_aj)

vt_abib = sapt.vt('abib')
Exch100 += 2 * np.einsum('abib,ij,aj',vt_abib,s_ij,s_aj)
Exch100 += 2 * np.einsum('abib,iB,aB',vt_abib,s_ib,s_ab)
Exch100 -= 2 * np.einsum('abiB,ib,aB',vt_abib,s_ib,s_ab)

vt_abab = sapt.vt('abab')
Exch100 += np.einsum('abaB,ib,iB',vt_abab,s_ib,s_ib)
Exch100 += np.einsum('abaB,Ab,AB',vt_abab,s_ab,s_ab)
Exch100 += np.einsum('abAb,Aj,aj',vt_abab,s_aj,s_aj)
Exch100 += np.einsum('abAb,AB,aB',vt_abab,s_ab,s_ab)
Exch100 -= np.einsum('abAB,Ab,aB',vt_abab,s_ab,s_ab)

exch_timer.stop()
### End E100 (S^2) Exchange

### Start E200 Disp
disp_timer = sapt_timer('dispersion and exchange dispersion')
v_rsij = sapt.v('rsij')
v_rsab = sapt.v('rsab')
v_rsaj = sapt.v('rsaj')
v_rsib = sapt.v('rsib')
v_abij = sapt.v('abij')
v_rbij = sapt.v('rbij')
v_asij = sapt.v('asij')
v_rbaj = sapt.v('rbaj')
v_asib = sapt.v('asib')
e_rsij = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rsab = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('a', dim=2) + sapt.eps('b'))
e_rsaj = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('a', dim=2) + sapt.eps('j'))
e_rsib = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('b'))
e_abij = 1/(-sapt.eps('a', dim=4) - sapt.eps('b', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rbij = 1/(-sapt.eps('r', dim=4) - sapt.eps('b', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_asij = 1/(-sapt.eps('a', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rbaj = 1/(-sapt.eps('r', dim=4) - sapt.eps('b', dim=3) + sapt.eps('a', dim=2) + sapt.eps('j'))
e_asib = 1/(-sapt.eps('a', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('b'))
t_rsij = np.einsum('rsij,rsij->rsij', v_rsij, e_rsij)
t_rsab = np.einsum('rsab,rsab->rsab', v_rsab, e_rsab)
t_rsaj = np.einsum('rsaj,rsaj->rsaj', v_rsaj, e_rsaj)
t_rsib = np.einsum('rsib,rsib->rsib', v_rsib, e_rsib)
t_abij = np.einsum('abij,abij->abij', v_abij, e_abij)
t_rbij = np.einsum('rbij,rbij->rbij', v_rbij, e_rbij)
t_asij = np.einsum('asij,asij->asij', v_asij, e_asij)
t_rbaj = np.einsum('rbaj,rbaj->rbaj', v_rbaj, e_rbaj)
t_asib = np.einsum('asib,asib->asib', v_asib, e_asib)

Disp200 = 4 * np.einsum('rsij,rsij,rsij->', e_rsij, v_rsij, v_rsij)
Disp200 += np.einsum('rsab,rsab,rsab->', e_rsab, v_rsab, v_rsab)
Disp200 += 2 * np.einsum('rsaj,rsaj,rsaj->', e_rsaj, v_rsaj, v_rsaj)
Disp200 += 2 * np.einsum('rsib,rsib,rsib->', e_rsib, v_rsib, v_rsib)
Disp200 += np.einsum('abij,abij,abij->', e_abij, v_abij, v_abij)
Disp200 += 2 * np.einsum('rbij,rbij,rbij->', e_rbij, v_rbij, v_rbij)
Disp200 += 2 * np.einsum('asij,asij,asij->', e_asij, v_asij, v_asij)
Disp200 += np.einsum('rbaj,rbaj,rbaj->', e_rbaj, v_rbaj, v_rbaj)
Disp200 += np.einsum('asib,asib,asib->', e_asib, v_asib, v_asib)
### End E200 Disp

### Start E200 Exchange-Dispersion
# the code is brute-force autoimplemented from the auto-gnerated LaTeX formula
result = 0.0
temp = sapt.vt('absr')
result -= np.einsum('rsab,absr->',t_rsab,temp)
temp = sapt.vt('ajsr')
result -= np.einsum('rsaj,ajsr->',t_rsaj,temp)
temp = sapt.vt('ibsr')
result -= np.einsum('rsib,ibsr->',t_rsib,temp)
temp = sapt.vt('ijba')
result -= np.einsum('abij,ijba->',t_abij,temp)
temp = sapt.vt('ijsa')
result -= np.einsum('asij,ijsa->',t_asij,temp)
temp = sapt.vt('ijbr')
result -= np.einsum('rbij,ijbr->',t_rbij,temp)
temp = sapt.vt('ijsr')
result -= 2 * np.einsum('rsij,ijsr->',t_rsij,temp)
temp = sapt.vt('abar')
result -= np.einsum('rsab,as,AbAr->',t_rsab,s_as,temp)
result += np.einsum('rsab,As,abAr->',t_rsab,s_as,temp)
temp = sapt.vt('abbs')
result += np.einsum('rsab,rb,aBBs->',t_rsab,s_rb,temp)
result -= np.einsum('rsab,rB,abBs->',t_rsab,s_rb,temp)
temp = sapt.vt('abir')
result += np.einsum('rsab,Is,abIr->',t_rsab,s_is,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('rsab,as,IbIr->',t_rsab,s_as,temp)
temp = sapt.vt('abjs')
result -= np.einsum('rsab,rJ,abJs->',t_rsab,s_rj,temp)
temp = sapt.vt('ajjs')
result += np.einsum('rsab,rb,aJJs->',t_rsab,s_rb,temp)
temp = sapt.vt('abra')
result += np.einsum('rsab,as,AbrA->',t_rsab,s_as,temp)
result -= np.einsum('rsab,As,abrA->',t_rsab,s_as,temp)
temp = sapt.vt('abri')
result -= np.einsum('rsab,Is,abrI->',t_rsab,s_is,temp)
temp = sapt.vt('ibri')
result += np.einsum('rsab,as,IbrI->',t_rsab,s_as,temp)
temp = sapt.vt('absb')
result -= np.einsum('rsab,rb,aBsB->',t_rsab,s_rb,temp)
result += np.einsum('rsab,rB,absB->',t_rsab,s_rb,temp)
temp = sapt.vt('absj')
result += np.einsum('rsab,rJ,absJ->',t_rsab,s_rj,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('rsab,rb,aJsJ->',t_rsab,s_rb,temp)
temp = sapt.vt('ajbb')
result -= np.einsum('rbaj,rB,ajBb->',t_rbaj,s_rb,temp)
temp = sapt.vt('ajjb')
result -= np.einsum('rbaj,rJ,ajJb->',t_rbaj,s_rj,temp)
temp = sapt.vt('ajri')
result -= np.einsum('rbaj,Ib,ajrI->',t_rbaj,s_ib,temp)
temp = sapt.vt('ajar')
result -= np.einsum('rsaj,as,AjAr->',t_rsaj,s_as,temp)
result += np.einsum('rsaj,As,ajAr->',t_rsaj,s_as,temp)
temp = sapt.vt('abbs')
result += np.einsum('rsaj,rj,aBBs->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajbs')
result -= 2 * np.einsum('rsaj,rB,ajBs->',t_rsaj,s_rb,temp)
temp = sapt.vt('ajir')
result += np.einsum('rsaj,Is,ajIr->',t_rsaj,s_is,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('rsaj,as,IjIr->',t_rsaj,s_as,temp)
temp = sapt.vt('ajjs')
result += np.einsum('rsaj,rj,aJJs->',t_rsaj,s_rj,temp)
result -= 2 * np.einsum('rsaj,rJ,ajJs->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajra')
result += np.einsum('rsaj,as,AjrA->',t_rsaj,s_as,temp)
result -= np.einsum('rsaj,As,ajrA->',t_rsaj,s_as,temp)
temp = sapt.vt('ajri')
result -= 2 * np.einsum('rsaj,Is,ajrI->',t_rsaj,s_is,temp)
temp = sapt.vt('ijri')
result += np.einsum('rsaj,as,IjrI->',t_rsaj,s_as,temp)
temp = sapt.vt('absb')
result -= np.einsum('rsaj,rj,aBsB->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajsb')
result += np.einsum('rsaj,rB,ajsB->',t_rsaj,s_rb,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('rsaj,rj,aJsJ->',t_rsaj,s_rj,temp)
result += np.einsum('rsaj,rJ,ajsJ->',t_rsaj,s_rj,temp)
temp = sapt.vt('ibaa')
result -= np.einsum('asib,As,ibaA->',t_asib,s_as,temp)
temp = sapt.vt('ibai')
result -= np.einsum('asib,Is,ibaI->',t_asib,s_is,temp)
temp = sapt.vt('ibjs')
result -= np.einsum('asib,aJ,ibJs->',t_asib,s_aj,temp)
temp = sapt.vt('abar')
result -= np.einsum('rsib,is,AbAr->',t_rsib,s_is,temp)
temp = sapt.vt('ibar')
result += np.einsum('rsib,As,ibAr->',t_rsib,s_as,temp)
temp = sapt.vt('ibbs')
result += np.einsum('rsib,rb,iBBs->',t_rsib,s_rb,temp)
result -= np.einsum('rsib,rB,ibBs->',t_rsib,s_rb,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('rsib,is,IbIr->',t_rsib,s_is,temp)
result += np.einsum('rsib,Is,ibIr->',t_rsib,s_is,temp)
temp = sapt.vt('ibjs')
result -= 2 * np.einsum('rsib,rJ,ibJs->',t_rsib,s_rj,temp)
temp = sapt.vt('ijjs')
result += np.einsum('rsib,rb,iJJs->',t_rsib,s_rb,temp)
temp = sapt.vt('abra')
result += np.einsum('rsib,is,AbrA->',t_rsib,s_is,temp)
temp = sapt.vt('ibra')
result -= 2 * np.einsum('rsib,As,ibrA->',t_rsib,s_as,temp)
temp = sapt.vt('ibri')
result += np.einsum('rsib,is,IbrI->',t_rsib,s_is,temp)
result -= 2 * np.einsum('rsib,Is,ibrI->',t_rsib,s_is,temp)
temp = sapt.vt('ibsb')
result -= np.einsum('rsib,rb,iBsB->',t_rsib,s_rb,temp)
result += np.einsum('rsib,rB,ibsB->',t_rsib,s_rb,temp)
temp = sapt.vt('ibsj')
result += np.einsum('rsib,rJ,ibsJ->',t_rsib,s_rj,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('rsib,rb,iJsJ->',t_rsib,s_rb,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('abij,ib,AjAa->',t_abij,s_ib,temp)
temp = sapt.vt('ijai')
result += np.einsum('abij,ib,IjaI->',t_abij,s_ib,temp)
result -= np.einsum('abij,Ib,ijaI->',t_abij,s_ib,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('abij,aj,iBbB->',t_abij,s_aj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('abij,aj,iJbJ->',t_abij,s_aj,temp)
result += np.einsum('abij,aJ,ijbJ->',t_abij,s_aj,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('abij,ib,IjIa->',t_abij,s_ib,temp)
result += np.einsum('abij,Ib,ijIa->',t_abij,s_ib,temp)
temp = sapt.vt('ijjb')
result += np.einsum('abij,aj,iJJb->',t_abij,s_aj,temp)
result -= np.einsum('abij,aJ,ijJb->',t_abij,s_aj,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('asij,is,AjAa->',t_asij,s_is,temp)
temp = sapt.vt('ijaa')
result -= np.einsum('asij,As,ijaA->',t_asij,s_as,temp)
temp = sapt.vt('ijai')
result += np.einsum('asij,is,IjaI->',t_asij,s_is,temp)
result -= 2 * np.einsum('asij,Is,ijaI->',t_asij,s_is,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('asij,is,IjIa->',t_asij,s_is,temp)
result += np.einsum('asij,Is,ijIa->',t_asij,s_is,temp)
temp = sapt.vt('ijjs')
result += np.einsum('asij,aj,iJJs->',t_asij,s_aj,temp)
result -= 2 * np.einsum('asij,aJ,ijJs->',t_asij,s_aj,temp)
temp = sapt.vt('ibsb')
result -= np.einsum('asij,aj,iBsB->',t_asij,s_aj,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('asij,aj,iJsJ->',t_asij,s_aj,temp)
result += np.einsum('asij,aJ,ijsJ->',t_asij,s_aj,temp)
temp = sapt.vt('ajar')
result -= np.einsum('rbij,ib,AjAr->',t_rbij,s_ib,temp)
temp = sapt.vt('ijbb')
result -= np.einsum('rbij,rB,ijBb->',t_rbij,s_rb,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('rbij,rj,iBbB->',t_rbij,s_rj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('rbij,rj,iJbJ->',t_rbij,s_rj,temp)
result += np.einsum('rbij,rJ,ijbJ->',t_rbij,s_rj,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('rbij,ib,IjIr->',t_rbij,s_ib,temp)
result += np.einsum('rbij,Ib,ijIr->',t_rbij,s_ib,temp)
temp = sapt.vt('ijjb')
result += np.einsum('rbij,rj,iJJb->',t_rbij,s_rj,temp)
result -= 2 * np.einsum('rbij,rJ,ijJb->',t_rbij,s_rj,temp)
temp = sapt.vt('ijri')
result += np.einsum('rbij,ib,IjrI->',t_rbij,s_ib,temp)
result -= 2 * np.einsum('rbij,Ib,ijrI->',t_rbij,s_ib,temp)
temp = sapt.vt('ajar')
result -= 2 * np.einsum('rsij,is,AjAr->',t_rsij,s_is,temp)
temp = sapt.vt('ijar')
result += np.einsum('rsij,As,ijAr->',t_rsij,s_as,temp)
temp = sapt.vt('ibbs')
result += np.einsum('rsij,rj,iBBs->',t_rsij,s_rj,temp)
temp = sapt.vt('ijbs')
result -= 2 * np.einsum('rsij,rB,ijBs->',t_rsij,s_rb,temp)
temp = sapt.vt('ijir')
result -= 4 * np.einsum('rsij,is,IjIr->',t_rsij,s_is,temp)
result += 2 * np.einsum('rsij,Is,ijIr->',t_rsij,s_is,temp)
temp = sapt.vt('ijjs')
result += 2 * np.einsum('rsij,rj,iJJs->',t_rsij,s_rj,temp)
result -= 4 * np.einsum('rsij,rJ,ijJs->',t_rsij,s_rj,temp)
temp = sapt.vt('ajra')
result += np.einsum('rsij,is,AjrA->',t_rsij,s_is,temp)
temp = sapt.vt('ijra')
result -= 2 * np.einsum('rsij,As,ijrA->',t_rsij,s_as,temp)
temp = sapt.vt('ijri')
result += 2 * np.einsum('rsij,is,IjrI->',t_rsij,s_is,temp)
result -= 4 * np.einsum('rsij,Is,ijrI->',t_rsij,s_is,temp)
temp = sapt.vt('ibsb')
result -= 2 * np.einsum('rsij,rj,iBsB->',t_rsij,s_rj,temp)
temp = sapt.vt('ijsb')
result += np.einsum('rsij,rB,ijsB->',t_rsij,s_rb,temp)
temp = sapt.vt('ijsj')
result -= 4 * np.einsum('rsij,rj,iJsJ->',t_rsij,s_rj,temp)
result += 2 * np.einsum('rsij,rJ,ijsJ->',t_rsij,s_rj,temp)
temp = sapt.vt('abab')
result += np.einsum('rsab,as,rB,AbAB->',t_rsab,s_as,s_rb,temp)
result += np.einsum('rsab,As,rb,aBAB->',t_rsab,s_as,s_rb,temp)
result -= np.einsum('rsab,As,rB,abAB->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('rsab,as,rJ,AbAJ->',t_rsab,s_as,s_rj,temp)
result -= np.einsum('rsab,As,rJ,abAJ->',t_rsab,s_as,s_rj,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('rsab,As,rb,aJAJ->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abas')
result += np.einsum('rsab,aB,rb,ABAs->',t_rsab,s_ab,s_rb,temp)
result -= np.einsum('rsab,aB,rB,AbAs->',t_rsab,s_ab,s_rb,temp)
result -= np.einsum('rsab,aJ,rJ,AbAs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsab,aJ,rb,AJAs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abas')
result -= np.einsum('rsab,AB,rb,aBAs->',t_rsab,s_ab,s_rb,temp)
result += np.einsum('rsab,AB,rB,abAs->',t_rsab,s_ab,s_rb,temp)
result += np.einsum('rsab,AJ,rJ,abAs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('rsab,AJ,rb,aJAs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abib')
result += np.einsum('rsab,Is,rb,aBIB->',t_rsab,s_is,s_rb,temp)
result -= np.einsum('rsab,Is,rB,abIB->',t_rsab,s_is,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsab,as,rB,IbIB->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abij')
result -= np.einsum('rsab,Is,rJ,abIJ->',t_rsab,s_is,s_rj,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('rsab,Is,rb,aJIJ->',t_rsab,s_is,s_rb,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('rsab,as,rJ,IbIJ->',t_rsab,s_as,s_rj,temp)
temp = sapt.vt('abis')
result -= np.einsum('rsab,IB,rb,aBIs->',t_rsab,s_ib,s_rb,temp)
result += np.einsum('rsab,IB,rB,abIs->',t_rsab,s_ib,s_rb,temp)
result += np.einsum('rsab,IJ,rJ,abIs->',t_rsab,s_ij,s_rj,temp)
temp = sapt.vt('ajis')
result -= np.einsum('rsab,IJ,rb,aJIs->',t_rsab,s_ij,s_rb,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsab,aB,rb,IBIs->',t_rsab,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsab,aB,rB,IbIs->',t_rsab,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsab,aJ,rJ,IbIs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsab,aJ,rb,IJIs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsab,as,Ab,ABrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,as,AB,AbrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,As,Ab,aBrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,Is,Ib,aBrB->',t_rsab,s_is,s_ib,temp)
result += np.einsum('rsab,As,AB,abrB->',t_rsab,s_as,s_ab,temp)
result += np.einsum('rsab,Is,IB,abrB->',t_rsab,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsab,as,Ib,IBrB->',t_rsab,s_as,s_ib,temp)
result -= np.einsum('rsab,as,IB,IbrB->',t_rsab,s_as,s_ib,temp)
temp = sapt.vt('abrj')
result -= np.einsum('rsab,as,AJ,AbrJ->',t_rsab,s_as,s_aj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsab,as,Ab,AJrJ->',t_rsab,s_as,s_ab,temp)
temp = sapt.vt('abrj')
result += np.einsum('rsab,As,AJ,abrJ->',t_rsab,s_as,s_aj,temp)
result += np.einsum('rsab,Is,IJ,abrJ->',t_rsab,s_is,s_ij,temp)
temp = sapt.vt('ajrj')
result -= 2 * np.einsum('rsab,As,Ab,aJrJ->',t_rsab,s_as,s_ab,temp)
result -= 2 * np.einsum('rsab,Is,Ib,aJrJ->',t_rsab,s_is,s_ib,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('rsab,as,IJ,IbrJ->',t_rsab,s_as,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsab,as,Ib,IJrJ->',t_rsab,s_as,s_ib,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsab,aB,Ab,ABrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,aB,AB,Abrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,aJ,AJ,Abrs->',t_rsab,s_aj,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsab,aJ,Ab,AJrs->',t_rsab,s_aj,s_ab,temp)
temp = sapt.vt('abrs')
result += np.einsum('rsab,AB,Ab,aBrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,IB,Ib,aBrs->',t_rsab,s_ib,s_ib,temp)
temp = sapt.vt('ajrs')
result += np.einsum('rsab,AJ,Ab,aJrs->',t_rsab,s_aj,s_ab,temp)
result += np.einsum('rsab,IJ,Ib,aJrs->',t_rsab,s_ij,s_ib,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsab,aB,Ib,IBrs->',t_rsab,s_ab,s_ib,temp)
result += np.einsum('rsab,aB,IB,Ibrs->',t_rsab,s_ab,s_ib,temp)
result += np.einsum('rsab,aJ,IJ,Ibrs->',t_rsab,s_aj,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsab,aJ,Ib,IJrs->',t_rsab,s_aj,s_ib,temp)
temp = sapt.vt('ajab')
result -= np.einsum('rbaj,aB,rB,AjAb->',t_rbaj,s_ab,s_rb,temp)
result -= np.einsum('rbaj,aJ,rJ,AjAb->',t_rbaj,s_aj,s_rj,temp)
result += np.einsum('rbaj,AB,rB,ajAb->',t_rbaj,s_ab,s_rb,temp)
result += np.einsum('rbaj,AJ,rJ,ajAb->',t_rbaj,s_aj,s_rj,temp)
temp = sapt.vt('ajib')
result += np.einsum('rbaj,IB,rB,ajIb->',t_rbaj,s_ib,s_rb,temp)
result += np.einsum('rbaj,IJ,rJ,ajIb->',t_rbaj,s_ij,s_rj,temp)
temp = sapt.vt('ijib')
result -= 2 * np.einsum('rbaj,aB,rB,IjIb->',t_rbaj,s_ab,s_rb,temp)
result -= 2 * np.einsum('rbaj,aJ,rJ,IjIb->',t_rbaj,s_aj,s_rj,temp)
temp = sapt.vt('abrb')
result -= np.einsum('rbaj,Ib,Ij,aBrB->',t_rbaj,s_ib,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rbaj,aB,AB,Ajrb->',t_rbaj,s_ab,s_ab,temp)
result += np.einsum('rbaj,aJ,AJ,Ajrb->',t_rbaj,s_aj,s_aj,temp)
result += np.einsum('rbaj,IJ,Ij,aJrb->',t_rbaj,s_ij,s_ij,temp)
temp = sapt.vt('ijrb')
result += np.einsum('rbaj,aB,IB,Ijrb->',t_rbaj,s_ab,s_ib,temp)
result += np.einsum('rbaj,aJ,IJ,Ijrb->',t_rbaj,s_aj,s_ij,temp)
temp = sapt.vt('ajrj')
result -= 2 * np.einsum('rbaj,Ib,Ij,aJrJ->',t_rbaj,s_ib,s_ij,temp)
result += np.einsum('rbaj,Ib,IJ,ajrJ->',t_rbaj,s_ib,s_ij,temp)
temp = sapt.vt('ajab')
result += np.einsum('rsaj,as,rB,AjAB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('abab')
result += np.einsum('rsaj,As,rj,aBAB->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('ajab')
result -= np.einsum('rsaj,As,rB,ajAB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('ajaj')
result += np.einsum('rsaj,as,rJ,AjAJ->',t_rsaj,s_as,s_rj,temp)
result += 2 * np.einsum('rsaj,As,rj,aJAJ->',t_rsaj,s_as,s_rj,temp)
result -= np.einsum('rsaj,As,rJ,ajAJ->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('abas')
result += np.einsum('rsaj,aB,rj,ABAs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsaj,aJ,rj,AJAs->',t_rsaj,s_aj,s_rj,temp)
result -= 2 * np.einsum('rsaj,aB,rB,AjAs->',t_rsaj,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsaj,aJ,rJ,AjAs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abas')
result -= np.einsum('rsaj,AB,rj,aBAs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('rsaj,AJ,rj,aJAs->',t_rsaj,s_aj,s_rj,temp)
result += 2 * np.einsum('rsaj,AB,rB,ajAs->',t_rsaj,s_ab,s_rb,temp)
result += 2 * np.einsum('rsaj,AJ,rJ,ajAs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abib')
result += np.einsum('rsaj,Is,rj,aBIB->',t_rsaj,s_is,s_rj,temp)
temp = sapt.vt('ajib')
result -= np.einsum('rsaj,Is,rB,ajIB->',t_rsaj,s_is,s_rb,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rsaj,as,rB,IjIB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('rsaj,Is,rj,aJIJ->',t_rsaj,s_is,s_rj,temp)
result -= np.einsum('rsaj,Is,rJ,ajIJ->',t_rsaj,s_is,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rsaj,as,rJ,IjIJ->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('abis')
result -= np.einsum('rsaj,IB,rj,aBIs->',t_rsaj,s_ib,s_rj,temp)
temp = sapt.vt('ajis')
result -= np.einsum('rsaj,IJ,rj,aJIs->',t_rsaj,s_ij,s_rj,temp)
result += 2 * np.einsum('rsaj,IB,rB,ajIs->',t_rsaj,s_ib,s_rb,temp)
result += 2 * np.einsum('rsaj,IJ,rJ,ajIs->',t_rsaj,s_ij,s_rj,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsaj,aB,rj,IBIs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsaj,aJ,rj,IJIs->',t_rsaj,s_aj,s_rj,temp)
result -= 4 * np.einsum('rsaj,aB,rB,IjIs->',t_rsaj,s_ab,s_rb,temp)
result -= 4 * np.einsum('rsaj,aJ,rJ,IjIs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsaj,as,Aj,ABrB->',t_rsaj,s_as,s_aj,temp)
temp = sapt.vt('ajrb')
result -= np.einsum('rsaj,as,AB,AjrB->',t_rsaj,s_as,s_ab,temp)
temp = sapt.vt('abrb')
result -= np.einsum('rsaj,As,Aj,aBrB->',t_rsaj,s_as,s_aj,temp)
result -= 2 * np.einsum('rsaj,Is,Ij,aBrB->',t_rsaj,s_is,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rsaj,As,AB,ajrB->',t_rsaj,s_as,s_ab,temp)
result += np.einsum('rsaj,Is,IB,ajrB->',t_rsaj,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsaj,as,Ij,IBrB->',t_rsaj,s_as,s_ij,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rsaj,as,IB,IjrB->',t_rsaj,s_as,s_ib,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsaj,as,Aj,AJrJ->',t_rsaj,s_as,s_aj,temp)
result -= np.einsum('rsaj,as,AJ,AjrJ->',t_rsaj,s_as,s_aj,temp)
result -= 2 * np.einsum('rsaj,As,Aj,aJrJ->',t_rsaj,s_as,s_aj,temp)
result -= 4 * np.einsum('rsaj,Is,Ij,aJrJ->',t_rsaj,s_is,s_ij,temp)
result += np.einsum('rsaj,As,AJ,ajrJ->',t_rsaj,s_as,s_aj,temp)
result += 2 * np.einsum('rsaj,Is,IJ,ajrJ->',t_rsaj,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsaj,as,Ij,IJrJ->',t_rsaj,s_as,s_ij,temp)
result -= np.einsum('rsaj,as,IJ,IjrJ->',t_rsaj,s_as,s_ij,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsaj,aB,Aj,ABrs->',t_rsaj,s_ab,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsaj,aJ,Aj,AJrs->',t_rsaj,s_aj,s_aj,temp)
result += 2 * np.einsum('rsaj,aB,AB,Ajrs->',t_rsaj,s_ab,s_ab,temp)
result += 2 * np.einsum('rsaj,aJ,AJ,Ajrs->',t_rsaj,s_aj,s_aj,temp)
temp = sapt.vt('abrs')
result += np.einsum('rsaj,AB,Aj,aBrs->',t_rsaj,s_ab,s_aj,temp)
result += np.einsum('rsaj,IB,Ij,aBrs->',t_rsaj,s_ib,s_ij,temp)
temp = sapt.vt('ajrs')
result += np.einsum('rsaj,AJ,Aj,aJrs->',t_rsaj,s_aj,s_aj,temp)
result += 2 * np.einsum('rsaj,IJ,Ij,aJrs->',t_rsaj,s_ij,s_ij,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsaj,aB,Ij,IBrs->',t_rsaj,s_ab,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsaj,aJ,Ij,IJrs->',t_rsaj,s_aj,s_ij,temp)
result += 2 * np.einsum('rsaj,aB,IB,Ijrs->',t_rsaj,s_ab,s_ib,temp)
result += 2 * np.einsum('rsaj,aJ,IJ,Ijrs->',t_rsaj,s_aj,s_ij,temp)
temp = sapt.vt('abas')
result -= np.einsum('asib,iJ,aJ,AbAs->',t_asib,s_ij,s_aj,temp)
temp = sapt.vt('ibab')
result -= np.einsum('asib,As,Ab,iBaB->',t_asib,s_as,s_ab,temp)
result -= np.einsum('asib,Is,Ib,iBaB->',t_asib,s_is,s_ib,temp)
result += np.einsum('asib,As,AB,ibaB->',t_asib,s_as,s_ab,temp)
result += np.einsum('asib,Is,IB,ibaB->',t_asib,s_is,s_ib,temp)
temp = sapt.vt('ibaj')
result += np.einsum('asib,As,AJ,ibaJ->',t_asib,s_as,s_aj,temp)
result += np.einsum('asib,Is,IJ,ibaJ->',t_asib,s_is,s_ij,temp)
temp = sapt.vt('ijaj')
result -= 2 * np.einsum('asib,As,Ab,iJaJ->',t_asib,s_as,s_ab,temp)
result -= 2 * np.einsum('asib,Is,Ib,iJaJ->',t_asib,s_is,s_ib,temp)
temp = sapt.vt('ibas')
result += np.einsum('asib,iJ,IJ,Ibas->',t_asib,s_ij,s_ij,temp)
result += np.einsum('asib,AB,Ab,iBas->',t_asib,s_ab,s_ab,temp)
result += np.einsum('asib,IB,Ib,iBas->',t_asib,s_ib,s_ib,temp)
temp = sapt.vt('ijas')
result += np.einsum('asib,AJ,Ab,iJas->',t_asib,s_aj,s_ab,temp)
result += np.einsum('asib,IJ,Ib,iJas->',t_asib,s_ij,s_ib,temp)
temp = sapt.vt('ibis')
result -= 2 * np.einsum('asib,iJ,aJ,IbIs->',t_asib,s_ij,s_aj,temp)
result += np.einsum('asib,IJ,aJ,ibIs->',t_asib,s_ij,s_aj,temp)
temp = sapt.vt('abab')
result += np.einsum('rsib,is,rB,AbAB->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibab')
result += np.einsum('rsib,As,rb,iBAB->',t_rsib,s_as,s_rb,temp)
result -= np.einsum('rsib,As,rB,ibAB->',t_rsib,s_as,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('rsib,is,rJ,AbAJ->',t_rsib,s_is,s_rj,temp)
temp = sapt.vt('ibaj')
result -= np.einsum('rsib,As,rJ,ibAJ->',t_rsib,s_as,s_rj,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('rsib,As,rb,iJAJ->',t_rsib,s_as,s_rb,temp)
temp = sapt.vt('abas')
result += np.einsum('rsib,iB,rb,ABAs->',t_rsib,s_ib,s_rb,temp)
result -= np.einsum('rsib,iB,rB,AbAs->',t_rsib,s_ib,s_rb,temp)
result -= 2 * np.einsum('rsib,iJ,rJ,AbAs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsib,iJ,rb,AJAs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('ibas')
result -= np.einsum('rsib,AB,rb,iBAs->',t_rsib,s_ab,s_rb,temp)
result += np.einsum('rsib,AB,rB,ibAs->',t_rsib,s_ab,s_rb,temp)
result += np.einsum('rsib,AJ,rJ,ibAs->',t_rsib,s_aj,s_rj,temp)
temp = sapt.vt('ijas')
result -= np.einsum('rsib,AJ,rb,iJAs->',t_rsib,s_aj,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsib,is,rB,IbIB->',t_rsib,s_is,s_rb,temp)
result += np.einsum('rsib,Is,rb,iBIB->',t_rsib,s_is,s_rb,temp)
result -= np.einsum('rsib,Is,rB,ibIB->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('rsib,is,rJ,IbIJ->',t_rsib,s_is,s_rj,temp)
result -= np.einsum('rsib,Is,rJ,ibIJ->',t_rsib,s_is,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rsib,Is,rb,iJIJ->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsib,iB,rb,IBIs->',t_rsib,s_ib,s_rb,temp)
result -= 2 * np.einsum('rsib,iB,rB,IbIs->',t_rsib,s_ib,s_rb,temp)
result -= 4 * np.einsum('rsib,iJ,rJ,IbIs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsib,iJ,rb,IJIs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('ibis')
result -= np.einsum('rsib,IB,rb,iBIs->',t_rsib,s_ib,s_rb,temp)
result += np.einsum('rsib,IB,rB,ibIs->',t_rsib,s_ib,s_rb,temp)
result += 2 * np.einsum('rsib,IJ,rJ,ibIs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ijis')
result -= np.einsum('rsib,IJ,rb,iJIs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsib,is,Ab,ABrB->',t_rsib,s_is,s_ab,temp)
result -= np.einsum('rsib,is,AB,AbrB->',t_rsib,s_is,s_ab,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsib,is,Ib,IBrB->',t_rsib,s_is,s_ib,temp)
result -= np.einsum('rsib,is,IB,IbrB->',t_rsib,s_is,s_ib,temp)
result -= 2 * np.einsum('rsib,As,Ab,iBrB->',t_rsib,s_as,s_ab,temp)
result -= 2 * np.einsum('rsib,Is,Ib,iBrB->',t_rsib,s_is,s_ib,temp)
result += 2 * np.einsum('rsib,As,AB,ibrB->',t_rsib,s_as,s_ab,temp)
result += 2 * np.einsum('rsib,Is,IB,ibrB->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('abrj')
result -= np.einsum('rsib,is,AJ,AbrJ->',t_rsib,s_is,s_aj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsib,is,Ab,AJrJ->',t_rsib,s_is,s_ab,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('rsib,is,IJ,IbrJ->',t_rsib,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsib,is,Ib,IJrJ->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('ibrj')
result += 2 * np.einsum('rsib,As,AJ,ibrJ->',t_rsib,s_as,s_aj,temp)
result += 2 * np.einsum('rsib,Is,IJ,ibrJ->',t_rsib,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result -= 4 * np.einsum('rsib,As,Ab,iJrJ->',t_rsib,s_as,s_ab,temp)
result -= 4 * np.einsum('rsib,Is,Ib,iJrJ->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsib,iB,Ab,ABrs->',t_rsib,s_ib,s_ab,temp)
result += np.einsum('rsib,iB,AB,Abrs->',t_rsib,s_ib,s_ab,temp)
result += np.einsum('rsib,iJ,AJ,Abrs->',t_rsib,s_ij,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsib,iJ,Ab,AJrs->',t_rsib,s_ij,s_ab,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsib,iB,Ib,IBrs->',t_rsib,s_ib,s_ib,temp)
result += np.einsum('rsib,iB,IB,Ibrs->',t_rsib,s_ib,s_ib,temp)
result += 2 * np.einsum('rsib,iJ,IJ,Ibrs->',t_rsib,s_ij,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsib,iJ,Ib,IJrs->',t_rsib,s_ij,s_ib,temp)
temp = sapt.vt('ibrs')
result += 2 * np.einsum('rsib,AB,Ab,iBrs->',t_rsib,s_ab,s_ab,temp)
result += 2 * np.einsum('rsib,IB,Ib,iBrs->',t_rsib,s_ib,s_ib,temp)
temp = sapt.vt('ijrs')
result += 2 * np.einsum('rsib,AJ,Ab,iJrs->',t_rsib,s_aj,s_ab,temp)
result += 2 * np.einsum('rsib,IJ,Ib,iJrs->',t_rsib,s_ij,s_ib,temp)
temp = sapt.vt('ajab')
result += np.einsum('abij,iJ,aj,AJAb->',t_abij,s_ij,s_aj,temp)
result -= np.einsum('abij,iJ,aJ,AjAb->',t_abij,s_ij,s_aj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('abij,ib,aJ,AjAJ->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ibab')
result += np.einsum('abij,ib,Ij,IBaB->',t_abij,s_ib,s_ij,temp)
result -= np.einsum('abij,Ib,Ij,iBaB->',t_abij,s_ib,s_ij,temp)
temp = sapt.vt('ijab')
result -= np.einsum('abij,iJ,Ij,IJab->',t_abij,s_ij,s_ij,temp)
result += np.einsum('abij,iJ,IJ,Ijab->',t_abij,s_ij,s_ij,temp)
result += np.einsum('abij,IJ,Ij,iJab->',t_abij,s_ij,s_ij,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('abij,ib,Ij,IJaJ->',t_abij,s_ib,s_ij,temp)
result -= np.einsum('abij,ib,IJ,IjaJ->',t_abij,s_ib,s_ij,temp)
result -= 2 * np.einsum('abij,Ib,Ij,iJaJ->',t_abij,s_ib,s_ij,temp)
result += np.einsum('abij,Ib,IJ,ijaJ->',t_abij,s_ib,s_ij,temp)
temp = sapt.vt('ibib')
result += np.einsum('abij,Ib,aj,iBIB->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('abij,iJ,aj,IJIb->',t_abij,s_ij,s_aj,temp)
result -= 2 * np.einsum('abij,iJ,aJ,IjIb->',t_abij,s_ij,s_aj,temp)
result -= np.einsum('abij,IJ,aj,iJIb->',t_abij,s_ij,s_aj,temp)
result += np.einsum('abij,IJ,aJ,ijIb->',t_abij,s_ij,s_aj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('abij,ib,aJ,IjIJ->',t_abij,s_ib,s_aj,temp)
result += 2 * np.einsum('abij,Ib,aj,iJIJ->',t_abij,s_ib,s_aj,temp)
result -= np.einsum('abij,Ib,aJ,ijIJ->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('asij,is,aJ,AjAJ->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ajas')
result += np.einsum('asij,iJ,aj,AJAs->',t_asij,s_ij,s_aj,temp)
result -= 2 * np.einsum('asij,iJ,aJ,AjAs->',t_asij,s_ij,s_aj,temp)
temp = sapt.vt('ibab')
result += np.einsum('asij,is,Ij,IBaB->',t_asij,s_is,s_ij,temp)
result -= np.einsum('asij,As,Aj,iBaB->',t_asij,s_as,s_aj,temp)
result -= 2 * np.einsum('asij,Is,Ij,iBaB->',t_asij,s_is,s_ij,temp)
temp = sapt.vt('ijab')
result += np.einsum('asij,As,AB,ijaB->',t_asij,s_as,s_ab,temp)
result += np.einsum('asij,Is,IB,ijaB->',t_asij,s_is,s_ib,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('asij,is,Ij,IJaJ->',t_asij,s_is,s_ij,temp)
result -= np.einsum('asij,is,IJ,IjaJ->',t_asij,s_is,s_ij,temp)
result -= 2 * np.einsum('asij,As,Aj,iJaJ->',t_asij,s_as,s_aj,temp)
result -= 4 * np.einsum('asij,Is,Ij,iJaJ->',t_asij,s_is,s_ij,temp)
result += np.einsum('asij,As,AJ,ijaJ->',t_asij,s_as,s_aj,temp)
result += 2 * np.einsum('asij,Is,IJ,ijaJ->',t_asij,s_is,s_ij,temp)
temp = sapt.vt('ijas')
result -= np.einsum('asij,iJ,Ij,IJas->',t_asij,s_ij,s_ij,temp)
result += 2 * np.einsum('asij,iJ,IJ,Ijas->',t_asij,s_ij,s_ij,temp)
temp = sapt.vt('ibas')
result += np.einsum('asij,AB,Aj,iBas->',t_asij,s_ab,s_aj,temp)
result += np.einsum('asij,IB,Ij,iBas->',t_asij,s_ib,s_ij,temp)
temp = sapt.vt('ijas')
result += np.einsum('asij,AJ,Aj,iJas->',t_asij,s_aj,s_aj,temp)
result += 2 * np.einsum('asij,IJ,Ij,iJas->',t_asij,s_ij,s_ij,temp)
temp = sapt.vt('ibib')
result += np.einsum('asij,Is,aj,iBIB->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('asij,is,aJ,IjIJ->',t_asij,s_is,s_aj,temp)
result += 2 * np.einsum('asij,Is,aj,iJIJ->',t_asij,s_is,s_aj,temp)
result -= np.einsum('asij,Is,aJ,ijIJ->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('asij,iJ,aj,IJIs->',t_asij,s_ij,s_aj,temp)
result -= 4 * np.einsum('asij,iJ,aJ,IjIs->',t_asij,s_ij,s_aj,temp)
result -= np.einsum('asij,IJ,aj,iJIs->',t_asij,s_ij,s_aj,temp)
result += 2 * np.einsum('asij,IJ,aJ,ijIs->',t_asij,s_ij,s_aj,temp)
temp = sapt.vt('ajab')
result += np.einsum('rbij,iJ,rj,AJAb->',t_rbij,s_ij,s_rj,temp)
result -= np.einsum('rbij,iB,rB,AjAb->',t_rbij,s_ib,s_rb,temp)
result -= 2 * np.einsum('rbij,iJ,rJ,AjAb->',t_rbij,s_ij,s_rj,temp)
temp = sapt.vt('ijab')
result += np.einsum('rbij,AB,rB,ijAb->',t_rbij,s_ab,s_rb,temp)
result += np.einsum('rbij,AJ,rJ,ijAb->',t_rbij,s_aj,s_rj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('rbij,ib,rJ,AjAJ->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ibib')
result += np.einsum('rbij,Ib,rj,iBIB->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rbij,iJ,rj,IJIb->',t_rbij,s_ij,s_rj,temp)
result -= 2 * np.einsum('rbij,iB,rB,IjIb->',t_rbij,s_ib,s_rb,temp)
result -= 4 * np.einsum('rbij,iJ,rJ,IjIb->',t_rbij,s_ij,s_rj,temp)
result -= np.einsum('rbij,IJ,rj,iJIb->',t_rbij,s_ij,s_rj,temp)
result += np.einsum('rbij,IB,rB,ijIb->',t_rbij,s_ib,s_rb,temp)
result += 2 * np.einsum('rbij,IJ,rJ,ijIb->',t_rbij,s_ij,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rbij,ib,rJ,IjIJ->',t_rbij,s_ib,s_rj,temp)
result += 2 * np.einsum('rbij,Ib,rj,iJIJ->',t_rbij,s_ib,s_rj,temp)
result -= np.einsum('rbij,Ib,rJ,ijIJ->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rbij,ib,Ij,IBrB->',t_rbij,s_ib,s_ij,temp)
result -= 2 * np.einsum('rbij,Ib,Ij,iBrB->',t_rbij,s_ib,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rbij,iB,AB,Ajrb->',t_rbij,s_ib,s_ab,temp)
result += np.einsum('rbij,iJ,AJ,Ajrb->',t_rbij,s_ij,s_aj,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rbij,iJ,Ij,IJrb->',t_rbij,s_ij,s_ij,temp)
result += np.einsum('rbij,iB,IB,Ijrb->',t_rbij,s_ib,s_ib,temp)
result += 2 * np.einsum('rbij,iJ,IJ,Ijrb->',t_rbij,s_ij,s_ij,temp)
result += 2 * np.einsum('rbij,IJ,Ij,iJrb->',t_rbij,s_ij,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rbij,ib,Ij,IJrJ->',t_rbij,s_ib,s_ij,temp)
result -= np.einsum('rbij,ib,IJ,IjrJ->',t_rbij,s_ib,s_ij,temp)
result -= 4 * np.einsum('rbij,Ib,Ij,iJrJ->',t_rbij,s_ib,s_ij,temp)
result += 2 * np.einsum('rbij,Ib,IJ,ijrJ->',t_rbij,s_ib,s_ij,temp)
temp = sapt.vt('ajab')
result += np.einsum('rsij,is,rB,AjAB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ibab')
result += np.einsum('rsij,As,rj,iBAB->',t_rsij,s_as,s_rj,temp)
temp = sapt.vt('ijab')
result -= np.einsum('rsij,As,rB,ijAB->',t_rsij,s_as,s_rb,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('rsij,is,rJ,AjAJ->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('rsij,As,rj,iJAJ->',t_rsij,s_as,s_rj,temp)
result -= np.einsum('rsij,As,rJ,ijAJ->',t_rsij,s_as,s_rj,temp)
temp = sapt.vt('abas')
result += np.einsum('rsij,iB,rj,ABAs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ajas')
result += 2 * np.einsum('rsij,iJ,rj,AJAs->',t_rsij,s_ij,s_rj,temp)
result -= 2 * np.einsum('rsij,iB,rB,AjAs->',t_rsij,s_ib,s_rb,temp)
result -= 4 * np.einsum('rsij,iJ,rJ,AjAs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('ibas')
result -= np.einsum('rsij,AB,rj,iBAs->',t_rsij,s_ab,s_rj,temp)
temp = sapt.vt('ijas')
result -= np.einsum('rsij,AJ,rj,iJAs->',t_rsij,s_aj,s_rj,temp)
result += 2 * np.einsum('rsij,AB,rB,ijAs->',t_rsij,s_ab,s_rb,temp)
result += 2 * np.einsum('rsij,AJ,rJ,ijAs->',t_rsij,s_aj,s_rj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rsij,is,rB,IjIB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsij,Is,rj,iBIB->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ijib')
result -= np.einsum('rsij,Is,rB,ijIB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ijij')
result += 4 * np.einsum('rsij,is,rJ,IjIJ->',t_rsij,s_is,s_rj,temp)
result += 4 * np.einsum('rsij,Is,rj,iJIJ->',t_rsij,s_is,s_rj,temp)
result -= 2 * np.einsum('rsij,Is,rJ,ijIJ->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsij,iB,rj,IBIs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ijis')
result += 4 * np.einsum('rsij,iJ,rj,IJIs->',t_rsij,s_ij,s_rj,temp)
result -= 4 * np.einsum('rsij,iB,rB,IjIs->',t_rsij,s_ib,s_rb,temp)
result -= 8 * np.einsum('rsij,iJ,rJ,IjIs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('ibis')
result -= np.einsum('rsij,IB,rj,iBIs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ijis')
result -= 2 * np.einsum('rsij,IJ,rj,iJIs->',t_rsij,s_ij,s_rj,temp)
result += 2 * np.einsum('rsij,IB,rB,ijIs->',t_rsij,s_ib,s_rb,temp)
result += 4 * np.einsum('rsij,IJ,rJ,ijIs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsij,is,Aj,ABrB->',t_rsij,s_is,s_aj,temp)
temp = sapt.vt('ajrb')
result -= np.einsum('rsij,is,AB,AjrB->',t_rsij,s_is,s_ab,temp)
temp = sapt.vt('ibrb')
result += 2 * np.einsum('rsij,is,Ij,IBrB->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rsij,is,IB,IjrB->',t_rsij,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result -= 2 * np.einsum('rsij,As,Aj,iBrB->',t_rsij,s_as,s_aj,temp)
result -= 4 * np.einsum('rsij,Is,Ij,iBrB->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('ijrb')
result += 2 * np.einsum('rsij,As,AB,ijrB->',t_rsij,s_as,s_ab,temp)
result += 2 * np.einsum('rsij,Is,IB,ijrB->',t_rsij,s_is,s_ib,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsij,is,Aj,AJrJ->',t_rsij,s_is,s_aj,temp)
result -= np.einsum('rsij,is,AJ,AjrJ->',t_rsij,s_is,s_aj,temp)
temp = sapt.vt('ijrj')
result += 4 * np.einsum('rsij,is,Ij,IJrJ->',t_rsij,s_is,s_ij,temp)
result -= 2 * np.einsum('rsij,is,IJ,IjrJ->',t_rsij,s_is,s_ij,temp)
result -= 4 * np.einsum('rsij,As,Aj,iJrJ->',t_rsij,s_as,s_aj,temp)
result -= 8 * np.einsum('rsij,Is,Ij,iJrJ->',t_rsij,s_is,s_ij,temp)
result += 2 * np.einsum('rsij,As,AJ,ijrJ->',t_rsij,s_as,s_aj,temp)
result += 4 * np.einsum('rsij,Is,IJ,ijrJ->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsij,iB,Aj,ABrs->',t_rsij,s_ib,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsij,iJ,Aj,AJrs->',t_rsij,s_ij,s_aj,temp)
result += 2 * np.einsum('rsij,iB,AB,Ajrs->',t_rsij,s_ib,s_ab,temp)
result += 2 * np.einsum('rsij,iJ,AJ,Ajrs->',t_rsij,s_ij,s_aj,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsij,iB,Ij,IBrs->',t_rsij,s_ib,s_ij,temp)
temp = sapt.vt('ijrs')
result -= 2 * np.einsum('rsij,iJ,Ij,IJrs->',t_rsij,s_ij,s_ij,temp)
result += 2 * np.einsum('rsij,iB,IB,Ijrs->',t_rsij,s_ib,s_ib,temp)
result += 4 * np.einsum('rsij,iJ,IJ,Ijrs->',t_rsij,s_ij,s_ij,temp)
temp = sapt.vt('ibrs')
result += 2 * np.einsum('rsij,AB,Aj,iBrs->',t_rsij,s_ab,s_aj,temp)
result += 2 * np.einsum('rsij,IB,Ij,iBrs->',t_rsij,s_ib,s_ij,temp)
temp = sapt.vt('ijrs')
result += 2 * np.einsum('rsij,AJ,Aj,iJrs->',t_rsij,s_aj,s_aj,temp)
result += 4 * np.einsum('rsij,IJ,Ij,iJrs->',t_rsij,s_ij,s_ij,temp)
#end autogenerated stuff

ExchDisp20 = result
disp_timer.stop()
### End E200 Exchange-Dispersion

### Start E200 Induction and Exchange-Induction
#in this variant, no CPHF response will be calculated

# E200Induction and CPHF orbitals
ind_timer = sapt_timer('induction')

omb_ir = 2 * np.einsum('ijrj->ir',sapt.vt('ijrj')) + np.einsum('ibrb->ir',sapt.vt('ibrb'))
omb_ia = 2 * np.einsum('ijaj->ia',sapt.vt('ijaj')) + np.einsum('ibab->ia',sapt.vt('ibab'))
omb_ar = 2 * np.einsum('ajrj->ar',sapt.vt('ajrj')) + np.einsum('abrb->ar',sapt.vt('abrb'))
oma_js = 2 * np.einsum('ijis->js',sapt.vt('ijis')) + np.einsum('ajas->js',sapt.vt('ajas'))
oma_jb = 2 * np.einsum('ijib->jb',sapt.vt('ijib')) + np.einsum('ajab->jb',sapt.vt('ajab'))
oma_bs = 2 * np.einsum('ibis->bs',sapt.vt('ibis')) + np.einsum('abas->bs',sapt.vt('abas'))
e_ir = 1/(sapt.eps('i', dim=2) - sapt.eps('r'))
e_ia = 1/(sapt.eps('i', dim=2) - sapt.eps('a'))
e_ar = 1/(sapt.eps('a', dim=2) - sapt.eps('r'))
e_js = 1/(sapt.eps('j', dim=2) - sapt.eps('s'))
e_jb = 1/(sapt.eps('j', dim=2) - sapt.eps('b'))
e_bs = 1/(sapt.eps('b', dim=2) - sapt.eps('s'))
ind_ir = np.einsum('ir,ir->ir', omb_ir, e_ir)
ind_ia = np.einsum('ia,ia->ia', omb_ia, e_ia)
ind_ar = np.einsum('ar,ar->ar', omb_ar, e_ar)
ind_js = np.einsum('js,js->js', oma_js, e_js)
ind_jb = np.einsum('jb,jb->jb', oma_jb, e_jb)
ind_bs = np.einsum('bs,bs->bs', oma_bs, e_bs)

Ind20_ab = 2 * np.einsum('ir,ir->',omb_ir,ind_ir)
Ind20_ab += np.einsum('ia,ia->',omb_ia,ind_ia)
Ind20_ab += np.einsum('ar,ar->',omb_ar,ind_ar)
Ind20_ba = 2 * np.einsum('js,js->',oma_js,ind_js)
Ind20_ba += np.einsum('jb,jb->',oma_jb,ind_jb)
Ind20_ba += np.einsum('bs,bs->',oma_bs,ind_bs)

Ind20r = Ind20_ba + Ind20_ab

# Exchange-Induction

# A <- B
result = 0.0
#automatically programmed stuff below
temp = sapt.vt('abbr')
result -= np.einsum('ar,abbr->',ind_ar,temp)
temp = sapt.vt('ajjr')
result -= np.einsum('ar,ajjr->',ind_ar,temp)
temp = sapt.vt('ijja')
result -= np.einsum('ia,ijja->',ind_ia,temp)
temp = sapt.vt('ibbr')
result -= np.einsum('ir,ibbr->',ind_ir,temp)
temp = sapt.vt('ijjr')
result -= 2 * np.einsum('ir,ijjr->',ind_ir,temp)
temp = sapt.vt('abar')
result += np.einsum('ar,Ab,abAr->',ind_ar,s_ab,temp)
result -= np.einsum('ar,ab,AbAr->',ind_ar,s_ab,temp)
result -= np.einsum('ir,ib,AbAr->',ind_ir,s_ib,temp)
temp = sapt.vt('abra')
result -= np.einsum('ar,Ab,abrA->',ind_ar,s_ab,temp)
result += np.einsum('ar,ab,AbrA->',ind_ar,s_ab,temp)
result += np.einsum('ir,ib,AbrA->',ind_ir,s_ib,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('ar,ab,IbIr->',ind_ar,s_ab,temp)
result += np.einsum('ir,Ib,ibIr->',ind_ir,s_ib,temp)
result -= 2 * np.einsum('ir,ib,IbIr->',ind_ir,s_ib,temp)
temp = sapt.vt('ibri')
result += np.einsum('ir,ib,IbrI->',ind_ir,s_ib,temp)
result += np.einsum('ar,ab,IbrI->',ind_ar,s_ab,temp)
result -= 2 * np.einsum('ir,Ib,ibrI->',ind_ir,s_ib,temp)
temp = sapt.vt('abir')
result += np.einsum('ar,Ib,abIr->',ind_ar,s_ib,temp)
temp = sapt.vt('abri')
result -= np.einsum('ar,Ib,abrI->',ind_ar,s_ib,temp)
temp = sapt.vt('ibar')
result += np.einsum('ir,Ab,ibAr->',ind_ir,s_ab,temp)
temp = sapt.vt('ibra')
result -= 2 * np.einsum('ir,Ab,ibrA->',ind_ir,s_ab,temp)
temp = sapt.vt('ajar')
result += np.einsum('ar,Aj,ajAr->',ind_ar,s_aj,temp)
result -= np.einsum('ar,aj,AjAr->',ind_ar,s_aj,temp)
result -= 2 * np.einsum('ir,ij,AjAr->',ind_ir,s_ij,temp)
temp = sapt.vt('ajra')
result -= np.einsum('ar,Aj,ajrA->',ind_ar,s_aj,temp)
result += np.einsum('ar,aj,AjrA->',ind_ar,s_aj,temp)
result += np.einsum('ir,ij,AjrA->',ind_ir,s_ij,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('ar,aj,IjIr->',ind_ar,s_aj,temp)
result += 2 * np.einsum('ir,Ij,ijIr->',ind_ir,s_ij,temp)
result -= 4 * np.einsum('ir,ij,IjIr->',ind_ir,s_ij,temp)
temp = sapt.vt('ijri')
result += np.einsum('ar,aj,IjrI->',ind_ar,s_aj,temp)
result += 2 * np.einsum('ir,ij,IjrI->',ind_ir,s_ij,temp)
result -= 4 * np.einsum('ir,Ij,ijrI->',ind_ir,s_ij,temp)
temp = sapt.vt('ajir')
result += np.einsum('ar,Ij,ajIr->',ind_ar,s_ij,temp)
temp = sapt.vt('ajri')
result -= 2 * np.einsum('ar,Ij,ajrI->',ind_ar,s_ij,temp)
temp = sapt.vt('abbb')
result -= np.einsum('ar,rB,abBb->',ind_ar,s_rb,temp)
result += np.einsum('ar,rb,aBBb->',ind_ar,s_rb,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('ir,rB,ibBb->',ind_ir,s_rb,temp)
result += np.einsum('ir,rb,iBBb->',ind_ir,s_rb,temp)
temp = sapt.vt('ajbj')
result -= 2 * np.einsum('ar,rB,ajBj->',ind_ar,s_rb,temp)
temp = sapt.vt('ajjb')
result += np.einsum('ar,rb,aJJb->',ind_ar,s_rb,temp)
temp = sapt.vt('abjb')
result -= np.einsum('ar,rJ,abJb->',ind_ar,s_rj,temp)
temp = sapt.vt('ajjj')
result -= 2 * np.einsum('ar,rJ,ajJj->',ind_ar,s_rj,temp)
temp = sapt.vt('abbj')
result += np.einsum('ar,rj,aBBj->',ind_ar,s_rj,temp)
temp = sapt.vt('ajjj')
result += np.einsum('ar,rj,aJJj->',ind_ar,s_rj,temp)
temp = sapt.vt('ibjb')
result -= np.einsum('ia,aJ,ibJb->',ind_ia,s_aj,temp)
result -= 2 * np.einsum('ir,rJ,ibJb->',ind_ir,s_rj,temp)
temp = sapt.vt('ijjj')
result -= 2 * np.einsum('ia,aJ,ijJj->',ind_ia,s_aj,temp)
result += np.einsum('ia,aj,iJJj->',ind_ia,s_aj,temp)
result -= 4 * np.einsum('ir,rJ,ijJj->',ind_ir,s_rj,temp)
result += 2 * np.einsum('ir,rj,iJJj->',ind_ir,s_rj,temp)
temp = sapt.vt('ibaa')
result -= np.einsum('ia,Ab,ibaA->',ind_ia,s_ab,temp)
temp = sapt.vt('ibai')
result -= np.einsum('ia,Ib,ibaI->',ind_ia,s_ib,temp)
temp = sapt.vt('ijaa')
result -= np.einsum('ia,Aj,ijaA->',ind_ia,s_aj,temp)
temp = sapt.vt('ijai')
result -= 2 * np.einsum('ia,Ij,ijaI->',ind_ia,s_ij,temp)
result += np.einsum('ia,ij,IjaI->',ind_ia,s_ij,temp)
temp = sapt.vt('ijia')
result += np.einsum('ia,Ij,ijIa->',ind_ia,s_ij,temp)
result -= 2 * np.einsum('ia,ij,IjIa->',ind_ia,s_ij,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('ia,ij,AjAa->',ind_ia,s_ij,temp)
temp = sapt.vt('ijar')
result += np.einsum('ir,Aj,ijAr->',ind_ir,s_aj,temp)
temp = sapt.vt('ijra')
result -= 2 * np.einsum('ir,Aj,ijrA->',ind_ir,s_aj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('ir,rB,ijBj->',ind_ir,s_rb,temp)
temp = sapt.vt('ijjb')
result += np.einsum('ir,rb,iJJb->',ind_ir,s_rb,temp)
temp = sapt.vt('ibbj')
result += np.einsum('ir,rj,iBBj->',ind_ir,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('ar,AB,Ab,aBrb->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,aB,AB,Abrb->',ind_ar,s_ab,s_ab,temp)
result -= np.einsum('ar,aB,Ab,ABrb->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,IB,Ib,aBrb->',ind_ar,s_ib,s_ib,temp)
result += np.einsum('ar,aJ,AJ,Abrb->',ind_ar,s_aj,s_aj,temp)
result += np.einsum('ir,iB,AB,Abrb->',ind_ir,s_ib,s_ab,temp)
result -= np.einsum('ir,iB,Ab,ABrb->',ind_ir,s_ib,s_ab,temp)
result += np.einsum('ir,iJ,AJ,Abrb->',ind_ir,s_ij,s_aj,temp)
temp = sapt.vt('abrj')
result -= np.einsum('ir,iB,Aj,ABrj->',ind_ir,s_ib,s_aj,temp)
result += np.einsum('ar,AB,Aj,aBrj->',ind_ar,s_ab,s_aj,temp)
result -= np.einsum('ar,aB,Aj,ABrj->',ind_ar,s_ab,s_aj,temp)
result += np.einsum('ar,IB,Ij,aBrj->',ind_ar,s_ib,s_ij,temp)
temp = sapt.vt('abab')
result += np.einsum('ar,AB,rB,abAb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ar,aB,rb,ABAb->',ind_ar,s_ab,s_rb,temp)
result -= np.einsum('ar,AB,rb,aBAb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ar,AJ,rJ,abAb->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ir,iB,rb,ABAb->',ind_ir,s_ib,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('ir,iB,rj,ABAj->',ind_ir,s_ib,s_rj,temp)
result -= np.einsum('ar,AB,rj,aBAj->',ind_ar,s_ab,s_rj,temp)
result += np.einsum('ar,aB,rj,ABAj->',ind_ar,s_ab,s_rj,temp)
temp = sapt.vt('abib')
result += np.einsum('ar,IB,rB,abIb->',ind_ar,s_ib,s_rb,temp)
result -= np.einsum('ar,IB,rb,aBIb->',ind_ar,s_ib,s_rb,temp)
result += np.einsum('ar,IJ,rJ,abIb->',ind_ar,s_ij,s_rj,temp)
temp = sapt.vt('abij')
result -= np.einsum('ar,IB,rj,aBIj->',ind_ar,s_ib,s_rj,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('ar,IB,rB,ajIj->',ind_ar,s_ib,s_rb,temp)
result += 2 * np.einsum('ar,IJ,rJ,ajIj->',ind_ar,s_ij,s_rj,temp)
result -= np.einsum('ar,IJ,rj,aJIj->',ind_ar,s_ij,s_rj,temp)
temp = sapt.vt('ajib')
result -= np.einsum('ar,IJ,rb,aJIb->',ind_ar,s_ij,s_rb,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('ar,AB,rB,ajAj->',ind_ar,s_ab,s_rb,temp)
result += 2 * np.einsum('ar,AJ,rJ,ajAj->',ind_ar,s_aj,s_rj,temp)
result -= np.einsum('ar,AJ,rj,aJAj->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ar,aJ,rj,AJAj->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ia,iJ,aj,AJAj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ir,iJ,rj,AJAj->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('ar,aB,AB,Ajrj->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,AJ,Aj,aJrj->',ind_ar,s_aj,s_aj,temp)
result += 2 * np.einsum('ar,aJ,AJ,Ajrj->',ind_ar,s_aj,s_aj,temp)
result -= np.einsum('ar,aJ,Aj,AJrj->',ind_ar,s_aj,s_aj,temp)
result += 2 * np.einsum('ar,IJ,Ij,aJrj->',ind_ar,s_ij,s_ij,temp)
result += 2 * np.einsum('ir,iB,AB,Ajrj->',ind_ir,s_ib,s_ab,temp)
result += 2 * np.einsum('ir,iJ,AJ,Ajrj->',ind_ir,s_ij,s_aj,temp)
result -= np.einsum('ir,iJ,Aj,AJrj->',ind_ir,s_ij,s_aj,temp)
temp = sapt.vt('ajab')
result -= np.einsum('ar,AJ,rb,aJAb->',ind_ar,s_aj,s_rb,temp)
result += np.einsum('ar,aJ,rb,AJAb->',ind_ar,s_aj,s_rb,temp)
result += np.einsum('ir,iJ,rb,AJAb->',ind_ir,s_ij,s_rb,temp)
temp = sapt.vt('ajrb')
result += np.einsum('ar,AJ,Ab,aJrb->',ind_ar,s_aj,s_ab,temp)
result -= np.einsum('ar,aJ,Ab,AJrb->',ind_ar,s_aj,s_ab,temp)
result += np.einsum('ar,IJ,Ib,aJrb->',ind_ar,s_ij,s_ib,temp)
result -= np.einsum('ir,iJ,Ab,AJrb->',ind_ir,s_ij,s_ab,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('ar,aJ,rj,IJIj->',ind_ar,s_aj,s_rj,temp)
result += 2 * np.einsum('ia,IJ,aJ,ijIj->',ind_ia,s_ij,s_aj,temp)
result -= np.einsum('ia,IJ,aj,iJIj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ia,iJ,aj,IJIj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ir,IB,rB,ijIj->',ind_ir,s_ib,s_rb,temp)
result += 4 * np.einsum('ir,iJ,rj,IJIj->',ind_ir,s_ij,s_rj,temp)
result += 4 * np.einsum('ir,IJ,rJ,ijIj->',ind_ir,s_ij,s_rj,temp)
result -= 2 * np.einsum('ir,IJ,rj,iJIj->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ijaj')
result += np.einsum('ia,AJ,Aj,iJaj->',ind_ia,s_aj,s_aj,temp)
result += 2 * np.einsum('ia,IJ,Ij,iJaj->',ind_ia,s_ij,s_ij,temp)
result += 2 * np.einsum('ia,iJ,IJ,Ijaj->',ind_ia,s_ij,s_ij,temp)
result -= np.einsum('ia,iJ,Ij,IJaj->',ind_ia,s_ij,s_ij,temp)
result += 2 * np.einsum('ir,AB,rB,ijAj->',ind_ir,s_ab,s_rb,temp)
result += 2 * np.einsum('ir,AJ,rJ,ijAj->',ind_ir,s_aj,s_rj,temp)
result -= np.einsum('ir,AJ,rj,iJAj->',ind_ir,s_aj,s_rj,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('ar,aB,IB,Ijrj->',ind_ar,s_ab,s_ib,temp)
result += 2 * np.einsum('ar,aJ,IJ,Ijrj->',ind_ar,s_aj,s_ij,temp)
result -= np.einsum('ar,aJ,Ij,IJrj->',ind_ar,s_aj,s_ij,temp)
result += 2 * np.einsum('ir,iB,IB,Ijrj->',ind_ir,s_ib,s_ib,temp)
result += 2 * np.einsum('ir,AJ,Aj,iJrj->',ind_ir,s_aj,s_aj,temp)
result += 4 * np.einsum('ir,iJ,IJ,Ijrj->',ind_ir,s_ij,s_ij,temp)
result -= 2 * np.einsum('ir,iJ,Ij,IJrj->',ind_ir,s_ij,s_ij,temp)
result += 4 * np.einsum('ir,IJ,Ij,iJrj->',ind_ir,s_ij,s_ij,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('ar,aJ,rb,IJIb->',ind_ar,s_aj,s_rb,temp)
result += 2 * np.einsum('ir,iJ,rb,IJIb->',ind_ir,s_ij,s_rb,temp)
result -= np.einsum('ir,IJ,rb,iJIb->',ind_ir,s_ij,s_rb,temp)
temp = sapt.vt('ijab')
result += np.einsum('ia,AJ,Ab,iJab->',ind_ia,s_aj,s_ab,temp)
result += np.einsum('ia,IJ,Ib,iJab->',ind_ia,s_ij,s_ib,temp)
result -= np.einsum('ir,AJ,rb,iJAb->',ind_ir,s_aj,s_rb,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('ar,aJ,Ib,IJrb->',ind_ar,s_aj,s_ib,temp)
result += 2 * np.einsum('ir,AJ,Ab,iJrb->',ind_ir,s_aj,s_ab,temp)
result += 2 * np.einsum('ir,IJ,Ib,iJrb->',ind_ir,s_ij,s_ib,temp)
result -= np.einsum('ir,iJ,Ib,IJrb->',ind_ir,s_ij,s_ib,temp)
temp = sapt.vt('ibrb')
result -= np.einsum('ar,aB,Ib,IBrb->',ind_ar,s_ab,s_ib,temp)
result += np.einsum('ar,aB,IB,Ibrb->',ind_ar,s_ab,s_ib,temp)
result += np.einsum('ar,aJ,IJ,Ibrb->',ind_ar,s_aj,s_ij,temp)
result += 2 * np.einsum('ir,AB,Ab,iBrb->',ind_ir,s_ab,s_ab,temp)
result += 2 * np.einsum('ir,IB,Ib,iBrb->',ind_ir,s_ib,s_ib,temp)
result += np.einsum('ir,iB,IB,Ibrb->',ind_ir,s_ib,s_ib,temp)
result -= np.einsum('ir,iB,Ib,IBrb->',ind_ir,s_ib,s_ib,temp)
result += 2 * np.einsum('ir,iJ,IJ,Ibrb->',ind_ir,s_ij,s_ij,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('ar,aB,Ij,IBrj->',ind_ar,s_ab,s_ij,temp)
result += 2 * np.einsum('ir,AB,Aj,iBrj->',ind_ir,s_ab,s_aj,temp)
result += 2 * np.einsum('ir,IB,Ij,iBrj->',ind_ir,s_ib,s_ij,temp)
result -= np.einsum('ir,iB,Ij,IBrj->',ind_ir,s_ib,s_ij,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('ar,aB,rb,IBIb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ia,IJ,aJ,ibIb->',ind_ia,s_ij,s_aj,temp)
result += np.einsum('ir,IB,rB,ibIb->',ind_ir,s_ib,s_rb,temp)
result -= np.einsum('ir,IB,rb,iBIb->',ind_ir,s_ib,s_rb,temp)
result += 2 * np.einsum('ir,iB,rb,IBIb->',ind_ir,s_ib,s_rb,temp)
result += 2 * np.einsum('ir,IJ,rJ,ibIb->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('ar,aB,rj,IBIj->',ind_ar,s_ab,s_rj,temp)
result -= np.einsum('ir,IB,rj,iBIj->',ind_ir,s_ib,s_rj,temp)
result += 2 * np.einsum('ir,iB,rj,IBIj->',ind_ir,s_ib,s_rj,temp)
temp = sapt.vt('ibab')
result += np.einsum('ia,AB,Ab,iBab->',ind_ia,s_ab,s_ab,temp)
result += np.einsum('ia,IB,Ib,iBab->',ind_ia,s_ib,s_ib,temp)
result += np.einsum('ia,iJ,IJ,Ibab->',ind_ia,s_ij,s_ij,temp)
result += np.einsum('ir,AB,rB,ibAb->',ind_ir,s_ab,s_rb,temp)
result -= np.einsum('ir,AB,rb,iBAb->',ind_ir,s_ab,s_rb,temp)
result += np.einsum('ir,AJ,rJ,ibAb->',ind_ir,s_aj,s_rj,temp)
temp = sapt.vt('ibaj')
result += np.einsum('ia,AB,Aj,iBaj->',ind_ia,s_ab,s_aj,temp)
result += np.einsum('ia,IB,Ij,iBaj->',ind_ia,s_ib,s_ij,temp)
result -= np.einsum('ir,AB,rj,iBAj->',ind_ir,s_ab,s_rj,temp)
#automatically programmed stuff above
ExchInd20_ab = result

# B <- A
result = 0.0
#automatically programmed stuff below
temp = sapt.vt('absa')
result -= np.einsum('bs,absa',ind_bs,temp)
temp = sapt.vt('ibsi')
result -= np.einsum('bs,ibsi',ind_bs,temp)
temp = sapt.vt('ijbi')
result -= np.einsum('jb,ijbi',ind_jb,temp)
temp = sapt.vt('ajsa')
result -= np.einsum('js,ajsa',ind_js,temp)
temp = sapt.vt('ijsi')
result -= 2 * np.einsum('js,ijsi',ind_js,temp)
temp = sapt.vt('absb')
result += np.einsum('bs,aB,absB',ind_bs,s_ab,temp)
result -= np.einsum('bs,ab,aBsB',ind_bs,s_ab,temp)
result -= np.einsum('js,aj,aBsB',ind_js,s_aj,temp)
temp = sapt.vt('abbs')
result -= np.einsum('bs,aB,abBs',ind_bs,s_ab,temp)
result += np.einsum('bs,ab,aBBs',ind_bs,s_ab,temp)
result += np.einsum('js,aj,aBBs',ind_js,s_aj,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('bs,ab,aJsJ',ind_bs,s_ab,temp)
result += np.einsum('js,aJ,ajsJ',ind_js,s_aj,temp)
result -= 2 * np.einsum('js,aj,aJsJ',ind_js,s_aj,temp)
temp = sapt.vt('ajjs')
result += np.einsum('js,aj,aJJs',ind_js,s_aj,temp)
result += np.einsum('bs,ab,aJJs',ind_bs,s_ab,temp)
result -= 2 * np.einsum('js,aJ,ajJs',ind_js,s_aj,temp)
temp = sapt.vt('absj')
result += np.einsum('bs,aJ,absJ',ind_bs,s_aj,temp)
temp = sapt.vt('abjs')
result -= np.einsum('bs,aJ,abJs',ind_bs,s_aj,temp)
temp = sapt.vt('ajsb')
result += np.einsum('js,aB,ajsB',ind_js,s_ab,temp)
temp = sapt.vt('ajbs')
result -= 2 * np.einsum('js,aB,ajBs',ind_js,s_ab,temp)
temp = sapt.vt('ibsb')
result += np.einsum('bs,iB,ibsB',ind_bs,s_ib,temp)
result -= np.einsum('bs,ib,iBsB',ind_bs,s_ib,temp)
result -= 2 * np.einsum('js,ij,iBsB',ind_js,s_ij,temp)
temp = sapt.vt('ibbs')
result -= np.einsum('bs,iB,ibBs',ind_bs,s_ib,temp)
result += np.einsum('bs,ib,iBBs',ind_bs,s_ib,temp)
result += np.einsum('js,ij,iBBs',ind_js,s_ij,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('bs,ib,iJsJ',ind_bs,s_ib,temp)
result += 2 * np.einsum('js,iJ,ijsJ',ind_js,s_ij,temp)
result -= 4 * np.einsum('js,ij,iJsJ',ind_js,s_ij,temp)
temp = sapt.vt('ijjs')
result += np.einsum('bs,ib,iJJs',ind_bs,s_ib,temp)
result += 2 * np.einsum('js,ij,iJJs',ind_js,s_ij,temp)
result -= 4 * np.einsum('js,iJ,ijJs',ind_js,s_ij,temp)
temp = sapt.vt('ibsj')
result += np.einsum('bs,iJ,ibsJ',ind_bs,s_ij,temp)
temp = sapt.vt('ibjs')
result -= 2 * np.einsum('bs,iJ,ibJs',ind_bs,s_ij,temp)
temp = sapt.vt('abaa')
result -= np.einsum('bs,As,abaA',ind_bs,s_as,temp)
result += np.einsum('bs,as,AbaA',ind_bs,s_as,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('js,As,ajaA',ind_js,s_as,temp)
result += np.einsum('js,as,AjaA',ind_js,s_as,temp)
temp = sapt.vt('ibia')
result -= 2 * np.einsum('bs,As,ibiA',ind_bs,s_as,temp)
temp = sapt.vt('ibai')
result += np.einsum('bs,as,IbaI',ind_bs,s_as,temp)
temp = sapt.vt('abai')
result -= np.einsum('bs,Is,abaI',ind_bs,s_is,temp)
temp = sapt.vt('ibii')
result -= 2 * np.einsum('bs,Is,ibiI',ind_bs,s_is,temp)
temp = sapt.vt('abia')
result += np.einsum('bs,is,AbiA',ind_bs,s_is,temp)
temp = sapt.vt('ibii')
result += np.einsum('bs,is,IbiI',ind_bs,s_is,temp)
temp = sapt.vt('ajai')
result -= np.einsum('jb,Ib,ajaI',ind_jb,s_ib,temp)
result -= 2 * np.einsum('js,Is,ajaI',ind_js,s_is,temp)
temp = sapt.vt('ijii')
result -= 2 * np.einsum('jb,Ib,ijiI',ind_jb,s_ib,temp)
result += np.einsum('jb,ib,IjiI',ind_jb,s_ib,temp)
result -= 4 * np.einsum('js,Is,ijiI',ind_js,s_is,temp)
result += 2 * np.einsum('js,is,IjiI',ind_js,s_is,temp)
temp = sapt.vt('ajbb')
result -= np.einsum('jb,aB,ajBb',ind_jb,s_ab,temp)
temp = sapt.vt('ajjb')
result -= np.einsum('jb,aJ,ajJb',ind_jb,s_aj,temp)
temp = sapt.vt('ijbb')
result -= np.einsum('jb,iB,ijBb',ind_jb,s_ib,temp)
temp = sapt.vt('ijjb')
result -= 2 * np.einsum('jb,iJ,ijJb',ind_jb,s_ij,temp)
result += np.einsum('jb,ij,iJJb',ind_jb,s_ij,temp)
temp = sapt.vt('ijbj')
result += np.einsum('jb,iJ,ijbJ',ind_jb,s_ij,temp)
result -= 2 * np.einsum('jb,ij,iJbJ',ind_jb,s_ij,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('jb,ij,iBbB',ind_jb,s_ij,temp)
temp = sapt.vt('ijsb')
result += np.einsum('js,iB,ijsB',ind_js,s_ib,temp)
temp = sapt.vt('ijbs')
result -= 2 * np.einsum('js,iB,ijBs',ind_js,s_ib,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('js,As,ijiA',ind_js,s_as,temp)
temp = sapt.vt('ijai')
result += np.einsum('js,as,IjaI',ind_js,s_as,temp)
temp = sapt.vt('ajia')
result += np.einsum('js,is,AjiA',ind_js,s_is,temp)
temp = sapt.vt('abas')
result += np.einsum('bs,AB,aB,Abas',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,Ab,AB,aBas',ind_bs,s_ab,s_ab,temp)
result -= np.einsum('bs,Ab,aB,ABas',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,AJ,aJ,Abas',ind_bs,s_aj,s_aj,temp)
result += np.einsum('bs,Ib,IB,aBas',ind_bs,s_ib,s_ib,temp)
result += np.einsum('js,Aj,AB,aBas',ind_js,s_aj,s_ab,temp)
result -= np.einsum('js,Aj,aB,ABas',ind_js,s_aj,s_ab,temp)
result += np.einsum('js,Ij,IB,aBas',ind_js,s_ij,s_ib,temp)
temp = sapt.vt('abis')
result -= np.einsum('js,Aj,iB,ABis',ind_js,s_aj,s_ib,temp)
result += np.einsum('bs,AB,iB,Abis',ind_bs,s_ab,s_ib,temp)
result -= np.einsum('bs,Ab,iB,ABis',ind_bs,s_ab,s_ib,temp)
result += np.einsum('bs,AJ,iJ,Abis',ind_bs,s_aj,s_ij,temp)
temp = sapt.vt('abab')
result += np.einsum('bs,AB,As,abaB',ind_bs,s_ab,s_as,temp)
result += np.einsum('bs,Ab,as,ABaB',ind_bs,s_ab,s_as,temp)
result -= np.einsum('bs,AB,as,AbaB',ind_bs,s_ab,s_as,temp)
result += np.einsum('bs,IB,Is,abaB',ind_bs,s_ib,s_is,temp)
result += np.einsum('js,Aj,as,ABaB',ind_js,s_aj,s_as,temp)
temp = sapt.vt('abib')
result += np.einsum('js,Aj,is,ABiB',ind_js,s_aj,s_is,temp)
result -= np.einsum('bs,AB,is,AbiB',ind_bs,s_ab,s_is,temp)
result += np.einsum('bs,Ab,is,ABiB',ind_bs,s_ab,s_is,temp)
temp = sapt.vt('abaj')
result += np.einsum('bs,AJ,As,abaJ',ind_bs,s_aj,s_as,temp)
result -= np.einsum('bs,AJ,as,AbaJ',ind_bs,s_aj,s_as,temp)
result += np.einsum('bs,IJ,Is,abaJ',ind_bs,s_ij,s_is,temp)
temp = sapt.vt('abij')
result -= np.einsum('bs,AJ,is,AbiJ',ind_bs,s_aj,s_is,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('bs,AJ,As,ibiJ',ind_bs,s_aj,s_as,temp)
result += 2 * np.einsum('bs,IJ,Is,ibiJ',ind_bs,s_ij,s_is,temp)
result -= np.einsum('bs,IJ,is,IbiJ',ind_bs,s_ij,s_is,temp)
temp = sapt.vt('ibaj')
result -= np.einsum('bs,IJ,as,IbaJ',ind_bs,s_ij,s_as,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('bs,AB,As,ibiB',ind_bs,s_ab,s_as,temp)
result += 2 * np.einsum('bs,IB,Is,ibiB',ind_bs,s_ib,s_is,temp)
result -= np.einsum('bs,IB,is,IbiB',ind_bs,s_ib,s_is,temp)
result += np.einsum('bs,Ib,is,IBiB',ind_bs,s_ib,s_is,temp)
result += np.einsum('jb,Ij,ib,IBiB',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('js,Ij,is,IBiB',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('bs,Ab,AB,iBis',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,IB,iB,Ibis',ind_bs,s_ib,s_ib,temp)
result += 2 * np.einsum('bs,Ib,IB,iBis',ind_bs,s_ib,s_ib,temp)
result -= np.einsum('bs,Ib,iB,IBis',ind_bs,s_ib,s_ib,temp)
result += 2 * np.einsum('bs,IJ,iJ,Ibis',ind_bs,s_ij,s_ij,temp)
result += 2 * np.einsum('js,Aj,AB,iBis',ind_js,s_aj,s_ab,temp)
result += 2 * np.einsum('js,Ij,IB,iBis',ind_js,s_ij,s_ib,temp)
result -= np.einsum('js,Ij,iB,IBis',ind_js,s_ij,s_ib,temp)
temp = sapt.vt('ibab')
result -= np.einsum('bs,IB,as,IbaB',ind_bs,s_ib,s_as,temp)
result += np.einsum('bs,Ib,as,IBaB',ind_bs,s_ib,s_as,temp)
result += np.einsum('js,Ij,as,IBaB',ind_js,s_ij,s_as,temp)
temp = sapt.vt('ibas')
result += np.einsum('bs,IB,aB,Ibas',ind_bs,s_ib,s_ab,temp)
result -= np.einsum('bs,Ib,aB,IBas',ind_bs,s_ib,s_ab,temp)
result += np.einsum('bs,IJ,aJ,Ibas',ind_bs,s_ij,s_aj,temp)
result -= np.einsum('js,Ij,aB,IBas',ind_js,s_ij,s_ab,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('bs,Ib,is,IJiJ',ind_bs,s_ib,s_is,temp)
result += 2 * np.einsum('jb,IJ,Ib,ijiJ',ind_jb,s_ij,s_ib,temp)
result -= np.einsum('jb,IJ,ib,IjiJ',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('jb,Ij,ib,IJiJ',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('js,AJ,As,ijiJ',ind_js,s_aj,s_as,temp)
result += 4 * np.einsum('js,Ij,is,IJiJ',ind_js,s_ij,s_is,temp)
result += 4 * np.einsum('js,IJ,Is,ijiJ',ind_js,s_ij,s_is,temp)
result -= 2 * np.einsum('js,IJ,is,IjiJ',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ijib')
result += np.einsum('jb,IB,iB,Ijib',ind_jb,s_ib,s_ib,temp)
result += 2 * np.einsum('jb,IJ,iJ,Ijib',ind_jb,s_ij,s_ij,temp)
result += 2 * np.einsum('jb,Ij,IJ,iJib',ind_jb,s_ij,s_ij,temp)
result -= np.einsum('jb,Ij,iJ,IJib',ind_jb,s_ij,s_ij,temp)
result += 2 * np.einsum('js,AB,As,ijiB',ind_js,s_ab,s_as,temp)
result += 2 * np.einsum('js,IB,Is,ijiB',ind_js,s_ib,s_is,temp)
result -= np.einsum('js,IB,is,IjiB',ind_js,s_ib,s_is,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('bs,Ab,AJ,iJis',ind_bs,s_ab,s_aj,temp)
result += 2 * np.einsum('bs,Ib,IJ,iJis',ind_bs,s_ib,s_ij,temp)
result -= np.einsum('bs,Ib,iJ,IJis',ind_bs,s_ib,s_ij,temp)
result += 2 * np.einsum('js,Aj,AJ,iJis',ind_js,s_aj,s_aj,temp)
result += 2 * np.einsum('js,IB,iB,Ijis',ind_js,s_ib,s_ib,temp)
result += 4 * np.einsum('js,Ij,IJ,iJis',ind_js,s_ij,s_ij,temp)
result -= 2 * np.einsum('js,Ij,iJ,IJis',ind_js,s_ij,s_ij,temp)
result += 4 * np.einsum('js,IJ,iJ,Ijis',ind_js,s_ij,s_ij,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('bs,Ib,as,IJaJ',ind_bs,s_ib,s_as,temp)
result += 2 * np.einsum('js,Ij,as,IJaJ',ind_js,s_ij,s_as,temp)
result -= np.einsum('js,IJ,as,IjaJ',ind_js,s_ij,s_as,temp)
temp = sapt.vt('ijab')
result += np.einsum('jb,IB,aB,Ijab',ind_jb,s_ib,s_ab,temp)
result += np.einsum('jb,IJ,aJ,Ijab',ind_jb,s_ij,s_aj,temp)
result -= np.einsum('js,IB,as,IjaB',ind_js,s_ib,s_as,temp)
temp = sapt.vt('ijas')
result -= np.einsum('bs,Ib,aJ,IJas',ind_bs,s_ib,s_aj,temp)
result += 2 * np.einsum('js,IB,aB,Ijas',ind_js,s_ib,s_ab,temp)
result += 2 * np.einsum('js,IJ,aJ,Ijas',ind_js,s_ij,s_aj,temp)
result -= np.einsum('js,Ij,aJ,IJas',ind_js,s_ij,s_aj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('bs,Ab,aJ,AJas',ind_bs,s_ab,s_aj,temp)
result += np.einsum('bs,Ab,AJ,aJas',ind_bs,s_ab,s_aj,temp)
result += np.einsum('bs,Ib,IJ,aJas',ind_bs,s_ib,s_ij,temp)
result += 2 * np.einsum('js,AB,aB,Ajas',ind_js,s_ab,s_ab,temp)
result += 2 * np.einsum('js,AJ,aJ,Ajas',ind_js,s_aj,s_aj,temp)
result += np.einsum('js,Aj,AJ,aJas',ind_js,s_aj,s_aj,temp)
result -= np.einsum('js,Aj,aJ,AJas',ind_js,s_aj,s_aj,temp)
result += 2 * np.einsum('js,Ij,IJ,aJas',ind_js,s_ij,s_ij,temp)
temp = sapt.vt('ajis')
result -= np.einsum('bs,Ab,iJ,AJis',ind_bs,s_ab,s_ij,temp)
result += 2 * np.einsum('js,AB,iB,Ajis',ind_js,s_ab,s_ib,temp)
result += 2 * np.einsum('js,AJ,iJ,Ajis',ind_js,s_aj,s_ij,temp)
result -= np.einsum('js,Aj,iJ,AJis',ind_js,s_aj,s_ij,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('bs,Ab,as,AJaJ',ind_bs,s_ab,s_as,temp)
result += np.einsum('jb,IJ,Ib,ajaJ',ind_jb,s_ij,s_ib,temp)
result += np.einsum('js,AJ,As,ajaJ',ind_js,s_aj,s_as,temp)
result -= np.einsum('js,AJ,as,AjaJ',ind_js,s_aj,s_as,temp)
result += 2 * np.einsum('js,Aj,as,AJaJ',ind_js,s_aj,s_as,temp)
result += 2 * np.einsum('js,IJ,Is,ajaJ',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('bs,Ab,is,AJiJ',ind_bs,s_ab,s_is,temp)
result -= np.einsum('js,AJ,is,AjiJ',ind_js,s_aj,s_is,temp)
result += 2 * np.einsum('js,Aj,is,AJiJ',ind_js,s_aj,s_is,temp)
temp = sapt.vt('ajab')
result += np.einsum('jb,AB,aB,Ajab',ind_jb,s_ab,s_ab,temp)
result += np.einsum('jb,AJ,aJ,Ajab',ind_jb,s_aj,s_aj,temp)
result += np.einsum('jb,Ij,IJ,aJab',ind_jb,s_ij,s_ij,temp)
result += np.einsum('js,AB,As,ajaB',ind_js,s_ab,s_as,temp)
result -= np.einsum('js,AB,as,AjaB',ind_js,s_ab,s_as,temp)
result += np.einsum('js,IB,Is,ajaB',ind_js,s_ib,s_is,temp)
temp = sapt.vt('ajib')
result += np.einsum('jb,AB,iB,Ajib',ind_jb,s_ab,s_ib,temp)
result += np.einsum('jb,AJ,iJ,Ajib',ind_jb,s_aj,s_ij,temp)
result -= np.einsum('js,AB,is,AjiB',ind_js,s_ab,s_is,temp)
#automatically programmed stuff above
ExchInd20_ba = result

#sapt_printer('Exch-Ind20 A<-B', ExchInd20_ab)
#sapt_printer('Exch-Ind20 B<-A', ExchInd20_ba)

ExchInd20 = ExchInd20_ab + ExchInd20_ba

ind_timer.stop()
### End E200 Induction and Exchange-Induction

print('\nSAPT0(ROHF) Results')
print('-' * 70)
sapt_printer('Exch10 (S^2)', Exch100)
sapt_printer('Elst10', Elst10)
sapt_printer('Disp20', Disp200)
sapt_printer('Exch-Disp20', ExchDisp20)
sapt_printer('Ind20', Ind20r)
sapt_printer('Exch-Ind20', ExchInd20)

print('-' * 70)
sapt0 = Exch100 + Elst10 + Disp200 + ExchDisp20 + Ind20r + ExchInd20
sapt_printer('Total SAPT0(ROHF)', sapt0)
    
# ==> Compare to Psi4 <==
# in Psi4, we can only run SAPT with DF-ROHF
psi4.set_options({'df_basis_sapt':'aug-cc-pvdz-ri'})
psi4.set_options({'df_basis_scf':'aug-cc-pvdz-jkfit'})
psi4.set_options({'scf_type': 'df'})
psi4.energy('sapt0')
Eelst = psi4.get_variable('SAPT ELST ENERGY')
Eexch = psi4.get_variable('SAPT EXCH10(S^2) ENERGY')
Eind  = psi4.get_variable('SAPT IND20,R ENERGY')
Eexind  = psi4.get_variable('SAPT EXCH-IND20,R ENERGY')
Edisp  = psi4.get_variable('SAPT DISP20 ENERGY')
Eexdisp  = psi4.get_variable('SAPT EXCH-DISP20 ENERGY')
psi4.driver.p4util.compare_values(Eelst, Elst10, 5, 'Elst100')
psi4.driver.p4util.compare_values(Eexch, Exch100, 5, 'Exch100(S^2)')
psi4.driver.p4util.compare_values(Edisp, Disp200, 5, 'Disp200')
psi4.driver.p4util.compare_values(Eexdisp, ExchDisp20, 5, 'Exch-Disp200')
psi4.driver.p4util.compare_values(Eind, Ind20r, 5, 'Ind200,r')
psi4.driver.p4util.compare_values(Eexind, ExchInd20, 5, 'Exch-Ind200,r')

# SAPT0(ROHF) script for the oxygen dimer (two triplets making a quintet)
# The code is transparent but not optimized in any way, and this test might take up to a couple minutes.
#
# Created by: <NAME>
# Date: 12/1/14
# License: GPL v3.0
#

import time
import numpy as np
from helper_SAPT import *
np.set_printoptions(precision=5, linewidth=200, threshold=2000, suppress=True)
import psi4

# Set Psi4 & NumPy Memory Options
psi4.set_memory('2 GB')
psi4.core.set_output_file('output.dat', False)

numpy_memory = 2

# Set molecule to dimer
dimer = psi4.geometry("""
#Set the spin of A
0 3
O    0.000000000   0.000000000   2.605000000
O    0.000000000   0.000000000   1.395000000
--
#Set the spin of A
0 3
O    0.000000000   0.000000000  -1.395000000
O    0.000000000   0.000000000  -2.605000000
symmetry c1
""")

psi4.set_options({'basis': 'jun-cc-pVDZ',
                  'e_convergence': 1e-8,
                  'd_convergence': 1e-8,
                  'scf_type': 'pk',
                  'reference': 'rohf'})

sapt = helper_SAPT(dimer, memory=8, reference='ROHF')

### Start E100 Electostatics
elst_timer = sapt_timer('electrostatics')
Elst10 = 4 * np.einsum('ijij', sapt.vt('ijij'))
Elst10 += 2 * np.einsum('ajaj', sapt.vt('ajaj'))
Elst10 += 2 * np.einsum('ibib', sapt.vt('ibib'))
Elst10 += np.einsum('abab', sapt.vt('abab'))
elst_timer.stop()
### End E100 Electrostatics

### Start E100 Exchange
exch_timer = sapt_timer('exchange')
s_ij = sapt.s('ij')
s_ib = sapt.s('ib')
s_is = sapt.s('is')
s_aj = sapt.s('aj')
s_ab = sapt.s('ab')
s_as = sapt.s('as')
s_rj = sapt.s('rj')
s_rb = sapt.s('rb')

vt_ijji = sapt.vt('ijji')
vt_ajja = sapt.vt('ajja')
vt_ibbi = sapt.vt('ibbi')
vt_abba = sapt.vt('abba')

Exch100 = -2 * np.einsum('ijji', vt_ijji)
Exch100 -= np.einsum('ajja', vt_ajja)
Exch100 -= np.einsum('ibbi', vt_ibbi)
Exch100 -= np.einsum('abba', vt_abba)
#znacznik

vt_ijii = sapt.vt('ijii')
temp = -2 * vt_ijii + vt_ijii.swapaxes(2,3)
Exch100 += 2 * np.einsum('ijiI,Ij',temp,s_ij)
vt_ibii = sapt.vt('ibii')
temp = -2 * vt_ibii + vt_ibii.swapaxes(2,3)
Exch100 += np.einsum('ibiI,Ib',temp,s_ib)
vt_ijia = sapt.vt('ijia')
vt_ijai = sapt.vt('ijai')
Exch100 -= 2 * np.einsum('ijia,aj',vt_ijia,s_aj)
Exch100 += np.einsum('ijai,aj',vt_ijai,s_aj)
vt_ibia = sapt.vt('ibia')
vt_ibai = sapt.vt('ibai')
Exch100 -= 2 * np.einsum('ibia,ab',vt_ibia,s_ab)
Exch100 += np.einsum('ibai,ab',vt_ibai,s_ab)

vt_ajai = sapt.vt('ajai')
vt_ajia = sapt.vt('ajia')
Exch100 -= 2 * np.einsum('ajai,ij',vt_ajai,s_ij)
Exch100 += np.einsum('ajia,ij',vt_ajia,s_ij)
vt_abai = sapt.vt('abai')
vt_abia = sapt.vt('abia')
Exch100 -= np.einsum('abai,ib',vt_abai,s_ib)
Exch100 += np.einsum('abia,ib',vt_abia,s_ib)
vt_ajaa = sapt.vt('ajaa')
temp = - vt_ajaa + vt_ajaa.swapaxes(2,3)
Exch100 += np.einsum('ajaA,Aj',temp,s_aj)
vt_abaa = sapt.vt('abaa')
temp = - vt_abaa + vt_abaa.swapaxes(2,3)
Exch100 += np.einsum('abaA,Ab',temp,s_ab)

vt_ijjj = sapt.vt('ijjj')
temp = -2 * vt_ijjj + vt_ijjj.swapaxes(2,3)
Exch100 += 2 * np.einsum('ijJj,iJ',temp,s_ij)
vt_ajjj = sapt.vt('ajjj')
temp = -2 * vt_ajjj + vt_ajjj.swapaxes(2,3)
Exch100 += np.einsum('ajJj,aJ',temp,s_aj)
vt_ibjb = sapt.vt('ibjb')
vt_ibbj = sapt.vt('ibbj')
Exch100 -= 2 * np.einsum('ibjb,ij',vt_ibjb,s_ij)
Exch100 += np.einsum('ibbj,ij',vt_ibbj,s_ij)
vt_abjb = sapt.vt('abjb')
vt_abbj = sapt.vt('abbj')
Exch100 -= np.einsum('abjb,aj',vt_abjb,s_aj)
Exch100 += np.einsum('abbj,aj',vt_abbj,s_aj)

vt_ijbj = sapt.vt('ijbj')
vt_ijjb = sapt.vt('ijjb')
Exch100 -= 2 * np.einsum('ijbj,ib',vt_ijbj,s_ib)
Exch100 += np.einsum('ijjb,ib',vt_ijjb,s_ib)
vt_ajbj = sapt.vt('ajbj')
vt_ajjb = sapt.vt('ajjb')
Exch100 -= 2 * np.einsum('ajbj,ab',vt_ajbj,s_ab)
Exch100 += np.einsum('ajjb,ab',vt_ajjb,s_ab)
vt_ibbb = sapt.vt('ibbb')
temp = - vt_ibbb + vt_ibbb.swapaxes(2,3)
Exch100 += np.einsum('ibBb,iB',temp,s_ib)
vt_abbb = sapt.vt('abbb')
temp = - vt_abbb + vt_abbb.swapaxes(2,3)
Exch100 += np.einsum('abBb,aB',temp,s_ab)

vt_ijij = sapt.vt('ijij')
Exch100 += 4 * np.einsum('ijiJ,Ij,IJ',vt_ijij,s_ij,s_ij)
Exch100 += 2 * np.einsum('ijiJ,aj,aJ',vt_ijij,s_aj,s_aj)
Exch100 += 4 * np.einsum('ijIj,IJ,iJ',vt_ijij,s_ij,s_ij)
Exch100 += 2 * np.einsum('ijIj,Ib,ib',vt_ijij,s_ib,s_ib)
Exch100 -= 2 * np.einsum('ijIJ,Ij,iJ',vt_ijij,s_ij,s_ij)

vt_ibij = sapt.vt('ibij')
Exch100 += 4 * np.einsum('ibij,Ib,Ij',vt_ibij,s_ib,s_ij)
Exch100 += 4 * np.einsum('ibij,ab,aj',vt_ibij,s_ab,s_aj)
Exch100 -= 2 * np.einsum('ibIj,Ib,ij',vt_ibij,s_ib,s_ij)

vt_ajij = sapt.vt('ajij')
Exch100 += 4 * np.einsum('ajij,iJ,aJ',vt_ajij,s_ij,s_aj)
Exch100 += 4 * np.einsum('ajij,ib,ab',vt_ajij,s_ib,s_ab)
Exch100 -= 2 * np.einsum('ajiJ,ij,aJ',vt_ajij,s_ij,s_aj)

vt_abij = sapt.vt('abij')
Exch100 -= 2 * np.einsum('abij,ib,aj',vt_abij,s_ib,s_aj)
Exch100 -= 2 * np.einsum('abij,ij,ab',vt_abij,s_ij,s_ab)

vt_ibib = sapt.vt('ibib')
Exch100 += 2 * np.einsum('ibiB,Ib,IB',vt_ibib,s_ib,s_ib)
Exch100 += 2 * np.einsum('ibiB,ab,aB',vt_ibib,s_ab,s_ab)
Exch100 += 2 * np.einsum('ibIb,Ij,ij',vt_ibib,s_ij,s_ij)
Exch100 += np.einsum('ibIb,IB,iB',vt_ibib,s_ib,s_ib)
Exch100 -= np.einsum('ibIB,Ib,iB',vt_ibib,s_ib,s_ib)

vt_ajaj = sapt.vt('ajaj')
Exch100 += 2 * np.einsum('ajAj,AJ,aJ',vt_ajaj,s_aj,s_aj)
Exch100 += 2 * np.einsum('ajAj,Ab,ab',vt_ajaj,s_ab,s_ab)
Exch100 += 2 * np.einsum('ajaJ,ij,iJ',vt_ajaj,s_ij,s_ij)
Exch100 += np.einsum('ajaJ,Aj,AJ',vt_ajaj,s_aj,s_aj)
Exch100 -= np.einsum('ajAJ,Aj,aJ',vt_ajaj,s_aj,s_aj)

vt_abaj = sapt.vt('abaj')
Exch100 += 2 * np.einsum('abaj,ib,ij',vt_abaj,s_ib,s_ij)
Exch100 += 2 * np.einsum('abaj,Ab,Aj',vt_abaj,s_ab,s_aj)
Exch100 -= 2 * np.einsum('abAj,Ab,aj',vt_abaj,s_ab,s_aj)

vt_abib = sapt.vt('abib')
Exch100 += 2 * np.einsum('abib,ij,aj',vt_abib,s_ij,s_aj)
Exch100 += 2 * np.einsum('abib,iB,aB',vt_abib,s_ib,s_ab)
Exch100 -= 2 * np.einsum('abiB,ib,aB',vt_abib,s_ib,s_ab)

vt_abab = sapt.vt('abab')
Exch100 += np.einsum('abaB,ib,iB',vt_abab,s_ib,s_ib)
Exch100 += np.einsum('abaB,Ab,AB',vt_abab,s_ab,s_ab)
Exch100 += np.einsum('abAb,Aj,aj',vt_abab,s_aj,s_aj)
Exch100 += np.einsum('abAb,AB,aB',vt_abab,s_ab,s_ab)
Exch100 -= np.einsum('abAB,Ab,aB',vt_abab,s_ab,s_ab)

exch_timer.stop()
### End E100 (S^2) Exchange

### Start E200 Disp
disp_timer = sapt_timer('dispersion and exchange dispersion')
v_rsij = sapt.v('rsij')
v_rsab = sapt.v('rsab')
v_rsaj = sapt.v('rsaj')
v_rsib = sapt.v('rsib')
v_abij = sapt.v('abij')
v_rbij = sapt.v('rbij')
v_asij = sapt.v('asij')
v_rbaj = sapt.v('rbaj')
v_asib = sapt.v('asib')
e_rsij = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rsab = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('a', dim=2) + sapt.eps('b'))
e_rsaj = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('a', dim=2) + sapt.eps('j'))
e_rsib = 1/(-sapt.eps('r', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('b'))
e_abij = 1/(-sapt.eps('a', dim=4) - sapt.eps('b', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rbij = 1/(-sapt.eps('r', dim=4) - sapt.eps('b', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_asij = 1/(-sapt.eps('a', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('j'))
e_rbaj = 1/(-sapt.eps('r', dim=4) - sapt.eps('b', dim=3) + sapt.eps('a', dim=2) + sapt.eps('j'))
e_asib = 1/(-sapt.eps('a', dim=4) - sapt.eps('s', dim=3) + sapt.eps('i', dim=2) + sapt.eps('b'))
t_rsij = np.einsum('rsij,rsij->rsij', v_rsij, e_rsij)
t_rsab = np.einsum('rsab,rsab->rsab', v_rsab, e_rsab)
t_rsaj = np.einsum('rsaj,rsaj->rsaj', v_rsaj, e_rsaj)
t_rsib = np.einsum('rsib,rsib->rsib', v_rsib, e_rsib)
t_abij = np.einsum('abij,abij->abij', v_abij, e_abij)
t_rbij = np.einsum('rbij,rbij->rbij', v_rbij, e_rbij)
t_asij = np.einsum('asij,asij->asij', v_asij, e_asij)
t_rbaj = np.einsum('rbaj,rbaj->rbaj', v_rbaj, e_rbaj)
t_asib = np.einsum('asib,asib->asib', v_asib, e_asib)

Disp200 = 4 * np.einsum('rsij,rsij,rsij->', e_rsij, v_rsij, v_rsij)
Disp200 += np.einsum('rsab,rsab,rsab->', e_rsab, v_rsab, v_rsab)
Disp200 += 2 * np.einsum('rsaj,rsaj,rsaj->', e_rsaj, v_rsaj, v_rsaj)
Disp200 += 2 * np.einsum('rsib,rsib,rsib->', e_rsib, v_rsib, v_rsib)
Disp200 += np.einsum('abij,abij,abij->', e_abij, v_abij, v_abij)
Disp200 += 2 * np.einsum('rbij,rbij,rbij->', e_rbij, v_rbij, v_rbij)
Disp200 += 2 * np.einsum('asij,asij,asij->', e_asij, v_asij, v_asij)
Disp200 += np.einsum('rbaj,rbaj,rbaj->', e_rbaj, v_rbaj, v_rbaj)
Disp200 += np.einsum('asib,asib,asib->', e_asib, v_asib, v_asib)
### End E200 Disp

### Start E200 Exchange-Dispersion
# the code is brute-force autoimplemented from the auto-gnerated LaTeX formula
result = 0.0
temp = sapt.vt('absr')
result -= np.einsum('rsab,absr->',t_rsab,temp)
temp = sapt.vt('ajsr')
result -= np.einsum('rsaj,ajsr->',t_rsaj,temp)
temp = sapt.vt('ibsr')
result -= np.einsum('rsib,ibsr->',t_rsib,temp)
temp = sapt.vt('ijba')
result -= np.einsum('abij,ijba->',t_abij,temp)
temp = sapt.vt('ijsa')
result -= np.einsum('asij,ijsa->',t_asij,temp)
temp = sapt.vt('ijbr')
result -= np.einsum('rbij,ijbr->',t_rbij,temp)
temp = sapt.vt('ijsr')
result -= 2 * np.einsum('rsij,ijsr->',t_rsij,temp)
temp = sapt.vt('abar')
result -= np.einsum('rsab,as,AbAr->',t_rsab,s_as,temp)
result += np.einsum('rsab,As,abAr->',t_rsab,s_as,temp)
temp = sapt.vt('abbs')
result += np.einsum('rsab,rb,aBBs->',t_rsab,s_rb,temp)
result -= np.einsum('rsab,rB,abBs->',t_rsab,s_rb,temp)
temp = sapt.vt('abir')
result += np.einsum('rsab,Is,abIr->',t_rsab,s_is,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('rsab,as,IbIr->',t_rsab,s_as,temp)
temp = sapt.vt('abjs')
result -= np.einsum('rsab,rJ,abJs->',t_rsab,s_rj,temp)
temp = sapt.vt('ajjs')
result += np.einsum('rsab,rb,aJJs->',t_rsab,s_rb,temp)
temp = sapt.vt('abra')
result += np.einsum('rsab,as,AbrA->',t_rsab,s_as,temp)
result -= np.einsum('rsab,As,abrA->',t_rsab,s_as,temp)
temp = sapt.vt('abri')
result -= np.einsum('rsab,Is,abrI->',t_rsab,s_is,temp)
temp = sapt.vt('ibri')
result += np.einsum('rsab,as,IbrI->',t_rsab,s_as,temp)
temp = sapt.vt('absb')
result -= np.einsum('rsab,rb,aBsB->',t_rsab,s_rb,temp)
result += np.einsum('rsab,rB,absB->',t_rsab,s_rb,temp)
temp = sapt.vt('absj')
result += np.einsum('rsab,rJ,absJ->',t_rsab,s_rj,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('rsab,rb,aJsJ->',t_rsab,s_rb,temp)
temp = sapt.vt('ajbb')
result -= np.einsum('rbaj,rB,ajBb->',t_rbaj,s_rb,temp)
temp = sapt.vt('ajjb')
result -= np.einsum('rbaj,rJ,ajJb->',t_rbaj,s_rj,temp)
temp = sapt.vt('ajri')
result -= np.einsum('rbaj,Ib,ajrI->',t_rbaj,s_ib,temp)
temp = sapt.vt('ajar')
result -= np.einsum('rsaj,as,AjAr->',t_rsaj,s_as,temp)
result += np.einsum('rsaj,As,ajAr->',t_rsaj,s_as,temp)
temp = sapt.vt('abbs')
result += np.einsum('rsaj,rj,aBBs->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajbs')
result -= 2 * np.einsum('rsaj,rB,ajBs->',t_rsaj,s_rb,temp)
temp = sapt.vt('ajir')
result += np.einsum('rsaj,Is,ajIr->',t_rsaj,s_is,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('rsaj,as,IjIr->',t_rsaj,s_as,temp)
temp = sapt.vt('ajjs')
result += np.einsum('rsaj,rj,aJJs->',t_rsaj,s_rj,temp)
result -= 2 * np.einsum('rsaj,rJ,ajJs->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajra')
result += np.einsum('rsaj,as,AjrA->',t_rsaj,s_as,temp)
result -= np.einsum('rsaj,As,ajrA->',t_rsaj,s_as,temp)
temp = sapt.vt('ajri')
result -= 2 * np.einsum('rsaj,Is,ajrI->',t_rsaj,s_is,temp)
temp = sapt.vt('ijri')
result += np.einsum('rsaj,as,IjrI->',t_rsaj,s_as,temp)
temp = sapt.vt('absb')
result -= np.einsum('rsaj,rj,aBsB->',t_rsaj,s_rj,temp)
temp = sapt.vt('ajsb')
result += np.einsum('rsaj,rB,ajsB->',t_rsaj,s_rb,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('rsaj,rj,aJsJ->',t_rsaj,s_rj,temp)
result += np.einsum('rsaj,rJ,ajsJ->',t_rsaj,s_rj,temp)
temp = sapt.vt('ibaa')
result -= np.einsum('asib,As,ibaA->',t_asib,s_as,temp)
temp = sapt.vt('ibai')
result -= np.einsum('asib,Is,ibaI->',t_asib,s_is,temp)
temp = sapt.vt('ibjs')
result -= np.einsum('asib,aJ,ibJs->',t_asib,s_aj,temp)
temp = sapt.vt('abar')
result -= np.einsum('rsib,is,AbAr->',t_rsib,s_is,temp)
temp = sapt.vt('ibar')
result += np.einsum('rsib,As,ibAr->',t_rsib,s_as,temp)
temp = sapt.vt('ibbs')
result += np.einsum('rsib,rb,iBBs->',t_rsib,s_rb,temp)
result -= np.einsum('rsib,rB,ibBs->',t_rsib,s_rb,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('rsib,is,IbIr->',t_rsib,s_is,temp)
result += np.einsum('rsib,Is,ibIr->',t_rsib,s_is,temp)
temp = sapt.vt('ibjs')
result -= 2 * np.einsum('rsib,rJ,ibJs->',t_rsib,s_rj,temp)
temp = sapt.vt('ijjs')
result += np.einsum('rsib,rb,iJJs->',t_rsib,s_rb,temp)
temp = sapt.vt('abra')
result += np.einsum('rsib,is,AbrA->',t_rsib,s_is,temp)
temp = sapt.vt('ibra')
result -= 2 * np.einsum('rsib,As,ibrA->',t_rsib,s_as,temp)
temp = sapt.vt('ibri')
result += np.einsum('rsib,is,IbrI->',t_rsib,s_is,temp)
result -= 2 * np.einsum('rsib,Is,ibrI->',t_rsib,s_is,temp)
temp = sapt.vt('ibsb')
result -= np.einsum('rsib,rb,iBsB->',t_rsib,s_rb,temp)
result += np.einsum('rsib,rB,ibsB->',t_rsib,s_rb,temp)
temp = sapt.vt('ibsj')
result += np.einsum('rsib,rJ,ibsJ->',t_rsib,s_rj,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('rsib,rb,iJsJ->',t_rsib,s_rb,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('abij,ib,AjAa->',t_abij,s_ib,temp)
temp = sapt.vt('ijai')
result += np.einsum('abij,ib,IjaI->',t_abij,s_ib,temp)
result -= np.einsum('abij,Ib,ijaI->',t_abij,s_ib,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('abij,aj,iBbB->',t_abij,s_aj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('abij,aj,iJbJ->',t_abij,s_aj,temp)
result += np.einsum('abij,aJ,ijbJ->',t_abij,s_aj,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('abij,ib,IjIa->',t_abij,s_ib,temp)
result += np.einsum('abij,Ib,ijIa->',t_abij,s_ib,temp)
temp = sapt.vt('ijjb')
result += np.einsum('abij,aj,iJJb->',t_abij,s_aj,temp)
result -= np.einsum('abij,aJ,ijJb->',t_abij,s_aj,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('asij,is,AjAa->',t_asij,s_is,temp)
temp = sapt.vt('ijaa')
result -= np.einsum('asij,As,ijaA->',t_asij,s_as,temp)
temp = sapt.vt('ijai')
result += np.einsum('asij,is,IjaI->',t_asij,s_is,temp)
result -= 2 * np.einsum('asij,Is,ijaI->',t_asij,s_is,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('asij,is,IjIa->',t_asij,s_is,temp)
result += np.einsum('asij,Is,ijIa->',t_asij,s_is,temp)
temp = sapt.vt('ijjs')
result += np.einsum('asij,aj,iJJs->',t_asij,s_aj,temp)
result -= 2 * np.einsum('asij,aJ,ijJs->',t_asij,s_aj,temp)
temp = sapt.vt('ibsb')
result -= np.einsum('asij,aj,iBsB->',t_asij,s_aj,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('asij,aj,iJsJ->',t_asij,s_aj,temp)
result += np.einsum('asij,aJ,ijsJ->',t_asij,s_aj,temp)
temp = sapt.vt('ajar')
result -= np.einsum('rbij,ib,AjAr->',t_rbij,s_ib,temp)
temp = sapt.vt('ijbb')
result -= np.einsum('rbij,rB,ijBb->',t_rbij,s_rb,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('rbij,rj,iBbB->',t_rbij,s_rj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('rbij,rj,iJbJ->',t_rbij,s_rj,temp)
result += np.einsum('rbij,rJ,ijbJ->',t_rbij,s_rj,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('rbij,ib,IjIr->',t_rbij,s_ib,temp)
result += np.einsum('rbij,Ib,ijIr->',t_rbij,s_ib,temp)
temp = sapt.vt('ijjb')
result += np.einsum('rbij,rj,iJJb->',t_rbij,s_rj,temp)
result -= 2 * np.einsum('rbij,rJ,ijJb->',t_rbij,s_rj,temp)
temp = sapt.vt('ijri')
result += np.einsum('rbij,ib,IjrI->',t_rbij,s_ib,temp)
result -= 2 * np.einsum('rbij,Ib,ijrI->',t_rbij,s_ib,temp)
temp = sapt.vt('ajar')
result -= 2 * np.einsum('rsij,is,AjAr->',t_rsij,s_is,temp)
temp = sapt.vt('ijar')
result += np.einsum('rsij,As,ijAr->',t_rsij,s_as,temp)
temp = sapt.vt('ibbs')
result += np.einsum('rsij,rj,iBBs->',t_rsij,s_rj,temp)
temp = sapt.vt('ijbs')
result -= 2 * np.einsum('rsij,rB,ijBs->',t_rsij,s_rb,temp)
temp = sapt.vt('ijir')
result -= 4 * np.einsum('rsij,is,IjIr->',t_rsij,s_is,temp)
result += 2 * np.einsum('rsij,Is,ijIr->',t_rsij,s_is,temp)
temp = sapt.vt('ijjs')
result += 2 * np.einsum('rsij,rj,iJJs->',t_rsij,s_rj,temp)
result -= 4 * np.einsum('rsij,rJ,ijJs->',t_rsij,s_rj,temp)
temp = sapt.vt('ajra')
result += np.einsum('rsij,is,AjrA->',t_rsij,s_is,temp)
temp = sapt.vt('ijra')
result -= 2 * np.einsum('rsij,As,ijrA->',t_rsij,s_as,temp)
temp = sapt.vt('ijri')
result += 2 * np.einsum('rsij,is,IjrI->',t_rsij,s_is,temp)
result -= 4 * np.einsum('rsij,Is,ijrI->',t_rsij,s_is,temp)
temp = sapt.vt('ibsb')
result -= 2 * np.einsum('rsij,rj,iBsB->',t_rsij,s_rj,temp)
temp = sapt.vt('ijsb')
result += np.einsum('rsij,rB,ijsB->',t_rsij,s_rb,temp)
temp = sapt.vt('ijsj')
result -= 4 * np.einsum('rsij,rj,iJsJ->',t_rsij,s_rj,temp)
result += 2 * np.einsum('rsij,rJ,ijsJ->',t_rsij,s_rj,temp)
temp = sapt.vt('abab')
result += np.einsum('rsab,as,rB,AbAB->',t_rsab,s_as,s_rb,temp)
result += np.einsum('rsab,As,rb,aBAB->',t_rsab,s_as,s_rb,temp)
result -= np.einsum('rsab,As,rB,abAB->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('rsab,as,rJ,AbAJ->',t_rsab,s_as,s_rj,temp)
result -= np.einsum('rsab,As,rJ,abAJ->',t_rsab,s_as,s_rj,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('rsab,As,rb,aJAJ->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abas')
result += np.einsum('rsab,aB,rb,ABAs->',t_rsab,s_ab,s_rb,temp)
result -= np.einsum('rsab,aB,rB,AbAs->',t_rsab,s_ab,s_rb,temp)
result -= np.einsum('rsab,aJ,rJ,AbAs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsab,aJ,rb,AJAs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abas')
result -= np.einsum('rsab,AB,rb,aBAs->',t_rsab,s_ab,s_rb,temp)
result += np.einsum('rsab,AB,rB,abAs->',t_rsab,s_ab,s_rb,temp)
result += np.einsum('rsab,AJ,rJ,abAs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('rsab,AJ,rb,aJAs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abib')
result += np.einsum('rsab,Is,rb,aBIB->',t_rsab,s_is,s_rb,temp)
result -= np.einsum('rsab,Is,rB,abIB->',t_rsab,s_is,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsab,as,rB,IbIB->',t_rsab,s_as,s_rb,temp)
temp = sapt.vt('abij')
result -= np.einsum('rsab,Is,rJ,abIJ->',t_rsab,s_is,s_rj,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('rsab,Is,rb,aJIJ->',t_rsab,s_is,s_rb,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('rsab,as,rJ,IbIJ->',t_rsab,s_as,s_rj,temp)
temp = sapt.vt('abis')
result -= np.einsum('rsab,IB,rb,aBIs->',t_rsab,s_ib,s_rb,temp)
result += np.einsum('rsab,IB,rB,abIs->',t_rsab,s_ib,s_rb,temp)
result += np.einsum('rsab,IJ,rJ,abIs->',t_rsab,s_ij,s_rj,temp)
temp = sapt.vt('ajis')
result -= np.einsum('rsab,IJ,rb,aJIs->',t_rsab,s_ij,s_rb,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsab,aB,rb,IBIs->',t_rsab,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsab,aB,rB,IbIs->',t_rsab,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsab,aJ,rJ,IbIs->',t_rsab,s_aj,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsab,aJ,rb,IJIs->',t_rsab,s_aj,s_rb,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsab,as,Ab,ABrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,as,AB,AbrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,As,Ab,aBrB->',t_rsab,s_as,s_ab,temp)
result -= np.einsum('rsab,Is,Ib,aBrB->',t_rsab,s_is,s_ib,temp)
result += np.einsum('rsab,As,AB,abrB->',t_rsab,s_as,s_ab,temp)
result += np.einsum('rsab,Is,IB,abrB->',t_rsab,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsab,as,Ib,IBrB->',t_rsab,s_as,s_ib,temp)
result -= np.einsum('rsab,as,IB,IbrB->',t_rsab,s_as,s_ib,temp)
temp = sapt.vt('abrj')
result -= np.einsum('rsab,as,AJ,AbrJ->',t_rsab,s_as,s_aj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsab,as,Ab,AJrJ->',t_rsab,s_as,s_ab,temp)
temp = sapt.vt('abrj')
result += np.einsum('rsab,As,AJ,abrJ->',t_rsab,s_as,s_aj,temp)
result += np.einsum('rsab,Is,IJ,abrJ->',t_rsab,s_is,s_ij,temp)
temp = sapt.vt('ajrj')
result -= 2 * np.einsum('rsab,As,Ab,aJrJ->',t_rsab,s_as,s_ab,temp)
result -= 2 * np.einsum('rsab,Is,Ib,aJrJ->',t_rsab,s_is,s_ib,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('rsab,as,IJ,IbrJ->',t_rsab,s_as,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsab,as,Ib,IJrJ->',t_rsab,s_as,s_ib,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsab,aB,Ab,ABrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,aB,AB,Abrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,aJ,AJ,Abrs->',t_rsab,s_aj,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsab,aJ,Ab,AJrs->',t_rsab,s_aj,s_ab,temp)
temp = sapt.vt('abrs')
result += np.einsum('rsab,AB,Ab,aBrs->',t_rsab,s_ab,s_ab,temp)
result += np.einsum('rsab,IB,Ib,aBrs->',t_rsab,s_ib,s_ib,temp)
temp = sapt.vt('ajrs')
result += np.einsum('rsab,AJ,Ab,aJrs->',t_rsab,s_aj,s_ab,temp)
result += np.einsum('rsab,IJ,Ib,aJrs->',t_rsab,s_ij,s_ib,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsab,aB,Ib,IBrs->',t_rsab,s_ab,s_ib,temp)
result += np.einsum('rsab,aB,IB,Ibrs->',t_rsab,s_ab,s_ib,temp)
result += np.einsum('rsab,aJ,IJ,Ibrs->',t_rsab,s_aj,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsab,aJ,Ib,IJrs->',t_rsab,s_aj,s_ib,temp)
temp = sapt.vt('ajab')
result -= np.einsum('rbaj,aB,rB,AjAb->',t_rbaj,s_ab,s_rb,temp)
result -= np.einsum('rbaj,aJ,rJ,AjAb->',t_rbaj,s_aj,s_rj,temp)
result += np.einsum('rbaj,AB,rB,ajAb->',t_rbaj,s_ab,s_rb,temp)
result += np.einsum('rbaj,AJ,rJ,ajAb->',t_rbaj,s_aj,s_rj,temp)
temp = sapt.vt('ajib')
result += np.einsum('rbaj,IB,rB,ajIb->',t_rbaj,s_ib,s_rb,temp)
result += np.einsum('rbaj,IJ,rJ,ajIb->',t_rbaj,s_ij,s_rj,temp)
temp = sapt.vt('ijib')
result -= 2 * np.einsum('rbaj,aB,rB,IjIb->',t_rbaj,s_ab,s_rb,temp)
result -= 2 * np.einsum('rbaj,aJ,rJ,IjIb->',t_rbaj,s_aj,s_rj,temp)
temp = sapt.vt('abrb')
result -= np.einsum('rbaj,Ib,Ij,aBrB->',t_rbaj,s_ib,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rbaj,aB,AB,Ajrb->',t_rbaj,s_ab,s_ab,temp)
result += np.einsum('rbaj,aJ,AJ,Ajrb->',t_rbaj,s_aj,s_aj,temp)
result += np.einsum('rbaj,IJ,Ij,aJrb->',t_rbaj,s_ij,s_ij,temp)
temp = sapt.vt('ijrb')
result += np.einsum('rbaj,aB,IB,Ijrb->',t_rbaj,s_ab,s_ib,temp)
result += np.einsum('rbaj,aJ,IJ,Ijrb->',t_rbaj,s_aj,s_ij,temp)
temp = sapt.vt('ajrj')
result -= 2 * np.einsum('rbaj,Ib,Ij,aJrJ->',t_rbaj,s_ib,s_ij,temp)
result += np.einsum('rbaj,Ib,IJ,ajrJ->',t_rbaj,s_ib,s_ij,temp)
temp = sapt.vt('ajab')
result += np.einsum('rsaj,as,rB,AjAB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('abab')
result += np.einsum('rsaj,As,rj,aBAB->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('ajab')
result -= np.einsum('rsaj,As,rB,ajAB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('ajaj')
result += np.einsum('rsaj,as,rJ,AjAJ->',t_rsaj,s_as,s_rj,temp)
result += 2 * np.einsum('rsaj,As,rj,aJAJ->',t_rsaj,s_as,s_rj,temp)
result -= np.einsum('rsaj,As,rJ,ajAJ->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('abas')
result += np.einsum('rsaj,aB,rj,ABAs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsaj,aJ,rj,AJAs->',t_rsaj,s_aj,s_rj,temp)
result -= 2 * np.einsum('rsaj,aB,rB,AjAs->',t_rsaj,s_ab,s_rb,temp)
result -= 2 * np.einsum('rsaj,aJ,rJ,AjAs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abas')
result -= np.einsum('rsaj,AB,rj,aBAs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('rsaj,AJ,rj,aJAs->',t_rsaj,s_aj,s_rj,temp)
result += 2 * np.einsum('rsaj,AB,rB,ajAs->',t_rsaj,s_ab,s_rb,temp)
result += 2 * np.einsum('rsaj,AJ,rJ,ajAs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abib')
result += np.einsum('rsaj,Is,rj,aBIB->',t_rsaj,s_is,s_rj,temp)
temp = sapt.vt('ajib')
result -= np.einsum('rsaj,Is,rB,ajIB->',t_rsaj,s_is,s_rb,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rsaj,as,rB,IjIB->',t_rsaj,s_as,s_rb,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('rsaj,Is,rj,aJIJ->',t_rsaj,s_is,s_rj,temp)
result -= np.einsum('rsaj,Is,rJ,ajIJ->',t_rsaj,s_is,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rsaj,as,rJ,IjIJ->',t_rsaj,s_as,s_rj,temp)
temp = sapt.vt('abis')
result -= np.einsum('rsaj,IB,rj,aBIs->',t_rsaj,s_ib,s_rj,temp)
temp = sapt.vt('ajis')
result -= np.einsum('rsaj,IJ,rj,aJIs->',t_rsaj,s_ij,s_rj,temp)
result += 2 * np.einsum('rsaj,IB,rB,ajIs->',t_rsaj,s_ib,s_rb,temp)
result += 2 * np.einsum('rsaj,IJ,rJ,ajIs->',t_rsaj,s_ij,s_rj,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsaj,aB,rj,IBIs->',t_rsaj,s_ab,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsaj,aJ,rj,IJIs->',t_rsaj,s_aj,s_rj,temp)
result -= 4 * np.einsum('rsaj,aB,rB,IjIs->',t_rsaj,s_ab,s_rb,temp)
result -= 4 * np.einsum('rsaj,aJ,rJ,IjIs->',t_rsaj,s_aj,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsaj,as,Aj,ABrB->',t_rsaj,s_as,s_aj,temp)
temp = sapt.vt('ajrb')
result -= np.einsum('rsaj,as,AB,AjrB->',t_rsaj,s_as,s_ab,temp)
temp = sapt.vt('abrb')
result -= np.einsum('rsaj,As,Aj,aBrB->',t_rsaj,s_as,s_aj,temp)
result -= 2 * np.einsum('rsaj,Is,Ij,aBrB->',t_rsaj,s_is,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rsaj,As,AB,ajrB->',t_rsaj,s_as,s_ab,temp)
result += np.einsum('rsaj,Is,IB,ajrB->',t_rsaj,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsaj,as,Ij,IBrB->',t_rsaj,s_as,s_ij,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rsaj,as,IB,IjrB->',t_rsaj,s_as,s_ib,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsaj,as,Aj,AJrJ->',t_rsaj,s_as,s_aj,temp)
result -= np.einsum('rsaj,as,AJ,AjrJ->',t_rsaj,s_as,s_aj,temp)
result -= 2 * np.einsum('rsaj,As,Aj,aJrJ->',t_rsaj,s_as,s_aj,temp)
result -= 4 * np.einsum('rsaj,Is,Ij,aJrJ->',t_rsaj,s_is,s_ij,temp)
result += np.einsum('rsaj,As,AJ,ajrJ->',t_rsaj,s_as,s_aj,temp)
result += 2 * np.einsum('rsaj,Is,IJ,ajrJ->',t_rsaj,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsaj,as,Ij,IJrJ->',t_rsaj,s_as,s_ij,temp)
result -= np.einsum('rsaj,as,IJ,IjrJ->',t_rsaj,s_as,s_ij,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsaj,aB,Aj,ABrs->',t_rsaj,s_ab,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsaj,aJ,Aj,AJrs->',t_rsaj,s_aj,s_aj,temp)
result += 2 * np.einsum('rsaj,aB,AB,Ajrs->',t_rsaj,s_ab,s_ab,temp)
result += 2 * np.einsum('rsaj,aJ,AJ,Ajrs->',t_rsaj,s_aj,s_aj,temp)
temp = sapt.vt('abrs')
result += np.einsum('rsaj,AB,Aj,aBrs->',t_rsaj,s_ab,s_aj,temp)
result += np.einsum('rsaj,IB,Ij,aBrs->',t_rsaj,s_ib,s_ij,temp)
temp = sapt.vt('ajrs')
result += np.einsum('rsaj,AJ,Aj,aJrs->',t_rsaj,s_aj,s_aj,temp)
result += 2 * np.einsum('rsaj,IJ,Ij,aJrs->',t_rsaj,s_ij,s_ij,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsaj,aB,Ij,IBrs->',t_rsaj,s_ab,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsaj,aJ,Ij,IJrs->',t_rsaj,s_aj,s_ij,temp)
result += 2 * np.einsum('rsaj,aB,IB,Ijrs->',t_rsaj,s_ab,s_ib,temp)
result += 2 * np.einsum('rsaj,aJ,IJ,Ijrs->',t_rsaj,s_aj,s_ij,temp)
temp = sapt.vt('abas')
result -= np.einsum('asib,iJ,aJ,AbAs->',t_asib,s_ij,s_aj,temp)
temp = sapt.vt('ibab')
result -= np.einsum('asib,As,Ab,iBaB->',t_asib,s_as,s_ab,temp)
result -= np.einsum('asib,Is,Ib,iBaB->',t_asib,s_is,s_ib,temp)
result += np.einsum('asib,As,AB,ibaB->',t_asib,s_as,s_ab,temp)
result += np.einsum('asib,Is,IB,ibaB->',t_asib,s_is,s_ib,temp)
temp = sapt.vt('ibaj')
result += np.einsum('asib,As,AJ,ibaJ->',t_asib,s_as,s_aj,temp)
result += np.einsum('asib,Is,IJ,ibaJ->',t_asib,s_is,s_ij,temp)
temp = sapt.vt('ijaj')
result -= 2 * np.einsum('asib,As,Ab,iJaJ->',t_asib,s_as,s_ab,temp)
result -= 2 * np.einsum('asib,Is,Ib,iJaJ->',t_asib,s_is,s_ib,temp)
temp = sapt.vt('ibas')
result += np.einsum('asib,iJ,IJ,Ibas->',t_asib,s_ij,s_ij,temp)
result += np.einsum('asib,AB,Ab,iBas->',t_asib,s_ab,s_ab,temp)
result += np.einsum('asib,IB,Ib,iBas->',t_asib,s_ib,s_ib,temp)
temp = sapt.vt('ijas')
result += np.einsum('asib,AJ,Ab,iJas->',t_asib,s_aj,s_ab,temp)
result += np.einsum('asib,IJ,Ib,iJas->',t_asib,s_ij,s_ib,temp)
temp = sapt.vt('ibis')
result -= 2 * np.einsum('asib,iJ,aJ,IbIs->',t_asib,s_ij,s_aj,temp)
result += np.einsum('asib,IJ,aJ,ibIs->',t_asib,s_ij,s_aj,temp)
temp = sapt.vt('abab')
result += np.einsum('rsib,is,rB,AbAB->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibab')
result += np.einsum('rsib,As,rb,iBAB->',t_rsib,s_as,s_rb,temp)
result -= np.einsum('rsib,As,rB,ibAB->',t_rsib,s_as,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('rsib,is,rJ,AbAJ->',t_rsib,s_is,s_rj,temp)
temp = sapt.vt('ibaj')
result -= np.einsum('rsib,As,rJ,ibAJ->',t_rsib,s_as,s_rj,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('rsib,As,rb,iJAJ->',t_rsib,s_as,s_rb,temp)
temp = sapt.vt('abas')
result += np.einsum('rsib,iB,rb,ABAs->',t_rsib,s_ib,s_rb,temp)
result -= np.einsum('rsib,iB,rB,AbAs->',t_rsib,s_ib,s_rb,temp)
result -= 2 * np.einsum('rsib,iJ,rJ,AbAs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ajas')
result += np.einsum('rsib,iJ,rb,AJAs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('ibas')
result -= np.einsum('rsib,AB,rb,iBAs->',t_rsib,s_ab,s_rb,temp)
result += np.einsum('rsib,AB,rB,ibAs->',t_rsib,s_ab,s_rb,temp)
result += np.einsum('rsib,AJ,rJ,ibAs->',t_rsib,s_aj,s_rj,temp)
temp = sapt.vt('ijas')
result -= np.einsum('rsib,AJ,rb,iJAs->',t_rsib,s_aj,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsib,is,rB,IbIB->',t_rsib,s_is,s_rb,temp)
result += np.einsum('rsib,Is,rb,iBIB->',t_rsib,s_is,s_rb,temp)
result -= np.einsum('rsib,Is,rB,ibIB->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('rsib,is,rJ,IbIJ->',t_rsib,s_is,s_rj,temp)
result -= np.einsum('rsib,Is,rJ,ibIJ->',t_rsib,s_is,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rsib,Is,rb,iJIJ->',t_rsib,s_is,s_rb,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsib,iB,rb,IBIs->',t_rsib,s_ib,s_rb,temp)
result -= 2 * np.einsum('rsib,iB,rB,IbIs->',t_rsib,s_ib,s_rb,temp)
result -= 4 * np.einsum('rsib,iJ,rJ,IbIs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('rsib,iJ,rb,IJIs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('ibis')
result -= np.einsum('rsib,IB,rb,iBIs->',t_rsib,s_ib,s_rb,temp)
result += np.einsum('rsib,IB,rB,ibIs->',t_rsib,s_ib,s_rb,temp)
result += 2 * np.einsum('rsib,IJ,rJ,ibIs->',t_rsib,s_ij,s_rj,temp)
temp = sapt.vt('ijis')
result -= np.einsum('rsib,IJ,rb,iJIs->',t_rsib,s_ij,s_rb,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsib,is,Ab,ABrB->',t_rsib,s_is,s_ab,temp)
result -= np.einsum('rsib,is,AB,AbrB->',t_rsib,s_is,s_ab,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rsib,is,Ib,IBrB->',t_rsib,s_is,s_ib,temp)
result -= np.einsum('rsib,is,IB,IbrB->',t_rsib,s_is,s_ib,temp)
result -= 2 * np.einsum('rsib,As,Ab,iBrB->',t_rsib,s_as,s_ab,temp)
result -= 2 * np.einsum('rsib,Is,Ib,iBrB->',t_rsib,s_is,s_ib,temp)
result += 2 * np.einsum('rsib,As,AB,ibrB->',t_rsib,s_as,s_ab,temp)
result += 2 * np.einsum('rsib,Is,IB,ibrB->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('abrj')
result -= np.einsum('rsib,is,AJ,AbrJ->',t_rsib,s_is,s_aj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsib,is,Ab,AJrJ->',t_rsib,s_is,s_ab,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('rsib,is,IJ,IbrJ->',t_rsib,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rsib,is,Ib,IJrJ->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('ibrj')
result += 2 * np.einsum('rsib,As,AJ,ibrJ->',t_rsib,s_as,s_aj,temp)
result += 2 * np.einsum('rsib,Is,IJ,ibrJ->',t_rsib,s_is,s_ij,temp)
temp = sapt.vt('ijrj')
result -= 4 * np.einsum('rsib,As,Ab,iJrJ->',t_rsib,s_as,s_ab,temp)
result -= 4 * np.einsum('rsib,Is,Ib,iJrJ->',t_rsib,s_is,s_ib,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsib,iB,Ab,ABrs->',t_rsib,s_ib,s_ab,temp)
result += np.einsum('rsib,iB,AB,Abrs->',t_rsib,s_ib,s_ab,temp)
result += np.einsum('rsib,iJ,AJ,Abrs->',t_rsib,s_ij,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsib,iJ,Ab,AJrs->',t_rsib,s_ij,s_ab,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsib,iB,Ib,IBrs->',t_rsib,s_ib,s_ib,temp)
result += np.einsum('rsib,iB,IB,Ibrs->',t_rsib,s_ib,s_ib,temp)
result += 2 * np.einsum('rsib,iJ,IJ,Ibrs->',t_rsib,s_ij,s_ij,temp)
temp = sapt.vt('ijrs')
result -= np.einsum('rsib,iJ,Ib,IJrs->',t_rsib,s_ij,s_ib,temp)
temp = sapt.vt('ibrs')
result += 2 * np.einsum('rsib,AB,Ab,iBrs->',t_rsib,s_ab,s_ab,temp)
result += 2 * np.einsum('rsib,IB,Ib,iBrs->',t_rsib,s_ib,s_ib,temp)
temp = sapt.vt('ijrs')
result += 2 * np.einsum('rsib,AJ,Ab,iJrs->',t_rsib,s_aj,s_ab,temp)
result += 2 * np.einsum('rsib,IJ,Ib,iJrs->',t_rsib,s_ij,s_ib,temp)
temp = sapt.vt('ajab')
result += np.einsum('abij,iJ,aj,AJAb->',t_abij,s_ij,s_aj,temp)
result -= np.einsum('abij,iJ,aJ,AjAb->',t_abij,s_ij,s_aj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('abij,ib,aJ,AjAJ->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ibab')
result += np.einsum('abij,ib,Ij,IBaB->',t_abij,s_ib,s_ij,temp)
result -= np.einsum('abij,Ib,Ij,iBaB->',t_abij,s_ib,s_ij,temp)
temp = sapt.vt('ijab')
result -= np.einsum('abij,iJ,Ij,IJab->',t_abij,s_ij,s_ij,temp)
result += np.einsum('abij,iJ,IJ,Ijab->',t_abij,s_ij,s_ij,temp)
result += np.einsum('abij,IJ,Ij,iJab->',t_abij,s_ij,s_ij,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('abij,ib,Ij,IJaJ->',t_abij,s_ib,s_ij,temp)
result -= np.einsum('abij,ib,IJ,IjaJ->',t_abij,s_ib,s_ij,temp)
result -= 2 * np.einsum('abij,Ib,Ij,iJaJ->',t_abij,s_ib,s_ij,temp)
result += np.einsum('abij,Ib,IJ,ijaJ->',t_abij,s_ib,s_ij,temp)
temp = sapt.vt('ibib')
result += np.einsum('abij,Ib,aj,iBIB->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('abij,iJ,aj,IJIb->',t_abij,s_ij,s_aj,temp)
result -= 2 * np.einsum('abij,iJ,aJ,IjIb->',t_abij,s_ij,s_aj,temp)
result -= np.einsum('abij,IJ,aj,iJIb->',t_abij,s_ij,s_aj,temp)
result += np.einsum('abij,IJ,aJ,ijIb->',t_abij,s_ij,s_aj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('abij,ib,aJ,IjIJ->',t_abij,s_ib,s_aj,temp)
result += 2 * np.einsum('abij,Ib,aj,iJIJ->',t_abij,s_ib,s_aj,temp)
result -= np.einsum('abij,Ib,aJ,ijIJ->',t_abij,s_ib,s_aj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('asij,is,aJ,AjAJ->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ajas')
result += np.einsum('asij,iJ,aj,AJAs->',t_asij,s_ij,s_aj,temp)
result -= 2 * np.einsum('asij,iJ,aJ,AjAs->',t_asij,s_ij,s_aj,temp)
temp = sapt.vt('ibab')
result += np.einsum('asij,is,Ij,IBaB->',t_asij,s_is,s_ij,temp)
result -= np.einsum('asij,As,Aj,iBaB->',t_asij,s_as,s_aj,temp)
result -= 2 * np.einsum('asij,Is,Ij,iBaB->',t_asij,s_is,s_ij,temp)
temp = sapt.vt('ijab')
result += np.einsum('asij,As,AB,ijaB->',t_asij,s_as,s_ab,temp)
result += np.einsum('asij,Is,IB,ijaB->',t_asij,s_is,s_ib,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('asij,is,Ij,IJaJ->',t_asij,s_is,s_ij,temp)
result -= np.einsum('asij,is,IJ,IjaJ->',t_asij,s_is,s_ij,temp)
result -= 2 * np.einsum('asij,As,Aj,iJaJ->',t_asij,s_as,s_aj,temp)
result -= 4 * np.einsum('asij,Is,Ij,iJaJ->',t_asij,s_is,s_ij,temp)
result += np.einsum('asij,As,AJ,ijaJ->',t_asij,s_as,s_aj,temp)
result += 2 * np.einsum('asij,Is,IJ,ijaJ->',t_asij,s_is,s_ij,temp)
temp = sapt.vt('ijas')
result -= np.einsum('asij,iJ,Ij,IJas->',t_asij,s_ij,s_ij,temp)
result += 2 * np.einsum('asij,iJ,IJ,Ijas->',t_asij,s_ij,s_ij,temp)
temp = sapt.vt('ibas')
result += np.einsum('asij,AB,Aj,iBas->',t_asij,s_ab,s_aj,temp)
result += np.einsum('asij,IB,Ij,iBas->',t_asij,s_ib,s_ij,temp)
temp = sapt.vt('ijas')
result += np.einsum('asij,AJ,Aj,iJas->',t_asij,s_aj,s_aj,temp)
result += 2 * np.einsum('asij,IJ,Ij,iJas->',t_asij,s_ij,s_ij,temp)
temp = sapt.vt('ibib')
result += np.einsum('asij,Is,aj,iBIB->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('asij,is,aJ,IjIJ->',t_asij,s_is,s_aj,temp)
result += 2 * np.einsum('asij,Is,aj,iJIJ->',t_asij,s_is,s_aj,temp)
result -= np.einsum('asij,Is,aJ,ijIJ->',t_asij,s_is,s_aj,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('asij,iJ,aj,IJIs->',t_asij,s_ij,s_aj,temp)
result -= 4 * np.einsum('asij,iJ,aJ,IjIs->',t_asij,s_ij,s_aj,temp)
result -= np.einsum('asij,IJ,aj,iJIs->',t_asij,s_ij,s_aj,temp)
result += 2 * np.einsum('asij,IJ,aJ,ijIs->',t_asij,s_ij,s_aj,temp)
temp = sapt.vt('ajab')
result += np.einsum('rbij,iJ,rj,AJAb->',t_rbij,s_ij,s_rj,temp)
result -= np.einsum('rbij,iB,rB,AjAb->',t_rbij,s_ib,s_rb,temp)
result -= 2 * np.einsum('rbij,iJ,rJ,AjAb->',t_rbij,s_ij,s_rj,temp)
temp = sapt.vt('ijab')
result += np.einsum('rbij,AB,rB,ijAb->',t_rbij,s_ab,s_rb,temp)
result += np.einsum('rbij,AJ,rJ,ijAb->',t_rbij,s_aj,s_rj,temp)
temp = sapt.vt('ajaj')
result += np.einsum('rbij,ib,rJ,AjAJ->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ibib')
result += np.einsum('rbij,Ib,rj,iBIB->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rbij,iJ,rj,IJIb->',t_rbij,s_ij,s_rj,temp)
result -= 2 * np.einsum('rbij,iB,rB,IjIb->',t_rbij,s_ib,s_rb,temp)
result -= 4 * np.einsum('rbij,iJ,rJ,IjIb->',t_rbij,s_ij,s_rj,temp)
result -= np.einsum('rbij,IJ,rj,iJIb->',t_rbij,s_ij,s_rj,temp)
result += np.einsum('rbij,IB,rB,ijIb->',t_rbij,s_ib,s_rb,temp)
result += 2 * np.einsum('rbij,IJ,rJ,ijIb->',t_rbij,s_ij,s_rj,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('rbij,ib,rJ,IjIJ->',t_rbij,s_ib,s_rj,temp)
result += 2 * np.einsum('rbij,Ib,rj,iJIJ->',t_rbij,s_ib,s_rj,temp)
result -= np.einsum('rbij,Ib,rJ,ijIJ->',t_rbij,s_ib,s_rj,temp)
temp = sapt.vt('ibrb')
result += np.einsum('rbij,ib,Ij,IBrB->',t_rbij,s_ib,s_ij,temp)
result -= 2 * np.einsum('rbij,Ib,Ij,iBrB->',t_rbij,s_ib,s_ij,temp)
temp = sapt.vt('ajrb')
result += np.einsum('rbij,iB,AB,Ajrb->',t_rbij,s_ib,s_ab,temp)
result += np.einsum('rbij,iJ,AJ,Ajrb->',t_rbij,s_ij,s_aj,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rbij,iJ,Ij,IJrb->',t_rbij,s_ij,s_ij,temp)
result += np.einsum('rbij,iB,IB,Ijrb->',t_rbij,s_ib,s_ib,temp)
result += 2 * np.einsum('rbij,iJ,IJ,Ijrb->',t_rbij,s_ij,s_ij,temp)
result += 2 * np.einsum('rbij,IJ,Ij,iJrb->',t_rbij,s_ij,s_ij,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('rbij,ib,Ij,IJrJ->',t_rbij,s_ib,s_ij,temp)
result -= np.einsum('rbij,ib,IJ,IjrJ->',t_rbij,s_ib,s_ij,temp)
result -= 4 * np.einsum('rbij,Ib,Ij,iJrJ->',t_rbij,s_ib,s_ij,temp)
result += 2 * np.einsum('rbij,Ib,IJ,ijrJ->',t_rbij,s_ib,s_ij,temp)
temp = sapt.vt('ajab')
result += np.einsum('rsij,is,rB,AjAB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ibab')
result += np.einsum('rsij,As,rj,iBAB->',t_rsij,s_as,s_rj,temp)
temp = sapt.vt('ijab')
result -= np.einsum('rsij,As,rB,ijAB->',t_rsij,s_as,s_rb,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('rsij,is,rJ,AjAJ->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('rsij,As,rj,iJAJ->',t_rsij,s_as,s_rj,temp)
result -= np.einsum('rsij,As,rJ,ijAJ->',t_rsij,s_as,s_rj,temp)
temp = sapt.vt('abas')
result += np.einsum('rsij,iB,rj,ABAs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ajas')
result += 2 * np.einsum('rsij,iJ,rj,AJAs->',t_rsij,s_ij,s_rj,temp)
result -= 2 * np.einsum('rsij,iB,rB,AjAs->',t_rsij,s_ib,s_rb,temp)
result -= 4 * np.einsum('rsij,iJ,rJ,AjAs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('ibas')
result -= np.einsum('rsij,AB,rj,iBAs->',t_rsij,s_ab,s_rj,temp)
temp = sapt.vt('ijas')
result -= np.einsum('rsij,AJ,rj,iJAs->',t_rsij,s_aj,s_rj,temp)
result += 2 * np.einsum('rsij,AB,rB,ijAs->',t_rsij,s_ab,s_rb,temp)
result += 2 * np.einsum('rsij,AJ,rJ,ijAs->',t_rsij,s_aj,s_rj,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('rsij,is,rB,IjIB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('rsij,Is,rj,iBIB->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ijib')
result -= np.einsum('rsij,Is,rB,ijIB->',t_rsij,s_is,s_rb,temp)
temp = sapt.vt('ijij')
result += 4 * np.einsum('rsij,is,rJ,IjIJ->',t_rsij,s_is,s_rj,temp)
result += 4 * np.einsum('rsij,Is,rj,iJIJ->',t_rsij,s_is,s_rj,temp)
result -= 2 * np.einsum('rsij,Is,rJ,ijIJ->',t_rsij,s_is,s_rj,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('rsij,iB,rj,IBIs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ijis')
result += 4 * np.einsum('rsij,iJ,rj,IJIs->',t_rsij,s_ij,s_rj,temp)
result -= 4 * np.einsum('rsij,iB,rB,IjIs->',t_rsij,s_ib,s_rb,temp)
result -= 8 * np.einsum('rsij,iJ,rJ,IjIs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('ibis')
result -= np.einsum('rsij,IB,rj,iBIs->',t_rsij,s_ib,s_rj,temp)
temp = sapt.vt('ijis')
result -= 2 * np.einsum('rsij,IJ,rj,iJIs->',t_rsij,s_ij,s_rj,temp)
result += 2 * np.einsum('rsij,IB,rB,ijIs->',t_rsij,s_ib,s_rb,temp)
result += 4 * np.einsum('rsij,IJ,rJ,ijIs->',t_rsij,s_ij,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('rsij,is,Aj,ABrB->',t_rsij,s_is,s_aj,temp)
temp = sapt.vt('ajrb')
result -= np.einsum('rsij,is,AB,AjrB->',t_rsij,s_is,s_ab,temp)
temp = sapt.vt('ibrb')
result += 2 * np.einsum('rsij,is,Ij,IBrB->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('rsij,is,IB,IjrB->',t_rsij,s_is,s_ib,temp)
temp = sapt.vt('ibrb')
result -= 2 * np.einsum('rsij,As,Aj,iBrB->',t_rsij,s_as,s_aj,temp)
result -= 4 * np.einsum('rsij,Is,Ij,iBrB->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('ijrb')
result += 2 * np.einsum('rsij,As,AB,ijrB->',t_rsij,s_as,s_ab,temp)
result += 2 * np.einsum('rsij,Is,IB,ijrB->',t_rsij,s_is,s_ib,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('rsij,is,Aj,AJrJ->',t_rsij,s_is,s_aj,temp)
result -= np.einsum('rsij,is,AJ,AjrJ->',t_rsij,s_is,s_aj,temp)
temp = sapt.vt('ijrj')
result += 4 * np.einsum('rsij,is,Ij,IJrJ->',t_rsij,s_is,s_ij,temp)
result -= 2 * np.einsum('rsij,is,IJ,IjrJ->',t_rsij,s_is,s_ij,temp)
result -= 4 * np.einsum('rsij,As,Aj,iJrJ->',t_rsij,s_as,s_aj,temp)
result -= 8 * np.einsum('rsij,Is,Ij,iJrJ->',t_rsij,s_is,s_ij,temp)
result += 2 * np.einsum('rsij,As,AJ,ijrJ->',t_rsij,s_as,s_aj,temp)
result += 4 * np.einsum('rsij,Is,IJ,ijrJ->',t_rsij,s_is,s_ij,temp)
temp = sapt.vt('abrs')
result -= np.einsum('rsij,iB,Aj,ABrs->',t_rsij,s_ib,s_aj,temp)
temp = sapt.vt('ajrs')
result -= np.einsum('rsij,iJ,Aj,AJrs->',t_rsij,s_ij,s_aj,temp)
result += 2 * np.einsum('rsij,iB,AB,Ajrs->',t_rsij,s_ib,s_ab,temp)
result += 2 * np.einsum('rsij,iJ,AJ,Ajrs->',t_rsij,s_ij,s_aj,temp)
temp = sapt.vt('ibrs')
result -= np.einsum('rsij,iB,Ij,IBrs->',t_rsij,s_ib,s_ij,temp)
temp = sapt.vt('ijrs')
result -= 2 * np.einsum('rsij,iJ,Ij,IJrs->',t_rsij,s_ij,s_ij,temp)
result += 2 * np.einsum('rsij,iB,IB,Ijrs->',t_rsij,s_ib,s_ib,temp)
result += 4 * np.einsum('rsij,iJ,IJ,Ijrs->',t_rsij,s_ij,s_ij,temp)
temp = sapt.vt('ibrs')
result += 2 * np.einsum('rsij,AB,Aj,iBrs->',t_rsij,s_ab,s_aj,temp)
result += 2 * np.einsum('rsij,IB,Ij,iBrs->',t_rsij,s_ib,s_ij,temp)
temp = sapt.vt('ijrs')
result += 2 * np.einsum('rsij,AJ,Aj,iJrs->',t_rsij,s_aj,s_aj,temp)
result += 4 * np.einsum('rsij,IJ,Ij,iJrs->',t_rsij,s_ij,s_ij,temp)
#end autogenerated stuff

ExchDisp20 = result
disp_timer.stop()
### End E200 Exchange-Dispersion

### Start E200 Induction and Exchange-Induction
#in this variant, no CPHF response will be calculated

# E200Induction and CPHF orbitals
ind_timer = sapt_timer('induction')

omb_ir = 2 * np.einsum('ijrj->ir',sapt.vt('ijrj')) + np.einsum('ibrb->ir',sapt.vt('ibrb'))
omb_ia = 2 * np.einsum('ijaj->ia',sapt.vt('ijaj')) + np.einsum('ibab->ia',sapt.vt('ibab'))
omb_ar = 2 * np.einsum('ajrj->ar',sapt.vt('ajrj')) + np.einsum('abrb->ar',sapt.vt('abrb'))
oma_js = 2 * np.einsum('ijis->js',sapt.vt('ijis')) + np.einsum('ajas->js',sapt.vt('ajas'))
oma_jb = 2 * np.einsum('ijib->jb',sapt.vt('ijib')) + np.einsum('ajab->jb',sapt.vt('ajab'))
oma_bs = 2 * np.einsum('ibis->bs',sapt.vt('ibis')) + np.einsum('abas->bs',sapt.vt('abas'))
e_ir = 1/(sapt.eps('i', dim=2) - sapt.eps('r'))
e_ia = 1/(sapt.eps('i', dim=2) - sapt.eps('a'))
e_ar = 1/(sapt.eps('a', dim=2) - sapt.eps('r'))
e_js = 1/(sapt.eps('j', dim=2) - sapt.eps('s'))
e_jb = 1/(sapt.eps('j', dim=2) - sapt.eps('b'))
e_bs = 1/(sapt.eps('b', dim=2) - sapt.eps('s'))
ind_ir = np.einsum('ir,ir->ir', omb_ir, e_ir)
ind_ia = np.einsum('ia,ia->ia', omb_ia, e_ia)
ind_ar = np.einsum('ar,ar->ar', omb_ar, e_ar)
ind_js = np.einsum('js,js->js', oma_js, e_js)
ind_jb = np.einsum('jb,jb->jb', oma_jb, e_jb)
ind_bs = np.einsum('bs,bs->bs', oma_bs, e_bs)

Ind20_ab = 2 * np.einsum('ir,ir->',omb_ir,ind_ir)
Ind20_ab += np.einsum('ia,ia->',omb_ia,ind_ia)
Ind20_ab += np.einsum('ar,ar->',omb_ar,ind_ar)
Ind20_ba = 2 * np.einsum('js,js->',oma_js,ind_js)
Ind20_ba += np.einsum('jb,jb->',oma_jb,ind_jb)
Ind20_ba += np.einsum('bs,bs->',oma_bs,ind_bs)

Ind20r = Ind20_ba + Ind20_ab

# Exchange-Induction

# A <- B
result = 0.0
#automatically programmed stuff below
temp = sapt.vt('abbr')
result -= np.einsum('ar,abbr->',ind_ar,temp)
temp = sapt.vt('ajjr')
result -= np.einsum('ar,ajjr->',ind_ar,temp)
temp = sapt.vt('ijja')
result -= np.einsum('ia,ijja->',ind_ia,temp)
temp = sapt.vt('ibbr')
result -= np.einsum('ir,ibbr->',ind_ir,temp)
temp = sapt.vt('ijjr')
result -= 2 * np.einsum('ir,ijjr->',ind_ir,temp)
temp = sapt.vt('abar')
result += np.einsum('ar,Ab,abAr->',ind_ar,s_ab,temp)
result -= np.einsum('ar,ab,AbAr->',ind_ar,s_ab,temp)
result -= np.einsum('ir,ib,AbAr->',ind_ir,s_ib,temp)
temp = sapt.vt('abra')
result -= np.einsum('ar,Ab,abrA->',ind_ar,s_ab,temp)
result += np.einsum('ar,ab,AbrA->',ind_ar,s_ab,temp)
result += np.einsum('ir,ib,AbrA->',ind_ir,s_ib,temp)
temp = sapt.vt('ibir')
result -= 2 * np.einsum('ar,ab,IbIr->',ind_ar,s_ab,temp)
result += np.einsum('ir,Ib,ibIr->',ind_ir,s_ib,temp)
result -= 2 * np.einsum('ir,ib,IbIr->',ind_ir,s_ib,temp)
temp = sapt.vt('ibri')
result += np.einsum('ir,ib,IbrI->',ind_ir,s_ib,temp)
result += np.einsum('ar,ab,IbrI->',ind_ar,s_ab,temp)
result -= 2 * np.einsum('ir,Ib,ibrI->',ind_ir,s_ib,temp)
temp = sapt.vt('abir')
result += np.einsum('ar,Ib,abIr->',ind_ar,s_ib,temp)
temp = sapt.vt('abri')
result -= np.einsum('ar,Ib,abrI->',ind_ar,s_ib,temp)
temp = sapt.vt('ibar')
result += np.einsum('ir,Ab,ibAr->',ind_ir,s_ab,temp)
temp = sapt.vt('ibra')
result -= 2 * np.einsum('ir,Ab,ibrA->',ind_ir,s_ab,temp)
temp = sapt.vt('ajar')
result += np.einsum('ar,Aj,ajAr->',ind_ar,s_aj,temp)
result -= np.einsum('ar,aj,AjAr->',ind_ar,s_aj,temp)
result -= 2 * np.einsum('ir,ij,AjAr->',ind_ir,s_ij,temp)
temp = sapt.vt('ajra')
result -= np.einsum('ar,Aj,ajrA->',ind_ar,s_aj,temp)
result += np.einsum('ar,aj,AjrA->',ind_ar,s_aj,temp)
result += np.einsum('ir,ij,AjrA->',ind_ir,s_ij,temp)
temp = sapt.vt('ijir')
result -= 2 * np.einsum('ar,aj,IjIr->',ind_ar,s_aj,temp)
result += 2 * np.einsum('ir,Ij,ijIr->',ind_ir,s_ij,temp)
result -= 4 * np.einsum('ir,ij,IjIr->',ind_ir,s_ij,temp)
temp = sapt.vt('ijri')
result += np.einsum('ar,aj,IjrI->',ind_ar,s_aj,temp)
result += 2 * np.einsum('ir,ij,IjrI->',ind_ir,s_ij,temp)
result -= 4 * np.einsum('ir,Ij,ijrI->',ind_ir,s_ij,temp)
temp = sapt.vt('ajir')
result += np.einsum('ar,Ij,ajIr->',ind_ar,s_ij,temp)
temp = sapt.vt('ajri')
result -= 2 * np.einsum('ar,Ij,ajrI->',ind_ar,s_ij,temp)
temp = sapt.vt('abbb')
result -= np.einsum('ar,rB,abBb->',ind_ar,s_rb,temp)
result += np.einsum('ar,rb,aBBb->',ind_ar,s_rb,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('ir,rB,ibBb->',ind_ir,s_rb,temp)
result += np.einsum('ir,rb,iBBb->',ind_ir,s_rb,temp)
temp = sapt.vt('ajbj')
result -= 2 * np.einsum('ar,rB,ajBj->',ind_ar,s_rb,temp)
temp = sapt.vt('ajjb')
result += np.einsum('ar,rb,aJJb->',ind_ar,s_rb,temp)
temp = sapt.vt('abjb')
result -= np.einsum('ar,rJ,abJb->',ind_ar,s_rj,temp)
temp = sapt.vt('ajjj')
result -= 2 * np.einsum('ar,rJ,ajJj->',ind_ar,s_rj,temp)
temp = sapt.vt('abbj')
result += np.einsum('ar,rj,aBBj->',ind_ar,s_rj,temp)
temp = sapt.vt('ajjj')
result += np.einsum('ar,rj,aJJj->',ind_ar,s_rj,temp)
temp = sapt.vt('ibjb')
result -= np.einsum('ia,aJ,ibJb->',ind_ia,s_aj,temp)
result -= 2 * np.einsum('ir,rJ,ibJb->',ind_ir,s_rj,temp)
temp = sapt.vt('ijjj')
result -= 2 * np.einsum('ia,aJ,ijJj->',ind_ia,s_aj,temp)
result += np.einsum('ia,aj,iJJj->',ind_ia,s_aj,temp)
result -= 4 * np.einsum('ir,rJ,ijJj->',ind_ir,s_rj,temp)
result += 2 * np.einsum('ir,rj,iJJj->',ind_ir,s_rj,temp)
temp = sapt.vt('ibaa')
result -= np.einsum('ia,Ab,ibaA->',ind_ia,s_ab,temp)
temp = sapt.vt('ibai')
result -= np.einsum('ia,Ib,ibaI->',ind_ia,s_ib,temp)
temp = sapt.vt('ijaa')
result -= np.einsum('ia,Aj,ijaA->',ind_ia,s_aj,temp)
temp = sapt.vt('ijai')
result -= 2 * np.einsum('ia,Ij,ijaI->',ind_ia,s_ij,temp)
result += np.einsum('ia,ij,IjaI->',ind_ia,s_ij,temp)
temp = sapt.vt('ijia')
result += np.einsum('ia,Ij,ijIa->',ind_ia,s_ij,temp)
result -= 2 * np.einsum('ia,ij,IjIa->',ind_ia,s_ij,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('ia,ij,AjAa->',ind_ia,s_ij,temp)
temp = sapt.vt('ijar')
result += np.einsum('ir,Aj,ijAr->',ind_ir,s_aj,temp)
temp = sapt.vt('ijra')
result -= 2 * np.einsum('ir,Aj,ijrA->',ind_ir,s_aj,temp)
temp = sapt.vt('ijbj')
result -= 2 * np.einsum('ir,rB,ijBj->',ind_ir,s_rb,temp)
temp = sapt.vt('ijjb')
result += np.einsum('ir,rb,iJJb->',ind_ir,s_rb,temp)
temp = sapt.vt('ibbj')
result += np.einsum('ir,rj,iBBj->',ind_ir,s_rj,temp)
temp = sapt.vt('abrb')
result += np.einsum('ar,AB,Ab,aBrb->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,aB,AB,Abrb->',ind_ar,s_ab,s_ab,temp)
result -= np.einsum('ar,aB,Ab,ABrb->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,IB,Ib,aBrb->',ind_ar,s_ib,s_ib,temp)
result += np.einsum('ar,aJ,AJ,Abrb->',ind_ar,s_aj,s_aj,temp)
result += np.einsum('ir,iB,AB,Abrb->',ind_ir,s_ib,s_ab,temp)
result -= np.einsum('ir,iB,Ab,ABrb->',ind_ir,s_ib,s_ab,temp)
result += np.einsum('ir,iJ,AJ,Abrb->',ind_ir,s_ij,s_aj,temp)
temp = sapt.vt('abrj')
result -= np.einsum('ir,iB,Aj,ABrj->',ind_ir,s_ib,s_aj,temp)
result += np.einsum('ar,AB,Aj,aBrj->',ind_ar,s_ab,s_aj,temp)
result -= np.einsum('ar,aB,Aj,ABrj->',ind_ar,s_ab,s_aj,temp)
result += np.einsum('ar,IB,Ij,aBrj->',ind_ar,s_ib,s_ij,temp)
temp = sapt.vt('abab')
result += np.einsum('ar,AB,rB,abAb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ar,aB,rb,ABAb->',ind_ar,s_ab,s_rb,temp)
result -= np.einsum('ar,AB,rb,aBAb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ar,AJ,rJ,abAb->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ir,iB,rb,ABAb->',ind_ir,s_ib,s_rb,temp)
temp = sapt.vt('abaj')
result += np.einsum('ir,iB,rj,ABAj->',ind_ir,s_ib,s_rj,temp)
result -= np.einsum('ar,AB,rj,aBAj->',ind_ar,s_ab,s_rj,temp)
result += np.einsum('ar,aB,rj,ABAj->',ind_ar,s_ab,s_rj,temp)
temp = sapt.vt('abib')
result += np.einsum('ar,IB,rB,abIb->',ind_ar,s_ib,s_rb,temp)
result -= np.einsum('ar,IB,rb,aBIb->',ind_ar,s_ib,s_rb,temp)
result += np.einsum('ar,IJ,rJ,abIb->',ind_ar,s_ij,s_rj,temp)
temp = sapt.vt('abij')
result -= np.einsum('ar,IB,rj,aBIj->',ind_ar,s_ib,s_rj,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('ar,IB,rB,ajIj->',ind_ar,s_ib,s_rb,temp)
result += 2 * np.einsum('ar,IJ,rJ,ajIj->',ind_ar,s_ij,s_rj,temp)
result -= np.einsum('ar,IJ,rj,aJIj->',ind_ar,s_ij,s_rj,temp)
temp = sapt.vt('ajib')
result -= np.einsum('ar,IJ,rb,aJIb->',ind_ar,s_ij,s_rb,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('ar,AB,rB,ajAj->',ind_ar,s_ab,s_rb,temp)
result += 2 * np.einsum('ar,AJ,rJ,ajAj->',ind_ar,s_aj,s_rj,temp)
result -= np.einsum('ar,AJ,rj,aJAj->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ar,aJ,rj,AJAj->',ind_ar,s_aj,s_rj,temp)
result += np.einsum('ia,iJ,aj,AJAj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ir,iJ,rj,AJAj->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ajrj')
result += 2 * np.einsum('ar,aB,AB,Ajrj->',ind_ar,s_ab,s_ab,temp)
result += np.einsum('ar,AJ,Aj,aJrj->',ind_ar,s_aj,s_aj,temp)
result += 2 * np.einsum('ar,aJ,AJ,Ajrj->',ind_ar,s_aj,s_aj,temp)
result -= np.einsum('ar,aJ,Aj,AJrj->',ind_ar,s_aj,s_aj,temp)
result += 2 * np.einsum('ar,IJ,Ij,aJrj->',ind_ar,s_ij,s_ij,temp)
result += 2 * np.einsum('ir,iB,AB,Ajrj->',ind_ir,s_ib,s_ab,temp)
result += 2 * np.einsum('ir,iJ,AJ,Ajrj->',ind_ir,s_ij,s_aj,temp)
result -= np.einsum('ir,iJ,Aj,AJrj->',ind_ir,s_ij,s_aj,temp)
temp = sapt.vt('ajab')
result -= np.einsum('ar,AJ,rb,aJAb->',ind_ar,s_aj,s_rb,temp)
result += np.einsum('ar,aJ,rb,AJAb->',ind_ar,s_aj,s_rb,temp)
result += np.einsum('ir,iJ,rb,AJAb->',ind_ir,s_ij,s_rb,temp)
temp = sapt.vt('ajrb')
result += np.einsum('ar,AJ,Ab,aJrb->',ind_ar,s_aj,s_ab,temp)
result -= np.einsum('ar,aJ,Ab,AJrb->',ind_ar,s_aj,s_ab,temp)
result += np.einsum('ar,IJ,Ib,aJrb->',ind_ar,s_ij,s_ib,temp)
result -= np.einsum('ir,iJ,Ab,AJrb->',ind_ir,s_ij,s_ab,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('ar,aJ,rj,IJIj->',ind_ar,s_aj,s_rj,temp)
result += 2 * np.einsum('ia,IJ,aJ,ijIj->',ind_ia,s_ij,s_aj,temp)
result -= np.einsum('ia,IJ,aj,iJIj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ia,iJ,aj,IJIj->',ind_ia,s_ij,s_aj,temp)
result += 2 * np.einsum('ir,IB,rB,ijIj->',ind_ir,s_ib,s_rb,temp)
result += 4 * np.einsum('ir,iJ,rj,IJIj->',ind_ir,s_ij,s_rj,temp)
result += 4 * np.einsum('ir,IJ,rJ,ijIj->',ind_ir,s_ij,s_rj,temp)
result -= 2 * np.einsum('ir,IJ,rj,iJIj->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ijaj')
result += np.einsum('ia,AJ,Aj,iJaj->',ind_ia,s_aj,s_aj,temp)
result += 2 * np.einsum('ia,IJ,Ij,iJaj->',ind_ia,s_ij,s_ij,temp)
result += 2 * np.einsum('ia,iJ,IJ,Ijaj->',ind_ia,s_ij,s_ij,temp)
result -= np.einsum('ia,iJ,Ij,IJaj->',ind_ia,s_ij,s_ij,temp)
result += 2 * np.einsum('ir,AB,rB,ijAj->',ind_ir,s_ab,s_rb,temp)
result += 2 * np.einsum('ir,AJ,rJ,ijAj->',ind_ir,s_aj,s_rj,temp)
result -= np.einsum('ir,AJ,rj,iJAj->',ind_ir,s_aj,s_rj,temp)
temp = sapt.vt('ijrj')
result += 2 * np.einsum('ar,aB,IB,Ijrj->',ind_ar,s_ab,s_ib,temp)
result += 2 * np.einsum('ar,aJ,IJ,Ijrj->',ind_ar,s_aj,s_ij,temp)
result -= np.einsum('ar,aJ,Ij,IJrj->',ind_ar,s_aj,s_ij,temp)
result += 2 * np.einsum('ir,iB,IB,Ijrj->',ind_ir,s_ib,s_ib,temp)
result += 2 * np.einsum('ir,AJ,Aj,iJrj->',ind_ir,s_aj,s_aj,temp)
result += 4 * np.einsum('ir,iJ,IJ,Ijrj->',ind_ir,s_ij,s_ij,temp)
result -= 2 * np.einsum('ir,iJ,Ij,IJrj->',ind_ir,s_ij,s_ij,temp)
result += 4 * np.einsum('ir,IJ,Ij,iJrj->',ind_ir,s_ij,s_ij,temp)
temp = sapt.vt('ijib')
result += 2 * np.einsum('ar,aJ,rb,IJIb->',ind_ar,s_aj,s_rb,temp)
result += 2 * np.einsum('ir,iJ,rb,IJIb->',ind_ir,s_ij,s_rb,temp)
result -= np.einsum('ir,IJ,rb,iJIb->',ind_ir,s_ij,s_rb,temp)
temp = sapt.vt('ijab')
result += np.einsum('ia,AJ,Ab,iJab->',ind_ia,s_aj,s_ab,temp)
result += np.einsum('ia,IJ,Ib,iJab->',ind_ia,s_ij,s_ib,temp)
result -= np.einsum('ir,AJ,rb,iJAb->',ind_ir,s_aj,s_rb,temp)
temp = sapt.vt('ijrb')
result -= np.einsum('ar,aJ,Ib,IJrb->',ind_ar,s_aj,s_ib,temp)
result += 2 * np.einsum('ir,AJ,Ab,iJrb->',ind_ir,s_aj,s_ab,temp)
result += 2 * np.einsum('ir,IJ,Ib,iJrb->',ind_ir,s_ij,s_ib,temp)
result -= np.einsum('ir,iJ,Ib,IJrb->',ind_ir,s_ij,s_ib,temp)
temp = sapt.vt('ibrb')
result -= np.einsum('ar,aB,Ib,IBrb->',ind_ar,s_ab,s_ib,temp)
result += np.einsum('ar,aB,IB,Ibrb->',ind_ar,s_ab,s_ib,temp)
result += np.einsum('ar,aJ,IJ,Ibrb->',ind_ar,s_aj,s_ij,temp)
result += 2 * np.einsum('ir,AB,Ab,iBrb->',ind_ir,s_ab,s_ab,temp)
result += 2 * np.einsum('ir,IB,Ib,iBrb->',ind_ir,s_ib,s_ib,temp)
result += np.einsum('ir,iB,IB,Ibrb->',ind_ir,s_ib,s_ib,temp)
result -= np.einsum('ir,iB,Ib,IBrb->',ind_ir,s_ib,s_ib,temp)
result += 2 * np.einsum('ir,iJ,IJ,Ibrb->',ind_ir,s_ij,s_ij,temp)
temp = sapt.vt('ibrj')
result -= np.einsum('ar,aB,Ij,IBrj->',ind_ar,s_ab,s_ij,temp)
result += 2 * np.einsum('ir,AB,Aj,iBrj->',ind_ir,s_ab,s_aj,temp)
result += 2 * np.einsum('ir,IB,Ij,iBrj->',ind_ir,s_ib,s_ij,temp)
result -= np.einsum('ir,iB,Ij,IBrj->',ind_ir,s_ib,s_ij,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('ar,aB,rb,IBIb->',ind_ar,s_ab,s_rb,temp)
result += np.einsum('ia,IJ,aJ,ibIb->',ind_ia,s_ij,s_aj,temp)
result += np.einsum('ir,IB,rB,ibIb->',ind_ir,s_ib,s_rb,temp)
result -= np.einsum('ir,IB,rb,iBIb->',ind_ir,s_ib,s_rb,temp)
result += 2 * np.einsum('ir,iB,rb,IBIb->',ind_ir,s_ib,s_rb,temp)
result += 2 * np.einsum('ir,IJ,rJ,ibIb->',ind_ir,s_ij,s_rj,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('ar,aB,rj,IBIj->',ind_ar,s_ab,s_rj,temp)
result -= np.einsum('ir,IB,rj,iBIj->',ind_ir,s_ib,s_rj,temp)
result += 2 * np.einsum('ir,iB,rj,IBIj->',ind_ir,s_ib,s_rj,temp)
temp = sapt.vt('ibab')
result += np.einsum('ia,AB,Ab,iBab->',ind_ia,s_ab,s_ab,temp)
result += np.einsum('ia,IB,Ib,iBab->',ind_ia,s_ib,s_ib,temp)
result += np.einsum('ia,iJ,IJ,Ibab->',ind_ia,s_ij,s_ij,temp)
result += np.einsum('ir,AB,rB,ibAb->',ind_ir,s_ab,s_rb,temp)
result -= np.einsum('ir,AB,rb,iBAb->',ind_ir,s_ab,s_rb,temp)
result += np.einsum('ir,AJ,rJ,ibAb->',ind_ir,s_aj,s_rj,temp)
temp = sapt.vt('ibaj')
result += np.einsum('ia,AB,Aj,iBaj->',ind_ia,s_ab,s_aj,temp)
result += np.einsum('ia,IB,Ij,iBaj->',ind_ia,s_ib,s_ij,temp)
result -= np.einsum('ir,AB,rj,iBAj->',ind_ir,s_ab,s_rj,temp)
#automatically programmed stuff above
ExchInd20_ab = result

# B <- A
result = 0.0
#automatically programmed stuff below
temp = sapt.vt('absa')
result -= np.einsum('bs,absa',ind_bs,temp)
temp = sapt.vt('ibsi')
result -= np.einsum('bs,ibsi',ind_bs,temp)
temp = sapt.vt('ijbi')
result -= np.einsum('jb,ijbi',ind_jb,temp)
temp = sapt.vt('ajsa')
result -= np.einsum('js,ajsa',ind_js,temp)
temp = sapt.vt('ijsi')
result -= 2 * np.einsum('js,ijsi',ind_js,temp)
temp = sapt.vt('absb')
result += np.einsum('bs,aB,absB',ind_bs,s_ab,temp)
result -= np.einsum('bs,ab,aBsB',ind_bs,s_ab,temp)
result -= np.einsum('js,aj,aBsB',ind_js,s_aj,temp)
temp = sapt.vt('abbs')
result -= np.einsum('bs,aB,abBs',ind_bs,s_ab,temp)
result += np.einsum('bs,ab,aBBs',ind_bs,s_ab,temp)
result += np.einsum('js,aj,aBBs',ind_js,s_aj,temp)
temp = sapt.vt('ajsj')
result -= 2 * np.einsum('bs,ab,aJsJ',ind_bs,s_ab,temp)
result += np.einsum('js,aJ,ajsJ',ind_js,s_aj,temp)
result -= 2 * np.einsum('js,aj,aJsJ',ind_js,s_aj,temp)
temp = sapt.vt('ajjs')
result += np.einsum('js,aj,aJJs',ind_js,s_aj,temp)
result += np.einsum('bs,ab,aJJs',ind_bs,s_ab,temp)
result -= 2 * np.einsum('js,aJ,ajJs',ind_js,s_aj,temp)
temp = sapt.vt('absj')
result += np.einsum('bs,aJ,absJ',ind_bs,s_aj,temp)
temp = sapt.vt('abjs')
result -= np.einsum('bs,aJ,abJs',ind_bs,s_aj,temp)
temp = sapt.vt('ajsb')
result += np.einsum('js,aB,ajsB',ind_js,s_ab,temp)
temp = sapt.vt('ajbs')
result -= 2 * np.einsum('js,aB,ajBs',ind_js,s_ab,temp)
temp = sapt.vt('ibsb')
result += np.einsum('bs,iB,ibsB',ind_bs,s_ib,temp)
result -= np.einsum('bs,ib,iBsB',ind_bs,s_ib,temp)
result -= 2 * np.einsum('js,ij,iBsB',ind_js,s_ij,temp)
temp = sapt.vt('ibbs')
result -= np.einsum('bs,iB,ibBs',ind_bs,s_ib,temp)
result += np.einsum('bs,ib,iBBs',ind_bs,s_ib,temp)
result += np.einsum('js,ij,iBBs',ind_js,s_ij,temp)
temp = sapt.vt('ijsj')
result -= 2 * np.einsum('bs,ib,iJsJ',ind_bs,s_ib,temp)
result += 2 * np.einsum('js,iJ,ijsJ',ind_js,s_ij,temp)
result -= 4 * np.einsum('js,ij,iJsJ',ind_js,s_ij,temp)
temp = sapt.vt('ijjs')
result += np.einsum('bs,ib,iJJs',ind_bs,s_ib,temp)
result += 2 * np.einsum('js,ij,iJJs',ind_js,s_ij,temp)
result -= 4 * np.einsum('js,iJ,ijJs',ind_js,s_ij,temp)
temp = sapt.vt('ibsj')
result += np.einsum('bs,iJ,ibsJ',ind_bs,s_ij,temp)
temp = sapt.vt('ibjs')
result -= 2 * np.einsum('bs,iJ,ibJs',ind_bs,s_ij,temp)
temp = sapt.vt('abaa')
result -= np.einsum('bs,As,abaA',ind_bs,s_as,temp)
result += np.einsum('bs,as,AbaA',ind_bs,s_as,temp)
temp = sapt.vt('ajaa')
result -= np.einsum('js,As,ajaA',ind_js,s_as,temp)
result += np.einsum('js,as,AjaA',ind_js,s_as,temp)
temp = sapt.vt('ibia')
result -= 2 * np.einsum('bs,As,ibiA',ind_bs,s_as,temp)
temp = sapt.vt('ibai')
result += np.einsum('bs,as,IbaI',ind_bs,s_as,temp)
temp = sapt.vt('abai')
result -= np.einsum('bs,Is,abaI',ind_bs,s_is,temp)
temp = sapt.vt('ibii')
result -= 2 * np.einsum('bs,Is,ibiI',ind_bs,s_is,temp)
temp = sapt.vt('abia')
result += np.einsum('bs,is,AbiA',ind_bs,s_is,temp)
temp = sapt.vt('ibii')
result += np.einsum('bs,is,IbiI',ind_bs,s_is,temp)
temp = sapt.vt('ajai')
result -= np.einsum('jb,Ib,ajaI',ind_jb,s_ib,temp)
result -= 2 * np.einsum('js,Is,ajaI',ind_js,s_is,temp)
temp = sapt.vt('ijii')
result -= 2 * np.einsum('jb,Ib,ijiI',ind_jb,s_ib,temp)
result += np.einsum('jb,ib,IjiI',ind_jb,s_ib,temp)
result -= 4 * np.einsum('js,Is,ijiI',ind_js,s_is,temp)
result += 2 * np.einsum('js,is,IjiI',ind_js,s_is,temp)
temp = sapt.vt('ajbb')
result -= np.einsum('jb,aB,ajBb',ind_jb,s_ab,temp)
temp = sapt.vt('ajjb')
result -= np.einsum('jb,aJ,ajJb',ind_jb,s_aj,temp)
temp = sapt.vt('ijbb')
result -= np.einsum('jb,iB,ijBb',ind_jb,s_ib,temp)
temp = sapt.vt('ijjb')
result -= 2 * np.einsum('jb,iJ,ijJb',ind_jb,s_ij,temp)
result += np.einsum('jb,ij,iJJb',ind_jb,s_ij,temp)
temp = sapt.vt('ijbj')
result += np.einsum('jb,iJ,ijbJ',ind_jb,s_ij,temp)
result -= 2 * np.einsum('jb,ij,iJbJ',ind_jb,s_ij,temp)
temp = sapt.vt('ibbb')
result -= np.einsum('jb,ij,iBbB',ind_jb,s_ij,temp)
temp = sapt.vt('ijsb')
result += np.einsum('js,iB,ijsB',ind_js,s_ib,temp)
temp = sapt.vt('ijbs')
result -= 2 * np.einsum('js,iB,ijBs',ind_js,s_ib,temp)
temp = sapt.vt('ijia')
result -= 2 * np.einsum('js,As,ijiA',ind_js,s_as,temp)
temp = sapt.vt('ijai')
result += np.einsum('js,as,IjaI',ind_js,s_as,temp)
temp = sapt.vt('ajia')
result += np.einsum('js,is,AjiA',ind_js,s_is,temp)
temp = sapt.vt('abas')
result += np.einsum('bs,AB,aB,Abas',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,Ab,AB,aBas',ind_bs,s_ab,s_ab,temp)
result -= np.einsum('bs,Ab,aB,ABas',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,AJ,aJ,Abas',ind_bs,s_aj,s_aj,temp)
result += np.einsum('bs,Ib,IB,aBas',ind_bs,s_ib,s_ib,temp)
result += np.einsum('js,Aj,AB,aBas',ind_js,s_aj,s_ab,temp)
result -= np.einsum('js,Aj,aB,ABas',ind_js,s_aj,s_ab,temp)
result += np.einsum('js,Ij,IB,aBas',ind_js,s_ij,s_ib,temp)
temp = sapt.vt('abis')
result -= np.einsum('js,Aj,iB,ABis',ind_js,s_aj,s_ib,temp)
result += np.einsum('bs,AB,iB,Abis',ind_bs,s_ab,s_ib,temp)
result -= np.einsum('bs,Ab,iB,ABis',ind_bs,s_ab,s_ib,temp)
result += np.einsum('bs,AJ,iJ,Abis',ind_bs,s_aj,s_ij,temp)
temp = sapt.vt('abab')
result += np.einsum('bs,AB,As,abaB',ind_bs,s_ab,s_as,temp)
result += np.einsum('bs,Ab,as,ABaB',ind_bs,s_ab,s_as,temp)
result -= np.einsum('bs,AB,as,AbaB',ind_bs,s_ab,s_as,temp)
result += np.einsum('bs,IB,Is,abaB',ind_bs,s_ib,s_is,temp)
result += np.einsum('js,Aj,as,ABaB',ind_js,s_aj,s_as,temp)
temp = sapt.vt('abib')
result += np.einsum('js,Aj,is,ABiB',ind_js,s_aj,s_is,temp)
result -= np.einsum('bs,AB,is,AbiB',ind_bs,s_ab,s_is,temp)
result += np.einsum('bs,Ab,is,ABiB',ind_bs,s_ab,s_is,temp)
temp = sapt.vt('abaj')
result += np.einsum('bs,AJ,As,abaJ',ind_bs,s_aj,s_as,temp)
result -= np.einsum('bs,AJ,as,AbaJ',ind_bs,s_aj,s_as,temp)
result += np.einsum('bs,IJ,Is,abaJ',ind_bs,s_ij,s_is,temp)
temp = sapt.vt('abij')
result -= np.einsum('bs,AJ,is,AbiJ',ind_bs,s_aj,s_is,temp)
temp = sapt.vt('ibij')
result += 2 * np.einsum('bs,AJ,As,ibiJ',ind_bs,s_aj,s_as,temp)
result += 2 * np.einsum('bs,IJ,Is,ibiJ',ind_bs,s_ij,s_is,temp)
result -= np.einsum('bs,IJ,is,IbiJ',ind_bs,s_ij,s_is,temp)
temp = sapt.vt('ibaj')
result -= np.einsum('bs,IJ,as,IbaJ',ind_bs,s_ij,s_as,temp)
temp = sapt.vt('ibib')
result += 2 * np.einsum('bs,AB,As,ibiB',ind_bs,s_ab,s_as,temp)
result += 2 * np.einsum('bs,IB,Is,ibiB',ind_bs,s_ib,s_is,temp)
result -= np.einsum('bs,IB,is,IbiB',ind_bs,s_ib,s_is,temp)
result += np.einsum('bs,Ib,is,IBiB',ind_bs,s_ib,s_is,temp)
result += np.einsum('jb,Ij,ib,IBiB',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('js,Ij,is,IBiB',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ibis')
result += 2 * np.einsum('bs,Ab,AB,iBis',ind_bs,s_ab,s_ab,temp)
result += np.einsum('bs,IB,iB,Ibis',ind_bs,s_ib,s_ib,temp)
result += 2 * np.einsum('bs,Ib,IB,iBis',ind_bs,s_ib,s_ib,temp)
result -= np.einsum('bs,Ib,iB,IBis',ind_bs,s_ib,s_ib,temp)
result += 2 * np.einsum('bs,IJ,iJ,Ibis',ind_bs,s_ij,s_ij,temp)
result += 2 * np.einsum('js,Aj,AB,iBis',ind_js,s_aj,s_ab,temp)
result += 2 * np.einsum('js,Ij,IB,iBis',ind_js,s_ij,s_ib,temp)
result -= np.einsum('js,Ij,iB,IBis',ind_js,s_ij,s_ib,temp)
temp = sapt.vt('ibab')
result -= np.einsum('bs,IB,as,IbaB',ind_bs,s_ib,s_as,temp)
result += np.einsum('bs,Ib,as,IBaB',ind_bs,s_ib,s_as,temp)
result += np.einsum('js,Ij,as,IBaB',ind_js,s_ij,s_as,temp)
temp = sapt.vt('ibas')
result += np.einsum('bs,IB,aB,Ibas',ind_bs,s_ib,s_ab,temp)
result -= np.einsum('bs,Ib,aB,IBas',ind_bs,s_ib,s_ab,temp)
result += np.einsum('bs,IJ,aJ,Ibas',ind_bs,s_ij,s_aj,temp)
result -= np.einsum('js,Ij,aB,IBas',ind_js,s_ij,s_ab,temp)
temp = sapt.vt('ijij')
result += 2 * np.einsum('bs,Ib,is,IJiJ',ind_bs,s_ib,s_is,temp)
result += 2 * np.einsum('jb,IJ,Ib,ijiJ',ind_jb,s_ij,s_ib,temp)
result -= np.einsum('jb,IJ,ib,IjiJ',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('jb,Ij,ib,IJiJ',ind_jb,s_ij,s_ib,temp)
result += 2 * np.einsum('js,AJ,As,ijiJ',ind_js,s_aj,s_as,temp)
result += 4 * np.einsum('js,Ij,is,IJiJ',ind_js,s_ij,s_is,temp)
result += 4 * np.einsum('js,IJ,Is,ijiJ',ind_js,s_ij,s_is,temp)
result -= 2 * np.einsum('js,IJ,is,IjiJ',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ijib')
result += np.einsum('jb,IB,iB,Ijib',ind_jb,s_ib,s_ib,temp)
result += 2 * np.einsum('jb,IJ,iJ,Ijib',ind_jb,s_ij,s_ij,temp)
result += 2 * np.einsum('jb,Ij,IJ,iJib',ind_jb,s_ij,s_ij,temp)
result -= np.einsum('jb,Ij,iJ,IJib',ind_jb,s_ij,s_ij,temp)
result += 2 * np.einsum('js,AB,As,ijiB',ind_js,s_ab,s_as,temp)
result += 2 * np.einsum('js,IB,Is,ijiB',ind_js,s_ib,s_is,temp)
result -= np.einsum('js,IB,is,IjiB',ind_js,s_ib,s_is,temp)
temp = sapt.vt('ijis')
result += 2 * np.einsum('bs,Ab,AJ,iJis',ind_bs,s_ab,s_aj,temp)
result += 2 * np.einsum('bs,Ib,IJ,iJis',ind_bs,s_ib,s_ij,temp)
result -= np.einsum('bs,Ib,iJ,IJis',ind_bs,s_ib,s_ij,temp)
result += 2 * np.einsum('js,Aj,AJ,iJis',ind_js,s_aj,s_aj,temp)
result += 2 * np.einsum('js,IB,iB,Ijis',ind_js,s_ib,s_ib,temp)
result += 4 * np.einsum('js,Ij,IJ,iJis',ind_js,s_ij,s_ij,temp)
result -= 2 * np.einsum('js,Ij,iJ,IJis',ind_js,s_ij,s_ij,temp)
result += 4 * np.einsum('js,IJ,iJ,Ijis',ind_js,s_ij,s_ij,temp)
temp = sapt.vt('ijaj')
result += 2 * np.einsum('bs,Ib,as,IJaJ',ind_bs,s_ib,s_as,temp)
result += 2 * np.einsum('js,Ij,as,IJaJ',ind_js,s_ij,s_as,temp)
result -= np.einsum('js,IJ,as,IjaJ',ind_js,s_ij,s_as,temp)
temp = sapt.vt('ijab')
result += np.einsum('jb,IB,aB,Ijab',ind_jb,s_ib,s_ab,temp)
result += np.einsum('jb,IJ,aJ,Ijab',ind_jb,s_ij,s_aj,temp)
result -= np.einsum('js,IB,as,IjaB',ind_js,s_ib,s_as,temp)
temp = sapt.vt('ijas')
result -= np.einsum('bs,Ib,aJ,IJas',ind_bs,s_ib,s_aj,temp)
result += 2 * np.einsum('js,IB,aB,Ijas',ind_js,s_ib,s_ab,temp)
result += 2 * np.einsum('js,IJ,aJ,Ijas',ind_js,s_ij,s_aj,temp)
result -= np.einsum('js,Ij,aJ,IJas',ind_js,s_ij,s_aj,temp)
temp = sapt.vt('ajas')
result -= np.einsum('bs,Ab,aJ,AJas',ind_bs,s_ab,s_aj,temp)
result += np.einsum('bs,Ab,AJ,aJas',ind_bs,s_ab,s_aj,temp)
result += np.einsum('bs,Ib,IJ,aJas',ind_bs,s_ib,s_ij,temp)
result += 2 * np.einsum('js,AB,aB,Ajas',ind_js,s_ab,s_ab,temp)
result += 2 * np.einsum('js,AJ,aJ,Ajas',ind_js,s_aj,s_aj,temp)
result += np.einsum('js,Aj,AJ,aJas',ind_js,s_aj,s_aj,temp)
result -= np.einsum('js,Aj,aJ,AJas',ind_js,s_aj,s_aj,temp)
result += 2 * np.einsum('js,Ij,IJ,aJas',ind_js,s_ij,s_ij,temp)
temp = sapt.vt('ajis')
result -= np.einsum('bs,Ab,iJ,AJis',ind_bs,s_ab,s_ij,temp)
result += 2 * np.einsum('js,AB,iB,Ajis',ind_js,s_ab,s_ib,temp)
result += 2 * np.einsum('js,AJ,iJ,Ajis',ind_js,s_aj,s_ij,temp)
result -= np.einsum('js,Aj,iJ,AJis',ind_js,s_aj,s_ij,temp)
temp = sapt.vt('ajaj')
result += 2 * np.einsum('bs,Ab,as,AJaJ',ind_bs,s_ab,s_as,temp)
result += np.einsum('jb,IJ,Ib,ajaJ',ind_jb,s_ij,s_ib,temp)
result += np.einsum('js,AJ,As,ajaJ',ind_js,s_aj,s_as,temp)
result -= np.einsum('js,AJ,as,AjaJ',ind_js,s_aj,s_as,temp)
result += 2 * np.einsum('js,Aj,as,AJaJ',ind_js,s_aj,s_as,temp)
result += 2 * np.einsum('js,IJ,Is,ajaJ',ind_js,s_ij,s_is,temp)
temp = sapt.vt('ajij')
result += 2 * np.einsum('bs,Ab,is,AJiJ',ind_bs,s_ab,s_is,temp)
result -= np.einsum('js,AJ,is,AjiJ',ind_js,s_aj,s_is,temp)
result += 2 * np.einsum('js,Aj,is,AJiJ',ind_js,s_aj,s_is,temp)
temp = sapt.vt('ajab')
result += np.einsum('jb,AB,aB,Ajab',ind_jb,s_ab,s_ab,temp)
result += np.einsum('jb,AJ,aJ,Ajab',ind_jb,s_aj,s_aj,temp)
result += np.einsum('jb,Ij,IJ,aJab',ind_jb,s_ij,s_ij,temp)
result += np.einsum('js,AB,As,ajaB',ind_js,s_ab,s_as,temp)
result -= np.einsum('js,AB,as,AjaB',ind_js,s_ab,s_as,temp)
result += np.einsum('js,IB,Is,ajaB',ind_js,s_ib,s_is,temp)
temp = sapt.vt('ajib')
result += np.einsum('jb,AB,iB,Ajib',ind_jb,s_ab,s_ib,temp)
result += np.einsum('jb,AJ,iJ,Ajib',ind_jb,s_aj,s_ij,temp)
result -= np.einsum('js,AB,is,AjiB',ind_js,s_ab,s_is,temp)
#automatically programmed stuff above
ExchInd20_ba = result

#sapt_printer('Exch-Ind20 A<-B', ExchInd20_ab)
#sapt_printer('Exch-Ind20 B<-A', ExchInd20_ba)

ExchInd20 = ExchInd20_ab + ExchInd20_ba

ind_timer.stop()
### End E200 Induction and Exchange-Induction

print('\nSAPT0(ROHF) Results')
print('-' * 70)
sapt_printer('Exch10 (S^2)', Exch100)
sapt_printer('Elst10', Elst10)
sapt_printer('Disp20', Disp200)
sapt_printer('Exch-Disp20', ExchDisp20)
sapt_printer('Ind20', Ind20r)
sapt_printer('Exch-Ind20', ExchInd20)

print('-' * 70)
sapt0 = Exch100 + Elst10 + Disp200 + ExchDisp20 + Ind20r + ExchInd20
sapt_printer('Total SAPT0(ROHF)', sapt0)
    
# ==> Compare to Psi4 <==
# in Psi4, we can only run SAPT with DF-ROHF
psi4.set_options({'df_basis_sapt':'aug-cc-pvdz-ri'})
psi4.set_options({'df_basis_scf':'aug-cc-pvdz-jkfit'})
psi4.set_options({'scf_type': 'df'})
psi4.energy('sapt0')
Eelst = psi4.get_variable('SAPT ELST ENERGY')
Eexch = psi4.get_variable('SAPT EXCH10(S^2) ENERGY')
Eind  = psi4.get_variable('SAPT IND20,R ENERGY')
Eexind  = psi4.get_variable('SAPT EXCH-IND20,R ENERGY')
Edisp  = psi4.get_variable('SAPT DISP20 ENERGY')
Eexdisp  = psi4.get_variable('SAPT EXCH-DISP20 ENERGY')
psi4.driver.p4util.compare_values(Eelst, Elst10, 5, 'Elst100')
psi4.driver.p4util.compare_values(Eexch, Exch100, 5, 'Exch100(S^2)')
psi4.driver.p4util.compare_values(Edisp, Disp200, 5, 'Disp200')
psi4.driver.p4util.compare_values(Eexdisp, ExchDisp20, 5, 'Exch-Disp200')
psi4.driver.p4util.compare_values(Eind, Ind20r, 5, 'Ind200,r')
psi4.driver.p4util.compare_values(Eexind, ExchInd20, 5, 'Exch-Ind200,r')

# SAPT0(ROHF) script for the oxygen dimer (two triplets making a quintet) # The code is transparent but not optimized in any way, and this test might take up to a couple minutes. # # Created by: <NAME> # Date: 12/1/14 # License: GPL v3.0 # # Set Psi4 & NumPy Memory Options # Set molecule to dimer #Set the spin of A 0 3 O    0.000000000   0.000000000   2.605000000 O    0.000000000   0.000000000   1.395000000 -- #Set the spin of A 0 3 O    0.000000000   0.000000000  -1.395000000 O    0.000000000   0.000000000  -2.605000000 symmetry c1 ### Start E100 Electostatics ### End E100 Electrostatics ### Start E100 Exchange #znacznik ### End E100 (S^2) Exchange ### Start E200 Disp ### End E200 Disp ### Start E200 Exchange-Dispersion # the code is brute-force autoimplemented from the auto-gnerated LaTeX formula #end autogenerated stuff ### End E200 Exchange-Dispersion ### Start E200 Induction and Exchange-Induction #in this variant, no CPHF response will be calculated # E200Induction and CPHF orbitals # Exchange-Induction # A <- B #automatically programmed stuff below #automatically programmed stuff above # B <- A #automatically programmed stuff below #automatically programmed stuff above #sapt_printer('Exch-Ind20 A<-B', ExchInd20_ab) #sapt_printer('Exch-Ind20 B<-A', ExchInd20_ba) ### End E200 Induction and Exchange-Induction # ==> Compare to Psi4 <== # in Psi4, we can only run SAPT with DF-ROHF