Exemple #1
0
 def setup_kpoints_jobs(self,
                        Grid_type='M',
                        kpoints_list=None,
                        conv_step=1):
     self.logger.warn("Its a molecule ! no need for kpoint convergence")
     self.kpoints = Kpoints.monkhorst_automatic(kpts=[1, 1, 1])
     return
Exemple #2
0
 def test_as_dict_from_dict(self):
     k = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
     d = k.as_dict()
     k2 = Kpoints.from_dict(d)
     self.assertEqual(k.kpts, k2.kpts)
     self.assertEqual(k.style, k2.style)
     self.assertEqual(k.kpts_shift, k2.kpts_shift)
Exemple #3
0
 def test_as_dict_from_dict(self):
     k = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
     d = k.as_dict()
     k2 = Kpoints.from_dict(d)
     self.assertEqual(k.kpts, k2.kpts)
     self.assertEqual(k.style, k2.style)
     self.assertEqual(k.kpts_shift, k2.kpts_shift)
Exemple #4
0
    def monkhorst_list(cls):
        """
        Initialize Monkhorst grid from a list explicitly defining the number
        of kpoint subdivisions along the crystal axis

        Example:

        .. code-block:: python

           Automatic Kpoint Scheme
           0
           Monkhorst
           4 4 4
        """
        if cls.kpoint_params['sympath'] is not None:
            warnings.warn("Explicit monkhorst grid mode: Ignoring defined "
                          "high symmetry path object")
        kpoints = cls.kpoint_params['kpoints']
        if len(kpoints) != 3:
            raise KpointWrapperError("Expected list of length 3 for explict "
                                     "k-point grid input")
        shift = cls.kpoint_params['shift'] or [.0, .0, .0]
        if len(shift) != 3:
            raise KpointWrapperError("Expected list of length 3 for k-point "
                                     "grid shift")
        return Kpoints.monkhorst_automatic(kpts=kpoints, shift=shift)
Exemple #5
0
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic)
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = self.TEST_FILES_DIR / 'POSCAR'
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[1, 3, 3]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 10, 13]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.from_string("""k-point mesh 
0
G
10 10 10
0.5 0.5 0.5
""")
        self.assertArrayAlmostEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5])
Exemple #6
0
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic)
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[2, 4, 4]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 11, 13]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
    def get_kpoints_object(self, step, structure):
        try:
            kpoints_tags = self.kpoints[step]
        except KeyError:
            return None

        if kpoints_tags['Type'] == 'automatic_density':
            K = Kpoints.automatic_density(structure,
                                          kpoints_tags['Grid Density'],
                                          kpoints_tags['Force Gamma'])
        elif kpoints_tags['Type'] == 'automatic_density_by_vol':
            K = Kpoints.automatic_density_by_vol(
                structure,
                kpoints_tags['Grid Density per A^(-3) of Reciprocal Cell'],
                kpoints_tags['Force Gamma'])
        elif kpoints_tags['Type'] == 'automatic_gamma_density':
            K = Kpoints.automatic_gamma_density(structure,
                                                kpoints_tags['Grid Density'])
        elif kpoints_tags['Type'] == 'gamma_automatic':
            K = Kpoints.gamma_automatic(kpoints_tags["KPTS"],
                                        kpoints_tags["Shift"])
        elif kpoints_tags['Type'] == 'monkhorst_automatic':
            K = Kpoints.monkhorst_automatic(kpoints_tags["KPTS"],
                                            kpoints_tags["Shift"])
        else:
            print('Invalid kpoints generation type %s; fatal error' %
                  kpoints_tags['Type'])
            sys.exit(1)
        return K
Exemple #8
0
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic)
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = os.path.join(test_dir, "POSCAR")
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[2, 4, 4]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 11, 13]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
Exemple #9
0
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic)
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[1, 3, 3]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 10, 13]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
        kpoints = Kpoints.from_string("""k-point mesh 
0
G
10 10 10
0.5 0.5 0.5
""")
        self.assertArrayAlmostEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5])
