QuantumEspressoXC.py 35.3 KB
Newer Older
Henning Glawe's avatar
Henning Glawe committed
1
2
import logging
import re
3
import copy
Henning Glawe's avatar
Henning Glawe committed
4
5
6
7
8


LOGGER = logging.getLogger(__name__)


9
10
11
12
13
14
15
16
17
18
def parse_qe_xc_num(xc_functional_num):
    """parse Quantum Espresso XC number/index notation
    :returns: list with 6 integer elements (components of QE XC functionals)
              [iexch, icorr, igcx, igcc, imeta, inlc]
                iexch, icorr - density exchange/correlation
                igcx, igcc   - gradient correction exchange/correlation
                imeta        - meta-GGA
                inlc         - non-local term of Van der Waals functionals
    """
    xf_num_split_i = []
19
    xf_num_split = re.split(r'\s+', xc_functional_num.strip())
20
21
    if len(xf_num_split) > 6:
        # tested versions of espresso <=5.4.0 have 6 elements
22
23
        raise RuntimeError("unsupported number of XC components: %d" % (
            len(xf_num_split)))
24
25
    elif len(xf_num_split) == 6:
        # trivial case: we got 6 components from simply splitting
26
27
        xf_num_split_i = [int(x) for x in xf_num_split]
    elif len(xf_num_split) == 1 and len(xc_functional_num) == 4:
28
        # old 4-component form without space separator
29
30
31
32
33
        xf_num_split_i = [int(x) for x in re.findall(
            '(\d)', xc_functional_num)]
    elif len(xc_functional_num) == 10:
        # intermediate versions used 2-digit, 5 component form,
        # occasionally missing spaces
34
35
36
        # examples:
        # ( 1 4 4 0 1)
        # ( 0 413 0 2)  <- missing space
37
38
        xf_num_split_i = [int(x) for x in re.findall(
            '([ \d]\d)', xc_functional_num)]
39
40
    else:
        raise RuntimeError("unparsable input: '%s'", xc_functional_num)
41
    if len(xf_num_split_i) < 1:
42
43
        raise RuntimeError("this should not happen")
    # zero-pad up to 6 elements
44
    xf_num_split_i += [0] * (6 - len(xf_num_split_i))
45
46
47
    return xf_num_split_i


48
def translate_qe_xc_num(xc_functional_num, exact_exchange_fraction=None):
49
50
    # all remainders of excact_exchange_fraction must be ordinary DFT
    if exact_exchange_fraction is None:
51
        exact_exchange_fraction = 0.0
52
    xf_num = parse_qe_xc_num(xc_functional_num)
53
54
    LOGGER.debug('num <- input: %s <- %s, exx_fraction: %s',  str(xf_num),
                 xc_functional_num, str(exact_exchange_fraction))
55
    # use dictionaries to ensure uniqueness:
56
57
58
    #   exchange/correlation functionals may be combined into _XC_, and we
    #   only want to emit such combinations once
    xc_data = {}
59
60
61
62
    #   libXC definitions of GGAs/Hybrids include the density contribution
    #   while QE allows to freely combine density, gradient etc. dependency
    #   so we need to remove at least the default settings to be compliant
    #   with libXC and NOMAD metaInfo
63
    xc_data_remove = {}
64
    # collect everything that will go to section_method
65
    xc_section_method = {}
66
    for component_i in range(6):
67
68
69
70
        this_xf_num = xf_num[component_i]
        if this_xf_num == 0:
            # 0 means unset component
            continue
71
        component_max = len(XC_COMPONENT[component_i])-1
72
73
        this_component = None
        if this_xf_num > component_max:
74
75
            LOGGER.error(
                "%s[%d] beyond limit of %d",
76
77
                XC_COMPONENT_NAME[component_i], this_xf_num, component_max)
        else:
78
            this_component = XC_COMPONENT[component_i][this_xf_num]
79
80
81
        if this_component is None:
            raise RuntimeError("Undefined XC component %s[%d]" % (
                XC_COMPONENT_NAME[component_i], this_xf_num))
82
        xc_section_method.update(this_component['xc_section_method'])
83
        for this_term in this_component['xc_terms']:
84
            apply_term_add(
85
                xc_data, this_term, exact_exchange_fraction)
