def _get_delta_fc3(dataset_first_atom, fc3, supercell, reduced_site_sym, translational_symmetry_type, is_permutation_symmetry, symprec, verbose): disp_fc3 = _get_constrained_fc3(supercell, dataset_first_atom, reduced_site_sym, translational_symmetry_type, is_permutation_symmetry, symprec, verbose) if verbose: show_drift_fc3(disp_fc3, name="delta fc3") return disp_fc3 - fc3
def _get_delta_fc3(dataset_first_atom, fc3, supercell, reduced_site_sym, is_translational_symmetry, is_permutation_symmetry, symprec, verbose): disp_fc3 = _get_constrained_fc3(supercell, dataset_first_atom, reduced_site_sym, is_translational_symmetry, is_permutation_symmetry, symprec, verbose) if verbose: show_drift_fc3(disp_fc3, name="fc3 with disp.") return disp_fc3 - fc3
def create_phono3py_force_constants(phono3py, phonon_supercell_matrix, settings, energy_to_eV=None, distance_to_A=None, input_filename=None, output_filename=None, log_level=1): read_fc3 = settings.get_read_fc3() read_fc2 = settings.get_read_fc2() symmetrize_fc3_r = settings.get_is_symmetrize_fc3_r() symmetrize_fc3_q = settings.get_is_symmetrize_fc3_q() symmetrize_fc2 = settings.get_is_symmetrize_fc2() if settings.get_is_translational_symmetry(): tsym_type = 1 elif settings.get_tsym_type() > 0: tsym_type = settings.get_tsym_type() else: tsym_type = 0 if log_level: show_phono3py_force_constants_settings(read_fc3, read_fc2, tsym_type, symmetrize_fc3_r, symmetrize_fc3_q, symmetrize_fc2, settings) # fc3 if (settings.get_is_joint_dos() or (settings.get_is_isotope() and not (settings.get_is_bterta() or settings.get_is_lbte())) or settings.get_read_gamma() or settings.get_read_amplitude() or settings.get_constant_averaged_pp_interaction() is not None): pass else: if read_fc3: # Read fc3.hdf5 if input_filename is None: filename = 'fc3.hdf5' else: filename = 'fc3.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc3 from %s" % filename) fc3 = read_fc3_from_hdf5(filename=filename) num_atom = phono3py.get_supercell().get_number_of_atoms() if fc3.shape[0] != num_atom: print("Matrix shape of fc3 doesn't agree with supercell size.") if log_level: print_error() sys.exit(1) phono3py.set_fc3(fc3) else: # fc3 from FORCES_FC3 if not _create_phono3py_fc3( phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc3_r, symmetrize_fc2, settings.get_cutoff_fc3_distance(), input_filename, output_filename, log_level): print("fc3 was not created properly.") if log_level: print_error() sys.exit(1) if log_level: show_drift_fc3(phono3py.get_fc3()) # fc2 if read_fc2: if input_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc2 from %s" % filename) num_atom = phono3py.get_phonon_supercell().get_number_of_atoms() phonon_fc2 = read_fc2_from_hdf5(filename=filename) if phonon_fc2.shape[0] != num_atom: print("Matrix shape of fc2 doesn't agree with supercell size.") if log_level: print_error() sys.exit(1) phono3py.set_fc2(phonon_fc2) else: if log_level: print("Solving fc2") if phonon_supercell_matrix is None: if phono3py.get_fc2() is None: if not _create_phono3py_fc2( phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc2, input_filename, log_level): print("fc2 was not created properly.") if log_level: print_error() sys.exit(1) else: if not _create_phono3py_phonon_fc2( phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc2, input_filename, log_level): print("fc2 was not created properly.") if log_level: print_error() sys.exit(1) if output_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + output_filename + '.hdf5' if log_level: print("Writing fc2 to %s" % filename) write_fc2_to_hdf5(phono3py.get_fc2(), filename=filename) if log_level: show_drift_force_constants(phono3py.get_fc2(), name='fc2')
def create_phono3py_force_constants(phono3py, phonon_supercell_matrix, settings, read_fc3, read_fc2, tsym_type, symmetrize_fc3_r, symmetrize_fc3_q, symmetrize_fc2, input_filename, output_filename, log_level): if log_level: show_phono3py_force_constants_settings(read_fc3, read_fc2, tsym_type, symmetrize_fc3_r, symmetrize_fc3_q, symmetrize_fc2, settings) # fc3 if (settings.get_is_joint_dos() or (settings.get_is_isotope() and not (settings.get_is_bterta() or settings.get_is_lbte())) or settings.get_read_gamma() or settings.get_read_amplitude() or settings.get_constant_averaged_pp_interaction() is not None): pass else: if read_fc3: # Read fc3.hdf5 if input_filename is None: filename = 'fc3.hdf5' else: filename = 'fc3.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc3 from %s" % filename) fc3 = read_fc3_from_hdf5(filename=filename) phono3py.set_fc3(fc3) else: # fc3 from FORCES_THIRD and FORCES_SECOND _create_phono3py_fc3(phono3py, tsym_type, symmetrize_fc3_r, symmetrize_fc2, settings.get_cutoff_fc3_distance(), input_filename, output_filename, log_level) if log_level: show_drift_fc3(phono3py.get_fc3()) # fc2 if read_fc2: if input_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc2 from %s" % filename) phonon_supercell = phono3py.get_phonon_supercell() phonon_fc2 = read_fc2_from_hdf5(filename=filename) if phonon_fc2.shape[0] != phonon_supercell.get_number_of_atoms(): print("Matrix shape of fc2 doesn't agree with supercell.") if log_level: print_error() sys.exit(1) phono3py.set_fc2(phonon_fc2) else: if log_level: print("Solving fc2") if phonon_supercell_matrix is None: if phono3py.get_fc2() is None: _create_phono3py_fc2(phono3py, tsym_type, symmetrize_fc2, input_filename, log_level) else: _create_phono3py_phonon_fc2(phono3py, tsym_type, symmetrize_fc2, input_filename, log_level) if output_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + output_filename + '.hdf5' if log_level: print("Writing fc2 to %s" % filename) write_fc2_to_hdf5(phono3py.get_fc2(), filename=filename) if log_level: show_drift_force_constants(phono3py.get_fc2(), name='fc2')
# # Create fc2 from disp_fc2.yaml and FORCES_FC2 # disp_dataset2 = parse_disp_fc2_yaml(filename="disp_fc2.yaml") # forces_fc2 = parse_FORCES_FC2(disp_dataset2, filename="FORCES_FC2") # phono3py.produce_fc2( # forces_fc2, # displacement_dataset=disp_dataset2, # is_translational_symmetry=True, # is_permutation_symmetry=True) # # Read fc3 and fc2 from c3.hdf5 and fc2.hdf5 # fc3 = read_fc3_from_hdf5(filename="fc3.hdf5") # fc2 = read_fc2_from_hdf5(filename="fc2.hdf5") # phono3py.set_fc3(fc3) # phono3py.set_fc2(fc2) show_drift_fc3(fc3) show_drift_force_constants(fc2, name='fc2') # # For special cases like NAC # primitive = phono3py.get_phonon_primitive() # nac_params = parse_BORN(primitive, filename="BORN") # nac_params['factor'] = Hartree * Bohr # phono3py.set_phph_interaction(nac_params=nac_params) phono3py.run_thermal_conductivity(temperatures=range(0, 1001, 10), write_kappa=True) # Conductivity_RTA object (https://git.io/vVRUW) cond_rta = phono3py.get_thermal_conductivity()
def create_phono3py_force_constants(phono3py, phonon_supercell_matrix, settings, energy_to_eV=None, distance_to_A=None, input_filename=None, output_filename=None, log_level=1): read_fc3 = settings.get_read_fc3() read_fc2 = settings.get_read_fc2() symmetrize_fc3_r = settings.get_is_symmetrize_fc3_r() symmetrize_fc3_q = settings.get_is_symmetrize_fc3_q() symmetrize_fc2 = settings.get_is_symmetrize_fc2() if settings.get_is_translational_symmetry(): tsym_type = 1 elif settings.get_tsym_type() > 0: tsym_type = settings.get_tsym_type() else: tsym_type = 0 if log_level: show_phono3py_force_constants_settings(read_fc3, read_fc2, tsym_type, symmetrize_fc3_r, symmetrize_fc3_q, symmetrize_fc2, settings) # fc3 if (settings.get_is_joint_dos() or (settings.get_is_isotope() and not (settings.get_is_bterta() or settings.get_is_lbte())) or settings.get_read_gamma() or settings.get_read_amplitude() or settings.get_constant_averaged_pp_interaction() is not None): pass else: if read_fc3: # Read fc3.hdf5 if input_filename is None: filename = 'fc3.hdf5' else: filename = 'fc3.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc3 from %s" % filename) fc3 = read_fc3_from_hdf5(filename=filename) num_atom = phono3py.get_supercell().get_number_of_atoms() if fc3.shape[0] != num_atom: print("Matrix shape of fc3 doesn't agree with supercell size.") if log_level: print_error() sys.exit(1) phono3py.set_fc3(fc3) else: # fc3 from FORCES_FC3 if not _create_phono3py_fc3(phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc3_r, symmetrize_fc2, settings.get_cutoff_fc3_distance(), input_filename, output_filename, log_level): print("fc3 was not created properly.") if log_level: print_error() sys.exit(1) if log_level: show_drift_fc3(phono3py.get_fc3()) # fc2 if read_fc2: if input_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + input_filename + '.hdf5' file_exists(filename, log_level) if log_level: print("Reading fc2 from %s" % filename) num_atom = phono3py.get_phonon_supercell().get_number_of_atoms() phonon_fc2 = read_fc2_from_hdf5(filename=filename) if phonon_fc2.shape[0] != num_atom: print("Matrix shape of fc2 doesn't agree with supercell size.") if log_level: print_error() sys.exit(1) phono3py.set_fc2(phonon_fc2) else: if log_level: print("Solving fc2") if phonon_supercell_matrix is None: if phono3py.get_fc2() is None: if not _create_phono3py_fc2(phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc2, input_filename, log_level): print("fc2 was not created properly.") if log_level: print_error() sys.exit(1) else: if not _create_phono3py_phonon_fc2(phono3py, energy_to_eV, distance_to_A, tsym_type, symmetrize_fc2, input_filename, log_level): print("fc2 was not created properly.") if log_level: print_error() sys.exit(1) if output_filename is None: filename = 'fc2.hdf5' else: filename = 'fc2.' + output_filename + '.hdf5' if log_level: print("Writing fc2 to %s" % filename) write_fc2_to_hdf5(phono3py.get_fc2(), filename=filename) if log_level: show_drift_force_constants(phono3py.get_fc2(), name='fc2')