本文整理汇总了Python中ase.tasks.task.OptimizeTask.optimize方法的典型用法代码示例。如果您正苦于以下问题:Python OptimizeTask.optimize方法的具体用法?Python OptimizeTask.optimize怎么用?Python OptimizeTask.optimize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.tasks.task.OptimizeTask
的用法示例。
在下文中一共展示了OptimizeTask.optimize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculate
# 需要导入模块: from ase.tasks.task import OptimizeTask [as 别名]
# 或者: from ase.tasks.task.OptimizeTask import optimize [as 别名]
def calculate(self, name, atoms):
#????
if self.sfmax is not None and self.fmax is not None:
# this performs first relaxation of internal degrees of freedom
data = OptimizeTask.calculate(self, name, atoms)
# writing traj from optimizer does not work for StrainFilter!
traj = Trajectory(self.get_filename(name, 'traj'), 'a', atoms)
sf = StrainFilter(atoms)
while not self.converged(atoms, sfmax=self.sfmax, fmax=self.fmax):
# take a step on the cell
self.soptimize(name, sf, data, trajectory=traj)
# relax internal degrees of freedom
OptimizeTask.optimize(self, name, atoms, data, trajectory=traj)
data['relaxed energy'] = atoms.get_potential_energy()
data['relaxed volume'] = atoms.get_volume()
elif self.sfmax is not None:
# this performs single-point energy calculation
data = OptimizeTask.calculate(self, name, atoms)
sf = StrainFilter(atoms)
# writing traj from optimizer does not work for StrainFilter!
traj = Trajectory(self.get_filename(name, 'traj'), 'w', atoms)
self.soptimize(name, sf, data, trajectory=traj)
data['relaxed energy'] = atoms.get_potential_energy()
data['relaxed volume'] = atoms.get_volume()
elif self.fmax is not None:
data = OptimizeTask.calculate(self, name, atoms)
else:
# no optimization
if self.fit is None:
# only calculate single-point energy if no fit follows
data = OptimizeTask.calculate(self, name, atoms)
if self.fit is not None:
if self.sfmax is not None or self.fmax is not None:
# fit after optimization
self.fit_volume(name, atoms, data)
else:
# fit is the only task performed
data = self.fit_volume(name, atoms)
return data