86
87
88
89
90
        # collect all to-be-removed terms
        for this_term in this_component.get('xc_terms_remove', []):
            apply_term_add(
                xc_data_remove, this_term, exact_exchange_fraction)
    # remove all collected terms from xc_terms_remove from xc_data
91
    apply_terms_remove(xc_data, xc_data_remove)
92
    # filter terms in xc_data:
93
    apply_terms_filter(xc_data)
94
    xc_functional = xc_functional_str(xc_data)
95
96
97
98
99
100
101
102
    # apply shortcuts/overrides for libXC compliance
    if xc_functional in LIBXC_SHORTCUT:
        xc_data = {}
        for this_term in LIBXC_SHORTCUT[xc_functional]['xc_terms']:
            apply_term_add(
                xc_data, this_term, exact_exchange_fraction)
        apply_terms_filter(xc_data)
        xc_functional = xc_functional_str(xc_data)
103
    xc_section_method['XC_functional'] = xc_functional
Henning Glawe's avatar
Henning Glawe committed
104
    result = []
Henning Glawe's avatar
Henning Glawe committed
105
106
    for k in sorted(xc_data.keys()):
        v = xc_data[k]
Henning Glawe's avatar
Henning Glawe committed
107
        result.append(v)
108
    return (xc_section_method, result)
109
110


111
def apply_term_add(xc_data, this_term, exact_exchange_fraction):
112
    term = copy.deepcopy(this_term)
Henning Glawe's avatar
Henning Glawe committed
113
114
115
    if 'exx_compute_weight' in term:
        term['XC_functional_weight'] = term['exx_compute_weight'](
            exact_exchange_fraction)
116
117
    if 'XC_functional_weight' not in term:
        term['XC_functional_weight'] = 1.0
Henning Glawe's avatar
Henning Glawe committed
118
119
120
121
122
123
124
125
    if term['XC_functional_name'] not in xc_data:
        xc_data[term['XC_functional_name']] = term
    else:
        LOGGER.info("pre-existing XC term: %s",
                    term['XC_functional_name'])
    return xc_data


126
def apply_terms_remove(xc_data, xc_data_remove):
127
128
129
130
131
132
133
134
    for (k, v) in xc_data_remove.items():
        if k in xc_data:
            xc_data[k]['XC_functional_weight'] -= v['XC_functional_weight']
        else:
            xc_data[k] = v
            xc_data[k]['XC_functional_weight'] *= -1.0


135
def apply_terms_filter(xc_data):
Henning Glawe's avatar
Henning Glawe committed
136
    for (k, v) in list(xc_data.items()):
137
        if abs(v['XC_functional_weight']) < 0.01:
Henning Glawe's avatar
Henning Glawe committed
138
            del xc_data[k]
139
140
141
        else:
            if abs(v['XC_functional_weight'] - 1.0) < 0.01:
                del v['XC_functional_weight']
Henning Glawe's avatar
Henning Glawe committed
142
            v.pop('exx_compute_weight', None)
Henning Glawe's avatar
Henning Glawe committed
143
144


145
146
147
148
149
150
151
152
153
154
155
156
def xc_functional_str(xc_data):
    result = ''
    for k in sorted(xc_data.keys()):
        v = xc_data[k]
        if len(result) > 0 and v.get('XC_functional_weight', 1.0) > 0:
            result += '+'
        if v.get('XC_functional_weight', None) is not None:
            result += '%.3f*' % (v['XC_functional_weight'])
        result += v['XC_functional_name']
    return result


