def get_atoms_adsorbate(): # We need the relaxed slab here! slab = Atoms([ Atom('Cu', [-1.028468159509163, -0.432387156877267, -0.202086055768265]), Atom('Cu', [0.333333333333333, 0.333333333333333, -2.146500000000000]), Atom('Cu', [1.671531840490805, -0.432387156877287, -0.202086055768242]), Atom('Cu', [3.033333333333334, 0.333333333333333, -2.146500000000000]), Atom('Cu', [4.371531840490810, -0.432387156877236, -0.202086055768261]), Atom('Cu', [5.733333333333333, 0.333333333333333, -2.146500000000000]), Atom('Cu', [7.071531840490944, -0.432387156877258, -0.202086055768294]), Atom('Cu', [8.433333333333335, 0.333333333333333, -2.146500000000000]), Atom('Cu', [0.321531840490810, 1.905881433340708, -0.202086055768213]), Atom('Cu', [1.683333333333333, 2.671601923551318, -2.146500000000000]), Atom('Cu', [3.021531840490771, 1.905881433340728, -0.202086055768250]), Atom('Cu', [4.383333333333334, 2.671601923551318, -2.146500000000000]), Atom('Cu', [5.721531840490857, 1.905881433340735, -0.202086055768267]), Atom('Cu', [7.083333333333333, 2.671601923551318, -2.146500000000000]), Atom('Cu', [8.421531840490820, 1.905881433340739, -0.202086055768265]), Atom('Cu', [9.783333333333335, 2.671601923551318, -2.146500000000000]), Atom('Cu', [1.671531840490742, 4.244150023558601, -0.202086055768165]), Atom('Cu', [3.033333333333334, 5.009870513769302, -2.146500000000000]), Atom('Cu', [4.371531840490840, 4.244150023558694, -0.202086055768265]), Atom('Cu', [5.733333333333333, 5.009870513769302, -2.146500000000000]), Atom('Cu', [7.071531840490880, 4.244150023558786, -0.202086055768352]), 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)) 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_atoms(): # 2x2-Al(001) surface with 3 layers and an # Au atom adsorbed in a hollow site: slab = fcc100('Al', size=(2, 2, 3)) add_adsorbate(slab, 'Au', 1.7, 'hollow') slab.center(axis=2, vacuum=4.0) # Fix second and third layers: mask = [atom.tag > 1 for atom in slab] slab.set_constraint(FixAtoms(mask=mask)) # Use EMT potential: slab.set_calculator(EMT()) # Initial state: qn = QuasiNewton(slab, logfile=None) qn.run(fmax=0.05) initial = slab.copy() # Final state: slab[-1].x += slab.get_cell()[0, 0] / 2 qn = QuasiNewton(slab, logfile=None) qn.run(fmax=0.05) final = slab.copy() # Setup a NEB calculation constraint = FixAtoms(mask=[atom.tag > 1 for atom in initial]) images = [initial] for i in range(3): image = initial.copy() image.set_constraint(constraint) images.append(image) images.append(final) neb = NEB(images, parallel=mpi.parallel) neb.interpolate() def set_calculator(calc): 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
import numpy as np from ase_ext import Atoms from ase_ext.calculators.emt import EMT from ase_ext.io import PickleTrajectory Cu = Atoms('Cu', pbc=(1, 0, 0), calculator=EMT()) traj = PickleTrajectory('Cu.traj', 'w') for a in np.linspace(2.0, 4.0, 20): Cu.set_cell([a, 1, 1], scale_atoms=True) traj.write(Cu)
from ase_ext import Atoms from ase_ext.calculators.emt import EMT from ase_ext.constraints import FixBondLength from ase_ext.io import PickleTrajectory from ase_ext.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 = PickleTrajectory('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
from ase_ext import Atoms from ase_ext.calculators.emt import EMT from ase_ext.optimize import QuasiNewton from ase_ext.vibrations import Vibrations from ase_ext.thermochemistry import IdealGasThermo n2 = Atoms('N2', positions=[(0, 0, 0), (0, 0, 1.1)], calculator=EMT()) QuasiNewton(n2).run(fmax=0.01) vib = Vibrations(n2) vib.run() print(vib.get_frequencies()) vib.summary() print(vib.get_mode(-1)) vib.write_mode(-1, nimages=20) vib_energies = vib.get_energies() thermo = IdealGasThermo(vib_energies=vib_energies, geometry='linear', atoms=n2, symmetrynumber=2, spin=0) thermo.get_free_energy(temperature=298.15, pressure=2 * 101325.)
from ase_ext import Atoms from ase_ext.calculators.emt import EMT from ase_ext.md import VelocityVerlet from ase_ext.io import PickleTrajectory a = 3.6 b = a / 2 fcc = Atoms('Cu', positions=[(0, 0, 0)], cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1) fcc *= (2, 1, 1) fcc.set_calculator(EMT()) fcc.set_momenta([(0.9, 0.0, 0.0), (-0.9, 0, 0)]) md = VelocityVerlet(fcc, dt=0.1) def f(): print(fcc.get_potential_energy(), fcc.get_total_energy()) md.attach(f) md.attach(PickleTrajectory('Cu2.traj', 'w', fcc).write, interval=3) md.run(steps=20) fcc2 = PickleTrajectory('Cu2.traj', 'r')[-1]
def get_calculator(): return EMT()
def get_calculator_emt(): return EMT()
def get_calculator(): calc = EMT() return calc
from ase_ext.optimize import QuasiNewton from ase_ext.io import PickleTrajectory from ase_ext.neb import NEB from ase_ext.calculators.emt import EMT # Distance between Cu atoms on a (111) surface: a = 3.6 d = a / sqrt(2) y = d * sqrt(3) / 2 fcc111 = Atoms('Cu', cell=[(d, 0, 0), (d / 2, y, 0), (d / 2, y / 3, -a / sqrt(3))], pbc=True) slab = fcc111 * (2, 2, 4) slab.set_cell([2 * d, 2 * y, 1]) slab.set_pbc((1, 1, 0)) slab.set_calculator(EMT()) Z = slab.get_positions()[:, 2] indices = [i for i, z in enumerate(Z) if z < Z.mean()] 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))
def setup_calculator(self, system, calculator): return EMT()
Optimizer=FIRE Optimizer=QuasiNewton # Distance between Cu atoms on a (111) surface: a = 3.6 d = a / sqrt(2) fcc111 = Atoms(symbols='Cu', cell=[(d, 0, 0), (d / 2, d * sqrt(3) / 2, 0), (d / 2, d * sqrt(3) / 6, -a / sqrt(3))], pbc=True) initial = fcc111 * (2, 2, 4) initial.set_cell([2 * d, d * sqrt(3), 1]) initial.set_pbc((1, 1, 0)) initial.set_calculator(EMT()) Z = initial.get_positions()[:, 2] indices = [i for i, z in enumerate(Z) if z < Z.mean()] constraint = FixAtoms(indices=indices) initial.set_constraint(constraint) dyn = Optimizer(initial) dyn.run(fmax=0.05) Z = initial.get_positions()[:, 2] print(Z[0] - Z[1]) print(Z[1] - Z[2]) print(Z[2] - Z[3]) b = 1.2 h = 1.5 initial += Atom('C', (d / 2, -b / 2, h)) initial += Atom('O', (d / 2, +b / 2, h))
import numpy as np from ase_ext.calculators.emt import EMT from ase_ext import Atoms a = 3.60 b = a / 2 cu = Atoms('Cu', positions=[(0, 0, 0)], cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1, calculator=EMT()) e0 = cu.get_potential_energy() print(e0) cu.set_cell(cu.get_cell() * 1.001, scale_atoms=True) e1 = cu.get_potential_energy() V = a**3 / 4 B = 2 * (e1 - e0) / 0.003**2 / V * 160.2 print(B) for i in range(4): x = 0.001 * i A = np.array([(x, b, b + x), (b, 0, b), (b, b, 0)]) cu.set_cell(A, scale_atoms=True) e = cu.get_potential_energy() - e0 if i == 0: print(i, e) else: print(i, e, e / x**2) A = np.array([(0, b, b), (b, 0, b), (6 * b, 6 * b, 0)])
from math import sqrt, pi from ase_ext import Atoms from ase_ext.calculators.emt import EMT from ase_ext.constraints import FixBondLengths from ase_ext.optimize import BFGS, QuasiNewton from ase_ext.neb import SingleCalculatorNEB from ase_ext.lattice.surface import fcc111, add_adsorbate from math import sqrt, cos, sin zpos = cos(134.3 / 2.0 * pi / 180.0) * 1.197 xpos = sin(134.3 / 2.0 * pi / 180.0) * 1.19 co2 = Atoms('COO', positions=[(-xpos + 1.2, 0, -zpos), (-xpos + 1.2, -1.1, -zpos), (-xpos + 1.2, 1.1, -zpos)]) slab = fcc111('Au', size=(2, 2, 4), vacuum=2 * 5, orthogonal=True) slab.center() add_adsorbate(slab, co2, 1.5, 'bridge') slab.set_pbc((True, True, False)) d0 = co2.get_distance(-3, -2) d1 = co2.get_distance(-3, -1) calc = EMT() slab.set_calculator(calc) constraint = FixBondLengths([[-3, -2], [-3, -1]]) slab.set_constraint(constraint) dyn = BFGS(slab, trajectory='relax.traj') dyn.run(fmax=0.05) assert abs(co2.get_distance(-3, -2) - d0) < 1e-14 assert abs(co2.get_distance(-3, -1) - d1) < 1e-14