Exemple #10
0
 def kpoints(self):
     self._config_dict["KPOINTS"]["grid_density"] = self.grid_density
     kpoints = super(PRLRoughStaticSet, self).kpoints
     # Prefer to use k-point scheme from previous run
     if self.prev_kpoints and self.prev_kpoints.style != kpoints.style:
         if self.prev_kpoints.style == Kpoints.supported_modes.Monkhorst:
             k_div = [
                 kp + 1 if kp % 2 == 1 else kp for kp in kpoints.kpts[0]
             ]
             kpoints = Kpoints.monkhorst_automatic(k_div)
         else:
             kpoints = Kpoints.gamma_automatic(kpoints.kpts[0])
     return kpoints
Exemple #11
0
 def set_kpoints(self, kpoint):
     """
     set the kpoint
     """
     if self.Grid_type == 'M':
         self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint)
     elif self.Grid_type == 'A':
         self.kpoints = Kpoints.automatic(subdivisions=kpoint)
     elif self.Grid_type == 'G':
         self.kpoints = Kpoints.gamma_automatic(kpts=kpoint)
     elif self.Grid_type == '3DD':
         self.kpoints = Kpoints.automatic_density_by_vol(structure= \
                                                             self.poscar.structure, kppvol=kpoint)
     elif self.Grid_type == 'band':
         self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \
                                                   ibz=HighSymmKpath(self.poscar.structure))
Exemple #12
0
 def set_kpoints(self, kpoint):
     """
     set the kpoint
     """
     if self.Grid_type == 'M':
         self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint)
     elif self.Grid_type == 'A':
         self.kpoints = Kpoints.automatic(subdivisions=kpoint)
     elif self.Grid_type == 'G':
         self.kpoints = Kpoints.gamma_automatic(kpts=kpoint)
     elif self.Grid_type == '3DD':
         self.kpoints = Kpoints.automatic_density_by_vol(structure= \
                                                             self.poscar.structure,
                                                         kppvol=kpoint)
     elif self.Grid_type == 'band':
         self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \
                                                   ibz=HighSymmKpath(
                                                       self.poscar.structure))
Exemple #13
0
def StepVASP0(my_project, struct_list, order_key=0):
    """
    1. reads a poscar list of a 2D motif(s)
    2. sets the default incar, kpoints and potcar as per mw
       database

    Returns:
        checkpoint Motif_like_2D_relax.json, Motif_like_bulk_relax.json
    """
    WORKFLOWS = my_project['Workflow']
    Workflow_Params = WORKFLOWS['Steps'][order_key]
    Workflow_name = Workflow_Params['NAME']
    job_dir = my_project['NAME'] + Workflow_Params['NAME']
    logger = get_logger(job_dir)
    chkpt = job_dir + '.json'

    incar_dict = my_project['Incar_General']
    incar_init = Incar.from_dict(incar_dict)
    kpoints_init = Kpoints.monkhorst_automatic(
        [18, 18, 18])  # an initialization to anything sensible

    # Decide the Kpoints density per atom setting here
    turn_knobs= OrderedDict({'POSCAR': struct_list,'KPOINTS':Workflow_Params['KPOINTS'],\
                             'POTCAR_pseudopotential':Workflow_Params['PSEUDOPOTENTIAL']})

    if Workflow_Params['Other_Knobs']:
        #for k in Workflow_Params['Other_Knobs']:
        #print (type(Workflow_Params['Other_Knobs']))
        turn_knobs.update(Workflow_Params['Other_Knobs'])
    job_bin = vasp_config[Workflow_Params['Queue']['Bin']]
    qdict = Workflow_Params['Queue']
    # Decide general queue settings for all runs in this step
    #print (turn_knobs)
    qadapter, job_cmd = get_run_cmmnd(partition=qdict['Partition'],ntasks=qdict['Ntasks'],\
                        nnodes = qdict['Nnodes'],walltime=qdict['Walltime'],job_bin=job_bin,\
                        mem=qdict['Memory'], job_name=job_dir)

    # run the jobs in this step
    run_cal(turn_knobs, qadapter, job_cmd, job_dir, logger,
            chkpt, incar=incar_init, kpoints=kpoints_init,
            poscar=struct_list[0], magnetism=Workflow_Params['Magnetism'],\
            is_matrix=Workflow_Params['Matrix'],\
            Grid_type=Workflow_Params['Kpt_Grid'])
    return [chkpt]