157
158
159
160
# origin: espresso-5.4.0/Modules/funct.f90
EXCHANGE = [
    None,
    {
161
        'xc_terms': [{
162
163
            'XC_functional_name': 'LDA_X',
        }],
164
165
166
167
168
        'xc_section_method': {
            'x_qe_xc_iexch_name':       'sla',
            'x_qe_xc_iexch_comment':    'Slater (alpha=2/3)',
            'x_qe_xc_iexch':      1,
        },
169
170
    },
    {
171
        'xc_terms': [{
172
            'XC_functional_name': 'LDA_X',
173
            'XC_functional_parameters': {'alpha': 1.0},
174
        }],
175
176
177
178
179
        'xc_section_method': {
            'x_qe_xc_iexch_name':       'sl1',
            'x_qe_xc_iexch_comment':    'Slater (alpha=1.0)',
            'x_qe_xc_iexch':      2,
        },
180
181
    },
    {
182
        'xc_terms': [{
183
184
            'XC_functional_name': 'x_qe_LDA_X_RELATIVISTIC',
        }],
185
186
187
188
189
        'xc_section_method': {
            'x_qe_xc_iexch_name':       'rxc',
            'x_qe_xc_iexch_comment':    'Relativistic Slater',
            'x_qe_xc_iexch':      3,
        },
190
191
    },
    {
192
        'xc_terms': [{
193
            'XC_functional_name': 'OEP_EXX',
194
        }],
195
196
197
198
199
        'xc_section_method': {
            'x_qe_xc_iexch_name':       'oep',
            'x_qe_xc_iexch_comment':    'Optimized Effective Potential',
            'x_qe_xc_iexch':      4,
        },
200
201
    },
    {
202
        'xc_terms': [{
203
204
            'XC_functional_name': 'HF_X',
        }],
205
206
207
208
209
        'xc_section_method': {
            'x_qe_xc_iexch_name':       'hf',
            'x_qe_xc_iexch_comment':    'Hartree-Fock',
            'x_qe_xc_iexch':      5,
        },
210
211
    },
    {
212
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
213
            'XC_functional_name': 'HF_X',
214
            'exx_compute_weight': lambda exx: exx,
Henning Glawe's avatar
Henning Glawe committed
215
216
217
            'XC_functional_weight': 0.25,
        }, {
            'XC_functional_name': 'LDA_X',
218
            'exx_compute_weight': lambda exx: (1.0 - exx),
Henning Glawe's avatar
Henning Glawe committed
219
220
            'XC_functional_weight': 0.75,
        }],
221
222
223
224
225
        'xc_section_method': {
            'x_qe_xc_iexch_name':       "pb0x",
            'x_qe_xc_iexch_comment':    'PBE0 (Slater*0.75+HF*0.25)',
            'x_qe_xc_iexch':      6,
        },
226
227
    },
    {
228
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
229
            'XC_functional_name': 'HF_X',
230
            'exx_compute_weight': lambda exx: exx,
Henning Glawe's avatar
Henning Glawe committed
231
232
233
            'XC_functional_weight': 0.20,
        }, {
            'XC_functional_name': 'LDA_X',
234
            'exx_compute_weight': lambda exx: (1.0 - exx),
Henning Glawe's avatar
Henning Glawe committed
235
236
            'XC_functional_weight': 0.8,
        }],
237
238
239
240
241
        'xc_section_method': {
            'x_qe_xc_iexch_name':       "b3lp",
            'x_qe_xc_iexch_comment':    "B3LYP(Slater*0.80+HF*0.20)",
            'x_qe_xc_iexch':      7,
        },
242
243
    },
    {
244
        'xc_terms': [{
245
            'XC_functional_name': "LDA_X_KZK_x_qe",
246
        }],
247
248
249
250
251
        'xc_section_method': {
            'x_qe_xc_iexch_name':       "kzk",
            'x_qe_xc_iexch_comment':    "Finite-size corrections",
            'x_qe_xc_iexch':      8,
        },
252
253
    },
    {
254
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
255
            'XC_functional_name': 'HF_X',
256
            'exx_compute_weight': lambda exx: exx,
Henning Glawe's avatar
Henning Glawe committed
257
258
259
            'XC_functional_weight': 0.218,
        }, {
            'XC_functional_name': 'LDA_X',
260
            'exx_compute_weight': lambda exx: (1.0 - exx),
Henning Glawe's avatar
Henning Glawe committed
261
262
            'XC_functional_weight': 0.782,
        }],
263
264
265
266
267
        'xc_section_method': {
            'x_qe_xc_iexch_name':       "x3lp",
            'x_qe_xc_iexch_comment':    "X3LYP(Slater*0.782+HF*0.218)",
            'x_qe_xc_iexch':      9,
        },
268
269
270
271
272
273
274
    },
]


CORRELATION = [
    None,
    {
275
        'xc_terms': [{
276
277
            'XC_functional_name': 'LDA_C_PZ',
        }],
278
279
280
281
282
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "pz",
            'x_qe_xc_icorr_comment':    "Perdew-Zunger",
            'x_qe_xc_icorr':      1,
        },
283
284
    },
    {
285
        'xc_terms': [{
286
287
            'XC_functional_name': 'LDA_C_VWN',
        }],
288
289
290
291
292
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "vwn",
            'x_qe_xc_icorr_comment':    "Vosko-Wilk-Nusair",
            'x_qe_xc_icorr':      2,
        },
