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


Python vasp.Vasp类代码示例

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


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

示例1: defect_strain_matrices

def defect_strain_matrices(label,conc,Latt):
	from ase.calculators.vasp import Vasp
	calc = Vasp(restart=1)
	atoms = calc.get_atoms()
	LattDef = numpy.array(atoms.get_cell())
	# LattDef = correct_lattice_matrix(numpy.array(atoms.get_cell()))
	dstrain = (1/conc)*numpy.dot(numpy.subtract(LattDef,Latt),numpy.linalg.inv(Latt))
	dstrain_vec = asetools.tensorise(dstrain)
	outfile = 'defect_strain.txt'
	fout = open(outfile,'w')
	print>>fout, label
	print>>fout, "concentration {:^10}".format(conc)
	print>>fout, "defect strain matrix"
	for item in dstrain:
		print>>fout, '   '.join(map(str, item))
	print>>fout, "defect strain vector"
	for item in dstrain_vec:
		print>>fout, item
	print>>fout, "Defect supercell lattice"
	for item in LattDef:
		print>>fout, '   '.join(map(str, item))
	print>>fout, "Perfect supercell lattice"
	for item in Latt:
		print>>fout, '   '.join(map(str, item))
	fout.close
开发者ID:ankoor7,项目名称:VASP-and-ASE-tools,代码行数:25,代码来源:aseroutines.py

示例2: calculate

    def calculate(self, atoms):
        '''
        Blocking/Non-blocking calculate method

        If we are in blocking mode we just run, wait for 
        the job to end and read in the results. Easy ...
        
        The non-blocking mode is a little tricky. 
        We need to start the job and guard against it reading 
        back possible old data from the directory - the queuing 
        system may not even started the job when we get control 
        back from the starting script. Thus anything we read 
        after invocation is potentially garbage - even if it 
        is a converged calculation data.

        We handle it by custom run function above which 
        raises an exception after submitting the job.
        This skips post-run processing in the calculator, preserves 
        the state of the data and signals here that we need to wait
        for results.
        '''
        
        with work_dir(self.working_dir) :
            self.prepare_calc_dir()
            self.calc_running=True
            #print('Run VASP.calculate')
            try :
                Vasp.calculate(self, atoms)
                self.calc_running=False
                #print('VASP.calculate returned')
            except _NonBlockingRunException as e:
                # We have nothing else to docs
                # until the job finishes
                #print('Interrupted ', self.working_dir, os.getcwd())
                pass
开发者ID:digideskio,项目名称:Elastic,代码行数:35,代码来源:parcalc.py

示例3: update

 def update(self, atoms):
     if self.calc_running :
         # we have started the calculation and have 
         # nothing to read really. But we need to check
         # first if this is still true.
         if  self.calc_finished():
             # We were running but recently finished => read the results
             # This is a piece of copy-and-paste programming
             # This is a copy of code from Vasp.calculate
             self.calc_running=False
             with work_dir(self.working_dir) :
                 atoms_sorted = ase.io.read('CONTCAR', format='vasp') 
                 if self.int_params['ibrion'] > -1 and self.int_params['nsw'] > 0: 
                     # Update atomic positions and unit cell with the ones read 
                     # from CONTCAR. 
                     atoms.positions = atoms_sorted[self.resort].positions 
                     atoms.cell = atoms_sorted.cell 
                 self.converged = self.read_convergence()
                 Vasp.set_results(self,atoms)
             return
         else :
             return
     # We are not in the middle of calculation. 
     # Update as normal
     Vasp.update(self, atoms)
开发者ID:digideskio,项目名称:Elastic,代码行数:25,代码来源:parcalc.py

示例4: run_energy_eval

def run_energy_eval(totalsol, calc_method='LAMMPS', fx_region=False, fit_scheme='totalenfit', STR='', static_calc=None):
    if calc_method=='VASP':
        en=totalsol.get_potential_energy()
        calcb=Vasp(restart=True)
        totalsol=calcb.get_atoms()
        stress=calcb.read_stress()
    else:
        totcop = totalsol.copy()
        OUT = totalsol.calc.calculate(totalsol)
        totalsol = OUT['atoms']
        totalsol.set_pbc(True)
        if fx_region:
            STR+='Energy of fixed region calc = {0}\n'.format(OUT['thermo'][-1]['pe'])
            totalsol.set_calculator(static_calc)
            OUT=totalsol.calc.calculate(totalsol)
            totalsol=OUT['atoms']
            totalsol.set_pbc(True)
            STR+='Energy of static calc = {0}\n'.format(OUT['thermo'][-1]['pe'])
        en=OUT['thermo'][-1]['pe']
        stress=numpy.array([OUT['thermo'][-1][i] for i in ('pxx','pyy','pzz','pyz','pxz','pxy')])*(-1e-4*GPa)
    if fit_scheme == 'enthalpyfit':
        pressure = totalsol.get_isotropic_pressure(stress)
    else:
        pressure = 0
    volume = totalsol.get_volume()
    energy=en
    STR+='Energy per atom = {0}\n'.format(energy/len(totalsol))
    return totalsol, energy, pressure, volume, STR