Exemple #14
0
 def set_kpoints(self, kpoint):
     """
     set the kpoint
     """
     if self.Grid_type == 'M':
         self.kpoints = Kpoints.monkhorst_automatic(kpts = kpoint)
     elif self.Grid_type == 'A':
         self.kpoints = Kpoints.automatic(subdivisions = kpoint)
     elif self.Grid_type == 'G': 
         self.kpoints = Kpoints.gamma_automatic(kpts = kpoint)
     elif self.Grid_type == '3DD':
         self.kpoints = Kpoints.automatic_density_by_vol(structure=\
                        self.poscar.structure, kppvol=kpoint)
     elif self.Grid_type == 'band':
         self.kpoints = Kpoints.automatic_linemode(divisions=kpoint,\
                        ibz=HighSymmKpath(self.poscar.structure))
     name = self.kpoint_to_name(kpoint, self.Grid_type)
     job_dir = self.job_dir +os.sep+ self.key_to_name('KPOINTS') \
       + os.sep + name
     return job_dir
Exemple #15
0
 def set_kpoints(self, kpoint):
     """
     set the kpoint
     """
     if self.Grid_type == 'M':
         self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint)
     elif self.Grid_type == 'A':
         self.kpoints = Kpoints.automatic(subdivisions=kpoint)
     elif self.Grid_type == 'G':
         self.kpoints = Kpoints.gamma_automatic(kpts=kpoint)
     elif self.Grid_type == '3DD':
         self.kpoints = Kpoints.automatic_density_by_vol(structure= \
                                                             self.poscar.structure, kppvol=kpoint)
     elif self.Grid_type == 'band':
         self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \
                                                   ibz=HighSymmKpath(self.poscar.structure))
     name = self.kpoint_to_name(kpoint, self.Grid_type)
     job_dir = self.job_dir + os.sep + self.key_to_name('KPOINTS') \
               + os.sep + name
     return job_dir
# all the info/warnings/outputs redirected to the log file: convg.log
logger = get_logger('convg')

incar_dict = dict(
    PREC='Accurate',
    ENCUT=400,
    ISMEAR=1,
    EDIFF='1E-6',
    NSW=0,
    NPAR=4,
    LCHARG='.FALSE.',
    LWAVE='.FALSE.')
# INCAR
incar = Incar.from_dict(incar_dict)
# KPOINTS
kpoints = Kpoints.monkhorst_automatic(kpts=(12, 12, 12))
# QUE
nprocs = 8
nnodes = 1
mem = '1000'
walltime = '1:00:00'
job_bin = '/home/km468/Software/VASP/vasp.5.3.5/vasp'
qadapter, job_cmd = get_run_cmmnd(nnodes=nnodes, nprocs=nprocs,
                                  walltime=walltime,
                                  job_bin=job_bin, mem=mem)
# STRUCTURES
structures = ['Pt', 'Ag', 'Cu']
poscar_list = []


def get_structures():
Exemple #17
0
    iface.create_interface()
    iface.sort()

    incarparams = {
        'System': 'test',
        'ENCUT': 400,
        'ISMEAR': 1,
        'SIGMA': 0.1,
        'EDIFF': 1E-6
    }
    incar = Incar(params=incarparams)
    poscar = Poscar(iface)
    potcar = Potcar(symbols=poscar.site_symbols,
                    functional='PBE',
                    sym_potcar_map=None)
    kpoints = Kpoints.monkhorst_automatic(kpts=(16, 16, 16), shift=(0, 0, 0))
    cal = CalibrateInterface(incar,
                             poscar,
                             potcar,
                             kpoints,
                             system=iface.as_dict(),
                             job_dir='test',
                             job_cmd=['ls', '-lt'])
    cal.setup()
    cal.run()
    # list of calibrate objects
    cal_objs = [cal]
    # check whether the cal jobs were done
    # Calibrate.check_calcs(cal_objs)
    # set the measurement
    # measure = MeasurementInterface(cal_objs, job_dir='./Measurements')
Exemple #18
0
 def setup_kpoints_jobs(self, Grid_type = 'M',
                        kpoints_list = None, conv_step = 1):
     self.logger.warn("Its a molecule ! no need for kpoint convergence")
     self.kpoints = Kpoints.monkhorst_automatic(kpts = [1,1,1])
     return
# all the info/warnings/outputs redirected to the log file: convg.log
logger = get_logger('convg')