293
294
    },
    {
295
        'xc_terms': [{
296
297
            'XC_functional_name': 'LDA_C_LYP',
        }],
298
299
300
301
302
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "lyp",
            'x_qe_xc_icorr_comment':    "Lee-Yang-Parr",
            'x_qe_xc_icorr':      3,
        },
303
304
    },
    {
305
        'xc_terms': [{
306
307
            'XC_functional_name': "LDA_C_PW",
        }],
308
309
310
311
312
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "pw",
            'x_qe_xc_icorr_comment':    "Perdew-Wang",
            'x_qe_xc_icorr':      4,
        },
313
314
    },
    {
315
        'xc_terms': [{
316
317
            'XC_functional_name': 'LDA_C_WIGNER',
        }],
318
319
320
321
322
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "wig",
            'x_qe_xc_icorr_comment':    "Wigner",
            'x_qe_xc_icorr':      5,
        },
323
324
    },
    {
325
        'xc_terms': [{
326
327
            'XC_functional_name': 'LDA_C_HL',
        }],
328
329
330
331
332
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "hl",
            'x_qe_xc_icorr_comment':    "Hedin-Lunqvist",
            'x_qe_xc_icorr':      6,
        },
333
334
    },
    {
335
        'xc_terms': [{
336
337
            'XC_functional_name': 'LDA_C_OB_PZ',
        }],
338
339
340
341
342
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "obz",
            'x_qe_xc_icorr_comment':    "Ortiz-Ballone form for PZ",
            'x_qe_xc_icorr':      7,
        },
343
344
    },
    {
345
        'xc_terms': [{
346
347
            'XC_functional_name': 'LDA_C_OB_PW',
        }],
348
349
350
351
352
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "obw",
            'x_qe_xc_icorr_comment':    "Ortiz-Ballone form for PW",
            'x_qe_xc_icorr':      8,
        },
353
354
    },
    {
355
        'xc_terms': [{
356
357
            'XC_functional_name': 'LDA_C_GL',
        }],
358
359
360
361
362
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "gl",
            'x_qe_xc_icorr_comment':    "Gunnarson-Lunqvist",
            'x_qe_xc_icorr':      9,
        },
363
364
    },
    {
365
        'xc_terms': [{
366
            'XC_functional_name': "LDA_C_KZK_x_qe",
367
        }],
368
369
370
371
372
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "kzk",
            'x_qe_xc_icorr_comment':    "Finite-size corrections",
            'x_qe_xc_icorr':      10,
        },
373
374
    },
    {
375
        'xc_terms': [{
376
377
            'XC_functional_name': 'LDA_C_VWN_RPA',
        }],
378
379
380
381
382
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "vwn-rpa",
            'x_qe_xc_icorr_comment':    "Vosko-Wilk-Nusair, alt param",
            'x_qe_xc_icorr':      11,
        },
383
384
    },
    {
385
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
386
387
388
389
390
391
            'XC_functional_name': 'LDA_C_VWN',
            'XC_functional_weight': 0.19,
        }, {
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.81,
        }],
392
393
394
395
396
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "b3lp",
            'x_qe_xc_icorr_comment':    "B3LYP (0.19*vwn+0.81*lyp)",
            'x_qe_xc_icorr':      12,
        },
397
398
    },
    {
399
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
400
            'XC_functional_name': 'LDA_C_VWN_RPA',
Henning Glawe's avatar
Henning Glawe committed
401
402
403
404
405
            'XC_functional_weight': 0.19,
        }, {
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.81,
        }],
406
        'xc_section_method': {
407
408
409
            'x_qe_xc_icorr_name':    "b3lpv1r",
            'x_qe_xc_icorr_comment': "B3LYP-VWN-1-RPA (0.19*vwn_rpa+0.81*lyp)",
            'x_qe_xc_icorr':         13,
410
        },
411
412
    },
    {
413
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
414
            'XC_functional_name': 'LDA_C_VWN_RPA',
Henning Glawe's avatar
Henning Glawe committed
415
416
417
418
419
            'XC_functional_weight': 0.129,
        }, {
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.871,
        }],
