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


Python Vasp.nbands方法代码示例

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


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

示例1: test_typed

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import nbands [as 别名]
def test_typed():
  from pylada.vasp import Vasp
  from pylada.error import ValueError
  a = Vasp()

  assert a.nbands is None
  assert a._input['nbands'].keyword == 'nbands'
  assert a._input['nbands'].output_map() is None

  a.nbands = 50
  assert a.nbands == 50
  assert 'nbands' in a._input['nbands'].output_map()
  assert a._input['nbands'].output_map()['nbands'] == str(a.nbands)
  a.nbands = '51'
  assert a.nbands == 51
  assert 'nbands' in a._input['nbands'].output_map()
  assert a._input['nbands'].output_map()['nbands'] == str(a.nbands)
  a.nbands = None
  assert a.nbands is None
  assert a._input['nbands'].output_map() is None

  try: a.nbands = 'a'
  except ValueError: pass
  else: raise Exception()

  assert a.smearings is None
  assert a._input['smearings'].keyword == 'smearings'
  assert a._input['smearings'].output_map() is None
  a.smearings = [1.5, 1.0, 0.5]
  assert len(a.smearings) == 3
  assert all(abs(i-v) < 1e-8 for i, v in zip(a.smearings, [1.5, 1.0, 0.5]))
  assert 'smearings' in a._input['smearings'].output_map()
  assert all(abs(float(i)-v) < 1e-8 for i, v in zip(a._input['smearings'].output_map()['smearings'].split(), [1.5, 1.0, 0.5]))
  a.smearings = ['1.2', '0.2']
  assert len(a.smearings) == 2
  assert all(abs(i-v) < 1e-8 for i, v in zip(a.smearings, [1.2, 0.2]))
  assert 'smearings' in a._input['smearings'].output_map()
  assert all(abs(float(i)-v) < 1e-8 for i, v in zip(a._input['smearings'].output_map()['smearings'].split(), [1.2, 0.2]))
  a.smearings = '1.3 0.3'
  assert len(a.smearings) == 2
  assert all(abs(i-v) < 1e-8 for i, v in zip(a.smearings, [1.3, 0.3]))
  assert 'smearings' in a._input['smearings'].output_map()
  assert all(abs(float(i)-v) < 1e-8 for i, v in zip(a._input['smearings'].output_map()['smearings'].split(), [1.3, 0.3]))
  a.smearings = '1.3, 0.3'
  assert len(a.smearings) == 2
  assert all(abs(i-v) < 1e-8 for i, v in zip(a.smearings, [1.3, 0.3]))
  a.smearings = '1.3; 0.3'
  assert len(a.smearings) == 2
  assert all(abs(i-v) < 1e-8 for i, v in zip(a.smearings, [1.3, 0.3]))
  a.smearings = None
  assert a.smearings is None
  assert a._input['smearings'].output_map() is None
  
  try: a.smearings = 5.5
  except ValueError: pass
  else: raise Exception()
  try: a.smearings = [5.5, 'a']
  except ValueError: pass
  else: raise Exception()
开发者ID:mdavezac,项目名称:LaDa,代码行数:61,代码来源:keywords.py

示例2: __call__

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import nbands [as 别名]
    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)
开发者ID:pylada,项目名称:tutorial,代码行数:56,代码来源:custom_chain.py

