Ejemplo n.º 1
0
    def _set_phonon(self):
        if self._supercell_matrix is None:
            cell = sort_cell_by_symbols(
                get_crystallographic_cell(self.get_cell()))
            self._supercell_matrix = estimate_supercell_matrix(
                cell,
                max_num_atoms=self._max_num_atoms)
        else:
            cell = self.get_cell()

        phonopy_cell = cell2atoms(cell)
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               primitive_matrix=self._primitive_matrix,
                               dynamical_matrix_decimals=14,
                               force_constants_decimals=14,
                               symprec=self._symmetry_tolerance)
        self._phonon.generate_displacements(
            distance=self._distance,
            is_plusminus=self._displace_plusminus,
            is_diagonal=self._displace_diagonal)
        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, filename="POSCAR-unitcell")
        write_poscar_yaml(cell, filename="POSCAR-unitcell.yaml")
        write_disp_yaml(displacements, supercell)
Ejemplo n.º 2
0
 def test_read_poscar_yaml(self):
     filename = "POSCAR.yaml"
     cell, poscar_order = read_poscar_yaml(filename)
     for s, p in zip(cell.get_symbols(), cell.get_points().T):
         print s, p
     print write_poscar(cell)
     print poscar_order
Ejemplo n.º 3
0
    def _set_phonon(self):
        cell = self.get_cell()
        phonopy_cell = Atoms(cell=cell.get_lattice().T,
                             scaled_positions=cell.get_points().T,
                             symbols=cell.get_symbols())

        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               is_auto_displacements=False)
        self._phonon.generate_displacements(distance=self._distance,
                                            is_diagonal=False)

        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, "POSCAR-unitcell")
        write_disp_yaml(displacements, supercell)
Ejemplo n.º 4
0
    def _set_phonon(self):
        cell = self.get_cell()
        phonopy_cell = cell2atoms(cell)
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               primitive_matrix=self._primitive_matrix,
                               is_auto_displacements=False,
                               dynamical_matrix_decimals=14,
                               force_constants_decimals=14)
        self._phonon.generate_displacements(
            distance=self._distance,
            is_plusminus=self._displace_plusminus,
            is_diagonal=self._displace_diagonal)
        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, "POSCAR-unitcell")
        write_disp_yaml(displacements, supercell)
Ejemplo n.º 5
0
    def _set_phonon(self):
        cell = self.get_cell()
        phonopy_cell = Atoms(
            cell=cell.get_lattice().T,
            scaled_positions=cell.get_points().T,
            symbols=cell.get_symbols())
        
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               is_auto_displacements=False)
        self._phonon.generate_displacements(distance=self._distance,
                                            is_diagonal=False)

        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, "POSCAR-unitcell")
        write_disp_yaml(displacements, supercell)
Ejemplo n.º 6
0
 def _set_phonon_fc3(self):
     cell = self.get_cell()
     phonopy_cell = cell2atoms(cell)
     self._phonon = Phonopy(phonopy_cell,
                            self._supercell_matrix,
                            primitive_matrix=self._primitive_matrix,
                            dynamical_matrix_decimals=14,
                            force_constants_decimals=14)
     self._phonon_fc3 = Phono3py(phonopy_cell,
                                 self._supercell_matrix,
                                 primitive_matrix=self._primitive_matrix)
     self._phonon_fc3.generate_displacements(distance=self._distance,
                                             is_diagonal=self._is_diagonal)
     supercell = self._phonon_fc3.get_supercell()
     disp_dataset = self._phonon_fc3.get_displacement_dataset()
     self._phonon.set_displacement_dataset(disp_dataset)
     write_poscar(cell, "POSCAR-unitcell")
     write_disp_yaml(self._phonon.get_displacements(),
                     supercell,
                     directions=self._phonon.get_displacement_directions())
     write_disp_fc3_yaml(disp_dataset, supercell)
Ejemplo n.º 7
0
 def next(self):
     if self._stage == 0:
         task = self._phr_tasks[0]
         if self._status == "next":
             imag_modes = task.get_imaginary_modes()
             self._comment += " --> %s" % task.get_space_group_type()
             self._energy = task.get_energy()
             if self._energy:
                 num_atom = len(task.get_cell().get_symbols())
                 self._comment += "\\n%f/%d" % (self._energy, num_atom)
             if imag_modes: # Next phonon-relaxes
                 self._stage = 1
                 self._status = "offspring"
                 self._set_offsprings(imag_modes)
                 return self._tasks
             else: # No imaginary mode
                 self._status = "done"
                 self._tasks = []
         elif self._status == "terminate":
             pass
         elif ("confluence" in self._status or
               self._status == "low_symmetry" or
               self._status == "max_iteration"):
             self._comment += " --> %s" % task.get_space_group_type()
             self._tasks = []
         else:
             print("It is something wrong happening in PhononRelaxBase.")
     else:
         if self._status == "next":
             self._log += "# phonon_relax: task ID %d\n" % self._tid
             self._log += write_poscar(self._cell)
             self._log += "#\n"
             self._status = "done"
             
     self._write_yaml()
     raise StopIteration
Ejemplo n.º 8
0
def get_unstable_modulations(phonon,
                             supercell_dimension,
                             degeneracy_tolerance=DEGENERACY_TOLERANCE,
                             symmetry_tolerance=0.1,
                             max_displacement=0.2,
                             cutoff_eigenvalue=0.0,
                             ndiv=180,
                             excluded_qpoints=[]):
    qpoints, weigths, frequencies, eigvecs = phonon.get_mesh()
    eigenvalues = frequencies ** 2 * np.sign(frequencies)
    imag_modes = []

    for i, (q, eigs_at_q) in enumerate(zip(qpoints, eigenvalues)):
        qpt_exists = False
        for qpt in excluded_qpoints:
            if (abs(q - qpt) < 1e-10).all():
                qpt_exists = True
                break
        if qpt_exists:
            continue
        
        indices_imaginary = np.where(eigs_at_q < cutoff_eigenvalue)[0]
        degeneracy_sets = get_degeneracy_sets(eigs_at_q,
                                              indices_imaginary,
                                              degeneracy_tolerance)
        if degeneracy_sets:
            phonon.write_animation(q, filename="anime-d%d%d%d-q%d.ascii" %
                                   (tuple(supercell_dimension) + (i + 1,)))
        
        for deg_set in degeneracy_sets:
            j = deg_set[0]
            eig = eigs_at_q[j]
            modulation_dimension = []
            for a, multi in zip(q, supercell_dimension):
                if abs(a) < CUTOFF_ZERO:
                    modulation_dimension.append(1)
                else:
                    modulation_dimension.append(multi)

            phononMod = PhononModulation(
                phonon,
                q,
                deg_set,
                modulation_dimension,
                ndiv=ndiv,
                symmetry_tolerance=symmetry_tolerance,
                max_displacement=max_displacement)
            modulation_cells = phononMod.get_modulation_cells()
            supercell = phononMod.get_supercell()
            write_poscar(supercell,
                        "SPOSCAR-d%d%d%d" % tuple(modulation_dimension))
            write_cif_P1(supercell,
                         "supercell-d%d%d%d.cif" % tuple(modulation_dimension))
            write_v_sim(supercell,
                        "supercell-d%d%d%d.ascii" % tuple(modulation_dimension))
            for k, modcell in enumerate(modulation_cells):
                write_poscar(modcell,
                            "POSCAR-d%d%d%d-q%db%d-%d" %
                            (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                write_cif_P1(modcell,
                             "mod-d%d%d%d-q%db%d-%d.cif" % 
                             (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                write_v_sim(modcell,
                            "mod-d%d%d%d-q%db%d-%d.ascii" % 
                            (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                imag_modes.append(
                    (modcell, q, np.sqrt(-eig), i, j, k,
                     len(deg_set), modulation_dimension))
            
    return imag_modes
Ejemplo n.º 9
0
                 'icsd_ids': get_icsd_ids,
                 'e_above_hull': get_e_above_hull,
                 'pretty_formula': get_pretty_formula,
                 'created_at': get_created_at,
                 'is_hubbard': get_is_hubbard,
                 'nsites': get_nsites,
                 'elasticity': get_elasticity,
                 'final_structure': get_final_structure,
                 'initial_structure': get_initial_structure,
                 'icsd_id': get_icsd_id,
                 'spacegroup': get_spacegroup,
                 'magnetic_type': get_magnetic_type,
                 'exp_lattice': get_exp_lattice}

functions = {'band_gap': get_band_gap,
             'e_above_hull': get_e_above_hull,
             'is_hubbard': get_is_hubbard,
             'final_structure': get_final_structure,
             'initial_structure': get_initial_structure,
             'magnetic_type': get_magnetic_type}

mid = sys.argv[2]
for line in open(sys.argv[1]):
    words = line.partition(':')
    key = words[0].strip()
    if key in functions:
        if key == 'final_structure':
            retval = functions[key](words[2].strip(), show=False)
            brv_cell = get_crystallographic_cell(retval, tolerance=1e-1)
            write_poscar(brv_cell, filename="BPOSCAR-%s" % mid)
Ejemplo n.º 10
0
def get_unstable_modulations(phonon,
                             supercell_dimension,
                             degeneracy_tolerance=DEGENERACY_TOLERANCE,
                             symmetry_tolerance=0.1,
                             max_displacement=0.2,
                             cutoff_eigenvalue=None,
                             ndiv=180,
                             excluded_qpoints=None):
    qpoints, weigths, frequencies, eigvecs = phonon.get_mesh()
    eigenvalues = frequencies**2 * np.sign(frequencies)
    imag_modes = []

    for i, (q, eigs_at_q) in enumerate(zip(qpoints, eigenvalues)):
        qpt_exists = False
        for qpt in excluded_qpoints:
            if (abs(q - qpt) < 1e-10).all():
                qpt_exists = True
                break
        if qpt_exists:
            continue

        indices_imaginary = np.where(eigs_at_q < cutoff_eigenvalue)[0]
        degeneracy_sets = get_degeneracy_sets(eigs_at_q, indices_imaginary,
                                              degeneracy_tolerance)
        if degeneracy_sets:
            phonon.write_animation(q,
                                   filename="anime-d%d%d%d-q%d.ascii" %
                                   (tuple(supercell_dimension) + (i + 1, )))

        for deg_set in degeneracy_sets:
            j = deg_set[0]
            eig = eigs_at_q[j]
            modulation_dimension = []
            for a, multi in zip(q, supercell_dimension):
                if abs(a) < CUTOFF_ZERO:
                    modulation_dimension.append(1)
                else:
                    modulation_dimension.append(multi)

            phononMod = PhononModulation(phonon,
                                         q,
                                         deg_set,
                                         modulation_dimension,
                                         ndiv=ndiv,
                                         symmetry_tolerance=symmetry_tolerance,
                                         max_displacement=max_displacement)
            modulation_cells = phononMod.get_modulation_cells()
            supercell = phononMod.get_supercell()
            write_poscar(supercell,
                         "SPOSCAR-d%d%d%d" % tuple(modulation_dimension))
            write_cif_P1(supercell,
                         "supercell-d%d%d%d.cif" % tuple(modulation_dimension))
            write_v_sim(
                supercell,
                "supercell-d%d%d%d.ascii" % tuple(modulation_dimension))
            for k, modcell in enumerate(modulation_cells):
                write_poscar(
                    modcell, "POSCAR-d%d%d%d-q%db%d-%d" %
                    (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                write_cif_P1(
                    modcell, "mod-d%d%d%d-q%db%d-%d.cif" %
                    (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                write_v_sim(
                    modcell, "mod-d%d%d%d-q%db%d-%d.ascii" %
                    (tuple(modulation_dimension) + (i + 1, j + 1, k + 1)))
                imag_modes.append((modcell, q, np.sqrt(-eig), i, j, k,
                                   len(deg_set), modulation_dimension))

    return imag_modes