Esempio n. 1
0
def get_cif_P1(cell, U_cif=None):
    a, b, c = get_cell_parameters(cell.get_cell())
    alpha, beta, gamma = get_angles(cell.get_cell())

    cif = """data_crystal_structure_P1

_symmetry_space_group_name_H-M     'P 1'
_symmetry_Int_Tables_number        1

_cell_length_a                     %.5f
_cell_length_b                     %.5f
_cell_length_c                     %.5f
_cell_angle_alpha                  %.5f
_cell_angle_beta                   %.5f
_cell_angle_gamma                  %.5f
_cell_volume                       %.5f
_cell_formula_units_Z              1

loop_
_space_group_symop_operation_xyz
x,y,z

loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy\n""" % (a, b, c, alpha, beta, gamma, cell.get_volume())

    symbols = []
    for s, p in zip(cell.get_chemical_symbols(), cell.get_scaled_positions()):
        symbols.append(s)
        cif += ("%-7s%2s %10.5f%10.5f%10.5f   1.00000\n" %
                (s + "%d" % symbols.count(s), s, p[0], p[1], p[2]))

    if U_cif is not None:

        aniso_U = """loop_
_atom_site_aniso_label
_atom_site_aniso_U_11
_atom_site_aniso_U_22
_atom_site_aniso_U_33
_atom_site_aniso_U_23
_atom_site_aniso_U_13
_atom_site_aniso_U_12\n"""

        cif += aniso_U
    
        symbols = []
        for i, s in enumerate(cell.get_chemical_symbols()):
            symbols.append(s)
            m = U_cif[i]
            vals = (m[0, 0], m[1, 1], m[2, 2], m[1, 2], m[0, 2], m[0, 1])
            cif += ("%6s %10.5f %10.5f %10.5f %10.5f %10.5f %10.5f\n" %
                    ((s + "%d" % symbols.count(s),) + vals))

    return cif
Esempio n. 2
0
 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 ) )
Esempio n. 3
0
 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))
Esempio n. 4
0
 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))
Esempio n. 5
0
def get_wien2k_struct(cell, npts, r0s, rmts):

    num_atom = cell.get_number_of_atoms()
    lattice = cell.get_cell()
    a, b, c = get_cell_parameters(lattice)
    alpha, beta, gamma = get_angles(lattice)
    positions = cell.get_scaled_positions()
    symbols = cell.get_chemical_symbols()
    numbers = cell.get_atomic_numbers()

    text = ""

    # 1
    text += "Title\n"

    # 2
    text += "%-4s%23s%3d\n" % ("P", "LATTICE,NONEQUIV.ATOMS:", num_atom)

    # 3
    text += "%13s%4s\n" % ("MODE OF CALC=", "RELA")

    # 4
    text += "%10.6f%10.6f%10.6f%10.6f%10.6f%10.6f\n" % (a, b, c, alpha, beta,
                                                        gamma)

    for i, pos in enumerate(positions):

        for j in (0, 1, 2):
            if pos[j] < 0:
                pos[j] += 1
            if int(float("%10.8f" % pos[j])) == 1:
                pos[j] = 0.0

        # 5 format (4X,I4,4X,F10.8,3X,F10.8,3X,F10.8)
        text += "%4s%4d%4s%10.8f%3s%10.8f%3s%10.8f\n" % (
            "ATOM", -(i + 1), ": X=", pos[0], " Y=", pos[1], " Z=", pos[2])

        # 6  format (15X,I2,17X,I2)
        text += "%15s%2d%17s%2d\n" % ("MULT=", 1, "ISPLIT=", 8)

        # 7 format (A10,5X,I5,5X,F10.8,5X,F10.5,5X,F5.2)
        npt = npts[i]
        r0 = r0s[i]
        rmt = rmts[i]
        text += "%-10s%5s%5d%5s%10.8f%5s%10.5f%5s%5.1f\n" % (
            symbols[i], "NPT=", npt, "R0=", r0, "RMT=", rmt, "Z:", numbers[i])

        # 8 - 10 format (20X,3F10.7)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("LOCAL ROT MATRIX:", 1, 0, 0)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("", 0, 1, 0)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("", 0, 0, 1)

    text += "   0      NUMBER OF SYMMETRY OPERATIONS"

    return text