420
421
422
423
424
        'xc_section_method': {
            'x_qe_xc_icorr_name':       "x3lp",
            'x_qe_xc_icorr_comment':    "X3LYP (0.129*vwn_rpa+0.871*lyp)",
            'x_qe_xc_icorr':      14,
        },
425
426
427
428
429
430
    },
]

EXCHANGE_GRADIENT_CORRECTION = [
    None,
    {
431
        'xc_terms': [{
432
433
            'XC_functional_name': "GGA_X_B88",
        }],
434
        'xc_terms_remove': [{
435
436
            'XC_functional_name': 'LDA_X',
        }],
437
438
439
440
441
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "b88",
            'x_qe_xc_igcx_comment':    "Becke88 (beta=0.0042)",
            'x_qe_xc_igcx':      1,
        },
442
443
    },
    {
444
        'xc_terms': [{
445
446
            'XC_functional_name': "GGA_X_PW91",
        }],
447
        'xc_terms_remove': [{
448
449
            'XC_functional_name': 'LDA_X',
        }],
450
451
452
453
454
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "ggx",
            'x_qe_xc_igcx_comment':    "Perdew-Wang 91",
            'x_qe_xc_igcx':      2,
        },
455
456
    },
    {
457
        'xc_terms': [{
458
459
            'XC_functional_name': "GGA_X_PBE",
        }],
460
        'xc_terms_remove': [{
461
462
            'XC_functional_name': 'LDA_X',
        }],
463
464
465
466
467
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "pbx",
            'x_qe_xc_igcx_comment':    "Perdew-Burke-Ernzenhof exch",
            'x_qe_xc_igcx':      3,
        },
468
469
    },
    {
470
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
471
            'XC_functional_name': "GGA_X_PBE_R",
472
        }],
473
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
474
475
            'XC_functional_name': 'LDA_X',
        }],
476
477
478
479
480
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "rpb",
            'x_qe_xc_igcx_comment':    "revised PBE by Zhang-Yang",
            'x_qe_xc_igcx':      4,
        },
481
482
    },
    {
483
        'xc_terms': [{
484
485
            'XC_functional_name': "GGA_XC_HCTH_120",
        }],
486
487
488
489
490
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "hcth",
            'x_qe_xc_igcx_comment':    "Cambridge exch, Handy et al, HCTH/120",
            'x_qe_xc_igcx':      5,
        },
491
492
    },
    {
493
        'xc_terms': [{
494
495
            'XC_functional_name': "GGA_X_OPTX",
        }],
496
497
498
499
500
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "optx",
            'x_qe_xc_igcx_comment':    "Handy's exchange functional",
            'x_qe_xc_igcx':      6,
        },
501
    },
502
503
504
    {
        # igcx=7 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
505
        'xc_terms': [{
506
507
            'XC_functional_name': "MGGA_X_TPSS",
        }],
508
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
509
510
            'XC_functional_name': 'LDA_X',
        }],
511
        'xc_section_method': {
512
513
514
            'x_qe_xc_igcx_name':    "tpss",
            'x_qe_xc_igcx_comment': "TPSS Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcx':         7,
515
        },
516
    },
517
    {
518
        'xc_terms': [{
519
            'XC_functional_name': "GGA_X_PBE",
520
            'XC_functional_weight': 0.75,
521
            'exx_compute_weight': lambda exx: (1.0 - exx),
522
        }],
523
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
524
525
            'XC_functional_name': 'LDA_X',
            'XC_functional_weight': 0.75,
526
            'exx_compute_weight': lambda exx: (1.0 - exx),
Henning Glawe's avatar
Henning Glawe committed
527
        }],
528
529
530
531
532
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "pb0x",
            'x_qe_xc_igcx_comment':    "PBE0 (PBE exchange*0.75)",
            'x_qe_xc_igcx':      8,
        },
533
534
    },
    {
535
        'xc_terms': [{
536
            'XC_functional_name': "GGA_X_B88",
537
            'XC_functional_weight': 0.72,
Henning Glawe's avatar
Henning Glawe committed
538
            'exx_compute_weight': lambda exx: 0.72 if abs(exx) > 0.01 else 1.0
539
        }],
540
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
541
542
543
544
            'XC_functional_name': 'LDA_X',
            'XC_functional_weight': 0.8,
            'exx_compute_weight': lambda exx: (1.0 - exx),
         }],
