当前位置: 首页>>代码示例>>Python>>正文


Python inputs.Kpoints类代码示例

本文整理汇总了Python中pymatgen.io.vasp.inputs.Kpoints的典型用法代码示例。如果您正苦于以下问题:Python Kpoints类的具体用法?Python Kpoints怎么用?Python Kpoints使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Kpoints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_as_dict_from_dict

 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)
开发者ID:ExpHP,项目名称:pymatgen,代码行数:7,代码来源:test_inputs.py

示例2: run_task

    def run_task(self, fw_spec):

        prev_dir = fw_spec.get('PREV_DIR', None)
        self.custom_params = self.get('custom_params', None)   

        if isinstance(self["structure"], Structure):
            s = self["structure"]
        elif isinstance(self["structure"], dict):
            s = Structure.from_dict(self["structure"])
        else:
            s = Structure.from_file(os.path.join(prev_dir, self["structure"]))


        vis = load_class("pymatgen.io.vasp.sets", self["vasp_input_set"])(
                         **self.get("input_set_params", {}))
        vis.write_input(s, ".")


        # Write Custom KPOINTS settings if necessary
        ksettings = self.custom_params.get('user_kpts_settings', None) if isinstance(
                self.custom_params, dict) else None
        if ksettings:
            style = ksettings.get('kpts_style', 'Gamma')
            kpoints = ksettings.get('kpts', [16,16,16])
            shift = ksettings.get('kpts_shift', [0,0,0])
            k = Kpoints(kpts=[kpoints], kpts_shift=shift)
            k.style = style
            k.write_file("KPOINTS")
开发者ID:dcossey014,项目名称:pymatgen,代码行数:28,代码来源:interfaces.py

示例3: relax

def relax(dim=2, submit=True, force_overwrite=False):
    """
    Writes input files and (optionally) submits a self-consistent
    relaxation. Should be run before pretty much anything else, in
    order to get the right energy and structure of the material.

    Args:
        dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
        submit (bool): Whether or not to submit the job.
        force_overwrite (bool): Whether or not to overwrite files
            if an already converged vasprun.xml exists in the
            directory.
    """

    if force_overwrite or not utl.is_converged(os.getcwd()):
        directory = os.getcwd().split('/')[-1]

        # vdw_kernel.bindat file required for VDW calculations.
        if VDW_KERNEL:
            os.system('cp {} .'.format(VDW_KERNEL))
        # KPOINTS
        Kpoints.automatic_density(Structure.from_file('POSCAR'),
                                  1000).write_file('KPOINTS')

        # INCAR
        INCAR_DICT.update(
            {'MAGMOM': utl.get_magmom_string(Structure.from_file('POSCAR'))}
        )
        Incar.from_dict(INCAR_DICT).write_file('INCAR')
        # POTCAR
        utl.write_potcar()

        # Special tasks only performed for 2D materials.
        if dim == 2:
            # Ensure 20A interlayer vacuum
            utl.ensure_vacuum(Structure.from_file('POSCAR'), 20)
            # Remove all z k-points.
            kpts_lines = open('KPOINTS').readlines()
            with open('KPOINTS', 'w') as kpts:
                for line in kpts_lines[:3]:
                    kpts.write(line)
                kpts.write(kpts_lines[3].split()[0] + ' '
                           + kpts_lines[3].split()[1] + ' 1')

        # Submission script
        if dim == 2:
            binary = VASP_TWOD_BIN
        elif dim == 3:
            binary = VASP_STD_BIN
        if QUEUE_SYSTEM == 'pbs':
            utl.write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00', binary)
            submission_command = 'qsub runjob'

        elif QUEUE_SYSTEM == 'slurm':
            utl.write_slurm_runjob(directory, 16, '800mb', '6:00:00', binary)
            submission_command = 'sbatch runjob'

        if submit:
            os.system(submission_command)
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:59,代码来源:startup.py

示例4: test_remove_z_kpoints

 def test_remove_z_kpoints(self):
     os.chdir(os.path.join(PACKAGE_PATH, 'stability/tests/BiTeCl'))
     structure = Structure.from_file('POSCAR')
     kpath = HighSymmKpath(structure)
     Kpoints.automatic_linemode(20, kpath).write_file('KPOINTS')
     remove_z_kpoints()
     test_lines = open('KPOINTS').readlines()
     control_lines = open('../BiTeCl_control/KPOINTS').readlines()
     self.assertEqual(test_lines, control_lines)
     os.system('rm KPOINTS')
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:10,代码来源:test_utils.py

示例5: test_kpt_bands_as_dict_from_dict

 def test_kpt_bands_as_dict_from_dict(self):
     file_name = os.path.join(test_dir, 'KPOINTS.band')
     k = Kpoints.from_file(file_name)
     d = k.as_dict()
     import json
     json.dumps(d)
     # This doesn't work
     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)
     self.assertEqual(k.num_kpts, k2.num_kpts)