Esempio n. 6
0
def get_wien2k_struct(cell, npts, r0s, rmts):

    num_atom = cell.get_number_of_atoms()
    lattice = cell.get_cell()
    a, b, c = get_cell_parameters(lattice)
    alpha, beta, gamma = get_angles(lattice)
    positions = cell.get_scaled_positions()
    symbols = cell.get_chemical_symbols()
    numbers = cell.get_atomic_numbers()

    text = ""

    # 1
    text += "Title\n"
    
    # 2
    text += "%-4s%23s%3d\n" % ("P", "LATTICE,NONEQUIV.ATOMS:", num_atom)
    
    # 3
    text += "%13s%4s\n" % ("MODE OF CALC=", "RELA")
    
    # 4
    text += "%10.6f%10.6f%10.6f%10.6f%10.6f%10.6f\n" % (
        a, b, c, alpha, beta, gamma)
    
    for i, pos in enumerate(positions):

        for j in (0,1,2):
            if pos[j] < 0:
                pos[j] += 1
            if int(float("%10.8f" % pos[j])) == 1:
                pos[j] = 0.0

        # 5 format (4X,I4,4X,F10.8,3X,F10.8,3X,F10.8)
        text += "%4s%4d%4s%10.8f%3s%10.8f%3s%10.8f\n" % (
            "ATOM", -(i + 1), ": X=", pos[0], " Y=", pos[1], " Z=", pos[2])
    
        # 6  format (15X,I2,17X,I2)
        text += "%15s%2d%17s%2d\n" % ("MULT=", 1, "ISPLIT=", 8)
    
        # 7 format (A10,5X,I5,5X,F10.8,5X,F10.5,5X,F5.2)
        npt = npts[i]
        r0 = r0s[i]
        rmt = rmts[i]
        text += "%-10s%5s%5d%5s%10.8f%5s%10.5f%5s%5.1f\n" % (
            symbols[i], "NPT=", npt, "R0=", r0, "RMT=", rmt, "Z:", numbers[i])
    
        # 8 - 10 format (20X,3F10.7)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("LOCAL ROT MATRIX:", 1, 0, 0)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("", 0, 1, 0)
        text += "%-20s%10.7f%10.7f%10.7f\n" % ("", 0, 0, 1)

    text +="   0      NUMBER OF SYMMETRY OPERATIONS"

    return text
Esempio n. 7
0
def write_fplo(directory, cell, sym=None):
    from phonopy.structure.cells import get_angles, get_cell_parameters

    FEDIT = 'fedit14.00-47-x86_64'
    FPLO = 'fplo14.00-47-x86_64'

    import os

    lattice = cell.get_cell()
    positions = cell.get_scaled_positions()
    chemical_symbols = cell.get_chemical_symbols()

    alpha, beta, gamma = get_angles(lattice)
    a, b, c = get_cell_parameters(lattice)

    os.mkdir(directory)
    os.system('cp =.in ' + directory + '/')
    os.chdir(directory)

    # Write the structure plan to the pipe file.
    fpipe = open("=.t_pipe", "w")
    fpipe.write("@+@\n")

    # add spacegroup
    if sym != None:
        fpipe.write("@s@\n")
        fpipe.write("@{0:d}@\n".format(sym["spg"]))
        fpipe.write("@x@\n")

    # change lattice units to bohr
    fpipe.write("@u@\n")
    fpipe.write("@b@\n")
    fpipe.write("@x@\n")

    fpipe.write("@l@ {0:+10.6f} {1:+10.6f} {2:+10.6f}\n".format(a, b, c))
    fpipe.write("@a@ {0:+8.4f} {1:+8.4f} {2:+8.4f}\n".format(
        alpha, beta, gamma))
    fpipe.write("@n@ {0:d}\n".format(len(positions)))
    for i in np.arange(len(positions)):
        fpipe.write("@{0:d}@ {1} @ {2:16.8f} {3:16.8f} {4:16.8f}\n".format(
            i + 1, chemical_symbols[i], positions[i, 0], positions[i, 1],
            positions[i, 2]))
    fpipe.write("@+@\n")
    fpipe.write("@x@\n")
    fpipe.write("@q@\n")
    fpipe.write("@y@")
    fpipe.close()

    # Execute fedit with the pip file.
    os.system(FEDIT + ' -p ' + FPLO +
              ' -pipe < ./=.t_pipe 2>./+log 1>/dev/null')

    # Clean up.
    os.remove("=.t_pipe")
    os.chdir("../")
Esempio n. 8
0
def get_cif_P1(cell, U_cif=None):
    a, b, c = get_cell_parameters(cell.get_cell())
    alpha, beta, gamma = get_angles(cell.get_cell())

    cif = """data_crystal_structure_P1

_symmetry_space_group_name_H-M     'P 1'
_symmetry_Int_Tables_number        1

_cell_length_a                     %.5f
_cell_length_b                     %.5f
_cell_length_c                     %.5f
_cell_angle_alpha                  %.5f
_cell_angle_beta                   %.5f
_cell_angle_gamma                  %.5f
_cell_volume                       %.5f
_cell_formula_units_Z              1

loop_
_space_group_symop_operation_xyz
x,y,z

loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy\n""" % (
        a,
        b,
        c,
        alpha,
        beta,
        gamma,
        cell.get_volume(),
    )

    symbols = []
    for s, p in zip(cell.get_chemical_symbols(), cell.get_scaled_positions()):
        symbols.append(s)
        cif += "%-7s%2s %10.5f%10.5f%10.5f   1.00000\n" % (s + "%d" % symbols.count(s), s, p[0], p[1], p[2])

    if U_cif is not None:

        aniso_U = """loop_
_atom_site_aniso_label
_atom_site_aniso_U_11
_atom_site_aniso_U_22
_atom_site_aniso_U_33
_atom_site_aniso_U_23
_atom_site_aniso_U_13
_atom_site_aniso_U_12\n"""

        cif += aniso_U

        symbols = []
        for i, s in enumerate(cell.get_chemical_symbols()):
            symbols.append(s)
            m = U_cif[i]
            vals = (m[0, 0], m[1, 1], m[2, 2], m[1, 2], m[0, 2], m[0, 1])
            cif += "%6s %10.5f %10.5f %10.5f %10.5f %10.5f %10.5f\n" % ((s + "%d" % symbols.count(s),) + vals)

    return cif