Example #1
0
def test_nlep():
  """ Test nlep translation. """
  from pylada.vasp.specie import nlep
  import pylada
  pylada.vasp_has_nlep = True
  a = nlep("liechtenstein", 's', -1e0)
  assert a['type'] == 1 and a['l'] == 0 and abs(a['U0'] + 1e0) < 1e-8 \
         and 'U1' not in a and a['func'] == 'nlep'
  a = nlep("dudarev", 'p', -0.5)
  assert a['type'] == 2 and a['l'] == 1 and abs(a['U0'] + 0.5) < 1e-8 \
         and 'U1' not in a and a['func'] == 'nlep'
  a = nlep("dudarev", 'd')
  assert a['type'] == 2 and a['l'] == 2 and abs(a['U0']) < 1e-8 \
         and 'U1' not in a and a['func'] == 'nlep'
  a = nlep("dudarev", 'f')
  assert a['type'] == 2 and a['l'] == 3 and abs(a['U0']) < 1e-8 \
         and 'U1' not in a and a['func'] == 'nlep'
  try: nlep('shit')
  except: pass
  else: raise RuntimeError()
  try: nlep(l=4)
  except: pass
  else: raise RuntimeError()
  try: nlep(type=0)
  except: pass
  else: raise RuntimeError()
Example #2
0
def test_nlep():
    """ Test nlep translation. """
    from pylada.vasp.specie import nlep
    import pylada
    pylada.vasp_has_nlep = True
    a = nlep("liechtenstein", 's', -1e0)
    assert a['type'] == 1 and a['l'] == 0 and abs(a['U0'] + 1e0) < 1e-8 \
        and 'U1' not in a and a['func'] == 'nlep'
    a = nlep("dudarev", 'p', -0.5)
    assert a['type'] == 2 and a['l'] == 1 and abs(a['U0'] + 0.5) < 1e-8 \
        and 'U1' not in a and a['func'] == 'nlep'
    a = nlep("dudarev", 'd')
    assert a['type'] == 2 and a['l'] == 2 and abs(a['U0']) < 1e-8 \
        and 'U1' not in a and a['func'] == 'nlep'
    a = nlep("dudarev", 'f')
    assert a['type'] == 2 and a['l'] == 3 and abs(a['U0']) < 1e-8 \
        and 'U1' not in a and a['func'] == 'nlep'
    try:
        nlep('shit')
    except:
        pass
    else:
        raise RuntimeError()
    try:
        nlep(l=4)
    except:
        pass
    else:
        raise RuntimeError()
    try:
        nlep(type=0)
    except:
        pass
    else:
        raise RuntimeError()
def test_enabled_complex_nlep(vasp, structure, Specie):
    from numpy import all, abs, array
    from pylada.vasp.specie import U, nlep
    import pylada
    pylada.vasp_has_nlep = True

    vasp.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]),
        'X': Specie([])
    }
    vasp.ldau = True
    map = vasp.output_map(vasp=vasp, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(
        abs(array(map['LDUL1'].split(), dtype='float64') - [0, 0, -1]) < 1e-8)
    assert all(
        abs(array(map['LDUU1'].split(), dtype='float64') -
            [0.5, -0.5, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUJ1'].split(), dtype='float64') - [0, 0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUO1'].split(), dtype='float64') - [1, 1, 1]) < 1e-8)
    assert all(
        abs(array(map['LDUL2'].split(), dtype='float64') - [-1, 2, -1]) < 1e-8)
    assert all(
        abs(array(map['LDUU2'].split(), dtype='float64') -
            [0, -1.0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUJ2'].split(), dtype='float64') -
            [0, -3.0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUO2'].split(), dtype='float64') - [1, 3, 1]) < 1e-8)
def test_disabled_nlep(vasp, Specie, structure):
    from numpy import all, abs, array
    from pylada.vasp.specie import U, nlep
    import pylada
    pylada.vasp_has_nlep = True

    vasp.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]),
        'X': Specie([])
    }
    vasp.ldau = False
    assert vasp.ldau == False
    assert vasp.output_map(vasp=vasp) is None
def test_disabled_nlep(vasp, Specie, structure):
    from numpy import all, abs, array
    from pylada.vasp.specie import U, nlep
    import pylada
    pylada.vasp_has_nlep = True

    vasp.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]),
        'X': Specie([])
    }
    vasp.ldau = False
    assert vasp.ldau == False
    assert vasp.output_map(vasp=vasp) is None
