Commit 9defde48 authored by Jens Jørgen Mortensen's avatar Jens Jørgen Mortensen

Merge branch 'master' into agts7

parents af0ea42a 871c8d27
Pipeline #21376097 passed with stage
in 3 minutes and 42 seconds
......@@ -11,34 +11,49 @@ small and quick tests and by a weekly set of larger test.
Quick test suite
================
Use the :program:`gpaw-test` command to run the tests::
Use the :program:`gpaw` command to run the tests::
$ gpaw-test --help
Usage: gpaw-test [options] [tests]
Options:
--version show program's version number and exit
$ gpaw test --help
usage: gpaw test [-h] [-x test1.py,test2.py,...] [-f] [--from TESTFILE]
[--after TESTFILE] [--range test_i.py,test_j.py] [-j JOBS]
[--reverse] [-k] [-d DIRECTORY] [-s] [--list]
[tests [tests ...]]
Run the GPAW test suite. The test suite can be run in parallel with MPI
through gpaw-python. The test suite supports 1, 2, 4 or 8 CPUs although some
tests are skipped for some parallelizations. If no TESTs are given, run all
tests supporting the parallelization.
positional arguments:
tests
optional arguments:
-h, --help show this help message and exit
-x test1.py,test2.py,..., --exclude=test1.py,test2.py,...
-x test1.py,test2.py,..., --exclude test1.py,test2.py,...
Exclude tests (comma separated list of tests).
-f, --run-failed-tests-only
Run failed tests only.
--from=TESTFILE Run remaining tests, starting from TESTFILE
--after=TESTFILE Run remaining tests, starting after TESTFILE
--range=test_i.py,test_j.py
--from TESTFILE Run remaining tests, starting from TESTFILE
--after TESTFILE Run remaining tests, starting after TESTFILE
--range test_i.py,test_j.py
Run tests in range test_i.py to test_j.py (inclusive)
-j JOBS, --jobs=JOBS Run JOBS threads.
-j JOBS, --jobs JOBS Run JOBS threads. Each test will be executed in serial
by one thread. This option cannot be used for
parallelization together with MPI.
--reverse Run tests in reverse order (less overhead with
multiple jobs)
-k, --keep-temp-dir Do not delete temporary files.
-d DIRECTORY, --directory DIRECTORY
Run test in this directory
-s, --show-output Show standard output from tests.
--list list the full list of tests, then exit
A temporary directory will be made and the tests will run in that
directory. If all tests pass, the directory is removed.
The test suite consists of a large number of small and quick tests
found in the :git:`gpaw/test/` directory. The tests run nightly in serial
and in parallel. Here are the results from `BuildBot
<https://gpaw-buildbot.fysik.dtu.dk/waterfall>`_.
and in parallel.
......@@ -66,7 +81,7 @@ Use this function to check results:
.. _big-test:
.. _agts:
Big tests
=========
......
......@@ -12,7 +12,7 @@ with broadcast_imports:
import os
import runpy
import warnings
from distutils.util import get_platform
from sysconfig import get_platform
from os.path import join, isfile
from argparse import ArgumentParser, REMAINDER, RawDescriptionHelpFormatter
......
......@@ -19,6 +19,7 @@ def create_external_potential(name, **kwargs):
class ExternalPotential:
vext_g = None
vext_q = None
def get_potential(self, gd):
"""Get the potential on a regular 3-d grid.
......@@ -29,6 +30,17 @@ class ExternalPotential:
self.calculate_potential(gd)
return self.vext_g
def get_potentialq(self, gd, pd3):
"""Get the potential on a regular 3-d grid in real space.
Will only call calculate_potential() the first time."""
if self.vext_q is None:
vext_g = self.get_potential(gd)
self.vext_q = pd3.fft(vext_g)
return self.vext_q
def calculate_potential(self, gd):
raise NotImplementedError
......@@ -69,11 +81,12 @@ class ConstantElectricField(ExternalPotential):
def calculate_potential(self, gd):
d_v = self.field_v / (self.field_v**2).sum()**0.5
for axis_v in gd.cell_cv[gd.pbc_c]:
if abs(np.dot(d_v, axis_v)) > self.tolerance:
raise ValueError(
'Field not perpendicular to periodic axis: {}'
.format(axis_v))
# Currently skipped, PW mode is periodic in all directions
#for axis_v in gd.cell_cv[gd.pbc_c]:
# if abs(np.dot(d_v, axis_v)) > self.tolerance:
# raise ValueError(
# 'Field not perpendicular to periodic axis: {}'
# .format(axis_v))
center_v = 0.5 * gd.cell_cv.sum(0)
r_gv = gd.get_grid_point_coordinates().transpose((1, 2, 3, 0))
......
......@@ -194,6 +194,7 @@ tests = [
'broydenmixer.py', # ~3s
'pw/fulldiagk.py', # ~3s
'ext_potential/external.py', # ~3s
'ext_potential/external_pw.py', # ~3s
'lcao/atomic_corrections.py', # ~3s
'vdw/libvdwxc_h2.py', # ~3s
'generic/mixer.py', # ~3s
......
from __future__ import print_function
from ase import Atoms
from gpaw import GPAW
from gpaw.test import equal
from gpaw.wavefunctions.pw import PW
from gpaw.external import ConstantPotential
cp = ConstantPotential()
sc = 2.9
R = 0.7 # approx. experimental bond length
R = 1.0
a = 2 * sc
c = 3 * sc
at = 'H'
H2 = Atoms('HH', [(a / 2, a / 2, (c - R) / 2),
(a / 2, a / 2, (c + R) / 2)],
cell=(a, a, c),
pbc=False)
txt = None
convergence = {'eigenstates': 1.e-6 * 40 * 1.5**3,
'density': 1.e-2,
'energy': 0.1}
# without potential
if True:
if txt:
print('\n################## no potential')
c00 = GPAW(mode=PW(200), nbands=-1,
convergence=convergence,
txt=txt)
c00.calculate(H2)
eps00_n = c00.get_eigenvalues()
# 0 potential
if True:
if txt:
print('\n################## 0 potential')
cp0 = ConstantPotential(0.0)
c01 = GPAW(mode=PW(200), nbands=-2, external=cp0,
convergence=convergence,
txt=txt)
c01.calculate(H2)
# 1 potential
if True:
if txt:
print('################## 1 potential')
cp1 = ConstantPotential(-1.0)
c1 = GPAW(mode=PW(200), nbands=-2, external=cp1,
convergence=convergence,
txt=txt)
c1.calculate(H2)
for i in range(c00.get_number_of_bands()):
f00 = c00.get_occupation_numbers()[i]
if f00 > 0.01:
e00 = c00.get_eigenvalues()[i]
e1 = c1.get_eigenvalues()[i]
print('Eigenvalues no pot, expected, error=',
e00, e1 + 1, e00 - e1 - 1)
equal(e00, e1 + 1., 0.007)
E_c00 = c00.get_potential_energy()
E_c1 = c1.get_potential_energy()
DeltaE = E_c00 - E_c1
equal(DeltaE, 0, 0.002)
......@@ -22,20 +22,20 @@ def calculate(**kwargs1):
system.get_potential_energy()
return calc
fdbandpar = world.size // 2
fddomainpar = min(2, world.size)
for mode in ['fd', 'pw', 'lcao']:
kwargs = {}
if mode == 'pw':
kwargs['mode'] = PW(150)
else:
kwargs['parallel'] = {'band': fdbandpar}
kwargs['parallel'] = {'domain': fddomainpar}
calc = calculate(**kwargs)
E1 = calc.get_potential_energy()
calc.write('dump.libvdwxc.gpw')
calc2 = GPAW('dump.libvdwxc.gpw', txt='restart.txt',
parallel={'band': fdbandpar})
parallel={'domain': fddomainpar})
system2 = calc.get_atoms()
# Verify same energy after restart
......
......@@ -1581,6 +1581,14 @@ class ReciprocalSpaceHamiltonian(Hamiltonian):
self.epot = 0.5 * self.pd3.integrate(self.vHt_q, dens.rhot_q)
self.vt_Q = self.vbar_Q + self.vHt_q[dens.G3_G] / 8
self.e_external = 0.0
if self.vext is not None:
gd = self.finegd
vext_q = self.vext.get_potentialq(gd, self.pd3)
self.vt_Q += vext_q[dens.G3_G] / 8
self.e_external = self.pd3.integrate(vext_q, dens.rhot_q)
self.vt_sG[:] = self.pd2.ifft(self.vt_Q)
self.timer.start('XC 3D grid')
......@@ -1602,15 +1610,17 @@ class ReciprocalSpaceHamiltonian(Hamiltonian):
self.timer.stop('XC 3D grid')
eext = 0.0
return np.array([self.epot, self.ebar, eext, self.exc])
return np.array([self.epot, self.ebar, self.e_external, self.exc])
def calculate_atomic_hamiltonians(self, density):
W_aL = {}
for a in density.D_asp:
W_aL[a] = np.empty((self.setups[a].lmax + 1)**2)
density.ghat.integrate(self.vHt_q, W_aL)
if self.vext:
vext_q = self.vext.get_potentialq(self.finegd, self.pd3)
density.ghat.integrate(self.vHt_q+vext_q, W_aL)
else:
density.ghat.integrate(self.vHt_q, W_aL)
return W_aL
def calculate_kinetic_energy(self, density):
......@@ -1636,7 +1646,11 @@ class ReciprocalSpaceHamiltonian(Hamiltonian):
restrict_and_collect = restrict
def calculate_forces2(self, dens, ghat_aLv, nct_av, vbar_av):
dens.ghat.derivative(self.vHt_q, ghat_aLv)
if self.vext:
vext_q = self.vext.get_potentialq(self.finegd, self.pd3)
dens.ghat.derivative(self.vHt_q+vext_q, ghat_aLv)
else:
dens.ghat.derivative(self.vHt_q, ghat_aLv)
dens.nct.derivative(self.vt_Q, nct_av)
self.vbar.derivative(dens.nt_Q, vbar_av)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment