def setUp(self): with open(os.path.join(test_dir, "NaCl_ph_dos.json"), "r") as f: self.dos = PhononDos.from_dict(json.load(f)) with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.structure = CompletePhononDos.from_dict( json.load(f)).structure
def phdos(self): """ Returns: PhononDos object """ return PhononDos(self.tdos.frequency_points, self.tdos.dos)
def setUp(self): with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "NaCl_ph_dos.json")) as f: self.dos = PhononDos.from_dict(json.load(f)) with open( os.path.join(PymatgenTest.TEST_FILES_DIR, "NaCl_complete_ph_dos.json")) as f: self.structure = CompletePhononDos.from_dict( json.load(f)).structure
def get_ph_dos(total_dos_path): """ Creates a pymatgen PhononDos from a total_dos.dat file. Args: total_dos_path: path to the total_dos.dat file. """ a = np.loadtxt(total_dos_path) return PhononDos(a[:, 0], a[:, 1])
def get_phonon_dos_from_fc( structure: Structure, supercell_matrix: np.ndarray, force_constants: np.ndarray, mesh_density: float = 100.0, num_dos_steps: int = 200, **kwargs, ) -> CompletePhononDos: """ Get a projected phonon density of states from phonopy force constants. Args: structure: A structure. supercell_matrix: The supercell matrix used to generate the force constants. force_constants: The force constants in phonopy format. mesh_density: The density of the q-point mesh. See the docstring for the ``mesh`` argument in Phonopy.init_mesh() for more details. num_dos_steps: Number of frequency steps in the energy grid. **kwargs: Additional kwargs passed to the Phonopy constructor. Returns: The density of states. """ structure_phonopy = get_phonopy_structure(structure) phonon = Phonopy(structure_phonopy, supercell_matrix=supercell_matrix, **kwargs) phonon.set_force_constants(force_constants) phonon.run_mesh( mesh_density, is_mesh_symmetry=False, with_eigenvectors=True, is_gamma_center=True, ) # get min, max, step frequency frequencies = phonon.get_mesh_dict()["frequencies"] freq_min = frequencies.min() freq_max = frequencies.max() freq_pitch = (freq_max - freq_min) / num_dos_steps phonon.run_projected_dos(freq_min=freq_min, freq_max=freq_max, freq_pitch=freq_pitch) dos_raw = phonon.projected_dos.get_partial_dos() pdoss = dict(zip(structure, dos_raw[1])) total_dos = PhononDos(dos_raw[0], dos_raw[1].sum(axis=0)) return CompletePhononDos(structure, total_dos, pdoss)
def get_complete_ph_dos(partial_dos_path, phonopy_yaml_path): """ Creates a pymatgen CompletePhononDos from a partial_dos.dat and phonopy.yaml files. The second is produced when generating a Dos and is needed to extract the structure. Args: partial_dos_path: path to the partial_dos.dat file. phonopy_yaml_path: path to the phonopy.yaml file. """ a = np.loadtxt(partial_dos_path).transpose() d = loadfn(phonopy_yaml_path) structure = get_structure_from_dict(d['primitive_cell']) total_dos = PhononDos(a[0], a[1:].sum(axis=0)) pdoss = {} for site, pdos in zip(structure, a[1:]): pdoss[site] = pdos.tolist() return CompletePhononDos(structure, total_dos, pdoss)
def setUp(self): with open(os.path.join(test_dir, "NaCl_ph_dos.json"), "r") as f: self.dos = PhononDos.from_dict(json.load(f)) with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.structure = CompletePhononDos.from_dict(json.load(f)).structure
def setUp(self): with open(os.path.join(test_dir, "NaCl_ph_dos.json"), "r") as f: self.dos = PhononDos.from_dict(json.load(f))