def test_enabled_complex_nlep(vasp, structure, Specie):
    from numpy import all, abs, array
    from pylada.vasp.specie import U, nlep
    import pylada
    pylada.vasp_has_nlep = True

    vasp.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]),
        'X': Specie([])
    }
    vasp.ldau = True
    map = vasp.output_map(vasp=vasp, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(abs(array(map['LDUL1'].split(), dtype='float64') - [0, 0, -1]) < 1e-8)
    assert all(abs(array(map['LDUU1'].split(), dtype='float64') - [0.5, -0.5, 0]) < 1e-8)
    assert all(abs(array(map['LDUJ1'].split(), dtype='float64') - [0, 0, 0]) < 1e-8)
    assert all(abs(array(map['LDUO1'].split(), dtype='float64') - [1, 1, 1]) < 1e-8)
    assert all(abs(array(map['LDUL2'].split(), dtype='float64') - [-1, 2, -1]) < 1e-8)
    assert all(abs(array(map['LDUU2'].split(), dtype='float64') - [0, -1.0, 0]) < 1e-8)
    assert all(abs(array(map['LDUJ2'].split(), dtype='float64') - [0, -3.0, 0]) < 1e-8)
    assert all(abs(array(map['LDUO2'].split(), dtype='float64') - [1, 3, 1]) < 1e-8)
Example #7
0
def test():
    from collections import namedtuple
    from pickle import loads, dumps
    from pylada.crystal.cppwrappers import Structure
    from pylada.vasp.incar._params import UParams
    from pylada.vasp.specie import U, nlep

    u = 0.25
    x, y = u, 0.25 - u
    structure = Structure([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]) \
                         .add_atom(5.000000e-01, 5.000000e-01, 5.000000e-01, "A") \
                         .add_atom(5.000000e-01, 2.500000e-01, 2.500000e-01, "A") \
                         .add_atom(2.500000e-01, 5.000000e-01, 2.500000e-01, "A") \
                         .add_atom(2.500000e-01, 2.500000e-01, 5.000000e-01, "A") \
                         .add_atom(8.750000e-01, 8.750000e-01, 8.750000e-01, "B") \
                         .add_atom(1.250000e-01, 1.250000e-01, 1.250000e-01, "B") \
                         .add_atom(     x,     x,     x, "X") \
                         .add_atom(     x,     y,     y, "X") \
                         .add_atom(     y,     x,     y, "X") \
                         .add_atom(     y,     y,     x, "X") \
                         .add_atom(    -x,    -x,    -x, "X") \
                         .add_atom(    -x,    -y,    -y, "X") \
                         .add_atom(    -y,    -x,    -y, "X") \
                         .add_atom(    -y,    -y,    -x, "X")
    Vasp = namedtuple('Vasp', ['species'])
    Specie = namedtuple('Specie', ['U'])
    vasp = Vasp({
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]),
        'X': Specie([])
    })
    a =\
  """\
LDAU = .TRUE.
LDAUPRINT = 0
LDAUTYPE = 2

LDUL1= 0 -1 0
LDUU1=   5.0000000000e-01   0.0000000000e+00  -5.0000000000e-01
LDUJ1=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO1= 1 1 1

LDUL2= -1 -1 1
LDUU2=   0.0000000000e+00   0.0000000000e+00  -1.0000000000e+00
LDUJ2=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO2= 1 1 2
"""
    assert a == UParams('off').incar_string(vasp=vasp, structure=structure)
    vasp = Vasp({
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]),
        'X': Specie([])
    })
    a =\
  """\
LDAU = .TRUE.
LDAUPRINT = 1
LDAUTYPE = 2

LDUL1= 0 -1 0
LDUU1=   5.0000000000e-01   0.0000000000e+00  -5.0000000000e-01
LDUJ1=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO1= 1 1 1

LDUL2= -1 -1 2
LDUU2=   0.0000000000e+00   0.0000000000e+00  -1.0000000000e+00
LDUJ2=   0.0000000000e+00   0.0000000000e+00  -3.0000000000e+00
LDUO2= 1 1 3
"""
    assert a == UParams('on').incar_string(vasp=vasp, structure=structure)
    vasp = Vasp({'A': Specie([]), 'B': Specie([]), 'X': Specie([])})
    assert '# no LDA+U/NLEP parameters' == UParams('all').incar_string(
        vasp=vasp, structure=structure)

    assert repr(UParams('off')) == "UParams('off')"
    assert repr(UParams('on')) == "UParams('on')"
    assert repr(UParams(None)) == "UParams('off')"
    assert repr(UParams('all')) == "UParams('all')"
    assert repr(loads(dumps(UParams('off')))) == "UParams('off')"
    assert repr(loads(dumps(UParams('on')))) == "UParams('on')"
    assert repr(loads(dumps(UParams(None)))) == "UParams('off')"
    assert repr(loads(dumps(UParams('all')))) == "UParams('all')"
