-
Notifications
You must be signed in to change notification settings - Fork 93
/
run_oneshot_phonon.py
executable file
·93 lines (71 loc) · 3 KB
/
run_oneshot_phonon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
"""Phonon band structure of AlAs."""
from __future__ import print_function, division, unicode_literals, absolute_import
import sys
import os
import numpy as np
import abipy.abilab as abilab
import abipy.data as abidata
import abipy.flowapi as flowapi
def scf_ph_inputs(paral_kgb=0):
"""
This function constructs the input files for the phonon calculation:
GS input + the input files for the phonon calculation.
"""
# Crystalline AlAs: computation of the second derivative of the total energy
structure = abidata.structure_from_ucell("AlAs")
pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc")
# List of q-points for the phonon calculation.
qpoints = [
0.00000000E+00, 0.00000000E+00, 0.00000000E+00,
]
qpoints = np.reshape(qpoints, (-1,3))
# Global variables used both for the GS and the DFPT run.
global_vars = dict(nband=4,
ecut=3.0,
ngkpt=[4, 4, 4],
shiftk=[0, 0, 0],
tolvrs=1.0e-8,
paral_kgb=paral_kgb,
)
multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=1+len(qpoints))
multi.set_structure(structure)
multi.set_vars(global_vars)
for i, qpt in enumerate(qpoints):
# Response-function calculation for phonons.
multi[i+1].set_vars(
nstep=20,
rfphon=1, # Will consider phonon-type perturbation
nqpt=1, # One one wavevector is to be considered
qpt=qpt, # The q-point
rfatpol=[1, len(structure)], # Only the first atom is displaced
rfdir=[1, 1, 1], # Along the first reduced coordinate axis
#kptopt 2 # Automatic generation of k points, taking
)
# Split input into gs_inp and ph_inputs
return multi.split_datasets()
def build_flow(options):
"""
Create an `AbinitFlow` for phonon calculations:
1) One workflow for the GS run.
2) nqpt workflows for phonon calculations. Each workflow contains
nirred tasks where nirred is the number of irreducible phonon perturbations
for that particular q-point.
"""
# Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
workdir = options.workdir
if not options.workdir:
workdir = os.path.basename(__file__).replace(".py", "").replace("run_","flow_")
all_inps = scf_ph_inputs()
scf_input, ph_inputs = all_inps[0], all_inps[1:]
flow = flowapi.Flow(workdir, manager=options.manager, remove=options.remove)
work = flowapi.build_oneshot_phononwork(scf_input, ph_inputs)
flow.register_work(work)
return flow
@abilab.flow_main
def main(options):
flow = build_flow(options)
flow.build_and_pickle_dump()
return flow
if __name__ == "__main__":
sys.exit(main())