incar_dict = dict(PREC='Accurate',
                  ENCUT=400,
                  ISMEAR=1,
                  EDIFF='1E-6',
                  NSW=0,
                  NPAR=4,
                  LCHARG='.FALSE.',
                  LWAVE='.FALSE.')
# INCAR
incar = Incar.from_dict(incar_dict)
# KPOINTS
kpoints = Kpoints.monkhorst_automatic(kpts=(12, 12, 12))
# QUE
nprocs = 8
nnodes = 1
mem = '1000'
walltime = '1:00:00'
job_bin = '/home/km468/Software/VASP/vasp.5.3.5/vasp'
qadapter, job_cmd = get_run_cmmnd(nnodes=nnodes,
                                  nprocs=nprocs,
                                  walltime=walltime,
                                  job_bin=job_bin,
                                  mem=mem)
# STRUCTURES
structures = ['Pt', 'Ag', 'Cu']
poscar_list = []
Exemple #20
0
def make_vasp_defect_files(dictio,
                           path_base,
                           task_id,
                           compo,
                           hse=False,
                           encut_redo=False):
    """
    simple static method creating VASP files ready for defect computations
    Args:
        dictio:
            the defects data as a dictionnary
        path_base:
            where do we write the files
        task_id:
            some id of the bulk computed data
        compo:
            Composition of the bulk computed data
        hse:
            hse run or not
    """
    count = 1
    for site in dictio:
        #### bulk ####
        if site['short_name'] == 'bulk':
            bulk_unitcell = site['bulk_unitcell'].as_dict()
            uc_type = site['uc_type']
            sc_type = site['sc_type']
            for s in site['supercells']:
                defect_dist = round(closest_defect_distance(s['structure']), 2)
                bulk_info = '%s_%s_%s' % (uc_type, sc_type, str(defect_dist))
                dict_transf = {
                    'history': [{
                        'source': task_id,
                        'unitcell_type': site['uc_type']
                    }],
                    'defect_type':
                    'bulk',
                    'supercell':
                    s['size']
                }
                structs = {'bulk_unitcell': bulk_unitcell}
                dict_params = MPStaticSet(s['structure']).all_input
                incar_init = dict_params['INCAR']
                incar = IncarSetup(incar_init, 'bulk', hse)
                if encut_redo:
                    enmax = round(
                        max([i.PSCTR['ENMAX']
                             for i in dict_params['POTCAR']]) * 1.3)
                    incar['ENCUT'] = int(enmax)
                if hse:
                    kpoint = Kpoints.gamma_automatic()
                else:
                    kpoint = Kpoints.monkhorst_automatic()
                path = path_base + "/" + str(
                    task_id
                ) + '_' + compo.reduced_formula + '/bulk/' + bulk_info
                os.makedirs(path)
                f = open(path + "/transformations.json", 'w')
                f.write(json.dumps(jsanitize(dict_transf)))
                g = open(path + "/structures.json", 'w')
                g.write(json.dumps(jsanitize(structs)))
                dict_params['POTCAR'].write_file(path + "/POTCAR")
                incar.write_file(path + "/INCAR")
                kpoint.write_file(path + "/KPOINTS")
                dict_params['POSCAR'].write_file(path + "/POSCAR")
            continue

        #### dielectric constants ####
        if site['short_name'] == 'dielectric':
            dict_transf = {
                'history': [{
                    'source': task_id,
                    'unit_cell': site['uc_type']
                }],
                'defect_type': 'dielectric'
            }
            dict_params = MPStaticSet(site['structure']).all_input
            incar = dict_params['INCAR']
            kpoints = Kpoints.automatic_gamma_density(site['structure'], 2000)
            try:
                bs = m.get_bandstructure_by_material_id(task_id)
                if not bs.is_spin_polarized:
                    incar['ISPIN'] = 1
                else:
                    incar['ISPIN'] = 2
            except:
                incar['ISPIN'] = 1
            incar = IncarSetup(incar, 'dielectric', hse)
            if encut_redo:
                enmax = round(
                    max([i.PSCTR['ENMAX']
                         for i in dict_params['POTCAR']]) * 1.3)
                incar['ENCUT'] = int(enmax)
            path = path_base + "/" + str(
                task_id
            ) + '_' + compo.reduced_formula + "/" + 'dielectric/' + site[
                'uc_type']
            os.makedirs(path)
            f = open(path + "/transformations.json", 'w')
            f.write(json.dumps(jsanitize(dict_transf)))
            dict_params['POTCAR'].write_file(path + "/POTCAR")
            incar.write_file(path + "/INCAR")
            kpoints.write_file(path + "/KPOINTS")
            dict_params['POSCAR'].write_file(path + "/POSCAR")
            continue

        #### defects ####
        uc_type = site['uc_type']
        sc_type = site['sc_type']
        for charge in site['charges']:
            uc = site['bulk_unitcell'].copy()
            bulk_unitcell = uc.as_dict()
            for s in site['supercells']:
                defect_dist = round(closest_defect_distance(s['structure']), 2)
                defect_info = '%s_%s_%s' % (uc_type, sc_type, str(defect_dist))
                uc.make_supercell(s['size'], to_unit_cell=True)
                bulk_supercell = uc.as_dict()
                dict_transf = {
                    'history': [{
                        'source': task_id,
                        'unit_cell': site['uc_type']
                    }],
                    'compo': compo.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
                try:
                    defect_no_relaxation = s['struct_no_move'].as_dict()
                except:
                    defect_no_relaxation = s['structure'].as_dict()
                structs = {
                    'bulk_unitcell': bulk_unitcell,
                    'bulk_supercell': bulk_supercell,
                    'defect_no_relaxation': defect_no_relaxation
                }
                incar = dict_params['INCAR']
                incar = IncarSetup(incar, 'defect', hse)
                if encut_redo:
                    enmax = round(
                        max([i.PSCTR['ENMAX']
                             for i in dict_params['POTCAR']]) * 1.3)
                    incar['ENCUT'] = int(enmax)
                if hse:
                    kpoint = Kpoints.gamma_automatic()
                else:
                    kpoint = Kpoints.monkhorst_automatic()
                path=path_base+"/"+str(task_id)+'_'+compo.reduced_formula+ \
                    '/'+str(site['short_name'])+"/"+"charge"+str(charge)+'/'+defect_info
                os.makedirs(path)
                f = open(path + "/transformations.json", 'w')
                f.write(json.dumps(jsanitize(dict_transf)))
                g = open(path + "/structures.json", 'w')
                g.write(json.dumps(jsanitize(structs)))
                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)
                if charge != 0:
                    incar['NELECT'] = sum_elec - charge
                dict_params['POTCAR'].write_file(path + "/POTCAR")
                incar.write_file(path + "/INCAR")
                kpoint.write_file(path + "/KPOINTS")
                dict_params['POSCAR'].write_file(path + "/POSCAR")
                count = count + 1
                f.close()
                g.close()