545
546
547
548
549
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "b3lp",
            'x_qe_xc_igcx_comment':    "B3LYP (Becke88*0.72)",
            'x_qe_xc_igcx':      9,
        },
550
551
    },
    {
552
        'xc_terms': [{
553
554
            'XC_functional_name': "GGA_X_PBE_SOL",
        }],
555
        'xc_terms_remove': [{
556
557
            'XC_functional_name': 'LDA_X',
         }],
558
559
560
561
562
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "psx",
            'x_qe_xc_igcx_comment':    "PBEsol exchange",
            'x_qe_xc_igcx':      10,
        },
563
564
    },
    {
565
        'xc_terms': [{
566
567
            'XC_functional_name': "GGA_X_WC",
        }],
568
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
569
570
            'XC_functional_name': 'LDA_X',
         }],
571
572
573
574
575
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "wcx",
            'x_qe_xc_igcx_comment':    "Wu-Cohen",
            'x_qe_xc_igcx':      11,
        },
576
577
    },
    {
578
        'xc_terms': [{
579
            'XC_functional_name': "HYB_GGA_XC_HSE06",
580
581
582
583
            'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0
        }, {
            'XC_functional_name': "GGA_X_PBE",
            'exx_compute_weight': lambda exx: 0.0 if (abs(exx) > 0.01) else 1.0
584
        }],
585
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
586
            'XC_functional_name': 'LDA_X',
587
588
589
590
        }, {
            'XC_functional_name': 'GGA_C_PBE',
            'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0
        }],
591
592
593
594
595
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "hse",
            'x_qe_xc_igcx_comment':    "HSE screened exchange",
            'x_qe_xc_igcx':      12,
        },
596
597
    },
    {
598
        'xc_terms': [{
599
600
            'XC_functional_name': "GGA_X_RPW86",
        }],
601
        'xc_terms_remove': [{
602
603
            'XC_functional_name': 'LDA_X',
         }],
604
605
606
607
608
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "rw86",
            'x_qe_xc_igcx_comment':    "revised PW86",
            'x_qe_xc_igcx':      13,
        },
609
610
    },
    {
611
        'xc_terms': [{
612
613
            'XC_functional_name': "GGA_X_PBE",
        }],
614
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
615
616
            'XC_functional_name': 'LDA_X',
         }],
617
618
619
620
621
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "pbe",
            'x_qe_xc_igcx_comment':    "same as PBX, back-comp.",
            'x_qe_xc_igcx':      14,
        },
622
    },
623
624
625
    {
        # igcx=15 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
626
        'xc_terms': [{
627
628
            'XC_functional_name': "MGGA_X_TB09",
        }],
629
        'xc_terms_remove': [{
630
631
            'XC_functional_name': 'LDA_X',
         }],
632
        'xc_section_method': {
633
634
635
            'x_qe_xc_igcx_name':    "tb09",
            'x_qe_xc_igcx_comment': "TB09 Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcx':         15,
636
        },
637
    },
638
    {
639
        'xc_terms': [{
640
641
            'XC_functional_name': "GGA_X_C09X",
        }],
642
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
643
644
            'XC_functional_name': 'LDA_X',
         }],
645
646
647
648
649
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "c09x",
            'x_qe_xc_igcx_comment':    "Cooper 09",
            'x_qe_xc_igcx':      16,
        },
650
651
    },
    {
652
        'xc_terms': [{
653
654
            'XC_functional_name': "GGA_X_SOGGA",
        }],
655
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
656
657
            'XC_functional_name': 'LDA_X',
         }],
658
659
660
661
662
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "sox",
            'x_qe_xc_igcx_comment':    "sogga",
            'x_qe_xc_igcx':      17,
        },
663
    },
664
665
666
    {
        # igcx=18 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
667
        'xc_terms': [{
668
669
            'XC_functional_name': "MGGA_X_M06_L",
        }],
670
        'xc_section_method': {
671
672
673
            'x_qe_xc_igcx_name':    "m6lx",
            'x_qe_xc_igcx_comment': "M06L Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcx':         18,
674
        },
675
    },
676
    {
677
        'xc_terms': [{
678
679
            'XC_functional_name': "GGA_X_Q2D",
        }],
680
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
681
            'XC_functional_name': 'LDA_X',
Henning Glawe's avatar
Henning Glawe committed
682
        }],
