示例#1
0
def symmetrize_rank3(indexedexp, symmetry, dimension):
    symmetry_, symmetry = symmetry, []
    for sym in symmetry_.split('_'):
        index = 3 if sym[:3] == 'sym' else 4
        if len(sym[index:]) == 3:
            prefix = sym[:index]
            symmetry.append(prefix + sym[index:(index + 2)])
            symmetry.append(prefix + sym[(index + 1):(index + 3)])
        else:
            symmetry.append(sym)
    for sym in (symmetry[k] for n in range(len(symmetry), 0, -1)
                for k in range(n)):
        sign = 1 if sym[:3] == 'sym' else -1
        for i, j, k in func.product(range(dimension), repeat=3):
            if sym[-2:] == '01':
                if j < i: indexedexp[i][j][k] = sign * indexedexp[j][i][k]
                elif i == j and sign < 0: indexedexp[i][j][k] = 0
            elif sym[-2:] == '02':
                if k < i: indexedexp[i][j][k] = sign * indexedexp[k][j][i]
                elif i == k and sign < 0: indexedexp[i][j][k] = 0
            elif sym[-2:] == '12':
                if k < j: indexedexp[i][j][k] = sign * indexedexp[i][k][j]
                elif j == k and sign < 0: indexedexp[i][j][k] = 0
            elif sym == 'nosym': pass
            else:
                raise Exception('unsupported symmetry option \'' + sym + '\'')
    return indexedexp
示例#2
0
def symmetrize_rank2(indexedexp, symmetry, dimension):
    for sym in symmetry.split('_'):
        sign = 1 if sym[:3] == 'sym' else -1
        for i, j in func.product(range(dimension), repeat=2):
            if sym[-2:] == '01':
                if j < i: indexedexp[i][j] = sign*indexedexp[j][i]
                elif i == j and sign < 0: indexedexp[i][j] = 0
            elif sym == 'nosym': pass
            else: raise Exception('unsupported symmetry option \'' + sym + '\'')
    return indexedexp