From fbd174d0c2ee367e3cecc38d420132ecd72be221 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Wed, 20 Sep 2023 18:41:06 +0100 Subject: [PATCH 01/13] Fixes for DC --- ebcc/__init__.py | 2 +- ebcc/ansatz.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ebcc/__init__.py b/ebcc/__init__.py index cce502d3..dd566c46 100644 --- a/ebcc/__init__.py +++ b/ebcc/__init__.py @@ -123,7 +123,7 @@ def get_git_hash(directory): # --- Types of ansatz supporting by the EBCC solvers: -METHOD_TYPES = ["MP", "CC", "LCC", "QCI", "QCC"] +METHOD_TYPES = ["MP", "CC", "LCC", "QCI", "QCC", "DC"] # --- Import NumPy here to allow drop-in replacements diff --git a/ebcc/ansatz.py b/ebcc/ansatz.py index 5798fc4b..bf96abc7 100644 --- a/ebcc/ansatz.py +++ b/ebcc/ansatz.py @@ -15,6 +15,7 @@ "CC2": ("CC2", "", 0, 0), "CC3": ("CC3", "", 0, 0), "QCISD": ("QCISD", "", 0, 0), + "DCD": ("DCD", "", 0, 0), "CCSDt'": ("CCSDt'", "", 0, 0), "CCSD-S-1-1": ("CCSD", "S", 1, 1), "CCSD-SD-1-1": ("CCSD", "SD", 1, 1), @@ -257,7 +258,7 @@ def fermionic_cluster_ranks(self, spin_type="G"): # another method for method_type in sorted(METHOD_TYPES, key=len)[::-1]: if op.startswith(method_type): - op = op.lstrip(method_type) + op = op.replace(method_type, "", 1) break # If it's MP we only ever need to initialise second-order From 57f04e4c290b916b5657aa86aaf96e09ceddc830 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 17:28:43 +0100 Subject: [PATCH 02/13] Adds DCD using new reference --- ebcc/codegen/GDCD.py | 43 +++++++++++++++++++++++++++++++++++++ ebcc/codegen/RDCD.py | 47 ++++++++++++++++++++++++++++++++++++++++ ebcc/codegen/UDCD.py | 51 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 ebcc/codegen/GDCD.py create mode 100644 ebcc/codegen/RDCD.py create mode 100644 ebcc/codegen/UDCD.py diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py new file mode 100644 index 00000000..4a0bcc93 --- /dev/null +++ b/ebcc/codegen/GDCD.py @@ -0,0 +1,43 @@ +# Code generated for ebcc. + +from ebcc import numpy as np +from ebcc.util import pack_2e, einsum, Namespace + +def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + # energy + e_cc = 0 + e_cc += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 2, 3), ()) * 0.25 + + return e_cc + +def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + # T amplitudes + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 + t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 + x0 = np.zeros((nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) + del x0 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + del x1 + x2 = np.zeros((nocc, nocc), dtype=np.float64) + x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + del x2 + t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 + t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 + del x3 + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) + del x4 + + return {"t2new": t2new} + diff --git a/ebcc/codegen/RDCD.py b/ebcc/codegen/RDCD.py new file mode 100644 index 00000000..03e8bab1 --- /dev/null +++ b/ebcc/codegen/RDCD.py @@ -0,0 +1,47 @@ +# Code generated for ebcc. + +from ebcc import numpy as np +from ebcc.util import pack_2e, einsum, Namespace + +def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + # energy + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + e_cc = 0 + e_cc += einsum(t2, (0, 1, 2, 3), x0, (0, 1, 3, 2), ()) * 2.0 + del x0 + + return e_cc + +def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + # T amplitudes + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 + t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 + x0 = np.zeros((nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) + del x0 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + del x1 + x2 = np.zeros((nocc, nocc), dtype=np.float64) + x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + del x2 + t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 + t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 + del x3 + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) + del x4 + + return {"t2new": t2new} + diff --git a/ebcc/codegen/UDCD.py b/ebcc/codegen/UDCD.py new file mode 100644 index 00000000..f965757b --- /dev/null +++ b/ebcc/codegen/UDCD.py @@ -0,0 +1,51 @@ +# Code generated for ebcc. + +from ebcc import numpy as np +from ebcc.util import pack_2e, einsum, Namespace + +def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + # energy + e_cc = 0 + e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) + + return e_cc + +def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): + t2new = Namespace() + + # T amplitudes + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 + t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 + x0 = np.zeros((nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) + del x0 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + del x1 + x2 = np.zeros((nocc, nocc), dtype=np.float64) + x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + del x2 + t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 + t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 + del x3 + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) + del x4 + + t2new.aaaa = t2new_aaaa + t2new.abab = t2new_abab + t2new.bbbb = t2new_bbbb + + return {"t2new": t2new} + From bf054f62cca6e0149aefc2374da9b8e7d719d710 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 18:01:23 +0100 Subject: [PATCH 03/13] Try fixing DCD --- ebcc/codegen/GDCD.py | 52 +++++---- ebcc/codegen/RDCD.py | 123 ++++++++++++++++----- ebcc/codegen/UDCD.py | 258 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 363 insertions(+), 70 deletions(-) diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py index 4a0bcc93..e65ba3aa 100644 --- a/ebcc/codegen/GDCD.py +++ b/ebcc/codegen/GDCD.py @@ -12,32 +12,42 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 - t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 - x0 = np.zeros((nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) - x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) + t1new = np.zeros((nocc, nvir), dtype=np.float64) + t1new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 4)) * 0.5 + t1new += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) + t1new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (4, 5)) + t1new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 5)) * -1.0 + x0 = np.zeros((nvir,), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 2), (4,)) + t1new += einsum(x0, (0,), t2, (1, 2, 3, 0), (1, 3)) * 0.5 del x0 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + x1 = np.zeros((nocc,), dtype=np.float64) + x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4,)) + t1new += einsum(x1, (0,), t2, (1, 0, 2, 3), (1, 2)) * 0.5 del x1 - x2 = np.zeros((nocc, nocc), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (1, 4, 5, 2), (0, 1, 4, 5)) + t1new += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -0.5 del x2 - t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 - t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 + x3 = np.zeros((nocc, nocc), dtype=np.float64) + x3 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + t1new += einsum(x3, (0, 1), t2, (2, 1, 3, 4), (0, 3)) * 0.5 del x3 - x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) - t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) + x4 = np.zeros((nocc, nvir), dtype=np.float64) + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 5)) + t1new += einsum(x4, (0, 1), t2, (2, 0, 3, 1), (2, 3)) del x4 + x5 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x5 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1)) + x5 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 5)) * -1.0 + t1new += einsum(x5, (0, 1, 2), t2, (3, 1, 4, 2), (0, 4)) + del x5 + x6 = np.zeros((nocc, nocc, nocc), dtype=np.float64) + x6 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) * -1.0 + x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4, 0, 1)) * -0.5 + t1new += einsum(x6, (0, 1, 2), t2, (0, 1, 3, 4), (2, 3)) * 0.5 + del x6 return {"t2new": t2new} diff --git a/ebcc/codegen/RDCD.py b/ebcc/codegen/RDCD.py index 03e8bab1..0c0230d0 100644 --- a/ebcc/codegen/RDCD.py +++ b/ebcc/codegen/RDCD.py @@ -6,42 +6,115 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # energy x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -0.5 + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) e_cc = 0 - e_cc += einsum(t2, (0, 1, 2, 3), x0, (0, 1, 3, 2), ()) * 2.0 + e_cc += einsum(t2, (0, 1, 2, 3), x0, (0, 1, 2, 3), ()) * 2.0 del x0 return e_cc def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 - t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 - t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 - x0 = np.zeros((nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) - x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) - del x0 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + t1new = np.zeros((nocc, nvir), dtype=np.float64) + t1new += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) * 2.0 + t1new += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + x0 = np.zeros((nocc, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), (0, 2)) + x0 += einsum(t2, (0, 1, 2, 3), (0, 3)) * -0.5 + x1 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x1 += einsum(x0, (0, 1), v.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) * 4.0 + x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x2 += einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x2 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 del x1 - x2 = np.zeros((nocc, nocc), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + t1new += einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 2), (4, 3)) del x2 - t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 - t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 - del x3 + x3 = np.zeros((nocc, nvir), dtype=np.float64) + x3 += einsum(t2, (0, 1, 2, 3), (0, 2)) * 2.0 + x3 += einsum(t2, (0, 1, 2, 3), (0, 3)) * -1.0 x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) - t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) - del x4 + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 + x5 = np.zeros((nocc, nvir), dtype=np.float64) + x5 += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) + x5 += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) * -0.5 + x5 += einsum(x3, (0, 1), x4, (0, 2, 1, 3), (2, 3)) * 0.5 + del x3, x4 + x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + t1new += einsum(x5, (0, 1), x6, (0, 2, 1, 3), (2, 3)) * 2.0 + del x5, x6 + x7 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) + x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -0.5 + t1new += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 4)) * -2.0 + x8 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x8 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3)) + x8 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 5)) * -1.0 + x8 += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 3, 4)) * 2.0 + del x7 + x9 = np.zeros((nocc, nvir, nvir), dtype=np.float64) + x9 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -1.0 + x9 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * 2.0 + t1new += einsum(x8, (0, 1, 2), x9, (1, 3, 2), (0, 3)) * -1.0 + del x8, x9 + x10 = np.zeros((nvir, nvir, nvir), dtype=np.float64) + x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) * -0.5 + x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) + t1new += einsum(x10, (0, 1, 2), t2, (3, 4, 2, 0), (3, 1)) * 2.0 + del x10 + x11 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x11 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2)) * -1.0 + x11 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 4, 5)) + x12 = np.zeros((nocc, nvir, nvir), dtype=np.float64) + x12 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) + x12 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * -0.5 + t1new += einsum(x11, (0, 1, 2), x12, (1, 3, 2), (0, 3)) * 2.0 + del x11, x12 + x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x13 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 + x13 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t1new += einsum(x0, (0, 1), x13, (0, 2, 1, 3), (2, 3)) * 2.0 + del x13 + x14 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * -1.0 + x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * 2.0 + t1new += einsum(x14, (0, 1, 2), v.oovv, (3, 0, 4, 2), (1, 4)) * -1.0 + del x14 + x15 = np.zeros((nocc, nocc, nocc), dtype=np.float64) + x15 += einsum(t2, (0, 1, 2, 3), v.ovov, (1, 2, 4, 3), (0, 1, 4)) + x16 = np.zeros((nocc, nocc, nocc), dtype=np.float64) + x16 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) + x16 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) * -0.5 + x16 += einsum(x15, (0, 1, 2), (1, 0, 2)) + x16 += einsum(x15, (0, 1, 2), (2, 0, 1)) * -0.5 + del x15 + t1new += einsum(x16, (0, 1, 2), t2, (0, 2, 3, 4), (1, 3)) * 2.0 + del x16 + x17 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x17 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x17 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x18 = np.zeros((nvir,), dtype=np.float64) + x18 += einsum(t2, (0, 1, 2, 3), x17, (0, 1, 3, 4), (4,)) * 2.0 + x19 = np.zeros((nocc, nvir, nvir), dtype=np.float64) + x19 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -0.5 + x19 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) + t1new += einsum(x18, (0,), x19, (1, 0, 2), (1, 2)) * -2.0 + del x18, x19 + x20 = np.zeros((nocc, nocc), dtype=np.float64) + x20 += einsum(t2, (0, 1, 2, 3), x17, (1, 4, 2, 3), (0, 4)) * 2.0 + t1new += einsum(x0, (0, 1), x20, (2, 0), (2, 1)) * -2.0 + del x0, x20 + x21 = np.zeros((nocc,), dtype=np.float64) + x21 += einsum(t2, (0, 1, 2, 3), x17, (0, 4, 3, 2), (4,)) + del x17 + x22 = np.zeros((nocc, nocc, nvir), dtype=np.float64) + x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * 2.0 + x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -1.0 + t1new += einsum(x21, (0,), x22, (1, 0, 2), (1, 2)) * -2.0 + del x21, x22 return {"t2new": t2new} diff --git a/ebcc/codegen/UDCD.py b/ebcc/codegen/UDCD.py index f965757b..1ee705a3 100644 --- a/ebcc/codegen/UDCD.py +++ b/ebcc/codegen/UDCD.py @@ -7,7 +7,7 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # energy e_cc = 0 e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) - e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 2), ()) * -1.0 e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) return e_cc @@ -16,32 +16,242 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): t2new = Namespace() # T amplitudes - t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (4, 0, 5, 2)) * -1.0 - t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 - x0 = np.zeros((nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) - x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) - del x0 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.25 - t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 + t1new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + t1new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) + t1new_aa += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) + t1new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + t1new_aa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 4)) * 2.0 + t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 4)) * -1.0 + t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 5)) * -1.0 + t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 4)) + t1new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + t1new_bb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 2, 3, 5), (0, 4)) * 2.0 + t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (0, 4, 5, 3), (1, 5)) * -1.0 + t1new_bb += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) + t1new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) + t1new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (1, 5)) + t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 5)) * -1.0 + x0 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x0 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) + x0 += einsum(t2.abab, (0, 1, 2, 3), (0, 2)) * 0.5 + x1 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x1 += einsum(x0, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) * 2.0 + t1new_aa += einsum(t2.abab, (0, 1, 2, 3), x1, (4, 0, 1, 3), (4, 2)) * -1.0 del x1 - x2 = np.zeros((nocc, nocc), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(x2, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + x2 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x2 += einsum(x0, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) * 2.0 + t1new_aa += einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -2.0 del x2 - t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.25 - t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.25 - del x3 - x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) - t2new += einsum(t2, (0, 1, 2, 3), x4, (4, 1, 5, 3), (0, 4, 2, 5)) + x3 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x3 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x3 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x4 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x4 += einsum(x0, (0, 1), x3, (0, 2, 3, 1), (2, 3)) * 2.0 + x5 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x5 += einsum(t2.abab, (0, 1, 2, 3), (1, 3)) + x5 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 2)) * 2.0 + x6 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x6 += einsum(x5, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) + x7 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x7 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) + x7 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) + x7 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 2)) * -1.0 + x7 += einsum(x4, (0, 1), (0, 1)) * -1.0 del x4 + x7 += einsum(x6, (0, 1), (0, 1)) + del x6 + t1new_aa += einsum(x7, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3)) * 2.0 + t1new_bb += einsum(x7, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3)) + del x7 + x8 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x8 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x8 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x9 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x9 += einsum(x5, (0, 1), x8, (0, 2, 1, 3), (2, 3)) + x10 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x10 += einsum(x0, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3)) * 2.0 + del x0 + t1new_bb += einsum(x10, (0, 1), (0, 1)) + x11 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x11 += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) + x11 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) + x11 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 2)) * -1.0 + x11 += einsum(x9, (0, 1), (0, 1)) * -1.0 + del x9 + x11 += einsum(x10, (0, 1), (0, 1)) + del x10 + t1new_aa += einsum(x11, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3)) + t1new_bb += einsum(x11, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3)) * 2.0 + del x11 + x12 = np.zeros((nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x12 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2)) + x12 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3)) * -1.0 + x12 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 5)) * -1.0 + x12 += einsum(t2.aaaa, (0, 1, 2, 3), x3, (1, 4, 5, 3), (0, 4, 5)) * 2.0 + del x3 + t1new_aa += einsum(x12, (0, 1, 2), t2.aaaa, (3, 1, 4, 2), (0, 4)) * 2.0 + del x12 + x13 = np.zeros((nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x13 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 3)) * -1.0 + x13 += einsum(t2.aaaa, (0, 1, 2, 3), v.aabb.ovov, (1, 3, 4, 5), (0, 4, 5)) * -2.0 + x13 += einsum(t2.abab, (0, 1, 2, 3), x8, (1, 4, 3, 5), (0, 4, 5)) + del x8 + t1new_aa += einsum(x13, (0, 1, 2), t2.abab, (3, 1, 4, 2), (0, 4)) + del x13 + x14 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x14 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) * 2.0 + x14 += einsum(t2.abab, (0, 1, 2, 3), (0, 2)) + x15 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x15 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x15 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + t1new_aa += einsum(x14, (0, 1), x15, (0, 2, 1, 3), (2, 3)) * -1.0 + del x15 + x16 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x16 += einsum(t2.abab, (0, 1, 2, 3), (1, 3)) * 0.5 + x16 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 2)) + t1new_aa += einsum(x16, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) * 2.0 + del x16 + x17 = np.zeros((nocc[0], nocc[0], nvir[1]), dtype=np.float64) + x17 += einsum(v.aabb.oovv, (0, 1, 2, 3), (0, 1, 2)) + x17 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 5), (4, 0, 5)) * -1.0 + t1new_aa += einsum(x17, (0, 1, 2), t2.abab, (0, 3, 4, 2), (1, 4)) * -1.0 + del x17 + x18 = np.zeros((nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x18 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 2, 3)) + x18 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 + t1new_aa += einsum(x18, (0, 1, 2), t2.aaaa, (3, 0, 4, 1), (3, 2)) * 2.0 + del x18 + x19 = np.zeros((nocc[0], nocc[0], nocc[1]), dtype=np.float64) + x19 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2)) + x19 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 5)) + t1new_aa += einsum(x19, (0, 1, 2), t2.abab, (0, 2, 3, 4), (1, 3)) + del x19 + x20 = np.zeros((nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x20 += einsum(v.aaaa.oooo, (0, 1, 1, 2), (0, 1, 2)) + x20 += einsum(t2.aaaa, (0, 0, 1, 2), v.aaaa.ovov, (3, 2, 4, 1), (3, 0, 4)) * -1.0 + t1new_aa += einsum(x20, (0, 1, 2), t2.aaaa, (2, 0, 3, 4), (1, 3)) * -2.0 + del x20 + x21 = np.zeros((nvir[1],), dtype=np.float64) + x21 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (4,)) + x22 = np.zeros((nvir[1],), dtype=np.float64) + x22 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 4), (4,)) * -1.0 + x23 = np.zeros((nvir[1],), dtype=np.float64) + x23 += einsum(x21, (0,), (0,)) * -0.5 + del x21 + x23 += einsum(x22, (0,), (0,)) + del x22 + t1new_aa += einsum(x23, (0,), t2.abab, (1, 2, 3, 0), (1, 3)) * 2.0 + t1new_bb += einsum(x23, (0,), t2.bbbb, (1, 2, 3, 0), (1, 3)) * 4.0 + del x23 + x24 = np.zeros((nvir[0],), dtype=np.float64) + x24 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 2), (4,)) + x25 = np.zeros((nvir[0],), dtype=np.float64) + x25 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (4,)) * -1.0 + x26 = np.zeros((nvir[0],), dtype=np.float64) + x26 += einsum(x24, (0,), (0,)) * 2.0 + x26 += einsum(x25, (0,), (0,)) + t1new_aa += einsum(x26, (0,), t2.aaaa, (1, 2, 3, 0), (1, 3)) * 2.0 + del x26 + x27 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x27 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 + x27 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) * 0.5 + t1new_aa += einsum(x14, (0, 1), x27, (2, 0), (2, 1)) * -2.0 + del x14, x27 + x28 = np.zeros((nocc[1],), dtype=np.float64) + x28 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (4,)) + x29 = np.zeros((nocc[1],), dtype=np.float64) + x29 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 0, 2), (4,)) * -1.0 + x30 = np.zeros((nocc[1],), dtype=np.float64) + x30 += einsum(x28, (0,), (0,)) * -0.5 + del x28 + x30 += einsum(x29, (0,), (0,)) + del x29 + t1new_aa += einsum(x30, (0,), t2.abab, (1, 0, 2, 3), (1, 2)) * 2.0 + t1new_bb += einsum(x30, (0,), t2.bbbb, (1, 0, 2, 3), (1, 2)) * 4.0 + del x30 + x31 = np.zeros((nocc[0],), dtype=np.float64) + x31 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 0, 2), (4,)) * -1.0 + x32 = np.zeros((nocc[0],), dtype=np.float64) + x32 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (4,)) * -1.0 + x33 = np.zeros((nocc[0],), dtype=np.float64) + x33 += einsum(x31, (0,), (0,)) * 2.0 + x33 += einsum(x32, (0,), (0,)) + t1new_aa += einsum(x33, (0,), t2.aaaa, (1, 0, 2, 3), (1, 2)) * 2.0 + del x33 + x34 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x34 += einsum(x5, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) + t1new_bb += einsum(t2.bbbb, (0, 1, 2, 3), x34, (4, 1, 0, 3), (4, 2)) * -2.0 + del x34 + x35 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x35 += einsum(x5, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3)) + t1new_bb += einsum(t2.abab, (0, 1, 2, 3), x35, (0, 4, 1, 2), (4, 3)) * -1.0 + del x35 + x36 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x36 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x36 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x37 = np.zeros((nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x37 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3)) * 0.5 + x37 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2)) * -0.5 + x37 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 4, 5)) * 0.5 + x37 += einsum(t2.bbbb, (0, 1, 2, 3), x36, (1, 4, 3, 5), (0, 4, 5)) + del x36 + t1new_bb += einsum(x37, (0, 1, 2), t2.bbbb, (3, 1, 4, 2), (0, 4)) * -4.0 + del x37 + x38 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x38 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x38 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x39 = np.zeros((nocc[0], nocc[1], nvir[0]), dtype=np.float64) + x39 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1)) * -1.0 + x39 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5)) * -2.0 + x39 += einsum(t2.abab, (0, 1, 2, 3), x38, (0, 4, 5, 2), (4, 1, 5)) * -1.0 + del x38 + t1new_bb += einsum(x39, (0, 1, 2), t2.abab, (0, 3, 2, 4), (1, 4)) + del x39 + x40 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x40 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x40 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + t1new_bb += einsum(x5, (0, 1), x40, (0, 2, 1, 3), (2, 3)) * -1.0 + del x40 + x41 = np.zeros((nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x41 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0)) + x41 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 5, 3), (5, 1, 4)) * -1.0 + t1new_bb += einsum(x41, (0, 1, 2), t2.abab, (3, 0, 2, 4), (1, 4)) * -1.0 + del x41 + x42 = np.zeros((nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x42 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 2, 3)) + x42 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 + t1new_bb += einsum(x42, (0, 1, 2), t2.bbbb, (3, 0, 1, 4), (3, 2)) * -2.0 + del x42 + x43 = np.zeros((nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x43 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 2, 3)) + x43 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 5, 1)) + t1new_bb += einsum(x43, (0, 1, 2), t2.abab, (0, 1, 3, 4), (2, 4)) + del x43 + x44 = np.zeros((nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x44 += einsum(v.bbbb.oooo, (0, 1, 2, 2), (0, 1, 2)) + x44 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (4, 0, 1)) * -1.0 + t1new_bb += einsum(x44, (0, 1, 2), t2.bbbb, (2, 0, 3, 4), (1, 3)) * -2.0 + del x44 + x45 = np.zeros((nvir[0],), dtype=np.float64) + x45 += einsum(x24, (0,), (0,)) + del x24 + x45 += einsum(x25, (0,), (0,)) * 0.5 + del x25 + t1new_bb += einsum(x45, (0,), t2.abab, (1, 2, 0, 3), (2, 3)) * 2.0 + del x45 + x46 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x46 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) + x46 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 2, 1, 3), (0, 4)) * 2.0 + t1new_bb += einsum(x46, (0, 1), x5, (1, 2), (0, 2)) * -1.0 + del x5, x46 + x47 = np.zeros((nocc[0],), dtype=np.float64) + x47 += einsum(x31, (0,), (0,)) + del x31 + x47 += einsum(x32, (0,), (0,)) * 0.5 + del x32 + t1new_bb += einsum(x47, (0,), t2.abab, (0, 1, 2, 3), (1, 3)) * 2.0 + del x47 t2new.aaaa = t2new_aaaa t2new.abab = t2new_abab From f70c6f89e524a0d22efa9c8440aceb9122554e45 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 18:02:41 +0100 Subject: [PATCH 04/13] Fix t2new name --- ebcc/codegen/GDCD.py | 24 +++++------ ebcc/codegen/RDCD.py | 30 ++++++------- ebcc/codegen/UDCD.py | 100 +++++++++++++++++++++---------------------- 3 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py index e65ba3aa..8d904a36 100644 --- a/ebcc/codegen/GDCD.py +++ b/ebcc/codegen/GDCD.py @@ -12,41 +12,41 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t1new = np.zeros((nocc, nvir), dtype=np.float64) - t1new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 4)) * 0.5 - t1new += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) - t1new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (4, 5)) - t1new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 5)) * -1.0 + t2new = np.zeros((nocc, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 4)) * 0.5 + t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (4, 5)) + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 5)) * -1.0 x0 = np.zeros((nvir,), dtype=np.float64) x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 2), (4,)) - t1new += einsum(x0, (0,), t2, (1, 2, 3, 0), (1, 3)) * 0.5 + t2new += einsum(x0, (0,), t2, (1, 2, 3, 0), (1, 3)) * 0.5 del x0 x1 = np.zeros((nocc,), dtype=np.float64) x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4,)) - t1new += einsum(x1, (0,), t2, (1, 0, 2, 3), (1, 2)) * 0.5 + t2new += einsum(x1, (0,), t2, (1, 0, 2, 3), (1, 2)) * 0.5 del x1 x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (1, 4, 5, 2), (0, 1, 4, 5)) - t1new += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -0.5 + t2new += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -0.5 del x2 x3 = np.zeros((nocc, nocc), dtype=np.float64) x3 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - t1new += einsum(x3, (0, 1), t2, (2, 1, 3, 4), (0, 3)) * 0.5 + t2new += einsum(x3, (0, 1), t2, (2, 1, 3, 4), (0, 3)) * 0.5 del x3 x4 = np.zeros((nocc, nvir), dtype=np.float64) x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 5)) - t1new += einsum(x4, (0, 1), t2, (2, 0, 3, 1), (2, 3)) + t2new += einsum(x4, (0, 1), t2, (2, 0, 3, 1), (2, 3)) del x4 x5 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x5 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1)) x5 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 5)) * -1.0 - t1new += einsum(x5, (0, 1, 2), t2, (3, 1, 4, 2), (0, 4)) + t2new += einsum(x5, (0, 1, 2), t2, (3, 1, 4, 2), (0, 4)) del x5 x6 = np.zeros((nocc, nocc, nocc), dtype=np.float64) x6 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) * -1.0 x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4, 0, 1)) * -0.5 - t1new += einsum(x6, (0, 1, 2), t2, (0, 1, 3, 4), (2, 3)) * 0.5 + t2new += einsum(x6, (0, 1, 2), t2, (0, 1, 3, 4), (2, 3)) * 0.5 del x6 return {"t2new": t2new} diff --git a/ebcc/codegen/RDCD.py b/ebcc/codegen/RDCD.py index 0c0230d0..1f30f5d2 100644 --- a/ebcc/codegen/RDCD.py +++ b/ebcc/codegen/RDCD.py @@ -16,9 +16,9 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t1new = np.zeros((nocc, nvir), dtype=np.float64) - t1new += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) * 2.0 - t1new += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + t2new = np.zeros((nocc, nvir), dtype=np.float64) + t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) * 2.0 + t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 x0 = np.zeros((nocc, nvir), dtype=np.float64) x0 += einsum(t2, (0, 1, 2, 3), (0, 2)) x0 += einsum(t2, (0, 1, 2, 3), (0, 3)) * -0.5 @@ -28,7 +28,7 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x2 += einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 x2 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 del x1 - t1new += einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 2), (4, 3)) + t2new += einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 2), (4, 3)) del x2 x3 = np.zeros((nocc, nvir), dtype=np.float64) x3 += einsum(t2, (0, 1, 2, 3), (0, 2)) * 2.0 @@ -44,12 +44,12 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 - t1new += einsum(x5, (0, 1), x6, (0, 2, 1, 3), (2, 3)) * 2.0 + t2new += einsum(x5, (0, 1), x6, (0, 2, 1, 3), (2, 3)) * 2.0 del x5, x6 x7 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -0.5 - t1new += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 4)) * -2.0 + t2new += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 4)) * -2.0 x8 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x8 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3)) x8 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 5)) * -1.0 @@ -58,12 +58,12 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x9 = np.zeros((nocc, nvir, nvir), dtype=np.float64) x9 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -1.0 x9 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * 2.0 - t1new += einsum(x8, (0, 1, 2), x9, (1, 3, 2), (0, 3)) * -1.0 + t2new += einsum(x8, (0, 1, 2), x9, (1, 3, 2), (0, 3)) * -1.0 del x8, x9 x10 = np.zeros((nvir, nvir, nvir), dtype=np.float64) x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) * -0.5 x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) - t1new += einsum(x10, (0, 1, 2), t2, (3, 4, 2, 0), (3, 1)) * 2.0 + t2new += einsum(x10, (0, 1, 2), t2, (3, 4, 2, 0), (3, 1)) * 2.0 del x10 x11 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x11 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2)) * -1.0 @@ -71,17 +71,17 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x12 = np.zeros((nocc, nvir, nvir), dtype=np.float64) x12 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) x12 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * -0.5 - t1new += einsum(x11, (0, 1, 2), x12, (1, 3, 2), (0, 3)) * 2.0 + t2new += einsum(x11, (0, 1, 2), x12, (1, 3, 2), (0, 3)) * 2.0 del x11, x12 x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x13 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 x13 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t1new += einsum(x0, (0, 1), x13, (0, 2, 1, 3), (2, 3)) * 2.0 + t2new += einsum(x0, (0, 1), x13, (0, 2, 1, 3), (2, 3)) * 2.0 del x13 x14 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * -1.0 x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * 2.0 - t1new += einsum(x14, (0, 1, 2), v.oovv, (3, 0, 4, 2), (1, 4)) * -1.0 + t2new += einsum(x14, (0, 1, 2), v.oovv, (3, 0, 4, 2), (1, 4)) * -1.0 del x14 x15 = np.zeros((nocc, nocc, nocc), dtype=np.float64) x15 += einsum(t2, (0, 1, 2, 3), v.ovov, (1, 2, 4, 3), (0, 1, 4)) @@ -91,7 +91,7 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x16 += einsum(x15, (0, 1, 2), (1, 0, 2)) x16 += einsum(x15, (0, 1, 2), (2, 0, 1)) * -0.5 del x15 - t1new += einsum(x16, (0, 1, 2), t2, (0, 2, 3, 4), (1, 3)) * 2.0 + t2new += einsum(x16, (0, 1, 2), t2, (0, 2, 3, 4), (1, 3)) * 2.0 del x16 x17 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x17 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) @@ -101,11 +101,11 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x19 = np.zeros((nocc, nvir, nvir), dtype=np.float64) x19 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -0.5 x19 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) - t1new += einsum(x18, (0,), x19, (1, 0, 2), (1, 2)) * -2.0 + t2new += einsum(x18, (0,), x19, (1, 0, 2), (1, 2)) * -2.0 del x18, x19 x20 = np.zeros((nocc, nocc), dtype=np.float64) x20 += einsum(t2, (0, 1, 2, 3), x17, (1, 4, 2, 3), (0, 4)) * 2.0 - t1new += einsum(x0, (0, 1), x20, (2, 0), (2, 1)) * -2.0 + t2new += einsum(x0, (0, 1), x20, (2, 0), (2, 1)) * -2.0 del x0, x20 x21 = np.zeros((nocc,), dtype=np.float64) x21 += einsum(t2, (0, 1, 2, 3), x17, (0, 4, 3, 2), (4,)) @@ -113,7 +113,7 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x22 = np.zeros((nocc, nocc, nvir), dtype=np.float64) x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * 2.0 x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t1new += einsum(x21, (0,), x22, (1, 0, 2), (1, 2)) * -2.0 + t2new += einsum(x21, (0,), x22, (1, 0, 2), (1, 2)) * -2.0 del x21, x22 return {"t2new": t2new} diff --git a/ebcc/codegen/UDCD.py b/ebcc/codegen/UDCD.py index 1ee705a3..9c8d08ee 100644 --- a/ebcc/codegen/UDCD.py +++ b/ebcc/codegen/UDCD.py @@ -16,32 +16,32 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): t2new = Namespace() # T amplitudes - t1new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - t1new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) - t1new_aa += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) - t1new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - t1new_aa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 4)) * 2.0 - t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 4)) * -1.0 - t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 5)) * -1.0 - t1new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 4)) - t1new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - t1new_bb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 2, 3, 5), (0, 4)) * 2.0 - t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (0, 4, 5, 3), (1, 5)) * -1.0 - t1new_bb += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) - t1new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) - t1new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (1, 5)) - t1new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 5)) * -1.0 + t2new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + t2new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) + t2new_aa += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) + t2new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + t2new_aa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 4)) * 2.0 + t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 4)) * -1.0 + t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 5)) * -1.0 + t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 4)) + t2new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + t2new_bb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 2, 3, 5), (0, 4)) * 2.0 + t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (0, 4, 5, 3), (1, 5)) * -1.0 + t2new_bb += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) + t2new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) + t2new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 + t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (1, 5)) + t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 5)) * -1.0 x0 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) x0 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) x0 += einsum(t2.abab, (0, 1, 2, 3), (0, 2)) * 0.5 x1 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) x1 += einsum(x0, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) * 2.0 - t1new_aa += einsum(t2.abab, (0, 1, 2, 3), x1, (4, 0, 1, 3), (4, 2)) * -1.0 + t2new_aa += einsum(t2.abab, (0, 1, 2, 3), x1, (4, 0, 1, 3), (4, 2)) * -1.0 del x1 x2 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) x2 += einsum(x0, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) * 2.0 - t1new_aa += einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -2.0 + t2new_aa += einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -2.0 del x2 x3 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) x3 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 @@ -61,8 +61,8 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): del x4 x7 += einsum(x6, (0, 1), (0, 1)) del x6 - t1new_aa += einsum(x7, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3)) * 2.0 - t1new_bb += einsum(x7, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3)) + t2new_aa += einsum(x7, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3)) * 2.0 + t2new_bb += einsum(x7, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3)) del x7 x8 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) x8 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) @@ -72,7 +72,7 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x10 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) x10 += einsum(x0, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3)) * 2.0 del x0 - t1new_bb += einsum(x10, (0, 1), (0, 1)) + t2new_bb += einsum(x10, (0, 1), (0, 1)) x11 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) x11 += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) x11 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) @@ -81,8 +81,8 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): del x9 x11 += einsum(x10, (0, 1), (0, 1)) del x10 - t1new_aa += einsum(x11, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3)) - t1new_bb += einsum(x11, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3)) * 2.0 + t2new_aa += einsum(x11, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3)) + t2new_bb += einsum(x11, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3)) * 2.0 del x11 x12 = np.zeros((nocc[0], nocc[0], nvir[0]), dtype=np.float64) x12 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2)) @@ -90,14 +90,14 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x12 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 5)) * -1.0 x12 += einsum(t2.aaaa, (0, 1, 2, 3), x3, (1, 4, 5, 3), (0, 4, 5)) * 2.0 del x3 - t1new_aa += einsum(x12, (0, 1, 2), t2.aaaa, (3, 1, 4, 2), (0, 4)) * 2.0 + t2new_aa += einsum(x12, (0, 1, 2), t2.aaaa, (3, 1, 4, 2), (0, 4)) * 2.0 del x12 x13 = np.zeros((nocc[0], nocc[1], nvir[1]), dtype=np.float64) x13 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 3)) * -1.0 x13 += einsum(t2.aaaa, (0, 1, 2, 3), v.aabb.ovov, (1, 3, 4, 5), (0, 4, 5)) * -2.0 x13 += einsum(t2.abab, (0, 1, 2, 3), x8, (1, 4, 3, 5), (0, 4, 5)) del x8 - t1new_aa += einsum(x13, (0, 1, 2), t2.abab, (3, 1, 4, 2), (0, 4)) + t2new_aa += einsum(x13, (0, 1, 2), t2.abab, (3, 1, 4, 2), (0, 4)) del x13 x14 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) x14 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) * 2.0 @@ -105,32 +105,32 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x15 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) x15 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) x15 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - t1new_aa += einsum(x14, (0, 1), x15, (0, 2, 1, 3), (2, 3)) * -1.0 + t2new_aa += einsum(x14, (0, 1), x15, (0, 2, 1, 3), (2, 3)) * -1.0 del x15 x16 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) x16 += einsum(t2.abab, (0, 1, 2, 3), (1, 3)) * 0.5 x16 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 2)) - t1new_aa += einsum(x16, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) * 2.0 + t2new_aa += einsum(x16, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) * 2.0 del x16 x17 = np.zeros((nocc[0], nocc[0], nvir[1]), dtype=np.float64) x17 += einsum(v.aabb.oovv, (0, 1, 2, 3), (0, 1, 2)) x17 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 5), (4, 0, 5)) * -1.0 - t1new_aa += einsum(x17, (0, 1, 2), t2.abab, (0, 3, 4, 2), (1, 4)) * -1.0 + t2new_aa += einsum(x17, (0, 1, 2), t2.abab, (0, 3, 4, 2), (1, 4)) * -1.0 del x17 x18 = np.zeros((nocc[0], nvir[0], nvir[0]), dtype=np.float64) x18 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 2, 3)) x18 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t1new_aa += einsum(x18, (0, 1, 2), t2.aaaa, (3, 0, 4, 1), (3, 2)) * 2.0 + t2new_aa += einsum(x18, (0, 1, 2), t2.aaaa, (3, 0, 4, 1), (3, 2)) * 2.0 del x18 x19 = np.zeros((nocc[0], nocc[0], nocc[1]), dtype=np.float64) x19 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2)) x19 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 5)) - t1new_aa += einsum(x19, (0, 1, 2), t2.abab, (0, 2, 3, 4), (1, 3)) + t2new_aa += einsum(x19, (0, 1, 2), t2.abab, (0, 2, 3, 4), (1, 3)) del x19 x20 = np.zeros((nocc[0], nocc[0], nocc[0]), dtype=np.float64) x20 += einsum(v.aaaa.oooo, (0, 1, 1, 2), (0, 1, 2)) x20 += einsum(t2.aaaa, (0, 0, 1, 2), v.aaaa.ovov, (3, 2, 4, 1), (3, 0, 4)) * -1.0 - t1new_aa += einsum(x20, (0, 1, 2), t2.aaaa, (2, 0, 3, 4), (1, 3)) * -2.0 + t2new_aa += einsum(x20, (0, 1, 2), t2.aaaa, (2, 0, 3, 4), (1, 3)) * -2.0 del x20 x21 = np.zeros((nvir[1],), dtype=np.float64) x21 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (4,)) @@ -141,8 +141,8 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): del x21 x23 += einsum(x22, (0,), (0,)) del x22 - t1new_aa += einsum(x23, (0,), t2.abab, (1, 2, 3, 0), (1, 3)) * 2.0 - t1new_bb += einsum(x23, (0,), t2.bbbb, (1, 2, 3, 0), (1, 3)) * 4.0 + t2new_aa += einsum(x23, (0,), t2.abab, (1, 2, 3, 0), (1, 3)) * 2.0 + t2new_bb += einsum(x23, (0,), t2.bbbb, (1, 2, 3, 0), (1, 3)) * 4.0 del x23 x24 = np.zeros((nvir[0],), dtype=np.float64) x24 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 2), (4,)) @@ -151,12 +151,12 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x26 = np.zeros((nvir[0],), dtype=np.float64) x26 += einsum(x24, (0,), (0,)) * 2.0 x26 += einsum(x25, (0,), (0,)) - t1new_aa += einsum(x26, (0,), t2.aaaa, (1, 2, 3, 0), (1, 3)) * 2.0 + t2new_aa += einsum(x26, (0,), t2.aaaa, (1, 2, 3, 0), (1, 3)) * 2.0 del x26 x27 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) x27 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 x27 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) * 0.5 - t1new_aa += einsum(x14, (0, 1), x27, (2, 0), (2, 1)) * -2.0 + t2new_aa += einsum(x14, (0, 1), x27, (2, 0), (2, 1)) * -2.0 del x14, x27 x28 = np.zeros((nocc[1],), dtype=np.float64) x28 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (4,)) @@ -167,8 +167,8 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): del x28 x30 += einsum(x29, (0,), (0,)) del x29 - t1new_aa += einsum(x30, (0,), t2.abab, (1, 0, 2, 3), (1, 2)) * 2.0 - t1new_bb += einsum(x30, (0,), t2.bbbb, (1, 0, 2, 3), (1, 2)) * 4.0 + t2new_aa += einsum(x30, (0,), t2.abab, (1, 0, 2, 3), (1, 2)) * 2.0 + t2new_bb += einsum(x30, (0,), t2.bbbb, (1, 0, 2, 3), (1, 2)) * 4.0 del x30 x31 = np.zeros((nocc[0],), dtype=np.float64) x31 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 0, 2), (4,)) * -1.0 @@ -177,15 +177,15 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x33 = np.zeros((nocc[0],), dtype=np.float64) x33 += einsum(x31, (0,), (0,)) * 2.0 x33 += einsum(x32, (0,), (0,)) - t1new_aa += einsum(x33, (0,), t2.aaaa, (1, 0, 2, 3), (1, 2)) * 2.0 + t2new_aa += einsum(x33, (0,), t2.aaaa, (1, 0, 2, 3), (1, 2)) * 2.0 del x33 x34 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) x34 += einsum(x5, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) - t1new_bb += einsum(t2.bbbb, (0, 1, 2, 3), x34, (4, 1, 0, 3), (4, 2)) * -2.0 + t2new_bb += einsum(t2.bbbb, (0, 1, 2, 3), x34, (4, 1, 0, 3), (4, 2)) * -2.0 del x34 x35 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) x35 += einsum(x5, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3)) - t1new_bb += einsum(t2.abab, (0, 1, 2, 3), x35, (0, 4, 1, 2), (4, 3)) * -1.0 + t2new_bb += einsum(t2.abab, (0, 1, 2, 3), x35, (0, 4, 1, 2), (4, 3)) * -1.0 del x35 x36 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) x36 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 @@ -196,7 +196,7 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x37 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 4, 5)) * 0.5 x37 += einsum(t2.bbbb, (0, 1, 2, 3), x36, (1, 4, 3, 5), (0, 4, 5)) del x36 - t1new_bb += einsum(x37, (0, 1, 2), t2.bbbb, (3, 1, 4, 2), (0, 4)) * -4.0 + t2new_bb += einsum(x37, (0, 1, 2), t2.bbbb, (3, 1, 4, 2), (0, 4)) * -4.0 del x37 x38 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) x38 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) @@ -206,51 +206,51 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): x39 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5)) * -2.0 x39 += einsum(t2.abab, (0, 1, 2, 3), x38, (0, 4, 5, 2), (4, 1, 5)) * -1.0 del x38 - t1new_bb += einsum(x39, (0, 1, 2), t2.abab, (0, 3, 2, 4), (1, 4)) + t2new_bb += einsum(x39, (0, 1, 2), t2.abab, (0, 3, 2, 4), (1, 4)) del x39 x40 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) x40 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) x40 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - t1new_bb += einsum(x5, (0, 1), x40, (0, 2, 1, 3), (2, 3)) * -1.0 + t2new_bb += einsum(x5, (0, 1), x40, (0, 2, 1, 3), (2, 3)) * -1.0 del x40 x41 = np.zeros((nocc[1], nocc[1], nvir[0]), dtype=np.float64) x41 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0)) x41 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 5, 3), (5, 1, 4)) * -1.0 - t1new_bb += einsum(x41, (0, 1, 2), t2.abab, (3, 0, 2, 4), (1, 4)) * -1.0 + t2new_bb += einsum(x41, (0, 1, 2), t2.abab, (3, 0, 2, 4), (1, 4)) * -1.0 del x41 x42 = np.zeros((nocc[1], nvir[1], nvir[1]), dtype=np.float64) x42 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 2, 3)) x42 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t1new_bb += einsum(x42, (0, 1, 2), t2.bbbb, (3, 0, 1, 4), (3, 2)) * -2.0 + t2new_bb += einsum(x42, (0, 1, 2), t2.bbbb, (3, 0, 1, 4), (3, 2)) * -2.0 del x42 x43 = np.zeros((nocc[0], nocc[1], nocc[1]), dtype=np.float64) x43 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 2, 3)) x43 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 5, 1)) - t1new_bb += einsum(x43, (0, 1, 2), t2.abab, (0, 1, 3, 4), (2, 4)) + t2new_bb += einsum(x43, (0, 1, 2), t2.abab, (0, 1, 3, 4), (2, 4)) del x43 x44 = np.zeros((nocc[1], nocc[1], nocc[1]), dtype=np.float64) x44 += einsum(v.bbbb.oooo, (0, 1, 2, 2), (0, 1, 2)) x44 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (4, 0, 1)) * -1.0 - t1new_bb += einsum(x44, (0, 1, 2), t2.bbbb, (2, 0, 3, 4), (1, 3)) * -2.0 + t2new_bb += einsum(x44, (0, 1, 2), t2.bbbb, (2, 0, 3, 4), (1, 3)) * -2.0 del x44 x45 = np.zeros((nvir[0],), dtype=np.float64) x45 += einsum(x24, (0,), (0,)) del x24 x45 += einsum(x25, (0,), (0,)) * 0.5 del x25 - t1new_bb += einsum(x45, (0,), t2.abab, (1, 2, 0, 3), (2, 3)) * 2.0 + t2new_bb += einsum(x45, (0,), t2.abab, (1, 2, 0, 3), (2, 3)) * 2.0 del x45 x46 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) x46 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) x46 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 2, 1, 3), (0, 4)) * 2.0 - t1new_bb += einsum(x46, (0, 1), x5, (1, 2), (0, 2)) * -1.0 + t2new_bb += einsum(x46, (0, 1), x5, (1, 2), (0, 2)) * -1.0 del x5, x46 x47 = np.zeros((nocc[0],), dtype=np.float64) x47 += einsum(x31, (0,), (0,)) del x31 x47 += einsum(x32, (0,), (0,)) * 0.5 del x32 - t1new_bb += einsum(x47, (0,), t2.abab, (0, 1, 2, 3), (1, 3)) * 2.0 + t2new_bb += einsum(x47, (0,), t2.abab, (0, 1, 2, 3), (1, 3)) * 2.0 del x47 t2new.aaaa = t2new_aaaa From 7fba5e7c7691abcf0974fdaa3e93d71cb04dd26f Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 18:07:35 +0100 Subject: [PATCH 05/13] Fix tensor rank --- ebcc/codegen/GDCD.py | 65 +++---- ebcc/codegen/RDCD.py | 159 +++++++---------- ebcc/codegen/UDCD.py | 402 ++++++++++++++++++++----------------------- 3 files changed, 286 insertions(+), 340 deletions(-) diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py index 8d904a36..1ebdb829 100644 --- a/ebcc/codegen/GDCD.py +++ b/ebcc/codegen/GDCD.py @@ -12,42 +12,47 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t2new = np.zeros((nocc, nvir), dtype=np.float64) - t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 4)) * 0.5 - t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (4, 5)) - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 5)) * -1.0 - x0 = np.zeros((nvir,), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 2), (4,)) - t2new += einsum(x0, (0,), t2, (1, 2, 3, 0), (1, 3)) * 0.5 + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 + t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) + t2new += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x0, (0, 1, 2, 3), (0, 1, 3, 2)) + t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x0 - x1 = np.zeros((nocc,), dtype=np.float64) - x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4,)) - t2new += einsum(x1, (0,), t2, (1, 0, 2, 3), (1, 2)) * 0.5 + x1 = np.zeros((nvir, nvir), dtype=np.float64) + x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x2 += einsum(x1, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) del x1 - x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (1, 4, 5, 2), (0, 1, 4, 5)) - t2new += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -0.5 - del x2 - x3 = np.zeros((nocc, nocc), dtype=np.float64) - x3 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - t2new += einsum(x3, (0, 1), t2, (2, 1, 3, 4), (0, 3)) * 0.5 + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(t2, (0, 1, 2, 3), x3, (4, 1, 5, 3), (0, 4, 2, 5)) del x3 - x4 = np.zeros((nocc, nvir), dtype=np.float64) - x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 5)) - t2new += einsum(x4, (0, 1), t2, (2, 0, 3, 1), (2, 3)) + x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x5 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + del x2 + x5 += einsum(x4, (0, 1, 2, 3), (0, 1, 2, 3)) del x4 - x5 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x5 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1)) - x5 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 5)) * -1.0 - t2new += einsum(x5, (0, 1, 2), t2, (3, 1, 4, 2), (0, 4)) + t2new += einsum(x5, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x5, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 del x5 - x6 = np.zeros((nocc, nocc, nocc), dtype=np.float64) - x6 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) * -1.0 - x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 0, 2, 3), (4, 0, 1)) * -0.5 - t2new += einsum(x6, (0, 1, 2), t2, (0, 1, 3, 4), (2, 3)) * 0.5 + x6 = np.zeros((nocc, nocc), dtype=np.float64) + x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x7 += einsum(x6, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) del x6 + t2new += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.5 + t2new += einsum(x7, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.5 + del x7 + x8 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x8 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x8 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 5, 2, 3), (4, 5, 0, 1)) * 0.5 + t2new += einsum(t2, (0, 1, 2, 3), x8, (0, 1, 4, 5), (4, 5, 2, 3)) * 0.5 + del x8 return {"t2new": t2new} diff --git a/ebcc/codegen/RDCD.py b/ebcc/codegen/RDCD.py index 1f30f5d2..4051f742 100644 --- a/ebcc/codegen/RDCD.py +++ b/ebcc/codegen/RDCD.py @@ -6,115 +6,76 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # energy x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -0.5 - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 e_cc = 0 - e_cc += einsum(t2, (0, 1, 2, 3), x0, (0, 1, 2, 3), ()) * 2.0 + e_cc += einsum(t2, (0, 1, 2, 3), x0, (0, 1, 3, 2), ()) * 2.0 del x0 return e_cc def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes - t2new = np.zeros((nocc, nvir), dtype=np.float64) - t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) * 2.0 - t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - x0 = np.zeros((nocc, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), (0, 2)) - x0 += einsum(t2, (0, 1, 2, 3), (0, 3)) * -0.5 - x1 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x1 += einsum(x0, (0, 1), v.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) * 4.0 - x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x2 += einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - x2 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 - del x1 - t2new += einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 2), (4, 3)) + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) + t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) * 2.0 + t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 2), (4, 0, 3, 5)) * -1.0 + t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2)) * -1.0 + t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5)) + t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x1 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x2 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 5, 2), (0, 4, 3, 5)) + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 5, 3), (0, 4, 2, 5)) * 2.0 del x2 - x3 = np.zeros((nocc, nvir), dtype=np.float64) - x3 += einsum(t2, (0, 1, 2, 3), (0, 2)) * 2.0 - x3 += einsum(t2, (0, 1, 2, 3), (0, 3)) * -1.0 - x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 - x5 = np.zeros((nocc, nvir), dtype=np.float64) - x5 += einsum(v.ovov, (0, 1, 2, 3), (0, 1)) - x5 += einsum(v.oovv, (0, 1, 2, 3), (0, 2)) * -0.5 - x5 += einsum(x3, (0, 1), x4, (0, 2, 1, 3), (2, 3)) * 0.5 - del x3, x4 - x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - x6 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 - t2new += einsum(x5, (0, 1), x6, (0, 2, 1, 3), (2, 3)) * 2.0 - del x5, x6 - x7 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) - x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -0.5 - t2new += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 4)) * -2.0 - x8 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x8 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3)) - x8 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 5)) * -1.0 - x8 += einsum(x7, (0, 1, 2), v.ovov, (3, 4, 0, 2), (1, 3, 4)) * 2.0 + x4 = np.zeros((nvir, nvir), dtype=np.float64) + x4 += einsum(t2, (0, 1, 2, 3), x1, (0, 1, 3, 4), (2, 4)) + x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x5 += einsum(x4, (0, 1), t2, (2, 3, 1, 4), (2, 3, 4, 0)) * 2.0 + del x4 + x6 = np.zeros((nocc, nocc), dtype=np.float64) + x6 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 2, 3), (0, 4)) + x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x7 += einsum(x6, (0, 1), t2, (2, 1, 3, 4), (2, 0, 4, 3)) * 2.0 + del x6 + x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x8 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + del x3 + x8 += einsum(x5, (0, 1, 2, 3), (1, 0, 2, 3)) + del x5 + x8 += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) del x7 - x9 = np.zeros((nocc, nvir, nvir), dtype=np.float64) - x9 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -1.0 - x9 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * 2.0 - t2new += einsum(x8, (0, 1, 2), x9, (1, 3, 2), (0, 3)) * -1.0 - del x8, x9 - x10 = np.zeros((nvir, nvir, nvir), dtype=np.float64) - x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) * -0.5 - x10 += einsum(v.vvvv, (0, 1, 1, 2), (0, 1, 2)) - t2new += einsum(x10, (0, 1, 2), t2, (3, 4, 2, 0), (3, 1)) * 2.0 + t2new += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x8, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x8 + x9 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x9 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x9 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x9 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 5, 3), (0, 4, 2, 5)) * 2.0 + del x1 + t2new += einsum(t2, (0, 1, 2, 3), x9, (4, 1, 5, 3), (0, 4, 2, 5)) * 2.0 + del x9 + x10 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x10 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x10 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 5, 3), (4, 0, 5, 1)) + t2new += einsum(t2, (0, 1, 2, 3), x10, (0, 4, 1, 5), (4, 5, 2, 3)) del x10 - x11 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x11 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2)) * -1.0 - x11 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 4, 5)) - x12 = np.zeros((nocc, nvir, nvir), dtype=np.float64) - x12 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) - x12 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) * -0.5 - t2new += einsum(x11, (0, 1, 2), x12, (1, 3, 2), (0, 3)) * 2.0 - del x11, x12 - x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x13 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 - x13 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new += einsum(x0, (0, 1), x13, (0, 2, 1, 3), (2, 3)) * 2.0 - del x13 - x14 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * -1.0 - x14 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * 2.0 - t2new += einsum(x14, (0, 1, 2), v.oovv, (3, 0, 4, 2), (1, 4)) * -1.0 - del x14 - x15 = np.zeros((nocc, nocc, nocc), dtype=np.float64) - x15 += einsum(t2, (0, 1, 2, 3), v.ovov, (1, 2, 4, 3), (0, 1, 4)) - x16 = np.zeros((nocc, nocc, nocc), dtype=np.float64) - x16 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) - x16 += einsum(v.oooo, (0, 1, 1, 2), (0, 1, 2)) * -0.5 - x16 += einsum(x15, (0, 1, 2), (1, 0, 2)) - x16 += einsum(x15, (0, 1, 2), (2, 0, 1)) * -0.5 - del x15 - t2new += einsum(x16, (0, 1, 2), t2, (0, 2, 3, 4), (1, 3)) * 2.0 - del x16 - x17 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x17 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x17 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 - x18 = np.zeros((nvir,), dtype=np.float64) - x18 += einsum(t2, (0, 1, 2, 3), x17, (0, 1, 3, 4), (4,)) * 2.0 - x19 = np.zeros((nocc, nvir, nvir), dtype=np.float64) - x19 += einsum(t2, (0, 1, 2, 3), (0, 2, 3)) * -0.5 - x19 += einsum(t2, (0, 1, 2, 3), (0, 3, 2)) - t2new += einsum(x18, (0,), x19, (1, 0, 2), (1, 2)) * -2.0 - del x18, x19 - x20 = np.zeros((nocc, nocc), dtype=np.float64) - x20 += einsum(t2, (0, 1, 2, 3), x17, (1, 4, 2, 3), (0, 4)) * 2.0 - t2new += einsum(x0, (0, 1), x20, (2, 0), (2, 1)) * -2.0 - del x0, x20 - x21 = np.zeros((nocc,), dtype=np.float64) - x21 += einsum(t2, (0, 1, 2, 3), x17, (0, 4, 3, 2), (4,)) - del x17 - x22 = np.zeros((nocc, nocc, nvir), dtype=np.float64) - x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 2)) * 2.0 - x22 += einsum(t2, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t2new += einsum(x21, (0,), x22, (1, 0, 2), (1, 2)) * -2.0 - del x21, x22 + x11 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x11 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x11 += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) + del x0 + t2new += einsum(t2, (0, 1, 2, 3), x11, (4, 1, 5, 2), (0, 4, 3, 5)) + del x11 + x12 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x12 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x12 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 4, 3, 5)) + t2new += einsum(t2, (0, 1, 2, 3), x12, (4, 1, 5, 2), (0, 4, 5, 3)) + del x12 return {"t2new": t2new} diff --git a/ebcc/codegen/UDCD.py b/ebcc/codegen/UDCD.py index 9c8d08ee..c6412df7 100644 --- a/ebcc/codegen/UDCD.py +++ b/ebcc/codegen/UDCD.py @@ -6,9 +6,9 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # energy e_cc = 0 + e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 2), ()) * -1.0 - e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) return e_cc @@ -16,242 +16,222 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): t2new = Namespace() # T amplitudes - t2new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - t2new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) - t2new_aa += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) - t2new_aa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - t2new_aa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 4)) * 2.0 - t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 4)) * -1.0 - t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 5)) * -1.0 - t2new_aa += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 4)) - t2new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - t2new_bb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 2, 3, 5), (0, 4)) * 2.0 - t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (0, 4, 5, 3), (1, 5)) * -1.0 - t2new_bb += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) - t2new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) - t2new_bb += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 3)) * -1.0 - t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (1, 5)) - t2new_bb += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 5)) * -1.0 - x0 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x0 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) - x0 += einsum(t2.abab, (0, 1, 2, 3), (0, 2)) * 0.5 - x1 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) - x1 += einsum(x0, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) * 2.0 - t2new_aa += einsum(t2.abab, (0, 1, 2, 3), x1, (4, 0, 1, 3), (4, 2)) * -1.0 + t2new_aaaa = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 + t2new_aaaa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + t2new_aaaa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + t2new_abab = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (4, 0, 5, 3), (4, 1, 2, 5)) * -1.0 + t2new_abab += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) + t2new_bbbb = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 + x0 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x0 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + x1 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x1 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x1 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x1 += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) + x2 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x2 += einsum(t2.aaaa, (0, 1, 2, 3), x1, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 del x1 - x2 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x2 += einsum(x0, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) * 2.0 - t2new_aa += einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2)) * -2.0 - del x2 x3 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x3 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x3 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x4 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x4 += einsum(x0, (0, 1), x3, (0, 2, 3, 1), (2, 3)) * 2.0 - x5 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x5 += einsum(t2.abab, (0, 1, 2, 3), (1, 3)) - x5 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 2)) * 2.0 - x6 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x6 += einsum(x5, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) - x7 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x7 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1)) - x7 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 1)) - x7 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 2)) * -1.0 - x7 += einsum(x4, (0, 1), (0, 1)) * -1.0 - del x4 - x7 += einsum(x6, (0, 1), (0, 1)) - del x6 - t2new_aa += einsum(x7, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3)) * 2.0 - t2new_bb += einsum(x7, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3)) - del x7 - x8 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x8 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x8 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - x9 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x9 += einsum(x5, (0, 1), x8, (0, 2, 1, 3), (2, 3)) - x10 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x10 += einsum(x0, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3)) * 2.0 - del x0 - t2new_bb += einsum(x10, (0, 1), (0, 1)) - x11 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x11 += einsum(v.aabb.ovov, (0, 1, 2, 3), (2, 3)) - x11 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1)) - x11 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 2)) * -1.0 - x11 += einsum(x9, (0, 1), (0, 1)) * -1.0 - del x9 - x11 += einsum(x10, (0, 1), (0, 1)) - del x10 - t2new_aa += einsum(x11, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3)) - t2new_bb += einsum(x11, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3)) * 2.0 - del x11 - x12 = np.zeros((nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x12 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2)) - x12 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3)) * -1.0 - x12 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 5)) * -1.0 - x12 += einsum(t2.aaaa, (0, 1, 2, 3), x3, (1, 4, 5, 3), (0, 4, 5)) * 2.0 + x3 += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) + x3 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) + del x2 + t2new_aaaa += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_aaaa += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_aaaa += einsum(x3, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + t2new_aaaa += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) del x3 - t2new_aa += einsum(x12, (0, 1, 2), t2.aaaa, (3, 1, 4, 2), (0, 4)) * 2.0 - del x12 - x13 = np.zeros((nocc[0], nocc[1], nvir[1]), dtype=np.float64) - x13 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 3)) * -1.0 - x13 += einsum(t2.aaaa, (0, 1, 2, 3), v.aabb.ovov, (1, 3, 4, 5), (0, 4, 5)) * -2.0 - x13 += einsum(t2.abab, (0, 1, 2, 3), x8, (1, 4, 3, 5), (0, 4, 5)) + x4 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x4 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x4 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x5 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x5 += einsum(t2.aaaa, (0, 1, 2, 3), x4, (1, 4, 3, 5), (0, 4, 2, 5)) + x6 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x6 += einsum(t2.aaaa, (0, 1, 2, 3), x5, (4, 1, 5, 3), (0, 4, 2, 5)) * -4.0 + del x5 + x7 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x7 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x7 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x8 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x8 += einsum(t2.abab, (0, 1, 2, 3), x7, (1, 4, 3, 5), (0, 4, 2, 5)) + del x7 + x9 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x9 += einsum(t2.abab, (0, 1, 2, 3), x8, (4, 1, 5, 3), (0, 4, 2, 5)) * -1.0 del x8 - t2new_aa += einsum(x13, (0, 1, 2), t2.abab, (3, 1, 4, 2), (0, 4)) + x10 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x10 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 + x11 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x11 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (2, 4)) + x12 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x12 += einsum(x10, (0, 1), (0, 1)) + x12 += einsum(x11, (0, 1), (0, 1)) * 0.5 + x13 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x13 += einsum(x12, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 4, 0)) * -4.0 + del x12 + x14 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x14 += einsum(x6, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x6 + x14 += einsum(x9, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x9 + x14 += einsum(x13, (0, 1, 2, 3), (1, 0, 2, 3)) del x13 - x14 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x14 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 2)) * 2.0 - x14 += einsum(t2.abab, (0, 1, 2, 3), (0, 2)) - x15 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x15 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - x15 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - t2new_aa += einsum(x14, (0, 1), x15, (0, 2, 1, 3), (2, 3)) * -1.0 - del x15 - x16 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x16 += einsum(t2.abab, (0, 1, 2, 3), (1, 3)) * 0.5 - x16 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 2)) - t2new_aa += einsum(x16, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) * 2.0 - del x16 - x17 = np.zeros((nocc[0], nocc[0], nvir[1]), dtype=np.float64) - x17 += einsum(v.aabb.oovv, (0, 1, 2, 3), (0, 1, 2)) - x17 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 5), (4, 0, 5)) * -1.0 - t2new_aa += einsum(x17, (0, 1, 2), t2.abab, (0, 3, 4, 2), (1, 4)) * -1.0 + t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 3, 2)) + del x14 + x15 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x15 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 + x16 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x16 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) + x17 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x17 += einsum(x15, (0, 1), (0, 1)) + x17 += einsum(x16, (0, 1), (0, 1)) * 0.5 + x18 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x18 += einsum(x17, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4)) * -4.0 del x17 - x18 = np.zeros((nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x18 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 2, 3)) - x18 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t2new_aa += einsum(x18, (0, 1, 2), t2.aaaa, (3, 0, 4, 1), (3, 2)) * 2.0 + t2new_aaaa += einsum(x18, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_aaaa += einsum(x18, (0, 1, 2, 3), (1, 0, 3, 2)) del x18 - x19 = np.zeros((nocc[0], nocc[0], nocc[1]), dtype=np.float64) - x19 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2)) - x19 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 5)) - t2new_aa += einsum(x19, (0, 1, 2), t2.abab, (0, 2, 3, 4), (1, 3)) + x19 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x19 += einsum(v.aaaa.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x19 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 5, 2), (4, 0, 1, 5)) * -1.0 + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), x19, (0, 4, 5, 1), (5, 4, 2, 3)) * -2.0 del x19 - x20 = np.zeros((nocc[0], nocc[0], nocc[0]), dtype=np.float64) - x20 += einsum(v.aaaa.oooo, (0, 1, 1, 2), (0, 1, 2)) - x20 += einsum(t2.aaaa, (0, 0, 1, 2), v.aaaa.ovov, (3, 2, 4, 1), (3, 0, 4)) * -1.0 - t2new_aa += einsum(x20, (0, 1, 2), t2.aaaa, (2, 0, 3, 4), (1, 3)) * -2.0 - del x20 - x21 = np.zeros((nvir[1],), dtype=np.float64) - x21 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (4,)) - x22 = np.zeros((nvir[1],), dtype=np.float64) - x22 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 4), (4,)) * -1.0 - x23 = np.zeros((nvir[1],), dtype=np.float64) - x23 += einsum(x21, (0,), (0,)) * -0.5 + x20 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x20 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) + t2new_abab += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + x21 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x21 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x21 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x21 += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) + del x0 + x21 += einsum(t2.aaaa, (0, 1, 2, 3), x4, (1, 4, 3, 5), (4, 0, 5, 2)) * -2.0 + del x4 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x21, (0, 4, 2, 5), (4, 1, 5, 3)) del x21 - x23 += einsum(x22, (0,), (0,)) - del x22 - t2new_aa += einsum(x23, (0,), t2.abab, (1, 2, 3, 0), (1, 3)) * 2.0 - t2new_bb += einsum(x23, (0,), t2.bbbb, (1, 2, 3, 0), (1, 3)) * 4.0 + x22 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x22 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x22 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x23 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x23 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 + x23 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x23 += einsum(t2.bbbb, (0, 1, 2, 3), x22, (1, 4, 3, 5), (4, 0, 5, 2)) * -1.0 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x23, (1, 4, 3, 5), (0, 4, 2, 5)) * -2.0 del x23 - x24 = np.zeros((nvir[0],), dtype=np.float64) - x24 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 2), (4,)) - x25 = np.zeros((nvir[0],), dtype=np.float64) - x25 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (4,)) * -1.0 - x26 = np.zeros((nvir[0],), dtype=np.float64) - x26 += einsum(x24, (0,), (0,)) * 2.0 - x26 += einsum(x25, (0,), (0,)) - t2new_aa += einsum(x26, (0,), t2.aaaa, (1, 2, 3, 0), (1, 3)) * 2.0 + x24 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x24 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x24 += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + del x20 + t2new_abab += einsum(t2.aaaa, (0, 1, 2, 3), x24, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 + x25 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) + x25 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1)) + x25 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 5, 3), (5, 1, 4, 2)) * -1.0 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x25, (1, 4, 2, 5), (0, 4, 5, 3)) * -1.0 + del x25 + x26 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x26 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x26 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 5, 1)) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x26, (0, 4, 1, 5), (4, 5, 2, 3)) del x26 - x27 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x27 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 - x27 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) * 0.5 - t2new_aa += einsum(x14, (0, 1), x27, (2, 0), (2, 1)) * -2.0 - del x14, x27 - x28 = np.zeros((nocc[1],), dtype=np.float64) - x28 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (4,)) - x29 = np.zeros((nocc[1],), dtype=np.float64) - x29 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 0, 2), (4,)) * -1.0 - x30 = np.zeros((nocc[1],), dtype=np.float64) - x30 += einsum(x28, (0,), (0,)) * -0.5 + x27 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x27 += einsum(x10, (0, 1), (0, 1)) * 2.0 + del x10 + x27 += einsum(x11, (0, 1), (0, 1)) + del x11 + t2new_abab += einsum(x27, (0, 1), t2.abab, (2, 3, 1, 4), (2, 3, 0, 4)) * -1.0 + del x27 + x28 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x28 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4)) + x29 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x29 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 + x30 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x30 += einsum(x28, (0, 1), (0, 1)) del x28 - x30 += einsum(x29, (0,), (0,)) + x30 += einsum(x29, (0, 1), (0, 1)) * 2.0 del x29 - t2new_aa += einsum(x30, (0,), t2.abab, (1, 0, 2, 3), (1, 2)) * 2.0 - t2new_bb += einsum(x30, (0,), t2.bbbb, (1, 0, 2, 3), (1, 2)) * 4.0 - del x30 - x31 = np.zeros((nocc[0],), dtype=np.float64) - x31 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 0, 2), (4,)) * -1.0 - x32 = np.zeros((nocc[0],), dtype=np.float64) - x32 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (4,)) * -1.0 - x33 = np.zeros((nocc[0],), dtype=np.float64) - x33 += einsum(x31, (0,), (0,)) * 2.0 - x33 += einsum(x32, (0,), (0,)) - t2new_aa += einsum(x33, (0,), t2.aaaa, (1, 0, 2, 3), (1, 2)) * 2.0 + t2new_abab += einsum(x30, (0, 1), t2.abab, (2, 3, 4, 1), (2, 3, 4, 0)) * -1.0 + x31 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x31 += einsum(x15, (0, 1), (0, 1)) * 2.0 + del x15 + x31 += einsum(x16, (0, 1), (0, 1)) + del x16 + t2new_abab += einsum(x31, (0, 1), t2.abab, (1, 2, 3, 4), (0, 2, 3, 4)) * -1.0 + del x31 + x32 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x32 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) + x33 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x33 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 + x34 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x34 += einsum(x32, (0, 1), (0, 1)) + del x32 + x34 += einsum(x33, (0, 1), (0, 1)) * 2.0 del x33 - x34 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x34 += einsum(x5, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) - t2new_bb += einsum(t2.bbbb, (0, 1, 2, 3), x34, (4, 1, 0, 3), (4, 2)) * -2.0 - del x34 - x35 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) - x35 += einsum(x5, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3)) - t2new_bb += einsum(t2.abab, (0, 1, 2, 3), x35, (0, 4, 1, 2), (4, 3)) * -1.0 - del x35 + t2new_abab += einsum(x34, (0, 1), t2.abab, (2, 1, 3, 4), (2, 0, 3, 4)) * -1.0 + x35 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x35 += einsum(t2.bbbb, (0, 1, 2, 3), x22, (1, 4, 5, 3), (0, 4, 2, 5)) + del x22 x36 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x36 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x36 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x37 = np.zeros((nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x37 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3)) * 0.5 - x37 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2)) * -0.5 - x37 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (1, 4, 5)) * 0.5 - x37 += einsum(t2.bbbb, (0, 1, 2, 3), x36, (1, 4, 3, 5), (0, 4, 5)) + x36 += einsum(t2.bbbb, (0, 1, 2, 3), x35, (4, 1, 5, 3), (0, 4, 2, 5)) * -4.0 + del x35 + x37 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x37 += einsum(x30, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 4, 0)) * -2.0 + del x30 + x38 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x38 += einsum(x36, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x36 - t2new_bb += einsum(x37, (0, 1, 2), t2.bbbb, (3, 1, 4, 2), (0, 4)) * -4.0 + x38 += einsum(x37, (0, 1, 2, 3), (1, 0, 2, 3)) del x37 - x38 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x38 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x38 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - x39 = np.zeros((nocc[0], nocc[1], nvir[0]), dtype=np.float64) - x39 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1)) * -1.0 - x39 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5)) * -2.0 - x39 += einsum(t2.abab, (0, 1, 2, 3), x38, (0, 4, 5, 2), (4, 1, 5)) * -1.0 + t2new_bbbb += einsum(x38, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_bbbb += einsum(x38, (0, 1, 2, 3), (0, 1, 3, 2)) del x38 - t2new_bb += einsum(x39, (0, 1, 2), t2.abab, (0, 3, 2, 4), (1, 4)) + x39 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x39 += einsum(x34, (0, 1), t2.bbbb, (2, 1, 3, 4), (2, 0, 3, 4)) * -2.0 + del x34 + t2new_bbbb += einsum(x39, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_bbbb += einsum(x39, (0, 1, 2, 3), (1, 0, 3, 2)) del x39 - x40 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x40 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - x40 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - t2new_bb += einsum(x5, (0, 1), x40, (0, 2, 1, 3), (2, 3)) * -1.0 + x40 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x40 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x40 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x41 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x41 += einsum(t2.abab, (0, 1, 2, 3), x40, (0, 4, 5, 2), (4, 1, 5, 3)) del x40 - x41 = np.zeros((nocc[1], nocc[1], nvir[0]), dtype=np.float64) - x41 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0)) - x41 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 5, 3), (5, 1, 4)) * -1.0 - t2new_bb += einsum(x41, (0, 1, 2), t2.abab, (3, 0, 2, 4), (1, 4)) * -1.0 + x42 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x42 += einsum(t2.abab, (0, 1, 2, 3), x41, (0, 4, 2, 5), (4, 1, 5, 3)) * -1.0 del x41 - x42 = np.zeros((nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x42 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 2, 3)) - x42 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 1, 3)) * -1.0 - t2new_bb += einsum(x42, (0, 1, 2), t2.bbbb, (3, 0, 1, 4), (3, 2)) * -2.0 + x43 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x43 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x43 += einsum(x42, (0, 1, 2, 3), (1, 0, 3, 2)) del x42 - x43 = np.zeros((nocc[0], nocc[1], nocc[1]), dtype=np.float64) - x43 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 2, 3)) - x43 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 5, 1)) - t2new_bb += einsum(x43, (0, 1, 2), t2.abab, (0, 1, 3, 4), (2, 4)) + t2new_bbbb += einsum(x43, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_bbbb += einsum(x43, (0, 1, 2, 3), (0, 1, 2, 3)) del x43 - x44 = np.zeros((nocc[1], nocc[1], nocc[1]), dtype=np.float64) - x44 += einsum(v.bbbb.oooo, (0, 1, 2, 2), (0, 1, 2)) - x44 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (4, 0, 1)) * -1.0 - t2new_bb += einsum(x44, (0, 1, 2), t2.bbbb, (2, 0, 3, 4), (1, 3)) * -2.0 - del x44 - x45 = np.zeros((nvir[0],), dtype=np.float64) - x45 += einsum(x24, (0,), (0,)) + x44 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x44 += einsum(t2.abab, (0, 1, 2, 3), x24, (0, 4, 2, 5), (4, 1, 5, 3)) del x24 - x45 += einsum(x25, (0,), (0,)) * 0.5 - del x25 - t2new_bb += einsum(x45, (0,), t2.abab, (1, 2, 0, 3), (2, 3)) * 2.0 + x45 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x45 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x45 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x46 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x46 += einsum(t2.bbbb, (0, 1, 2, 3), x45, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 del x45 - x46 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x46 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) - x46 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 2, 1, 3), (0, 4)) * 2.0 - t2new_bb += einsum(x46, (0, 1), x5, (1, 2), (0, 2)) * -1.0 - del x5, x46 - x47 = np.zeros((nocc[0],), dtype=np.float64) - x47 += einsum(x31, (0,), (0,)) - del x31 - x47 += einsum(x32, (0,), (0,)) * 0.5 - del x32 - t2new_bb += einsum(x47, (0,), t2.abab, (0, 1, 2, 3), (1, 3)) * 2.0 + x47 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x47 += einsum(x44, (0, 1, 2, 3), (1, 0, 3, 2)) + del x44 + x47 += einsum(x46, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x46 + t2new_bbbb += einsum(x47, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_bbbb += einsum(x47, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_bbbb += einsum(x47, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + t2new_bbbb += einsum(x47, (0, 1, 2, 3), (1, 0, 3, 2)) del x47 + x48 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x48 += einsum(v.bbbb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x48 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 5, 2), (4, 0, 1, 5)) * -1.0 + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), x48, (0, 4, 5, 1), (5, 4, 2, 3)) * -2.0 + del x48 t2new.aaaa = t2new_aaaa t2new.abab = t2new_abab From 51668c8828ceb3500d3a5831eb3726b4ced5a8fc Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 18:16:26 +0100 Subject: [PATCH 06/13] Try CCD comparison --- ebcc/codegen/GDCD.py | 62 ++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py index 1ebdb829..5a833caa 100644 --- a/ebcc/codegen/GDCD.py +++ b/ebcc/codegen/GDCD.py @@ -15,44 +15,56 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) - t2new += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new += einsum(x0, (0, 1, 2, 3), (0, 1, 3, 2)) - t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 2, 3)) - t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x0 = np.zeros((nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) del x0 - x1 = np.zeros((nvir, nvir), dtype=np.float64) - x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x2 += einsum(x1, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) - del x1 + x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + x3 += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 5, 3), (0, 4, 2, 5)) + del x2 x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(t2, (0, 1, 2, 3), x3, (4, 1, 5, 3), (0, 4, 2, 5)) + x4 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + del x1 + x4 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) del x3 - x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x5 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 - del x2 - x5 += einsum(x4, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x4, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x4, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 del x4 - t2new += einsum(x5, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(x5, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - del x5 + x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x5 += einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4)) x6 = np.zeros((nocc, nocc), dtype=np.float64) x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x7 += einsum(x6, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) del x6 - t2new += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.5 - t2new += einsum(x7, (0, 1, 2, 3), (1, 0, 3, 2)) * -0.5 + x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x8 += einsum(x5, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x5 + x8 += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.5 del x7 - x8 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) - x8 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) - x8 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 5, 2, 3), (4, 5, 0, 1)) * 0.5 - t2new += einsum(t2, (0, 1, 2, 3), x8, (0, 1, 4, 5), (4, 5, 2, 3)) * 0.5 + t2new += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x8, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 del x8 + x9 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x9 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) + t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 3, 2)) + t2new += einsum(x9, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new += einsum(x9, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x9 + x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x10 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) + t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x10 + x11 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x11 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + x11 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 5, 2, 3), (4, 5, 0, 1)) + t2new += einsum(t2, (0, 1, 2, 3), x11, (0, 1, 4, 5), (4, 5, 2, 3)) * 0.25 + del x11 return {"t2new": t2new} From 3b9bb8d0ab1a547cfdb2a416733973a2ee92f7df Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 19:04:51 +0100 Subject: [PATCH 07/13] Now try actual DCD --- ebcc/codegen/GDCD.py | 68 +++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py index 5a833caa..a07138aa 100644 --- a/ebcc/codegen/GDCD.py +++ b/ebcc/codegen/GDCD.py @@ -15,56 +15,52 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - x0 = np.zeros((nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) - x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x1 += einsum(x0, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) - del x0 + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4)) + x1 = np.zeros((nocc, nocc), dtype=np.float64) + x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (0, 4, 2, 5)) + x2 += einsum(x1, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) + del x1 x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 5, 3), (0, 4, 2, 5)) + x3 += einsum(x0, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x0 + x3 += einsum(x2, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 del x2 - x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 - del x1 - x4 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 del x3 - t2new += einsum(x4, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(x4, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) + t2new += einsum(x4, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new += einsum(x4, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x4 - x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x5 += einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4)) - x6 = np.zeros((nocc, nocc), dtype=np.float64) - x6 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) + x5 = np.zeros((nvir, nvir), dtype=np.float64) + x5 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) + x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x6 += einsum(x5, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) + del x5 x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x7 += einsum(x6, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) - del x6 + x7 += einsum(t2, (0, 1, 2, 3), vs, (4, 1, 5, 3), (0, 4, 2, 5)) x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x8 += einsum(x5, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - del x5 - x8 += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.5 + x8 += einsum(t2, (0, 1, 2, 3), x7, (4, 1, 5, 3), (0, 4, 2, 5)) del x7 - t2new += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(x8, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 - del x8 x9 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x9 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) - t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 3, 2)) - t2new += einsum(x9, (0, 1, 2, 3), (1, 0, 2, 3)) - t2new += einsum(x9, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x9 += einsum(x6, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.25 + del x6 + x9 += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) + del x8 + t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 del x9 x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x10 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) + x10 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) + t2new += einsum(x10, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x10, (0, 1, 2, 3), (0, 1, 3, 2)) t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 2, 3)) t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x10 - x11 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) - x11 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 - x11 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 5, 2, 3), (4, 5, 0, 1)) - t2new += einsum(t2, (0, 1, 2, 3), x11, (0, 1, 4, 5), (4, 5, 2, 3)) * 0.25 - del x11 return {"t2new": t2new} From e9a11a766ebf2ebfe127e1eceb1b35147458774b Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 19:06:33 +0100 Subject: [PATCH 08/13] Can't actually do GDCD now --- ebcc/codegen/RDCD.py | 100 ++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/ebcc/codegen/RDCD.py b/ebcc/codegen/RDCD.py index 4051f742..59075742 100644 --- a/ebcc/codegen/RDCD.py +++ b/ebcc/codegen/RDCD.py @@ -18,64 +18,74 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) - t2new += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) * 2.0 - t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 2), (4, 0, 3, 5)) * -1.0 - t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2)) * -1.0 t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 1, 5, 0), (4, 5, 3, 2)) + t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2)) * -1.0 x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5)) - t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x0 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + t2new += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) * 2.0 x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x1 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x1 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x1 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5)) + t2new += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x2 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 5, 2), (0, 4, 3, 5)) + x2 += einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4)) x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(t2, (0, 1, 2, 3), x2, (4, 1, 5, 3), (0, 4, 2, 5)) * 2.0 - del x2 - x4 = np.zeros((nvir, nvir), dtype=np.float64) - x4 += einsum(t2, (0, 1, 2, 3), x1, (0, 1, 3, 4), (2, 4)) + x3 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 2), (0, 4, 3, 5)) x5 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x5 += einsum(x4, (0, 1), t2, (2, 3, 1, 4), (2, 3, 4, 0)) * 2.0 - del x4 - x6 = np.zeros((nocc, nocc), dtype=np.float64) - x6 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 2, 3), (0, 4)) - x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x7 += einsum(x6, (0, 1), t2, (2, 1, 3, 4), (2, 0, 4, 3)) * 2.0 - del x6 - x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x8 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + x5 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) + del x2 + x5 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 del x3 - x8 += einsum(x5, (0, 1, 2, 3), (1, 0, 2, 3)) + x5 += einsum(x4, (0, 1, 2, 3), (0, 1, 2, 3)) + del x4 + t2new += einsum(x5, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new += einsum(x5, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 del x5 - x8 += einsum(x7, (0, 1, 2, 3), (0, 1, 3, 2)) + x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x6 += einsum(t2, (0, 1, 2, 3), x1, (4, 1, 5, 3), (0, 4, 2, 5)) + x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x7 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x7 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x8 = np.zeros((nvir, nvir), dtype=np.float64) + x8 += einsum(t2, (0, 1, 2, 3), x7, (0, 1, 4, 2), (3, 4)) del x7 - t2new += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new += einsum(x8, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 - del x8 x9 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x9 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x9 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 - x9 += einsum(t2, (0, 1, 2, 3), x1, (1, 4, 5, 3), (0, 4, 2, 5)) * 2.0 - del x1 - t2new += einsum(t2, (0, 1, 2, 3), x9, (4, 1, 5, 3), (0, 4, 2, 5)) * 2.0 - del x9 - x10 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) - x10 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) - x10 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 5, 3), (4, 0, 5, 1)) - t2new += einsum(t2, (0, 1, 2, 3), x10, (0, 4, 1, 5), (4, 5, 2, 3)) + x9 += einsum(x8, (0, 1), t2, (2, 3, 1, 4), (2, 3, 4, 0)) + del x8 + x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x10 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -0.5 + x10 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x11 = np.zeros((nocc, nocc), dtype=np.float64) + x11 += einsum(t2, (0, 1, 2, 3), x10, (1, 4, 3, 2), (0, 4)) del x10 - x11 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x11 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 - x11 += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) - del x0 - t2new += einsum(t2, (0, 1, 2, 3), x11, (4, 1, 5, 2), (0, 4, 3, 5)) - del x11 x12 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x12 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - x12 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 2, 1, 5), (0, 4, 3, 5)) - t2new += einsum(t2, (0, 1, 2, 3), x12, (4, 1, 5, 2), (0, 4, 5, 3)) + x12 += einsum(x11, (0, 1), t2, (2, 1, 3, 4), (2, 0, 4, 3)) + del x11 + x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x13 += einsum(x6, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + del x6 + x13 += einsum(x9, (0, 1, 2, 3), (1, 0, 2, 3)) + del x9 + x13 += einsum(x12, (0, 1, 2, 3), (0, 1, 3, 2)) del x12 + t2new += einsum(x13, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x13, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x13 + x14 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x14 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x14 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) + del x1 + t2new += einsum(t2, (0, 1, 2, 3), x14, (4, 1, 5, 2), (4, 0, 5, 3)) + del x14 + x15 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x15 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 0.5 + x15 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.25 + x15 += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) + del x0 + t2new += einsum(t2, (0, 1, 2, 3), x15, (4, 1, 5, 3), (0, 4, 2, 5)) * 4.0 + del x15 return {"t2new": t2new} From 1dbeb9d0e0a8b64fb3a0cf4ddb861bca9dc97451 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 19:07:56 +0100 Subject: [PATCH 09/13] DCD maybe working --- ebcc/codegen/GDCD.py | 66 --------- ebcc/codegen/UDCD.py | 322 ++++++++++++++++++++++--------------------- 2 files changed, 167 insertions(+), 221 deletions(-) delete mode 100644 ebcc/codegen/GDCD.py diff --git a/ebcc/codegen/GDCD.py b/ebcc/codegen/GDCD.py deleted file mode 100644 index a07138aa..00000000 --- a/ebcc/codegen/GDCD.py +++ /dev/null @@ -1,66 +0,0 @@ -# Code generated for ebcc. - -from ebcc import numpy as np -from ebcc.util import pack_2e, einsum, Namespace - -def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): - # energy - e_cc = 0 - e_cc += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 2, 3), ()) * 0.25 - - return e_cc - -def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): - # T amplitudes - t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - t2new += einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 5, 2, 3), (0, 1, 4, 5)) * 0.5 - t2new += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 5, 0, 1), (4, 5, 2, 3)) * 0.5 - x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4)) - x1 = np.zeros((nocc, nocc), dtype=np.float64) - x1 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 2, 3), (0, 4)) - x2 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x2 += einsum(x1, (0, 1), t2, (2, 1, 3, 4), (2, 0, 3, 4)) - del x1 - x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 += einsum(x0, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - del x0 - x3 += einsum(x2, (0, 1, 2, 3), (0, 1, 3, 2)) * 0.25 - del x2 - t2new += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(x3, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 - del x3 - x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x4 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) - t2new += einsum(x4, (0, 1, 2, 3), (1, 0, 2, 3)) - t2new += einsum(x4, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 - del x4 - x5 = np.zeros((nvir, nvir), dtype=np.float64) - x5 += einsum(t2, (0, 1, 2, 3), v.oovv, (0, 1, 4, 3), (2, 4)) - x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x6 += einsum(x5, (0, 1), t2, (2, 3, 4, 1), (2, 3, 4, 0)) - del x5 - x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x7 += einsum(t2, (0, 1, 2, 3), vs, (4, 1, 5, 3), (0, 4, 2, 5)) - x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x8 += einsum(t2, (0, 1, 2, 3), x7, (4, 1, 5, 3), (0, 4, 2, 5)) - del x7 - x9 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x9 += einsum(x6, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.25 - del x6 - x9 += einsum(x8, (0, 1, 2, 3), (0, 1, 2, 3)) - del x8 - t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new += einsum(x9, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - del x9 - x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x10 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 3, 1, 5), (0, 4, 2, 5)) - t2new += einsum(x10, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new += einsum(x10, (0, 1, 2, 3), (0, 1, 3, 2)) - t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 2, 3)) - t2new += einsum(x10, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 - del x10 - - return {"t2new": t2new} - diff --git a/ebcc/codegen/UDCD.py b/ebcc/codegen/UDCD.py index c6412df7..69776a52 100644 --- a/ebcc/codegen/UDCD.py +++ b/ebcc/codegen/UDCD.py @@ -6,9 +6,9 @@ def energy(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # energy e_cc = 0 - e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 2, 1, 3), ()) e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) - e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 2), ()) * -1.0 + e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) return e_cc @@ -17,221 +17,233 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t2=None, **kwargs): # T amplitudes t2new_aaaa = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 - t2new_aaaa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - t2new_aaaa += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) * 2.0 + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.oooo, (4, 0, 5, 1), (4, 5, 2, 3)) * 2.0 t2new_abab = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 5, 4, 3)) * -1.0 t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (4, 0, 5, 3), (4, 1, 2, 5)) * -1.0 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.oooo, (4, 0, 5, 1), (4, 5, 2, 3)) t2new_abab += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) t2new_abab += einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) t2new_bbbb = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.oooo, (4, 1, 5, 0), (4, 5, 2, 3)) * -2.0 + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 2, 5, 3), (0, 1, 4, 5)) * 2.0 x0 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x0 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) - x1 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x1 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x1 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - x1 += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) - x2 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x2 += einsum(t2.aaaa, (0, 1, 2, 3), x1, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 - del x1 - x3 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x3 += einsum(x0, (0, 1, 2, 3), (0, 1, 2, 3)) - x3 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) - del x2 - t2new_aaaa += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) - t2new_aaaa += einsum(x3, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - t2new_aaaa += einsum(x3, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 - t2new_aaaa += einsum(x3, (0, 1, 2, 3), (1, 0, 3, 2)) - del x3 + x0 += einsum(f.aa.oo, (0, 1), t2.aaaa, (2, 1, 3, 4), (0, 2, 3, 4)) + x1 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x1 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 + x2 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x2 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) + x3 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x3 += einsum(x1, (0, 1), (0, 1)) + x3 += einsum(x2, (0, 1), (0, 1)) * 0.5 x4 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x4 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x4 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x4 += einsum(x3, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4)) * -2.0 + del x3 x5 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x5 += einsum(t2.aaaa, (0, 1, 2, 3), x4, (1, 4, 3, 5), (0, 4, 2, 5)) - x6 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x6 += einsum(t2.aaaa, (0, 1, 2, 3), x5, (4, 1, 5, 3), (0, 4, 2, 5)) * -4.0 + x5 += einsum(x0, (0, 1, 2, 3), (0, 1, 3, 2)) * 2.0 + del x0 + x5 += einsum(x4, (0, 1, 2, 3), (0, 1, 3, 2)) + del x4 + t2new_aaaa += einsum(x5, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_aaaa += einsum(x5, (0, 1, 2, 3), (1, 0, 2, 3)) del x5 - x7 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x7 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x7 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x6 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x6 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + x7 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x7 += einsum(t2.aaaa, (0, 1, 2, 3), x6, (4, 1, 5, 3), (4, 0, 5, 2)) x8 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x8 += einsum(t2.abab, (0, 1, 2, 3), x7, (1, 4, 3, 5), (0, 4, 2, 5)) - del x7 + x8 += einsum(t2.abab, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) x9 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x9 += einsum(t2.abab, (0, 1, 2, 3), x8, (4, 1, 5, 3), (0, 4, 2, 5)) * -1.0 + x9 += einsum(t2.abab, (0, 1, 2, 3), x8, (4, 1, 5, 3), (4, 0, 5, 2)) del x8 x10 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x10 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 + x10 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 3), (2, 4)) x11 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) x11 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (2, 4)) x12 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) x12 += einsum(x10, (0, 1), (0, 1)) x12 += einsum(x11, (0, 1), (0, 1)) * 0.5 x13 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x13 += einsum(x12, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 4, 0)) * -4.0 + x13 += einsum(x12, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 4, 0)) * -2.0 del x12 x14 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x14 += einsum(x6, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 - del x6 - x14 += einsum(x9, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x14 += einsum(x7, (0, 1, 2, 3), (0, 1, 2, 3)) * 4.0 + del x7 + x14 += einsum(x9, (0, 1, 2, 3), (0, 1, 2, 3)) del x9 - x14 += einsum(x13, (0, 1, 2, 3), (1, 0, 2, 3)) + x14 += einsum(x13, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 del x13 - t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 3, 2)) + t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_aaaa += einsum(x14, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 del x14 - x15 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x15 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 - x16 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x16 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) - x17 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x17 += einsum(x15, (0, 1), (0, 1)) - x17 += einsum(x16, (0, 1), (0, 1)) * 0.5 + x15 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x15 += einsum(f.aa.vv, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 0, 4)) + x16 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x16 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x16 += einsum(x15, (0, 1, 2, 3), (1, 0, 3, 2)) * -2.0 + del x15 + t2new_aaaa += einsum(x16, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_aaaa += einsum(x16, (0, 1, 2, 3), (0, 1, 2, 3)) + del x16 + x17 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x17 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) x18 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x18 += einsum(x17, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4)) * -4.0 - del x17 - t2new_aaaa += einsum(x18, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - t2new_aaaa += einsum(x18, (0, 1, 2, 3), (1, 0, 3, 2)) + x18 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x18 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x18 += einsum(x17, (0, 1, 2, 3), (1, 0, 3, 2)) + x19 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x19 += einsum(t2.aaaa, (0, 1, 2, 3), x18, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 del x18 - x19 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) - x19 += einsum(v.aaaa.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) - x19 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 5, 2), (4, 0, 1, 5)) * -1.0 - t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), x19, (0, 4, 5, 1), (5, 4, 2, 3)) * -2.0 + x20 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x20 += einsum(x17, (0, 1, 2, 3), (0, 1, 2, 3)) + del x17 + x20 += einsum(x19, (0, 1, 2, 3), (0, 1, 2, 3)) del x19 - x20 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x20 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) - t2new_abab += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 - x21 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x21 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x21 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - x21 += einsum(x0, (0, 1, 2, 3), (1, 0, 3, 2)) - del x0 - x21 += einsum(t2.aaaa, (0, 1, 2, 3), x4, (1, 4, 3, 5), (4, 0, 5, 2)) * -2.0 - del x4 - t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x21, (0, 4, 2, 5), (4, 1, 5, 3)) - del x21 + t2new_aaaa += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_aaaa += einsum(x20, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_aaaa += einsum(x20, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + t2new_aaaa += einsum(x20, (0, 1, 2, 3), (1, 0, 3, 2)) + del x20 + x21 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x21 += einsum(t2.aaaa, (0, 1, 2, 3), v.aabb.ovov, (1, 3, 4, 5), (0, 4, 2, 5)) + t2new_abab += einsum(x21, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 x22 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x22 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x22 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x22 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) x23 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x23 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 - x23 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 - x23 += einsum(t2.bbbb, (0, 1, 2, 3), x22, (1, 4, 3, 5), (4, 0, 5, 2)) * -1.0 - t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x23, (1, 4, 3, 5), (0, 4, 2, 5)) * -2.0 + x23 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 0.5 + x23 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x23 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (4, 1, 5, 3)) * 0.5 + x23 += einsum(x22, (0, 1, 2, 3), (1, 0, 3, 2)) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x23, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 del x23 - x24 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x24 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x24 += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 - del x20 - t2new_abab += einsum(t2.aaaa, (0, 1, 2, 3), x24, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 - x25 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) - x25 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1)) - x25 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 5, 3), (5, 1, 4, 2)) * -1.0 - t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x25, (1, 4, 2, 5), (0, 4, 5, 3)) * -1.0 + x24 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x24 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x24 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x24 += einsum(x6, (0, 1, 2, 3), (1, 0, 3, 2)) * 2.0 + del x6 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x24, (0, 4, 2, 5), (4, 1, 5, 3)) + del x24 + x25 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x25 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 0.5 + x25 += einsum(x21, (0, 1, 2, 3), (0, 1, 2, 3)) + del x21 + t2new_abab += einsum(t2.bbbb, (0, 1, 2, 3), x25, (4, 1, 5, 3), (4, 0, 5, 2)) * 4.0 del x25 - x26 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) - x26 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) - x26 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 5, 1)) - t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x26, (0, 4, 1, 5), (4, 5, 2, 3)) - del x26 - x27 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x27 += einsum(x10, (0, 1), (0, 1)) * 2.0 - del x10 - x27 += einsum(x11, (0, 1), (0, 1)) - del x11 - t2new_abab += einsum(x27, (0, 1), t2.abab, (2, 3, 1, 4), (2, 3, 0, 4)) * -1.0 - del x27 + x26 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x26 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4)) + x27 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x27 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 x28 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x28 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4)) - x29 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x29 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 - x30 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x30 += einsum(x28, (0, 1), (0, 1)) + x28 += einsum(f.bb.vv, (0, 1), (0, 1)) * -1.0 + x28 += einsum(x26, (0, 1), (1, 0)) * 0.5 + x28 += einsum(x27, (0, 1), (1, 0)) + t2new_abab += einsum(x28, (0, 1), t2.abab, (2, 3, 4, 0), (2, 3, 4, 1)) * -1.0 del x28 - x30 += einsum(x29, (0, 1), (0, 1)) * 2.0 + x29 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x29 += einsum(f.aa.vv, (0, 1), (0, 1)) * -2.0 + x29 += einsum(x10, (0, 1), (1, 0)) * 2.0 + del x10 + x29 += einsum(x11, (0, 1), (1, 0)) + del x11 + t2new_abab += einsum(x29, (0, 1), t2.abab, (2, 3, 0, 4), (2, 3, 1, 4)) * -0.5 del x29 - t2new_abab += einsum(x30, (0, 1), t2.abab, (2, 3, 4, 1), (2, 3, 4, 0)) * -1.0 - x31 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x31 += einsum(x15, (0, 1), (0, 1)) * 2.0 - del x15 - x31 += einsum(x16, (0, 1), (0, 1)) - del x16 - t2new_abab += einsum(x31, (0, 1), t2.abab, (1, 2, 3, 4), (0, 2, 3, 4)) * -1.0 - del x31 + x30 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x30 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) + x31 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x31 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 x32 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x32 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) - x33 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x33 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 - x34 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x34 += einsum(x32, (0, 1), (0, 1)) + x32 += einsum(f.bb.oo, (0, 1), (0, 1)) * 2.0 + x32 += einsum(x30, (0, 1), (1, 0)) + x32 += einsum(x31, (0, 1), (1, 0)) * 2.0 + t2new_abab += einsum(x32, (0, 1), t2.abab, (2, 0, 3, 4), (2, 1, 3, 4)) * -0.5 del x32 - x34 += einsum(x33, (0, 1), (0, 1)) * 2.0 + x33 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x33 += einsum(f.aa.oo, (0, 1), (0, 1)) + x33 += einsum(x1, (0, 1), (1, 0)) + del x1 + x33 += einsum(x2, (0, 1), (1, 0)) * 0.5 + del x2 + t2new_abab += einsum(x33, (0, 1), t2.abab, (0, 2, 3, 4), (1, 2, 3, 4)) * -1.0 del x33 - t2new_abab += einsum(x34, (0, 1), t2.abab, (2, 1, 3, 4), (2, 0, 3, 4)) * -1.0 - x35 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x35 += einsum(t2.bbbb, (0, 1, 2, 3), x22, (1, 4, 5, 3), (0, 4, 2, 5)) - del x22 + x34 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x34 += einsum(f.bb.oo, (0, 1), t2.bbbb, (2, 1, 3, 4), (0, 2, 3, 4)) + x35 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x35 += einsum(x30, (0, 1), (0, 1)) + del x30 + x35 += einsum(x31, (0, 1), (0, 1)) * 2.0 + del x31 x36 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x36 += einsum(t2.bbbb, (0, 1, 2, 3), x35, (4, 1, 5, 3), (0, 4, 2, 5)) * -4.0 + x36 += einsum(x35, (0, 1), t2.bbbb, (2, 1, 3, 4), (0, 2, 3, 4)) * -1.0 del x35 x37 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x37 += einsum(x30, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 4, 0)) * -2.0 - del x30 - x38 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x38 += einsum(x36, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + x37 += einsum(x34, (0, 1, 2, 3), (0, 1, 3, 2)) * 2.0 + del x34 + x37 += einsum(x36, (0, 1, 2, 3), (1, 0, 3, 2)) del x36 - x38 += einsum(x37, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new_bbbb += einsum(x37, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_bbbb += einsum(x37, (0, 1, 2, 3), (1, 0, 2, 3)) del x37 - t2new_bbbb += einsum(x38, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 - t2new_bbbb += einsum(x38, (0, 1, 2, 3), (0, 1, 3, 2)) - del x38 - x39 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x39 += einsum(x34, (0, 1), t2.bbbb, (2, 1, 3, 4), (2, 0, 3, 4)) * -2.0 - del x34 - t2new_bbbb += einsum(x39, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - t2new_bbbb += einsum(x39, (0, 1, 2, 3), (1, 0, 3, 2)) + x38 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x38 += einsum(t2.bbbb, (0, 1, 2, 3), x22, (4, 1, 5, 3), (4, 0, 5, 2)) + del x22 + x39 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x39 += einsum(x26, (0, 1), (0, 1)) + del x26 + x39 += einsum(x27, (0, 1), (0, 1)) * 2.0 + del x27 + x40 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x40 += einsum(x39, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 0, 4)) * -1.0 del x39 - x40 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x40 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x40 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x41 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x41 += einsum(t2.abab, (0, 1, 2, 3), x40, (0, 4, 5, 2), (4, 1, 5, 3)) + x41 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x41 += einsum(x38, (0, 1, 2, 3), (0, 1, 2, 3)) * -4.0 + del x38 + x41 += einsum(x40, (0, 1, 2, 3), (1, 0, 3, 2)) del x40 - x42 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x42 += einsum(t2.abab, (0, 1, 2, 3), x41, (0, 4, 2, 5), (4, 1, 5, 3)) * -1.0 + t2new_bbbb += einsum(x41, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_bbbb += einsum(x41, (0, 1, 2, 3), (0, 1, 3, 2)) del x41 - x43 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x43 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) - x43 += einsum(x42, (0, 1, 2, 3), (1, 0, 3, 2)) + x42 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x42 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) + x43 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x43 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x43 += einsum(x42, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 del x42 - t2new_bbbb += einsum(x43, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 - t2new_bbbb += einsum(x43, (0, 1, 2, 3), (0, 1, 2, 3)) - del x43 x44 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x44 += einsum(t2.abab, (0, 1, 2, 3), x24, (0, 4, 2, 5), (4, 1, 5, 3)) - del x24 + x44 += einsum(t2.abab, (0, 1, 2, 3), x43, (0, 4, 2, 5), (4, 1, 5, 3)) + del x43 x45 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) x45 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) x45 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 x46 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x46 += einsum(t2.bbbb, (0, 1, 2, 3), x45, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 + x46 += einsum(t2.bbbb, (0, 1, 2, 3), x45, (1, 4, 3, 5), (4, 0, 5, 2)) * 2.0 del x45 x47 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) x47 += einsum(x44, (0, 1, 2, 3), (1, 0, 3, 2)) del x44 - x47 += einsum(x46, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x47 += einsum(x46, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x46 t2new_bbbb += einsum(x47, (0, 1, 2, 3), (0, 1, 2, 3)) t2new_bbbb += einsum(x47, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 t2new_bbbb += einsum(x47, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 t2new_bbbb += einsum(x47, (0, 1, 2, 3), (1, 0, 3, 2)) del x47 - x48 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) - x48 += einsum(v.bbbb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) - x48 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 5, 2), (4, 0, 1, 5)) * -1.0 - t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), x48, (0, 4, 5, 1), (5, 4, 2, 3)) * -2.0 + x48 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x48 += einsum(f.bb.vv, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 0, 4)) + x49 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x49 += einsum(t2.abab, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 0, 2), (4, 1, 5, 3)) + x50 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x50 += einsum(t2.abab, (0, 1, 2, 3), x49, (0, 4, 2, 5), (4, 1, 5, 3)) + del x49 + x51 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x51 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x51 += einsum(x48, (0, 1, 2, 3), (1, 0, 3, 2)) * -2.0 del x48 + x51 += einsum(x50, (0, 1, 2, 3), (1, 0, 3, 2)) + del x50 + t2new_bbbb += einsum(x51, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_bbbb += einsum(x51, (0, 1, 2, 3), (0, 1, 2, 3)) + del x51 t2new.aaaa = t2new_aaaa t2new.abab = t2new_abab From 6c5fb3e333c41ca34d6566c75edba8fa8f5b1014 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 20:41:31 +0100 Subject: [PATCH 10/13] Add DCSD to ansatzes --- ebcc/ansatz.py | 1 + ebcc/codegen/RDCSD.py | 192 ++++++++++++++++ ebcc/codegen/UDCSD.py | 520 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 713 insertions(+) create mode 100644 ebcc/codegen/RDCSD.py create mode 100644 ebcc/codegen/UDCSD.py diff --git a/ebcc/ansatz.py b/ebcc/ansatz.py index bf96abc7..2dd31ffa 100644 --- a/ebcc/ansatz.py +++ b/ebcc/ansatz.py @@ -16,6 +16,7 @@ "CC3": ("CC3", "", 0, 0), "QCISD": ("QCISD", "", 0, 0), "DCD": ("DCD", "", 0, 0), + "DCSD": ("DCSD", "", 0, 0), "CCSDt'": ("CCSDt'", "", 0, 0), "CCSD-S-1-1": ("CCSD", "S", 1, 1), "CCSD-SD-1-1": ("CCSD", "SD", 1, 1), diff --git a/ebcc/codegen/RDCSD.py b/ebcc/codegen/RDCSD.py new file mode 100644 index 00000000..74955912 --- /dev/null +++ b/ebcc/codegen/RDCSD.py @@ -0,0 +1,192 @@ +# Code generated for ebcc. + +from ebcc import numpy as np +from ebcc.util import pack_2e, einsum, Namespace + +def energy(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): + # energy + e_cc = 0 + e_cc += einsum(f.ov, (0, 1), t1, (0, 1), ()) * 2.0 + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x1 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) + x1 += einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3)) + e_cc += einsum(x0, (0, 1, 2, 3), x1, (0, 1, 3, 2), ()) * 2.0 + del x0, x1 + + return e_cc + +def update_amps(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): + # T amplitudes + t1new = np.zeros((nocc, nvir), dtype=np.float64) + t1new = einsum(f.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new) + t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + t2new = einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2), alpha=-1.0, beta=1.0, out=t2new) + t2new = einsum(t2, (0, 1, 2, 3), v.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=1.0, beta=1.0, out=t2new) + t2new = einsum(t1, (0, 1), v.ooov, (2, 0, 3, 4), (3, 2, 4, 1), alpha=-1.0, beta=1.0, out=t2new) + t2new = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=t2new) + t2new = einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 2, 5, 3), (0, 1, 4, 5), alpha=1.0, beta=1.0, out=t2new) + x0 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x0 = einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x0) + x0 = einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x0) + t1new = einsum(t2, (0, 1, 2, 3), x0, (1, 3, 2, 4), (0, 4), alpha=2.0, beta=1.0, out=t1new) + del x0 + x1 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x1 = einsum(t1, (0, 1), v.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x1) + x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x2 = einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x2) + x2 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x2) + x2 = einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x2) + x2 = einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x2) + t1new = einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 3), (4, 2), alpha=-1.0, beta=1.0, out=t1new) + del x2 + x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x3 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x3) + x3 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x3) + x4 = np.zeros((nocc, nvir), dtype=np.float64) + x4 = einsum(t1, (0, 1), x3, (0, 2, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=x4) + x5 = np.zeros((nocc, nvir), dtype=np.float64) + x5 = einsum(f.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x5) + x5 = einsum(x4, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x5) + del x4 + x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x6 = einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x6) + x6 = einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x6) + t1new = einsum(x5, (0, 1), x6, (0, 2, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new) + del x6 + x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x7 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x7) + x7 = einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x7) + t1new = einsum(t1, (0, 1), x7, (0, 2, 1, 3), (2, 3), alpha=2.0, beta=1.0, out=t1new) + del x7 + x8 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x8 = einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x8) + x8 = einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-0.5, beta=1.0, out=x8) + x9 = np.zeros((nvir, nvir), dtype=np.float64) + x9 = einsum(f.vv, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x9) + x9 = einsum(t1, (0, 1), x8, (0, 1, 2, 3), (3, 2), alpha=1.0, beta=1.0, out=x9) + del x8 + t1new = einsum(t1, (0, 1), x9, (1, 2), (0, 2), alpha=2.0, beta=1.0, out=t1new) + del x9 + x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x10 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-0.5, beta=1.0, out=x10) + x10 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x10) + x11 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x11 = einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x11) + x11 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x11) + x12 = np.zeros((nocc, nocc), dtype=np.float64) + x12 = einsum(f.oo, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) + x12 = einsum(t2, (0, 1, 2, 3), x10, (1, 4, 3, 2), (4, 0), alpha=2.0, beta=1.0, out=x12) + x12 = einsum(t1, (0, 1), x11, (2, 3, 0, 1), (3, 2), alpha=2.0, beta=1.0, out=x12) + del x11 + x12 = einsum(t1, (0, 1), x5, (2, 1), (2, 0), alpha=1.0, beta=1.0, out=x12) + del x5 + t1new = einsum(t1, (0, 1), x12, (0, 2), (2, 1), alpha=-1.0, beta=1.0, out=t1new) + del x12 + x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x13 = einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x13) + t2new = einsum(x13, (0, 1, 2, 3), (1, 0, 3, 2), alpha=2.0, beta=1.0, out=t2new) + x14 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x14 = einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5), alpha=1.0, beta=1.0, out=x14) + t2new = einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new) + x15 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x15 = einsum(t1, (0, 1), v.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x15) + t2new = einsum(t1, (0, 1), x15, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=t2new) + del x15 + x16 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x16 = einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x16) + x17 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x17 = einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x17) + x18 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x18 = einsum(t1, (0, 1), v.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x18) + x19 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x19 = einsum(t1, (0, 1), v.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x19) + x20 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x20 = einsum(t1, (0, 1), x19, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x20) + del x19 + x21 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x21 = einsum(t1, (0, 1), x20, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x21) + del x20 + x22 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x22 = einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x22) + x22 = einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x22) + x23 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x23 = einsum(v.oovv, (0, 1, 2, 3), x22, (1, 4, 5, 3), (4, 0, 5, 2), alpha=1.0, beta=1.0, out=x23) + del x22 + x24 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x24 = einsum(x16, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) + del x16 + x24 = einsum(x17, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) + del x17 + x24 = einsum(x18, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) + x24 = einsum(x21, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) + del x21 + x24 = einsum(x23, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) + del x23 + t2new = einsum(x24, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new) + t2new = einsum(x24, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=t2new) + del x24 + x25 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x25 = einsum(t2, (0, 1, 2, 3), x14, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x25) + x26 = np.zeros((nvir, nvir), dtype=np.float64) + x26 = einsum(t2, (0, 1, 2, 3), x3, (0, 1, 3, 4), (2, 4), alpha=1.0, beta=1.0, out=x26) + del x3 + x27 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x27 = einsum(x26, (0, 1), t2, (2, 3, 1, 4), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x27) + del x26 + x28 = np.zeros((nocc, nocc), dtype=np.float64) + x28 = einsum(t2, (0, 1, 2, 3), x10, (1, 4, 3, 2), (0, 4), alpha=1.0, beta=1.0, out=x28) + del x10 + x29 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x29 = einsum(x28, (0, 1), t2, (2, 1, 3, 4), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x29) + del x28 + x30 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x30 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x30) + x30 = einsum(x18, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=x30) + del x18 + x31 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x31 = einsum(t1, (0, 1), x30, (2, 3, 1, 4), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x31) + del x30 + x32 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x32 = einsum(t1, (0, 1), x31, (0, 2, 3, 4), (3, 2, 4, 1), alpha=1.0, beta=1.0, out=x32) + del x31 + x33 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x33 = einsum(x25, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x33) + del x25 + x33 = einsum(x27, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x33) + del x27 + x33 = einsum(x29, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x33) + del x29 + x33 = einsum(x32, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x33) + del x32 + t2new = einsum(x33, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new) + t2new = einsum(x33, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new) + del x33 + x34 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x34 = einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x34) + x34 = einsum(t1, (0, 1), x1, (2, 3, 4, 1), (3, 0, 2, 4), alpha=1.0, beta=1.0, out=x34) + del x1 + x35 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x35 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x35) + x35 = einsum(t1, (0, 1), x34, (0, 2, 3, 4), (3, 2, 4, 1), alpha=1.0, beta=1.0, out=x35) + del x34 + t2new = einsum(t1, (0, 1), x35, (2, 3, 0, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=t2new) + del x35 + x36 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x36 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x36) + x36 = einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x36) + x36 = einsum(x13, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x36) + del x13 + t2new = einsum(t2, (0, 1, 2, 3), x36, (4, 1, 5, 3), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new) + del x36 + x37 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x37 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x37) + x37 = einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x37) + del x14 + t2new = einsum(t2, (0, 1, 2, 3), x37, (4, 1, 5, 2), (4, 0, 5, 3), alpha=1.0, beta=1.0, out=t2new) + del x37 + + return {"t1new": t1new, "t2new": t2new} + diff --git a/ebcc/codegen/UDCSD.py b/ebcc/codegen/UDCSD.py new file mode 100644 index 00000000..91fe271d --- /dev/null +++ b/ebcc/codegen/UDCSD.py @@ -0,0 +1,520 @@ +# Code generated for ebcc. + +from ebcc import numpy as np +from ebcc.util import pack_2e, einsum, Namespace + +def energy(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): + # energy + e_cc = 0 + e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 2), ()) * -1.0 + e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) + x0 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x1 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x1 += einsum(f.aa.ov, (0, 1), (0, 1)) + x1 += einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) + x1 += einsum(t1.aa, (0, 1), x0, (0, 2, 1, 3), (2, 3)) * -0.5 + del x0 + e_cc += einsum(t1.aa, (0, 1), x1, (0, 1), ()) + del x1 + x2 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x3 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x3 += einsum(f.bb.ov, (0, 1), (0, 1)) * 2.0 + x3 += einsum(t1.bb, (0, 1), x2, (0, 2, 3, 1), (2, 3)) * -1.0 + del x2 + e_cc += einsum(t1.bb, (0, 1), x3, (0, 1), ()) * 0.5 + del x3 + + return e_cc + +def update_amps(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): + t1new = Namespace() + t2new = Namespace() + + # T amplitudes + t1new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + t1new_aa = einsum(f.aa.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_aa) + t1new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + t1new_bb = einsum(f.bb.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_bb) + t2new_aaaa = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + t2new_aaaa = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 1, 4, 5), alpha=2.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.oooo, (4, 1, 5, 0), (4, 5, 2, 3), alpha=-2.0, beta=1.0, out=t2new_aaaa) + t2new_abab = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=1.0, beta=1.0, out=t2new_abab) + t2new_abab = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=t2new_abab) + t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (4, 0, 5, 3), (4, 1, 2, 5), alpha=-1.0, beta=1.0, out=t2new_abab) + t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 5, 4, 3), alpha=-1.0, beta=1.0, out=t2new_abab) + t2new_abab = einsum(t1.aa, (0, 1), v.aabb.vvov, (2, 1, 3, 4), (0, 3, 2, 4), alpha=1.0, beta=1.0, out=t2new_abab) + t2new_bbbb = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + t2new_bbbb = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=2.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 3, 5, 2), (0, 1, 4, 5), alpha=-2.0, beta=1.0, out=t2new_bbbb) + x0 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x0 = einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3), alpha=1.0, beta=1.0, out=x0) + t1new_aa = einsum(x0, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_aa) + x1 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x1 = einsum(t1.aa, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x1) + x2 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x2 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x2) + x2 = einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x2) + t1new_aa = einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2), alpha=-2.0, beta=1.0, out=t1new_aa) + del x2 + x3 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x3 = einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x3) + x3 = einsum(t1.aa, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x3) + t1new_aa = einsum(t2.abab, (0, 1, 2, 3), x3, (0, 4, 1, 3), (4, 2), alpha=-1.0, beta=1.0, out=t1new_aa) + del x3 + x4 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x4 = einsum(t2.aaaa, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x4) + x4 = einsum(t1.aa, (0, 1), t1.aa, (2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x4) + t1new_aa = einsum(v.aaaa.ovvv, (0, 1, 2, 3), x4, (0, 4, 3, 1), (4, 2), alpha=-2.0, beta=1.0, out=t1new_aa) + del x4 + x5 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x5 = einsum(t2.abab, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x5) + x5 = einsum(t1.aa, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x5) + t1new_aa = einsum(v.aabb.vvov, (0, 1, 2, 3), x5, (4, 2, 1, 3), (4, 0), alpha=1.0, beta=1.0, out=t1new_aa) + t1new_bb = einsum(v.aabb.ovvv, (0, 1, 2, 3), x5, (0, 4, 1, 3), (4, 2), alpha=1.0, beta=1.0, out=t1new_bb) + t2new_abab = einsum(v.aabb.vvvv, (0, 1, 2, 3), x5, (4, 5, 1, 3), (4, 5, 0, 2), alpha=1.0, beta=1.0, out=t2new_abab) + del x5 + x6 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x6 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x6) + x6 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x6) + x7 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x7 = einsum(t1.aa, (0, 1), x6, (0, 2, 1, 3), (2, 3), alpha=1.0, beta=1.0, out=x7) + del x6 + x8 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x8 = einsum(f.aa.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x8) + x8 = einsum(x0, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x8) + del x0 + x8 = einsum(x7, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x8) + del x7 + t1new_aa = einsum(x8, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new_aa) + t1new_bb = einsum(x8, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3), alpha=1.0, beta=1.0, out=t1new_bb) + x9 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x9 = einsum(t1.aa, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x9) + t1new_bb = einsum(x9, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_bb) + x10 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x10 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-1.0, beta=1.0, out=x10) + x10 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x10) + x11 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x11 = einsum(t1.bb, (0, 1), x10, (0, 2, 3, 1), (2, 3), alpha=1.0, beta=1.0, out=x11) + del x10 + x12 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x12 = einsum(f.bb.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) + x12 = einsum(x9, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) + del x9 + x12 = einsum(x11, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x12) + del x11 + t1new_aa = einsum(x12, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3), alpha=1.0, beta=1.0, out=t1new_aa) + t1new_bb = einsum(x12, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new_bb) + x13 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x13 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x13) + x13 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x13) + t1new_aa = einsum(t1.aa, (0, 1), x13, (0, 2, 1, 3), (2, 3), alpha=-1.0, beta=1.0, out=t1new_aa) + t2new_abab = einsum(t2.abab, (0, 1, 2, 3), x13, (0, 4, 2, 5), (4, 1, 5, 3), alpha=-1.0, beta=1.0, out=t2new_abab) + del x13 + x14 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x14 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4), alpha=-1.0, beta=1.0, out=x14) + x15 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x15 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4), alpha=1.0, beta=1.0, out=x15) + x16 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x16 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x16) + x16 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x16) + x17 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x17 = einsum(f.aa.oo, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x17) + x17 = einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 0, 1), (2, 3), alpha=0.5, beta=1.0, out=x17) + x17 = einsum(x14, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x17) + x17 = einsum(x15, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x17) + x17 = einsum(t1.aa, (0, 1), x16, (2, 3, 0, 1), (3, 2), alpha=-0.5, beta=1.0, out=x17) + del x16 + x17 = einsum(t1.aa, (0, 1), x8, (2, 1), (2, 0), alpha=0.5, beta=1.0, out=x17) + del x8 + t1new_aa = einsum(t1.aa, (0, 1), x17, (0, 2), (2, 1), alpha=-2.0, beta=1.0, out=t1new_aa) + del x17 + x18 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x18 = einsum(f.aa.vv, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x18) + x18 = einsum(t1.aa, (0, 1), v.aaaa.ovvv, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x18) + t1new_aa = einsum(t1.aa, (0, 1), x18, (1, 2), (0, 2), alpha=1.0, beta=1.0, out=t1new_aa) + del x18 + x19 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x19 = einsum(t1.bb, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x19) + x20 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x20 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x20) + x20 = einsum(x19, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x20) + t1new_bb = einsum(t2.bbbb, (0, 1, 2, 3), x20, (4, 1, 0, 3), (4, 2), alpha=-2.0, beta=1.0, out=t1new_bb) + del x20 + x21 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x21 = einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x21) + x22 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x22 = einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x22) + x22 = einsum(x21, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x22) + t1new_bb = einsum(t2.abab, (0, 1, 2, 3), x22, (0, 1, 4, 2), (4, 3), alpha=-1.0, beta=1.0, out=t1new_bb) + x23 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x23 = einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x23) + x23 = einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x23) + t1new_bb = einsum(v.bbbb.ovvv, (0, 1, 2, 3), x23, (0, 4, 3, 1), (4, 2), alpha=-2.0, beta=1.0, out=t1new_bb) + del x23 + x24 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x24 = einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) + x24 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x24) + t1new_bb = einsum(t1.bb, (0, 1), x24, (0, 2, 1, 3), (2, 3), alpha=-1.0, beta=1.0, out=t1new_bb) + x25 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x25 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4), alpha=1.0, beta=1.0, out=x25) + x26 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x26 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4), alpha=-1.0, beta=1.0, out=x26) + x27 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x27 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x27) + x27 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (2, 0, 1, 3), alpha=-1.0, beta=1.0, out=x27) + x28 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x28 = einsum(f.bb.oo, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x28) + x28 = einsum(t1.aa, (0, 1), v.aabb.ovoo, (0, 1, 2, 3), (2, 3), alpha=0.5, beta=1.0, out=x28) + x28 = einsum(x25, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x28) + x28 = einsum(x26, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x28) + x28 = einsum(t1.bb, (0, 1), x27, (0, 2, 3, 1), (3, 2), alpha=-0.5, beta=1.0, out=x28) + del x27 + x28 = einsum(t1.bb, (0, 1), x12, (2, 1), (2, 0), alpha=0.5, beta=1.0, out=x28) + del x12 + t1new_bb = einsum(t1.bb, (0, 1), x28, (0, 2), (2, 1), alpha=-2.0, beta=1.0, out=t1new_bb) + del x28 + x29 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x29 = einsum(f.bb.vv, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x29) + x29 = einsum(t1.bb, (0, 1), v.bbbb.ovvv, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x29) + t1new_bb = einsum(t1.bb, (0, 1), x29, (1, 2), (0, 2), alpha=1.0, beta=1.0, out=t1new_bb) + del x29 + x30 = np.zeros((nocc[0], nvir[0], nvir[0], nvir[0]), dtype=np.float64) + x30 = einsum(t1.aa, (0, 1), v.aaaa.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x30) + x31 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x31 = einsum(t1.aa, (0, 1), x30, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x31) + del x30 + x32 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x32 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x32) + x33 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x33 = einsum(t2.aaaa, (0, 1, 2, 3), x32, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x33) + del x32 + x34 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x34 = einsum(t2.abab, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x34) + x35 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x35 = einsum(t2.abab, (0, 1, 2, 3), x34, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x35) + del x34 + x36 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x36 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x36) + x37 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x37 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x37) + x38 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x38 = einsum(x36, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x38) + x38 = einsum(x37, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x38) + x39 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x39 = einsum(x38, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 4, 0), alpha=-2.0, beta=1.0, out=x39) + del x38 + x40 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x40 = einsum(t1.aa, (0, 1), x1, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x40) + del x1 + x41 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x41 = einsum(v.aaaa.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x41) + x41 = einsum(x40, (0, 1, 2, 3), (3, 1, 2, 0), alpha=1.0, beta=1.0, out=x41) + del x40 + x42 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x42 = einsum(t1.aa, (0, 1), x41, (0, 2, 3, 4), (2, 3, 4, 1), alpha=1.0, beta=1.0, out=x42) + del x41 + x43 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x43 = einsum(t1.aa, (0, 1), x42, (2, 0, 3, 4), (3, 2, 1, 4), alpha=1.0, beta=1.0, out=x43) + del x42 + x44 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x44 = einsum(x31, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x44) + del x31 + x44 = einsum(x33, (0, 1, 2, 3), (0, 1, 2, 3), alpha=4.0, beta=1.0, out=x44) + del x33 + x44 = einsum(x35, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x44) + del x35 + x44 = einsum(x39, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=x44) + del x39 + x44 = einsum(x43, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x44) + del x43 + t2new_aaaa = einsum(x44, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x44, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) + del x44 + x45 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x45 = einsum(f.aa.oo, (0, 1), t2.aaaa, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x45) + x46 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x46 = einsum(x14, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x46) + x46 = einsum(x15, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x46) + x47 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x47 = einsum(x46, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4), alpha=-2.0, beta=1.0, out=x47) + del x46 + x48 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x48 = einsum(x45, (0, 1, 2, 3), (0, 1, 3, 2), alpha=2.0, beta=1.0, out=x48) + del x45 + x48 = einsum(x47, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x48) + del x47 + t2new_aaaa = einsum(x48, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x48, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) + del x48 + x49 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x49 = einsum(t1.aa, (0, 1), v.aaaa.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x49) + x50 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x50 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x50) + x51 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x51 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x51) + x51 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x51) + x51 = einsum(x50, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x51) + x52 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x52 = einsum(t2.aaaa, (0, 1, 2, 3), x51, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=x52) + del x51 + x53 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x53 = einsum(t1.aa, (0, 1), v.aaaa.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x53) + x54 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x54 = einsum(t1.aa, (0, 1), x53, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x54) + del x53 + x55 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x55 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x55) + x55 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x55) + x55 = einsum(x49, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x55) + x56 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x56 = einsum(t1.aa, (0, 1), x55, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x56) + del x55 + x57 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x57 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x57) + x57 = einsum(x54, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x57) + del x54 + x57 = einsum(x56, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x57) + del x56 + x58 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x58 = einsum(t1.aa, (0, 1), x57, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x58) + del x57 + x59 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x59 = einsum(x49, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x59) + del x49 + x59 = einsum(x50, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x59) + del x50 + x59 = einsum(x52, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x59) + del x52 + x59 = einsum(x58, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x59) + del x58 + t2new_aaaa = einsum(x59, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x59, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x59, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x59, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) + del x59 + x60 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x60 = einsum(f.aa.vv, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x60) + x61 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x61 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x61) + x61 = einsum(x60, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-2.0, beta=1.0, out=x61) + del x60 + t2new_aaaa = einsum(x61, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa = einsum(x61, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) + del x61 + x62 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x62 = einsum(t1.bb, (0, 1), v.aabb.ovvv, (2, 3, 4, 1), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x62) + t2new_abab = einsum(x62, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_abab) + x63 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x63 = einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2), alpha=1.0, beta=1.0, out=x63) + t2new_abab = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=t2new_abab) + x64 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x64 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x64) + x65 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x65 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x65) + x65 = einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x65) + x65 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (4, 1, 5, 3), alpha=0.5, beta=1.0, out=x65) + x65 = einsum(x64, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x65) + t2new_abab = einsum(t2.abab, (0, 1, 2, 3), x65, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new_abab) + del x65 + x66 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x66 = einsum(t2.abab, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 0, 2), (4, 1, 5, 3), alpha=1.0, beta=1.0, out=x66) + x67 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x67 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x67) + x67 = einsum(x66, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x67) + x67 = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x67) + t2new_abab = einsum(t2.aaaa, (0, 1, 2, 3), x67, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new_abab) + del x67 + x68 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x68 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4), alpha=1.0, beta=1.0, out=x68) + x69 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x69 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x69) + x70 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x70 = einsum(f.bb.vv, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x70) + x70 = einsum(x68, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x70) + x70 = einsum(x69, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x70) + t2new_abab = einsum(x70, (0, 1), t2.abab, (2, 3, 4, 0), (2, 3, 4, 1), alpha=-1.0, beta=1.0, out=t2new_abab) + del x70 + x71 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x71 = einsum(f.aa.vv, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x71) + x71 = einsum(x36, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x71) + del x36 + x71 = einsum(x37, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x71) + del x37 + t2new_abab = einsum(x71, (0, 1), t2.abab, (2, 3, 0, 4), (2, 3, 1, 4), alpha=-1.0, beta=1.0, out=t2new_abab) + del x71 + x72 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) + x72 = einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1), alpha=1.0, beta=1.0, out=x72) + x72 = einsum(t1.bb, (0, 1), v.aabb.vvov, (2, 3, 4, 1), (0, 4, 2, 3), alpha=1.0, beta=1.0, out=x72) + x73 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x73 = einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x73) + x73 = einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x73) + x73 = einsum(t1.aa, (0, 1), x22, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x73) + del x22 + x74 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x74 = einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x74) + x74 = einsum(x21, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x74) + del x21 + x74 = einsum(t1.aa, (0, 1), x72, (2, 3, 1, 4), (0, 3, 2, 4), alpha=1.0, beta=1.0, out=x74) + del x72 + x74 = einsum(t1.aa, (0, 1), x73, (0, 2, 3, 4), (2, 4, 3, 1), alpha=-1.0, beta=1.0, out=x74) + del x73 + t2new_abab = einsum(t1.bb, (0, 1), x74, (2, 0, 3, 4), (2, 3, 4, 1), alpha=-1.0, beta=1.0, out=t2new_abab) + del x74 + x75 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x75 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x75) + x75 = einsum(x62, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x75) + del x62 + x76 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x76 = einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x76) + x76 = einsum(t1.bb, (0, 1), v.aabb.oovv, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x76) + x76 = einsum(t1.aa, (0, 1), x75, (2, 3, 1, 4), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x76) + del x75 + t2new_abab = einsum(t1.aa, (0, 1), x76, (0, 2, 3, 4), (2, 3, 1, 4), alpha=-1.0, beta=1.0, out=t2new_abab) + del x76 + x77 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x77 = einsum(f.bb.oo, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x77) + x77 = einsum(x25, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x77) + x77 = einsum(x26, (0, 1), (1, 0), alpha=2.0, beta=1.0, out=x77) + t2new_abab = einsum(x77, (0, 1), t2.abab, (2, 0, 3, 4), (2, 1, 3, 4), alpha=-0.5, beta=1.0, out=t2new_abab) + del x77 + x78 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x78 = einsum(f.aa.oo, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x78) + x78 = einsum(x14, (0, 1), (1, 0), alpha=2.0, beta=1.0, out=x78) + del x14 + x78 = einsum(x15, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x78) + del x15 + t2new_abab = einsum(x78, (0, 1), t2.abab, (0, 2, 3, 4), (1, 2, 3, 4), alpha=-0.5, beta=1.0, out=t2new_abab) + del x78 + x79 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x79 = einsum(t1.bb, (0, 1), v.bbbb.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x79) + x80 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x80 = einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x80) + x80 = einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 3, 1), alpha=-1.0, beta=1.0, out=x80) + x81 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x81 = einsum(x24, (0, 1, 2, 3), x80, (0, 4, 2, 5), (1, 4, 3, 5), alpha=1.0, beta=1.0, out=x81) + del x24, x80 + x82 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x82 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x82) + x82 = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x82) + del x63 + x83 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x83 = einsum(t2.abab, (0, 1, 2, 3), x82, (0, 4, 2, 5), (1, 4, 3, 5), alpha=1.0, beta=1.0, out=x83) + del x82 + x84 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x84 = einsum(t1.bb, (0, 1), v.bbbb.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x84) + x85 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x85 = einsum(t1.bb, (0, 1), x84, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x85) + del x84 + x86 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x86 = einsum(t1.bb, (0, 1), x79, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x86) + x87 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x87 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x87) + x87 = einsum(x85, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x87) + del x85 + x87 = einsum(x86, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x87) + del x86 + x88 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x88 = einsum(t1.bb, (0, 1), x87, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x88) + del x87 + x89 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x89 = einsum(x79, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x89) + del x79 + x89 = einsum(x81, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x89) + del x81 + x89 = einsum(x83, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x89) + del x83 + x89 = einsum(x88, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x89) + del x88 + t2new_bbbb = einsum(x89, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x89, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x89, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x89, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) + del x89 + x90 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x90 = einsum(f.bb.vv, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x90) + x91 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x91 = einsum(t2.abab, (0, 1, 2, 3), x66, (0, 4, 2, 5), (4, 1, 5, 3), alpha=1.0, beta=1.0, out=x91) + del x66 + x92 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x92 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x92) + x92 = einsum(x90, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-2.0, beta=1.0, out=x92) + del x90 + x92 = einsum(x91, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x92) + del x91 + t2new_bbbb = einsum(x92, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x92, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) + del x92 + x93 = np.zeros((nocc[1], nvir[1], nvir[1], nvir[1]), dtype=np.float64) + x93 = einsum(t1.bb, (0, 1), v.bbbb.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x93) + x94 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x94 = einsum(t1.bb, (0, 1), x93, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x94) + del x93 + x95 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x95 = einsum(t2.bbbb, (0, 1, 2, 3), x64, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x95) + del x64 + x96 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x96 = einsum(x68, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x96) + del x68 + x96 = einsum(x69, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x96) + del x69 + x97 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x97 = einsum(x96, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 4, 0), alpha=-1.0, beta=1.0, out=x97) + del x96 + x98 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x98 = einsum(t1.bb, (0, 1), x19, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x98) + del x19 + x99 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x99 = einsum(v.bbbb.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x99) + x99 = einsum(x98, (0, 1, 2, 3), (3, 1, 0, 2), alpha=1.0, beta=1.0, out=x99) + del x98 + x100 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x100 = einsum(t1.bb, (0, 1), x99, (0, 2, 3, 4), (2, 3, 4, 1), alpha=1.0, beta=1.0, out=x100) + del x99 + x101 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x101 = einsum(t1.bb, (0, 1), x100, (2, 3, 0, 4), (3, 2, 1, 4), alpha=1.0, beta=1.0, out=x101) + del x100 + x102 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x102 = einsum(x94, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x102) + del x94 + x102 = einsum(x95, (0, 1, 2, 3), (0, 1, 2, 3), alpha=4.0, beta=1.0, out=x102) + del x95 + x102 = einsum(x97, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=x102) + del x97 + x102 = einsum(x101, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x102) + del x101 + t2new_bbbb = einsum(x102, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x102, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) + del x102 + x103 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x103 = einsum(f.bb.oo, (0, 1), t2.bbbb, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x103) + x104 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x104 = einsum(x25, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x104) + del x25 + x104 = einsum(x26, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x104) + del x26 + x105 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x105 = einsum(x104, (0, 1), t2.bbbb, (2, 1, 3, 4), (2, 0, 3, 4), alpha=-1.0, beta=1.0, out=x105) + del x104 + x106 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x106 = einsum(x103, (0, 1, 2, 3), (0, 1, 3, 2), alpha=2.0, beta=1.0, out=x106) + del x103 + x106 = einsum(x105, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x106) + del x105 + t2new_bbbb = einsum(x106, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb = einsum(x106, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) + del x106 + + t1new.aa = t1new_aa + t1new.bb = t1new_bb + t2new.aaaa = t2new_aaaa + t2new.abab = t2new_abab + t2new.bbbb = t2new_bbbb + + return {"t1new": t1new, "t2new": t2new} + From a06c652a991e9bd1af8816cec0aa6a51858e83bd Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 20:48:54 +0100 Subject: [PATCH 11/13] Trying to fix DCSD --- ebcc/codegen/RDCSD.py | 390 ++++++++------ ebcc/codegen/UDCSD.py | 1118 +++++++++++++++++++++++++---------------- 2 files changed, 936 insertions(+), 572 deletions(-) diff --git a/ebcc/codegen/RDCSD.py b/ebcc/codegen/RDCSD.py index 74955912..0f967e8c 100644 --- a/ebcc/codegen/RDCSD.py +++ b/ebcc/codegen/RDCSD.py @@ -8,12 +8,12 @@ def energy(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): e_cc = 0 e_cc += einsum(f.ov, (0, 1), t1, (0, 1), ()) * 2.0 x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -0.5 + x0 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) x1 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) x1 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) x1 += einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3)) - e_cc += einsum(x0, (0, 1, 2, 3), x1, (0, 1, 3, 2), ()) * 2.0 + e_cc += einsum(x0, (0, 1, 2, 3), x1, (0, 1, 2, 3), ()) * 2.0 del x0, x1 return e_cc @@ -21,172 +21,272 @@ def energy(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): def update_amps(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): # T amplitudes t1new = np.zeros((nocc, nvir), dtype=np.float64) - t1new = einsum(f.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new) + t1new += einsum(f.vv, (0, 1), t1, (2, 1), (2, 0)) + t1new += einsum(f.ov, (0, 1), (0, 1)) t2new = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - t2new = einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2), alpha=-1.0, beta=1.0, out=t2new) - t2new = einsum(t2, (0, 1, 2, 3), v.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=1.0, beta=1.0, out=t2new) - t2new = einsum(t1, (0, 1), v.ooov, (2, 0, 3, 4), (3, 2, 4, 1), alpha=-1.0, beta=1.0, out=t2new) - t2new = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=t2new) - t2new = einsum(t2, (0, 1, 2, 3), v.vvvv, (4, 2, 5, 3), (0, 1, 4, 5), alpha=1.0, beta=1.0, out=t2new) - x0 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) - x0 = einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x0) - x0 = einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x0) - t1new = einsum(t2, (0, 1, 2, 3), x0, (1, 3, 2, 4), (0, 4), alpha=2.0, beta=1.0, out=t1new) - del x0 - x1 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x1 = einsum(t1, (0, 1), v.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x1) + t2new += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 3), (4, 0, 5, 2)) * -1.0 + t2new += einsum(t1, (0, 1), v.ooov, (2, 0, 3, 4), (3, 2, 4, 1)) * -1.0 + t2new += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + t2new += einsum(t2, (0, 1, 2, 3), v.oooo, (4, 0, 5, 1), (4, 5, 2, 3)) + x0 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x0 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) + x0 += einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3)) + t2new += einsum(v.vvvv, (0, 1, 2, 3), x0, (4, 5, 3, 1), (5, 4, 0, 2)) + x1 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x1 += einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) + x1 += einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + t1new += einsum(x0, (0, 1, 2, 3), x1, (0, 2, 3, 4), (1, 4)) * 2.0 + del x1 x2 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x2 = einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x2) - x2 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x2) - x2 = einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x2) - x2 = einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x2) - t1new = einsum(t2, (0, 1, 2, 3), x2, (4, 0, 1, 3), (4, 2), alpha=-1.0, beta=1.0, out=t1new) - del x2 - x3 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x3 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x3) - x3 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x3) - x4 = np.zeros((nocc, nvir), dtype=np.float64) - x4 = einsum(t1, (0, 1), x3, (0, 2, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=x4) + x2 += einsum(t1, (0, 1), v.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) + x3 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x3 += einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x3 += einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * 2.0 + x3 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + x3 += einsum(x2, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + t1new += einsum(t2, (0, 1, 2, 3), x3, (4, 0, 1, 2), (4, 3)) * -1.0 + del x3 + x4 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -0.5 + x4 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) x5 = np.zeros((nocc, nvir), dtype=np.float64) - x5 = einsum(f.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x5) - x5 = einsum(x4, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x5) - del x4 - x6 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x6 = einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x6) - x6 = einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x6) - t1new = einsum(x5, (0, 1), x6, (0, 2, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new) - del x6 + x5 += einsum(t1, (0, 1), x4, (0, 2, 1, 3), (2, 3)) * 2.0 + x6 = np.zeros((nocc, nvir), dtype=np.float64) + x6 += einsum(f.ov, (0, 1), (0, 1)) + x6 += einsum(x5, (0, 1), (0, 1)) + del x5 x7 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x7 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x7) - x7 = einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x7) - t1new = einsum(t1, (0, 1), x7, (0, 2, 1, 3), (2, 3), alpha=2.0, beta=1.0, out=t1new) + x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2)) * -0.5 + x7 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) + t1new += einsum(x6, (0, 1), x7, (0, 2, 1, 3), (2, 3)) * 2.0 del x7 - x8 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) - x8 = einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x8) - x8 = einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-0.5, beta=1.0, out=x8) - x9 = np.zeros((nvir, nvir), dtype=np.float64) - x9 = einsum(f.vv, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x9) - x9 = einsum(t1, (0, 1), x8, (0, 1, 2, 3), (3, 2), alpha=1.0, beta=1.0, out=x9) + x8 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x8 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x8 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + t1new += einsum(t1, (0, 1), x8, (0, 2, 1, 3), (2, 3)) * 2.0 del x8 - t1new = einsum(t1, (0, 1), x9, (1, 2), (0, 2), alpha=2.0, beta=1.0, out=t1new) + x9 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x9 += einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) + x9 += einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x10 = np.zeros((nocc, nocc), dtype=np.float64) + x10 += einsum(t1, (0, 1), x9, (2, 3, 0, 1), (2, 3)) * 2.0 del x9 - x10 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x10 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-0.5, beta=1.0, out=x10) - x10 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x10) - x11 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x11 = einsum(v.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x11) - x11 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-0.5, beta=1.0, out=x11) - x12 = np.zeros((nocc, nocc), dtype=np.float64) - x12 = einsum(f.oo, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) - x12 = einsum(t2, (0, 1, 2, 3), x10, (1, 4, 3, 2), (4, 0), alpha=2.0, beta=1.0, out=x12) - x12 = einsum(t1, (0, 1), x11, (2, 3, 0, 1), (3, 2), alpha=2.0, beta=1.0, out=x12) + x11 = np.zeros((nocc, nocc), dtype=np.float64) + x11 += einsum(f.oo, (0, 1), (0, 1)) + x11 += einsum(f.ov, (0, 1), t1, (2, 1), (0, 2)) + x11 += einsum(x0, (0, 1, 2, 3), x4, (0, 4, 2, 3), (4, 1)) * 2.0 + x11 += einsum(x10, (0, 1), (1, 0)) + t1new += einsum(t1, (0, 1), x11, (0, 2), (2, 1)) * -1.0 del x11 - x12 = einsum(t1, (0, 1), x5, (2, 1), (2, 0), alpha=1.0, beta=1.0, out=x12) - del x5 - t1new = einsum(t1, (0, 1), x12, (0, 2), (2, 1), alpha=-1.0, beta=1.0, out=t1new) - del x12 + x12 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x12 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + t2new += einsum(x12, (0, 1, 2, 3), (1, 0, 3, 2)) * 2.0 x13 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x13 = einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x13) - t2new = einsum(x13, (0, 1, 2, 3), (1, 0, 3, 2), alpha=2.0, beta=1.0, out=t2new) - x14 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x14 = einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5), alpha=1.0, beta=1.0, out=x14) - t2new = einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new) - x15 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) - x15 = einsum(t1, (0, 1), v.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x15) - t2new = einsum(t1, (0, 1), x15, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=t2new) - del x15 + x13 += einsum(t2, (0, 1, 2, 3), v.ovov, (4, 5, 1, 2), (0, 4, 3, 5)) + t2new += einsum(x13, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x14 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x14 += einsum(t1, (0, 1), x2, (2, 3, 4, 1), (2, 0, 4, 3)) + t2new += einsum(t2, (0, 1, 2, 3), x14, (4, 5, 0, 1), (5, 4, 3, 2)) + del x14 + x15 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x15 += einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4)) x16 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x16 = einsum(f.oo, (0, 1), t2, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x16) + x16 += einsum(t1, (0, 1), v.ovvv, (2, 3, 4, 1), (0, 2, 3, 4)) x17 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x17 = einsum(f.vv, (0, 1), t2, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x17) - x18 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x18 = einsum(t1, (0, 1), v.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x18) - x19 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) - x19 = einsum(t1, (0, 1), v.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x19) - x20 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x20 = einsum(t1, (0, 1), x19, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x20) - del x19 - x21 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x21 = einsum(t1, (0, 1), x20, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x21) - del x20 + x17 += einsum(t2, (0, 1, 2, 3), v.oovv, (4, 1, 5, 2), (0, 4, 3, 5)) + x18 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x18 += einsum(t1, (0, 1), v.ooov, (2, 3, 4, 1), (0, 2, 3, 4)) + x19 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x19 += einsum(t2, (0, 1, 2, 3), x18, (4, 5, 0, 1), (4, 5, 2, 3)) + del x18 + x20 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x20 += einsum(t2, (0, 1, 2, 3), x16, (4, 1, 2, 5), (4, 0, 3, 5)) + x21 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x21 += einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x21 += einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 3, 1)) x22 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x22 = einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x22) - x22 = einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x22) + x22 += einsum(t1, (0, 1), x21, (2, 1, 3, 4), (2, 0, 3, 4)) * 2.0 + del x21 x23 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x23 = einsum(v.oovv, (0, 1, 2, 3), x22, (1, 4, 5, 3), (4, 0, 5, 2), alpha=1.0, beta=1.0, out=x23) + x23 += einsum(t2, (0, 1, 2, 3), x22, (1, 4, 5, 3), (4, 0, 5, 2)) del x22 - x24 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x24 = einsum(x16, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) - del x16 - x24 = einsum(x17, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) - del x17 - x24 = einsum(x18, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) - x24 = einsum(x21, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x24) - del x21 - x24 = einsum(x23, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) - del x23 - t2new = einsum(x24, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new) - t2new = einsum(x24, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=t2new) - del x24 - x25 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x25 = einsum(t2, (0, 1, 2, 3), x14, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x25) - x26 = np.zeros((nvir, nvir), dtype=np.float64) - x26 = einsum(t2, (0, 1, 2, 3), x3, (0, 1, 3, 4), (2, 4), alpha=1.0, beta=1.0, out=x26) - del x3 + x24 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x24 += einsum(t1, (0, 1), v.oovv, (2, 3, 4, 1), (0, 2, 3, 4)) + x25 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x25 += einsum(t2, (0, 1, 2, 3), v.ooov, (4, 1, 5, 3), (0, 4, 5, 2)) + x26 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x26 += einsum(t2, (0, 1, 2, 3), x2, (4, 5, 1, 2), (4, 0, 5, 3)) x27 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x27 = einsum(x26, (0, 1), t2, (2, 3, 1, 4), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x27) - del x26 - x28 = np.zeros((nocc, nocc), dtype=np.float64) - x28 = einsum(t2, (0, 1, 2, 3), x10, (1, 4, 3, 2), (0, 4), alpha=1.0, beta=1.0, out=x28) - del x10 - x29 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x29 = einsum(x28, (0, 1), t2, (2, 1, 3, 4), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x29) - del x28 - x30 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x30 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x30) - x30 = einsum(x18, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=x30) - del x18 + x27 += einsum(t1, (0, 1), t1, (2, 3), (0, 2, 1, 3)) * 0.5 + x27 += einsum(t2, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + x27 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) * 0.5 + x28 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x28 += einsum(v.ooov, (0, 1, 2, 3), x27, (2, 4, 5, 3), (4, 0, 1, 5)) * 2.0 + del x27 + x29 = np.zeros((nocc, nvir), dtype=np.float64) + x29 += einsum(t1, (0, 1), x4, (0, 2, 1, 3), (2, 3)) + x30 = np.zeros((nocc, nvir), dtype=np.float64) + x30 += einsum(f.ov, (0, 1), (0, 1)) * 0.5 + x30 += einsum(x29, (0, 1), (0, 1)) + del x29 x31 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x31 = einsum(t1, (0, 1), x30, (2, 3, 1, 4), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x31) + x31 += einsum(x30, (0, 1), t2, (2, 3, 1, 4), (0, 2, 3, 4)) * 2.0 del x30 - x32 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x32 = einsum(t1, (0, 1), x31, (0, 2, 3, 4), (3, 2, 4, 1), alpha=1.0, beta=1.0, out=x32) + x32 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x32 += einsum(x24, (0, 1, 2, 3), (2, 0, 1, 3)) * -1.0 + del x24 + x32 += einsum(x25, (0, 1, 2, 3), (2, 0, 1, 3)) + del x25 + x32 += einsum(x26, (0, 1, 2, 3), (2, 0, 1, 3)) + del x26 + x32 += einsum(x28, (0, 1, 2, 3), (2, 0, 1, 3)) + del x28 + x32 += einsum(x31, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 del x31 x33 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x33 = einsum(x25, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x33) - del x25 - x33 = einsum(x27, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x33) - del x27 - x33 = einsum(x29, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x33) - del x29 - x33 = einsum(x32, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x33) + x33 += einsum(t1, (0, 1), x32, (0, 2, 3, 4), (2, 3, 4, 1)) del x32 - t2new = einsum(x33, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new) - t2new = einsum(x33, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new) - del x33 - x34 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) - x34 = einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x34) - x34 = einsum(t1, (0, 1), x1, (2, 3, 4, 1), (3, 0, 2, 4), alpha=1.0, beta=1.0, out=x34) - del x1 - x35 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) - x35 = einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x35) - x35 = einsum(t1, (0, 1), x34, (0, 2, 3, 4), (3, 2, 4, 1), alpha=1.0, beta=1.0, out=x35) + x34 = np.zeros((nocc, nocc), dtype=np.float64) + x34 += einsum(t1, (0, 1), x6, (2, 1), (2, 0)) * 0.5 + del x6 + x35 = np.zeros((nocc, nocc), dtype=np.float64) + x35 += einsum(f.oo, (0, 1), (0, 1)) * 0.5 + x35 += einsum(x34, (0, 1), (1, 0)) del x34 - t2new = einsum(t1, (0, 1), x35, (2, 3, 0, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=t2new) - del x35 x36 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x36 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x36) - x36 = einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x36) - x36 = einsum(x13, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x36) - del x13 - t2new = einsum(t2, (0, 1, 2, 3), x36, (4, 1, 5, 3), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new) - del x36 + x36 += einsum(x35, (0, 1), t2, (2, 1, 3, 4), (0, 2, 4, 3)) * 2.0 + del x35 x37 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) - x37 = einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x37) - x37 = einsum(x14, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x37) - del x14 - t2new = einsum(t2, (0, 1, 2, 3), x37, (4, 1, 5, 2), (4, 0, 5, 3), alpha=1.0, beta=1.0, out=t2new) + x37 += einsum(x15, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x15 + x37 += einsum(x16, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x37 += einsum(x17, (0, 1, 2, 3), (0, 1, 2, 3)) + del x17 + x37 += einsum(x19, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x19 + x37 += einsum(x20, (0, 1, 2, 3), (0, 1, 2, 3)) + del x20 + x37 += einsum(x23, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x23 + x37 += einsum(x33, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x33 + x37 += einsum(x36, (0, 1, 2, 3), (0, 1, 3, 2)) + del x36 + t2new += einsum(x37, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new += einsum(x37, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 del x37 + x38 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x38 += einsum(t1, (0, 1), v.ovvv, (2, 1, 3, 4), (0, 2, 3, 4)) + x39 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x39 += einsum(t2, (0, 1, 2, 3), x38, (4, 1, 5, 2), (4, 0, 3, 5)) + del x38 + x40 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x40 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x40 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x41 = np.zeros((nvir, nvir), dtype=np.float64) + x41 += einsum(t2, (0, 1, 2, 3), x40, (0, 1, 4, 2), (4, 3)) + del x40 + x42 = np.zeros((nocc, nvir, nvir, nvir), dtype=np.float64) + x42 += einsum(v.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + x42 += einsum(v.ovvv, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x43 = np.zeros((nvir, nvir), dtype=np.float64) + x43 += einsum(t1, (0, 1), x42, (0, 1, 2, 3), (2, 3)) + del x42 + x44 = np.zeros((nvir, nvir), dtype=np.float64) + x44 += einsum(x41, (0, 1), (0, 1)) + del x41 + x44 += einsum(x43, (0, 1), (1, 0)) * -1.0 + del x43 + x45 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x45 += einsum(x44, (0, 1), t2, (2, 3, 0, 4), (2, 3, 1, 4)) + del x44 + x46 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x46 += einsum(t2, (0, 1, 2, 3), (0, 1, 2, 3)) + x46 += einsum(t1, (0, 1), t1, (2, 3), (0, 2, 3, 1)) * -0.5 + x47 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x47 += einsum(v.ovov, (0, 1, 2, 3), x46, (2, 4, 3, 5), (4, 0, 5, 1)) + del x46 + x48 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x48 += einsum(t2, (0, 1, 2, 3), x47, (4, 1, 5, 2), (4, 0, 5, 3)) * 2.0 + del x47 + x49 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x49 += einsum(t2, (0, 1, 2, 3), v.ooov, (4, 1, 5, 2), (0, 4, 5, 3)) + x50 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x50 += einsum(t2, (0, 1, 2, 3), v.ovvv, (4, 2, 5, 3), (0, 1, 4, 5)) + x51 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x51 += einsum(x2, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x51 += einsum(x2, (0, 1, 2, 3), (0, 2, 1, 3)) + del x2 + x52 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x52 += einsum(t2, (0, 1, 2, 3), x51, (4, 5, 1, 3), (4, 5, 0, 2)) * 2.0 + del x51 + x53 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x53 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x53 += einsum(x16, (0, 1, 2, 3), (1, 0, 2, 3)) + del x16 + x54 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x54 += einsum(t1, (0, 1), x53, (2, 3, 1, 4), (2, 3, 0, 4)) + del x53 + x55 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x55 += einsum(x49, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x49 + x55 += einsum(x50, (0, 1, 2, 3), (0, 1, 2, 3)) + del x50 + x55 += einsum(x52, (0, 1, 2, 3), (0, 2, 1, 3)) + del x52 + x55 += einsum(x54, (0, 1, 2, 3), (2, 1, 0, 3)) + del x54 + x56 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x56 += einsum(t1, (0, 1), x55, (2, 3, 0, 4), (2, 3, 4, 1)) + del x55 + x57 = np.zeros((nocc, nocc), dtype=np.float64) + x57 += einsum(t2, (0, 1, 2, 3), x4, (1, 4, 3, 2), (4, 0)) + del x4 + x58 = np.zeros((nocc, nocc), dtype=np.float64) + x58 += einsum(x57, (0, 1), (0, 1)) + del x57 + x58 += einsum(x10, (0, 1), (1, 0)) + del x10 + x59 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x59 += einsum(x58, (0, 1), t2, (2, 0, 3, 4), (1, 2, 4, 3)) + del x58 + x60 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x60 += einsum(x39, (0, 1, 2, 3), (0, 1, 2, 3)) + del x39 + x60 += einsum(x45, (0, 1, 2, 3), (1, 0, 3, 2)) + del x45 + x60 += einsum(x48, (0, 1, 2, 3), (0, 1, 2, 3)) + del x48 + x60 += einsum(x56, (0, 1, 2, 3), (0, 1, 3, 2)) + del x56 + x60 += einsum(x59, (0, 1, 2, 3), (1, 0, 3, 2)) + del x59 + t2new += einsum(x60, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new += einsum(x60, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x60 + x61 = np.zeros((nocc, nocc, nocc, nocc), dtype=np.float64) + x61 += einsum(v.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x61 += einsum(v.ovov, (0, 1, 2, 3), x0, (4, 5, 3, 1), (0, 5, 4, 2)) + del x0 + x62 = np.zeros((nocc, nocc, nocc, nvir), dtype=np.float64) + x62 += einsum(v.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x62 += einsum(t1, (0, 1), x61, (0, 2, 3, 4), (3, 2, 4, 1)) + del x61 + t2new += einsum(t1, (0, 1), x62, (2, 3, 0, 4), (2, 3, 1, 4)) + del x62 + x63 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x63 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x63 += einsum(v.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x63 += einsum(x12, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + del x12 + t2new += einsum(t2, (0, 1, 2, 3), x63, (4, 1, 5, 3), (0, 4, 2, 5)) * 2.0 + del x63 + x64 = np.zeros((nocc, nocc, nvir, nvir), dtype=np.float64) + x64 += einsum(v.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x64 += einsum(x13, (0, 1, 2, 3), (0, 1, 2, 3)) + del x13 + t2new += einsum(t2, (0, 1, 2, 3), x64, (4, 1, 5, 2), (4, 0, 5, 3)) + del x64 return {"t1new": t1new, "t2new": t2new} diff --git a/ebcc/codegen/UDCSD.py b/ebcc/codegen/UDCSD.py index 91fe271d..bcfc066b 100644 --- a/ebcc/codegen/UDCSD.py +++ b/ebcc/codegen/UDCSD.py @@ -6,25 +6,25 @@ def energy(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs): # energy e_cc = 0 + e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 2, 1, 3), ()) + e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 3, 1, 2), ()) * -1.0 e_cc += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 3), ()) - e_cc += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 2), ()) * -1.0 - e_cc += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 2, 1, 3), ()) x0 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) - x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x0 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) x1 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x1 += einsum(f.aa.ov, (0, 1), (0, 1)) - x1 += einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) - x1 += einsum(t1.aa, (0, 1), x0, (0, 2, 1, 3), (2, 3)) * -0.5 + x1 += einsum(f.aa.ov, (0, 1), (0, 1)) * 2.0 + x1 += einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) * 2.0 + x1 += einsum(t1.aa, (0, 1), x0, (0, 2, 3, 1), (2, 3)) * -1.0 del x0 - e_cc += einsum(t1.aa, (0, 1), x1, (0, 1), ()) + e_cc += einsum(t1.aa, (0, 1), x1, (0, 1), ()) * 0.5 del x1 x2 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 - x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x2 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 x3 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) x3 += einsum(f.bb.ov, (0, 1), (0, 1)) * 2.0 - x3 += einsum(t1.bb, (0, 1), x2, (0, 2, 3, 1), (2, 3)) * -1.0 + x3 += einsum(t1.bb, (0, 1), x2, (0, 2, 1, 3), (2, 3)) * -1.0 del x2 e_cc += einsum(t1.bb, (0, 1), x3, (0, 1), ()) * 0.5 del x3 @@ -37,478 +37,742 @@ def update_amps(f=None, v=None, nocc=None, nvir=None, t1=None, t2=None, **kwargs # T amplitudes t1new_aa = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - t1new_aa = einsum(f.aa.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_aa) + t1new_aa += einsum(f.aa.ov, (0, 1), (0, 1)) t1new_bb = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - t1new_bb = einsum(f.bb.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_bb) + t1new_bb += einsum(f.bb.ov, (0, 1), (0, 1)) t2new_aaaa = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - t2new_aaaa = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 2, 5, 3), (0, 1, 4, 5), alpha=2.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.oooo, (4, 1, 5, 0), (4, 5, 2, 3), alpha=-2.0, beta=1.0, out=t2new_aaaa) + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 t2new_abab = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=1.0, beta=1.0, out=t2new_abab) - t2new_abab = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=t2new_abab) - t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.oovv, (4, 0, 5, 3), (4, 1, 2, 5), alpha=-1.0, beta=1.0, out=t2new_abab) - t2new_abab = einsum(t2.abab, (0, 1, 2, 3), v.aabb.vvoo, (4, 2, 5, 1), (0, 5, 4, 3), alpha=-1.0, beta=1.0, out=t2new_abab) - t2new_abab = einsum(t1.aa, (0, 1), v.aabb.vvov, (2, 1, 3, 4), (0, 3, 2, 4), alpha=1.0, beta=1.0, out=t2new_abab) + t2new_abab += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) t2new_bbbb = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - t2new_bbbb = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.oooo, (4, 0, 5, 1), (4, 5, 2, 3), alpha=2.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 3, 5, 2), (0, 1, 4, 5), alpha=-2.0, beta=1.0, out=t2new_bbbb) + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.vvvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -2.0 x0 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x0 = einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3), alpha=1.0, beta=1.0, out=x0) - t1new_aa = einsum(x0, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_aa) + x0 += einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 0, 1), (2, 3)) + t1new_aa += einsum(x0, (0, 1), (0, 1)) x1 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x1 = einsum(t1.aa, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x1) + x1 += einsum(t1.aa, (0, 1), v.aaaa.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) x2 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x2 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x2) - x2 = einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x2) - t1new_aa = einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 1, 0, 3), (4, 2), alpha=-2.0, beta=1.0, out=t1new_aa) + x2 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x2 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) + t1new_aa += einsum(t2.aaaa, (0, 1, 2, 3), x2, (4, 0, 1, 3), (4, 2)) * 2.0 del x2 x3 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) - x3 = einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x3) - x3 = einsum(t1.aa, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x3) - t1new_aa = einsum(t2.abab, (0, 1, 2, 3), x3, (0, 4, 1, 3), (4, 2), alpha=-1.0, beta=1.0, out=t1new_aa) - del x3 - x4 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x4 = einsum(t2.aaaa, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x4) - x4 = einsum(t1.aa, (0, 1), t1.aa, (2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x4) - t1new_aa = einsum(v.aaaa.ovvv, (0, 1, 2, 3), x4, (0, 4, 3, 1), (4, 2), alpha=-2.0, beta=1.0, out=t1new_aa) + x3 += einsum(t1.aa, (0, 1), v.aabb.ovov, (2, 1, 3, 4), (0, 2, 3, 4)) + x4 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x4 += einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) + x4 += einsum(x3, (0, 1, 2, 3), (1, 0, 2, 3)) + t1new_aa += einsum(t2.abab, (0, 1, 2, 3), x4, (0, 4, 1, 3), (4, 2)) * -1.0 del x4 - x5 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x5 = einsum(t2.abab, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x5) - x5 = einsum(t1.aa, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x5) - t1new_aa = einsum(v.aabb.vvov, (0, 1, 2, 3), x5, (4, 2, 1, 3), (4, 0), alpha=1.0, beta=1.0, out=t1new_aa) - t1new_bb = einsum(v.aabb.ovvv, (0, 1, 2, 3), x5, (0, 4, 1, 3), (4, 2), alpha=1.0, beta=1.0, out=t1new_bb) - t2new_abab = einsum(v.aabb.vvvv, (0, 1, 2, 3), x5, (4, 5, 1, 3), (4, 5, 0, 2), alpha=1.0, beta=1.0, out=t2new_abab) + x5 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x5 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 1, 2, 3)) + x5 += einsum(t1.aa, (0, 1), t1.aa, (2, 3), (0, 2, 1, 3)) * 0.5 + t1new_aa += einsum(v.aaaa.ovvv, (0, 1, 2, 3), x5, (0, 4, 1, 3), (4, 2)) * 2.0 del x5 - x6 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x6 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x6) - x6 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x6) - x7 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x7 = einsum(t1.aa, (0, 1), x6, (0, 2, 1, 3), (2, 3), alpha=1.0, beta=1.0, out=x7) + x6 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x6 += einsum(t2.abab, (0, 1, 2, 3), (0, 1, 2, 3)) + x6 += einsum(t1.aa, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3)) + t1new_aa += einsum(v.aabb.vvov, (0, 1, 2, 3), x6, (4, 2, 1, 3), (4, 0)) + t1new_bb += einsum(v.aabb.ovvv, (0, 1, 2, 3), x6, (0, 4, 1, 3), (4, 2)) del x6 + x7 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x7 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x7 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) x8 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) - x8 = einsum(f.aa.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x8) - x8 = einsum(x0, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x8) - del x0 - x8 = einsum(x7, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x8) + x8 += einsum(t1.aa, (0, 1), x7, (0, 2, 3, 1), (2, 3)) del x7 - t1new_aa = einsum(x8, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new_aa) - t1new_bb = einsum(x8, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3), alpha=1.0, beta=1.0, out=t1new_bb) - x9 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x9 = einsum(t1.aa, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x9) - t1new_bb = einsum(x9, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=t1new_bb) - x10 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x10 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=-1.0, beta=1.0, out=x10) - x10 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x10) - x11 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x11 = einsum(t1.bb, (0, 1), x10, (0, 2, 3, 1), (2, 3), alpha=1.0, beta=1.0, out=x11) - del x10 + x9 = np.zeros((nocc[0], nvir[0]), dtype=np.float64) + x9 += einsum(f.aa.ov, (0, 1), (0, 1)) + x9 += einsum(x0, (0, 1), (0, 1)) + del x0 + x9 += einsum(x8, (0, 1), (0, 1)) * -1.0 + del x8 + t1new_aa += einsum(x9, (0, 1), t2.aaaa, (2, 0, 3, 1), (2, 3)) * 2.0 + t1new_bb += einsum(x9, (0, 1), t2.abab, (0, 2, 1, 3), (2, 3)) + x10 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x10 += einsum(t1.aa, (0, 1), v.aabb.ovov, (0, 1, 2, 3), (2, 3)) + t1new_bb += einsum(x10, (0, 1), (0, 1)) + x11 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x11 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x11 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 x12 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) - x12 = einsum(f.bb.ov, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) - x12 = einsum(x9, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x12) - del x9 - x12 = einsum(x11, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x12) + x12 += einsum(t1.bb, (0, 1), x11, (0, 2, 1, 3), (2, 3)) del x11 - t1new_aa = einsum(x12, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3), alpha=1.0, beta=1.0, out=t1new_aa) - t1new_bb = einsum(x12, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3), alpha=2.0, beta=1.0, out=t1new_bb) - x13 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x13 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x13) - x13 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x13) - t1new_aa = einsum(t1.aa, (0, 1), x13, (0, 2, 1, 3), (2, 3), alpha=-1.0, beta=1.0, out=t1new_aa) - t2new_abab = einsum(t2.abab, (0, 1, 2, 3), x13, (0, 4, 2, 5), (4, 1, 5, 3), alpha=-1.0, beta=1.0, out=t2new_abab) - del x13 - x14 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x14 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4), alpha=-1.0, beta=1.0, out=x14) + x13 = np.zeros((nocc[1], nvir[1]), dtype=np.float64) + x13 += einsum(f.bb.ov, (0, 1), (0, 1)) + x13 += einsum(x10, (0, 1), (0, 1)) + del x10 + x13 += einsum(x12, (0, 1), (0, 1)) * -1.0 + del x12 + t1new_aa += einsum(x13, (0, 1), t2.abab, (2, 0, 3, 1), (2, 3)) + t1new_bb += einsum(x13, (0, 1), t2.bbbb, (2, 0, 3, 1), (2, 3)) * 2.0 + x14 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x14 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x14 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + t1new_aa += einsum(t1.aa, (0, 1), x14, (0, 2, 1, 3), (2, 3)) * -1.0 + del x14 x15 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x15 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4), alpha=1.0, beta=1.0, out=x15) - x16 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x16 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x16) - x16 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x16) + x15 += einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 0, 1), (2, 3)) + x16 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x16 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 x17 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x17 = einsum(f.aa.oo, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x17) - x17 = einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 0, 1), (2, 3), alpha=0.5, beta=1.0, out=x17) - x17 = einsum(x14, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x17) - x17 = einsum(x15, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x17) - x17 = einsum(t1.aa, (0, 1), x16, (2, 3, 0, 1), (3, 2), alpha=-0.5, beta=1.0, out=x17) - del x16 - x17 = einsum(t1.aa, (0, 1), x8, (2, 1), (2, 0), alpha=0.5, beta=1.0, out=x17) - del x8 - t1new_aa = einsum(t1.aa, (0, 1), x17, (0, 2), (2, 1), alpha=-2.0, beta=1.0, out=t1new_aa) - del x17 - x18 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x18 = einsum(f.aa.vv, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x18) - x18 = einsum(t1.aa, (0, 1), v.aaaa.ovvv, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x18) - t1new_aa = einsum(t1.aa, (0, 1), x18, (1, 2), (0, 2), alpha=1.0, beta=1.0, out=t1new_aa) - del x18 - x19 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x19 = einsum(t1.bb, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3), alpha=1.0, beta=1.0, out=x19) - x20 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x20 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x20) - x20 = einsum(x19, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x20) - t1new_bb = einsum(t2.bbbb, (0, 1, 2, 3), x20, (4, 1, 0, 3), (4, 2), alpha=-2.0, beta=1.0, out=t1new_bb) - del x20 - x21 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) - x21 = einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x21) - x22 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) - x22 = einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x22) - x22 = einsum(x21, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x22) - t1new_bb = einsum(t2.abab, (0, 1, 2, 3), x22, (0, 1, 4, 2), (4, 3), alpha=-1.0, beta=1.0, out=t1new_bb) - x23 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x23 = einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x23) - x23 = einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x23) - t1new_bb = einsum(v.bbbb.ovvv, (0, 1, 2, 3), x23, (0, 4, 3, 1), (4, 2), alpha=-2.0, beta=1.0, out=t1new_bb) - del x23 - x24 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x24 = einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x24) - x24 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=-1.0, beta=1.0, out=x24) - t1new_bb = einsum(t1.bb, (0, 1), x24, (0, 2, 1, 3), (2, 3), alpha=-1.0, beta=1.0, out=t1new_bb) - x25 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x25 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4), alpha=1.0, beta=1.0, out=x25) - x26 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x26 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4), alpha=-1.0, beta=1.0, out=x26) - x27 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x27 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x27) - x27 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (2, 0, 1, 3), alpha=-1.0, beta=1.0, out=x27) - x28 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x28 = einsum(f.bb.oo, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x28) - x28 = einsum(t1.aa, (0, 1), v.aabb.ovoo, (0, 1, 2, 3), (2, 3), alpha=0.5, beta=1.0, out=x28) - x28 = einsum(x25, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x28) - x28 = einsum(x26, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x28) - x28 = einsum(t1.bb, (0, 1), x27, (0, 2, 3, 1), (3, 2), alpha=-0.5, beta=1.0, out=x28) + x17 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 1, 3), (0, 4)) + x18 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x18 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x18 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x19 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x19 += einsum(t1.aa, (0, 1), x18, (2, 3, 0, 1), (2, 3)) + x20 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x20 += einsum(t1.aa, (0, 1), x9, (2, 1), (0, 2)) + x21 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x21 += einsum(f.aa.oo, (0, 1), (0, 1)) + x21 += einsum(x15, (0, 1), (1, 0)) + x21 += einsum(x16, (0, 1), (1, 0)) * 2.0 + x21 += einsum(x17, (0, 1), (1, 0)) + x21 += einsum(x19, (0, 1), (1, 0)) * -1.0 + x21 += einsum(x20, (0, 1), (1, 0)) + t1new_aa += einsum(t1.aa, (0, 1), x21, (0, 2), (2, 1)) * -1.0 + del x21 + x22 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x22 += einsum(f.aa.vv, (0, 1), (0, 1)) + x22 += einsum(t1.aa, (0, 1), v.aaaa.ovvv, (0, 2, 3, 1), (2, 3)) * -1.0 + t1new_aa += einsum(t1.aa, (0, 1), x22, (1, 2), (0, 2)) + del x22 + x23 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x23 += einsum(t1.bb, (0, 1), v.aabb.ovov, (2, 3, 4, 1), (2, 0, 4, 3)) + x24 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x24 += einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1)) + x24 += einsum(x23, (0, 1, 2, 3), (0, 2, 1, 3)) + t1new_bb += einsum(t2.abab, (0, 1, 2, 3), x24, (0, 1, 4, 2), (4, 3)) * -1.0 + x25 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x25 += einsum(t1.bb, (0, 1), v.bbbb.ovov, (2, 3, 4, 1), (0, 2, 4, 3)) + x26 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x26 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x26 += einsum(x25, (0, 1, 2, 3), (0, 1, 2, 3)) + t1new_bb += einsum(t2.bbbb, (0, 1, 2, 3), x26, (4, 0, 1, 3), (4, 2)) * 2.0 + del x26 + x27 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x27 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3)) + x27 += einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 1, 3)) * 0.5 + t1new_bb += einsum(v.bbbb.ovvv, (0, 1, 2, 3), x27, (0, 4, 1, 3), (4, 2)) * 2.0 del x27 - x28 = einsum(t1.bb, (0, 1), x12, (2, 1), (2, 0), alpha=0.5, beta=1.0, out=x28) - del x12 - t1new_bb = einsum(t1.bb, (0, 1), x28, (0, 2), (2, 1), alpha=-2.0, beta=1.0, out=t1new_bb) - del x28 - x29 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x29 = einsum(f.bb.vv, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x29) - x29 = einsum(t1.bb, (0, 1), v.bbbb.ovvv, (0, 1, 2, 3), (2, 3), alpha=1.0, beta=1.0, out=x29) - t1new_bb = einsum(t1.bb, (0, 1), x29, (1, 2), (0, 2), alpha=1.0, beta=1.0, out=t1new_bb) - del x29 - x30 = np.zeros((nocc[0], nvir[0], nvir[0], nvir[0]), dtype=np.float64) - x30 = einsum(t1.aa, (0, 1), v.aaaa.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x30) - x31 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x31 = einsum(t1.aa, (0, 1), x30, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x31) - del x30 - x32 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x32 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x32) - x33 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x33 = einsum(t2.aaaa, (0, 1, 2, 3), x32, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x33) + x28 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x28 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x28 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + t1new_bb += einsum(t1.bb, (0, 1), x28, (0, 2, 1, 3), (2, 3)) * -1.0 + x29 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x29 += einsum(t1.aa, (0, 1), v.aabb.ovoo, (0, 1, 2, 3), (2, 3)) + x30 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x30 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 3), (1, 4)) + x31 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x31 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 3, 1, 2), (0, 4)) * -1.0 + x32 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x32 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x32 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x33 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x33 += einsum(t1.bb, (0, 1), x32, (2, 3, 0, 1), (2, 3)) del x32 - x34 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x34 = einsum(t2.abab, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x34) - x35 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x35 = einsum(t2.abab, (0, 1, 2, 3), x34, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x35) - del x34 - x36 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x36 = einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x36) - x37 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x37 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x37) - x38 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x38 = einsum(x36, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x38) - x38 = einsum(x37, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x38) + x34 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x34 += einsum(t1.bb, (0, 1), x13, (2, 1), (0, 2)) + x35 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x35 += einsum(f.bb.oo, (0, 1), (0, 1)) + x35 += einsum(x29, (0, 1), (1, 0)) + x35 += einsum(x30, (0, 1), (1, 0)) + x35 += einsum(x31, (0, 1), (1, 0)) * 2.0 + x35 += einsum(x33, (0, 1), (1, 0)) * -1.0 + x35 += einsum(x34, (0, 1), (1, 0)) + t1new_bb += einsum(t1.bb, (0, 1), x35, (0, 2), (2, 1)) * -1.0 + del x35 + x36 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x36 += einsum(f.bb.vv, (0, 1), (0, 1)) + x36 += einsum(t1.bb, (0, 1), v.bbbb.ovvv, (0, 2, 3, 1), (2, 3)) * -1.0 + t1new_bb += einsum(t1.bb, (0, 1), x36, (1, 2), (0, 2)) + del x36 + x37 = np.zeros((nocc[0], nvir[0], nvir[0], nvir[0]), dtype=np.float64) + x37 += einsum(t1.aa, (0, 1), v.aaaa.vvvv, (2, 3, 4, 1), (0, 2, 3, 4)) + x38 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x38 += einsum(t1.aa, (0, 1), x37, (2, 3, 1, 4), (0, 2, 3, 4)) + del x37 x39 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x39 = einsum(x38, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 4, 0), alpha=-2.0, beta=1.0, out=x39) - del x38 - x40 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) - x40 = einsum(t1.aa, (0, 1), x1, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x40) - del x1 - x41 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) - x41 = einsum(v.aaaa.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x41) - x41 = einsum(x40, (0, 1, 2, 3), (3, 1, 2, 0), alpha=1.0, beta=1.0, out=x41) - del x40 - x42 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x42 = einsum(t1.aa, (0, 1), x41, (0, 2, 3, 4), (2, 3, 4, 1), alpha=1.0, beta=1.0, out=x42) + x39 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + x40 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x40 += einsum(t2.aaaa, (0, 1, 2, 3), x39, (4, 1, 5, 3), (4, 0, 5, 2)) + x41 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x41 += einsum(t2.abab, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + x42 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x42 += einsum(t2.abab, (0, 1, 2, 3), x41, (4, 1, 5, 3), (4, 0, 5, 2)) del x41 - x43 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x43 = einsum(t1.aa, (0, 1), x42, (2, 0, 3, 4), (3, 2, 1, 4), alpha=1.0, beta=1.0, out=x43) - del x42 - x44 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x44 = einsum(x31, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x44) - del x31 - x44 = einsum(x33, (0, 1, 2, 3), (0, 1, 2, 3), alpha=4.0, beta=1.0, out=x44) - del x33 - x44 = einsum(x35, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x44) - del x35 - x44 = einsum(x39, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=x44) - del x39 - x44 = einsum(x43, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x44) - del x43 - t2new_aaaa = einsum(x44, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x44, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) - del x44 - x45 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x45 = einsum(f.aa.oo, (0, 1), t2.aaaa, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x45) - x46 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x46 = einsum(x14, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x46) - x46 = einsum(x15, (0, 1), (0, 1), alpha=0.5, beta=1.0, out=x46) - x47 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x47 = einsum(x46, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4), alpha=-2.0, beta=1.0, out=x47) - del x46 - x48 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x48 = einsum(x45, (0, 1, 2, 3), (0, 1, 3, 2), alpha=2.0, beta=1.0, out=x48) - del x45 - x48 = einsum(x47, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x48) + x43 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x43 += einsum(t1.bb, (0, 1), v.aabb.vvov, (2, 3, 0, 1), (2, 3)) + x44 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x44 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 + x45 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x45 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 4, 1, 3), (2, 4)) + x46 = np.zeros((nocc[0], nvir[0], nvir[0], nvir[0]), dtype=np.float64) + x46 += einsum(v.aaaa.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) + x46 += einsum(v.aaaa.ovvv, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x47 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x47 += einsum(t1.aa, (0, 1), x46, (0, 1, 2, 3), (2, 3)) + x48 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x48 += einsum(x43, (0, 1), (1, 0)) * -1.0 + x48 += einsum(x44, (0, 1), (1, 0)) + x48 += einsum(x45, (0, 1), (1, 0)) * 0.5 + x48 += einsum(x47, (0, 1), (1, 0)) * -1.0 del x47 - t2new_aaaa = einsum(x48, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x48, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) - del x48 x49 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x49 = einsum(t1.aa, (0, 1), v.aaaa.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x49) - x50 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x50 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x50) - x51 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x51 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x51) - x51 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x51) - x51 = einsum(x50, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x51) - x52 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x52 = einsum(t2.aaaa, (0, 1, 2, 3), x51, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=x52) - del x51 + x49 += einsum(x48, (0, 1), t2.aaaa, (2, 3, 4, 0), (2, 3, 4, 1)) * -2.0 + del x48 + x50 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x50 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -1.0 + x51 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x51 += einsum(x9, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 0, 4)) * -2.0 + x52 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x52 += einsum(t1.aa, (0, 1), x1, (2, 3, 4, 1), (2, 0, 4, 3)) x53 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) - x53 = einsum(t1.aa, (0, 1), v.aaaa.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x53) + x53 += einsum(v.aaaa.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x53 += einsum(x52, (0, 1, 2, 3), (3, 1, 2, 0)) + del x52 + t2new_aaaa += einsum(t2.aaaa, (0, 1, 2, 3), x53, (0, 4, 1, 5), (4, 5, 2, 3)) * 2.0 x54 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x54 = einsum(t1.aa, (0, 1), x53, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x54) + x54 += einsum(t1.aa, (0, 1), x53, (0, 2, 3, 4), (2, 3, 4, 1)) del x53 - x55 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x55 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x55) - x55 = einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x55) - x55 = einsum(x49, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x55) - x56 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x56 = einsum(t1.aa, (0, 1), x55, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x56) - del x55 - x57 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) - x57 = einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x57) - x57 = einsum(x54, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x57) + x55 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x55 += einsum(x50, (0, 1, 2, 3), (2, 1, 0, 3)) * -2.0 + del x50 + x55 += einsum(x51, (0, 1, 2, 3), (2, 1, 0, 3)) * -1.0 + del x51 + x55 += einsum(x54, (0, 1, 2, 3), (1, 0, 2, 3)) del x54 - x57 = einsum(x56, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x57) + x56 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x56 += einsum(t1.aa, (0, 1), x55, (0, 2, 3, 4), (2, 3, 1, 4)) + del x55 + x57 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x57 += einsum(x38, (0, 1, 2, 3), (0, 1, 2, 3)) + del x38 + x57 += einsum(x40, (0, 1, 2, 3), (0, 1, 2, 3)) * 4.0 + del x40 + x57 += einsum(x42, (0, 1, 2, 3), (0, 1, 2, 3)) + del x42 + x57 += einsum(x49, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + del x49 + x57 += einsum(x56, (0, 1, 2, 3), (1, 0, 2, 3)) del x56 - x58 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x58 = einsum(t1.aa, (0, 1), x57, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x58) + t2new_aaaa += einsum(x57, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_aaaa += einsum(x57, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 del x57 + x58 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x58 += einsum(t1.aa, (0, 1), v.aaaa.ooov, (2, 3, 4, 1), (0, 2, 3, 4)) x59 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x59 = einsum(x49, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x59) - del x49 - x59 = einsum(x50, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x59) - del x50 - x59 = einsum(x52, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x59) - del x52 - x59 = einsum(x58, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x59) - del x58 - t2new_aaaa = einsum(x59, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x59, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x59, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x59, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) - del x59 - x60 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x60 = einsum(f.aa.vv, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x60) + x59 += einsum(t2.aaaa, (0, 1, 2, 3), x58, (4, 5, 0, 1), (4, 5, 2, 3)) + x60 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x60 += einsum(f.aa.oo, (0, 1), (0, 1)) + x60 += einsum(x20, (0, 1), (0, 1)) + del x20 x61 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) - x61 = einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x61) - x61 = einsum(x60, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-2.0, beta=1.0, out=x61) + x61 += einsum(x60, (0, 1), t2.aaaa, (2, 1, 3, 4), (2, 0, 3, 4)) * -2.0 del x60 - t2new_aaaa = einsum(x61, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_aaaa) - t2new_aaaa = einsum(x61, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_aaaa) + x62 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x62 += einsum(x15, (0, 1), (1, 0)) + x62 += einsum(x16, (0, 1), (1, 0)) + x62 += einsum(x17, (0, 1), (1, 0)) * 0.5 + x62 += einsum(x19, (0, 1), (1, 0)) * -1.0 + del x19 + x63 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x63 += einsum(x62, (0, 1), t2.aaaa, (2, 0, 3, 4), (2, 1, 3, 4)) * -2.0 + del x62 + x64 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x64 += einsum(x59, (0, 1, 2, 3), (0, 1, 3, 2)) * -2.0 + del x59 + x64 += einsum(x61, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x61 - x62 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x62 = einsum(t1.bb, (0, 1), v.aabb.ovvv, (2, 3, 4, 1), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x62) - t2new_abab = einsum(x62, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_abab) - x63 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x63 = einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2), alpha=1.0, beta=1.0, out=x63) - t2new_abab = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=t2new_abab) - x64 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x64 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x64) - x65 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x65 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=0.5, beta=1.0, out=x65) - x65 = einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-0.5, beta=1.0, out=x65) - x65 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (4, 1, 5, 3), alpha=0.5, beta=1.0, out=x65) - x65 = einsum(x64, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x65) - t2new_abab = einsum(t2.abab, (0, 1, 2, 3), x65, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new_abab) - del x65 - x66 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x66 = einsum(t2.abab, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 0, 2), (4, 1, 5, 3), alpha=1.0, beta=1.0, out=x66) + x64 += einsum(x63, (0, 1, 2, 3), (0, 1, 3, 2)) + del x63 + t2new_aaaa += einsum(x64, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_aaaa += einsum(x64, (0, 1, 2, 3), (1, 0, 2, 3)) + del x64 + x65 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x65 += einsum(t1.aa, (0, 1), v.aaaa.ovvv, (2, 3, 4, 1), (0, 2, 3, 4)) + x66 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x66 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) x67 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x67 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x67) - x67 = einsum(x66, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x67) - x67 = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x67) - t2new_abab = einsum(t2.aaaa, (0, 1, 2, 3), x67, (1, 4, 3, 5), (0, 4, 2, 5), alpha=2.0, beta=1.0, out=t2new_abab) - del x67 - x68 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x68 = einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4), alpha=1.0, beta=1.0, out=x68) - x69 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x69 = einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 4, 1, 3), (2, 4), alpha=1.0, beta=1.0, out=x69) - x70 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x70 = einsum(f.bb.vv, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x70) - x70 = einsum(x68, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x70) - x70 = einsum(x69, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x70) - t2new_abab = einsum(x70, (0, 1), t2.abab, (2, 3, 4, 0), (2, 3, 4, 1), alpha=-1.0, beta=1.0, out=t2new_abab) - del x70 - x71 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) - x71 = einsum(f.aa.vv, (0, 1), (0, 1), alpha=-1.0, beta=1.0, out=x71) - x71 = einsum(x36, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x71) - del x36 - x71 = einsum(x37, (0, 1), (1, 0), alpha=0.5, beta=1.0, out=x71) - del x37 - t2new_abab = einsum(x71, (0, 1), t2.abab, (2, 3, 0, 4), (2, 3, 1, 4), alpha=-1.0, beta=1.0, out=t2new_abab) + x67 += einsum(t1.aa, (0, 1), v.aabb.vvov, (2, 1, 3, 4), (0, 3, 2, 4)) + t2new_abab += einsum(x67, (0, 1, 2, 3), (0, 1, 2, 3)) + x68 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x68 += einsum(t2.abab, (0, 1, 2, 3), x67, (4, 1, 5, 3), (4, 0, 2, 5)) + x69 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x69 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x69 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x69 += einsum(x66, (0, 1, 2, 3), (1, 0, 3, 2)) + x70 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x70 += einsum(t2.aaaa, (0, 1, 2, 3), x69, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 + del x69 + x71 = np.zeros((nocc[0], nvir[0], nvir[0], nvir[0]), dtype=np.float64) + x71 += einsum(v.aaaa.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x71 += einsum(v.aaaa.ovvv, (0, 1, 2, 3), (0, 2, 1, 3)) + x72 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x72 += einsum(t1.aa, (0, 1), x71, (2, 3, 1, 4), (0, 2, 3, 4)) del x71 - x72 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) - x72 = einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1), alpha=1.0, beta=1.0, out=x72) - x72 = einsum(t1.bb, (0, 1), v.aabb.vvov, (2, 3, 4, 1), (0, 4, 2, 3), alpha=1.0, beta=1.0, out=x72) - x73 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) - x73 = einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x73) - x73 = einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x73) - x73 = einsum(t1.aa, (0, 1), x22, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x73) - del x22 - x74 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) - x74 = einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1), alpha=1.0, beta=1.0, out=x74) - x74 = einsum(x21, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x74) - del x21 - x74 = einsum(t1.aa, (0, 1), x72, (2, 3, 1, 4), (0, 3, 2, 4), alpha=1.0, beta=1.0, out=x74) + x73 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x73 += einsum(t2.aaaa, (0, 1, 2, 3), x72, (4, 1, 3, 5), (0, 4, 2, 5)) * -2.0 del x72 - x74 = einsum(t1.aa, (0, 1), x73, (0, 2, 3, 4), (2, 4, 3, 1), alpha=-1.0, beta=1.0, out=x74) - del x73 - t2new_abab = einsum(t1.bb, (0, 1), x74, (2, 0, 3, 4), (2, 3, 4, 1), alpha=-1.0, beta=1.0, out=t2new_abab) + x74 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x74 += einsum(t1.aa, (0, 1), x58, (2, 3, 4, 0), (2, 4, 3, 1)) + del x58 + x75 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x75 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ooov, (4, 5, 1, 3), (0, 4, 5, 2)) + x76 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x76 += einsum(t2.abab, (0, 1, 2, 3), x3, (4, 5, 1, 3), (4, 0, 5, 2)) + x77 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x77 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x77 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (2, 0, 1, 3)) + x78 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x78 += einsum(t2.aaaa, (0, 1, 2, 3), x77, (1, 4, 5, 3), (0, 4, 5, 2)) * 2.0 + del x77 + x79 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x79 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) + x79 += einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x80 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x80 += einsum(t2.aaaa, (0, 1, 2, 3), x79, (4, 5, 1, 3), (0, 4, 5, 2)) * 2.0 + del x79 + x81 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x81 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 3, 1)) + x81 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x81 += einsum(x65, (0, 1, 2, 3), (0, 1, 2, 3)) + x82 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x82 += einsum(t1.aa, (0, 1), x81, (2, 3, 1, 4), (0, 2, 3, 4)) + del x81 + x83 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x83 += einsum(x74, (0, 1, 2, 3), (0, 2, 1, 3)) del x74 - x75 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x75 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x75) - x75 = einsum(x62, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x75) - del x62 - x76 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) - x76 = einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x76) - x76 = einsum(t1.bb, (0, 1), v.aabb.oovv, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x76) - x76 = einsum(t1.aa, (0, 1), x75, (2, 3, 1, 4), (2, 0, 3, 4), alpha=1.0, beta=1.0, out=x76) + x83 += einsum(x75, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 del x75 - t2new_abab = einsum(t1.aa, (0, 1), x76, (0, 2, 3, 4), (2, 3, 1, 4), alpha=-1.0, beta=1.0, out=t2new_abab) + x83 += einsum(x76, (0, 1, 2, 3), (0, 2, 1, 3)) del x76 - x77 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x77 = einsum(f.bb.oo, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x77) - x77 = einsum(x25, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x77) - x77 = einsum(x26, (0, 1), (1, 0), alpha=2.0, beta=1.0, out=x77) - t2new_abab = einsum(x77, (0, 1), t2.abab, (2, 0, 3, 4), (2, 1, 3, 4), alpha=-0.5, beta=1.0, out=t2new_abab) - del x77 - x78 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) - x78 = einsum(f.aa.oo, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x78) - x78 = einsum(x14, (0, 1), (1, 0), alpha=2.0, beta=1.0, out=x78) - del x14 - x78 = einsum(x15, (0, 1), (1, 0), alpha=1.0, beta=1.0, out=x78) - del x15 - t2new_abab = einsum(x78, (0, 1), t2.abab, (0, 2, 3, 4), (1, 2, 3, 4), alpha=-0.5, beta=1.0, out=t2new_abab) + x83 += einsum(x78, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 del x78 - x79 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x79 = einsum(t1.bb, (0, 1), v.bbbb.ovvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x79) - x80 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x80 = einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x80) - x80 = einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 3, 1), alpha=-1.0, beta=1.0, out=x80) - x81 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x81 = einsum(x24, (0, 1, 2, 3), x80, (0, 4, 2, 5), (1, 4, 3, 5), alpha=1.0, beta=1.0, out=x81) - del x24, x80 - x82 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) - x82 = einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x82) - x82 = einsum(x63, (0, 1, 2, 3), (0, 1, 2, 3), alpha=2.0, beta=1.0, out=x82) - del x63 - x83 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x83 = einsum(t2.abab, (0, 1, 2, 3), x82, (0, 4, 2, 5), (1, 4, 3, 5), alpha=1.0, beta=1.0, out=x83) + x83 += einsum(x80, (0, 1, 2, 3), (1, 2, 0, 3)) * -1.0 + del x80 + x83 += einsum(x82, (0, 1, 2, 3), (0, 2, 1, 3)) del x82 - x84 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) - x84 = einsum(t1.bb, (0, 1), v.bbbb.ooov, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x84) - x85 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x85 = einsum(t1.bb, (0, 1), x84, (2, 3, 4, 0), (2, 4, 3, 1), alpha=1.0, beta=1.0, out=x85) + x84 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x84 += einsum(t1.aa, (0, 1), x83, (2, 0, 3, 4), (2, 3, 1, 4)) + del x83 + x85 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x85 += einsum(x65, (0, 1, 2, 3), (0, 1, 2, 3)) + del x65 + x85 += einsum(x66, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x66 + x85 += einsum(x68, (0, 1, 2, 3), (0, 1, 2, 3)) + del x68 + x85 += einsum(x70, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x70 + x85 += einsum(x73, (0, 1, 2, 3), (1, 0, 2, 3)) + del x73 + x85 += einsum(x84, (0, 1, 2, 3), (0, 1, 2, 3)) del x84 - x86 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x86 = einsum(t1.bb, (0, 1), x79, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x86) - x87 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x87 = einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x87) - x87 = einsum(x85, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x87) + t2new_aaaa += einsum(x85, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_aaaa += einsum(x85, (0, 1, 2, 3), (0, 1, 3, 2)) + t2new_aaaa += einsum(x85, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new_aaaa += einsum(x85, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 del x85 - x87 = einsum(x86, (0, 1, 2, 3), (0, 2, 1, 3), alpha=1.0, beta=1.0, out=x87) + x86 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x86 += einsum(t1.aa, (0, 1), v.aaaa.ooov, (2, 0, 3, 4), (2, 3, 1, 4)) + t2new_aaaa += einsum(x86, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_aaaa += einsum(x86, (0, 1, 2, 3), (1, 0, 2, 3)) del x86 - x88 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x88 = einsum(t1.bb, (0, 1), x87, (2, 0, 3, 4), (2, 3, 1, 4), alpha=1.0, beta=1.0, out=x88) + x87 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x87 += einsum(f.aa.vv, (0, 1), t2.aaaa, (2, 3, 4, 1), (2, 3, 0, 4)) + x88 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x88 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x88 += einsum(x87, (0, 1, 2, 3), (1, 0, 3, 2)) * -2.0 del x87 - x89 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x89 = einsum(x79, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x89) - del x79 - x89 = einsum(x81, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x89) - del x81 - x89 = einsum(x83, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=x89) - del x83 - x89 = einsum(x88, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x89) + t2new_aaaa += einsum(x88, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_aaaa += einsum(x88, (0, 1, 2, 3), (0, 1, 2, 3)) del x88 - t2new_bbbb = einsum(x89, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x89, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x89, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x89, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) + x89 = np.zeros((nocc[0], nocc[0], nocc[0], nocc[0]), dtype=np.float64) + x89 += einsum(t2.aaaa, (0, 1, 2, 3), v.aaaa.ovov, (4, 2, 5, 3), (0, 1, 4, 5)) + x90 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x90 += einsum(t1.aa, (0, 1), x89, (2, 3, 0, 4), (2, 3, 4, 1)) * -2.0 del x89 - x90 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x90 = einsum(f.bb.vv, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 0, 4), alpha=1.0, beta=1.0, out=x90) - x91 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x91 = einsum(t2.abab, (0, 1, 2, 3), x66, (0, 4, 2, 5), (4, 1, 5, 3), alpha=1.0, beta=1.0, out=x91) - del x66 - x92 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x92 = einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3), alpha=2.0, beta=1.0, out=x92) - x92 = einsum(x90, (0, 1, 2, 3), (1, 0, 3, 2), alpha=-2.0, beta=1.0, out=x92) + x90 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x90 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (2, 0, 1, 3)) + t2new_aaaa += einsum(t1.aa, (0, 1), x90, (2, 3, 0, 4), (2, 3, 4, 1)) * -1.0 del x90 - x92 = einsum(x91, (0, 1, 2, 3), (1, 0, 3, 2), alpha=1.0, beta=1.0, out=x92) - del x91 - t2new_bbbb = einsum(x92, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x92, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) - del x92 - x93 = np.zeros((nocc[1], nvir[1], nvir[1], nvir[1]), dtype=np.float64) - x93 = einsum(t1.bb, (0, 1), v.bbbb.vvvv, (2, 3, 4, 1), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x93) + x91 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x91 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 5, 1, 3), (0, 4, 2, 5)) + x92 = np.zeros((nocc[1], nvir[1], nvir[1], nvir[1]), dtype=np.float64) + x92 += einsum(v.bbbb.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) + x92 += einsum(v.bbbb.ovvv, (0, 1, 2, 3), (0, 2, 3, 1)) * -1.0 + x93 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x93 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x93 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x93 += einsum(x25, (0, 1, 2, 3), (0, 1, 2, 3)) + x93 += einsum(x25, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 x94 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x94 = einsum(t1.bb, (0, 1), x93, (2, 3, 1, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x94) + x94 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) * 0.5 + x94 += einsum(v.bbbb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -0.5 + x94 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 4, 5), (4, 1, 5, 3)) * 0.5 + x94 += einsum(x91, (0, 1, 2, 3), (1, 0, 3, 2)) + x94 += einsum(t1.bb, (0, 1), x92, (2, 1, 3, 4), (2, 0, 4, 3)) * -0.5 + x94 += einsum(t1.bb, (0, 1), x93, (2, 3, 0, 4), (3, 2, 4, 1)) * -0.5 del x93 - x95 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x95 = einsum(t2.bbbb, (0, 1, 2, 3), x64, (4, 1, 5, 3), (0, 4, 2, 5), alpha=1.0, beta=1.0, out=x95) - del x64 - x96 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) - x96 = einsum(x68, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x96) - del x68 - x96 = einsum(x69, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x96) - del x69 - x97 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x97 = einsum(x96, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 4, 0), alpha=-1.0, beta=1.0, out=x97) - del x96 - x98 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) - x98 = einsum(t1.bb, (0, 1), x19, (2, 3, 4, 1), (2, 0, 4, 3), alpha=1.0, beta=1.0, out=x98) - del x19 - x99 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) - x99 = einsum(v.bbbb.oooo, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x99) - x99 = einsum(x98, (0, 1, 2, 3), (3, 1, 0, 2), alpha=1.0, beta=1.0, out=x99) - del x98 - x100 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) - x100 = einsum(t1.bb, (0, 1), x99, (0, 2, 3, 4), (2, 3, 4, 1), alpha=1.0, beta=1.0, out=x100) - del x99 - x101 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x101 = einsum(t1.bb, (0, 1), x100, (2, 3, 0, 4), (3, 2, 1, 4), alpha=1.0, beta=1.0, out=x101) - del x100 - x102 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x102 = einsum(x94, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x102) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x94, (1, 4, 3, 5), (0, 4, 2, 5)) * 2.0 del x94 - x102 = einsum(x95, (0, 1, 2, 3), (0, 1, 2, 3), alpha=4.0, beta=1.0, out=x102) + x95 = np.zeros((nocc[0], nocc[0], nocc[0], nvir[0]), dtype=np.float64) + x95 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x95 += einsum(v.aaaa.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) + x95 += einsum(x1, (0, 1, 2, 3), (0, 1, 2, 3)) + x95 += einsum(x1, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + del x1 + x96 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x96 += einsum(v.aaaa.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x96 += einsum(v.aaaa.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x96 += einsum(x39, (0, 1, 2, 3), (1, 0, 3, 2)) * 2.0 + del x39 + x96 += einsum(t1.aa, (0, 1), x46, (2, 1, 3, 4), (2, 0, 4, 3)) * -1.0 + x96 += einsum(t1.aa, (0, 1), x95, (2, 3, 0, 4), (3, 2, 4, 1)) * -1.0 del x95 - x102 = einsum(x97, (0, 1, 2, 3), (1, 0, 2, 3), alpha=-1.0, beta=1.0, out=x102) - del x97 - x102 = einsum(x101, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=x102) - del x101 - t2new_bbbb = einsum(x102, (0, 1, 2, 3), (0, 1, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x102, (0, 1, 2, 3), (0, 1, 3, 2), alpha=-1.0, beta=1.0, out=t2new_bbbb) - del x102 - x103 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x103 = einsum(f.bb.oo, (0, 1), t2.bbbb, (2, 1, 3, 4), (0, 2, 3, 4), alpha=1.0, beta=1.0, out=x103) - x104 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) - x104 = einsum(x25, (0, 1), (0, 1), alpha=1.0, beta=1.0, out=x104) - del x25 - x104 = einsum(x26, (0, 1), (0, 1), alpha=2.0, beta=1.0, out=x104) - del x26 - x105 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x105 = einsum(x104, (0, 1), t2.bbbb, (2, 1, 3, 4), (2, 0, 3, 4), alpha=-1.0, beta=1.0, out=x105) - del x104 - x106 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) - x106 = einsum(x103, (0, 1, 2, 3), (0, 1, 3, 2), alpha=2.0, beta=1.0, out=x106) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x96, (0, 4, 2, 5), (4, 1, 5, 3)) + del x96 + x97 = np.zeros((nocc[0], nocc[0], nvir[0], nvir[0]), dtype=np.float64) + x97 += einsum(t2.aaaa, (0, 1, 2, 3), (0, 1, 2, 3)) + x97 += einsum(t1.aa, (0, 1), t1.aa, (2, 3), (0, 2, 3, 1)) * -0.5 + x98 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x98 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x98 += einsum(t1.aa, (0, 1), v.aabb.ooov, (2, 0, 3, 4), (2, 3, 1, 4)) * -1.0 + x98 += einsum(x67, (0, 1, 2, 3), (0, 1, 2, 3)) + del x67 + x98 += einsum(v.aabb.ovov, (0, 1, 2, 3), x97, (0, 4, 1, 5), (4, 2, 5, 3)) * 2.0 + t2new_abab += einsum(t2.bbbb, (0, 1, 2, 3), x98, (4, 1, 5, 3), (4, 0, 5, 2)) * 2.0 + del x98 + x99 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x99 += einsum(t1.bb, (0, 1), v.aabb.ovvv, (2, 3, 4, 1), (2, 0, 3, 4)) + x100 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x100 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x100 += einsum(x99, (0, 1, 2, 3), (0, 1, 2, 3)) + x100 += einsum(t1.bb, (0, 1), x24, (2, 0, 3, 4), (2, 3, 4, 1)) * -1.0 + del x24 + t2new_abab += einsum(x100, (0, 1, 2, 3), x97, (0, 4, 2, 5), (4, 1, 5, 3)) * 2.0 + del x97, x100 + x101 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) + x101 += einsum(t1.bb, (0, 1), v.aabb.vvov, (2, 3, 4, 1), (0, 4, 2, 3)) + x102 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x102 += einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1)) + x102 += einsum(x23, (0, 1, 2, 3), (0, 1, 2, 3)) + x103 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) + x103 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1)) + x103 += einsum(x101, (0, 1, 2, 3), (1, 0, 3, 2)) + x103 += einsum(t1.aa, (0, 1), x102, (0, 2, 3, 4), (3, 2, 4, 1)) * -1.0 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x103, (1, 4, 2, 5), (0, 4, 5, 3)) * -1.0 del x103 - x106 = einsum(x105, (0, 1, 2, 3), (0, 1, 3, 2), alpha=1.0, beta=1.0, out=x106) + x104 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x104 += einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) + x104 += einsum(x3, (0, 1, 2, 3), (0, 1, 2, 3)) + del x3 + x105 = np.zeros((nocc[0], nocc[0], nvir[1], nvir[1]), dtype=np.float64) + x105 += einsum(v.aabb.oovv, (0, 1, 2, 3), (0, 1, 2, 3)) + x105 += einsum(t1.aa, (0, 1), v.aabb.ovvv, (2, 1, 3, 4), (2, 0, 3, 4)) + x105 += einsum(t1.bb, (0, 1), x104, (2, 3, 0, 4), (3, 2, 4, 1)) * -1.0 + del x104 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x105, (0, 4, 3, 5), (4, 1, 2, 5)) * -1.0 del x105 - t2new_bbbb = einsum(x106, (0, 1, 2, 3), (0, 1, 2, 3), alpha=-1.0, beta=1.0, out=t2new_bbbb) - t2new_bbbb = einsum(x106, (0, 1, 2, 3), (1, 0, 2, 3), alpha=1.0, beta=1.0, out=t2new_bbbb) + x106 = np.zeros((nvir[0], nvir[0], nvir[1], nvir[1]), dtype=np.float64) + x106 += einsum(v.aabb.vvvv, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x106 += einsum(t1.aa, (0, 1), v.aabb.ovvv, (0, 2, 3, 4), (2, 1, 3, 4)) + x106 += einsum(t1.bb, (0, 1), v.aabb.vvov, (2, 3, 0, 4), (2, 3, 4, 1)) + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x106, (2, 4, 3, 5), (0, 1, 4, 5)) * -1.0 del x106 + x107 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x107 += einsum(t1.aa, (0, 1), v.aabb.ovvv, (0, 1, 2, 3), (2, 3)) + x108 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x108 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (0, 2, 1, 4), (3, 4)) + x109 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x109 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (0, 3, 1, 4), (2, 4)) * -1.0 + x110 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x110 += einsum(t1.bb, (0, 1), x92, (0, 1, 2, 3), (2, 3)) + x111 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x111 += einsum(f.bb.vv, (0, 1), (0, 1)) * -1.0 + x111 += einsum(x107, (0, 1), (1, 0)) * -1.0 + x111 += einsum(x108, (0, 1), (1, 0)) * 0.5 + x111 += einsum(x109, (0, 1), (1, 0)) + x111 += einsum(x110, (0, 1), (1, 0)) * -1.0 + x111 += einsum(t1.bb, (0, 1), x13, (0, 2), (2, 1)) + t2new_abab += einsum(x111, (0, 1), t2.abab, (2, 3, 4, 0), (2, 3, 4, 1)) * -1.0 + del x111 + x112 = np.zeros((nvir[0], nvir[0]), dtype=np.float64) + x112 += einsum(f.aa.vv, (0, 1), (0, 1)) * -2.0 + x112 += einsum(x43, (0, 1), (1, 0)) * -2.0 + del x43 + x112 += einsum(x44, (0, 1), (1, 0)) * 2.0 + del x44 + x112 += einsum(x45, (0, 1), (1, 0)) + del x45 + x112 += einsum(t1.aa, (0, 1), x46, (0, 1, 2, 3), (3, 2)) * -2.0 + del x46 + x112 += einsum(t1.aa, (0, 1), x9, (0, 2), (2, 1)) * 2.0 + t2new_abab += einsum(x112, (0, 1), t2.abab, (2, 3, 0, 4), (2, 3, 1, 4)) * -0.5 + del x112 + x113 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x113 += einsum(t1.bb, (0, 1), v.aabb.ooov, (2, 3, 4, 1), (2, 3, 0, 4)) + x114 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x114 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x114 += einsum(x113, (0, 1, 2, 3), (1, 0, 3, 2)) + x114 += einsum(t1.aa, (0, 1), x102, (2, 3, 4, 1), (2, 0, 4, 3)) + del x102 + t2new_abab += einsum(t2.abab, (0, 1, 2, 3), x114, (0, 4, 1, 5), (4, 5, 2, 3)) + del x114 + x115 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x115 += einsum(f.bb.oo, (0, 1), (0, 1)) + x115 += einsum(x29, (0, 1), (1, 0)) + x115 += einsum(x30, (0, 1), (1, 0)) * 0.5 + x115 += einsum(x31, (0, 1), (1, 0)) + x115 += einsum(x33, (0, 1), (1, 0)) * -1.0 + x115 += einsum(x34, (0, 1), (1, 0)) + t2new_abab += einsum(x115, (0, 1), t2.abab, (2, 0, 3, 4), (2, 1, 3, 4)) * -1.0 + del x115 + x116 = np.zeros((nocc[0], nocc[0]), dtype=np.float64) + x116 += einsum(f.aa.oo, (0, 1), (0, 1)) * 2.0 + x116 += einsum(x15, (0, 1), (1, 0)) * 2.0 + del x15 + x116 += einsum(x16, (0, 1), (1, 0)) * 2.0 + del x16 + x116 += einsum(x17, (0, 1), (1, 0)) + del x17 + x116 += einsum(t1.aa, (0, 1), x18, (2, 3, 0, 1), (3, 2)) * -2.0 + del x18 + x116 += einsum(t1.aa, (0, 1), x9, (2, 1), (2, 0)) * 2.0 + del x9 + t2new_abab += einsum(x116, (0, 1), t2.abab, (0, 2, 3, 4), (1, 2, 3, 4)) * -0.5 + del x116 + x117 = np.zeros((nocc[1], nocc[1], nvir[0], nvir[0]), dtype=np.float64) + x117 += einsum(v.aabb.vvoo, (0, 1, 2, 3), (2, 3, 0, 1)) + x117 += einsum(x101, (0, 1, 2, 3), (0, 1, 3, 2)) + del x101 + x118 = np.zeros((nocc[0], nocc[0], nocc[1], nocc[1]), dtype=np.float64) + x118 += einsum(v.aabb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x118 += einsum(x113, (0, 1, 2, 3), (1, 0, 2, 3)) + del x113 + x118 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovov, (4, 2, 5, 3), (4, 0, 1, 5)) + x119 = np.zeros((nocc[0], nocc[1], nocc[1], nvir[0]), dtype=np.float64) + x119 += einsum(v.aabb.ovoo, (0, 1, 2, 3), (0, 2, 3, 1)) + x119 += einsum(x23, (0, 1, 2, 3), (0, 2, 1, 3)) + x119 += einsum(t1.aa, (0, 1), x117, (2, 3, 1, 4), (0, 3, 2, 4)) + del x117 + x119 += einsum(t1.aa, (0, 1), x118, (0, 2, 3, 4), (2, 4, 3, 1)) * -1.0 + del x118 + t2new_abab += einsum(t1.bb, (0, 1), x119, (2, 0, 3, 4), (2, 3, 4, 1)) * -1.0 + del x119 + x120 = np.zeros((nocc[0], nvir[0], nvir[1], nvir[1]), dtype=np.float64) + x120 += einsum(v.aabb.ovvv, (0, 1, 2, 3), (0, 1, 2, 3)) + x120 += einsum(t1.aa, (0, 1), v.aabb.vvvv, (2, 1, 3, 4), (0, 2, 3, 4)) + t2new_abab += einsum(t1.bb, (0, 1), x120, (2, 3, 1, 4), (2, 0, 3, 4)) + del x120 + x121 = np.zeros((nocc[0], nocc[0], nocc[1], nvir[1]), dtype=np.float64) + x121 += einsum(v.aabb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) + x121 += einsum(t1.bb, (0, 1), v.aabb.oovv, (2, 3, 4, 1), (2, 3, 0, 4)) + t2new_abab += einsum(t1.aa, (0, 1), x121, (0, 2, 3, 4), (2, 3, 1, 4)) * -1.0 + del x121 + x122 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x122 += einsum(t1.bb, (0, 1), v.bbbb.ovvv, (2, 3, 4, 1), (0, 2, 3, 4)) + x123 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x123 += einsum(t2.abab, (0, 1, 2, 3), x99, (0, 4, 2, 5), (4, 1, 3, 5)) + del x99 + x124 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x124 += einsum(t2.bbbb, (0, 1, 2, 3), (0, 1, 2, 3)) + x124 += einsum(t1.bb, (0, 1), t1.bb, (2, 3), (0, 2, 3, 1)) * -0.5 + x125 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x125 += einsum(x124, (0, 1, 2, 3), x28, (0, 4, 2, 5), (4, 1, 5, 3)) * 2.0 + del x28, x124 + x126 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x126 += einsum(t2.bbbb, (0, 1, 2, 3), v.aabb.ovov, (4, 5, 1, 3), (4, 0, 5, 2)) + x127 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x127 += einsum(v.aabb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x127 += einsum(x126, (0, 1, 2, 3), (0, 1, 2, 3)) * 2.0 + del x126 + x128 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x128 += einsum(t2.abab, (0, 1, 2, 3), x127, (0, 4, 2, 5), (1, 4, 3, 5)) + del x127 + x129 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x129 += einsum(t1.bb, (0, 1), x92, (2, 1, 3, 4), (0, 2, 3, 4)) + del x92 + x130 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x130 += einsum(t2.bbbb, (0, 1, 2, 3), x129, (4, 1, 5, 3), (0, 4, 2, 5)) * -2.0 + del x129 + x131 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x131 += einsum(t2.abab, (0, 1, 2, 3), v.aabb.ovoo, (0, 2, 4, 5), (1, 4, 5, 3)) + x132 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x132 += einsum(t1.bb, (0, 1), v.bbbb.ooov, (2, 3, 4, 1), (0, 2, 3, 4)) + x133 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x133 += einsum(t1.bb, (0, 1), x132, (2, 3, 4, 0), (2, 4, 3, 1)) + x134 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x134 += einsum(t1.bb, (0, 1), x122, (2, 3, 1, 4), (0, 2, 3, 4)) + x135 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x135 += einsum(t2.abab, (0, 1, 2, 3), x23, (0, 4, 5, 2), (4, 1, 5, 3)) + del x23 + x136 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x136 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 1, 2, 3)) + x136 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + x137 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x137 += einsum(t2.bbbb, (0, 1, 2, 3), x136, (4, 5, 1, 3), (0, 4, 5, 2)) * 2.0 + del x136 + x138 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x138 += einsum(x25, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + x138 += einsum(x25, (0, 1, 2, 3), (0, 2, 1, 3)) + x139 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x139 += einsum(t2.bbbb, (0, 1, 2, 3), x138, (4, 1, 5, 3), (0, 4, 5, 2)) * 2.0 + del x138 + x140 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x140 += einsum(x131, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + del x131 + x140 += einsum(x133, (0, 1, 2, 3), (0, 2, 1, 3)) + del x133 + x140 += einsum(x134, (0, 1, 2, 3), (0, 2, 1, 3)) + del x134 + x140 += einsum(x135, (0, 1, 2, 3), (0, 2, 1, 3)) + del x135 + x140 += einsum(x137, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + del x137 + x140 += einsum(x139, (0, 1, 2, 3), (1, 2, 0, 3)) * -1.0 + del x139 + x141 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x141 += einsum(t1.bb, (0, 1), x140, (2, 0, 3, 4), (2, 3, 1, 4)) + del x140 + x142 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x142 += einsum(x122, (0, 1, 2, 3), (0, 1, 2, 3)) + del x122 + x142 += einsum(x123, (0, 1, 2, 3), (0, 1, 2, 3)) + del x123 + x142 += einsum(x125, (0, 1, 2, 3), (1, 0, 3, 2)) + del x125 + x142 += einsum(x128, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + del x128 + x142 += einsum(x130, (0, 1, 2, 3), (1, 0, 2, 3)) + del x130 + x142 += einsum(x141, (0, 1, 2, 3), (0, 1, 2, 3)) + del x141 + t2new_bbbb += einsum(x142, (0, 1, 2, 3), (0, 1, 2, 3)) * -1.0 + t2new_bbbb += einsum(x142, (0, 1, 2, 3), (0, 1, 3, 2)) + t2new_bbbb += einsum(x142, (0, 1, 2, 3), (1, 0, 2, 3)) + t2new_bbbb += einsum(x142, (0, 1, 2, 3), (1, 0, 3, 2)) * -1.0 + del x142 + x143 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x143 += einsum(f.bb.vv, (0, 1), t2.bbbb, (2, 3, 4, 1), (2, 3, 0, 4)) + x144 = np.zeros((nocc[0], nocc[1], nvir[0], nvir[1]), dtype=np.float64) + x144 += einsum(t2.abab, (0, 1, 2, 3), v.aaaa.ovov, (4, 5, 0, 2), (4, 1, 5, 3)) + x145 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x145 += einsum(t2.abab, (0, 1, 2, 3), x144, (0, 4, 2, 5), (4, 1, 5, 3)) + del x144 + x146 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x146 += einsum(v.bbbb.ovov, (0, 1, 2, 3), (0, 2, 1, 3)) + x146 += einsum(x143, (0, 1, 2, 3), (1, 0, 3, 2)) * -2.0 + del x143 + x146 += einsum(x145, (0, 1, 2, 3), (1, 0, 3, 2)) + del x145 + t2new_bbbb += einsum(x146, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + t2new_bbbb += einsum(x146, (0, 1, 2, 3), (0, 1, 2, 3)) + del x146 + x147 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x147 += einsum(t1.bb, (0, 1), v.bbbb.ooov, (2, 0, 3, 4), (2, 3, 1, 4)) + x148 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x148 += einsum(t2.bbbb, (0, 1, 2, 3), x132, (4, 5, 0, 1), (4, 5, 2, 3)) + del x132 + x149 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x149 += einsum(f.bb.oo, (0, 1), (0, 1)) + x149 += einsum(x34, (0, 1), (0, 1)) + del x34 + x150 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x150 += einsum(x149, (0, 1), t2.bbbb, (2, 1, 3, 4), (2, 0, 3, 4)) * -2.0 + del x149 + x151 = np.zeros((nocc[1], nocc[1]), dtype=np.float64) + x151 += einsum(x29, (0, 1), (1, 0)) + del x29 + x151 += einsum(x30, (0, 1), (1, 0)) * 0.5 + del x30 + x151 += einsum(x31, (0, 1), (1, 0)) + del x31 + x151 += einsum(x33, (0, 1), (1, 0)) * -1.0 + del x33 + x152 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x152 += einsum(x151, (0, 1), t2.bbbb, (2, 0, 3, 4), (2, 1, 3, 4)) * -2.0 + del x151 + x153 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x153 += einsum(x147, (0, 1, 2, 3), (0, 1, 3, 2)) + del x147 + x153 += einsum(x148, (0, 1, 2, 3), (0, 1, 3, 2)) * 2.0 + del x148 + x153 += einsum(x150, (0, 1, 2, 3), (1, 0, 3, 2)) + del x150 + x153 += einsum(x152, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x152 + t2new_bbbb += einsum(x153, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_bbbb += einsum(x153, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + del x153 + x154 = np.zeros((nocc[1], nvir[1], nvir[1], nvir[1]), dtype=np.float64) + x154 += einsum(t1.bb, (0, 1), v.bbbb.vvvv, (2, 3, 4, 1), (0, 2, 3, 4)) + x155 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x155 += einsum(t1.bb, (0, 1), x154, (2, 3, 1, 4), (0, 2, 3, 4)) + del x154 + x156 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x156 += einsum(t2.bbbb, (0, 1, 2, 3), x91, (4, 1, 5, 3), (0, 4, 2, 5)) + del x91 + x157 = np.zeros((nvir[1], nvir[1]), dtype=np.float64) + x157 += einsum(x107, (0, 1), (1, 0)) * -1.0 + del x107 + x157 += einsum(x108, (0, 1), (1, 0)) * 0.5 + del x108 + x157 += einsum(x109, (0, 1), (1, 0)) + del x109 + x157 += einsum(x110, (0, 1), (1, 0)) * -1.0 + del x110 + x158 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x158 += einsum(x157, (0, 1), t2.bbbb, (2, 3, 4, 0), (2, 3, 4, 1)) * -2.0 + del x157 + x159 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x159 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovvv, (4, 3, 5, 2), (0, 1, 4, 5)) * -1.0 + x160 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x160 += einsum(x13, (0, 1), t2.bbbb, (2, 3, 4, 1), (0, 2, 3, 4)) * -2.0 + del x13 + x161 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x161 += einsum(t1.bb, (0, 1), x25, (2, 3, 4, 1), (2, 0, 4, 3)) + del x25 + x162 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x162 += einsum(v.bbbb.oooo, (0, 1, 2, 3), (0, 1, 2, 3)) + x162 += einsum(x161, (0, 1, 2, 3), (3, 1, 2, 0)) + del x161 + t2new_bbbb += einsum(t2.bbbb, (0, 1, 2, 3), x162, (0, 4, 1, 5), (4, 5, 2, 3)) * 2.0 + x163 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x163 += einsum(t1.bb, (0, 1), x162, (0, 2, 3, 4), (2, 3, 4, 1)) + del x162 + x164 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x164 += einsum(x159, (0, 1, 2, 3), (2, 1, 0, 3)) * -2.0 + del x159 + x164 += einsum(x160, (0, 1, 2, 3), (0, 2, 1, 3)) * -1.0 + del x160 + x164 += einsum(x163, (0, 1, 2, 3), (1, 0, 2, 3)) + del x163 + x165 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x165 += einsum(t1.bb, (0, 1), x164, (0, 2, 3, 4), (2, 3, 1, 4)) + del x164 + x166 = np.zeros((nocc[1], nocc[1], nvir[1], nvir[1]), dtype=np.float64) + x166 += einsum(x155, (0, 1, 2, 3), (0, 1, 2, 3)) + del x155 + x166 += einsum(x156, (0, 1, 2, 3), (0, 1, 2, 3)) * 4.0 + del x156 + x166 += einsum(x158, (0, 1, 2, 3), (1, 0, 2, 3)) * -1.0 + del x158 + x166 += einsum(x165, (0, 1, 2, 3), (1, 0, 2, 3)) + del x165 + t2new_bbbb += einsum(x166, (0, 1, 2, 3), (0, 1, 2, 3)) + t2new_bbbb += einsum(x166, (0, 1, 2, 3), (0, 1, 3, 2)) * -1.0 + del x166 + x167 = np.zeros((nocc[1], nocc[1], nocc[1], nocc[1]), dtype=np.float64) + x167 += einsum(t2.bbbb, (0, 1, 2, 3), v.bbbb.ovov, (4, 2, 5, 3), (0, 1, 4, 5)) + x168 = np.zeros((nocc[1], nocc[1], nocc[1], nvir[1]), dtype=np.float64) + x168 += einsum(t1.bb, (0, 1), x167, (2, 3, 0, 4), (2, 3, 4, 1)) * -1.0 + del x167 + x168 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (0, 2, 1, 3)) * -0.5 + x168 += einsum(v.bbbb.ooov, (0, 1, 2, 3), (2, 0, 1, 3)) * 0.5 + t2new_bbbb += einsum(t1.bb, (0, 1), x168, (2, 3, 0, 4), (2, 3, 1, 4)) * 2.0 + del x168 t1new.aa = t1new_aa t1new.bb = t1new_bb From e9bbda0793b6162fd4152d3ff63e3e880cc74f9f Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 20:51:42 +0100 Subject: [PATCH 12/13] Add DCD and DCSD to FEATURES.md --- FEATURES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FEATURES.md b/FEATURES.md index 36133bae..2ad5484b 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -20,6 +20,8 @@ The following table summarises the available methods and routines for the ansatz | CC2 | RUG | RUG | RUG | | | | RUG | RUG | - | | CC3 | RUG | RUG | | | | | | | - | | QCISD | RUG | RUG | | | | | | | - | +| DCD | RU | RU | | | | | | | - | +| DCSD | RU | RU | | | | | | | - | | CCSD-S-1-1 | RUG | RUG | RUG | | | | RUG | RUG | RUG | | CCSD-SD-1-1 | RUG | RUG | RUG | | | | RUG | RUG | RUG | | CCSD-SD-1-2 | RUG | RUG | RUG | | | | RUG | RUG | RUG | From 673b335dfd7deb8dbb39f0d732965e61f94db5b6 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Thu, 28 Sep 2023 21:04:52 +0100 Subject: [PATCH 13/13] Add DCD and DCSD tests --- tests/test_RDCD.py | 62 +++++++++++++++++++++++++++++++++++ tests/test_RDCSD.py | 61 +++++++++++++++++++++++++++++++++++ tests/test_UDCD.py | 72 +++++++++++++++++++++++++++++++++++++++++ tests/test_UDCSD.py | 78 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 273 insertions(+) create mode 100644 tests/test_RDCD.py create mode 100644 tests/test_RDCSD.py create mode 100644 tests/test_UDCD.py create mode 100644 tests/test_UDCSD.py diff --git a/tests/test_RDCD.py b/tests/test_RDCD.py new file mode 100644 index 00000000..b4e13386 --- /dev/null +++ b/tests/test_RDCD.py @@ -0,0 +1,62 @@ +"""Tests for the RDCD model. +""" + +import unittest + +import numpy as np +import pytest +from pyscf import gto, scf + +from ebcc import REBCC, NullLogger, Space + + +@pytest.mark.reference +class RDCD_Tests(unittest.TestCase): + """Test RDCD against reference values. + + Ref: J. Chem. Phys. 144, 124117 (2016) + """ + + @classmethod + def setUpClass(cls): + mol = gto.Mole() + mol.atom = "N 0 0 0; N 0 0 2.2" + mol.unit = "B" + mol.basis = "cc-pvdz" + mol.verbose = 0 + mol.build() + + mf = scf.RHF(mol) + mf.conv_tol = 1e-12 + mf.kernel() + + frozen = np.zeros_like(mf.mo_occ, dtype=bool) + frozen[:2] = True + space = Space(mf.mo_occ > 0, frozen, np.zeros_like(frozen)) + + dcd = REBCC( + mf, + space=space, + ansatz="DCD", + log=NullLogger(), + ) + dcd.options.e_tol = 1e-10 + dcd.kernel() + + cls.mf, cls.dcd = mf, dcd + + @classmethod + def tearDownClass(cls): + del cls.mf, cls.dcd + + def test_converged(self): + self.assertTrue(self.dcd.converged) + + def test_energy(self): + self.assertAlmostEqual(self.dcd.e_corr, -0.33481, places=5) + self.assertAlmostEqual(self.dcd.e_tot, -109.26792, places=5) + + +if __name__ == "__main__": + print("Tests for RDCD") + unittest.main() diff --git a/tests/test_RDCSD.py b/tests/test_RDCSD.py new file mode 100644 index 00000000..916eed49 --- /dev/null +++ b/tests/test_RDCSD.py @@ -0,0 +1,61 @@ +"""Tests for the RDCSD model. +""" + +import unittest + +import numpy as np +import pytest +from pyscf import gto, scf + +from ebcc import REBCC, NullLogger, Space + + +@pytest.mark.reference +class RDCSD_Tests(unittest.TestCase): + """Test RDCSD against reference values. + + Ref: J. Chem. Phys. 144, 124117 (2016) + """ + + @classmethod + def setUpClass(cls): + mol = gto.Mole() + mol.atom = "N 0 0 0; N 0 0 2.118" + mol.unit = "B" + mol.basis = "cc-pvdz" + mol.verbose = 0 + mol.build() + + mf = scf.RHF(mol) + mf.conv_tol = 1e-12 + mf.kernel() + + frozen = np.zeros_like(mf.mo_occ, dtype=bool) + frozen[:2] = True + space = Space(mf.mo_occ > 0, frozen, np.zeros_like(frozen)) + + dcsd = REBCC( + mf, + space=space, + ansatz="DCSD", + log=NullLogger(), + ) + dcsd.options.e_tol = 1e-10 + dcsd.kernel() + + cls.mf, cls.dcsd = mf, dcsd + + @classmethod + def tearDownClass(cls): + del cls.mf, cls.dcsd + + def test_converged(self): + self.assertTrue(self.dcsd.converged) + + def test_energy(self): + self.assertAlmostEqual(self.dcsd.e_corr, -0.327591, places=6) + + +if __name__ == "__main__": + print("Tests for RDCSD") + unittest.main() diff --git a/tests/test_UDCD.py b/tests/test_UDCD.py new file mode 100644 index 00000000..1fc33e61 --- /dev/null +++ b/tests/test_UDCD.py @@ -0,0 +1,72 @@ +"""Tests for the UDCD model. +""" + +import unittest + +import numpy as np +import pytest +from pyscf import gto, scf + +from ebcc import REBCC, UEBCC, NullLogger, Space + + +@pytest.mark.regression +class UDCD_Tests(unittest.TestCase): + """Test UDCD against RDCD. + """ + + @classmethod + def setUpClass(cls): + mol = gto.Mole() + mol.atom = "N 0 0 0; N 0 0 2.2" + mol.unit = "B" + mol.basis = "cc-pvdz" + mol.verbose = 0 + mol.build() + + mf = scf.RHF(mol) + mf.conv_tol = 1e-12 + mf.kernel() + + rdcd = REBCC( + mf, + ansatz="DCD", + log=NullLogger(), + ) + rdcd.options.e_tol = 1e-10 + rdcd.kernel() + + rdcd = UEBCC.from_rebcc(rdcd) + + udcd = UEBCC( + mf, + ansatz="DCD", + log=NullLogger(), + ) + udcd.options.e_tol = 1e-10 + udcd.kernel() + + cls.mf, cls.rdcd, cls.udcd= mf, rdcd, udcd + + @classmethod + def tearDownClass(cls): + del cls.mf, cls.rdcd, cls.udcd + + def test_converged(self): + self.assertTrue(self.rdcd.converged) + self.assertTrue(self.udcd.converged) + + def test_energy(self): + self.assertAlmostEqual(self.rdcd.e_tot, self.udcd.e_tot, places=8) + + def test_t2_amplitudes(self): + a = self.rdcd.t2 + b = self.udcd.t2 + np.testing.assert_allclose(a.aaaa, b.aaaa, atol=1e-7) + np.testing.assert_allclose(a.bbbb, b.bbbb, atol=1e-7) + np.testing.assert_allclose(a.abab, b.abab, atol=1e-7) + + +if __name__ == "__main__": + print("Tests for UDCD") + unittest.main() diff --git a/tests/test_UDCSD.py b/tests/test_UDCSD.py new file mode 100644 index 00000000..069052de --- /dev/null +++ b/tests/test_UDCSD.py @@ -0,0 +1,78 @@ +"""Tests for the UDCSD model. +""" + +import unittest + +import numpy as np +import pytest +from pyscf import gto, scf + +from ebcc import REBCC, UEBCC, NullLogger, Space + + +@pytest.mark.regression +class UDCSD_Tests(unittest.TestCase): + """Test UDCSD against RDCSD. + """ + + @classmethod + def setUpClass(cls): + mol = gto.Mole() + mol.atom = "N 0 0 0; N 0 0 2.2" + mol.unit = "B" + mol.basis = "cc-pvdz" + mol.verbose = 0 + mol.build() + + mf = scf.RHF(mol) + mf.conv_tol = 1e-12 + mf.kernel() + + rdcsd = REBCC( + mf, + ansatz="DCSD", + log=NullLogger(), + ) + rdcsd.options.e_tol = 1e-10 + rdcsd.kernel() + + rdcsd = UEBCC.from_rebcc(rdcsd) + + udcsd = UEBCC( + mf, + ansatz="DCSD", + log=NullLogger(), + ) + udcsd.options.e_tol = 1e-10 + udcsd.kernel() + + cls.mf, cls.rdcsd, cls.udcsd= mf, rdcsd, udcsd + + @classmethod + def tearDownClass(cls): + del cls.mf, cls.rdcsd, cls.udcsd + + def test_converged(self): + self.assertTrue(self.rdcsd.converged) + self.assertTrue(self.udcsd.converged) + + def test_energy(self): + self.assertAlmostEqual(self.rdcsd.e_tot, self.udcsd.e_tot, places=8) + + def test_t1_amplitudes(self): + a = self.rdcsd.t1 + b = self.udcsd.t1 + np.testing.assert_allclose(a.aa, b.aa, atol=1e-7) + np.testing.assert_allclose(a.bb, b.bb, atol=1e-7) + + def test_t2_amplitudes(self): + a = self.rdcsd.t2 + b = self.udcsd.t2 + np.testing.assert_allclose(a.aaaa, b.aaaa, atol=1e-7) + np.testing.assert_allclose(a.bbbb, b.bbbb, atol=1e-7) + np.testing.assert_allclose(a.abab, b.abab, atol=1e-7) + + +if __name__ == "__main__": + print("Tests for UDCSD") + unittest.main()