开发者ID:ExpHP,项目名称:pymatgen,代码行数:12,代码来源:test_inputs.py

示例6: get_kpoints

 def get_kpoints(self, structure):
     """
     Writes out a KPOINTS file using the automated gamma grid method.
     VASP crashes GW calculations on none gamma centered meshes.
     """
     if self.sort_structure:
         structure = structure.get_sorted_structure()
     dens = int(self.kpoints_settings['grid_density'])
     if dens == 1:
         return Kpoints.gamma_automatic()
     else:
         return Kpoints.automatic_gamma_density(structure, dens)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:12,代码来源:GWvaspinputsets.py

示例7: run_hse_prep_calculation

def run_hse_prep_calculation(dim=2, submit=True):
    """
    Submits a quick static calculation to calculate the IBZKPT
    file using a smaller number of k-points (200/atom instead of
    1000/atom). The other outputs from this calculation are
    essentially useless.

    Args:
        dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
        submit (bool): Whether or not to submit the job.
    """

    if not os.path.isdir('hse_prep'):
        os.mkdir('hse_prep')
    os.chdir('hse_prep')
    os.system('cp ../CONTCAR ./POSCAR')
    if os.path.isfile('../POTCAR'):
        os.system('cp POTCAR .')
    relax(dim=2, submit=False)
    incar_dict = Incar.from_file('INCAR').as_dict()
    incar_dict.update({'NSW': 0, 'NELM': 1, 'LWAVE': False, 'LCHARG': False,
                       'LAECHG': False})
    Incar.from_dict(incar_dict).write_file('INCAR')

    Kpoints.automatic_density(
        Structure.from_file('POSCAR'), 200
    ).write_file('KPOINTS')

    if dim == 2:
        kpts_lines = open('KPOINTS').readlines()

        with open('KPOINTS', 'w') as kpts:
            for line in kpts_lines[:3]:
                kpts.write(line)
            kpts.write(kpts_lines[3].split()[0] + ' '
                       + kpts_lines[3].split()[1] + ' 1')

    if QUEUE == 'pbs':
        write_pbs_runjob('{}_prep'.format(
            os.getcwd().split('/')[-2]), 1, 16, '800mb', '6:00:00', VASP)
        submission_command = 'qsub runjob'

    elif QUEUE == 'slurm':
        write_slurm_runjob('{}_prep'.format(
            os.getcwd().split('/')[-2]), 16, '800mb', '6:00:00', VASP)
        submission_command = 'sbatch runjob'

    if submit:
        os.system(submission_command)

    os.chdir('../')
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:51,代码来源:startup.py

示例8: test_static_constructors

    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])
开发者ID:ExpHP,项目名称:pymatgen,代码行数:33,代码来源:test_inputs.py

示例9: __init__

 def __init__(self, name, incar, poscar, potcar, kpoints,
              qadapter=None, **kwargs ):
     """
     default INCAR from config_dict
     
     """
     self.name = name
     self.incar = Incar.from_dict(incar.as_dict())
     self.poscar = Poscar.from_dict(poscar.as_dict())
     self.potcar = Potcar.from_dict(potcar.as_dict())
     self.kpoints = Kpoints.from_dict(kpoints.as_dict())
     self.extra = kwargs
     if qadapter is not None:
         self.qadapter = qadapter.from_dict(qadapter.to_dict())
     else:
         self.qadapter = None        
     config_dict = {}
     config_dict['INCAR'] = self.incar.as_dict()
     config_dict['POSCAR'] = self.poscar.as_dict() 
     #caution the key and the value are not always the same        
     config_dict['POTCAR'] = self.potcar.as_dict() 
     #dict(zip(self.potcar.as_dict()['symbols'],
     #self.potcar.as_dict()['symbols']))
     config_dict['KPOINTS'] = self.kpoints.as_dict()
     #self.user_incar_settings = self.incar.as_dict()        
     DictVaspInputSet.__init__(self, name, config_dict,
                                ediff_per_atom=False, **kwargs)
开发者ID:mbkumar,项目名称:MPInterfaces,代码行数:27,代码来源:instrument.py

