Example #1
0
 def run_task(self, fw_spec):
     #workdir=fw_spec['workdir']
     vasp_cmd = fw_spec['vasp_cmd']
     #with cd(workdir):
     incar = Incar.from_file('INCAR')
     kpoints = Kpoints.from_file('KPOINTS')
     poscar = Poscar.from_file('POSCAR')
     potcar = Potcar.from_file('POTCAR')
     try:
         out = Outcar(work_dir + '/OUTCAR')
         if len(out.run_stats) != 7:
             raise VaspDoneError()
     except:
         try:
             contcar = Structure.from_file('CONTCAR')
             os.rename('CONTCAR', 'POSCAR')
         except:
             pass
         job = VaspJob(vasp_cmd)
         handlers=[VaspErrorHandler(),UnconvergedErrorHandler(),FrozenJobErrorHandler(),\
                   NonConvergingErrorHandler(nionic_steps=2, change_algo=True),MeshSymmetryErrorHandler()]
         c = Custodian(handlers, [job], max_errors=10)
         c.run()
     else:
         print 'Vasp job was already done well. No need to rerun!'
Example #2
0
 def run_task(self, fw_spec):
     task_id = fw_spec['task_id']
     initial_struct = fw_spec['initial_struct']
     charge = fw_spec['charge']
     site = fw_spec['site']
     s = fw_spec['s']
     hse = fw_spec['hse']
     ####----------------initialization over-------------
     dict_transf = {
         'history': [{
             'source': task_id
         }],
         'compo': initial_struct.composition.as_dict(),
         'defect_type': site['short_name'],
         'defect_site': site['unique_sites'].as_dict(),
         'charge': charge,
         'supercell': s['size']
     }
     dict_params = MPRelaxSet(s['structure']).all_input
     incar = dict_params['INCAR']
     incar['IBRION'] = 2
     incar['ISIF'] = 0
     incar['ISPIN'] = 2
     incar['LWAVE'] = False
     incar['LCHARG'] = False
     incar['EDIFF'] = 0.0001
     incar['EDIFFG'] = 0.001
     incar['ISMEAR'] = 0
     incar['SIGMA'] = 0.05
     incar['LVHAR'] = True
     incar['LORBIT'] = 11
     incar['ALGO'] = "Normal"
     if hse == True:
         incar['LHFCALC'] = True
         incar["ALGO"] = "All"
         incar["HFSCREEN"] = 0.2
         incar["PRECFOCK"] = "Fast"
     kpoint = Kpoints.monkhorst_automatic()
     f = open("transformations.json", 'w')
     f.write(json.dumps(jsanitize(dict_transf)))
     f.close()
     comp = s['structure'].composition
     sum_elec = 0
     elts = set()
     for p in dict_params['POTCAR']:
         if p.element not in elts:
             sum_elec += comp.as_dict()[p.element] * p.nelectrons
             elts.add(p.element)
         #print p.element
         #print comp.as_dict[p.element]
         #print p.valence
     if charge != 0:
         incar['NELECT'] = sum_elec - charge
     dict_params['POTCAR'].write_file("POTCAR")
     incar.write_file("INCAR")
     kpoint.write_file("KPOINTS")
     dict_params['POSCAR'].write_file("POSCAR")
 def _add_weighted_kpts(self, irreducible_kpoints):
     kpts = [k[0] for k in irreducible_kpoints]
     weights = [k[1] for k in irreducible_kpoints]
     labels = [None] * len(irreducible_kpoints)
     self._kpoints = Kpoints(comment=self.comment,
                             style=Kpoints.supported_modes.Reciprocal,
                             num_kpts=len(kpts),
                             kpts=kpts,
                             kpts_weights=weights,
                             labels=labels)
    def _set_kpoints(self):
        # symmetrizer must be recreated since the fractional coordinates are
        # different in different lattices.
        # Symmetrized structure doesn't need the symprec and angle_tolerance
        symmetrizer = StructureSymmetrizer(self._structure)
        irreducible_kpoints = symmetrizer.irreducible_kpoints(
            self._num_kpt_list, self._kpt_shift)

        self.comment = ""
        if self._kpt_mode is KpointsMode.band:
            self._add_weighted_kpts(irreducible_kpoints)
            self._add_band_path_kpts()
            self._num_kpts = len(self._kpoints.kpts)
        else:
            self._kpoints = Kpoints(comment=self.comment,
                                    kpts=(self._num_kpt_list, ),
                                    kpts_shift=self._kpt_shift)
            self._num_kpts = len(irreducible_kpoints)

            self.kpoints.comment += f"Num irrep kpoints: {self._num_kpts}"