开发者ID:uw-cmg,项目名称:MAST,代码行数:28,代码来源:eval_energy_non_stem.py

示例5: main

def main():
    if sys.version_info < (2, 7):
        raise NotAvailable('read_xml requires Python version 2.7 or greater')

    assert installed()

    # simple test calculation of CO molecule
    d = 1.14
    co = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)],
               pbc=True)
    co.center(vacuum=5.)

    calc = Vasp(xc='PBE',
                prec='Low',
                algo='Fast',
                ismear=0,
                sigma=1.,
                istart=0,
                lwave=False,
                lcharg=False)

    co.set_calculator(calc)
    energy = co.get_potential_energy()
    forces = co.get_forces()

    # check that parsing of vasprun.xml file works
    conf = read('vasprun.xml')
    assert conf.calc.parameters['kpoints_generation']
    assert conf.calc.parameters['sigma'] == 1.0
    assert conf.calc.parameters['ialgo'] == 68
    assert energy - conf.get_potential_energy() == 0.0
    assert array_almost_equal(conf.get_forces(), forces, tol=1e-4)

    # Cleanup
    calc.clean()
开发者ID:rosswhitfield,项目名称:ase,代码行数:35,代码来源:vasp_xml.py

示例6: __init__

 def __init__(self, nodes=1, ppn=8, block=True, ncl=False, **kwargs):
     Vasp.__init__(self, **kwargs)
     self.nodes=nodes
     self.ppn=ppn
     self.block=block
     self.ncl=ncl
     self.calc_running=False
     self.working_dir=os.getcwd()
开发者ID:digideskio,项目名称:Elastic,代码行数:8,代码来源:parcalc.py

示例7: calc_defect_strain_matrix

def calc_defect_strain_matrix(Latt):
	from ase.calculators.vasp import Vasp
	# defect lattice
	calc = Vasp(restart=1)
	atoms = calc.get_atoms()
	LattDef = numpy.array(atoms.get_cell())
	dstrain = conc*numpy.dot(numpy.subtract(LattDef,Latt.T),numpy.linalg.inv(Latt.T))
	dstrain=asetools.symmetrize(dstrain)
	return dstrain
开发者ID:ankoor7,项目名称:VASP-and-ASE-tools,代码行数:9,代码来源:asetools.py

示例8: get_locpot_array

def get_locpot_array(file):
	""" Returns the charge densities on the fine FFT-grid in a numpy array."""
	from ase.calculators.vasp import VaspChargeDensity
	from ase.calculators.vasp import Vasp
 	calc = Vasp(restart=True)
 	cell = calc.get_atoms()
 	vol = cell.get_volume()
	pot_array = numpy.vstack((VaspChargeDensity(file)).chg)
	numpy.divide(pot_array,vol)
	return pot_array
开发者ID:ankoor7,项目名称:VASP-and-ASE-tools,代码行数:10,代码来源:asetools.py

示例9: write_input_files

 def write_input_files(self, at, label):
     global _chdir_lock
     # For LOTF Simulations active number of quantum 
     # atoms vary and must wait to this stage in order for
     # magnetic moments to be set properly. If magnetic moments
     # not set defaults to 0.
     self.vasp_args['magmom'] = at.get_initial_magnetic_moments()
     vasp = Vasp(**self.vasp_args)
     vasp.initialize(at)
     # chdir not thread safe, so acquire global lock before using it
     orig_dir = os.getcwd()
     try:
         _chdir_lock.acquire()
         os.chdir(self.subdir)
         if os.path.exists('OUTCAR'):
             n = 1
             while os.path.exists('OUTCAR.%d' % n):
                 n += 1
             shutil.copyfile('OUTCAR', 'OUTCAR.%d' % n)
             shutil.copyfile('POSCAR', 'POSCAR.%d' % n)
         write_vasp('POSCAR', vasp.atoms_sorted,
                    symbol_count=vasp.symbol_count,
                    vasp5='5' in self.exe)
         vasp.write_incar(at)
         vasp.write_potcar()
         vasp.write_kpoints()
     finally:
         os.chdir(orig_dir)
         _chdir_lock.release()
开发者ID:libAtoms,项目名称:matscipy,代码行数:29,代码来源:socketcalc.py

示例10: neb_initialize

