示例#1
0
def _create_phono3py_fc2(phono3py, energy_to_eV, distance_to_A, tsym_type,
                         symmetrize_fc2, input_filename, log_level):
    if input_filename is None:
        filename = 'disp_fc3.yaml'
    else:
        filename = 'disp_fc3.' + input_filename + '.yaml'
    if log_level:
        print("Displacement dataset is read from %s." % filename)
    file_exists(filename, log_level)
    disp_dataset = parse_disp_fc3_yaml(filename=filename)
    num_atom = phono3py.get_supercell().get_number_of_atoms()
    if disp_dataset['natom'] != num_atom:
        print("Number of atoms in supercell is not consistent with %s" %
              filename)
        if log_level:
            print_error()
        sys.exit(1)
    _convert_displacement_unit(disp_dataset, distance_to_A, is_fc2=True)

    if log_level:
        print("Sets of supercell forces are read from %s." % "FORCES_FC3")
    file_exists("FORCES_FC3", log_level)
    forces_fc2 = parse_FORCES_FC2(disp_dataset, filename="FORCES_FC3")
    if not forces_fc2:
        return False

    _convert_force_unit(forces_fc2, energy_to_eV, distance_to_A)

    phono3py.produce_fc2(forces_fc2,
                         displacement_dataset=disp_dataset,
                         translational_symmetry_type=tsym_type,
                         is_permutation_symmetry=symmetrize_fc2)

    return True
示例#2
0
def _create_phono3py_fc3(phono3py, tsym_type, symmetrize_fc3_r, symmetrize_fc2,
                         cutoff_distance, input_filename, output_filename,
                         log_level):
    if input_filename is None:
        filename = 'disp_fc3.yaml'
    else:
        filename = 'disp_fc3.' + input_filename + '.yaml'
    file_exists(filename, log_level)
    if log_level:
        print("Displacement dataset is read from %s." % filename)
    disp_dataset = parse_disp_fc3_yaml(filename=filename)
    file_exists("FORCES_FC3", log_level)
    if log_level:
        print("Sets of supercell forces are read from %s." % "FORCES_FC3")
    forces_fc3 = parse_FORCES_FC3(disp_dataset)
    phono3py.produce_fc3(forces_fc3,
                         displacement_dataset=disp_dataset,
                         cutoff_distance=cutoff_distance,
                         translational_symmetry_type=tsym_type,
                         is_permutation_symmetry=symmetrize_fc3_r,
                         is_permutation_symmetry_fc2=symmetrize_fc2)
    if output_filename is None:
        filename = 'fc3.hdf5'
    else:
        filename = 'fc3.' + output_filename + '.hdf5'
    if log_level:
        print("Writing fc3 to %s" % filename)
    write_fc3_to_hdf5(phono3py.get_fc3(), filename=filename)
示例#3
0
def _create_phono3py_fc3(phono3py,
                         energy_to_eV,
                         distance_to_A,
                         tsym_type,
                         symmetrize_fc3_r,
                         symmetrize_fc2,
                         cutoff_distance,
                         input_filename,
                         output_filename,
                         log_level):
    if input_filename is None:
        filename = 'disp_fc3.yaml'
    else:
        filename = 'disp_fc3.' + input_filename + '.yaml'
    file_exists(filename, log_level)
    if log_level:
        print("Displacement dataset is read from %s." % filename)
    disp_dataset = parse_disp_fc3_yaml(filename=filename)
    num_atom = phono3py.get_supercell().get_number_of_atoms()
    if disp_dataset['natom'] != num_atom:
        print("Number of atoms in supercell is not consistent with %s" %
              filename)
        if log_level:
            print_error()
        sys.exit(1)
    _convert_displacement_unit(disp_dataset, distance_to_A)

    file_exists("FORCES_FC3", log_level)
    if log_level:
        print("Sets of supercell forces are read from %s." % "FORCES_FC3")
    forces_fc3 = parse_FORCES_FC3(disp_dataset)
    if not forces_fc3:
        return False

    _convert_force_unit(forces_fc3, energy_to_eV, distance_to_A)

    phono3py.produce_fc3(
        forces_fc3,
        displacement_dataset=disp_dataset,
        cutoff_distance=cutoff_distance,
        translational_symmetry_type=tsym_type,
        is_permutation_symmetry=symmetrize_fc3_r,
        is_permutation_symmetry_fc2=symmetrize_fc2)
    if output_filename is None:
        filename = 'fc3.hdf5'
    else:
        filename = 'fc3.' + output_filename + '.hdf5'
    if log_level:
        print("Writing fc3 to %s" % filename)
    write_fc3_to_hdf5(phono3py.get_fc3(), filename=filename)

    return True
