def phonon_dos(fcp_file): if 'fcc2x2x2' in fcp_file: prim = read(ref_fcc_conv2x2x2) else: prim = read(ref_fcc) fcp = ForceConstantPotential.read(fcp_file) mesh = [33, 33, 33] atoms_phonopy = PhonopyAtoms(symbols=prim.get_chemical_symbols(), scaled_positions=prim.get_scaled_positions(), cell=prim.cell) phonopy = Phonopy(atoms_phonopy, supercell_matrix=5 * np.eye(3), primitive_matrix=None) supercell = phonopy.get_supercell() supercell = Atoms(cell=supercell.cell, numbers=supercell.numbers, pbc=True, scaled_positions=supercell.get_scaled_positions()) fcs = fcp.get_force_constants(supercell) phonopy.set_force_constants(fcs.get_fc_array(order=2)) phonopy.set_mesh(mesh, is_eigenvectors=True, is_mesh_symmetry=False) phonopy.run_total_dos() phonopy.plot_total_DOS() plt.savefig("phononDOS.png", dpi=200) Nq = 51 G2X = get_band(np.array([0, 0, 0]), np.array([0.5, 0.5, 0]), Nq) X2K2G = get_band(np.array([0.5, 0.5, 1.0]), np.array([0, 0, 0]), Nq) G2L = get_band(np.array([0, 0, 0]), np.array([0.5, 0.5, 0.5]), Nq) bands = [G2X, X2K2G, G2L] phonopy.set_band_structure(bands) phonopy.plot_band_structure() xticks = plt.gca().get_xticks() xticks = [x * hbar * 1e15 for x in xticks] # Convert THz to meV # plt.gca().set_xticks(xticks) plt.gca().set_xlabel("Frequency (THz)") plt.savefig("phononBand.png", dpi=200) phonopy.run_thermal_properties(t_step=10, t_max=800, t_min=100) tp_dict = phonopy.get_thermal_properties_dict() temperatures = tp_dict['temperatures'] free_energy = tp_dict['free_energy'] fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.plot(temperatures, free_energy) plt.show()
def md_calculation(fcp_file): from ase import units from ase.io.trajectory import Trajectory from ase.md.velocitydistribution import MaxwellBoltzmannDistribution from ase.md.langevin import Langevin from ase.md import MDLogger if 'fcc' in fcp_file: ref_cell = read(ref_fcc) P = np.array([[-1, 1, 1], [1, -1, 1], [1, 1, -1]]) P *= 3 atoms = make_supercell(ref_cell, P) else: raise ValueError("Unknown phase") fcp = ForceConstantPotential.read(fcp_file) fcs = fcp.get_force_constants(atoms) calc = ForceConstantCalculator(fcs) atoms.set_calculator(calc) temperature = 200 number_of_MD_steps = 100 time_step = 5 # in fs dump_interval = 10 traj_file = "data/md_" + fcp_file.split('.')[0] + '{}.traj'.format( temperature) log_file = "data/md_log_{}.log".format(temperature) dyn = Langevin(atoms, time_step * units.fs, temperature * units.kB, 0.02) logger = MDLogger(dyn, atoms, log_file, header=True, stress=False, peratom=True, mode='w') traj_writer = Trajectory(traj_file, 'w', atoms) dyn.attach(logger, interval=dump_interval) dyn.attach(traj_writer.write, interval=dump_interval) # run MD MaxwellBoltzmannDistribution(atoms, temperature * units.kB) dyn.run(number_of_MD_steps)