Exemple #21
0
    def set_kpoints(self, kpoint=None, poscar=None, ibzkpth=None):
        """
        set the kpoint
        """
        # useful to check if a poscar is supplied from setup_poscar_jobs (most often the case)
        # or this is a single poscar use case
        if not poscar:
            poscar = self.poscar

        # splitting into two if elif branches means fewer if statements to check on
        # a run

        # Most general method of setting the k-points for
        # different grid types
        # NOTE: requires that at least one k-points value be passed
        # as a turn - knobs list value
        # this is not true for values that may be caculated out of
        # a database
        # use this part only if this is a non-database run for example
        # for k-points calibration

        if not self.database:

            if self.Grid_type == 'M':
                self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint)
            elif self.Grid_type == 'A':
                self.kpoints = Kpoints.automatic(subdivisions=kpoint)
            elif self.Grid_type == 'G':
                self.kpoints = Kpoints.gamma_automatic(kpts=kpoint)
            elif self.Grid_type == '3D_vol':
                self.kpoints = Kpoints.automatic_density_by_vol(structure=poscar.structure,
                                                                kppvol=kpoint)
            elif self.Grid_type == 'bulk_bands_pbe':
                self.kpoints = Kpoints.automatic_linemode(divisions=kpoint,
                                                          ibz=HighSymmKpath(
                                                              poscar.structure))

            elif self.Grid_type == 'D':
                self.kpoints = Kpoints.automatic_density(structure=poscar.structure,kppa=kpoint)

            elif self.Grid_type == 'Finer_G_Mesh':
                # kpoint is the scaling factor and self.kpoints is the old kpoint mesh
                self.logger.info('Setting Finer G Mesh for {0} by scale {1}'.format(kpoint, self.finer_kpoint))
                self.kpoints = Kpoints.gamma_automatic(kpts = \
                   [i * self.finer_kpoint for i in kpoint])
                self.logger.info('Finished scaling operation of k-mesh')

        # applicable for database runs
        # future constructs or settinsg can be activated via a yaml file
        # database yaml file or better still the input deck from its speification
        # decides what combination of input calibrate constructor settings to use
        # one of them being the grid_type tag

        elif self.database == 'twod':

            # set of kpoints settings according to the 2D database profile
            # the actual settings of k-points density
            # will in future come from any database input file set

            if self.Grid_type == 'hse_bands_2D_prep':
                kpoint_dict = Kpoints.automatic_gamma_density(poscar.structure,
                                                              200).as_dict()
                kpoint_dict['kpoints'][0][2] = 1  # remove z kpoints
                self.kpoints = Kpoints.from_dict(kpoint_dict)

            elif self.Grid_type == 'hse_bands_2D':
                # can at most return the path to the correct kpoints file
                # needs kpoints to be written out in instrument in a different way
                # not using the Kpoints object
                self.kpoints = get_2D_hse_kpoints(poscar.structure, ibzkpth)

            elif self.Grid_type == 'bands_2D':
                kpoint_dict = Kpoints.automatic_linemode(divisions=20,
                                                         ibz=HighSymmKpath(poscar.structure)).as_dict()
                self.kpoints = Kpoints.from_dict(kpoint_dict)

            elif self.Grid_type == 'relax_2D':
                # general relaxation settings for 2D
                kpoint_dict = Kpoints.automatic_gamma_density(poscar.structure,
                                                              1000).as_dict()
                kpoint_dict['kpoints'][0][2] = 1
                self.kpoints = Kpoints.from_dict(kpoint_dict)

            elif self.Grid_type == 'relax_3D':
                # general relaxation settings for 3D
                kpoint_dict = Kpoints.automatic_gamma_density(
                    poscar.structure, 1000)
                self.kpoints = Kpoints.from_dict(kpoint_dict)
