atoms = Atoms([ Atom('Pd', [5.078689759346383, 5.410678028467162, 4.000000000000000]), Atom('Pd', [7.522055777772603, 4.000000000000000, 4.000000000000000]), Atom('Pd', [7.522055777772603, 6.821356056934325, 4.000000000000000]), Atom('Pd', [6.707600438297196, 5.410678028467162, 6.303627574066606]), Atom('N', [4.807604264052752, 5.728625577716107, 5.919407072553396]), Atom('H', [4.000000000000000, 5.965167390141987, 6.490469524180266]), ]) constraint = FixAtoms(mask=[a.symbol == 'Pd' for a in atoms]) atoms.set_constraint(constraint) atoms.center(vacuum=4.0) atoms.set_pbc(False) return atoms def get_calculator(): calc = GPAW(gpts=(64, 64, 64), #h=0.18, gives 64x60x60 mode='lcao', basis='szp(dzp)', nbands=-5, xc='LDA', width=0.1, mixer=Mixer(beta=0.1, nmaxold=5, weight=50.0), poissonsolver=PoissonSolver(nn='M', relax='GS'), convergence={'energy': 1e-4, 'bands': -3}, stencils=(3, 3), txt='nanoparticle.txt') return calc run_test(get_atoms, get_calculator, name, fmax=0.05, steps=200)
name = 'CO_Au111' def get_atoms(): zpos = cos(134.3 / 2.0 * pi / 180.0) * 1.197 xpos = sin(134.3 / 2.0 * pi / 180.0) * 1.19 no2 = Atoms('CO', positions=[(-xpos + 1.2, 0, -zpos), (-xpos + 1.2, -1.1, -zpos)]) # Surface slab slab = fcc111('Au', size=(2, 2, 4), vacuum=2 * 5, orthogonal=True) slab.center() add_adsorbate(slab, no2, 1.5, 'bridge') slab.set_pbc((True, True, False)) #constraints constraint = FixAtoms(mask=[(a.tag == 4) or (a.tag == 3) or (a.tag == 2) for a in slab]) slab.set_constraint(constraint) return slab def get_calculator(): calc = EMT() return calc run_test(get_atoms, get_calculator, name, steps=200)
i = 0 for image in neb.images[1:-1]: if not mpi.parallel or mpi.rank // (mpi.size // 3) == i: image.set_calculator(calc) i += 1 neb.set_calculator = set_calculator return neb def get_calculator_emt(): return EMT() def get_calculator_gpaw(): if mpi.parallel: assert mpi.size % 3 == 0 s = mpi.size // 3 r0 = mpi.rank // s * s comm = range(r0, r0 + s) else: comm = mpi.world calc = GPAW(h=0.25, kpts=(2, 2, 1), communicator=comm, txt='neb-%d.txt' % r0) return calc run_test(get_atoms, get_calculator_emt, name + '-emt') run_test(get_atoms, get_calculator_gpaw, name + '-gpaw')
from math import sin, cos, pi from ase import Atoms from ase.calculators.emt import EMT from ase.constraints import FixAtoms from ase.optimize.test import run_test from ase.build import fcc111, add_adsorbate name = 'CO_Au111' def get_atoms(): zpos = cos(134.3/2.0*pi/180.0)*1.197 xpos = sin(134.3/2.0*pi/180.0)*1.19 no2 =Atoms('CO', positions=[(-xpos+1.2,0,-zpos), (-xpos+1.2,-1.1,-zpos)]) # Surface slab slab =fcc111('Au', size=(2, 2, 4),vacuum=2*5, orthogonal = True ) slab.center() add_adsorbate(slab,no2,1.5,'bridge') slab.set_pbc((True,True,False)) #constraints constraint = FixAtoms(mask=[(a.tag == 4) or (a.tag == 3) or (a.tag==2) for a in slab]) slab.set_constraint(constraint) return slab def get_calculator(): calc = EMT() return calc run_test(get_atoms, get_calculator, name, steps=200)
if not mpi.parallel or mpi.rank // (mpi.size // 3) == i: image.set_calculator(calc) i += 1 neb.set_calculator = set_calculator return neb def get_calculator_emt(): return EMT() def get_calculator_gpaw(): if mpi.parallel: assert mpi.size % 3 == 0 s = mpi.size // 3 r0 = mpi.rank // s * s comm = range(r0, r0 + s) else: comm = mpi.world calc = GPAW(h=0.25, kpts=(2, 2, 1), communicator=comm, txt='neb-%d.txt' % r0) return calc run_test(get_atoms, get_calculator_emt, name + '-emt') run_test(get_atoms, get_calculator_gpaw, name + '-gpaw')
(0.0582, 0.0582, 9.4227), (2.5965, -0.2051, 9.4199), (5.1282, 0.0663, 9.4037), (7.6808, -0.0157, 9.4235), (-0.2051, 2.5965, 9.4199), (2.1913, 2.1913, 9.6123), (5.0046, 2.5955, 9.4873), (7.5409, 2.5336, 9.4126), (0.0663, 5.1282, 9.4037), (2.5955, 5.0046, 9.4873), (5.3381, 5.3381, 9.6106), (7.8015, 5.0682, 9.4237), (-0.0157, 7.6808, 9.4235), (2.5336, 7.5409, 9.4126), (5.0682, 7.8015, 9.4237), (7.6155, 7.6155, 9.4317)]) c2=Atoms('C2', [(3.2897, 3.2897, 10.6627), (4.2113, 4.2113, 10.6493)]) srf.extend(c2) srf.pbc=(1, 1, 0) srf.set_cell([ 10.2106, 10.2106, 20.6572],scale_atoms=False) mask=[a.index < 32 for a in srf] c1 = FixedPlane(-1, (1/np.sqrt(2), 1/np.sqrt(2), 1)) c2 = FixedPlane(-2, (1/np.sqrt(2), 1/np.sqrt(2), 1)) constraint = FixAtoms(mask=mask) srf.set_constraint([constraint, c1, c2]) return srf run_test(get_atoms, get_calculator, 'C2_Cu100')
Atom('Cu', [ 8.433333333333335, 5.009870513769302, -2.146500000000000]), Atom('Cu', [ 9.771531840491031, 4.244150023558828, -0.202086055768371]), Atom('Cu', [ 11.133333333333335, 5.009870513769302, -2.146500000000000]), Atom('Cu', [ 3.021531840490714, 6.582418613776583, -0.202086055768197]), Atom('Cu', [ 4.383333333333334, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 5.721531840490814, 6.582418613776629, -0.202086055768203]), Atom('Cu', [ 7.083333333333333, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 8.421531840490985, 6.582418613776876, -0.202086055768357]), Atom('Cu', [ 9.783333333333335, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 11.121531840490929, 6.582418613776676, -0.202086055768221]), Atom('Cu', [ 12.483333333333334, 7.348139103987287, -2.146500000000000]), ]) mask = [a.position[2] < -1 for a in slab] slab.set_constraint(FixAtoms(mask=mask)) h = 1.85 d = 1.10 molecule = Atoms('2N', positions=[(0., 0., h), (0., 0., h + d)]) molecule.set_calculator(EMT()) slab.extend(molecule) return slab def get_calculator(): return EMT() run_test(get_atoms_surf, get_calculator, name + '-surf', steps=200) run_test(get_atoms_adsorbate, get_calculator, name + '-N2', steps=200)
Atom('Cu', [ 11.133333333333335, 5.009870513769302, -2.146500000000000]), Atom('Cu', [ 3.021531840490714, 6.582418613776583, -0.202086055768197]), Atom('Cu', [ 4.383333333333334, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 5.721531840490814, 6.582418613776629, -0.202086055768203]), Atom('Cu', [ 7.083333333333333, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 8.421531840490985, 6.582418613776876, -0.202086055768357]), Atom('Cu', [ 9.783333333333335, 7.348139103987287, -2.146500000000000]), Atom('Cu', [ 11.121531840490929, 6.582418613776676, -0.202086055768221]), Atom('Cu', [ 12.483333333333334, 7.348139103987287, -2.146500000000000]), ]) mask = [a.position[2] < -1 for a in slab] slab.set_constraint(FixAtoms(mask=mask)) a = 2.70 c = 1.59 * a h = 1.85 d = 1.10 x = slab.positions[0, 2] / (c / 2) * 100 molecule = Atoms('2N', positions=[(0., 0., h), (0., 0., h + d)]) molecule.set_calculator(EMT()) slab.extend(molecule) return slab def get_calculator(): return EMT() run_test(get_atoms_surf, get_calculator, name + '-surf', steps=200) run_test(get_atoms_adsorbate, get_calculator, name + '-N2', steps=200)
[5.00000011, 6.30002353, 5.9163716], [5.88571848, 5.0122839, 6.82246859], [5.88625613, 5.01308931, 5.01214155], [7.14329342, 7.18115393, 6.81640316], [7.14551332, 7.17200869, 5.00879027], [8.41609966, 5.00661165, 5.02355167], [8.41971183, 5.0251482, 6.83462168], [9.69568096, 7.18645894, 6.8078633], [9.68914668, 7.16663649, 5.00000011], [10.95518898, 5.02163182, 6.8289018], [11.83752486, 6.29836826, 5.90274952], [10.94464142, 5.00000011, 5.01802495], ], ) return atoms def get_calculator(): calc = GPAW( h=0.2, mode="lcao", basis="szp(dzp)", mixer=Mixer(beta=0.1, nmaxold=5, weight=50.0), poissonsolver=PoissonSolver(nn="M", relax="GS"), txt="C5H12.txt", ) return calc run_test(get_atoms, get_calculator, name + "-gpaw")
from ase.calculators.emt import EMT from ase.lattice.cubic import FaceCenteredCubic from ase.optimize.test import run_test name = 'Cu_bulk' def get_atoms(): atoms = FaceCenteredCubic(directions=[[1,-1,0], [1,1,0], [0,0,1]], size=(3,3,3), symbol='Cu', pbc=(1,1,1)) atoms.rattle(stdev=0.1,seed=42) return atoms def get_calculator(): return EMT() run_test(get_atoms, get_calculator, name, fmax=0.02)
(1.2409, 1.2409, 7.6081), (3.7731, 1.2803, 7.6603), (6.3219, 1.3241, 7.6442), (8.8935, 1.2669, 7.6189), (1.2803, 3.7731, 7.6603), (3.8188, 3.8188, 7.5870), (6.3457, 3.8718, 7.6649), (8.9174, 3.8340, 7.5976), (1.3241, 6.3219, 7.6442), (3.8718, 6.3457, 7.6649), (6.3945, 6.3945, 7.6495), (8.9576, 6.3976, 7.6213), (1.2669, 8.8935, 7.6189), (3.8340, 8.9174, 7.5976), (6.3976, 8.9576, 7.6213), (8.9367, 8.9367, 7.6539), (0.0582, 0.0582, 9.4227), (2.5965, -0.2051, 9.4199), (5.1282, 0.0663, 9.4037), (7.6808, -0.0157, 9.4235), (-0.2051, 2.5965, 9.4199), (2.1913, 2.1913, 9.6123), (5.0046, 2.5955, 9.4873), (7.5409, 2.5336, 9.4126), (0.0663, 5.1282, 9.4037), (2.5955, 5.0046, 9.4873), (5.3381, 5.3381, 9.6106), (7.8015, 5.0682, 9.4237), (-0.0157, 7.6808, 9.4235), (2.5336, 7.5409, 9.4126), (5.0682, 7.8015, 9.4237), (7.6155, 7.6155, 9.4317)]) c2 = Atoms('C2', [(3.2897, 3.2897, 10.6627), (4.2113, 4.2113, 10.6493)]) srf.extend(c2) srf.pbc = (1, 1, 0) srf.set_cell([10.2106, 10.2106, 20.6572], scale_atoms=False) mask = [a.index < 32 for a in srf] c1 = FixedPlane(-1, (1 / np.sqrt(2), 1 / np.sqrt(2), 1)) c2 = FixedPlane(-2, (1 / np.sqrt(2), 1 / np.sqrt(2), 1)) constraint = FixAtoms(mask=mask) srf.set_constraint([constraint, c1, c2]) return srf run_test(get_atoms, get_calculator, 'C2_Cu100')
[ 5.90380523, 5.65545388, 5.91569796], [ 7.15617518, 6.52907738, 5.91569796], [ 8.41815022, 5.66384716, 5.92196554], [ 9.68108996, 6.52891016, 5.91022362], [ 10.93006206, 5.65545388, 5.91569796], [ 5.00000011, 6.30002353, 5.9163716 ], [ 5.88571848, 5.0122839 , 6.82246859], [ 5.88625613, 5.01308931, 5.01214155], [ 7.14329342, 7.18115393, 6.81640316], [ 7.14551332, 7.17200869, 5.00879027], [ 8.41609966, 5.00661165, 5.02355167], [ 8.41971183, 5.0251482 , 6.83462168], [ 9.69568096, 7.18645894, 6.8078633 ], [ 9.68914668, 7.16663649, 5.00000011], [ 10.95518898, 5.02163182, 6.8289018 ], [ 11.83752486, 6.29836826, 5.90274952], [ 10.94464142, 5.00000011, 5.01802495] ]) return atoms def get_calculator(): calc = GPAW(h=0.2, mode = 'lcao', basis = 'szp(dzp)', mixer=Mixer(beta=0.1, nmaxold=5, weight=50.0), poissonsolver=PoissonSolver(nn='M', relax='GS'), txt='C5H12.txt') return calc run_test(get_atoms, get_calculator, name + '-gpaw')