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


Python BFGS.attach方法代码示例

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


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

示例1: range

# 需要导入模块: from ase.optimize import BFGS [as 别名]
# 或者: from ase.optimize.BFGS import attach [as 别名]
for i in range(3):

    ranks = range(i * n, (i + 1) * n)
    image = initial.copy()

    if rank in ranks:

        calc = GPAW(h=0.3,
                    kpts=(2, 2, 1),
                    txt='neb%d.txt' % j,
                    communicator=ranks)
        
        image.set_calculator(calc)
        
    image.set_constraint(constraint)
    images.append(image)
    
images.append(final)

neb = NEB(images, parallel=True)
neb.interpolate()

qn = BFGS(neb, logfile='qn.log')

traj = PickleTrajectory('neb%d.traj' % j, 'w', images[j],
                        master=(rank % n == 0))

qn.attach(traj)
qn.run(fmax=0.05)
开发者ID:robwarm,项目名称:gpaw-symm,代码行数:31,代码来源:neb.py

示例2: Atoms

# 需要导入模块: from ase.optimize import BFGS [as 别名]
# 或者: from ase.optimize.BFGS import attach [as 别名]
from ase import Atoms
from ase.calculators.emt import EMT
from ase.constraints import FixBondLength
from ase.io import Trajectory
from ase.optimize import BFGS

a = 3.6
b = a / 2
cu = Atoms('Cu2Ag',
           positions=[(0, 0, 0),
                      (b, b, 0),
                      (a, a, b)],
           calculator=EMT())
e0 = cu.get_potential_energy()
print(e0)

d0 = cu.get_distance(0, 1)
cu.set_constraint(FixBondLength(0, 1))
t = Trajectory('cu2ag.traj', 'w', cu)
qn = BFGS(cu)
qn.attach(t.write)
def f(): print(cu.get_distance(0,1))
qn.attach(f)
qn.run(fmax=0.01)
assert abs(cu.get_distance(0, 1) - d0) < 1e-14
开发者ID:misdoro,项目名称:python-ase,代码行数:27,代码来源:emt1.py

示例3: print

# 需要导入模块: from ase.optimize import BFGS [as 别名]
# 或者: from ase.optimize.BFGS import attach [as 别名]
from ase.optimize import BFGS
from ase.io import read, write
from ase.calculators.emt import EMT
from ase.ga.relax_attaches import VariansBreak
import sys


fname = sys.argv[1]

print("Now relaxing {0}".format(fname))
a = read(fname)

a.set_calculator(EMT())
dyn = BFGS(a, trajectory=None, logfile=None)
vb = VariansBreak(a, dyn)
dyn.attach(vb.write)
dyn.run(fmax=0.05)

a.info["key_value_pairs"]["raw_score"] = -a.get_potential_energy()

write(fname[:-5] + "_done.traj", a)

print("Done relaxing {0}".format(fname))
开发者ID:rosswhitfield,项目名称:ase,代码行数:25,代码来源:ga_basic_calc.py

示例4: NEB

# 需要导入模块: from ase.optimize import BFGS [as 别名]
# 或者: from ase.optimize.BFGS import attach [as 别名]
    if i == j:
        image.set_calculator(calc)
    image.set_constraint(constraint)
    images.append(image)
images.append(final)

neb = NEB(images, climb=True, parallel=True)
neb.interpolate()

dyn = BFGS(neb, logfile="logFile") 
#if rank % (size // ) == 0:
#        traj = PickleTrajectory('neb%d.traj' % j, 'w', images[j], master=True)
#        qn.attach(traj)

for i in range(0, numOfImages):
    dyn.attach(PickleTrajectory('neb-%d.traj' % i, 'w', images[i]), master=True)
dyn.run(fmax=0.014)

#writes the coordinates for each image in NEB path in .xyz format
string = 'structure'

path = os.getcwd()
path = path + '/neb-scratch'
if not os.path.exists(path): os.makedirs(path)

outFileName = 'NEB-trajectory.xyz'
if os.path.exists(outFileName):
    os.remove(outFileName)

for i in range(0, neb.nimages):
    string = 'structure%03d' % (i,) +'.xyz'
开发者ID:mina-jafari,项目名称:NEB-scripts,代码行数:33,代码来源:NEB-paral.py


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