Пример #1
0
    def _set_stage1(self, cell):
        prim_cell = get_primitive_cell(cell, tolerance=self._symmetry_tolerance)
        sym_dataset = get_symmetry_dataset(prim_cell)
        self._space_group_type = sym_dataset['international']
        spg_number = sym_dataset['number']
        if (spg_number >= 143 and
            spg_number <= 194 and
            not self._space_group_type[0] == 'R'): # Hexagonal lattice
            self._supercell_dimensions = [[3, 3, 2], [2, 2, 2]]
        else: # Other cases
            self._supercell_dimensions = [[2, 2, 2]]

        # Long cell axis is not multiplied.
        for dimension in self._supercell_dimensions:
            for i, length in enumerate(
                get_lattice_parameters(prim_cell.get_lattice())):
                if length * dimension[i] > 20:
                    dimension[i] = 1

        self._tasks = []
        for i, dimension in enumerate(self._supercell_dimensions):
            task = self._get_phonon_task(prim_cell,
                                         np.diag(dimension),
                                         "phonon-%d" % (i + 1))
            self._phre_tasks.append(task)
            self._tasks.append(task)
Пример #2
0
def estimate_supercell_matrix(cell,
                              max_num_atoms=120,
                              symprec=1e-5):
    """Estimate supercell matrix from conventional cell

    Supercell matrix is estimated from basis vector lengths and
    maximum number of atoms accepted. The input cell must be already
    standarized. For triclinic, monoclinic, and orthorhombic cells,
    basis vectors of a, b, c are freely multiplied, but for tetragonal
    and hexagonal cells, multiplicities of a and b are the same, and
    for cubic cell, those of a, b, c are to be found the same.  The
    supercell matrix is always returned as a diagonal matrix.

    """

    dataset = get_symmetry_dataset(cell)
    spg_num = dataset['number']
    num_atoms = len(cell.get_numbers())
    lengths_orig = get_lattice_parameters(cell.get_lattice())
    lengths = get_lattice_parameters(dataset['std_lattice'])

    # assert (np.abs(lengths_orig - lengths) < symprec).all(), \
    #     "%s\n%s" % (cell.get_lattice(), dataset['std_lattice'])

    if spg_num <= 74: # Triclinic, monoclinic, and orthorhombic
        multi = _get_multiplicity_abc(num_atoms, lengths, max_num_atoms)
    elif spg_num <= 194: # Tetragonal and hexagonal
        multi = _get_multiplicity_ac(num_atoms, lengths, max_num_atoms)
    else: # Cubic
        multi = _get_multiplicity_a(num_atoms, lengths, max_num_atoms)

    smat = np.eye(3, dtype='intc')
    for i in range(3):
        smat[i, i] = multi[i]

    return smat
Пример #3
0
def _get_points_with_margin(cell, margin=1e-5):
    abc = get_lattice_parameters(cell.get_lattice())
    points = cell.get_points()
    points_new = []
    symbols_new = []
    for p, s in zip(points.T, cell.get_symbols()):
        for i in (-1, 0, 1):
            for j in (-1, 0, 1):
                for k in (-1, 0, 1):
                    p_inspect = p + np.array([i, j, k])
                    if ((p_inspect > 0 - margin / abc).all() and
                        (p_inspect < 1 + margin / abc).all()):
                        points_new.append(p_inspect)
                        symbols_new.append(s)
    return np.transpose(points_new), symbols_new