示例#4
0
def _create_phono3py_fc2(phono3py, tsym_type, symmetrize_fc2, input_filename,
                         log_level):
    if input_filename is None:
        filename = 'disp_fc3.yaml'
    else:
        filename = 'disp_fc3.' + input_filename + '.yaml'
    if log_level:
        print("Displacement dataset is read from %s." % filename)
    file_exists(filename, log_level)
    disp_dataset = parse_disp_fc3_yaml(filename=filename)
    if log_level:
        print("Sets of supercell forces are read from %s." % "FORCES_FC3")
    file_exists("FORCES_FC3", log_level)
    forces_fc3 = parse_FORCES_FC3(disp_dataset)
    phono3py.produce_fc2(forces_fc3,
                         displacement_dataset=disp_dataset,
                         translational_symmetry_type=tsym_type,
                         is_permutation_symmetry=symmetrize_fc2)
示例#5
0
文件: Si.py 项目: chueter/phonopy
                                parse_FORCES_FC3,
                                read_fc3_from_hdf5,
                                read_fc2_from_hdf5)

cell = read_vasp("POSCAR-unitcell")
mesh = [11, 11, 11]
phono3py = Phono3py(cell,
                    np.diag([2, 2, 2]),
                    primitive_matrix=[[0, 0.5, 0.5],
                                      [0.5, 0, 0.5],
                                      [0.5, 0.5, 0]],
                    mesh=mesh,
                    log_level=1) # log_level=0 make phono3py quiet

# Create fc3 and fc2 from disp_fc3.yaml and FORCES_FC3
disp_dataset = parse_disp_fc3_yaml(filename="disp_fc3.yaml")
forces_fc3 = parse_FORCES_FC3(disp_dataset, filename="FORCES_FC3")
phono3py.produce_fc3(
    forces_fc3,
    displacement_dataset=disp_dataset,
    is_translational_symmetry=True,
    is_permutation_symmetry=True,
    is_permutation_symmetry_fc2=True)
fc3 = phono3py.get_fc3()
fc2 = phono3py.get_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,
示例#6
0
from anharmonic.phonon3 import Phono3py
from anharmonic.file_IO import (parse_disp_fc3_yaml, parse_disp_fc2_yaml,
                                parse_FORCES_FC2, parse_FORCES_FC3,
                                read_fc3_from_hdf5, read_fc2_from_hdf5)

cell = read_vasp("POSCAR-unitcell")
mesh = [11, 11, 11]
phono3py = Phono3py(cell,
                    np.diag([2, 2, 2]),
                    primitive_matrix=[[0, 0.5, 0.5], [0.5, 0, 0.5],
                                      [0.5, 0.5, 0]],
                    mesh=mesh,
                    log_level=1)  # log_level=0 make phono3py quiet

# Create fc3 and fc2 from disp_fc3.yaml and FORCES_FC3
disp_dataset = parse_disp_fc3_yaml(filename="disp_fc3.yaml")
forces_fc3 = parse_FORCES_FC3(disp_dataset, filename="FORCES_FC3")
phono3py.produce_fc3(forces_fc3,
                     displacement_dataset=disp_dataset,
                     is_translational_symmetry=True,
                     is_permutation_symmetry=True,
                     is_permutation_symmetry_fc2=True)
fc3 = phono3py.get_fc3()
fc2 = phono3py.get_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,