コード例 #1
0
    def setup(self):
        """
        Define the current structure in the context to be the input structure.
        """
        self.ctx.current_structure = self.inputs.structure

        inputs = AttributeDict(
            self.exposed_inputs(Wannier90Calculation, namespace='wannier90'))
        parameters = inputs.parameters.get_dict()

        self.ctx.bands_plot = parameters.get('bands_plot', False)
        self.ctx.auto_projections = parameters.get('auto_projections', False)

        # check bands_plot kpoint_path
        if self.ctx.bands_plot:
            kpoint_path = inputs.get('kpoint_path', None)
            if kpoint_path is None:
                self.report(
                    'bands_plot is required but no kpoint_path provided')
                return self.exit_codes.ERROR_SUB_PROCESSS_FAILED_SETUP
コード例 #2
0
    def run_nscf(self):
        """
        Run the PwBaseWorkChain in nscf mode
        """
        inputs = AttributeDict(
            self.exposed_inputs(PwBaseWorkChain, namespace='nscf'))
        inputs.pw.structure = self.ctx.current_structure
        inputs.pw.parent_folder = self.ctx.current_folder
        inputs.pw.parameters = inputs.pw.parameters.get_dict()
        inputs.pw.parameters.setdefault('CONTROL', {})
        inputs.pw.parameters.setdefault('SYSTEM', {})
        inputs.pw.parameters.setdefault('ELECTRONS', {})
        inputs.pw.parameters['CONTROL']['restart_mode'] = 'from_scratch'
        inputs.pw.parameters['CONTROL']['calculation'] = 'nscf'
        inputs.pw.parameters['SYSTEM']['nosym'] = True
        inputs.pw.parameters['SYSTEM']['noinv'] = True
        inputs.pw.parameters['ELECTRONS']['diagonalization'] = 'cg'
        inputs.pw.parameters['ELECTRONS']['diago_full_acc'] = True

        if self.inputs.only_valence:
            inputs.pw.parameters['SYSTEM']['occupations'] = 'fixed'
            inputs.pw.parameters['SYSTEM'].pop(
                'smearing', None)  # pop None to avoid KeyError
            inputs.pw.parameters['SYSTEM'].pop(
                'degauss', None)  # pop None to avoid KeyError

        # inputs.pw.pseudos is an AttributeDict, but calcfunction only accepts
        # orm.Data, so we unpack it to pass in orm.UpfData
        inputs.pw.parameters = update_nscf_num_bands(
            orm.Dict(dict=inputs.pw.parameters),
            self.ctx.workchain_scf.outputs.output_parameters,
            self.ctx.current_structure, self.inputs.only_valence,
            **inputs.pw.pseudos)
        self.report('nscf number of bands set as ' +
                    str(inputs.pw.parameters['SYSTEM']['nbnd']))

        # check kmesh
        try:
            inputs.kpoints
        except AttributeError:
            # then kpoints_distance must exists, since this is ensured by inputs check of this workchain
            from aiida_quantumespresso.workflows.functions.create_kpoints_from_distance import create_kpoints_from_distance
            force_parity = inputs.get('kpoints_force_parity', orm.Bool(False))
            kmesh = create_kpoints_from_distance(self.ctx.current_structure,
                                                 inputs.kpoints_distance,
                                                 force_parity)
            #kpoints_data = orm.KpointsData()
            # kpoints_data.set_cell_from_structure(self.ctx.current_structure)
            # kmesh = kpoints_data.set_kpoints_mesh_from_density(inputs.kpoints_distance.value)
        else:
            try:
                inputs.kpoints.get_kpoints_mesh()
            except AttributeError:
                self.report("nscf only support `mesh' type KpointsData")
                return self.exit_codes.ERROR_SUB_PROCESS_FAILED_NSCF
            else:
                kmesh = inputs.kpoints
        # convert kmesh to explicit list, since auto generated kpoints
        # maybe different between QE & Wannier90. Here we explicitly
        # generate a list of kpoint to avoid discrepencies between
        # QE's & Wannier90's automatically generated kpoints.
        self.ctx.nscf_kmesh = kmesh  # store it since it will be used by w90
        inputs.kpoints = convert_kpoints_mesh_to_list(kmesh)

        inputs = prepare_process_inputs(PwBaseWorkChain, inputs)
        running = self.submit(PwBaseWorkChain, **inputs)

        self.report(
            'nscf step - launching PwBaseWorkChain<{}> in {} mode'.format(
                running.pk, 'nscf'))

        return ToContext(workchain_nscf=running)