Skip to content

Commit

Permalink
Merge pull request #13 from jimustafa/test-w90-v3
Browse files Browse the repository at this point in the history
add checks for `wannier90-v3.x` support
  • Loading branch information
jimustafa authored Apr 12, 2020
2 parents 0899b73 + f1f4d3f commit c22ae92
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/w90utils/io/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def read_projections(fname):

projections = []
for line in match.group('projections').rstrip('\n').split('\n'):
projections.extend(read_proj_line(line, dlv, basis, spinors))
if line:
projections.extend(read_proj_line(line, dlv, basis, spinors))

return projections

Expand Down
2 changes: 1 addition & 1 deletion tests/_data/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include site.mk


WANNIER90_VERSIONS := 2.0.1 2.1.0
WANNIER90_VERSIONS := 2.0.1 2.1 3.0.0 3.1.0


default: clean $(WANNIER90_VERSIONS)
Expand Down
35 changes: 18 additions & 17 deletions tests/_data/particular.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ EXAMPLES_1=$(foreach idx,01 02 03 04,example$(idx))
EXAMPLES_2=$(foreach idx,05 06 07 09 10 11 13 17 18 19 20,example$(idx))
EXAMPLES=$(EXAMPLES_1) $(EXAMPLES_2)


define write_hr
$(if $(filter $(shell echo $(subst .,,$(WANNIER90_VERSION))\>=210 | bc), 1), echo "write_hr=true" >> wannier.win, echo "hr_plot=true" >> wannier.win)
endef
ifeq ($(WANNIER90_VERSION), 2.0.1)
WRITE_HR="hr_plot=true"
else
WRITE_HR="write_hr=true"
endif

define modify_win
$(call write_hr)
echo $(WRITE_HR) >> wannier.win
echo "write_xyz=true" >> wannier.win
echo "bands_plot=true" >> wannier.win
echo "kpath=true" >> wannier.win
Expand All @@ -31,43 +32,43 @@ $(EXAMPLES):

$(foreach example,$(EXAMPLES_2),run-$(example)):
$(foreach fname, $(wildcard $(basename $(wildcard *.win))*), mv $(fname) $(addsuffix $(suffix $(fname)), wannier);)
$(W90) -pp
$(W90) -pp wannier

run-example01:
$(foreach fname, $(wildcard gaas.*), mv $(fname) $(addsuffix $(suffix $(fname)), wannier);)
$(W90) -pp
$(W90) -pp wannier
echo "write_xyz=true" >> wannier.win
$(W90)
$(W90) wannier

run-example02:
$(foreach fname, $(wildcard lead.*), mv $(fname) $(addsuffix $(suffix $(fname)), wannier);)
$(W90) -pp
$(call write_hr)
$(W90) -pp wannier
echo $(WRITE_HR) >> wannier.win
echo "write_xyz=true" >> wannier.win
$(W90)
$(W90) wannier

run-example03:
$(foreach fname, $(wildcard silicon.*), mv $(fname) $(addsuffix $(suffix $(fname)), wannier);)
$(W90) -pp
$(W90) -pp wannier
$(call modify_win)
$(W90)
$(W90) wannier
echo "" >> wannier_geninterp.kpt
echo "crystal" >> wannier_geninterp.kpt
head -n 1 wannier_band.kpt >> wannier_geninterp.kpt
awk 'FNR > 1 {OFS=" "; print NR-1,$$1,$$2,$$3}' wannier_band.kpt >> wannier_geninterp.kpt
$(POSTW90)
$(POSTW90) wannier

run-example04:
$(foreach fname, $(wildcard copper.*), mv $(fname) $(addsuffix $(suffix $(fname)), wannier);)
$(W90) -pp
$(W90) -pp wannier
$(call modify_win)
echo "geninterp_alsofirstder=true" >> wannier.win
$(W90)
$(W90) wannier
echo "" >> wannier_geninterp.kpt
echo "crystal" >> wannier_geninterp.kpt
head -n 1 wannier_band.kpt >> wannier_geninterp.kpt
awk 'FNR > 1 {OFS=" "; print NR-1,$$1,$$2,$$3}' wannier_band.kpt >> wannier_geninterp.kpt
$(POSTW90)
$(POSTW90) wannier

clean:
rm -rf example*
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/site.mk.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WANNIER90_ROOT=$(HOME)
WANNIER90_ROOT=$(HOME)/wannier90/
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

example_ids = {
'wannier90-2.0.1': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 17, 18, 19, 20],
'wannier90-2.1.0': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 17, 18, 19, 20],
'wannier90-2.1': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 17, 18, 19, 20],
'wannier90-3.0.0': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 17, 18, 19, 20],
'wannier90-3.1.0': [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 17, 18, 19, 20],
}


@pytest.fixture(scope='session', params=['wannier90-2.0.1', 'wannier90-2.1.0'])
@pytest.fixture(scope='session', params=example_ids.keys())
def data_dir(request, tmpdir_factory):
data_dir = os.path.join(os.path.dirname(__file__), './_data')
for example_dir in [('%s/example%02d' % (request.param, i)) for i in example_ids[request.param]]:
Expand Down
35 changes: 30 additions & 5 deletions tests/setup-travis.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
#!/bin/bash
set -ex

cd "$HOME"
for version in 2.0.1 2.1.0; do
curl http://wannier.org/code/wannier90-${version}.tar.gz | tar xz
WANNIER90_VERSIONS="2.0.1 2.1 3.0.0 3.1.0"

if [ -z "$WANNIER90_ROOT" ]; then
WANNIER90_ROOT=$HOME/wannier90/
fi

mkdir -p $WANNIER90_ROOT/src/

pushd $WANNIER90_ROOT
for version in $WANNIER90_VERSIONS; do
pushd $WANNIER90_ROOT/src/
if [ ! -f "v${version}.tar.gz" ]; then
wget https://github.com/wannier-developers/wannier90/archive/v${version}.tar.gz
fi
popd

tar zxf ./src/v${version}.tar.gz

pushd wannier90-${version}
touch make.sys make.inc
F90=gfortran LIBS="-llapack -lblas" make
if [ "$version" == "2.0.1" ]; then
# cp config/make.sys.gfort make.sys
touch make.sys
echo "F90=gfortran" >> make.sys
echo "LIBS=-lblas -llapack" >> make.sys
else
# cp config/make.inc.gfort make.inc
touch make.inc
echo "F90=gfortran" >> make.inc
echo "LIBS=-lblas -llapack" >> make.inc
fi
make
popd
done
3 changes: 3 additions & 0 deletions tests/test_w90io.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def test_read_chkpt_mats(data_dir, example):

@pytest.mark.parametrize('example', ['example03', 'example04'])
def test_read_bands(data_dir, example):
if 'wannier90-3.0.0' in data_dir:
pytest.xfail('known bug in wannier90-v3.0.0')

os.chdir(os.path.join(data_dir, example))

bands_ref = w90io.postw90.read_bands('wannier_geninterp.dat')
Expand Down

0 comments on commit c22ae92

Please sign in to comment.