Beispiel #1
0
def test():
    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'],
        '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.iteritems():
            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
Beispiel #2
0
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
Beispiel #3
0
vasp.ediff      = 1.0e-6
vasp.ediffg     = -0.01
vasp.convergence= 1.0e-6
vasp.nsw        = 1
vasp.lwave      = True
vasp.lorbit     = 10
vasp.lplane     = True
vasp.addgrid    = True
vasp.npar       = 8
vasp.isym       = 0
vasp.lcharg     = True
vasp.lwave      = True
vasp.lmaxmix    = 4
vasp.loptics    = False
vasp.lpead      = False
vasp.algo = "Normal"
vasp.relaxation = "ionic"

relax = Relax(copy=vasp)

relax.nsw=75
relax.minrelsteps= 4
relax.maxiter = 10
relax.keep_steps = True
relax.first_trial = { "kpoints": "\n0\nAuto\n10", "encut": 0.9 }

############### setting up the structures

# input bulk primitive cell
In2O3prim = read.poscar('POSCAR_In2O3')