def run_phonolammps(): n = 2 phlammps = Phonolammps('in.graphene', supercell_matrix=[[n, 0, 0], [0, n, 0], [0, 0, n]]) unitcell = phlammps.get_unitcell() force_constants = phlammps.get_force_constants() supercell_matrix = phlammps.get_supercell_matrix() print('unitcell') print('*' * 50) print(unitcell) print('force const') print('*' * 50) print(force_constants) print('supercell') print('*' * 50) print(supercell_matrix) from phonopy import Phonopy phonon = Phonopy(unitcell, supercell_matrix) print(phonon) print(dir(phonon)) phonon.set_force_constants(force_constants) phonon.set_mesh([20, 20, 20]) # phonon.write_yaml_band_structure('band.conf') # phonon.set_band_structure('band.conf') # phonon.plot_band_structure().savefig('band.png') # phonon.set_total_DOS() # phonon.plot_total_DOS().savefig('dos.png') phonon.set_thermal_properties() # print(phonon.get_thermal_properties_dict()) phonon.plot_thermal_properties().savefig('therm.png')
# Simple API example to calculate the harmonic force constants from phonolammps import Phonolammps import numpy as np phlammps = Phonolammps('in.lammps', supercell_matrix=np.diag([3, 3, 3]), primitive_matrix=np.identity(3)) phlammps.plot_phonon_dispersion_bands() force_constants = phlammps.get_force_constants() print(force_constants)
def test_phonolammps(): os.chdir('data') with open('data.si', 'w') as f: f.write('''Generated using dynaphopy 8 atoms 1 atom types 0.0000000000 5.4500000000 xlo xhi 0.0000000000 5.4500000000 ylo yhi 0.0000000000 5.4500000000 zlo zhi 0.0000000000 0.0000000000 0.0000000000 xy xz yz Masses 1 28.0855000000 Atoms 1 1 4.7687500000 4.7687500000 4.7687500000 2 1 4.7687500000 2.0437500000 2.0437500000 3 1 2.0437500000 4.7687500000 2.0437500000 4 1 2.0437500000 2.0437500000 4.7687500000 5 1 0.6812500000 0.6812500000 0.6812500000 6 1 0.6812500000 3.4062500000 3.4062500000 7 1 3.4062500000 0.6812500000 3.4062500000 8 1 3.4062500000 3.4062500000 0.6812500000 ''') with open('si.in', 'w') as f: f.write(''' units metal boundary p p p box tilt large atom_style atomic read_data data.si pair_style tersoff pair_coeff * * SiCGe.tersoff Si(C) neighbor 0.3 bin ''') supercell = [[2, 0, 0], [0, 2, 0], [0, 0, 2]] print(supercell) phlammps = Phonolammps('si.in', supercell_matrix=supercell) print(phlammps) unitcell = phlammps.get_unitcell() force_constants = phlammps.get_force_constants() supercell_matrix = phlammps.get_supercell_matrix() print(unitcell) print(force_constants) print(supercell_matrix) os.chdir('..') return phonon = Phonopy(unitcell, supercell_matrix) phonon.set_force_constants(force_constants) phonon.set_mesh([20, 20, 20]) phonon.set_total_DOS() phonon.plot_total_DOS().show() phonon.set_thermal_properties() phonon.plot_thermal_properties().show()
from dynaphopy.atoms import Structure import numpy as np # calculate harmonic force constants with phonoLAMMPS phlammps = Phonolammps('in.lammps', supercell_matrix=np.diag([2, 2, 2]), primitive_matrix=[[0.0, 0.5, 0.5], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]], ) phlammps.plot_phonon_dispersion_bands() # set force constants for dynaphopy force_constants = ForceConstants(phlammps.get_force_constants(), supercell=phlammps.get_supercell_matrix()) # Print harmonic force constants print('harmonic force constants') print(force_constants.get_array()) structure = phlammps.get_unitcell() # define structure for dynaphopy dp_structure = Structure(cell=structure.get_cell(), # cell_matrix, lattice vectors in rows scaled_positions=structure.get_scaled_positions(), atomic_elements=structure.get_chemical_symbols(), primitive_matrix=phlammps.get_primitve_matrix(), force_constants=force_constants)