Example #8
0
def test_uparams():
  from collections import namedtuple
  from pickle import loads, dumps
  from pylada.crystal.cppwrappers import Structure
  from pylada.vasp.incar._params import UParams
  from pylada.vasp.specie import U, nlep

  u = 0.25
  x, y = u, 0.25-u
  structure = Structure([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]) \
                       .add_atom(5.000000e-01, 5.000000e-01, 5.000000e-01, "A") \
                       .add_atom(5.000000e-01, 2.500000e-01, 2.500000e-01, "A") \
                       .add_atom(2.500000e-01, 5.000000e-01, 2.500000e-01, "A") \
                       .add_atom(2.500000e-01, 2.500000e-01, 5.000000e-01, "A") \
                       .add_atom(8.750000e-01, 8.750000e-01, 8.750000e-01, "B") \
                       .add_atom(1.250000e-01, 1.250000e-01, 1.250000e-01, "B") \
                       .add_atom(     x,     x,     x, "X") \
                       .add_atom(     x,     y,     y, "X") \
                       .add_atom(     y,     x,     y, "X") \
                       .add_atom(     y,     y,     x, "X") \
                       .add_atom(    -x,    -x,    -x, "X") \
                       .add_atom(    -x,    -y,    -y, "X") \
                       .add_atom(    -y,    -x,    -y, "X") \
                       .add_atom(    -y,    -y,    -x, "X") 
  Vasp = namedtuple('Vasp', ['species'])
  Specie = namedtuple('Specie', ['U'])
  vasp = Vasp({'A': Specie([U(2, 0, 0.5)]), 'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]), 'X': Specie([])})
  a =\
"""\
LDAU = .TRUE.
LDAUPRINT = 0
LDAUTYPE = 2

LDUL1= 0 -1 0
LDUU1=   5.0000000000e-01   0.0000000000e+00  -5.0000000000e-01
LDUJ1=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO1= 1 1 1

LDUL2= -1 -1 1
LDUU2=   0.0000000000e+00   0.0000000000e+00  -1.0000000000e+00
LDUJ2=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO2= 1 1 2
"""
  assert a == UParams('off').incar_string(vasp=vasp, structure=structure)
  vasp = Vasp({'A': Specie([U(2, 0, 0.5)]), 'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]), 'X': Specie([])})
  a =\
"""\
LDAU = .TRUE.
LDAUPRINT = 1
LDAUTYPE = 2

LDUL1= 0 -1 0
LDUU1=   5.0000000000e-01   0.0000000000e+00  -5.0000000000e-01
LDUJ1=   0.0000000000e+00   0.0000000000e+00   0.0000000000e+00
LDUO1= 1 1 1

LDUL2= -1 -1 2
LDUU2=   0.0000000000e+00   0.0000000000e+00  -1.0000000000e+00
LDUJ2=   0.0000000000e+00   0.0000000000e+00  -3.0000000000e+00
LDUO2= 1 1 3
"""
  assert a == UParams('on').incar_string(vasp=vasp, structure=structure)
  vasp = Vasp({'A': Specie([]), 'B': Specie([]), 'X': Specie([])})
  assert '# no LDA+U/NLEP parameters' == UParams('all').incar_string(vasp=vasp, structure=structure)

  assert repr(UParams('off')) == "UParams('off')"
  assert repr(UParams('on')) == "UParams('on')"
  assert repr(UParams(None)) == "UParams('off')"
  assert repr(UParams('all')) == "UParams('all')"
  assert repr(loads(dumps(UParams('off')))) == "UParams('off')"
  assert repr(loads(dumps(UParams('on')))) == "UParams('on')"
  assert repr(loads(dumps(UParams(None)))) == "UParams('off')"
  assert repr(loads(dumps(UParams('all')))) == "UParams('all')"
Example #9
0
def test():
  from collections import namedtuple
  from pickle import loads, dumps
  from numpy import all, abs, array
  from pylada.crystal import Structure
  from pylada.vasp import Vasp
  from pylada.vasp.specie import U, nlep
  import pylada

  u = 0.25
  x, y = u, 0.25-u
  structure = Structure([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]) \
                       .add_atom(5.000000e-01, 5.000000e-01, 5.000000e-01, "A") \
                       .add_atom(5.000000e-01, 2.500000e-01, 2.500000e-01, "A") \
                       .add_atom(2.500000e-01, 5.000000e-01, 2.500000e-01, "A") \
                       .add_atom(2.500000e-01, 2.500000e-01, 5.000000e-01, "A") \
                       .add_atom(8.750000e-01, 8.750000e-01, 8.750000e-01, "B") \
                       .add_atom(1.250000e-01, 1.250000e-01, 1.250000e-01, "B") \
                       .add_atom(     x,     x,     x, "X") \
                       .add_atom(     x,     y,     y, "X") \
                       .add_atom(     y,     x,     y, "X") \
                       .add_atom(     y,     y,     x, "X") \
                       .add_atom(    -x,    -x,    -x, "X") \
                       .add_atom(    -x,    -y,    -y, "X") \
                       .add_atom(    -y,    -x,    -y, "X") \
                       .add_atom(    -y,    -y,    -x, "X") 
  a = Vasp()
  Specie = namedtuple('Specie', ['U'])
  a.species = {'A': Specie([]), 'B': Specie([]), 'X': Specie([])}
  pylada.vasp_has_nlep  = False

  o = a._input['ldau']
  d = {'LDAU': o.__class__}
  assert a.ldau == True
  assert o.output_map(vasp=a, structure=structure) is None
  assert eval(repr(o), d)._value == True
  assert eval(repr(o), d).keyword == 'LDAU'
  assert loads(dumps(o)).keyword == 'LDAU'
  assert loads(dumps(o))._value 

  # now disables U.
  a.species = {'A': Specie([U(2, 0, 0.5)]), 'B': Specie([]), 'X': Specie([])}
  a.ldau = False
  assert a.ldau == False
  print o
  assert o.output_map(vasp=a) is None
  # now prints U
  a.ldau = True
  map = o.output_map(vasp=a, structure=structure)
  assert map['LDAU'] == '.TRUE.'
  assert map['LDAUTYPE'] == '2'
  assert all(abs(array(map['LDUJ'].split(), dtype='float64')) < 1e-8)
  assert all(abs(array(map['LDUU'].split(), dtype='float64')-[0.5, 0, 0]) < 1e-8)
  assert all(abs(array(map['LDUL'].split(), dtype='float64')-[0, -1, -1]) < 1e-8)
  a.species = {'A': Specie([U(2, 0, 0.5)]), 'B': Specie([U(2, 1, 0.6)]), 'X': Specie([])}
  map = o.output_map(vasp=a, structure=structure)
  assert map['LDAU'] == '.TRUE.'
  assert map['LDAUTYPE'] == '2'
  assert all(abs(array(map['LDUJ'].split(), dtype='float64')) < 1e-8)
  assert all(abs(array(map['LDUU'].split(), dtype='float64')-[0.5, 0, 0.6]) < 1e-8)
  assert all(abs(array(map['LDUL'].split(), dtype='float64')-[0, -1, 1]) < 1e-8)
  

  # now tries NLEP
  pylada.vasp_has_nlep = True
  a.species = {'A': Specie([U(2, 0, 0.5)]), 'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]), 'X': Specie([])}
  a.ldau = False
  assert a.ldau == False
  assert o.output_map(vasp=a) is None
  a.ldau = True
  map = o.output_map(vasp=a, structure=structure)
  assert map['LDAU'] == '.TRUE.'
  assert map['LDAUTYPE'] == '2'
  assert all(abs(array(map['LDUL1'].split(), dtype='float64')-[0, -1, 0]) < 1e-8)
  assert all(abs(array(map['LDUU1'].split(), dtype='float64')-[0.5, 0, -0.5]) < 1e-8)
  assert all(abs(array(map['LDUJ1'].split(), dtype='float64')-[0, 0, 0]) < 1e-8)
  assert all(abs(array(map['LDUO1'].split(), dtype='float64')-[1, 1, 1]) < 1e-8)
  assert all(abs(array(map['LDUL2'].split(), dtype='float64')-[-1, -1, 1]) < 1e-8)
  assert all(abs(array(map['LDUU2'].split(), dtype='float64')-[0, 0, -1.0]) < 1e-8)
  assert all(abs(array(map['LDUJ2'].split(), dtype='float64')-[0, 0, 0]) < 1e-8)
  assert all(abs(array(map['LDUO2'].split(), dtype='float64')-[1, 1, 2]) < 1e-8)

  a.species = {'A': Specie([U(2, 0, 0.5)]), 'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]), 'X': Specie([])}
  a.ldau = True
  map = o.output_map(vasp=a, structure=structure)
  assert map['LDAU'] == '.TRUE.'
  assert map['LDAUTYPE'] == '2'
  assert all(abs(array(map['LDUL1'].split(), dtype='float64')-[0, -1, 0]) < 1e-8)
  assert all(abs(array(map['LDUU1'].split(), dtype='float64')-[0.5, 0, -0.5]) < 1e-8)
  assert all(abs(array(map['LDUJ1'].split(), dtype='float64')-[0, 0, 0]) < 1e-8)
  assert all(abs(array(map['LDUO1'].split(), dtype='float64')-[1, 1, 1]) < 1e-8)
  assert all(abs(array(map['LDUL2'].split(), dtype='float64')-[-1, -1, 2]) < 1e-8)
  assert all(abs(array(map['LDUU2'].split(), dtype='float64')-[0, 0, -1.0]) < 1e-8)
  assert all(abs(array(map['LDUJ2'].split(), dtype='float64')-[0, 0, -3.0]) < 1e-8)
  assert all(abs(array(map['LDUO2'].split(), dtype='float64')-[1, 1, 3]) < 1e-8)
Example #10
0
def test():
    from collections import namedtuple
    from pickle import loads, dumps
    from numpy import all, abs, array
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.specie import U, nlep
    import pylada

    u = 0.25
    x, y = u, 0.25 - u
    structure = Structure([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]) \
                         .add_atom(5.000000e-01, 5.000000e-01, 5.000000e-01, "A") \
                         .add_atom(5.000000e-01, 2.500000e-01, 2.500000e-01, "A") \
                         .add_atom(2.500000e-01, 5.000000e-01, 2.500000e-01, "A") \
                         .add_atom(2.500000e-01, 2.500000e-01, 5.000000e-01, "A") \
                         .add_atom(8.750000e-01, 8.750000e-01, 8.750000e-01, "B") \
                         .add_atom(1.250000e-01, 1.250000e-01, 1.250000e-01, "B") \
                         .add_atom(     x,     x,     x, "X") \
                         .add_atom(     x,     y,     y, "X") \
                         .add_atom(     y,     x,     y, "X") \
                         .add_atom(     y,     y,     x, "X") \
                         .add_atom(    -x,    -x,    -x, "X") \
                         .add_atom(    -x,    -y,    -y, "X") \
                         .add_atom(    -y,    -x,    -y, "X") \
                         .add_atom(    -y,    -y,    -x, "X")
    a = Vasp()
    Specie = namedtuple('Specie', ['U'])
    a.species = {'A': Specie([]), 'B': Specie([]), 'X': Specie([])}
    pylada.vasp_has_nlep = False

    o = a._input['ldau']
    d = {'LDAU': o.__class__}
    assert a.ldau == True
    assert o.output_map(vasp=a, structure=structure) is None
    assert eval(repr(o), d)._value == True
    assert eval(repr(o), d).keyword == 'LDAU'
    assert loads(dumps(o)).keyword == 'LDAU'
    assert loads(dumps(o))._value

    # now disables U.
    a.species = {'A': Specie([U(2, 0, 0.5)]), 'B': Specie([]), 'X': Specie([])}
    a.ldau = False
    assert a.ldau == False
    print o
    assert o.output_map(vasp=a) is None
    # now prints U
    a.ldau = True
    map = o.output_map(vasp=a, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(abs(array(map['LDUJ'].split(), dtype='float64')) < 1e-8)
    assert all(
        abs(array(map['LDUU'].split(), dtype='float64') - [0.5, 0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUL'].split(), dtype='float64') - [0, -1, -1]) < 1e-8)
    a.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 1, 0.6)]),
        'X': Specie([])
    }
    map = o.output_map(vasp=a, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(abs(array(map['LDUJ'].split(), dtype='float64')) < 1e-8)
    assert all(
        abs(array(map['LDUU'].split(), dtype='float64') -
            [0.5, 0, 0.6]) < 1e-8)
    assert all(
        abs(array(map['LDUL'].split(), dtype='float64') - [0, -1, 1]) < 1e-8)

    # now tries NLEP
    pylada.vasp_has_nlep = True
    a.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 1, -1.0)]),
        'X': Specie([])
    }
    a.ldau = False
    assert a.ldau == False
    assert o.output_map(vasp=a) is None
    a.ldau = True
    map = o.output_map(vasp=a, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(
        abs(array(map['LDUL1'].split(), dtype='float64') - [0, -1, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUU1'].split(), dtype='float64') -
            [0.5, 0, -0.5]) < 1e-8)
    assert all(
        abs(array(map['LDUJ1'].split(), dtype='float64') - [0, 0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUO1'].split(), dtype='float64') - [1, 1, 1]) < 1e-8)
    assert all(
        abs(array(map['LDUL2'].split(), dtype='float64') - [-1, -1, 1]) < 1e-8)
    assert all(
        abs(array(map['LDUU2'].split(), dtype='float64') -
            [0, 0, -1.0]) < 1e-8)
    assert all(
        abs(array(map['LDUJ2'].split(), dtype='float64') - [0, 0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUO2'].split(), dtype='float64') - [1, 1, 2]) < 1e-8)

    a.species = {
        'A': Specie([U(2, 0, 0.5)]),
        'B': Specie([U(2, 0, -0.5), nlep(2, 2, -1.0, -3.0)]),
        'X': Specie([])
    }
    a.ldau = True
    map = o.output_map(vasp=a, structure=structure)
    assert map['LDAU'] == '.TRUE.'
    assert map['LDAUTYPE'] == '2'
    assert all(
        abs(array(map['LDUL1'].split(), dtype='float64') - [0, -1, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUU1'].split(), dtype='float64') -
            [0.5, 0, -0.5]) < 1e-8)
    assert all(
        abs(array(map['LDUJ1'].split(), dtype='float64') - [0, 0, 0]) < 1e-8)
    assert all(
        abs(array(map['LDUO1'].split(), dtype='float64') - [1, 1, 1]) < 1e-8)
    assert all(
        abs(array(map['LDUL2'].split(), dtype='float64') - [-1, -1, 2]) < 1e-8)
    assert all(
        abs(array(map['LDUU2'].split(), dtype='float64') -
            [0, 0, -1.0]) < 1e-8)
    assert all(
        abs(array(map['LDUJ2'].split(), dtype='float64') -
            [0, 0, -3.0]) < 1e-8)
    assert all(
        abs(array(map['LDUO2'].split(), dtype='float64') - [1, 1, 3]) < 1e-8)
Example #11
0
#  PyLaDa is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
#  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
#  Public License for more details.
#
#  You should have received a copy of the GNU General Public License along with PyLaDa.  If not, see
#  <http://www.gnu.org/licenses/>.
###############################

from pylada.vasp.specie import nlep

def_rng = 5
def_rng3 = 5
def_small_rng = 4
def_large_rng = 20

nlep_Al_s = nlep(type="Dudarev", l="s", U0=1, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)
nlep_Al_p = nlep(type="Dudarev", l="p", U0=0, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)
# this way, can also be specified as:
#nlep_Al_s = {'U1': 0.0, 'l': 0, 'U0': 1.0, 'U1_range': 0.69999999999999996, 'func': 'enlep', 'U0_range': 0.5, 'fitU1': True, 'fitU0': True, 'type': 2}
# direct from results of previous run.

nlep_Mg_s = nlep(type="Dudarev", l="s", U0=0, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)
nlep_Mg_p = nlep(type="Dudarev", l="p", U0=0, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)

nlep_Ga_s = nlep(type="Dudarev", l="s", U0=0, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)
nlep_Ga_p = nlep(type="Dudarev", l="p", U0=0, U1=0, fitU0=True,
                 fitU1=True, U0_range=def_rng,  U1_range=def_rng)
Example #12
0
def test_enlep():
  """ Test enlep translation. """
  from pylada.vasp.specie import nlep
  a = nlep("liechtenstein", 's', -1e0, -5e0)
  assert a['type'] == 1 and a['l'] == 0 and abs(a['U0'] + 1e0) < 1e-8 \
         and abs(a['U1'] + 5e0) < 1e-8 and a['func'] == 'enlep'
Example #13
0
def test_enlep():
    """ Test enlep translation. """
    from pylada.vasp.specie import nlep
    a = nlep("liechtenstein", 's', -1e0, -5e0)
    assert a['type'] == 1 and a['l'] == 0 and abs(a['U0'] + 1e0) < 1e-8 \
        and abs(a['U1'] + 5e0) < 1e-8 and a['func'] == 'enlep'