def __set_cell_oriented( self ): # Re-oriented lattice xx, yx, yy, zx, zy, zz self.angles = get_angles( self.lattice ) self.cell_params = get_cell_parameters( self.lattice ) a, b, c = self.cell_params alpha, beta, gamma = self.angles self.lattice_oriented = get_cell_matrix( a, b, c, alpha, beta, gamma ) self.positions_oriented = \ self.__set_orientation( np.dot( self.positions, self.lattice ) )
def _set_cell_oriented(self): # Re-oriented lattice xx, yx, yy, zx, zy, zz self._angles = get_angles(self._lattice) self._cell_params = get_cell_parameters(self._lattice) a, b, c = self._cell_params alpha, beta, gamma = self._angles self._lattice_oriented = get_cell_matrix(a, b, c, alpha, beta, gamma) self._positions_oriented = \ self._get_oriented_displacements(np.dot(self._positions, self._lattice))
def read_fplo(filename): from phonopy.structure.cells import get_cell_matrix fplo_in = open(filename).readlines() nsort = None for i in np.arange(len(fplo_in)): # spacegroup if fplo_in[i].find("spacegroup") + 1: curl_pos = fplo_in[i + 1].find("{") + 1 spg = int(fplo_in[i + 1][curl_pos:].split(",") [0]) # integer number of the spacegroup if spg != 1: sys.exit("(EE) Only SPG 1 / P1 implemented so far.") # unit of length if fplo_in[i].find("lengthunit") + 1: curl_pos = fplo_in[i + 1].find("{") + 1 if int(fplo_in[i + 1][curl_pos:].split(",")[0]) == 1: lfactor = 1.0 # bohr elif int(fplo_in[i + 1][curl_pos:].split(",")[0]) == 2: lfactor = 1.0 / Bohr # Angstroem else: sys.exit("(EE) Length unit unknown: " + fplo_in[i + 1]) # lattice constants if fplo_in[i].find("lattice_constants") + 1: curl_pos = fplo_in[i].find("{") + 1 a, b, c = map(float, fplo_in[i][curl_pos:].split(",")) # lattice angles if fplo_in[i].find("axis_angles") + 1: curl_pos = fplo_in[i].find("{") + 1 alpha, beta, gamma = map(float, fplo_in[i][curl_pos:].split(",")) # number of Wyckoff positions if fplo_in[i].find("nsort=") + 1: nsort = int(fplo_in[i][:-2].split("=")[1]) # Wyckoff positions if fplo_in[i].find("wyckoff_positions") + 1: if nsort == None: sys.exit("(EE) nsort not found!") species = np.zeros((nsort), dtype=int) positions = np.zeros((nsort, 3), dtype=float) for j in np.arange(nsort): ind = i + j + 2 indc = fplo_in[ind].find(",") indb = fplo_in[ind].find("}") species[j] = symbol_map[fplo_in[ind][indc - 3:indc - 1]] positions[j, :] = list( map(float, fplo_in[ind][indc + 2:indb].split(","))) lattice = get_cell_matrix(a * lfactor, b * lfactor, c * lfactor, alpha, beta, gamma) cell = Atoms(numbers=species, cell=lattice, scaled_positions=positions) return cell, False