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


Python QuasiNewton.attach方法代码示例

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


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

示例1: Atoms

# 需要导入模块: from ase.optimize import QuasiNewton [as 别名]
# 或者: from ase.optimize.QuasiNewton import attach [as 别名]
from ase.optimize import BFGS, QuasiNewton

atoms = Atoms('H7',
              positions=[(0, 0, 0),
                         (1, 0, 0),
                         (0, 1, 0),
                         (1, 1, 0),
                         (0, 2, 0),
                         (1, 2, 0),
                         (0.5, 0.5, 1)],
              constraint=[FixAtoms(range(6))],
              calculator=MorsePotential())

traj = Trajectory('H.traj', 'w', atoms)
dyn = QuasiNewton(atoms, maxstep=0.2)
dyn.attach(traj.write)
dyn.run(fmax=0.01, steps=100)

print(atoms)
del atoms[-1]
print(atoms)
del atoms[5]
print(atoms)
assert len(atoms.constraints[0].index) == 5




fmax = 0.05
nimages = 3
开发者ID:rosswhitfield,项目名称:ase,代码行数:32,代码来源:neb.py

示例2: open

# 需要导入模块: from ase.optimize import QuasiNewton [as 别名]
# 或者: from ase.optimize.QuasiNewton import attach [as 别名]
#		OP_f_text = np.savetxt('out.tmp', OP_f)
#		OP_f_infile = open('out.tmp','r')
#		OP_f_text = OP_f_infile.read()
#		text_file.write(OP_f_text)
#		text_file.close()
#		exit()

	x_dist = a.get_distance(a0 = 0, a1 = 1)
	OP.append(x_dist)	
	epot = a.get_potential_energy() / len(a)
	ekin = a.get_kinetic_energy() / len(a)
	ETOT = epot+ekin
	OP.append(ETOT)

qn = QuasiNewton(atoms, trajectory='qn.traj')
qn.attach(print_distance)
qn.run(fmax=0.001)
qn.attach(print_distance)
write('qn.final.xyz', atoms)

# Set the momenta corresponding to T=300K
MaxwellBoltzmannDistribution(atoms, 300*units.kB)
print 'Removing linear momentum and angular momentum'
Stationary(atoms) # zero linear momentum
ZeroRotation(atoms) # zero angular momentum

# We want to run MD using the VelocityVerlet algorithm.
dyn = VelocityVerlet(atoms, 0.1*units.fs, trajectory='moldyn4.traj') # save trajectory.

#Function to print the potential, kinetic and total energy.
def printenergy(t=atoms):    #store a reference to atoms in the definition.
开发者ID:amaharaj,项目名称:ASE,代码行数:33,代码来源:Relax_Then_Rotate.py

示例3: FixAtoms

# 需要导入模块: from ase.optimize import QuasiNewton [as 别名]
# 或者: from ase.optimize.QuasiNewton import attach [as 别名]
constraint = FixAtoms(indices=indices)
slab.set_constraint(constraint)
dyn = QuasiNewton(slab)
dyn.run(fmax=0.05)
Z = slab.get_positions()[:, 2]
print Z[0] - Z[1]
print Z[1] - Z[2]
print Z[2] - Z[3]

b = 1.2
h = 2.0
slab += Atom('C', (d, 2 * y / 3, h))
slab += Atom('O', (3 * d / 2, y / 3, h))
traj = PickleTrajectory('initial.traj', 'w', slab)
dyn = QuasiNewton(slab)
dyn.attach(traj.write)
dyn.run(fmax=0.05)
#view(slab)
# Make band:
images = [slab.copy() for i in range(6)]
neb = NEB(images, climb=True)

# Set constraints and calculator:
for image in images:
    image.set_calculator(EMT())
    image.set_constraint(constraint)

# Displace last image:
images[-1].positions[-1] = (2 * d, 2 * y / 3, h)
traj = PickleTrajectory('final.traj', 'w', images[-1])
dyn = QuasiNewton(images[-1])
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:33,代码来源:COCu111.py

示例4: Hookean_Always

# 需要导入模块: from ase.optimize import QuasiNewton [as 别名]
# 或者: from ase.optimize.QuasiNewton import attach [as 别名]
                         Hamiltonian_MaxAngularMomentum_='',
                         Hamiltonian_MaxAngularMomentum_H='"s"',
                         ))

c = Hookean_Always(a1=0, a2=1, k=0, rt=0.6)
atoms.set_constraint(c)
OP = []

def print_distance(a=atoms):
        distance = a.get_distance(a0=0,a1=1)
	OP.append(distance)
        epot = a.get_potential_energy() / len(a)
        ekin = a.get_kinetic_energy() / len(a)
        ETOT = epot+ekin
        OP.append(ETOT)

dyn = QuasiNewton(atoms, trajectory='atoms.traj')
dyn.attach(print_distance)
dyn.run(steps=10)
print atoms.get_distance(a0=0, a1=1)
write('test.final.xyz', atoms)

OP_f = [OP[i:i+2] for i in xrange(0,len(OP),2)]
OP_f_text = np.savetxt('out.tmp', OP_f)         # reads array and saves into a file as a string
OP_f_infile = open('out.tmp','r')       # open file to write string array onto
OP_f_text = OP_f_infile.read()

text_file.write(OP_f_text)
text_file.close()
                     
开发者ID:amaharaj,项目名称:ASE,代码行数:31,代码来源:13.py

示例5: range

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

    ranks = np.arange(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 = QuasiNewton(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:qsnake,项目名称:gpaw,代码行数:31,代码来源:neb.py


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