示例3: __call__

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import nbands [as 别名]
    def __call__(self, structure, outdir=None, vasp=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, MassExtract
        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=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, restart=None, **params)
        if not output.success:
            raise ExternalRunFailed("VASP calculation did not succeed.") 

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

        ## functional for Calc 2
        final = Vasp(copy=vasp)
        final.nbands=24*len(structure_)
        final.kpoints="\n0\nGamma\n2 2 2\n0. 0. 0.\n"
        final.loptics=True
        final.relaxation="static"
        ## end of the functional

        params = deepcopy(kwargs)
        fulldir = join(outdir, name)

        ## if this calculation has not been done, run it
        output = final(structure_, outdir=fulldir, restart=output, **params)
        if not output.success:
            raise ExternalRunFailed("VASP calculation did not succeed.") 

        ############## GW Loop ########################
        for name in self.names[2:]:

            gw = Vasp(copy=vasp)

            gw.kpoints    ="\n0\nGamma\n2 2 2\n0. 0. 0.\n"
            gw.nbands     =24*len(structure_)
            gw.lcharg     = True

            gw.add_keyword('nelm',1)
            gw.add_keyword('algo','gw')
            gw.add_keyword('LMAXFOCKAE',4)
            gw.add_keyword('nomega',64)
            gw.add_keyword('precfock','fast')
            gw.add_keyword('encutgw',50)
            gw.add_keyword('encutlf',50)
            gw.add_keyword('lrpa',False)
            gw.add_keyword('nkred',2)

            params = deepcopy(kwargs)
            fulldir = join(outdir, name)

            ## if this calculation has not been done, run it
            output = gw(structure_, outdir=fulldir, restart=output, **params)
            if not output.success:
                raise ExternalRunFailed("VASP calculation did not succeed.") 
        #########################

        return self.Extract(fulldir)
开发者ID:pylada,项目名称:tutorial,代码行数:84,代码来源:custom_chain_GW.py

示例4: main

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import nbands [as 别名]
def main():
  from boost.mpi import world
  from scipy.optimize import fmin as scipy_simplex
  from pylada.vasp import Extract, ExtractGW, Vasp, Specie
  from pylada.vasp.specie import nlep as nlep_parameters, U as u_parameters
  from pylada.vasp.incar import Standard, NBands
  from sys import exit

  indir = "SnO2"
  dft_in = Extract(directory=indir, comm=world)
  dft_in.OUTCAR = "OUTCAR_pbe"
  dft_in.CONTCAR = "POSCAR"
  gw_in = ExtractGW(directory=indir, comm=world)
  gw_in.OUTCAR = "OUTCAR_gw"
  gw_in.CONTCAR = "POSCAR"

  # Creates species with nlep parameters to optimize
  species = Specie\
            (
              "Sn", 
              path="pseudos/Sn", 
              U=[nlep_parameters(type="Dudarev", l=i, U0=0e0) for i in ["s", "p", "d"]]
            ),\
            Specie\
            (
              "O", 
              path="pseudos/O",
              U=[nlep_parameters(type="Dudarev", l=i, U0=0e0) for i in ["s", "p"]]
            )
  # add U to Sn atoms.
  species[0].U.append( u_parameters(type="Dudarev", U=2e0, l=2) )
  # creates vasp launcher
  vasp = Vasp\
         (
           kpoints    = lambda x: "Automatic generation\n0\ngamma\n6 6 10\n0 0 0",
           precision  = "accurate",
           smearing   = "bloechl",
           ediff      = 1e-5,
           relaxation = "ionic",
           encut      = 1, # uses ENMAX * 1, which is VASP default
           species    = species
         )
  # adds some extra parameters.
  vasp.nbands     = Standard("NBANDS", 64)
  vasp.lorbit     = Standard("LORBIT", 10)
  vasp.npar       = Standard("NPAR", 2)
  vasp.lplane     = Standard("LPLANE", ".TRUE.")
  vasp.addgrid    = Standard("ADDGRID", ".TRUE.")
  del vasp.fftgrid

  # creates objective function.
  objective = Objective(vasp, dft_in, gw_in)

  x0, f0, iter, funcalls, warnflag = scipy_simplex(objective, objective.x, maxfun=150, full_output=1, xtol=0.2)
  world.barrier()
  if world.rank == 0:
    print "minimum value:", f0
    print "for: ", x0 * units
    print "after %i iterations and %i function calls." % (iter, funcalls)
    print "with warning flag: ", warnflag 
    print final(x0)
开发者ID:mdavezac,项目名称:LaDa,代码行数:63,代码来源:test.py


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