def read_crystal_structure(filename=None, interface_mode="vasp", chemical_symbols=None, yaml_mode=False): if filename is None: unitcell_filename = get_default_cell_filename(interface_mode, yaml_mode) else: unitcell_filename = filename if not os.path.exists(unitcell_filename): if filename is None: return None, (unitcell_filename + " (default file name)",) else: return None, (unitcell_filename,) if yaml_mode: from phonopy.interface.phonopy_yaml import phonopyYaml unitcell = phonopyYaml(unitcell_filename).get_atoms() return unitcell, (unitcell_filename,) if interface_mode == "vasp": from phonopy.interface.vasp import read_vasp if chemical_symbols is None: unitcell = read_vasp(unitcell_filename) else: unitcell = read_vasp(unitcell_filename, symbols=chemical_symbols) return unitcell, (unitcell_filename,) if interface_mode == "abinit": from phonopy.interface.abinit import read_abinit unitcell = read_abinit(unitcell_filename) return unitcell, (unitcell_filename,) if interface_mode == "pwscf": from phonopy.interface.pwscf import read_pwscf unitcell, pp_filenames = read_pwscf(unitcell_filename) return unitcell, (unitcell_filename, pp_filenames) if interface_mode == "wien2k": from phonopy.interface.wien2k import parse_wien2k_struct unitcell, npts, r0s, rmts = parse_wien2k_struct(unitcell_filename) return unitcell, (unitcell_filename, npts, r0s, rmts) if interface_mode == "elk": from phonopy.interface.elk import read_elk unitcell, sp_filenames = read_elk(unitcell_filename) return unitcell, (unitcell_filename, sp_filenames) if interface_mode == "siesta": from phonopy.interface.siesta import read_siesta unitcell, atypes = read_siesta(unitcell_filename) return unitcell, (unitcell_filename, atypes)
def read_crystal_structure(filename=None, interface_mode='vasp', chemical_symbols=None, yaml_mode=False): if filename is None: unitcell_filename = get_default_cell_filename(interface_mode, yaml_mode) else: unitcell_filename = filename if not os.path.exists(unitcell_filename): if filename is None: return None, (unitcell_filename + " (default file name)", ) else: return None, (unitcell_filename, ) if yaml_mode: from phonopy.interface.phonopy_yaml import phonopyYaml unitcell = phonopyYaml(unitcell_filename).get_atoms() return unitcell, (unitcell_filename, ) if interface_mode == 'vasp': from phonopy.interface.vasp import read_vasp if chemical_symbols is None: unitcell = read_vasp(unitcell_filename) else: unitcell = read_vasp(unitcell_filename, symbols=chemical_symbols) return unitcell, (unitcell_filename, ) if interface_mode == 'abinit': from phonopy.interface.abinit import read_abinit unitcell = read_abinit(unitcell_filename) return unitcell, (unitcell_filename, ) if interface_mode == 'pwscf': from phonopy.interface.pwscf import read_pwscf unitcell, pp_filenames = read_pwscf(unitcell_filename) return unitcell, (unitcell_filename, pp_filenames) if interface_mode == 'wien2k': from phonopy.interface.wien2k import parse_wien2k_struct unitcell, npts, r0s, rmts = parse_wien2k_struct(unitcell_filename) return unitcell, (unitcell_filename, npts, r0s, rmts) if interface_mode == 'elk': from phonopy.interface.elk import read_elk unitcell, sp_filenames = read_elk(unitcell_filename) return unitcell, (unitcell_filename, sp_filenames) if interface_mode == 'siesta': from phonopy.interface.siesta import read_siesta unitcell, atypes = read_siesta(unitcell_filename) return unitcell, (unitcell_filename, atypes)
from thermal_prop import get_Z import matplotlib matplotlib.use('Agg') matplotlib.rcParams.update({'figure.figsize': (10, 7), 'font.family': 'serif'}) import matplotlib.pyplot as plt # plt.rcParams['backend'] = 'PDF' # plt.rcParams['pdf.fonttype'] = 42 # plt.rcParams['font.family'] = 'serif' # plt.rcParams['axes.labelsize'] = 18 # plt.rcParams['figure.subplot.left'] = 0.15 # plt.rcParams['figure.subplot.bottom'] = 0.15 # plt.rcParams['figure.figsize'] = 8, 6 cell = phonopyYaml("gruneisen-01/POSCAR-unitcell.yaml").get_atoms() volumes, electronic_energies = read_v_e("e-v.dat") (temperatures, cv, entropy, fe_phonon, imag_ratios) = read_thermal_properties_yaml(sys.argv[1:]) indices_used = np.nonzero(np.array(imag_ratios) < 0.001)[0] qha = QHA(volumes[indices_used], electronic_energies[indices_used], temperatures, fe_phonon[:, indices_used], cv[:, indices_used], entropy[:, indices_used],
def test_read_poscar_yaml(self): filename = "POSCAR.yaml" phpy_yaml = phonopyYaml(filename) print phpy_yaml
def setUp(self): filename = "POSCAR.yaml" self._cell = phonopyYaml(filename).get_atoms()
from phonopy import Phonopy, PhonopyGruneisen from phonopy.gruneisen.mesh import Mesh as GruneisenMesh 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 matplotlib.use('Agg') matplotlib.rcParams.update({'figure.figsize': (4, 4), 'font.family': 'serif'}) import matplotlib.pyplot as plt 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)
def _search_imaginary_qpoint_ratio(self): _, weights, freqs, _ = self._phonon.get_mesh() self._ratio = float(np.extract(freqs[:, 0] < 0, weights).sum()) / np.prod(self._mesh) 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