QuantumEspressoXC.py 34 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
56
57
58
    # use dictionary to ensure uniqueness:
    #   exchange/correlation functionals may be combined into _XC_, and we
    #   only want to emit such combinations once
    xc_data = {}
59
    xc_data_remove = {}
60
    xc_section_method = {}
61
    for component_i in range(6):
62
63
64
65
        this_xf_num = xf_num[component_i]
        if this_xf_num == 0:
            # 0 means unset component
            continue
66
        component_max = len(XC_COMPONENT[component_i])-1
67
68
        this_component = None
        if this_xf_num > component_max:
69
70
            LOGGER.error(
                "%s[%d] beyond limit of %d",
71
72
                XC_COMPONENT_NAME[component_i], this_xf_num, component_max)
        else:
73
            this_component = XC_COMPONENT[component_i][this_xf_num]
74
75
76
        if this_component is None:
            raise RuntimeError("Undefined XC component %s[%d]" % (
                XC_COMPONENT_NAME[component_i], this_xf_num))
77
        xc_section_method.update(this_component['xc_section_method'])
78
        for this_term in this_component['xc_terms']:
79
            apply_term_add(
80
                xc_data, this_term, exact_exchange_fraction)
81
82
        if 'xc_terms_subtract' in this_component:
            for this_term in this_component['xc_terms_subtract']:
83
                apply_term_add(
84
85
                    xc_data_remove, this_term, exact_exchange_fraction)
    apply_terms_subtract(xc_data, xc_data_remove)
86
    apply_terms_filter(xc_data)
87
88
    xc_functional = xc_functional_str(xc_data)
    xc_section_method['XC_functional'] = xc_functional
Henning Glawe's avatar
Henning Glawe committed
89
    result = []
Henning Glawe's avatar
Henning Glawe committed
90
91
    for k in sorted(xc_data.keys()):
        v = xc_data[k]
Henning Glawe's avatar
Henning Glawe committed
92
        result.append(v)
93
    return (xc_section_method, result)
94
95


96
def apply_term_add(xc_data, this_term, exact_exchange_fraction):
97
    term = copy.deepcopy(this_term)
Henning Glawe's avatar
Henning Glawe committed
98
99
100
101
102
103
    if term['XC_functional_name'] == 'HYB_GGA_XC_HSE06':
        if exact_exchange_fraction is not None:
            # we are at HSE06 component, with explicit exact_exchange_fraction
            term['XC_functional_parameters'] = {
                'exx_mixing': exact_exchange_fraction,
            }
Henning Glawe's avatar
Henning Glawe committed
104
105
106
    if 'exx_compute_weight' in term:
        term['XC_functional_weight'] = term['exx_compute_weight'](
            exact_exchange_fraction)
107
108
    if 'XC_functional_weight' not in term:
        term['XC_functional_weight'] = 1.0
Henning Glawe's avatar
Henning Glawe committed
109
110
111
112
113
114
115
116
    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


117
def apply_terms_subtract(xc_data, xc_data_remove):
118
119
120
121
122
123
124
125
    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


126
def apply_terms_filter(xc_data):
Henning Glawe's avatar
Henning Glawe committed
127
    for (k, v) in list(xc_data.items()):
128
        if abs(v['XC_functional_weight']) < 0.01:
Henning Glawe's avatar
Henning Glawe committed
129
            del xc_data[k]
130
131
132
        else:
            if abs(v['XC_functional_weight'] - 1.0) < 0.01:
                del v['XC_functional_weight']
Henning Glawe's avatar
Henning Glawe committed
133
            v.pop('exx_compute_weight', None)
Henning Glawe's avatar
Henning Glawe committed
134
135


136
137
138
139
140
141
142
143
144
145
146
147
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


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


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

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

CORRELATION_GRADIENT_CORRECTION = [
    None,
    {
810
        'xc_terms': [{
811
812
            'XC_functional_name': "GGA_C_P86",
        }],
Henning Glawe's avatar
Henning Glawe committed
813
814
815
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
816
817
818
819
820
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "p86",
            'x_qe_xc_igcc_comment':    "Perdew86",
            'x_qe_xc_igcc':      1,
        },
821
822
    },
    {
823
        'xc_terms': [{
824
825
            'XC_functional_name': "GGA_C_PW91",
        }],
Henning Glawe's avatar
Henning Glawe committed
826
827
828
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
829
830
831
832
833
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "ggc",
            'x_qe_xc_igcc_comment':    "Perdew-Wang 91 corr.",
            'x_qe_xc_igcc':      2,
        },
834
835
    },
    {
836
        'xc_terms': [{
837
838
            'XC_functional_name': "GGA_C_LYP",
        }],
Henning Glawe's avatar
Henning Glawe committed
839
840
841
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_LYP',
        }],
