本文整理汇总了Python中ase.neb.NEB.distribute方法的典型用法代码示例。如果您正苦于以下问题:Python NEB.distribute方法的具体用法?Python NEB.distribute怎么用?Python NEB.distribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.neb.NEB
的用法示例。
在下文中一共展示了NEB.distribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute_one_neb
# 需要导入模块: from ase.neb import NEB [as 别名]
# 或者: from ase.neb.NEB import distribute [as 别名]
def execute_one_neb(self, n_cur, to_run, climb=False, many_steps=False):
'''Internal method which executes one NEB optimization.'''
self.iteration += 1
# First we copy around all the images we are not using in this
# neb (for reproducability purposes)
if self.world.rank == 0:
for i in range(n_cur):
if i not in to_run[1: -1]:
filename = '%s%03d.traj' % (self.prefix, i)
self.all_images[i].write(filename)
filename_ref = self.iter_folder + \
'/%s%03diter%03d.traj' % (self.prefix, i,
self.iteration)
if os.path.isfile(filename):
shutil.copy2(filename, filename_ref)
if self.world.rank == 0:
print('Now starting iteration %d on ' % self.iteration, to_run)
# Attach calculators to all the images we will include in the NEB
self.attach_calculators([self.all_images[i] for i in to_run[1: -1]])
neb = NEB([self.all_images[i] for i in to_run],
k=[self.k[i] for i in to_run[0:-1]],
method=self.method,
parallel=self.parallel,
remove_rotation_and_translation=self
.remove_rotation_and_translation,
climb=climb)
# Do the actual NEB calculation
qn = self.optimizer(neb,
logfile=self.iter_folder +
'/%s_log_iter%03d.log' % (self.prefix,
self.iteration))
# Find the ranks which are masters for each their calculation
if self.parallel:
nneb = to_run[0]
nim = len(to_run) - 2
n = self.world.size // nim # number of cpu's per image
j = 1 + self.world.rank // n # my image number
assert nim * n == self.world.size
traj = Trajectory('%s%03d.traj' % (self.prefix, j + nneb), 'w',
self.all_images[j + nneb],
master=(self.world.rank % n == 0))
filename_ref = self.iter_folder + \
'/%s%03diter%03d.traj' % (self.prefix,
j + nneb, self.iteration)
trajhist = Trajectory(filename_ref, 'w',
self.all_images[j + nneb],
master=(self.world.rank % n == 0))
qn.attach(traj)
qn.attach(trajhist)
else:
num = 1
for i, j in enumerate(to_run[1: -1]):
filename_ref = self.iter_folder + \
'/%s%03diter%03d.traj' % (self.prefix, j, self.iteration)
trajhist = Trajectory(filename_ref, 'w', self.all_images[j])
qn.attach(seriel_writer(trajhist, i, num).write)
traj = Trajectory('%s%03d.traj' % (self.prefix, j), 'w',
self.all_images[j])
qn.attach(seriel_writer(traj, i, num).write)
num += 1
if isinstance(self.maxsteps, (list, tuple)) and many_steps:
steps = self.maxsteps[1]
elif isinstance(self.maxsteps, (list, tuple)) and not many_steps:
steps = self.maxsteps[0]
else:
steps = self.maxsteps
if isinstance(self.fmax, (list, tuple)) and many_steps:
fmax = self.fmax[1]
elif isinstance(self.fmax, (list, tuple)) and not many_steps:
fmax = self.fmax[0]
else:
fmax = self.fmax
qn.run(fmax=fmax, steps=steps)
# Remove the calculators and replace them with single
# point calculators and update all the nodes for
# preperration for next iteration
neb.distribute = types.MethodType(store_E_and_F_in_spc, neb)
neb.distribute()