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


Python Vasp.neb_nimages方法代码示例

本文整理汇总了Python中ase.calculators.vasp.Vasp.neb_nimages方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.neb_nimages方法的具体用法?Python Vasp.neb_nimages怎么用?Python Vasp.neb_nimages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ase.calculators.vasp.Vasp的用法示例。


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

示例1: read_neb_calculator

# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import neb_nimages [as 别名]
def read_neb_calculator():
    """Read calculator from the current working directory.

    Static method that returns a :mod:`jasp.Jasp` calculator.
    """
    log.debug('Entering read_neb_calculator in {0}'.format(os.getcwd()))

    calc = Vasp()
    calc.vaspdir = os.getcwd()
    calc.read_incar()
    calc.read_kpoints()

    if calc.in_queue():
        return ([None for i in range(calc.int_params['images'] + 2)],
                [None for i in range(calc.int_params['images'] + 2)])

    # set default functional
    # if both gga and xc are not specified
    if calc.string_params['gga'] is None:
        if calc.input_params['xc'] is None:
            calc.input_params['xc'] = 'PBE'

    images = []
    log.debug('calc.int_params[images] = %i', calc.int_params['images'])
    # Add 2 to IMAGES flag from INCAR to get
    # first and last images
    for i in range(calc.int_params['images'] + 2):
        log.debug('reading neb calculator: 0%i', i)
        cwd = os.getcwd()

        os.chdir('{0}'.format(str(i).zfill(2)))
        if os.path.exists('CONTCAR'):
            f = open('CONTCAR')
            if f.read() == '':
                log.debug('CONTCAR was empty, vasp probably still running')
                fname = 'POSCAR'
            else:
                fname = 'CONTCAR'
        else:
            fname = 'POSCAR'

        atoms = read(fname, format='vasp')

        f = open('ase-sort.dat')
        sort, resort = [], []
        for line in f:
            s, r = [int(x) for x in line.split()]
            sort.append(s)
            resort.append(r)

        images += [atoms[resort]]
        os.chdir(cwd)

    log.debug('len(images) = %i', len(images))

    calc.neb_images = images
    calc.neb_nimages = len(images) - 2
    calc.neb = True
    return calc
开发者ID:jkitchin,项目名称:vasp,代码行数:61,代码来源:neb.py

示例2: neb_initialize

# 需要导入模块: from ase.calculators.vasp import Vasp [as 别名]
# 或者: from ase.calculators.vasp.Vasp import neb_nimages [as 别名]
def neb_initialize(neb_images, kwargs):
    """Creates necessary files for an NEB calculation"""
    for a in neb_images:
        log.debug(a.numbers)

    calc = Vasp()

    # how to get the initial and final energies?
    initial = neb_images[0]
    log.debug(initial.numbers)
    calc0 = initial.get_calculator()

    log.debug('Calculator cwd = %s', calc0.cwd)
    log.debug('Calculator vaspdir = %s', calc0.vaspdir)

    # we have to store the initial and final energies because
    # otherwise they will not be available when reread the
    # directory in another script, e.g. jaspsum. The only other
    # option is to make the initial and final directories full
    # vasp calculations.
    CWD = os.getcwd()
    try:

        os.chdir(os.path.join(calc0.cwd, calc0.vaspdir))
        e0 = calc0.read_energy()[1]
        calc.neb_initial_energy = e0
    finally:
        os.chdir(CWD)

    final = neb_images[-1]
    log.debug(final.numbers)
    calc_final = final.get_calculator()
    log.debug(calc_final.cwd)
    log.debug(calc_final.vaspdir)
    try:
        os.chdir(os.path.join(calc_final.cwd, calc_final.vaspdir))
        efinal = calc_final.read_energy()[1]
        calc.neb_final_energy = efinal
    finally:
        os.chdir(CWD)

    # make a Vasp object and set inputs to initial image
    calc.int_params.update(calc0.int_params)
    calc.float_params.update(calc0.float_params)
    calc.exp_params.update(calc0.exp_params)
    calc.string_params.update(calc0.string_params)
    calc.bool_params.update(calc0.bool_params)
    calc.list_params.update(calc0.list_params)
    calc.dict_params.update(calc0.dict_params)
    calc.input_params.update(calc0.input_params)

    calc.neb_kwargs = kwargs
    # this is the vasp images tag. it does not include the endpoints
    IMAGES = len(neb_images) - 2
    calc.set(images=IMAGES)
    calc.neb_images = neb_images
    calc.neb_nimages = IMAGES
    calc.neb = True
    return calc
开发者ID:AkshayTharval,项目名称:jasp,代码行数:61,代码来源:jasp_neb.py


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