示例#1
0
    def prepare_extra_files(self, tempfolder, potential_object):

        if 'fore_constants' in self.inputs:
            force_constants = self.inputs.force_constants
        else:
            force_constants = None

        if 'fore_constants' in self.inputs:
            force_sets = self.inputs.force_sets
        else:
            force_sets = None

        cell_txt = get_poscar_txt(self.inputs.structure)

        cell_filename = tempfolder(self._POSCAR_NAME)
        with open(cell_filename, 'w') as infile:
            infile.write(cell_txt)

        if force_constants is not None:
            force_constants_txt = get_FORCE_CONSTANTS_txt(force_constants)
            force_constants_filename = tempfolder.get_abs_path(
                self._INPUT_FORCE_CONSTANTS)
            with open(force_constants_filename, 'w') as infile:
                infile.write(force_constants_txt)

        elif force_sets is not None:
            force_sets_txt = get_FORCE_SETS_txt(force_sets)
            force_sets_filename = tempfolder.get_abs_path(
                self._INPUT_FORCE_SETS)
            with open(force_sets_filename, 'w') as infile:
                infile.write(force_sets_txt)
        else:
            raise InputValidationError(
                "no force_sets nor force_constants are specified for this calculation"
            )

        try:
            parameters_data_dynaphopy = Dict.pop(
                self.get_linkname('parameters_dynaphopy'))
        except KeyError:
            raise InputValidationError(
                "No dynaphopy parameters specified for this calculation")

        parameters_dynaphopy_txt = generate_dynaphopy_input(
            parameters_data_dynaphopy,
            poscar_name=self._POSCAR_NAME,
            force_constants_name=self._INPUT_FORCE_CONSTANTS,
            force_sets_filename=self._INPUT_FORCE_SETS,
            use_sets=force_sets is not None)

        dynaphopy_filename = tempfolder.get_abs_path(
            self._INPUT_FILE_NAME_DYNA)
        with open(dynaphopy_filename, 'w') as infile:
            infile.write(parameters_dynaphopy_txt)

        md_supercell = parameters_data_dynaphopy.dict.md_supercell

        time_step = self._parameters_data.dict.timestep
        equilibrium_time = self._parameters_data.dict.equilibrium_steps * time_step
        total_time = self._parameters_data.dict.total_steps * time_step

        self._cmdline_params = [
            self._INPUT_FILE_NAME_DYNA,
            '--run_lammps',
            self._INPUT_FILE_NAME,
            '{}'.format(total_time),
            '{}'.format(time_step),
            '{}'.format(equilibrium_time),
            '--dim',
            '{}'.format(md_supercell[0]),
            '{}'.format(md_supercell[1]),
            '{}'.format(md_supercell[2]),
            '--silent',
            '-sfc',
            self._OUTPUT_FORCE_CONSTANTS,
            '-thm',  # '--resolution 0.01',
            '-psm',
            '2',
            '--normalize_dos',
            '-sdata',
            '--velocity_only',
            '--temperature',
            '{}'.format(self._parameters_data.dict.temperature)
        ]

        if 'md_commensurate' in parameters_data_dynaphopy.get_dict():
            if parameters_data_dynaphopy.dict.md_commensurate:
                self._cmdline_params.append('--MD_commensurate')
