Ejemplo n.º 1
0
    def setUp(self):
        self.structure = io.read_from_file_structure_poscar('Si_data/POSCAR')

        self.structure.set_primitive_matrix([[0.0, 0.5, 0.5], [0.5, 0.0, 0.5],
                                             [0.5, 0.5, 0.0]])

        self.structure.set_force_constants(
            get_force_constants_from_file(file_name='Si_data/FORCE_CONSTANTS',
                                          fc_supercell=[[2, 0, 0], [0, 2, 0],
                                                        [0, 0, 2]]))
Ejemplo n.º 2
0
    def setUp(self):
        structure = io.read_from_file_structure_poscar('MgO_data/POSCAR')

        structure.set_primitive_matrix([[0.0, 0.5, 0.5],
                                        [0.5, 0.0, 0.5],
                                        [0.5, 0.5, 0.0]])

        structure.set_force_constants(get_force_constants_from_file(file_name='MgO_data/FORCE_CONSTANTS',
                                                                    fc_supercell=[[2, 0, 0],
                                                                                  [0, 2, 0],
                                                                                  [0, 0, 2]]))

        trajectory = io.generate_test_trajectory(structure, supercell=[2, 2, 2], total_time=5, silent=False)
        self.calculation = dynaphopy.Quasiparticle(trajectory)
Ejemplo n.º 3
0
    def setUp(self):
        self.structure = io.read_from_file_structure_poscar('GaN_data/POSCAR')

        self.structure.set_primitive_matrix([[1.0, 0.0, 0.0],
                                             [0.0, 1.0, 0.0],
                                             [0.0, 0.0, 1.0]])

        self.structure.set_force_constants(get_force_constants_from_file(file_name='GaN_data/FORCE_CONSTANTS',
                                                                         fc_supercell=[[3, 0, 0],
                                                                                       [0, 3, 0],
                                                                                       [0, 0, 3]]))

        if not os.path.exists('test_gan.h5'):

            trajectory = io.generate_test_trajectory(self.structure, supercell=[3, 3, 3], total_time=8, silent=False)
            self.calculation = dynaphopy.Quasiparticle(trajectory)
            self.calculation.save_velocity_hdf5('test_gan.h5', save_trajectory=True)
Ejemplo n.º 4
0
    def setUp(self):
        self.structure = io.read_from_file_structure_poscar('GaN_data/POSCAR')
        self.structure.set_force_constants(
            parse_FORCE_CONSTANTS(filename='GaN_data/FORCE_CONSTANTS'))

        self.structure.set_primitive_matrix([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0],
                                             [0.0, 0.0, 1.0]])
        self.structure.set_supercell_phonon([[3, 0, 0], [0, 3, 0], [0, 0, 3]])

        if not os.path.exists('test_gan.h5'):

            trajectory = io.generate_test_trajectory(self.structure,
                                                     supercell=[3, 3, 3],
                                                     total_time=8,
                                                     silent=False)
            self.calculation = dynaphopy.Quasiparticle(trajectory)
            self.calculation.save_velocity_hdf5('test_gan.h5',
                                                save_trajectory=True)
Ejemplo n.º 5
0
#!/usr/bin/env python

import numpy as np
import phonopy.file_IO as file_IO
import dynaphopy.interface.iofile as reading
import dynaphopy.classes.controller as controller

##################################  STRUCTURE FILES #######################################
# 1. Set the directory in where the FORCE_SETS and structure OUTCAR are placed
# FORCE_SETS : force set file obtained from PHONOPY calculation
# OUTCAR : Single Point calculation of the unit cell structure used in PHONOPY calculation

directory ='/home/abel/VASP/Si-phonon/4x4x4B/'

structure = reading.read_from_file_structure_poscar(directory+'POSCAR')
structure.set_force_set(file_IO.parse_FORCE_SETS(filename=directory+'FORCE_SETS'))


############################### PHONOPY CELL INFORMATION ####################################
# 2. Set primitive matrix, this matrix fulfills that:
#    Primitive_cell = Unit_cell x Primitive_matrix
#    This matrix is the same needed for PHONOPY calculation

structure.set_primitive_matrix([[0.5, 0.0, 0.0],
                                [0.0, 0.5, 0.0],
                                [0.0, 0.0, 0.5]])



# 3. Set super cell phonon, this matrix denotes the super cell used in PHONOPY for creating
# the finite displacements
Ejemplo n.º 6
0
                                     eigenvectors)
    dynmat2fc.run()

    force_constants = ForceConstants(dynmat2fc.get_force_constants(),
                                     supercell=fc_supercell)

    # Symmetrize force constants using crystal symmetry
    if symmetrize:
        print('Symmetrizing force constants')
        set_tensor_symmetry_PJ(force_constants.get_array(),
                               phonon.supercell.get_cell().T,
                               phonon.supercell.get_scaled_positions(),
                               phonon.symmetry)

    return force_constants


if __name__ == "__main__":

    import dynaphopy.interface.iofile as reading
    input_parameters = reading.read_parameters_from_input_file(
        '/home/abel/VASP/Ag2Cu2O4/MD/input_dynaphopy')
    structure = reading.read_from_file_structure_poscar(
        input_parameters['structure_file_name_poscar'])
    structure.set_primitive_matrix(input_parameters['_primitive_matrix'])
    # structure.set_supercell_phonon(input_parameters['_supercell_phonon'])
    structure.set_force_set(
        get_force_sets_from_file(
            file_name=input_parameters['force_constants_file_name']))
    obtain_phonopy_dos(structure)
Ejemplo n.º 7
0
#!/usr/bin/env python

import numpy as np
import phonopy.file_IO as file_IO
import dynaphopy.interface.iofile as io
import dynaphopy.interface.iofile.trajectory_parsers as parsers
import dynaphopy

from dynaphopy.interface.phonopy_link import get_force_sets_from_file, get_force_constants_from_file

##################################  STRUCTURE FILES #######################################
# 1. Set the directory in where the FORCE_SETS and structure POSCAR are placed

directory = '/home/abel/VASP/Si/Si-FINAL3/PHONON/2x2x2/'
structure = io.read_from_file_structure_poscar(directory + 'POSCAR')

############################### PHONOPY CELL INFORMATION ####################################
# 2. Set primitive matrix that defines the primitive cell respect the unit cell
structure.set_primitive_matrix([[0.0, 0.5, 0.5], [0.5, 0.0, 0.5],
                                [0.5, 0.5, 0.0]])

# 3. Set the hamonic phonon data (input for phonopy)
# fs_supercell: supercell matrix used in PHONOPY to obtain the force_sets
# FORCE_SETS : force set file obtained from PHONOPY calculation that contains the forces
structure.set_force_set(
    get_force_sets_from_file(file_name=directory + 'FORCE_SETS',
                             fs_supercell=[[2, 0, 0], [0, 2, 0], [0, 0, 2]]))

# Alternatively get_force_constants_from_file function can be used to obtain the harmonic information.
# Check unittest files (unittest folder)
Ejemplo n.º 8
0
    def __init__(self, args, load_data=False, verbose=False, tmin=None):

        input_parameters = reading.read_parameters_from_input_file(
            args.input_file)

        if 'structure_file_name_outcar' in input_parameters:
            structure = reading.read_from_file_structure_outcar(
                input_parameters['structure_file_name_outcar'])
        else:
            structure = reading.read_from_file_structure_poscar(
                input_parameters['structure_file_name_poscar'])

        structure.get_data_from_dict(input_parameters)

        if 'supercell_phonon' in input_parameters:
            supercell_phonon = input_parameters['supercell_phonon']
        else:
            supercell_phonon = np.identity(3)

        structure.set_force_constants(
            get_force_constants_from_file(
                file_name=input_parameters['force_constants_file_name'],
                fc_supercell=supercell_phonon))

        if '_mesh_phonopy' in input_parameters:
            mesh = input_parameters['_mesh_phonopy']
        else:
            mesh = [20, 20, 20]  # Default
            print('mesh set to: {}'.format(mesh))

        if 'bands' in input_parameters is None:
            self._bands = structure.get_path_using_seek_path()
        else:
            self._bands = input_parameters['_band_ranges']

        volumes, energies = read_v_e(args.ev,
                                     factor=1.0,
                                     volume_factor=1.0,
                                     pressure=args.pressure)

        self._fc_fit = ForceConstantsFitting(
            structure,
            files_temperature=args.ct_data,
            files_volume=args.cv_data,
            temperatures=args.temperatures,
            volumes=volumes,
            mesh=mesh,
            ref_temperature=args.ref_temperature,
            fitting_order=args.order,
            tmin=tmin,
            use_NAC=True)

        if not load_data:
            temperatures = self._fc_fit.get_temperature_range()

            free_energy = []
            entropy = []
            cv = []
            for v, e in zip(volumes, energies):
                print('Volume: {} Ang.      Energy(U): {} eV'.format(v, e))
                tp_data = self._fc_fit.get_thermal_properties(volume=v)
                free_energy.append(tp_data[0])
                entropy.append(tp_data[1])
                cv.append(tp_data[2])

            free_energy = np.array(free_energy).T
            entropy = np.array(entropy).T
            cv = np.array(cv).T

            np.save('free_energy.npy', free_energy)
            np.save('temperatures.npy', temperatures)
            np.save('cv.npy', cv)
            np.save('entropy.npy', entropy)
        else:
            free_energy = np.load('free_energy.npy')
            temperatures = np.load('temperatures.npy')
            cv = np.load('cv.npy')
            entropy = np.load('entropy.npy')

        self.phonopy_qha = PhonopyQHA(
            volumes,
            energies,
            eos="vinet",  # options: 'vinet', 'murnaghan' or 'birch_murnaghan'
            temperatures=temperatures,
            free_energy=free_energy,
            cv=cv,
            entropy=entropy,
            t_max=self.fc_fit.get_temperature_range()[-1],
            verbose=False)

        # Write data files to disk
        self.phonopy_qha.write_bulk_modulus_temperature()
        self.phonopy_qha.write_gibbs_temperature()
        self.phonopy_qha.write_heat_capacity_P_numerical()
        self.phonopy_qha.write_gruneisen_temperature()
        self.phonopy_qha.write_thermal_expansion()
        self.phonopy_qha.write_helmholtz_volume()
        self.phonopy_qha.write_volume_expansion()
        self.phonopy_qha.write_volume_temperature()

        if verbose:
            self.phonopy_qha.plot_qha().show()
Ejemplo n.º 9
0
    def __init__(self, args, load_data=False, verbose=False, tmin=None):

        input_parameters = reading.read_parameters_from_input_file(args.input_file)

        if 'structure_file_name_outcar' in input_parameters:
            structure = reading.read_from_file_structure_outcar(input_parameters['structure_file_name_outcar'])
        else:
            structure = reading.read_from_file_structure_poscar(input_parameters['structure_file_name_poscar'])

        structure.get_data_from_dict(input_parameters)

        if 'supercell_phonon' in input_parameters:
            supercell_phonon = input_parameters['supercell_phonon']
        else:
            supercell_phonon = np.identity(3)

        structure.set_force_constants(get_force_constants_from_file(file_name=input_parameters['force_constants_file_name'],
                                                                    fc_supercell=supercell_phonon))

        if '_mesh_phonopy' in input_parameters:
            mesh = input_parameters['_mesh_phonopy']
        else:
            mesh = [20, 20, 20] # Default
            print ('mesh set to: {}'.format(mesh))

        if 'bands' in input_parameters is None:
            self._bands =  structure.get_path_using_seek_path()
        else:
            self._bands = input_parameters['_band_ranges']

        volumes, energies = read_v_e(args.ev, factor=1.0, volume_factor=1.0, pressure=args.pressure)

        self._fc_fit = ForceConstantsFitting(structure,
                                       files_temperature=args.ct_data,
                                       files_volume=args.cv_data,
                                       temperatures=args.temperatures,
                                       volumes=volumes,
                                       mesh=mesh,
                                       ref_temperature=args.ref_temperature,
                                       fitting_order=args.order,
                                       tmin=tmin,
                                       use_NAC=True)

        if not load_data:
            temperatures = self._fc_fit.get_temperature_range()

            free_energy = []
            entropy = []
            cv = []
            for v, e in zip(volumes, energies):
                print ('Volume: {} Ang.      Energy(U): {} eV'.format(v, e))
                tp_data = self._fc_fit.get_thermal_properties(volume=v)
                free_energy.append(tp_data[0])
                entropy.append(tp_data[1])
                cv.append(tp_data[2])

            free_energy = np.array(free_energy).T
            entropy = np.array(entropy).T
            cv = np.array(cv).T

            np.save('free_energy.npy', free_energy)
            np.save('temperatures.npy', temperatures)
            np.save('cv.npy', cv)
            np.save('entropy.npy', entropy)
        else:
            free_energy = np.load('free_energy.npy')
            temperatures = np.load('temperatures.npy')
            cv = np.load('cv.npy')
            entropy = np.load('entropy.npy')

        self.phonopy_qha = PhonopyQHA(volumes,
                                 energies,
                                 eos="vinet",  # options: 'vinet', 'murnaghan' or 'birch_murnaghan'
                                 temperatures=temperatures,
                                 free_energy=free_energy,
                                 cv=cv,
                                 entropy=entropy,
                                 t_max=self.fc_fit.get_temperature_range()[-1],
                                 verbose=False)

        # Write data files to disk
        self.phonopy_qha.write_bulk_modulus_temperature()
        self.phonopy_qha.write_gibbs_temperature()
        self.phonopy_qha.write_heat_capacity_P_numerical()
        self.phonopy_qha.write_gruneisen_temperature()
        self.phonopy_qha.write_thermal_expansion()
        self.phonopy_qha.write_helmholtz_volume()
        self.phonopy_qha.write_volume_expansion()
        self.phonopy_qha.write_volume_temperature()

        if verbose:
            self.phonopy_qha.plot_qha().show()
Ejemplo n.º 10
0
    size = structure.get_number_of_dimensions() * structure.get_number_of_primitive_atoms()
    eigenvectors = np.array([eigenvector.reshape(size, size, order='C').T for eigenvector in eigenvectors ])
    renormalized_frequencies = np.array(renormalized_frequencies)

    dynmat2fc.set_dynamical_matrices(renormalized_frequencies / VaspToTHz, eigenvectors)
    dynmat2fc.run()

    force_constants = ForceConstants(dynmat2fc.get_force_constants(), supercell=fc_supercell)

    # Symmetrize force constants using crystal symmetry
    if symmetrize:
        print('Symmetrizing force constants')
        set_tensor_symmetry_PJ(force_constants.get_array(),
                               phonon.supercell.get_cell(),
                               phonon.supercell.get_scaled_positions(),
                               phonon.symmetry)

    return force_constants


if __name__ == "__main__":

    import dynaphopy.interface.iofile as reading
    input_parameters = reading.read_parameters_from_input_file('/home/abel/VASP/Ag2Cu2O4/MD/input_dynaphopy')
    structure = reading.read_from_file_structure_poscar(input_parameters['structure_file_name_poscar'])
    structure.set_primitive_matrix(input_parameters['_primitive_matrix'])
    # structure.set_supercell_phonon(input_parameters['_supercell_phonon'])
    structure.set_force_set(get_force_sets_from_file(file_name=input_parameters['force_constants_file_name']))
    obtain_phonopy_dos(structure)