def neb_initialize(neb_images, kwargs):
    """Creates necessary files for an NEB calculation"""
    for a in neb_images:
        log.debug(a.numbers)

    calc = Vasp()

    # how to get the initial and final energies?
    initial = neb_images[0]
    log.debug(initial.numbers)
    calc0 = initial.get_calculator()

    log.debug('Calculator cwd = %s', calc0.cwd)
    log.debug('Calculator vaspdir = %s', calc0.vaspdir)

    # we have to store the initial and final energies because
    # otherwise they will not be available when reread the
    # directory in another script, e.g. jaspsum. The only other
    # option is to make the initial and final directories full
    # vasp calculations.
    CWD = os.getcwd()
    try:

        os.chdir(os.path.join(calc0.cwd, calc0.vaspdir))
        e0 = calc0.read_energy()[1]
        calc.neb_initial_energy = e0
    finally:
        os.chdir(CWD)

    final = neb_images[-1]
    log.debug(final.numbers)
    calc_final = final.get_calculator()
    log.debug(calc_final.cwd)
    log.debug(calc_final.vaspdir)
    try:
        os.chdir(os.path.join(calc_final.cwd, calc_final.vaspdir))
        efinal = calc_final.read_energy()[1]
        calc.neb_final_energy = efinal
    finally:
        os.chdir(CWD)

    # make a Vasp object and set inputs to initial image
    calc.int_params.update(calc0.int_params)
    calc.float_params.update(calc0.float_params)
    calc.exp_params.update(calc0.exp_params)
    calc.string_params.update(calc0.string_params)
    calc.bool_params.update(calc0.bool_params)
    calc.list_params.update(calc0.list_params)
    calc.dict_params.update(calc0.dict_params)
    calc.input_params.update(calc0.input_params)

    calc.neb_kwargs = kwargs
    # this is the vasp images tag. it does not include the endpoints
    IMAGES = len(neb_images) - 2
    calc.set(images=IMAGES)
    calc.neb_images = neb_images
    calc.neb_nimages = IMAGES
    calc.neb = True
    return calc
开发者ID:AkshayTharval,项目名称:jasp,代码行数:59,代码来源:jasp_neb.py

示例11: set

    def set(self,**kwargs):
        if 'block' in kwargs :
            self.block=kwargs['block']
            del kwargs['block']
        else :
            self.block=True

        if 'ncl' in kwargs :
            self.ncl=kwargs['ncl']
            del kwargs['ncl']
        else :
            self.ncl=False
        Vasp.set(self, **kwargs)
开发者ID:digideskio,项目名称:Elastic,代码行数:13,代码来源:parcalc.py

示例12: ase_vol_relax

def ase_vol_relax():
    Al = bulk('Al', 'fcc', a=4.5, cubic=True)
    calc = Vasp(xc='LDA')
    Al.set_calculator(calc)

    from ase.constraints import StrainFilter
    sf = StrainFilter(Al)
    qn = QuasiNewton(sf, logfile='relaxation.log')
    qn.run(fmax=0.1, steps=5)

    print 'Stress:\n', calc.read_stress()
    print 'Al post ASE volume relaxation\n', calc.get_atoms().get_cell()

    return Al
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:14,代码来源:vasp_Al_volrelax.py

示例13: ase_vol_relax

def ase_vol_relax():
    Al = bulk("Al", "fcc", a=4.5, cubic=True)
    calc = Vasp(xc="LDA")
    Al.set_calculator(calc)

    from ase.constraints import StrainFilter

    sf = StrainFilter(Al)
    qn = QuasiNewton(sf, logfile="relaxation.log")
    qn.run(fmax=0.1, steps=5)

    print("Stress:\n", calc.read_stress())
    print("Al post ASE volume relaxation\n", calc.get_atoms().get_cell())

    return Al
开发者ID:jboes,项目名称:ase,代码行数:15,代码来源:vasp_Al_volrelax.py

示例14: preprocess

    def preprocess(self, at, label, force_restart=False):
        self.logger.pr('vasp client %d preprocessing atoms label %d' % (self.client_id, label))

        # make a copy and then sort atoms in the same way that vasp
        # calculator will when it writes POSCAR. We use a new
        # calculator and store the sort order in the Atoms so it can
        # be reversed when results are ready.
        vasp = Vasp(**self.vasp_args)
        vasp.initialize(at)
        at = at.copy()
        order = np.array(range(len(at)))
        at.set_array('vasp_sort_order', order)
        at = at[vasp.resort]

        # finally, call the parent method
        return Client.preprocess(self, at, label, force_restart)
开发者ID:libAtoms,项目名称:matscipy,代码行数:16,代码来源:socketcalc.py

示例15: run

 def run(self):
     '''
     Blocking/Non-blocing run method.
     In blocking mode it just runs parent run method.
     In non-blocking mode it raises the __NonBlockingRunException
     to bail out of the processing of standard calculate method 
     (or any other method in fact) and signal that the data is not 
     ready to b collected.
     '''
     # This is only called from self.calculate - thus 
     # we do not need to change to working_dir 
     # since calculate already did
     Vasp.run(self)
     if not self.block : 
         #print('Interrupt processing of calculate', os.getcwd())
         raise _NonBlockingRunException
开发者ID:digideskio,项目名称:Elastic,代码行数:16,代码来源:parcalc.py


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