683
684
685
686
687
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "q2dx",
            'x_qe_xc_igcx_comment':    "Q2D exchange grad corr",
            'x_qe_xc_igcx':      19,
        },
688
689
    },
    {
690
        'xc_terms': [{
691
            'XC_functional_name': "HYB_GGA_XC_GAU_PBE_x_qe",
692
693
694
695
            'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0
        }, {
            'XC_functional_name': "GGA_X_PBE",
            'exx_compute_weight': lambda exx: 0.0 if (abs(exx) > 0.01) else 1.0
696
        }],
697
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
698
            'XC_functional_name': 'LDA_X',
Henning Glawe's avatar
Henning Glawe committed
699
        }, {
Henning Glawe's avatar
Henning Glawe committed
700
701
            'XC_functional_name': 'GGA_C_PBE',
            'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0
Henning Glawe's avatar
Henning Glawe committed
702
        }],
703
704
705
706
707
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "gaup",
            'x_qe_xc_igcx_comment':    "Gau-PBE hybrid exchange",
            'x_qe_xc_igcx':      20,
        },
708
709
    },
    {
710
        'xc_terms': [{
711
712
            'XC_functional_name': "GGA_X_PW86",
        }],
713
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
714
715
            'XC_functional_name': 'LDA_X',
        }],
716
717
718
719
720
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "pw86",
            'x_qe_xc_igcx_comment':    "Perdew-Wang (1986) exchange",
            'x_qe_xc_igcx':      21,
        },
721
722
    },
    {
723
        'xc_terms': [{
724
725
            'XC_functional_name': "GGA_X_B86_MGC",
        }],
726
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
727
728
            'XC_functional_name': 'LDA_X',
        }],
729
730
731
732
733
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "b86b",
            'x_qe_xc_igcx_comment':    "Becke (1986) exchange",
            'x_qe_xc_igcx':      22,
        },
734
735
    },
    {
736
        'xc_terms': [{
737
738
            'XC_functional_name': "GGA_X_OPTB88_VDW",
        }],
739
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
740
741
            'XC_functional_name': 'LDA_X',
        }],
742
743
744
745
746
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "obk8",
            'x_qe_xc_igcx_comment':    "optB88  exchange",
            'x_qe_xc_igcx':      23,
        },
747
748
    },
    {
749
        'xc_terms': [{
750
            'XC_functional_name': "GGA_X_OPTB86_VDW_x_qe",
751
        }],
752
        'xc_terms_remove': [{
753
754
            'XC_functional_name': 'LDA_X',
        }],
755
756
757
758
759
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "ob86",
            'x_qe_xc_igcx_comment':    "optB86b exchange",
            'x_qe_xc_igcx':      24,
        },
760
761
    },
    {
762
        'xc_terms': [{
763
764
            'XC_functional_name': "GGA_X_EV93",
        }],
765
        'xc_terms_remove': [{
766
767
            'XC_functional_name': 'LDA_X',
        }],
768
769
770
771
772
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "evx",
            'x_qe_xc_igcx_comment':    "Engel-Vosko exchange",
            'x_qe_xc_igcx':      25,
        },
773
774
    },
    {
775
        'xc_terms': [{
776
777
            'XC_functional_name': "GGA_X_B86_R",
        }],
778
        'xc_terms_remove': [{
779
780
            'XC_functional_name': 'LDA_X',
        }],
781
782
783
784
785
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "b86r",
            'x_qe_xc_igcx_comment':    "revised Becke (b86b)",
            'x_qe_xc_igcx':      26,
        },
786
787
    },
    {
788
        'xc_terms': [{
789
790
            'XC_functional_name': "GGA_X_LV_RPW86",
        }],
791
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
792
793
            'XC_functional_name': 'LDA_X',
        }],
794
795
796
797
798
        'xc_section_method': {
            'x_qe_xc_igcx_name':       "cx13",
            'x_qe_xc_igcx_comment':    "consistent exchange",
            'x_qe_xc_igcx':      27,
        },
799
800
    },
    {
801
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
802
803
            'XC_functional_name': "GGA_X_B88",
            'XC_functional_weight': 0.542,
804
805
            'exx_compute_weight':
                lambda exx: 0.542 if (abs(exx) > 0.01) else 1.0
Henning Glawe's avatar
Henning Glawe committed
806
807
808
        }, {
            'XC_functional_name': "GGA_X_PW91",
            'XC_functional_weight': 0.167,
809
810
            'exx_compute_weight':
                lambda exx: 0.167 if (abs(exx) > 0.01) else 0.0
Henning Glawe's avatar
Henning Glawe committed
811
        }],
