def get_atoms(): 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
vscr = os.getenv('VASP_SCRIPT') if vcmd == None and vscr == None: raise NotAvailable('Neither VASP_COMMAND nor VASP_SCRIPT defined') from ase_ext import Atoms from ase_ext.calculators.vasp import Vasp import numpy as np def array_almost_equal(a1, a2, tol=np.finfo(type(1.0)).eps): """Replacement for old numpy.testing.utils.array_almost_equal.""" return (np.abs(a1 - a2) < tol).all() d = 1.14 co = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)], pbc=True) co.center(vacuum=5.) calc = Vasp( xc = 'PBE', prec = 'Low', algo = 'Fast', ismear= 0, sigma = 1., lwave = False, lcharg = False) co.set_calculator(calc) en = co.get_potential_energy() assert abs(en + 14.918933) < 1e-4 # Secondly, check that restart from the previously created VASP output works
from gpaw import GPAW logo = """\ H HH HHH H H H H HHH H HH H H H H H H HH HHH""" d = 0.8 atoms = Atoms() for y, line in enumerate(logo.split('\n')): for x, c in enumerate(line): if c == 'H': atoms.append(Atom('H', [d * x, -d * y, 0])) atoms.center(vacuum=2.0) view(atoms) if 0: calc = GPAW(nbands=30) atoms.set_calculator(calc) atoms.get_potential_energy() calc.write('ase-logo.gpw') else: calc = GPAW('ase-logo.gpw', txt=None) density = calc.get_pseudo_density() image = density[..., density.shape[2] // 2] if 1: # scale colors to wiki background / foreground import numpy as np
def get_atoms(): cell = (5, 5, 5) atoms = Atoms('H2', [(0, 0, 0), (0, 0, 1.4)], cell=cell) atoms.center() return atoms