def solve_fc3(fc3, first_atom_num, supercell, site_symmetry, displacements_first, delta_fc2s, symprec, pinv="numpy"): lattice = supercell.get_cell().T site_sym_cart = [similarity_transformation(lattice, sym) for sym in site_symmetry] num_atom = supercell.get_number_of_atoms() positions = supercell.get_scaled_positions() pos_center = positions[first_atom_num].copy() positions -= pos_center rot_map_syms = get_positions_sent_by_rot_inv(positions, site_symmetry, symprec) rot_disps = get_rotated_displacement(displacements_first, site_sym_cart) if pinv == "numpy": inv_U = np.linalg.pinv(rot_disps) else: try: import anharmonic._phono3py as phono3c inv_U = np.zeros((rot_disps.shape[1], rot_disps.shape[0]), dtype='double') phono3c.pinv(inv_U, rot_disps, 1e-13) except ImportError: inv_U = np.linalg.pinv(rot_disps) for (i, j) in list(np.ndindex(num_atom, num_atom)): fc3[first_atom_num, i, j] = np.dot(inv_U, _get_rotated_fc2s( i, j, delta_fc2s, rot_map_syms, site_sym_cart)).reshape(3, 3, 3)
def solve_fc3(fc3, first_atom_num, supercell, site_symmetry, displacements_first, delta_fc2s, symprec, pinv="numpy", verbose=False): if verbose: print "Solving fc3[ %d, x, x ] with" % (first_atom_num + 1), if len(displacements_first) > 1: print "displacements:" else: print "a displacement:" for i, v in enumerate(displacements_first): print " [%7.4f %7.4f %7.4f]" % tuple(v) sys.stdout.flush() if verbose > 2: print " Site symmetry:" for i, v in enumerate(site_symmetry): print " [%2d %2d %2d] #%2d" % tuple(list(v[0]) + [i + 1]) print " [%2d %2d %2d]" % tuple(v[1]) print " [%2d %2d %2d]\n" % tuple(v[2]) sys.stdout.flush() lattice = supercell.get_cell().T site_sym_cart = [ similarity_transformation(lattice, sym) for sym in site_symmetry ] num_atom = supercell.get_number_of_atoms() positions = supercell.get_scaled_positions() pos_center = positions[first_atom_num].copy() positions -= pos_center rot_map_syms = get_positions_sent_by_rot_inv(positions, site_symmetry, symprec) rot_disps = get_rotated_displacement(displacements_first, site_sym_cart) if pinv == "numpy": inv_U = np.linalg.pinv(rot_disps) else: try: import anharmonic._phono3py as phono3c inv_U = np.zeros((rot_disps.shape[1], rot_disps.shape[0]), dtype='double') phono3c.pinv(inv_U, rot_disps, 1e-13) except ImportError: inv_U = np.linalg.pinv(rot_disps) for (i, j) in list(np.ndindex(num_atom, num_atom)): fc3[first_atom_num, i, j] = np.dot( inv_U, _get_rotated_fc2s(i, j, delta_fc2s, rot_map_syms, site_sym_cart)).reshape(3, 3, 3)
def solve_fc3( fc3, first_atom_num, supercell, site_symmetry, displacements_first, delta_fc2s, symprec, pinv="numpy", verbose=False ): if verbose: print "Solving fc3[ %d, x, x ] with" % (first_atom_num + 1), if len(displacements_first) > 1: print "displacements:" else: print "a displacement:" for i, v in enumerate(displacements_first): print " [%7.4f %7.4f %7.4f]" % tuple(v) sys.stdout.flush() if verbose > 2: print " Site symmetry:" for i, v in enumerate(site_symmetry): print " [%2d %2d %2d] #%2d" % tuple(list(v[0]) + [i + 1]) print " [%2d %2d %2d]" % tuple(v[1]) print " [%2d %2d %2d]\n" % tuple(v[2]) sys.stdout.flush() lattice = supercell.get_cell().T site_sym_cart = [similarity_transformation(lattice, sym) for sym in site_symmetry] num_atom = supercell.get_number_of_atoms() positions = supercell.get_scaled_positions() pos_center = positions[first_atom_num].copy() positions -= pos_center rot_map_syms = get_positions_sent_by_rot_inv(positions, site_symmetry, symprec) rot_disps = get_rotated_displacement(displacements_first, site_sym_cart) if pinv == "numpy": inv_U = np.linalg.pinv(rot_disps) else: try: import anharmonic._phono3py as phono3c inv_U = np.zeros((rot_disps.shape[1], rot_disps.shape[0]), dtype="double") phono3c.pinv(inv_U, rot_disps, 1e-13) except ImportError: inv_U = np.linalg.pinv(rot_disps) for (i, j) in list(np.ndindex(num_atom, num_atom)): fc3[first_atom_num, i, j] = np.dot( inv_U, _get_rotated_fc2s(i, j, delta_fc2s, rot_map_syms, site_sym_cart) ).reshape(3, 3, 3)
def solve_fc3(fc3, first_atom_num, supercell, site_symmetry, displacements_first, delta_fc2s, symprec, pinv="numpy"): lattice = supercell.get_cell().T site_sym_cart = [ similarity_transformation(lattice, sym) for sym in site_symmetry ] num_atom = supercell.get_number_of_atoms() positions = supercell.get_scaled_positions() pos_center = positions[first_atom_num].copy() positions -= pos_center rot_map_syms = get_positions_sent_by_rot_inv(positions, site_symmetry, symprec) rot_disps = get_rotated_displacement(displacements_first, site_sym_cart) if pinv == "numpy": inv_U = np.linalg.pinv(rot_disps) else: try: import anharmonic._phono3py as phono3c inv_U = np.zeros((rot_disps.shape[1], rot_disps.shape[0]), dtype='double') phono3c.pinv(inv_U, rot_disps, 1e-13) except ImportError: inv_U = np.linalg.pinv(rot_disps) for (i, j) in list(np.ndindex(num_atom, num_atom)): fc3[first_atom_num, i, j] = np.dot( inv_U, _get_rotated_fc2s(i, j, delta_fc2s, rot_map_syms, site_sym_cart)).reshape(3, 3, 3)