示例#2
0
    def _prepare_for_submission(self, tempfolder, inputdict):
        """
        This is the routine to be called when you want to create
        the input files and related stuff with a plugin.

        :param tempfolder: a aiida.common.folders.Folder subclass where
                           the plugin should put all its files.
        :param inputdict: a dictionary with the input nodes, as they would
                be returned by get_inputdata_dict (without the Code!)
        """

        try:
            parameters_data = inputdict.pop(self.get_linkname('parameters'))
        except KeyError:
            pass
            #raise InputValidationError("No parameters specified for this "
            #                           "calculation")
        if not isinstance(parameters_data, ParameterData):
            raise InputValidationError("parameters is not of type "
                                       "ParameterData")

        try:
            structure = inputdict.pop(self.get_linkname('structure'))
        except KeyError:
            raise InputValidationError(
                "no structure is specified for this calculation")

        try:
            trajectory = inputdict.pop(self.get_linkname('trajectory'))
        except KeyError:
            raise InputValidationError(
                "trajectory is specified for this calculation")

        try:
            force_constants = inputdict.pop(
                self.get_linkname('force_constants'))
        except KeyError:
            raise InputValidationError(
                "no force_constants is specified for this calculation")

        try:
            code = inputdict.pop(self.get_linkname('code'))
        except KeyError:
            raise InputValidationError(
                "no code is specified for this calculation")

        time_step = trajectory.get_times()[1] - trajectory.get_times()[0]

        ##############################
        # END OF INITIAL INPUT CHECK #
        ##############################

        # =================== prepare the python input files =====================

        cell_txt = get_poscar_txt(structure)
        input_txt = parameters_to_input_file(parameters_data)
        force_constants_txt = get_FORCE_CONSTANTS_txt(force_constants)
        trajectory_txt = get_trajectory_txt(trajectory)

        # =========================== dump to file =============================

        input_filename = tempfolder.get_abs_path(self._INPUT_FILE_NAME)
        with open(input_filename, 'w') as infile:
            infile.write(input_txt)

        cell_filename = tempfolder.get_abs_path(self._INPUT_CELL)
        with open(cell_filename, 'w') as infile:
            infile.write(cell_txt)

        force_constants_filename = tempfolder.get_abs_path(
            self._INPUT_FORCE_CONSTANTS)
        with open(force_constants_filename, 'w') as infile:
            infile.write(force_constants_txt)

        trajectory_filename = tempfolder.get_abs_path(self._INPUT_TRAJECTORY)
        with open(trajectory_filename, 'w') as infile:
            infile.write(trajectory_txt)

        # ============================ calcinfo ================================

        local_copy_list = []
        remote_copy_list = []
        #    additional_retrieve_list = settings_dict.pop("ADDITIONAL_RETRIEVE_LIST",[])

        calcinfo = CalcInfo()

        calcinfo.uuid = self.uuid
        # Empty command line by default
        calcinfo.local_copy_list = local_copy_list
        calcinfo.remote_copy_list = remote_copy_list

        # Retrieve files
        calcinfo.retrieve_list = [
            self._OUTPUT_FILE_NAME, self._OUTPUT_FORCE_CONSTANTS,
            self._OUTPUT_QUASIPARTICLES
        ]

        codeinfo = CodeInfo()
        codeinfo.cmdline_params = [
            self._INPUT_FILE_NAME,
            self._INPUT_TRAJECTORY,
            '-ts',
            '{}'.format(time_step),
            '--silent',
            '-sfc',
            self._OUTPUT_FORCE_CONSTANTS,
            '-thm',  # '--resolution 0.01',
            '-psm',
            '2',
            '--normalize_dos',
            '-sdata'
        ]

        if 'temperature' in parameters_data.get_dict():
            codeinfo.cmdline_params.append('--temperature')
            codeinfo.cmdline_params.append('{}'.format(
                parameters_data.dict.temperature))

        if 'md_commensurate' in parameters_data.get_dict():
            if parameters_data.dict.md_commensurate:
                codeinfo.cmdline_params.append('--MD_commensurate')

        codeinfo.stdout_name = self._OUTPUT_FILE_NAME
        codeinfo.code_uuid = code.uuid
        codeinfo.withmpi = False
        calcinfo.codes_info = [codeinfo]
        return calcinfo
示例#3
0
    def _prepare_for_submission(self, tempfolder, inputdict):
        """
        This is the routine to be called when you want to create
        the input files and related stuff with a plugin.
        :param tempfolder: a aiida.common.folders.Folder subclass where
                           the plugin should put all its files.
        :param inputdict: a dictionary with the input nodes, as they would
                be returned by get_inputdata_dict (without the Code!)
        """

        try:
            parameters_data = inputdict[self.get_linkname('parameters')]
        except KeyError:
            raise InputValidationError(
                "No parameters specified for this calculation")

        try:
            structure = inputdict[self.get_linkname('structure')]
        except KeyError:
            raise InputValidationError(
                "no structure is specified for this calculation")

        try:
            code = inputdict.pop(self.get_linkname('code'))
        except KeyError:
            raise InputValidationError(
                "no code is specified for this calculation")

        nac_data = inputdict.pop(self.get_linkname('nac_data'), None)
        bands = inputdict.pop(self.get_linkname('bands'), None)

        ##############################
        # END OF INITIAL INPUT CHECK #
        ##############################

        # =================== prepare the python input files =====================

        self._create_additional_files(tempfolder, inputdict)

        cell_txt = get_poscar_txt(structure)
        input_txt = get_phonopy_conf_file_txt(parameters_data, bands=bands)

        input_filename = tempfolder.get_abs_path(self._INPUT_FILE_NAME)
        with open(input_filename, 'w') as infile:
            infile.write(input_txt)

        cell_filename = tempfolder.get_abs_path(self._INPUT_CELL)
        with open(cell_filename, 'w') as infile:
            infile.write(cell_txt)

        if nac_data is not None:
            born_txt = get_BORN_txt(nac_data,
                                    structure=structure,
                                    parameters=parameters_data)
            nac_filename = tempfolder.get_abs_path(self._INPUT_NAC)
            with open(nac_filename, 'w') as infile:
                infile.write(born_txt)
            self._additional_cmdline_params += ['--nac']

        # ============================ calcinfo ================================

        local_copy_list = []
        remote_copy_list = []
        #    additional_retrieve_list = settings_dict.pop("ADDITIONAL_RETRIEVE_LIST",[])

        calcinfo = CalcInfo()

        calcinfo.uuid = self.uuid

        # Empty command line by default
        calcinfo.local_copy_list = local_copy_list
        calcinfo.remote_copy_list = remote_copy_list

        # Retrieve files
        calcinfo.retrieve_list = self._internal_retrieve_list

        calcinfo.codes_info = []
        for property_cmd in self._calculation_cmd:
            codeinfo = CodeInfo()
            codeinfo.cmdline_params = [
                self._INPUT_FILE_NAME
            ] + self._additional_cmdline_params + property_cmd
            codeinfo.code_uuid = code.uuid
            codeinfo.withmpi = False
            calcinfo.codes_info += [codeinfo]

        return calcinfo