842
843
844
845
846
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "blyp",
            'x_qe_xc_igcc_comment':    "Lee-Yang-Parr",
            'x_qe_xc_igcc':      3,
        },
847
848
    },
    {
849
        'xc_terms': [{
850
851
            'XC_functional_name': "GGA_C_PBE",
        }],
Henning Glawe's avatar
Henning Glawe committed
852
853
854
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
855
856
857
858
859
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "pbc",
            'x_qe_xc_igcc_comment':    "Perdew-Burke-Ernzenhof corr",
            'x_qe_xc_igcc':      4,
        },
860
861
    },
    {
862
        'xc_terms': [{
863
864
            'XC_functional_name': "GGA_XC_HCTH_120",
        }],
865
866
867
868
869
        '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,
        },
870
    },
871
872
873
    {
        # igcc=6 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
874
        'xc_terms': [{
875
876
            'XC_functional_name': "MGGA_C_TPSS",
        }],
877
878
879
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
880
        'xc_section_method': {
881
882
883
            'x_qe_xc_igcc_name':    "tpss",
            'x_qe_xc_igcc_comment': "TPSS Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcc':         6,
884
        },
885
    },
886
    {
887
        'xc_terms': [{
888
            'XC_functional_name': "GGA_C_LYP",
889
            'XC_functional_weight': 0.81,
890
        }],
891
892
893
894
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.81,
        }],
895
896
897
898
899
        '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,
        },
900
901
    },
    {
902
        'xc_terms': [{
903
904
            'XC_functional_name': "GGA_C_PBE_SOL",
        }],
905
906
907
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
908
909
910
911
912
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "psc",
            'x_qe_xc_igcc_comment':    "PBEsol corr",
            'x_qe_xc_igcc':      8,
        },
913
914
    },
    {
915
        'xc_terms': [{
916
917
            'XC_functional_name': "GGA_C_PBE",
        }],
918
919
920
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
921
922
923
924
925
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "pbe",
            'x_qe_xc_igcc_comment':    "same as PBX, back-comp.",
            'x_qe_xc_igcc':      9,
        },
926
    },
927
928
929
    {
        # igcc=10 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
930
        #        functionals.f90 tells that correlation is taken from tpss
931
        'xc_terms': [{
932
933
            'XC_functional_name': "MGGA_C_TPSS",
        }],
934
935
936
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
937
        'xc_section_method': {
938
939
940
            'x_qe_xc_igcc_name':    "tb09",
            'x_qe_xc_igcc_comment': "TB09 Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcc':         10,
941
        },
942
943
944
945
    },
    {
        # igcc=11 is not defined in 5.4's funct.f90
        #        definition taken from 5.0, which did not have separate imeta
946
        'xc_terms': [{
947
948
            'XC_functional_name': "MGGA_C_M06_L",
        }],
949
        'xc_section_method': {
Henning Glawe's avatar
Henning Glawe committed
950
            'x_qe_xc_igcc_name':    "m6lc",
951
952
            'x_qe_xc_igcc_comment': "M06L Meta-GGA (Espresso-version < 5.1)",
            'x_qe_xc_igcc':         2,
953
        },
954
    },
955
    {
956
        'xc_terms': [{
957
958
            'XC_functional_name': "GGA_C_Q2D",
        }],
Henning Glawe's avatar
Henning Glawe committed
959
960
961
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_PW',
        }],
962
963
964
965
966
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "q2dc",
            'x_qe_xc_igcc_comment':    "Q2D correlation grad corr",
            'x_qe_xc_igcc':      12,
        },
967
968
    },
    {
969
        'xc_terms': [{
970
            'XC_functional_name': "GGA_C_LYP",
971
            'XC_functional_weight': 0.871,
972
        }],
973
974
975
976
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_C_LYP',
            'XC_functional_weight': 0.871,
        }],
977
978
979
980
981
        'xc_section_method': {
            'x_qe_xc_igcc_name':       "x3lp",
            'x_qe_xc_igcc_comment':    "X3LYP (Lee-Yang-Parr*0.871)",
            'x_qe_xc_igcc':      13,
        },
982
983
984
985
    },
]


986
META_GGA = [
987
988
    None,
    {
989
        'xc_terms': [{
Henning Glawe's avatar
Henning Glawe committed
990
991
992
993
            'XC_functional_name': "MGGA_X_TPSS",
        }, {
            'XC_functional_name': "MGGA_C_TPSS",
        }],
Henning Glawe's avatar
Henning Glawe committed
994
995
        'xc_terms_subtract': [{
            'XC_functional_name': 'LDA_X',
996
997
        }, {
            'XC_functional_name': 'LDA_C_PW',
Henning Glawe's avatar
Henning Glawe committed
998
        }],