本文整理汇总了Python中gpaw.grid_descriptor.GridDescriptor.collect方法的典型用法代码示例。如果您正苦于以下问题:Python GridDescriptor.collect方法的具体用法?Python GridDescriptor.collect怎么用?Python GridDescriptor.collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpaw.grid_descriptor.GridDescriptor
的用法示例。
在下文中一共展示了GridDescriptor.collect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: f
# 需要导入模块: from gpaw.grid_descriptor import GridDescriptor [as 别名]
# 或者: from gpaw.grid_descriptor.GridDescriptor import collect [as 别名]
def f(n, p):
N = 2 * n
gd = GridDescriptor((N, N, N), (L, L, L))
a = gd.zeros()
print(a.shape)
#p = PoissonSolver(nn=1, relax=relax)
p.set_grid_descriptor(gd)
p.initialize()
cut = N / 2.0 * 0.9
s = Spline(l=0, rmax=cut, f_g=np.array([1, 0.5, 0.0]))
c = LFC(gd, [[s], [s]])
c.set_positions([(0, 0, 0), (0.5, 0.5, 0.5)])
c.add(a)
I0 = gd.integrate(a)
a -= gd.integrate(a) / L**3
I = gd.integrate(a)
b = gd.zeros()
p.solve(b, a, charge=0)#, eps=1e-20)
return gd.collect(b, broadcast=1)
示例2: GridDescriptor
# 需要导入模块: from gpaw.grid_descriptor import GridDescriptor [as 别名]
# 或者: from gpaw.grid_descriptor.GridDescriptor import collect [as 别名]
gd = GridDescriptor((8, 1, 1), (8.0, 1.0, 1.0), comm=domain_comm)
a = gd.zeros()
dadx = gd.zeros()
a[:, 0, 0] = np.arange(gd.beg_c[0], gd.end_c[0])
gradx = Gradient(gd, v=0)
print a.itemsize, a.dtype, a.shape
print dadx.itemsize, dadx.dtype, dadx.shape
gradx.apply(a, dadx)
# a = [ 0. 1. 2. 3. 4. 5. 6. 7.]
#
# da
# -- = [-2.5 1. 1. 1. 1. 1. 1. -2.5]
# dx
dadx = gd.collect(dadx, broadcast=True)
assert dadx[3, 0, 0] == 1.0 and np.sum(dadx[:, 0, 0]) == 0.0
gd = GridDescriptor((1, 8, 1), (1.0, 8.0, 1.0), (1, 0, 1), comm=domain_comm)
dady = gd.zeros()
a = gd.zeros()
grady = Gradient(gd, v=1)
a[0, :, 0] = np.arange(gd.beg_c[1], gd.end_c[1]) - 1
grady.apply(a, dady)
# da
# -- = [0.5 1. 1. 1. 1. 1. -2.5]
# dy
dady = gd.collect(dady, broadcast=True)
assert dady[0, 0, 0] == 0.5 and np.sum(dady[0, :, 0]) == 3.0