def step2():
    """
    read in the realxed bulk substrates and relaxed 2d,
    create substrate slab,
    get aligned substrates and 2d,
    relax the aligned structures seperatly(only ionic positions, ISIF=2)

    - input from step1_sub.json and step1_2d.json
    - 8(pairs) * 2 = 16 jobs
    - returns step2.json
    """
    nlayers_2d = 1
    nlayers_sub = 2
    hkl_sub = [1,1,1]
    min_thick = 10.0
    min_vac = 18.0
    hkl_2d = [0,0,1]
    #job directory for the runs
    job_dir_sub = 'step2_sub'
    job_dir_2d = 'step2_2d'
    # isif = 2
    incar_sub['ISIF'] = 2
    incar_2d['ISIF'] = 2
    # kpoints
    kpoints_sub = Kpoints.monkhorst_automatic(kpts=(18, 18, 1))
    kpoints_2d = Kpoints.monkhorst_automatic(kpts=(18, 18, 1))    
    # CSL settings for each substrate
    alignment_settings = { 'Pt': [120, 0.10, 1, 0.5],
                        'Ag': [120, 0.10, 1, 0.5],
                        'Al': [120, 0.10, 1, 0.5],
                        'Au': [120, 0.10, 1, 0.5],
                        'Pd': [120, 0.10, 1, 0.5],
                        'Ir': [120, 0.10, 1, 0.5],
                        'Cu': [50, 0.06, 1, 0.5],
                        'Ni': [50, 0.06, 1, 0.5] }
    # load in previous jobs
    relaxed_sub_jobs = Calibrate.jobs_from_file('step1_sub.json')
    relaxed_2d_jobs = Calibrate.jobs_from_file('step1_2d.json')
    poscars_sub = []
    poscars_2d = []
    # create list of all aligned substrate and 2d slabs
    for jsub in relaxed_sub_jobs:
        jdir = os.path.join(jsub.parent_job_dir, jsub.job_dir)
        contcar_file = os.path.join(jdir, 'CONTCAR')
        relaxed_struct_sub = Structure.from_file(contcar_file)
        # create slab
        slab_sub = Interface(relaxed_struct_sub,  hkl = hkl_sub,
                             min_thick = min_thick, min_vac = min_vac,
                             primitive = False, from_ase = True)
        species_sub = ''.join([tos.symbol for tos in slab_sub.types_of_specie])
        # loop over 2d
        for j2d in relaxed_2d_jobs:    
            jdir = os.path.join(j2d.parent_job_dir, j2d.job_dir)
            contcar_file = os.path.join(jdir, 'CONTCAR')
            slab_2d = slab_from_file(hkl_2d, contcar_file)
            species_2d = ''.join([tos.symbol for tos in slab_2d.types_of_specie])
            # align
            slab_sub_aligned, slab_2d_aligned = get_aligned_lattices(
                slab_sub,
                slab_2d,
                *alignment_settings[species_sub])
            # aligned sub poscar
            sd_flags = CalibrateSlab.set_sd_flags(interface=slab_sub_aligned,
                                                  n_layers=nlayers_sub)
            poscar = Poscar(slab_sub_aligned, selective_dynamics=sd_flags)
            poscar.comment = '_'.join([species_sub,species_2d,'sub'])            
            poscars_sub.append(poscar)
            # aligned 2d slab
            sd_flags = CalibrateSlab.set_sd_flags(interface=slab_2d_aligned,
                                                  n_layers=nlayers_2d)
            poscar = Poscar(slab_2d_aligned, selective_dynamics=sd_flags)
            poscar.comment = '_'.join([species_sub,species_2d,'2d'])
            poscars_2d.append(poscar)
    # setup calibrate and run'em
    turn_knobs_sub = OrderedDict(
        [
            ('POSCAR', poscars_sub)
        ])
    turn_knobs_2d = OrderedDict(
        [
            ('POSCAR', poscars_2d)
        ])
    qadapter, job_cmd = get_run_cmmnd(nnodes=nnodes, nprocs=nprocs,
                                            walltime=walltime,
                                            job_bin=bin_sub, mem=mem)
    run_cal(turn_knobs_sub, qadapter, job_cmd, job_dir_sub,
            'step2_sub', incar=incar_sub, kpoints=kpoints_sub)
    run_cal(turn_knobs_2d, qadapter, job_cmd, job_dir_2d,
            'step2_2d', incar=incar_2d, kpoints=kpoints_2d)
    return ['step2_sub.json', 'step2_2d.json']
def step3():
    """
    put aligned & relaxed 2d materials in all possible ways on the
    aligned & relaxed slab,
    relax interface ionic positions(ISIF=2)

    - uses info from step2_sub.json and step2_2d.json
    - creates required input files and submits the jobs to the que
    - 8(pairs) * 2(atoms in graphene basis) = 16 jobs
    - returns: step3.json     
    """
    seperation = 3 # in angstroms
    nlayers_2d = 1
    nlayers_sub = 2
    hkl_sub = [1,1,1]
    hkl_2d = [0,0,1]
    #job directory for the runs
    name = 'step3'    
    job_dir = 'step3'
    # incar
    incar = Incar.from_dict(incar_dict)
    incar['ISMEAR'] = 1
    incar['ISIF'] = 2
    # kpoints
    kpoints = Kpoints.monkhorst_automatic(kpts=(18, 18, 1))
    # load in previous jobs
    relaxed_sub_jobs = Calibrate.jobs_from_file('step2_sub.json')
    relaxed_2d_jobs = Calibrate.jobs_from_file('step2_2d.json')
    # create list of all substrate poscars
    all_poscars = []
    # loop over aligned & relaxed substrates and 2d
    for jsub, j2d in zip(relaxed_sub_jobs,relaxed_2d_jobs):
        # substrate
        job_dir_sub = os.path.join(jsub.parent_job_dir, jsub.job_dir)
        contcar_file = os.path.join(job_dir_sub, 'CONTCAR')
        # read in as structure object
        substrate_slab_aligned = Structure.from_file(contcar_file)
        species_sub = ''.join([tos.symbol for tos in substrate_slab_aligned.types_of_specie])
        # 2d
        job_dir_2d = os.path.join(j2d.parent_job_dir, j2d.job_dir)
        contcar_file = os.path.join(job_dir_2d, 'CONTCAR')
        # read in as structure object        
        mat2d_slab_aligned = Structure.from_file(contcar_file)
        species_2d = ''.join([tos.symbol for tos in mat2d_slab_aligned.types_of_specie])
        # position the aligned materials in all possible ways
        hetero_interfaces = generate_all_configs(mat2d_slab_aligned,
                                                 substrate_slab_aligned,
                                                 nlayers_2d,
                                                 nlayers_sub,
                                                 seperation )
        # loop over all hetero-interfaces
        for i, iface in enumerate(hetero_interfaces):
            sd_flags = CalibrateSlab.set_sd_flags(interface=iface,
                                                  n_layers=nlayers_2d+nlayers_sub,
                                                  top=True, bottom=False)
            poscar = Poscar(iface, selective_dynamics=sd_flags)
            poscar.comment = '_'.join([species_sub,species_2d,str(i)])
            all_poscars.append(poscar)
    # setup calibrate and run'em
    turn_knobs = OrderedDict(
        [
            ('POSCAR', all_poscars)
        ])
    qadapter, job_cmd = get_run_cmmnd(nnodes=nnodes, nprocs=nprocs,
                                      walltime=walltime,
                                      job_bin=bin_sub, mem=mem)
    run_cal(turn_knobs, qadapter, job_cmd, job_dir,
            name, incar=incar, kpoints=kpoints)
    return [name+'.json']
