Пример #1
0
def distribute_fc3(fc3,
                   first_disp_atoms,
                   lattice,
                   positions,
                   rotations,
                   translations,
                   symprec,
                   verbose):
    num_atom = len(positions)

    for i in range(num_atom):
        if i in first_disp_atoms:
            continue

        for atom_index_done in first_disp_atoms:
            rot_num = get_atom_mapping_by_symmetry(positions,
                                                   i,
                                                   atom_index_done,
                                                   rotations,
                                                   translations,
                                                   symprec)
            if rot_num > -1:
                i_rot = atom_index_done
                rot = rotations[rot_num]
                trans = translations[rot_num]
                break

        if rot_num < 0:
            print "Position or symmetry may be wrong."
            raise ValueError

        if verbose > 2:
            print "    [ %d, x, x ] to [ %d, x, x ]" % (i_rot + 1, i + 1)
            sys.stdout.flush()

        atom_mapping = np.zeros(num_atom, dtype='intc')
        for j in range(num_atom):
            atom_mapping[j] = get_atom_by_symmetry(positions,
                                                   rot,
                                                   trans,
                                                   j,
                                                   symprec)
            
        rot_cart_inv = np.double(
            similarity_transformation(lattice, rot).T.copy())

        try:
            import anharmonic._phono3py as phono3c
            phono3c.distribute_fc3(fc3,
                                   i,
                                   atom_mapping,
                                   rot_cart_inv)
        
        except ImportError:
            for j in range(num_atom):
                j_rot = atom_mapping[j]
                for k in range(num_atom):
                    k_rot = atom_mapping[k]
                    fc3[i, j, k] = third_rank_tensor_rotation(
                        rot_cart_inv, fc3[i_rot, j_rot, k_rot])
Пример #2
0
def distribute_fc3(fc3,
                   first_disp_atoms,
                   lattice,
                   positions,
                   rotations,
                   translations,
                   symprec,
                   verbose):
    num_atom = len(positions)

    for i in range(num_atom):
        if i in first_disp_atoms:
            continue

        for atom_index_done in first_disp_atoms:
            rot_num = get_atom_mapping_by_symmetry(positions,
                                                   i,
                                                   atom_index_done,
                                                   rotations,
                                                   translations,
                                                   symprec)
            if rot_num > -1:
                i_rot = atom_index_done
                rot = rotations[rot_num]
                trans = translations[rot_num]
                break

        if rot_num < 0:
            print "Position or symmetry may be wrong."
            raise ValueError

        if verbose > 2:
            print "  [ %d, x, x ] to [ %d, x, x ]" % (i_rot + 1, i + 1)
            sys.stdout.flush()

        atom_mapping = np.zeros(num_atom, dtype='intc')
        for j in range(num_atom):
            atom_mapping[j] = get_atom_by_symmetry(positions,
                                                   rot,
                                                   trans,
                                                   j,
                                                   symprec)
        rot_cart_inv = np.double(
            similarity_transformation(lattice, rot).T.copy())

        try:
            import anharmonic._phono3py as phono3c
            phono3c.distribute_fc3(fc3,
                                   i,
                                   atom_mapping,
                                   rot_cart_inv)
        
        except ImportError:
            for j in range(num_atom):
                j_rot = atom_mapping[j]
                for k in range(num_atom):
                    k_rot = atom_mapping[k]
                    fc3[i, j, k] = third_rank_tensor_rotation(
                        rot_cart_inv, fc3[i_rot, j_rot, k_rot])
Пример #3
0
def distribute_fc3(
    fc3_least_atoms,
    first_disp_atoms,
    lattice,
    positions,
    rotations,
    translations,
    symprec,
    overwrite=True,
    verbose=False,
):
    num_atom = len(positions)
    atom_mapping = np.zeros(num_atom, dtype="intc")

    if overwrite:
        fc3 = fc3_least_atoms
    else:
        fc3 = np.zeros((num_atom, num_atom, num_atom, 3, 3, 3), dtype="double")

    for i in range(num_atom):
        # if i in first_disp_atoms:
        #     continue

        for atom_index_done in first_disp_atoms:
            rot_num = get_atom_mapping_by_symmetry(positions, i, atom_index_done, rotations, translations, symprec)
            if rot_num > -1:
                i_rot = atom_index_done
                rot = rotations[rot_num]
                trans = translations[rot_num]
                break

        if rot_num < 0:
            print "Position or symmetry may be wrong."
            raise ValueError

        for j in range(num_atom):
            atom_mapping[j] = get_atom_by_symmetry(positions, rot, trans, j, symprec)

        rot_cart_inv = np.array(similarity_transformation(lattice, rot).T, dtype="double", order="C")

        if not (overwrite and i == i_rot):
            if verbose > 2:
                print "    [ %d, x, x ] to [ %d, x, x ]" % (i_rot + 1, i + 1)
                sys.stdout.flush()

            try:
                import anharmonic._phono3py as phono3c

                phono3c.distribute_fc3(fc3, fc3_least_atoms, i, atom_mapping, rot_cart_inv)

            except ImportError:
                for j in range(num_atom):
                    j_rot = atom_mapping[j]
                    for k in range(num_atom):
                        k_rot = atom_mapping[k]
                        fc3[i, j, k] = third_rank_tensor_rotation(rot_cart_inv, fc3_least_atoms[i_rot, j_rot, k_rot])

    if not overwrite:
        return fc3
Пример #4
0
def distribute_fc3(fc3_least_atoms,
                   first_disp_atoms,
                   lattice,
                   positions,
                   rotations,
                   translations,
                   symprec,
                   overwrite=True,
                   verbose=False):
    num_atom = len(positions)
    atom_mapping = np.zeros(num_atom, dtype='intc')

    if overwrite:
        fc3 = fc3_least_atoms
    else:
        fc3 = np.zeros((num_atom, num_atom, num_atom, 3, 3, 3), dtype='double')

    for i in range(num_atom):
        # if i in first_disp_atoms:
        #     continue

        for atom_index_done in first_disp_atoms:
            rot_num = get_atom_mapping_by_symmetry(positions, i,
                                                   atom_index_done, rotations,
                                                   translations, symprec)
            if rot_num > -1:
                i_rot = atom_index_done
                rot = rotations[rot_num]
                trans = translations[rot_num]
                break

        if rot_num < 0:
            print "Position or symmetry may be wrong."
            raise ValueError

        for j in range(num_atom):
            atom_mapping[j] = get_atom_by_symmetry(positions, rot, trans, j,
                                                   symprec)

        rot_cart_inv = np.array(similarity_transformation(lattice, rot).T,
                                dtype='double',
                                order='C')

        if not (overwrite and i == i_rot):
            if verbose > 2:
                print "    [ %d, x, x ] to [ %d, x, x ]" % (i_rot + 1, i + 1)
                sys.stdout.flush()

            try:
                import anharmonic._phono3py as phono3c
                phono3c.distribute_fc3(fc3, fc3_least_atoms, i, atom_mapping,
                                       rot_cart_inv)

            except ImportError:
                for j in range(num_atom):
                    j_rot = atom_mapping[j]
                    for k in range(num_atom):
                        k_rot = atom_mapping[k]
                        fc3[i, j, k] = third_rank_tensor_rotation(
                            rot_cart_inv, fc3_least_atoms[i_rot, j_rot, k_rot])

    if not overwrite:
        return fc3