Beispiel #1
0
def calculate(parallel, comm=world, Eref=None, Fref=None):
    calc = GPAW(
        mode=LCAO(atomic_correction='scipy'),
        basis=dict(O='dzp', Au='sz(dzp)'),
        occupations=FermiDirac(0.1),
        kpts=(4, 1, 1),
        #txt=None,
        communicator=comm,
        poissonsolver=PoissonSolver(eps=1e-8),
        nbands=16,
        parallel=parallel,
        h=0.35)
    system.set_calculator(calc)
    E = system.get_potential_energy()
    F = system.get_forces()

    if world.rank == 0:
        print('Results')
        print('-----------')
        print(E)
        print(F)
        print('-----------')

    if Eref is not None:
        Eerr = abs(E - Eref)
        assert Eerr < 1e-8, 'Bad E: err=%f; parallel=%s' % (Eerr, parallel)
    if Fref is not None:
        Ferr = np.abs(F - Fref).max()
        assert Ferr < 1e-6, 'Bad F: err=%f; parallel=%s' % (Ferr, parallel)
    return E, F
Beispiel #2
0
from ase import Atoms
from gpaw import GPAW, LCAO
from gpaw.lcaotddft import LCAOTDDFT
from gpaw.mpi import world

xc = 'oldLDA'
c = +1
h = 0.4
b = 'dzp'
sy = 'Na2'
positions = [[0.0, 0.0, 0.0], [0.0, 0.0, 2.0]]
atoms = Atoms(symbols=sy, positions=positions)
atoms.center(vacuum=3)

# LCAO-RT-TDDFT
calc = GPAW(mode=LCAO(force_complex_dtype=True),
            nbands=1,
            xc=xc,
            h=h,
            basis=b,
            charge=c,
            width=0,
            convergence={'density': 1e-8},
            setups={'Na': '1'})
atoms.set_calculator(calc)
atoms.get_potential_energy()
calc.write('Na2.gpw', 'all')
del calc

calc = LCAOTDDFT('Na2.gpw')
dmfile = sy + '_lcao_restart_' + b + '_rt_z.dm' + str(world.size)
Beispiel #3
0
from ase.build import molecule
from ase.utils import devnull

from gpaw import GPAW, LCAO, FermiDirac, KohnShamConvergenceError
from gpaw.utilities import compiled_with_sl
from gpaw.forces import calculate_forces
from gpaw.mpi import world

# Calculates energy and forces for various parallelizations

tolerance = 4e-5

parallel = dict()

basekwargs = dict(mode=LCAO(atomic_correction='dense'),
                  maxiter=3,
                  nbands=6,
                  kpts=(4, 4, 4),  # 8 kpts in the IBZ
                  parallel=parallel)

Eref = None
Fref_av = None


def run(formula='H2O', vacuum=1.5, cell=None, pbc=1, **morekwargs):
    print(formula, parallel)
    system = molecule(formula)
    kwargs = dict(basekwargs)
    kwargs.update(morekwargs)
    calc = GPAW(**kwargs)
Beispiel #4
0
system.pbc = (0, 0, 1)
system = system.repeat((1, 1, 2))
# Break symmetries so we don't get funny degeneracy effects.
system.rattle(stdev=0.05)

corrections = [DenseAtomicCorrection(), ScipyAtomicCorrection(tolerance=0.0)]


energies = []
for correction in corrections:
    parallel = {}
    if world.size >= 4:
        parallel['band'] = 2
    if correction.name != 'dense':
        parallel['sl_auto'] = True
    calc = GPAW(mode=LCAO(atomic_correction=correction),
                basis='sz(dzp)',
                #kpts=(1, 1, 4),
                #spinpol=True,
                poissonsolver=PoissonSolver('fd', relax='J', eps=1e100, nn=1),
                parallel=parallel,
                h=0.35)

    def stopcalc():
        calc.scf.converged = True

    calc.attach(stopcalc, 2)
    system.set_calculator(calc)
    energy = system.get_potential_energy()
    energies.append(energy)
