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


Python Vasp.algo方法代码示例

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


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

示例1: test_algo_keyword

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import algo [as 别名]
def test_algo_keyword():
    from pickle import loads, dumps
    from pylada.vasp import Vasp
    import pylada

    pylada.is_vasp_4 = True
    a = Vasp()

    # default.
    assert a.algo == 'Fast'
    # wrong argument.
    try:
        a.algo = 0
    except:
        pass
    else:
        raise RuntimeError()
    try:
        a.algo = "WTF"
    except:
        pass
    else:
        raise RuntimeError()

    # possible inputs and some.
    d = {
        'Very_Fast': ['very fast', 'VERY-fAst', 'very_FAST', 'v'],
        'VeryFast': ['very fast', 'VERY-fAst', 'very_FAST', 'v'],
        'Fast': ['fast', 'f'],
        'Normal': ['normal', 'n'],
        'Damped': ['damped', 'd'],
        'Diag': ['diag'],
        'All': ['all', 'a'],
        'None': ['none'],
        'Nothing': ['nothing'],
        'chi': ['chi'],
        'GW': ['gw'],
        'GW0': ['gw0'],
        'scGW': ['scgw'],
        'scGW0': ['scgw0'],
        'Conjugate': ['conjugate', 'c'],
        'Subrot': ['subrot', 's'],
        'Eigenval': ['eigenval', 'e']
    }
    vasp5 = 'Subrot', 'chi', 'GW', 'GW0', 'scGW', 'scGW0', 'Conjugate', 'Eigenval', 'Exact', 'Nothing'
    dictionary = {'Algo': a._input['algo'].__class__}
    for isvasp4 in [True, False]:
        pylada.is_vasp_4 = isvasp4
        for key, items in d.items():
            for value in items:
                if key in vasp5 and isvasp4:
                    try:
                        a.algo = value
                    except:
                        pass
                    else:
                        raise RuntimeError((value, key))
                    continue
                a.algo = value
                o = a._input['algo']
                if key == 'VeryFast' and isvasp4:
                    assert a.algo == 'Very_Fast'
                    assert o.output_map()['algo'] == 'Very_Fast'
                    assert loads(dumps(o)).output_map()["algo"] == 'Very_Fast'
                    assert eval(repr(o), dictionary).output_map()["algo"] == 'Very_Fast'
                elif key == 'Very_Fast' and not isvasp4:
                    assert a.algo == 'VeryFast'
                    assert o.output_map()['algo'] == 'VeryFast'
                    assert loads(dumps(o)).output_map()["algo"] == 'VeryFast'
                    assert eval(repr(o), dictionary).output_map()["algo"] == 'VeryFast'
                else:
                    assert a.algo == key
                    assert o.output_map()['algo'] == key
                    assert loads(dumps(o)).output_map()["algo"] == key
                    assert eval(repr(o), dictionary).output_map()["algo"] == key

    a.algo = None
    assert a.algo is None
    assert o.output_map() is None
    assert loads(dumps(o)).output_map() is None
    assert eval(repr(o), dictionary).output_map() is None
开发者ID:pylada,项目名称:pylada-light,代码行数:83,代码来源:test_algo.py


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