Beispiel #1
0
def test_alias():
    from pylada.vasp import Vasp
    from pylada.error import ValueError
    a = Vasp()

    assert a.ismear is None
    assert a._input['ismear'].keyword == 'ismear'
    assert a._input['ismear'].output_map() is None
    map = a._input['ismear'].aliases
    assert len(map) != 0
    for i, items in map.items():
        for item in items:
            a.ismear = item
            assert a.ismear == items[0]
            assert 'ismear' in a._input['ismear'].output_map()
            assert a._input['ismear'].output_map()['ismear'] == str(i)
            a.ismear = i
            assert a.ismear == items[0]
        a.ismear = str(i)
        assert a.ismear == items[0]

    try:
        a.lmaxmix = 'a'
    except ValueError:
        pass
    else:
        raise Exception()
def test_alias():
    from pylada.vasp import Vasp
    from pylada.error import ValueError
    a = Vasp()

    assert a.ismear is None
    assert a._input['ismear'].keyword == 'ismear'
    assert a._input['ismear'].output_map() is None
    map = a._input['ismear'].aliases
    assert len(map) != 0
    for i, items in map.items():
        for item in items:
            a.ismear = item
            assert a.ismear == items[0]
            assert 'ismear' in a._input['ismear'].output_map()
            assert a._input['ismear'].output_map()['ismear'] == str(i)
            a.ismear = i
            assert a.ismear == items[0]
        a.ismear = str(i)
        assert a.ismear == items[0]

    try:
        a.lmaxmix = 'a'
    except ValueError:
        pass
    else:
        raise Exception()