Beispiel #5
0
from ase.build import bulk
from gpaw import GPAW, LCAO

# This test calculates a GLLB quasiparticle gap with LCAO and verifies
# that it does not change from a reference value.  Note that the
# calculation, physically speaking, is garbage.

si = bulk('Si', 'diamond', a=5.421)
calc = GPAW(mode=LCAO(interpolation=2),
            h=0.3,
            basis='sz(dzp)',
            xc='GLLBSC',
            kpts={
                'size': (2, 2, 2),
                'gamma': True
            },
            txt='si.txt')


def stopcalc():
    calc.scf.converged = True


calc.attach(stopcalc, 1)

si.set_calculator(calc)
si.get_potential_energy()

response = calc.hamiltonian.xc.xcs['RESPONSE']
response.calculate_delta_xc()
EKs, Dxc = response.calculate_delta_xc_perturbation()
Beispiel #6
0
from ase import Atoms
from gpaw import GPAW, LCAO
from gpaw.test import equal

a = 6.0
b = a / 2
mol = Atoms('OHH', [(b, b, 0.1219 + b), (b, 0.7633 + b, -0.4876 + b),
                    (b, -0.7633 + b, -0.4876 + b)],
            pbc=False,
            cell=[a, a, a])
calc = GPAW(gpts=(32, 32, 32), nbands=4, mode='lcao')
mol.set_calculator(calc)
e = mol.get_potential_energy()
niter = calc.get_number_of_iterations()

equal(e, -10.266984, 1e-4)
equal(niter, 8, 1)

# Check that complex wave functions are allowed with gamma point calculations
calc = GPAW(gpts=(32, 32, 32), nbands=4, mode=LCAO(force_complex_dtype=True))
mol.set_calculator(calc)
ec = mol.get_potential_energy()
equal(e, ec, 1e-5)
Beispiel #7
0
from ase import Atoms
from gpaw import GPAW, LCAO
from gpaw.test import equal
from gpaw.poisson import FDPoissonSolver

a = 6.0
b = a / 2
mol = Atoms('OHH', [(b, b, 0.1219 + b), (b, 0.7633 + b, -0.4876 + b),
                    (b, -0.7633 + b, -0.4876 + b)],
            pbc=False,
            cell=[a, a, a])
calc = GPAW(gpts=(32, 32, 32),
            nbands=4,
            mode='lcao',
            poissonsolver=FDPoissonSolver())
mol.set_calculator(calc)
e = mol.get_potential_energy()
niter = calc.get_number_of_iterations()

equal(e, -10.266984, 1e-4)
equal(niter, 8, 1)

# Check that complex wave functions are allowed with gamma point calculations
calc = GPAW(gpts=(32, 32, 32),
            nbands=4,
            mode=LCAO(force_complex_dtype=True),
            poissonsolver=FDPoissonSolver())
mol.set_calculator(calc)
ec = mol.get_potential_energy()
equal(e, ec, 1e-5)
try:
    import scipy
except ImportError:
    pass
else:
    corrections.append(ScipyAtomicCorrection(tolerance=0.0))

energies = []
for correction in corrections:
    parallel = {}
    if world.size >= 4:
        parallel['band'] = 2
    if correction.name != 'dense':
        parallel['sl_auto'] = True
    calc = GPAW(
        mode=LCAO(atomic_correction=correction),
        basis='sz(dzp)',
        #kpts=(1, 1, 4),
        #spinpol=True,
        poissonsolver=PoissonSolver(relax='J', eps=1e100, nn=1),
        parallel=parallel,
        h=0.35)

    def stopcalc():
        calc.scf.converged = True

    calc.attach(stopcalc, 2)
    system.set_calculator(calc)
    energy = system.get_potential_energy()
    energies.append(energy)