Skip to content
Snippets Groups Projects
Commit 3a0a6108 authored by Philipp Rüssmann's avatar Philipp Rüssmann
Browse files

Activate KKRnano tests

parent 083ad98a
No related branches found
No related tags found
No related merge requests found
......@@ -39,10 +39,13 @@ stages:
# to be implemented ...
# pkkprime stages
- build_pkkprime
# run and verift stages not defined yet
# run and verify stages not defined yet
# rhoq stages
- build_rhoq
# run and verift stages not defined yet
# run and verify stages not defined yet
# kkrnano stages
- build_kkrnano
- run_kkrnano
###############################################################################
......@@ -72,12 +75,14 @@ include:
- tests/gitlab-ci/build_pkkprime.yml
- tests/gitlab-ci/build_voronoi.yml
- tests/gitlab-ci/build_rhoq.yml
- tests/gitlab-ci/build_kkrnano.yml
### 2. run tests ###
- tests/gitlab-ci/run_kkrhost.yml
- tests/gitlab-ci/run_kkrimp.yml
#- tests/gitlab-ci/run_kkrsusc.yml
#- tests/gitlab-ci/run_pkkprime.yml
- tests/gitlab-ci/run_voronoi.yml
- tests/gitlab-ci/run_kkrnano.yml
### 3. verify results ###
- tests/gitlab-ci/verify_kkrhost.yml
- tests/gitlab-ci/verify_kkrimp.yml
......
......@@ -11,8 +11,8 @@ import time
TESTDIR = os.getcwd() ### perform the calculation in the current working directory
DECIMALS = 6 ### 8=all digits, 6 should be enough
DEFAULT_lmax = 3
DEFAULT_nranks = 1
DEFAULT_nthreads = 1
DEFAULT_nranks = 8
DEFAULT_nthreads = 4
direct = 4 ##
iterative = 3 ##
DEFAULT_solver = iterative
......@@ -21,6 +21,8 @@ ShowMD5 = True
AllMPIs = 1 # 1=Yes, 0=No
HighLmax = True
testNocoSOC = True
verbose = True
MPIEXEC = 'srun'
def run_it(cmd):
"""Run cmd, suppressing output. Returns output from stdout and exit code"""
......@@ -44,7 +46,8 @@ def get_energy(string):
def KKRnano(inputdir, nranks=DEFAULT_nranks, nthreads=DEFAULT_nthreads, solver=DEFAULT_solver, lmax=DEFAULT_lmax, Lly=DEFAULT_Lly):
"""Run KKR-calculation with input from 'inputdir' and returns the total energy"""
#print "start KKR for", inputdir, "with lmax=",lmax, ", solver=",solver, ", nthreads=",nthreads, "nranks=",nranks
if verbose:
print "start KKR for", inputdir, "with lmax=",lmax, ", solver=",solver, ", nthreads=",nthreads, "nranks=",nranks
out, err, tim = run_it("./clearfiles.sh")
global ShowMD5
......@@ -66,9 +69,18 @@ def KKRnano(inputdir, nranks=DEFAULT_nranks, nthreads=DEFAULT_nthreads, solver=D
with open("input.conf", "a") as myfile: ## append to file
myfile.write("LLY = {0}\n".format(int(Lly)))
out, err, tim = run_it("./kkr.exe --prepare") ### start from JM-formatted potential file
mpirun = ''
if MPIEXEC=='srun':
mpirun = 'srun -n 1 '
out, err, tim = run_it(mpirun + "./kkr.exe --prepare") ### start from JM-formatted potential file
## execute the code
out, err, tim = run_it("OMP_STACKSIZE=80M OMP_NUM_THREADS={0} mpiexec -np {1} kkr.exe".format(int(nthreads), int(nranks)))
mpirun = 'mpirun -np'
if MPIEXEC=='srun':
mpirun = 'srun -n'
out, err, tim = run_it("OMP_STACKSIZE=80M OMP_NUM_THREADS={0} ".format(int(nthreads)) + mpirun + " {0} kkr.exe".format(int(nranks)))
#print 'out', out
#print 'err', err
#print 'tim', tim
### grep the result
total_energy = get_energy(out)
print "KKR for",inputdir," with lmax=",lmax," gives",total_energy,"Ryd",
......@@ -87,62 +99,70 @@ def KKRnano(inputdir, nranks=DEFAULT_nranks, nthreads=DEFAULT_nthreads, solver=D
class Test_alloys(unittest.TestCase):
def test_Fe8Co8(self):
"""Test random alloy of 16 atoms"""
Etot = -42561.17620828
Etot = -42561.325157
for r in range(0, AllMPIs*4+1): # nranks=[1, 2, 4, 8, 16]
self.assertAlmostEqual(KKRnano("Fe8Co8", solver=direct, nranks=2**r), Etot, DECIMALS) # about 30 seconds for nranks=1
# total time ~2.2min
class Test_copper(unittest.TestCase):
def test_Cu4_lmax(self):
"""Test with high lmax. Works only with -heap-arrays on ifort, 4 Cu atoms in the cubic unit cell"""
Etot = -13219.36420827
Etot = -13219.3620641
for r in range(0, AllMPIs*2+1): # nranks=[1, 2, 4]
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, nranks=2**r), Etot, DECIMALS)
if HighLmax:
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=4), -13219.71809004, DECIMALS)
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=5), -13219.60358021, DECIMALS) # about 30 seconds
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=6), -13219.5622359, DECIMALS) # about 60 seconds
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=4), -13219.716163, DECIMALS)
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=5), -13219.6016203, DECIMALS) # about 30 seconds
self.assertAlmostEqual(KKRnano("Cu4", solver=direct, lmax=6), -13219.5603038, DECIMALS) # about 60 seconds
# total time ~1.6min
def test_Cu1_lmax(self):
"""Test with high lmax. Works only with -heap-arrays on ifort, 1 Cu atoms in the FCC unit cell"""
self.assertAlmostEqual(KKRnano("Cu1", solver=direct), -3308.16564382, DECIMALS) # about 2 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct), -3308.14107181, DECIMALS) # about 2 seconds
if HighLmax:
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=4), -3308.26672862, DECIMALS) # about 4 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=5), -3308.23074153, DECIMALS) # about 8 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=6), -3308.15897626, DECIMALS) # about 16 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=4), -3308.26072261, DECIMALS) # about 4 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=5), -3308.22046659, DECIMALS) # about 8 seconds
self.assertAlmostEqual(KKRnano("Cu1", solver=direct, lmax=6), -3308.15010032, DECIMALS) # about 16 seconds
# total time ~1min
class Test_semiconductors(unittest.TestCase):
def test_GaN(self):
"""Test semiconductor in zincblende structure with 2 vacancy cells"""
Etot = -3990.85752538
Etot = -3990.8515006
for r in range(0, AllMPIs*2+1): # nranks=[4, 2, 1]
self.assertAlmostEqual(KKRnano("GaN", solver=direct, nranks=2**(2-r)), Etot, DECIMALS) # about 80 seconds
# total time ~4.6min
def test_Si(self):
"""Test semiconductor in diamond structure with 2 vacancy cells"""
Etot = -1155.68470407
Etot = -1155.68952256
for r in range(0, AllMPIs*2+1): # nranks=[1, 2, 4]
self.assertAlmostEqual(KKRnano("Si", solver=direct, nranks=2**r), Etot, DECIMALS) # about a minute
# def test_ZnO(self):
# """Test semiconductor in wurzite structure with 4 vacancy cells and voro_weights"""
# Etot = -7405.77074357 ## test iterative solver (solver=3, default) without and with MPI
# for r in range(0, AllMPIs*3+1): # nranks=[1, 2, 4, 8]
# self.assertAlmostEqual(KKRnano("ZnO", nranks=2**r), Etot, DECIMALS)
#
# Etot = -7405.77074351
# for r in range(0, AllMPIs*3+1): # nranks=[1, 2, 4, 8]
# self.assertAlmostEqual(KKRnano("ZnO", solver=direct, nranks=2**r), Etot, DECIMALS)
# ### Lloyd formula
# self.assertAlmostEqual(KKRnano("ZnO", solver=direct, nranks=8, Lly=1), -7405.74826372, DECIMALS)
# self.assertAlmostEqual(KKRnano("ZnO", nranks=8, Lly=1), -7405.74826372, DECIMALS)
# total time ~1.5min
def test_ZnO(self):
"""Test semiconductor in wurzite structure with 4 vacancy cells and voro_weights"""
Etot = -7405.77043939 ## test iterative solver (solver=3, default) without and with MPI
for r in range(0, AllMPIs*3+1): # nranks=[1, 2, 4, 8]
self.assertAlmostEqual(KKRnano("ZnO", nranks=2**r), Etot, DECIMALS)
for r in range(0, AllMPIs*3+1): # nranks=[1, 2, 4, 8]
self.assertAlmostEqual(KKRnano("ZnO", solver=direct, nranks=2**r), Etot, DECIMALS)
### Lloyd formula
# broken because of error message "Lloyd's formula and num_local_atoms > 1 not supported."
# Etot = -7405.74826372
# self.assertAlmostEqual(KKRnano("ZnO", solver=direct, nranks=8, Lly=1), Etot, DECIMALS)
# self.assertAlmostEqual(KKRnano("ZnO", nranks=8, Lly=1), Etot, DECIMALS)
# total time ~1.5min
class Test_nocosocmaterials(unittest.TestCase):
def test_MnGeB20(self):
"""Test chiral magnet MnGe B20 structure (8 atoms in unit cell)"""
Etot = -26017.23757851
Etot = -26017.1505286
if testNocoSOC:
self.assertAlmostEqual(KKRnano("MnGeB20", solver=direct, nranks=8), Etot, DECIMALS) # takes longer than other tests
self.assertAlmostEqual(KKRnano("MnGeB20", solver=direct, nranks=8), Etot, DECIMALS) # takes longer than other tests, ~3 mins
self.assertAlmostEqual(KKRnano("MnGeB20", solver=iterative, nranks=4), Etot, DECIMALS) # takes longer than other tests
# total time ~6min
unittest.main()
build_kkrnano:intel:hybrid:
stage: build_kkrnano
tags:
- docker-executor
script:
# compile code
- cd source/KKRnano/source && mkdir -p build
- make -j4 PLATFORM=ifort SMP=openmp
- cp kkr.exe ../regtests/kkr.exe
artifacts:
paths:
- source/KKRnano/regtests/kkr.exe
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:Cu1:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_Cu1; cd test_Cu1; ln -s ../* .
- python2.7 ./tests.py Test_copper.test_Cu1_lmax
artifacts:
paths:
- source/KKRnano/regtests/test_Cu1
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:Cu4:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_Cu4; cd test_Cu4; ln -s ../* .
- python2.7 ./tests.py Test_copper.test_Cu4_lmax
artifacts:
paths:
- source/KKRnano/regtests/test_Cu4
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:GaN:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_GaN; cd test_GaN; ln -s ../* .
- python2.7 ./tests.py Test_semiconductors.test_GaN
artifacts:
paths:
- source/KKRnano/regtests/test_GaN
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:Si:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_Si; cd test_Si; ln -s ../* .
- python2.7 ./tests.py Test_semiconductors.test_Si
artifacts:
paths:
- source/KKRnano/regtests/test_Si
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:ZnO:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_ZnO; cd test_ZnO; ln -s ../* .
- python2.7 ./tests.py Test_semiconductors.test_ZnO
artifacts:
paths:
- source/KKRnano/regtests/test_ZnO
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
run_kkrnano:intel:MnGeB20:
stage: run_kkrnano
tags:
- docker-executor
script:
- cd source/KKRnano/regtests
- mkdir -p test_MnGeB20; cd test_MnGeB20; ln -s ../* .
- python2.7 ./tests.py Test_nocosocmaterials.test_MnGeB20
artifacts:
paths:
- source/KKRnano/regtests/test_MnGeB20
expire_in: 1 day
only:
- schedules
- triggers
- web
- master
- develop
- kkrnano-activate-tests
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment