예제 #1
0
    def __init__(self,
                 txyz_input_file,
                 key_input_file,
                 force_field_file,
                 supercell_matrix=np.identity(3),
                 primitive_matrix=np.identity(3),
                 displacement_distance=0.01,
                 show_log=False,
                 show_progress=False,
                 use_NAC=False,
                 symmetrize=True):
        """
        Experimental class to use Tinker to calculate forces, can be used
        as an example to how to expand phonoLAMMPS to other software

        :param txyz_input_file:  TXYZ input file name (see example)
        :param supercell_matrix:  3x3 matrix supercell
        :param primitive cell:  3x3 matrix primitive cell
        :param displacement_distance: displacement distance in Angstroms
        :param show_log: set true to display lammps log info
        :param show_progress: set true to display progress of calculation
        :param use_NAC: set true to use Non-Analytical corrections or not
        :param symmetrize: set true to use symmetrization of the force constants
        """

        self._structure = get_structure_from_txyz(txyz_input_file,
                                                  key_input_file)
        self._txyz_input_file = txyz_input_file

        self._supercell_matrix = supercell_matrix
        self._primitive_matrix = primitive_matrix
        self._displacement_distance = displacement_distance
        self._show_log = show_log
        self._show_progress = show_progress
        self._symmetrize = symmetrize
        self._NAC = use_NAC

        self._force_constants = None
        self._data_set = None

        self.units = 'tinker'

        self.force_field = force_field_file

        if not self.units in unit_factors.keys():
            print('Units style not supported, use: {}'.format(
                unit_factors.keys()))
            exit()
예제 #2
0
            print(err)
            print('Something wrong in forces calculation!')
            exit()

        # print(output)
        os.unlink(tinker_input_file.name)
        os.unlink(tinker_key_file.name)

        forces = parse_tinker_forces(output) * unit_factors[self.units]

        return forces


if __name__ == '__main__':

    structure = get_structure_from_txyz('structure_wrap_min.txyz', 'structure.key')
    print(structure)
    print(structure.get_connectivity())
    print(generate_VASP_structure(structure))
    print(structure.get_scaled_positions())
    print(structure.get_chemical_symbols())

    phonon = get_phonon(structure,
                        setup_forces=False,
                        super_cell_phonon=[[2, 0, 0], [0, 2, 0], [0, 0, 2]],
                        NAC=False,
                        symmetrize=True)


    phonon.get_displacement_dataset()
    phonon.generate_displacements(distance=0.0001)