812
        'xc_terms_remove': [{
813
814
815
816
            'XC_functional_name': 'LDA_X',
            'exx_compute_weight':
                lambda exx: 0.709 if (abs(exx) > 0.01) else 1.0
        }],
817
        'xc_section_method': {
818
819
820
821
            'x_qe_xc_igcx_name':    "x3lp",
            'x_qe_xc_igcx_comment': "X3LYP (Becke88*0.542 "
                                    " + Perdew-Wang91*0.167)",
            'x_qe_xc_igcx':         28,
822
        },
823
824
825
826
827
828
    },
]

CORRELATION_GRADIENT_CORRECTION = [
    None,
    {
829
        'xc_terms': [{
830
831
            'XC_functional_name': "GGA_C_P86",
        }],
832
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
833
834
            'XC_functional_name': 'LDA_C_PW',
        }],
835
836
837
838
839
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "p86",
            'x_qe_xc_igcc_comment':    "Perdew86",
            'x_qe_xc_igcc':      1,
        },
840
841
    },
    {
842
        'xc_terms': [{
843
844
            'XC_functional_name': "GGA_C_PW91",
        }],
845
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
846
847
            'XC_functional_name': 'LDA_C_PW',
        }],
848
849
850
851
852
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "ggc",
            'x_qe_xc_igcc_comment':    "Perdew-Wang 91 corr.",
            'x_qe_xc_igcc':      2,
        },
853
854
    },
    {
855
        'xc_terms': [{
856
857
            'XC_functional_name': "GGA_C_LYP",
        }],
858
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
859
860
            'XC_functional_name': 'LDA_C_LYP',
        }],
861
862
863
864
865
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "blyp",
            'x_qe_xc_igcc_comment':    "Lee-Yang-Parr",
            'x_qe_xc_igcc':      3,
        },
866
867
    },
    {
868
        'xc_terms': [{
869
870
            'XC_functional_name': "GGA_C_PBE",
        }],
871
        'xc_terms_remove': [{
Henning Glawe's avatar
Henning Glawe committed
872
873
            'XC_functional_name': 'LDA_C_PW',
        }],
874
875
876
877
878
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "pbc",
            'x_qe_xc_igcc_comment':    "Perdew-Burke-Ernzenhof corr",
            'x_qe_xc_igcc':      4,
        },
879
880
    },
    {
881
        'xc_terms': [{
882
883
            'XC_functional_name': "GGA_XC_HCTH_120",
        }],
884
885
886
887
888
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "hcth",
            'x_qe_xc_igcc_comment':    "Cambridge exch, Handy et al, HCTH/120",
            'x_qe_xc_igcc':      5,
        },
889
    },
890
891
892
    {
        # igcc=6 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
893
        'xc_terms': [{
894
895
            'XC_functional_name': "MGGA_C_TPSS",
        }],
896
        'xc_terms_remove': [{
897
898
            'XC_functional_name': 'LDA_C_PW',
        }],
899
        'xc_section_method': {
900
901
902
            'x_qe_xc_igcc_name':    "tpss",
            'x_qe_xc_igcc_comment': "TPSS Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcc':         6,
903
        },
904
    },
905
    {
906
        'xc_terms': [{
907
            'XC_functional_name': "GGA_C_LYP",
908
            'XC_functional_weight': 0.81,
909
        }],
910
        'xc_terms_remove': [{
911
912
913
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.81,
        }],
914
915
916
917
918
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "b3lp",
            'x_qe_xc_igcc_comment':    "B3LYP (Lee-Yang-Parr*0.81)",
            'x_qe_xc_igcc':      7,
        },
919
920
    },
    {
921
        'xc_terms': [{
922
923
            'XC_functional_name': "GGA_C_PBE_SOL",
        }],
924
        'xc_terms_remove': [{
925
926
            'XC_functional_name': 'LDA_C_PW',
        }],
927
928
929
930
931
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "psc",
            'x_qe_xc_igcc_comment':    "PBEsol corr",
            'x_qe_xc_igcc':      8,
        },
932
933
    },
    {
934
        'xc_terms': [{
935
936