Пример #4
0
def write_cif_P1(cell, filename=None):
    a, b, c = get_lattice_parameters(cell.lattice)
    alpha, beta, gamma = get_angles(cell.lattice)

    cif = """data_cogue_crystal_converter

_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_symbols(), cell.get_points().T):
        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 filename is None:
        return cif
    else:
        w = open(filename, 'w')
        w.write(cif)
        w.close()
Пример #5
0
    phonons = []
    for dirname in ('gruneisen-01', 'gruneisen-02', 'gruneisen-00'):
        if len(sys.argv) > 1:
            cell = phonopyYaml("%s/" % dirname + sys.argv[1]).get_atoms()
        else:
            cell = phonopyYaml("%s/POSCAR-unitcell.yaml" % dirname).get_atoms()
        phonon_info = yaml.load(open("%s/phonon.yaml" % dirname))
        phonon = Phonopy(cell,
                         phonon_info['supercell_matrix'],
                         is_auto_displacements=False)
        force_sets = parse_FORCE_SETS(filename="%s/FORCE_SETS" % dirname)
        phonon.set_displacement_dataset(force_sets)
        phonon.produce_force_constants()
        phonons.append(phonon)

    phonopy_gruneisen = PhonopyGruneisen(phonons[0], phonons[1], phonons[2])
    distance = 200
    gruneisen = ModeGruneisen(phonopy_gruneisen,
                              distance=distance)
    if gruneisen.run():
        gruneisen.plot(plt)
        lattice = gruneisen.get_lattice()
        print "a, b, c =", get_lattice_parameters(lattice)
        print "alpha, beta, gamma =", get_angles(lattice)
        print "mesh (x=%f) =" % distance, gruneisen.get_mesh()
        gruneisen.save_figure(plt)
        # plt.show()
    else:
        print "Mode Gruneisen parameter calculation failed."
Пример #6
0

if __name__ == "__main__":
    import sys
    import yaml
    from phonopy import Phonopy
    from phonopy.interface.phonopy_yaml import phonopyYaml
    from phonopy.file_IO import parse_FORCE_SETS
    from cogue.crystal.utility import get_angles, get_lattice_parameters
    import matplotlib

    if len(sys.argv) > 1:
        cell = phonopyYaml(sys.argv[1]).get_atoms()
    else:
        cell = phonopyYaml("POSCAR-unitcell.yaml").get_atoms()
    phonon_info = yaml.load(open("phonon.yaml"))
    phonon = Phonopy(cell, phonon_info["supercell_matrix"], is_auto_displacements=False)
    force_sets = parse_FORCE_SETS()
    phonon.set_displacement_dataset(force_sets)
    phonon.produce_force_constants()

    distance = 200
    imaginary = Imaginary(phonon, distance=distance)

    lattice = imaginary.get_lattice()
    print "lattice_lengths: [ %f, %f, %f ]" % tuple(get_lattice_parameters(lattice))
    print "lattice_angles: [ %f, %f, %f ]" % tuple(get_angles(lattice))
    print "mesh_length: %f" % distance
    print "mesh: [ %d, %d, %d ]" % tuple(imaginary.get_mesh())
    print "ratio: %f" % imaginary.get_imaginary_qpoint_ratio()
Пример #7
0
    import matplotlib

    matplotlib.use('Agg')            
    matplotlib.rcParams.update({'figure.figsize': (4.5, 3),
                                'font.family': 'serif'})
    import matplotlib.pyplot as plt
    
    if len(sys.argv) > 1:
        cell = phonopyYaml(sys.argv[1]).get_atoms()
    else:
        cell = phonopyYaml("POSCAR-unitcell.yaml").get_atoms()
    phonon_info = yaml.load(open("phonon.yaml"))
    phonon = Phonopy(cell,
                     phonon_info['supercell_matrix'],
                     is_auto_displacements=False)
    force_sets = parse_FORCE_SETS()
    phonon.set_displacement_dataset(force_sets)
    phonon.produce_force_constants()
    
    distance = 100
    tprops = ThermalProperty(phonon, distance=distance)
    if tprops.run():
        tprops.plot(plt)
        lattice = tprops.get_lattice()
        print("a, b, c = %f %f %f" % tuple(get_lattice_parameters(lattice)))
        print("alpha, beta, gamma = %f %f %f" % tuple(get_angles(lattice)))
        print("mesh (x=%f) = %s" % (distance, tprops.get_mesh()))
        tprops.save_figure(plt)
    else:
        print "Thermal property calculation failed."