示例#4
0
    def prepare_for_submission(self, folder):
        """Create the input files from the input nodes passed to this instance of the `CalcJob`.

        :param folder: an `aiida.common.folders.Folder` to temporarily write files on disk
        :return: `aiida.common.datastructures.CalcInfo` instance
        """

        self.logger.info("prepare_for_submission")

        self._internal_retrieve_list = []
        self._additional_cmd_params = []
        self._calculation_cmd = []

        settings = self.inputs.settings
        structure = self.inputs.structure
        code = self.inputs.code

        ##############################
        # END OF INITIAL INPUT CHECK #
        ##############################

        # ================= prepare the python input files =================

        self._create_additional_files(folder)

        cell_txt = get_poscar_txt(structure)
        input_txt = get_phonopy_conf_file_txt(settings)

        input_filename = folder.get_abs_path(
            self.inputs.metadata.options.input_filename)
        with open(input_filename, 'w') as infile:
            infile.write(input_txt)

        cell_filename = folder.get_abs_path(self._INPUT_CELL)
        with open(cell_filename, 'w') as infile:
            infile.write(cell_txt)

        if ('nac_params' in self.inputs and 'primitive' in self.inputs):
            born_txt = get_BORN_txt(self.inputs.nac_params,
                                    self.inputs.primitive,
                                    settings['symmetry_tolerance'])

            nac_filename = folder.get_abs_path(self._INPUT_NAC)
            with open(nac_filename, 'w') as infile:
                infile.write(born_txt)
            for params in self._additional_cmd_params:
                params.append('--nac')

        # ============================ calcinfo ===============================

        local_copy_list = []
        remote_copy_list = []

        calcinfo = CalcInfo()

        calcinfo.uuid = self.uuid

        # Empty command line by default
        calcinfo.local_copy_list = local_copy_list
        calcinfo.remote_copy_list = remote_copy_list

        # Retrieve files
        calcinfo.retrieve_list = self._internal_retrieve_list

        calcinfo.codes_info = []
        for default_params, additional_params in zip(
                self._calculation_cmd, self._additional_cmd_params):
            codeinfo = CodeInfo()
            codeinfo.cmdline_params = ([
                self.inputs.metadata.options.input_filename,
            ] + default_params + additional_params)
            codeinfo.code_uuid = code.uuid
            codeinfo.stdout_name = self.inputs.metadata.options.output_filename
            codeinfo.withmpi = False
            calcinfo.codes_info.append(codeinfo)

        return calcinfo
ph_settings = wc.inp.ph_settings

supercell = get_supercell(phonopy_bulk_from_structure(structure),
                          ph_settings.dict.supercell,
                          symprec=ph_settings.dict.symmetry_precision)

write_disp_fc3_yaml(force_sets.get_data_sets3(),
                    supercell,
                    filename='disp_fc3.yaml')

write_FORCES_FC3(force_sets.get_data_sets3(),
                 force_sets.get_forces3(),
                 filename='FORCES_FC3')

with open('POSCAR-unitcell', mode='w') as f:
    f.writelines(get_poscar_txt(structure))

if 'nac_data' in wc.get_outputs_dict():
    nac_data = wc.out.nac_data
    print('Writing BORN file')
    with open('BORN', mode='w') as f:
        f.writelines(
            get_BORN_txt(nac_data, structure=structure,
                         parameters=ph_settings))

if 'force_constants_2order' and 'force_constants_3order' in wc.get_outputs_dict(
):
    from phono3py.file_IO import write_fc2_to_hdf5, write_fc3_to_hdf5

    print('Writing FC2 and FC3 into HDF5 files')
    fc2 = wc.out.force_constants_2order.get_data()