示例#1
0
def des_des_linkstr(strs, norb, nelec):
    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1 << i)]
        for i1, i in enumerate(occ):
            for j in occ[:i1]:
                inter.append(str0 ^ (1 << i) ^ (1 << j))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 2
    link_index = numpy.zeros((len(inter), nvir * nvir, 4), dtype=int)
    link_index[:, :, 0] = -1
    for i1, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1 << i)]
        k = 0
        for i in vir:
            for j in vir:
                str0 = str1 | (1 << i) | (1 << j)
                if i != j and str0 in addrs:
                    # from intermediate str1, create i, create j -> str0
                    # (str1 = des_i des_j str0)
                    # [cre_j, cre_i, targetddress, parity]
                    sign = cistring.cre_sign(i, str1)
                    sign *= cistring.cre_sign(j, str1 | (1 << i))
                    link_index[i1, k] = (i, j, addrs[str0], sign)
                    k += 1
    return link_index
示例#2
0
def des_des_linkstr(strs, norb, nelec):
    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1 << i)]
        for i1, i in enumerate(occ):
            for j in occ[:i1]:
                inter.append(str0 ^ (1 << i) ^ (1 << j))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 2
    link_index = numpy.zeros((len(inter), nvir * nvir, 4), dtype=int)
    link_index[:, :, 0] = -1
    for i1, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1 << i)]
        k = 0
        for i in vir:
            for j in vir:
                str0 = str1 | (1 << i) | (1 << j)
                if i != j and str0 in addrs:
                    # from intermediate str1, create i, create j -> str0
                    # (str1 = des_i des_j str0)
                    # [cre_j, cre_i, targetddress, parity]
                    sign = cistring.cre_sign(i, str1)
                    sign *= cistring.cre_sign(j, str1 | (1 << i))
                    link_index[i1, k] = (i, j, addrs[str0], sign)
                    k += 1
    return link_index
示例#3
0
def des_des_linkstr_tril(strs, norb, nelec):
    '''Given intermediates, the link table to generate input strs
    '''
    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1 << i)]
        for i1, i in enumerate(occ):
            for j in occ[:i1]:
                inter.append(str0 ^ (1 << i) ^ (1 << j))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 2
    link_index = numpy.zeros((len(inter), nvir * nvir, 4), dtype=numpy.int32)
    for i0, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1 << i)]
        k = 0
        for i1, i in enumerate(vir):
            for j in vir[:i1]:
                str0 = str1 | (1 << i) | (1 << j)
                if str0 in addrs:
                    # from intermediate str1(i0), create i, create j -> str0
                    # (str1 = des_i des_j str0)
                    # [cre_j, cre_i, targetddress, parity]
                    sign = cistring.cre_sign(i, str1)
                    sign *= cistring.cre_sign(j, str1 | (1 << i))
                    link_index[i0, k] = (i * (i - 1) // 2 + j, 0, addrs[str0],
                                         sign)
                    k += 1
    return link_index
示例#4
0
def des_des_linkstr_tril(strs, norb, nelec):
    '''Given intermediates, the link table to generate input strs
    '''
    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1<<i)]
        for i1, i in enumerate(occ):
            for j in occ[:i1]:
                inter.append(str0 ^ (1<<i) ^ (1<<j))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 2
    link_index = numpy.zeros((len(inter),nvir*nvir,4), dtype=numpy.int32)
    for i0, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1<<i)]
        k = 0
        for i1, i in enumerate(vir):
            for j in vir[:i1]:
                str0 = str1 | (1<<i) | (1<<j)
                if str0 in addrs:
                    # from intermediate str1(i0), create i, create j -> str0
                    # (str1 = des_i des_j str0)
                    # [cre_j, cre_i, targetddress, parity]
                    sign = cistring.cre_sign(i, str1)
                    sign*= cistring.cre_sign(j, str1|(1<<i))
                    link_index[i0,k] = (i*(i-1)//2+j, 0, addrs[str0], sign)
                    k += 1
    return link_index
示例#5
0
def gen_des_linkstr(strs, norb, nelec):
    '''Given intermediates, the link table to generate input strs
    '''
    if nelec < 1:
        return None

    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1 << i)]
        for i in occ:
            inter.append(str0 ^ (1 << i))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 1
    link_index = numpy.zeros((len(inter), nvir, 4), dtype=numpy.int32)
    for i1, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1 << i)]
        k = 0
        for i in vir:
            str0 = str1 | (1 << i)
            if str0 in addrs:
                sign = cistring.cre_sign(i, str1)
                link_index[i1, k] = (0, i, addrs[str0], sign)
                k += 1
    return link_index
示例#6
0
def gen_des_linkstr(strs, norb, nelec):
    '''Given intermediates, the link table to generate input strs
    '''
    if nelec < 1:
        return None

    inter = []
    for str0 in strs:
        occ = [i for i in range(norb) if str0 & (1<<i)]
        for i in occ:
            inter.append(str0 ^ (1<<i))
    inter = sorted(set(inter))
    addrs = dict(zip(strs, range(len(strs))))

    nvir = norb - nelec + 1
    link_index = numpy.zeros((len(inter),nvir,4), dtype=numpy.int32)
    for i1, str1 in enumerate(inter):
        vir = [i for i in range(norb) if not str1 & (1<<i)]
        k = 0
        for i in vir:
            str0 = str1 | (1<<i)
            if str0 in addrs:
                sign = cistring.cre_sign(i, str1)
                link_index[i1,k] = (0, i, addrs[str0], sign)
                k += 1
    return link_index