a = 2.5 H = Atoms('H', cell=[a, a, a], pbc=True) energy_tolerance = 0.00006 niter_tolerance = 0 if world.size >= 3: calc = GPAW(kpts=[6, 6, 1], spinpol=True, parallel={'domain': world.size}, txt='H-a.txt') H.set_calculator(calc) e1 = H.get_potential_energy() niter1 = calc.get_number_of_iterations() assert H.get_calculator().wfs.kpt_comm.size == 1 equal(e1, -2.23708481, energy_tolerance) equal(niter1, 16, niter_tolerance) comm = world.new_communicator(np.array([0, 1, 2])) if world.rank < 3: H.set_calculator( GPAW(kpts=[6, 6, 1], spinpol=True, communicator=comm, txt='H-b.txt')) e2 = H.get_potential_energy() assert H.get_calculator().wfs.kpt_comm.size == 3 equal(e1, e2, 1e-11)
a = 2.5 H = Atoms('H', cell=[a, a, a], pbc=True) energy_tolerance = 0.00006 niter_tolerance = 0 if world.size >= 3: calc = GPAW(kpts=[6, 6, 1], spinpol=True, parallel={'domain': world.size}, txt='H-a.txt') H.set_calculator(calc) e1 = H.get_potential_energy() niter1 = calc.get_number_of_iterations() assert H.get_calculator().wfs.kpt_comm.size == 1 equal(e1, -2.23708481, energy_tolerance) if world.rank < 3: comm = world.new_communicator(np.array([0, 1, 2])) H.set_calculator(GPAW(kpts=[6, 6, 1], spinpol=True, communicator=comm, txt='H-b.txt')) e2 = H.get_potential_energy() assert H.get_calculator().wfs.kpt_comm.size == 3 equal(e1, e2, 5e-9) else: comm = world.new_communicator(np.array(range(3, world.size))) H.set_calculator(GPAW(kpts=[6, 6, 1],
from gpaw.test import equal a = 5.0 d = 1.0 x = d / 3**0.5 atoms = Atoms([ Atom('C', (0.0, 0.0, 0.0)), Atom('H', (x, x, x)), Atom('H', (-x, -x, x)), Atom('H', (x, -x, -x)), Atom('H', (-x, x, -x)) ], cell=(a, a, a), pbc=False) atoms.positions[:] += a / 2 calc = GPAW(h=0.25, nbands=4, convergence={'eigenstates': 1e-11}) atoms.set_calculator(calc) energy = atoms.get_potential_energy() niter = calc.get_number_of_iterations() # The three eigenvalues e[1], e[2], and e[3] must be degenerate: e = atoms.get_calculator().wfs.kpt_u[0].eps_n print e[1] - e[3] equal(e[1], e[3], 9.3e-8) energy_tolerance = 0.0003 niter_tolerance = 0 equal(energy, -23.6277, energy_tolerance) assert 33 <= niter <= 36, niter
from ase import Atom, Atoms from gpaw import GPAW from gpaw.test import equal a = 5.0 d = 1.0 x = d / 3**0.5 atoms = Atoms([Atom('C', (0.0, 0.0, 0.0)), Atom('H', (x, x, x)), Atom('H', (-x, -x, x)), Atom('H', (x, -x, -x)), Atom('H', (-x, x, -x))], cell=(a, a, a), pbc=False) atoms.positions[:] += a / 2 calc = GPAW(h=0.25, nbands=4, convergence={'eigenstates': 1e-11}) atoms.set_calculator(calc) energy = atoms.get_potential_energy() niter = calc.get_number_of_iterations() # The three eigenvalues e[1], e[2], and e[3] must be degenerate: e = atoms.get_calculator().wfs.kpt_u[0].eps_n print e[1] - e[3] equal(e[1], e[3], 9.3e-8) energy_tolerance = 0.0003 niter_tolerance = 0 equal(energy, -23.6277, energy_tolerance) assert 33 <= niter <= 36, niter
pos = [] syms = '' y = s.readline().split() while len(y) > 0: nf = len(y) pos.append([float(x) for x in y[nf - 4:nf - 1]]) syms += y[1].strip('0123456789') y = s.readline().split() pos = np.array(pos) * alat natoms = len(pos) # create atoms object with coordinates and unit cell # as specified in the initial ionic step in log atoms = Atoms(syms, pos, cell=cell * alat, pbc=(1, 1, 1)) atoms.get_calculator = calc.get_calculator atoms.get_potential_energy = calc.get_potential_energy atoms.get_forces = calc.notimpl atoms.get_stress = calc.notimpl atoms.get_charges = calc.notimpl # get total energy at first ionic step en = get_total_energy(s) if en is not None: calc.set_energy(en) else: print >>stderr, 'no total energy found' exit(3) print(atoms)