def read_crystal_structure(filename=None, interface_mode=None, 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 phpy_yaml = PhonopyYaml() phpy_yaml.read(unitcell_filename) unitcell = phpy_yaml.get_unitcell() return unitcell, (unitcell_filename, ) if interface_mode is None or 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) if interface_mode == 'crystal': from phonopy.interface.crystal import read_crystal unitcell, conv_numbers = read_crystal(unitcell_filename) return unitcell, (unitcell_filename, conv_numbers)
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=None, 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 phpy_yaml = PhonopyYaml() phpy_yaml.read(unitcell_filename) unitcell = phpy_yaml.get_unitcell() return unitcell, (unitcell_filename,) if interface_mode is None or 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 test_read_pwscf(self): cell, pp_filenames = read_pwscf("NaCl-pwscf.in") cell_ref = get_unitcell_from_phonopy_yaml("NaCl-pwscf.yaml") self.assertTrue( (np.abs(cell.get_cell() - cell_ref.get_cell()) < 1e-5).all()) diff_pos = cell.get_scaled_positions() - cell_ref.get_scaled_positions() diff_pos -= np.rint(diff_pos) self.assertTrue((np.abs(diff_pos) < 1e-5).all()) for s, s_r in zip(cell.get_chemical_symbols(), cell_ref.get_chemical_symbols()): self.assertTrue(s == s_r)
def test_read_pwscf(self): cell, pp_filenames = read_pwscf(os.path.join(data_dir,"NaCl-pwscf.in")) filename = os.path.join(data_dir,"NaCl-abinit-pwscf.yaml") cell_ref = get_unitcell_from_phonopy_yaml(filename) self.assertTrue( (np.abs(cell.get_cell() - cell_ref.get_cell()) < 1e-5).all()) diff_pos = cell.get_scaled_positions() - cell_ref.get_scaled_positions() diff_pos -= np.rint(diff_pos) self.assertTrue((np.abs(diff_pos) < 1e-5).all()) for s, s_r in zip(cell.get_chemical_symbols(), cell_ref.get_chemical_symbols()): self.assertTrue(s == s_r)
def read_crystal_structure(filename=None, interface_mode='vasp', chemical_symbols=None): if filename is None: unitcell_filename = get_default_cell_filename(interface_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 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)
def read_crystal_structure(filename=None, interface_mode='vasp', chemical_symbols=None): if filename is None: unitcell_filename = get_default_cell_filename(interface_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 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)