Example #5
0
    def run_task(self, fw_spec):
        from pymongo import MongoClient
        clt = MongoClient('marilyn.pcpm.ucl.ac.be', 27017)
        db = clt.results_GY
        db.authenticate('gyu', 'pulco')
        hse_gap = db.HSE_gaps_ICSD

        pbe_bs = fw_spec['pbe_bs']
        job_info_array = fw_spec['_job_info']
        prev_job_info = job_info_array[-1]

        result = {}

        icsd_id = fw_spec['icsd_id']
        xml = Vasprun(prev_job_info['launch_dir'] + '/vasprun.xml')
        ks = Kpoints.from_file(prev_job_info['launch_dir'] + '/KPOINTS')
        is_converged = xml.converged
        bs = xml.get_band_structure()
        formula = xml.final_structure.composition.reduced_formula
        material = {
            'icsd_id': icsd_id,
            'formula': formula,
            'is_spin_polarized': bs.is_spin_polarized
        }

        input = {}
        incar = xml.incar.as_dict()
        potcar = xml.potcar_spec
        crystal = xml.final_structure.as_dict()
        kpoints = ks.as_dict()
        input['incar'] = incar
        input['potcar'] = potcar
        input['crystal'] = crystal
        input['kpoints'] = kpoints

        gap_info = {}
        ######### HSE #####################
        gap_info['HSE'] = {}
        gap_info['HSE']['gap'] = bs.get_band_gap()['energy']

        cbm = {}
        cbm['energy'] = bs.get_cbm()['energy']
        cbm_kpoint = {}
        cbm_kpoint['coordinate'] = list(bs.get_cbm()['kpoint']._fcoords)
        cbm_kpoint['label'] = bs.get_cbm()['kpoint'].label
        cbm['kpoint'] = cbm_kpoint

        vbm = {}
        vbm['energy'] = bs.get_vbm()['energy']
        vbm_kpoint = {}
        vbm_kpoint['coordiante'] = list(bs.get_vbm()['kpoint']._fcoords)
        vbm_kpoint['label'] = bs.get_vbm()['kpoint'].label
        vbm['kpoint'] = vbm_kpoint

        gap_info['HSE']['cbm'] = cbm
        gap_info['HSE']['vbm'] = vbm
        ########### PBE from ICSD############
        gap_info['PBE_icsd'] = {}
        gap_info['PBE_icsd']['gap'] = pbe_bs.get_band_gap()['energy']

        pbe_cbm = {}
        pbe_cbm['energy'] = pbe_bs.get_cbm()['energy']
        pbe_cbm_kpoint = {}
        pbe_cbm_kpoint['coordinate'] = list(
            pbe_bs.get_cbm()['kpoint']._fcoords)
        pbe_cbm_kpoint['label'] = pbe_bs.get_cbm()['kpoint'].label
        pbe_cbm['kpoint'] = pbe_cbm_kpoint

        pbe_vbm = {}
        pbe_vbm['energy'] = pbe_bs.get_vbm()['energy']
        pbe_vbm_kpoint = {}
        pbe_vbm_kpoint['coordiante'] = list(
            pbe_bs.get_vbm()['kpoint']._fcoords)
        pbe_vbm_kpoint['label'] = pbe_bs.get_vbm()['kpoint'].label
        pbe_vbm['kpoint'] = pbe_vbm_kpoint

        gap_info['PBE_icsd']['cbm'] = pbe_cbm
        gap_info['PBE_icsd']['vbm'] = pbe_vbm
        #############################################################################
        result['material'] = material
        result['input'] = input
        result['gap_info'] = gap_info
        result['is_converged'] = is_converged
        ##################################################################################
        hse_gap.insert(result)