def write_cif_P1(cell, filename=None): a, b, c = get_lattice_parameters(cell.lattice) alpha, beta, gamma = get_angles(cell.lattice) cif = """data_cogue_crystal_converter _symmetry_space_group_name_H-M 'P 1' _symmetry_Int_Tables_number 1 _cell_length_a %.5f _cell_length_b %.5f _cell_length_c %.5f _cell_angle_alpha %.5f _cell_angle_beta %.5f _cell_angle_gamma %.5f _cell_volume %.5f _cell_formula_units_Z 1 loop_ _space_group_symop_operation_xyz x,y,z loop_ _atom_site_label _atom_site_type_symbol _atom_site_fract_x _atom_site_fract_y _atom_site_fract_z _atom_site_occupancy\n""" % (a, b, c, alpha, beta, gamma, cell.get_volume()) symbols = [] for s, p in zip(cell.get_symbols(), cell.get_points().T): symbols.append(s) cif += ("%-7s%2s %10.5f%10.5f%10.5f 1.00000\n" % (s + "%d" % symbols.count(s), s, p[0], p[1], p[2])) if filename is None: return cif else: w = open(filename, 'w') w.write(cif) w.close()
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 print "mesh: [ %d, %d, %d ]" % tuple(imaginary.get_mesh()) print "ratio: %f" % imaginary.get_imaginary_qpoint_ratio()
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) if gruneisen.run(): gruneisen.plot(plt) lattice = gruneisen.get_lattice() print "a, b, c =", get_lattice_parameters(lattice) print "alpha, beta, gamma =", get_angles(lattice) print "mesh (x=%f) =" % distance, gruneisen.get_mesh() gruneisen.save_figure(plt) # plt.show() else: print "Mode Gruneisen parameter calculation failed."
import matplotlib matplotlib.use('Agg') matplotlib.rcParams.update({'figure.figsize': (4.5, 3), 'font.family': 'serif'}) import matplotlib.pyplot as plt 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 = 100 tprops = ThermalProperty(phonon, distance=distance) if tprops.run(): tprops.plot(plt) lattice = tprops.get_lattice() print("a, b, c = %f %f %f" % tuple(get_lattice_parameters(lattice))) print("alpha, beta, gamma = %f %f %f" % tuple(get_angles(lattice))) print("mesh (x=%f) = %s" % (distance, tprops.get_mesh())) tprops.save_figure(plt) else: print "Thermal property calculation failed."