# IT4Innovations 2023
# JK

name = 'WIEN2k'
version = '23.2'

homepage = 'http://www.wien2k.at/'
description = """The program package WIEN2k allows to perform electronic structure calculations of solids
using density functional theory (DFT). It is based on the full-potential (linearized) augmented plane-wave
((L)APW) + local orbitals (lo) method, one among the most accurate schemes for band structure calculations.
WIEN2k is an all-electron scheme including relativistic effects and has many features."""

toolchain = {'name': 'intel', 'version': '2021a'}

sources = ['%(name)s_%(version)s.tar']
patches = [
    'WIEN2k-21.1_fix_libxc_for_lapw0_mpi.patch',
#    'WIEN2k-21.1_fix_system_stderr_redirection.patch',
]
checksums = [
    {'WIEN2k_23.2.tar': '8ae0dda4b6d960c37f359b3d4198dd3953058efe2eae94083e91ddd619392cce'},
    {'WIEN2k-21.1_fix_libxc_for_lapw0_mpi.patch': '1cc480a4824d9185ad5918dfc68c47bcb7826114626c8133d573be901bbdca84'},
#    {'WIEN2k-21.1_fix_system_stderr_redirection.patch':
#     'cdba467b0b6f2b310c2e1e2a3e6cabe75f8fd15ee0f7c14f8ef80c7e48073bdd'},
]

dependencies = [
    ('Python', '3.9.5'),
    ('Perl', '5.32.1'),
    ('DFT-D3', '3.2.0'),
    ('ELPA', '2021.05.001'),
    ('FFTW', '3.3.9'),
    ('libxc', '5.1.5'),
]

osdependencies = [('glibc-devel', 'libc6-dev')]  # required for libpthread.a

# remote = 'pbsssh'
# If using a Slurm batch system it is highly recommended to use
# 'srun -n_NP_ _EXEC_' for wien_mpirun
wien_mpirun = 'mpirun  -np _NP_ _EXEC_'
use_remote = False
mpi_remote = False
wien_granularity = True
taskset = 'no'

# Change as needed, these are the defaults
# nmatmax = 19000
# nume = 6000

fix_perl_shebang_for = [
    'iniel_pressure_in2reader.pl_lapw',
    'iniel_pressure_reader.pl_lapw',
    'setrmt_lapw',
    'elast_setup_input.pl_lapw',
    'bashtime2csh.pl_lapw',
]

tests = [
    # test case 1: NaCl
    ('NaCl', '-b', '-i 3', [r'^:DIS.*0.1', r'^:ENE.*-1248.14']),
    # test case 2: TiO2
    ('TiO2',
     '-b -numk 1000 -rkmax 7.5',
     '-in1ef -cc 0.00001 -fc 0.5 -i 100',
     [
         r'^:ENE.*-4018.07',
         r'^:FGL001.*\s+[0.]+\s+[0.]+\s+[0.]+\s+total forces',
         r'^:FGL002.*15.*total forces',
     ]),
]

moduleclass = 'chem'