Exemple #24
0
    lvec = np.array(lvec) * a0
    lattice = Lattice(lvec)
    structure = Structure( lattice, ['Pt'], [ [0.0, 0.0, 0.0] ],
                           coords_are_cartesian=False )

    #INITIAL VASP INPUT SET
    incarparams = {'System':'test',
                   'ENCUT': 400,
                   'ISMEAR': 1,
                   'SIGMA': 0.1,
                   'EDIFF': 1E-6}
    incar = Incar(params = incarparams)
    poscar = Poscar(structure, comment='test')
    potcar = Potcar( symbols = poscar.site_symbols, functional='PBE',
                     sym_potcar_map=None)
    kpoints = Kpoints.monkhorst_automatic(kpts=(16, 16, 16),
                                          shift=(0, 0, 0))

    #CALIBRATION INPUT
    system = {'hkl':[1,1,1], 'ligand':None }    
    turn_knobs = OrderedDict( [
        ('SIGMA', [0.025, 0.50]),
        ('POTCAR', [{'Pt':'Pt'}, {'Pt':'Pt_pv'}, {'Pt':'Pt_GW'}]),
        ('IBRION', [1, 2, 3]),
        ('KPOINTS', [k for k in range(20, 40, 10)]),
        ('ENCUT', range(400,700,100)),
        ('VACUUM', [10,12,15]),
        ('THICKNESS', [11])        
        ] )
    is_matrix = True
    job_dir = 'Slab'
    job_cmd = ['ls','-lt'] 
    ISIF = 3,
    IBRION = 2,
    NSW = 500,
    NPAR = 4,
    LCHARG = '.FALSE.',
    GGA = 'BO',
    PARAM1 = 0.1833333333,
    PARAM2 = 0.2200000000,
    LUSE_VDW = '.TRUE.',
    AGGAC = 0.0000 )
# INCAR
incar_sub = Incar.from_dict(incar_dict)
incar_sub['ISMEAR'] = 1
incar_2d = Incar.from_dict(incar_dict)
# KPOINTS
kpoints_sub = Kpoints.monkhorst_automatic(kpts=(18, 18, 18))
kpoints_2d = Kpoints.monkhorst_automatic(kpts=(18, 18, 1))
# QUE
nprocs = 32
nnodes = 1
mem='1000'
walltime = '24:00:00'
bin_sub = '/home/km468/Software/VASP/vasp.5.3.5/vasp'
bin_2d = '/home/km468/Software/VASP/vasp.5.3.5/vasp_noz'
# STRUCTURES
substrates = [ 'Pt', 'Ag', 'Cu', 'Ni', 'Al' , 'Au', 'Pd', 'Ir']
mat2ds = ['POSCAR_graphene']


def run_cal(turn_knobs, qadapter, job_cmd, job_dir, name,
            incar=None, poscar=None, potcar=None, kpoints=None):