Beispiel #3
0
def test(tmpdir, path):
    from numpy import abs
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.emass import effective_mass, EMass
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, name='has a name')\
        .add_atom(0, 0, 0, "Si")\
        .add_atom(0.25, 0.25, 0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 25e-5
    vasp.encut = 1.4
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
    emass = EMass(copy=vasp)
    assert abs(emass.encut - 1.4) < 1e-8
    assert abs(emass.ediff - 25e-5) < 1e-10
    result = effective_mass(vasp, structure, outdir=str(tmpdir), comm=default_comm,
                            emassparams={'ediff': 1e-8})
    result.emass
    assert result.success
    result = emass(structure, outdir=str(tmpdir), comm=default_comm,
                   emassparams={'ediff': 1e-8})
    assert result.success
Beispiel #4
0
def test(path):
  from os import makedirs
  from os.path import exists
  from shutil import rmtree
  from tempfile import mkdtemp
  from pylada.crystal import Structure
  from pylada.vasp import Vasp
  from pylada import default_comm

  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.prec       = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1
  vasp.ismear     = "fermi"
  vasp.sigma      = 0.01
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
  directory = mkdtemp()
  if directory == '/tmp/test' or directory == '/tmp/test/':
    if exists(directory): rmtree(directory)
    makedirs(directory)
  try: 
    result = vasp(structure, outdir=directory, comm=default_comm)
    assert result.success
  finally: 
    if directory != '/tmp/test' and directory != '/tmp/test/':
      rmtree(directory)
Beispiel #5
0
def test(tmpdir, path):
    from numpy import abs
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.relax import epitaxial
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, name='has a name')\
        .add_atom(0, 0, 0, "Si")\
        .add_atom(0.25, 0.25, 0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1.4
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
    result = epitaxial(vasp,
                       structure,
                       outdir=str(tmpdir),
                       epiconv=1e-5,
                       comm=default_comm)
    assert result.success
    assert abs(result.stress[2, 2]) < 1.0
Beispiel #6
0
def test(path):
  from shutil import rmtree
  from tempfile import mkdtemp
  from pylada.crystal import Structure
  from pylada.vasp import Vasp
  from epirelax import epitaxial
  from pylada import default_comm

  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.prec       = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1.4
  vasp.ismear     = "fermi"
  vasp.sigma      = 0.01
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
  directory = mkdtemp()
  try: 
    result = epitaxial(vasp, structure, outdir=directory, epiconv=1e-4, comm=default_comm)
    assert result.success
  finally: 
    rmtree(directory)
    pass
Beispiel #7
0
def test(tmpdir, path):
    from numpy import all, abs
    from quantities import kbar, eV, angstrom
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.relax import Relax
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
        .add_atom(0, 0, 0, "Si")\
        .add_atom(0.25, 0.25, 0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)

    functional = Relax(copy=vasp)
    assert abs(functional.ediff - 1e-5) < 1e-8
    assert functional.prec == 'Accurate'
    result = functional(structure, outdir=str(tmpdir), comm=default_comm,
                        relaxation="volume ionic cellshape")
    assert result.success

    assert result.stress.units == kbar and all(abs(result.stress) < 1e0)
    assert result.forces.units == eV / angstrom and all(abs(result.forces) < 1e-1)
    assert result.total_energy.units == eV and all(
        abs(result.total_energy + 10.668652 * eV) < 1e-2)
Beispiel #8
0
def test(path):
    from os import makedirs
    from os.path import exists
    from shutil import rmtree
    from tempfile import mkdtemp
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                         .add_atom(0,0,0, "Si")\
                         .add_atom(0.25,0.25,0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
    directory = mkdtemp()
    if directory == '/tmp/test' or directory == '/tmp/test/':
        if exists(directory): rmtree(directory)
        makedirs(directory)
    try:
        result = vasp(structure, outdir=directory, comm=default_comm)
        assert result.success
    finally:
        if directory != '/tmp/test' and directory != '/tmp/test/':
            rmtree(directory)
Beispiel #9
0
def test_incar():
  from shutil import rmtree
  from tempfile import mkdtemp
  from os.path import join, dirname
  from quantities import eV
  from pylada.vasp import Vasp, read_incar
  from pylada.crystal import Structure
  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.precision  = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1
  vasp.ismear     = "metal"
  vasp.sigma      = 0.06
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", join(dirname(__file__), 'pseudos', 'Si')

  directory = mkdtemp()
  try: 
    vasp.write_incar(path=join(directory, 'INCAR'), structure=structure)
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    with open(join(directory, 'INCAR'), 'a') as file:
      file.write('\nSOMETHing = 0.5\n')
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    assert 'something' in other._input
    assert isinstance(other.something, float)
    assert abs(other.something - 0.5) < 1e-8
  finally: 
    rmtree(directory)
    pass
Beispiel #10
0
def test(path):
  from shutil import rmtree
  from tempfile import mkdtemp
  from os.path import join
  from quantities import eV
  from pylada.vasp import Vasp, read_incar
  from pylada.crystal import Structure
  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.precision  = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1
  vasp.ismear     = "metal"
  vasp.sigma      = 0.06
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)

  directory = mkdtemp()
  try: 
    vasp.write_incar(path=join(directory, 'INCAR'), structure=structure)
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    with open(join(directory, 'INCAR'), 'a') as file:
      file.write('\nSOMETHing = 0.5\n')
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    assert 'something' in other._input
    assert isinstance(other.something, float)
    assert abs(other.something - 0.5) < 1e-8
  finally: 
    rmtree(directory)
    pass
Beispiel #11
0
    def __call__(self, structure, outdir=None, **kwargs ):

        from copy import deepcopy
        from os import getcwd
        from os.path import join
        from pylada.misc import RelativePath
        from pylada.error import ExternalRunFailed
        from pylada.vasp.extract import Extract
        from pylada.vasp import Vasp
        from pylada.vasp.relax import Relax

        # make this function stateless.
        structure_ = structure.copy()
        outdir = getcwd() if outdir is None else RelativePath(outdir).path

        ############ Calc 1 ###############
        name  = self.names[0]

        ## functional for Calc 1
        relax = Relax(copy=deepcopy(self.vasp))
        relax.relaxation = "volume ionic cellshape"
        relax.maxiter = 10
        relax.keep_steps = True
        relax.first_trial = { "kpoints": "\n0\nAuto\n10", "encut": 0.9 }
        ## end of the functional
        
        params = deepcopy(kwargs)
        fulldir = join(outdir, name)
        
        ## if this calculation has not been done run it
        output = relax(structure_, outdir=fulldir, **params)
        if not output.success: 
            raise ExternalRunFailed("VASP calculation did not succeed.") 

        ############ Calc 2 ###############  
        name  = self.names[1]

        ## functional for Calc 2
        wfn = Vasp(copy=deepcopy(self.vasp))
        wfn.isym    = 1
        wfn.ismear  = -5
        wfn.nbands=24*len(structure_)
        wfn.kpoints="\n0\nGamma\n4 4 4\n0. 0. 0.\n"
        ## end of the functional
        
        params = deepcopy(kwargs)
        fulldir = join(outdir, name)
        
        ## if this calculation has not been done, run it
        output = wfn(structure_, outdir=fulldir, restart=output, **params)
        if not output.success: 
            raise ExternalRunFailed("VASP calculation did not succeed.") 

        return self.Extract(fulldir)
def vasp():
    from os.path import join, dirname
    from pylada.vasp import Vasp
    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.precision = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "metal"
    vasp.sigma = 0.06
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", join(dirname(__file__), 'pseudos', 'Si')
    return vasp
Beispiel #13
0
def vasp():
    from os.path import join, dirname
    from pylada.vasp import Vasp
    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.precision = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "metal"
    vasp.sigma = 0.06
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", join(dirname(__file__), 'pseudos', 'Si')
    return vasp
Beispiel #14
0
def test(path):
    from shutil import rmtree
    from os.path import exists
    from os import makedirs
    from tempfile import mkdtemp
    from numpy import abs
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.emass import effective_mass, EMass
    from pylada import default_comm



    structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, name='has a name')\
                         .add_atom(0,0,0, "Si")\
                         .add_atom(0.25,0.25,0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 25e-5
    vasp.encut = 1.4
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
    emass = EMass(copy=vasp)
    assert abs(emass.encut - 1.4) < 1e-8
    assert abs(emass.ediff - 25e-5) < 1e-10
    directory = "/tmp/test"  #mkdtemp()
    if exists(directory) and directory == '/tmp/test': rmtree(directory)
    if not exists(directory): makedirs(directory)
    try:
        result = effective_mass(vasp,
                                structure,
                                outdir=directory,
                                comm=default_comm,
                                emassparams={'ediff': 1e-8})
        result.emass
        assert result.success
        result = emass(structure,
                       outdir=directory,
                       comm=default_comm,
                       emassparams={'ediff': 1e-8})
        assert result.success
    finally:
        if directory != '/tmp/test': rmtree(directory)
        pass
Beispiel #15
0
def test(path):
  from glob import glob
  from os.path import join
  from shutil import rmtree
  from tempfile import mkdtemp
  from numpy import all, abs
  from quantities import kbar, eV, angstrom
  from pylada.crystal import Structure
  from pylada.vasp import Vasp
  from pylada.vasp.relax import Relax
  from pylada import default_comm
    
  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.prec       = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1
  vasp.ismear     = "fermi"
  vasp.sigma      = 0.01
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
  directory = mkdtemp()
  try: 
    functional = Relax(copy=vasp)
    assert abs(functional.ediff - 1e-5) < 1e-8
    assert functional.prec == 'Accurate'
    result = functional(structure, outdir=directory, comm=default_comm,
                        relaxation="volume ionic cellshape")
    assert result.success
    def sortme(a): return int(a.split('/')[-1])
    dirs = sorted(glob(join(join(directory, '*'), '[0-9]')), key=sortme)
  # for previous, current in zip(dirs, dirs[1:]):
  #   assert len(check_output(['diff', join(previous, 'CONTCAR'), join(current, 'POSCAR')])) == 0
  # assert len(check_output(['diff', join(current, 'CONTCAR'), join(directory, 'POSCAR')])) == 0
    assert result.stress.units == kbar and all(abs(result.stress) < 1e0)
    assert result.forces.units == eV/angstrom and all(abs(result.forces) < 1e-1)
    assert result.total_energy.units == eV and all(abs(result.total_energy + 10.668652*eV) < 1e-2)

  finally: 
    if directory != '/tmp/test/relax': rmtree(directory)
    pass
Beispiel #16
0
def test(path):
  from shutil import rmtree
  from os.path import exists
  from os import makedirs
  from tempfile import mkdtemp
  from numpy import abs
  from pylada.crystal import Structure
  from pylada.vasp import Vasp
  from pylada.vasp.emass import effective_mass, EMass
  from pylada import default_comm

    
    
  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.prec       = "accurate"
  vasp.ediff      = 25e-5
  vasp.encut      = 1.4
  vasp.ismear     = "fermi"
  vasp.sigma      = 0.01
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
  emass = EMass(copy=vasp)
  assert abs(emass.encut - 1.4) < 1e-8
  assert abs(emass.ediff - 25e-5) < 1e-10
  directory = "/tmp/test" #mkdtemp()
  if exists(directory) and directory == '/tmp/test': rmtree(directory)
  if not exists(directory): makedirs(directory)
  try: 
    result = effective_mass(vasp, structure, outdir=directory, comm=default_comm,
                            emassparams={'ediff': 1e-8})
    result.emass
    assert result.success
    result = emass(structure, outdir=directory, comm=default_comm,
                   emassparams={'ediff': 1e-8})
    assert result.success
  finally: 
    if directory != '/tmp/test': rmtree(directory)
    pass
Beispiel #17
0
def test(tmpdir, path):
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
        .add_atom(0, 0, 0, "Si")\
        .add_atom(0.25, 0.25, 0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
    result = vasp(structure, outdir=str(tmpdir), comm=default_comm)
    assert result.success
Beispiel #18
0
def test(tmpdir, path):
    from numpy import all, abs
    from quantities import kbar, eV, angstrom
    from pylada.crystal import Structure
    from pylada.vasp import Vasp
    from pylada.vasp.relax import Relax
    from pylada import default_comm

    structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
        .add_atom(0, 0, 0, "Si")\
        .add_atom(0.25, 0.25, 0.25, "Si")

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.prec = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "fermi"
    vasp.sigma = 0.01
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)

    functional = Relax(copy=vasp)
    assert abs(functional.ediff - 1e-5) < 1e-8
    assert functional.prec == 'Accurate'
    result = functional(structure,
                        outdir=str(tmpdir),
                        comm=default_comm,
                        relaxation="volume ionic cellshape")
    assert result.success

    assert result.stress.units == kbar and all(abs(result.stress) < 1e0)
    assert result.forces.units == eV / angstrom and all(
        abs(result.forces) < 1e-1)
    assert result.total_energy.units == eV and all(
        abs(result.total_energy + 10.668652 * eV) < 1e-2)
Beispiel #19
0
    if n3==0:n3=1

    return "\n0\nGamma\n%2i %2i %2i\n 0. 0. 0.\n" %(n1,n2,n3)

############### setting up the functional
vasp=Vasp()

vasp.program = '/home/vstevano/bin/vasp'

pseudoDir = '/home/vstevano/software/pseudos'
vasp.add_specie = "In", pseudoDir + "/In"
vasp.add_specie = "O", pseudoDir + "/O"

vasp.prec       = "accurate"
vasp.encut      = 340.
vasp.ismear     = 0
vasp.sigma      = 0.05
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
Beispiel #20
0
def test(path):
    from shutil import rmtree
    from tempfile import mkdtemp
    from os.path import join
    from quantities import eV
    from pylada.vasp import Vasp, read_incar
    from pylada.crystal import Structure

    structure = (
        Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name="has a name")
        .add_atom(0, 0, 0, "Si")
        .add_atom(0.25, 0.25, 0.25, "Si")
    )

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.precision = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "metal"
    vasp.sigma = 0.06
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)

    directory = mkdtemp()
    try:
        vasp.write_incar(path=join(directory, "INCAR"), structure=structure)
        other = read_incar(join(directory, "INCAR"))
        assert abs(other.ediff - 1e-5) < 1e-8
        assert abs(other.encut - 245.345) < 1e-8
        assert abs(other.sigma - 0.06 * eV) < 1e-8
        assert other.ibrion == 2
        assert other.icharg == "atomic"
        assert other.isif == 7
        assert other.ismear == "metal"
        assert other.istart == "scratch"
        assert other.lcharg == False
        assert other.nsw == 50
        assert other.relaxation == "volume"
        assert other.system == "has a name"
        with open(join(directory, "INCAR"), "a") as file:
            file.write("\nSOMETHing = 0.5\n")
        other = read_incar(join(directory, "INCAR"))
        assert abs(other.ediff - 1e-5) < 1e-8
        assert abs(other.encut - 245.345) < 1e-8
        assert abs(other.sigma - 0.06 * eV) < 1e-8
        assert other.ibrion == 2
        assert other.icharg == "atomic"
        assert other.isif == 7
        assert other.ismear == "metal"
        assert other.istart == "scratch"
        assert other.lcharg == False
        assert other.nsw == 50
        assert other.relaxation == "volume"
        assert other.system == "has a name"
        assert "something" in other._input
        assert isinstance(other.something, float)
        assert abs(other.something - 0.5) < 1e-8
    finally:
        rmtree(directory)
        pass