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


Python Vasp.get_charge_density方法代码示例

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


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

示例1: Vasp

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import get_charge_density [as 别名]
from vasp import Vasp
import numpy as np
calc = Vasp('molecules/co-centered')
atoms = calc.get_atoms()
x, y, z, cd = calc.get_charge_density()
def interp3d(x,y,z,cd,xi,yi,zi):
    '''
    interpolate a cubic 3D grid defined by x,y,z,cd at the point
    (xi,yi,zi)
    '''
    def get_index(value,vector):
        '''
        assumes vector ordered decreasing to increasing. A bisection
        search would be faster.
        '''
        for i,val in enumerate(vector):
            if val > value:
                return i-1
        return None
    xv = x[:,0,0]
    yv = y[0,:,0]
    zv = z[0,0,:]
    a,b,c = xi, yi, zi
    i = get_index(a,xv)
    j = get_index(b,yv)
    k = get_index(c,zv)
    x1 = x[i,j,k]
    x2 = x[i+1,j,k]
    y1 = y[i,j,k]
    y2 = y[i,j+1,k]
    z1 = z[i,j,k]
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-253.py

示例2: molecule

# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import get_charge_density [as 别名]
### Setup calculators
benzene = molecule('C6H6')
benzene.set_cell([10, 10, 10])
benzene.center()
calc1 = Vasp('molecules/benzene',
            xc='PBE',
            nbands=18,
            encut=350,
            atoms=benzene)
calc1.set(lcharg=True)
chlorobenzene =  molecule('C6H6')
chlorobenzene.set_cell([10, 10, 10])
chlorobenzene.center()
chlorobenzene[11].symbol ='Cl'
calc2 = Vasp('molecules/chlorobenzene',
            xc='PBE',
            nbands=22,
            encut=350,
            atoms=chlorobenzene)
calc2.set(lcharg=True)
calc2.stop_if(None in (calc1.potential_energy, calc2.potential_energy))
x1, y1, z1, cd1 = calc1.get_charge_density()
x2, y2, z2, cd2 = calc2.get_charge_density()
cdiff = cd2 - cd1
print(cdiff.min(), cdiff.max())
##########################################
##### set up visualization of charge difference
from enthought.mayavi import mlab
mlab.contour3d(x1, y1, z1, cdiff,
               contours=[-0.02, 0.02])
mlab.savefig('images/cdiff.png')
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-30.py


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