Skip to content

Syntax and capability enhancments #14

@dgasmith

Description

@dgasmith

The DF-MP2 example as per our discussion.

# Initialize base objects
iaQ = DiskTensor("iaQ DF Tensor", oshape, vshape, Qshape)
eps_o = CoreTensor("Occupied eigenvalues", oshape)
eps_v = CoreTensor("Virtual eigenvalues", vshape)

# Initialize temps
Qv_1 = CoreTensor("Qv_1", Qshape, vshape)
Qv_2 = CoreTensor("Qv_2", Qshape, vshape)

vv_numer_1 = CoreTensor("vv_numer_1", vshape, vshape)
vv_numer_2 = CoreTensor("vv_numer_2", vshape, vshape)

denom = CoreTensor("vv_denom", vshape, vshape)
vv_denom = CoreTensor("vv_denom", vshape, vshape)
vv_denom["i,j"] = - eps_v["i"] - eps_v["j"]

for i in range(ndocc):

    Qv_1[“ab"] = READ(iaQ, {j, "a", "b"})
    for j in range(ndocc):
        Qv_2["ab"] = READ(iaQ, {j, "a", “b"})

        # Form integrals
        vv_numer_1["ab"] = Qv_1["aQ"] * Qv_2["bQ"]

        # Form denominator
        denom["ab"] = vv_denom["ab"]
        denom["ab"] += (eps_o[i] + eps_o[j])

        # OS correlation
        vv_numer_2["ab"] = vv_numer_1["ab"]
        vv_numer_2["ab"] *= vv_numer_1["ab"]

        MP2corr_OS += vv_numer_2["ab"] / denom["ab"]

        # SS correlation
        vv_numer_2["ab"] = vv_numer_1["ab"]
        vv_numer_2["ab"] -= vv_numer_1["ba"]
        vv_numer_2["ab"] *= vv_numer_1["ab"]

        MP2corr_SS += vv_numer_2["ab"] / denom["ab"]

Features needed

  • Slicing syntax for read/writing from/to Core/Disk tensors. As a note if we do like the READ syntax it can be done in C++ through the use of std::tuples instead of std::vector.
  • Element-wise arithmetic -, +, /, *
  • Broadcasting. At its simplest form this is the ability to add a single number to a tensor.
  • Reduce (sum) operations. It would be nice if we could do reduce(vv_numer_2["ab"] / denom["ab"]) that would not require a second tensor to hold the product of the divisor. Some describe this as lazy evaluation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions