def create_FORCES_FC2_from_FORCE_SETS_then_exit(log_level): filename = 'FORCE_SETS' file_exists(filename, log_level) disp_dataset = parse_FORCE_SETS(filename=filename) write_FORCES_FC2(disp_dataset) write_disp_fc2_yaml(disp_dataset, None) if log_level: print("FORCES_FC2 and disp_fc2.yaml have been created from " "FORCE_SETS.") print_end() sys.exit(0)
def create_phono3py_supercells(unitcell, supercell_matrix, phonon_supercell_matrix, displacement_distance, is_plusminus, is_diagonal, cutoff_pair_distance, write_supercells_with_displacements, optional_structure_file_information, symprec, interface_mode='vasp', output_filename=None, log_level=1): if displacement_distance is None: if interface_mode in ('pwscf', 'abinit'): distance = 0.06 elif interface_mode == 'crystal': distance = 0.03 else: distance = 0.03 else: distance = displacement_distance phono3py = Phono3py(unitcell, supercell_matrix, phonon_supercell_matrix=phonon_supercell_matrix, symprec=symprec) supercell = phono3py.get_supercell() phono3py.generate_displacements(distance=distance, cutoff_pair_distance=cutoff_pair_distance, is_plusminus=is_plusminus, is_diagonal=is_diagonal) dds = phono3py.get_displacement_dataset() if log_level: print('') print("Displacement distance: %s" % distance) if output_filename is None: filename = 'disp_fc3.yaml' else: filename = 'disp_fc3.' + output_filename + '.yaml' num_disps, num_disp_files = write_disp_fc3_yaml(dds, supercell, filename=filename) cells_with_disps = phono3py.get_supercells_with_displacements() if interface_mode == 'pwscf': pp_filenames = optional_structure_file_information[1] write_supercells_with_displacements(supercell, cells_with_disps, pp_filenames, width=5) elif interface_mode == 'crystal': conv_numbers = optional_structure_file_information[1] write_supercells_with_displacements(supercell, cells_with_disps, conv_numbers, supercell_matrix, width=5, template_file="TEMPLATE3") elif interface_mode == 'abinit': write_supercells_with_displacements(supercell, cells_with_disps, width=5) else: # VASP write_supercells_with_displacements(supercell, cells_with_disps, width=5) if log_level: print("Number of displacements: %d" % num_disps) if cutoff_pair_distance is not None: print("Cutoff distance for displacements: %s" % cutoff_pair_distance) print("Number of displacement supercell files created: %d" % num_disp_files) if phonon_supercell_matrix is not None: phonon_dds = phono3py.get_phonon_displacement_dataset() phonon_supercell = phono3py.get_phonon_supercell() if output_filename is None: filename = 'disp_fc2.yaml' else: filename = 'disp_fc2.' + output_filename + '.yaml' num_disps = write_disp_fc2_yaml(phonon_dds, phonon_supercell, filename=filename) cells_with_disps = phono3py.get_phonon_supercells_with_displacements() if interface_mode == 'pwscf': pp_filenames = optional_structure_file_information[1] write_supercells_with_displacements(phonon_supercell, cells_with_disps, pp_filenames, pre_filename="supercell_fc2", width=5) elif interface_mode == 'crystal': conv_numbers = optional_structure_file_information[1] write_supercells_with_displacements(phonon_supercell, cells_with_disps, conv_numbers, phonon_supercell_matrix, pre_filename="supercell_fc2", width=5, template_file="TEMPLATE") elif interface_mode == 'abinit': write_supercells_with_displacements(phonon_supercell, cells_with_disps, pre_filename="supercell_fc2", width=5) else: write_supercells_with_displacements(phonon_supercell, cells_with_disps, pre_filename="POSCAR_FC2", width=5) if log_level: print("Number of displacements for special fc2: %d" % num_disps) return phono3py
def create_phono3py_supercells(unitcell, supercell_matrix, phonon_supercell_matrix, displacement_distance, is_plusminus, is_diagonal, cutoff_pair_distance, optional_structure_info, is_symmetry, symprec, interface_mode='vasp', output_filename=None, log_level=1): if displacement_distance is None: distance = get_default_displacement_distance(interface_mode) else: distance = displacement_distance phono3py = Phono3py(unitcell, supercell_matrix, phonon_supercell_matrix=phonon_supercell_matrix, is_symmetry=is_symmetry, symprec=symprec) supercell = phono3py.get_supercell() phono3py.generate_displacements(distance=distance, cutoff_pair_distance=cutoff_pair_distance, is_plusminus=is_plusminus, is_diagonal=is_diagonal) dds = phono3py.get_displacement_dataset() if log_level: print('') print("Displacement distance: %s" % distance) if output_filename is None: filename = 'disp_fc3.yaml' else: filename = 'disp_fc3.' + output_filename + '.yaml' num_disps, num_disp_files = write_disp_fc3_yaml(dds, supercell, filename=filename) cells_with_disps = phono3py.supercells_with_displacements ids = [] disp_cells = [] for i, cell in enumerate(cells_with_disps): if cell is not None: ids.append(i + 1) disp_cells.append(cell) additional_info = get_additional_info_to_write_supercells( interface_mode, phono3py) write_supercells_with_displacements(interface_mode, supercell, disp_cells, optional_structure_info, displacement_ids=ids, zfill_width=5, additional_info=additional_info) if log_level: print("Number of displacements: %d" % num_disps) if cutoff_pair_distance is not None: print("Cutoff distance for displacements: %s" % cutoff_pair_distance) print("Number of displacement supercell files created: %d" % num_disp_files) if phonon_supercell_matrix is not None: phonon_dds = phono3py.phonon_dataset phonon_supercell = phono3py.phonon_supercell phonon_supercell_matrix = phono3py.phonon_supercell_matrix if output_filename is None: filename = 'disp_fc2.yaml' else: filename = 'disp_fc2.' + output_filename + '.yaml' num_disps = write_disp_fc2_yaml(phonon_dds, phonon_supercell, filename=filename) cells_with_disps = phono3py.phonon_supercells_with_displacements additional_info = get_additional_info_to_write_fc2_supercells( interface_mode, phono3py) write_supercells_with_displacements(interface_mode, supercell, cells_with_disps, optional_structure_info, zfill_width=5, additional_info=additional_info) if log_level: print("Number of displacements for special fc2: %d" % num_disps) return phono3py
def create_phono3py_supercells(cell_info, settings, symprec, output_filename=None, interface_mode='vasp', log_level=1): """create displacements and supercells Distance unit used is that for the calculator interface. The default unit is Angstron. """ optional_structure_info = cell_info['optional_structure_info'] if settings.displacement_distance is None: distance = get_default_displacement_distance(interface_mode) else: distance = settings.displacement_distance phono3py = Phono3py( cell_info['unitcell'], cell_info['supercell_matrix'], primitive_matrix=cell_info['primitive_matrix'], phonon_supercell_matrix=cell_info['phonon_supercell_matrix'], is_symmetry=settings.is_symmetry, symprec=symprec, calculator=interface_mode) phono3py.generate_displacements( distance=distance, cutoff_pair_distance=settings.cutoff_pair_distance, is_plusminus=settings.is_plusminus_displacement, is_diagonal=settings.is_diagonal_displacement) if log_level: print('') print("Unit cell was read from \"%s\"." % optional_structure_info[0]) print("Displacement distance: %s" % distance) if output_filename is None: filename = 'disp_fc3.yaml' else: filename = 'disp_fc3.' + output_filename + '.yaml' num_disps, num_disp_files = write_disp_fc3_yaml(phono3py.dataset, phono3py.supercell, filename=filename) ids = [] disp_cells = [] for i, cell in enumerate(phono3py.supercells_with_displacements): if cell is not None: ids.append(i + 1) disp_cells.append(cell) additional_info = get_additional_info_to_write_supercells( interface_mode, phono3py.supercell_matrix) write_supercells_with_displacements(interface_mode, phono3py.supercell, disp_cells, optional_structure_info, displacement_ids=ids, zfill_width=5, additional_info=additional_info) if log_level: print("Number of displacements: %d" % num_disps) if settings.cutoff_pair_distance is not None: print("Cutoff distance for displacements: %s" % settings.cutoff_pair_distance) print("Number of displacement supercell files created: %d" % num_disp_files) if phono3py.phonon_supercell_matrix is not None: if output_filename is None: filename = 'disp_fc2.yaml' else: filename = 'disp_fc2.' + output_filename + '.yaml' num_disps = write_disp_fc2_yaml(phono3py.phonon_dataset, phono3py.phonon_supercell, filename=filename) additional_info = get_additional_info_to_write_fc2_supercells( interface_mode, phono3py.phonon_supercell_matrix) write_supercells_with_displacements( interface_mode, phono3py.supercell, phono3py.phonon_supercells_with_displacements, optional_structure_info, zfill_width=5, additional_info=additional_info) if log_level: print("Number of displacements for special fc2: %d" % num_disps) return phono3py
def create_phono3py_supercells( cell_info, settings, symprec, output_filename=None, interface_mode="vasp", log_level=1, write_disp_yaml=False, ): """Create displacements and supercells. Distance unit used is that for the calculator interface. The default unit is Angstron. Parameters ---------- write_disp_yaml : bool Write old-style files of disp_fc3.yaml and disp_fc2.yaml. Default is False. """ optional_structure_info = cell_info["optional_structure_info"] if settings.displacement_distance is None: distance = get_default_displacement_distance(interface_mode) else: distance = settings.displacement_distance phono3py = Phono3py( cell_info["unitcell"], cell_info["supercell_matrix"], primitive_matrix=cell_info["primitive_matrix"], phonon_supercell_matrix=cell_info["phonon_supercell_matrix"], is_symmetry=settings.is_symmetry, symprec=symprec, calculator=interface_mode, ) phono3py.generate_displacements( distance=distance, cutoff_pair_distance=settings.cutoff_pair_distance, is_plusminus=settings.is_plusminus_displacement, is_diagonal=settings.is_diagonal_displacement, ) if log_level: print("") print('Unit cell was read from "%s".' % optional_structure_info[0]) print("Displacement distance: %s" % distance) if write_disp_yaml: if output_filename is None: filename = "disp_fc3.yaml" else: filename = "disp_fc3." + output_filename + ".yaml" num_disps, num_disp_files = write_disp_fc3_yaml( phono3py.dataset, phono3py.supercell, filename=filename ) ids = [] disp_cells = [] for i, cell in enumerate(phono3py.supercells_with_displacements): if cell is not None: ids.append(i + 1) disp_cells.append(cell) additional_info = get_additional_info_to_write_supercells( interface_mode, phono3py.supercell_matrix ) write_supercells_with_displacements( interface_mode, phono3py.supercell, disp_cells, optional_structure_info, displacement_ids=ids, zfill_width=5, additional_info=additional_info, ) if log_level: num_disps = len(phono3py.supercells_with_displacements) num_disp_files = len(disp_cells) print("Number of displacements: %d" % num_disps) if settings.cutoff_pair_distance is not None: print( "Cutoff distance for displacements: %s" % settings.cutoff_pair_distance ) print("Number of displacement supercell files created: %d" % num_disp_files) if phono3py.phonon_supercell_matrix is not None: if write_disp_yaml: if output_filename is None: filename = "disp_fc2.yaml" else: filename = "disp_fc2." + output_filename + ".yaml" num_disps = write_disp_fc2_yaml( phono3py.phonon_dataset, phono3py.phonon_supercell, filename=filename ) additional_info = get_additional_info_to_write_fc2_supercells( interface_mode, phono3py.phonon_supercell_matrix ) write_supercells_with_displacements( interface_mode, phono3py.supercell, phono3py.phonon_supercells_with_displacements, optional_structure_info, zfill_width=5, additional_info=additional_info, ) if log_level: print("Number of displacements for special fc2: %d" % num_disps) return phono3py