示例10: setup

 def setup(self):
     """
     setup static jobs for all the calibrate objects
     copies CONTCAR to POSCAR
     sets NSW = 0
     """
     for cal in self.cal_objs:
         for i, jdir in enumerate(cal.old_job_dir_list):
             job_dir = self.job_dir + os.sep \
                 + jdir.replace(os.sep, '_').replace('.', '_') \
                 + os.sep + 'STATIC'
             logger.info('setting up job in {}'.format(job_dir))
             cal.incar = Incar.from_file(jdir + os.sep + 'INCAR')
             cal.incar['EDIFF'] = '1E-6'
             cal.incar['NSW'] = 0
             cal.potcar = Potcar.from_file(jdir + os.sep + 'POTCAR')
             cal.kpoints = Kpoints.from_file(jdir + os.sep + 'KPOINTS')
             contcar_file = jdir + os.sep + 'CONTCAR'
             if os.path.isfile(contcar_file):
                 logger.info('setting poscar file from {}'
                             .format(contcar_file))
                 cal.poscar = Poscar.from_file(contcar_file)
                 cal.add_job(job_dir=job_dir)
             else:
                 logger.critical("""CONTCAR doesnt exist.
                 Setting up job using input set in the old
                 calibration directory""")
                 cal.poscar = Poscar.from_file(jdir + os.sep + 'POSCAR')
                 cal.add_job(job_dir=job_dir)
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:29,代码来源:measurement.py

示例11: test_remove_z_kpoints

 def test_remove_z_kpoints(self):
     os.chdir(os.path.join(ROOT, 'BiTeCl'))
     structure = Structure.from_file('POSCAR')
     kpath = HighSymmKpath(structure)
     Kpoints.automatic_linemode(20, kpath).write_file('KPOINTS')
     remove_z_kpoints()
     test_file = open('KPOINTS')
     test_lines = test_file.readlines()
     print (test_lines)
     control_file = open('../BiTeCl_control/KPOINTS')
     control_lines = control_file.readlines()
     print (control_lines)
     self.assertEqual(test_lines, control_lines)
     os.system('rm KPOINTS')
     test_file.close()
     control_file.close()
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:16,代码来源:test_utils.py

示例12: set_kpoints

 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))
开发者ID:izxle,项目名称:MPInterfaces,代码行数:16,代码来源:calibrate.py

示例13: run_pbe_calculation

def run_pbe_calculation(dim=2, submit=True, force_overwrite=False):
    """
    Setup and submit a normal PBE calculation for band structure along
    high symmetry k-paths.

    Args:
        dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
        submit (bool): Whether or not to submit the job.
        force_overwrite (bool): Whether or not to overwrite files
            if an already converged vasprun.xml exists in the
            directory.
    """

    PBE_INCAR_DICT = {'EDIFF': 1e-6, 'IBRION': 2, 'ISIF': 3,
                      'ISMEAR': 1, 'NSW': 0, 'LVTOT': True, 'LVHAR': True,
                      'LORBIT': 1, 'LREAL': 'Auto', 'NPAR': 4,
                      'PREC': 'Accurate', 'LWAVE': True, 'SIGMA': 0.1,
                      'ENCUT': 500, 'ISPIN': 2}

    directory = os.getcwd().split('/')[-1]

    if not os.path.isdir('pbe_bands'):
        os.mkdir('pbe_bands')
    if force_overwrite or not is_converged('pbe_bands'):
        os.system('cp CONTCAR pbe_bands/POSCAR')
        if os.path.isfile('POTCAR'):
            os.system('cp POTCAR pbe_bands/')
        PBE_INCAR_DICT.update({'MAGMOM': get_magmom_string()})
        Incar.from_dict(PBE_INCAR_DICT).write_file('pbe_bands/INCAR')
        structure = Structure.from_file('POSCAR')
        kpath = HighSymmKpath(structure)
        Kpoints.automatic_linemode(20, kpath).write_file('pbe_bands/KPOINTS')
        os.chdir('pbe_bands')
        if dim == 2:
            remove_z_kpoints()
        if QUEUE == 'pbs':
            write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00', VASP)
            submission_command = 'qsub runjob'

        elif QUEUE == 'slurm':
            write_slurm_runjob(directory, 16, '800mb', '6:00:00', VASP)
            submission_command = 'sbatch runjob'

        if submit:
            os.system(submission_command)

        os.chdir('../')
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:47,代码来源:startup.py

示例14: test_static_constructors

    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)
开发者ID:gpetretto,项目名称:pymatgen,代码行数:26,代码来源:test_inputs.py

示例15: from_dict

 def from_dict(cls, d):
     incar = Incar.from_dict(d["incar"])
     poscar = Poscar.from_dict(d["poscar"])
     potcar = Potcar.from_dict(d["potcar"])
     kpoints = Kpoints.from_dict(d["kpoints"])
     qadapter = None
     if d["qadapter"] is not None:
         qadapter = CommonAdapter.from_dict(d["qadapter"])
     return MPINTVaspInputSet(d["name"], incar, poscar, potcar,
                              kpoints, qadapter, **d["kwargs"])
开发者ID:mbkumar,项目名称:MPInterfaces,代码行数:10,代码来源:instrument.py


注:本文中的pymatgen.io.vasp.inputs.Kpoints类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。