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')
def get_phonon_analyzer_from_lammps_static( lammps_static: LammpsStatic, supercell_matrix: np.array, primitive_matrix: np.array = np.identity(3), original_cell: tuple = None, no_standardize: bool = False, ): """ Get phonon analyzer from lammps. Args: lammps_static: LammpsStatic class object. original_cell: Original cell. no_standardize: See docstring in RelaxAnalyzer. If no_standardize is True, input 'original_cell' is ignored and original_cell and input_cell becomes identical. """ rlx_analyzer = get_relax_analyzer_from_lammps_static( lammps_static=lammps_static, original_cell=original_cell, no_standardize=no_standardize, ) ph_lammps_input = lammps_static.get_lammps_input_for_phonolammps() ph_lmp = Phonolammps(lammps_input=ph_lammps_input, supercell_matrix=supercell_matrix, primitive_matrix=primitive_matrix) phonon = get_phonon_from_phonolammps(ph_lmp) ph_analyzer = PhononAnalyzer(phonon=phonon, relax_analyzer=rlx_analyzer) return ph_analyzer
def get_phonon_analyzer_from_lammps( cell, pair_style: str, supercell_matrix, pair_coeff: str = None, pot_file: str = None, is_relax_lattice: bool = False, is_relax_z: bool = False, ): lmp_stc = get_lammps_relax( cell=cell, pair_style=pair_style, pair_coeff=pair_coeff, pot_file=pot_file, is_relax_lattice=is_relax_lattice, is_relax_z=is_relax_z, run_lammps=True, ) rlx_analyzer = get_relax_analyzer_from_lammps_static( lammps_static=lmp_stc, original_cell=None, no_standardize=True, ) ph_lammps_input = lmp_stc.get_lammps_input_for_phonolammps() ph_lmp = Phonolammps(lammps_input=ph_lammps_input, supercell_matrix=supercell_matrix, primitive_matrix=np.identity(3)) phonon = get_phonon_from_phonolammps(ph_lmp) ph_analyzer = PhononAnalyzer(phonon=phonon, relax_analyzer=rlx_analyzer) return ph_analyzer
# 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)
# Integration with phonopy from phonolammps import Phonolammps from phonopy import Phonopy phlammps = Phonolammps('in.lammps', supercell_matrix=[[3, 0, 0], [0, 3, 0], [0, 0, 3]]) unitcell = phlammps.get_unitcell() force_constants = phlammps.get_force_constants() supercell_matrix = phlammps.get_supercell_matrix() 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()
# API example to calculate finite temperature (300K) force constants # using dynaphopy (quasiparticle theory) from phonolammps import Phonolammps from dynaphopy.interface.lammps_link import generate_lammps_trajectory from dynaphopy.interface.phonopy_link import ForceConstants from dynaphopy import Quasiparticle 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() force_constants = phlammps.get_force_constants() # Print harmonic force constants print('harmonic force constants') print(force_constants) structure = phlammps.get_unitcell() # define structure for dynaphopy dp_structure = Structure( cell=structure.get_cell(), # cell_matrix, lattice vectors in rows
new_target = open(os.devnull, "w") old_target, sys.stdout = sys.stdout, new_target try: yield new_target finally: sys.stdout = old_target # input parameters supercell = [2, 2, 2] primitive_mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] temperature = 800 # calculate harmonic force constants with phonolammps phlammps = Phonolammps('in.lammps', supercell_matrix=np.diag(supercell), primitive_matrix=primitive_mat) force_constants = phlammps.get_force_constants() unitcell = phlammps.get_unitcell() structure = Structure( cell=unitcell.get_cell(), # cell_matrix, lattice vectors in rows scaled_positions=unitcell.get_scaled_positions(), atomic_elements=unitcell.get_chemical_symbols(), primitive_matrix=primitive_mat) structure.set_force_constants( ForceConstants(force_constants, supercell=np.diag(supercell))) # generate LAMMPS MD trajectory (requires dynaphopy development)
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()