Skip to content

Commit

Permalink
get all wave function script using pawpyseed
Browse files Browse the repository at this point in the history
  • Loading branch information
frssp committed Apr 2, 2019
1 parent b687e8b commit 2a5ea95
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 57 deletions.
6 changes: 3 additions & 3 deletions example/DX-center/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ captures:
σ: 0.010
ccs:
- cc:
W: 0.06754919103705884
g: 1
W: 0.023928100621566802
g: 4
initial: d0+e+h
final: DX-+h
- cc:
W: 0.021733641278758646
W: 0.020252900368602698
g: 1
initial: DX-+h
final: d0
54 changes: 54 additions & 0 deletions script/get_pswf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
# -*- coding=utf-8 -*-

import sys
import argparse
import numpy as np
from pymatgen.io.vasp.outputs import Wavecar

def read_WAVECAR(file='WAVECAR', ks=0, bs=1, s=0, output='wf'):
# The list of coefficients for each k-point and band for reconstructing the wavefunction.
# For non-spin-polarized, the first index corresponds to the kpoint and the second corresponds to the band
# (e.g. self.coeffs[kp][b] corresponds to k-point kp and band b).
# For spin-polarized calculations, the first index is for the spin.
wavecar = Wavecar(file)
for k in ks:
for b in bs:
#wf = wavecar.fft_mesh(kpoint=k, band=b-1)
coeffs = np.array(wavecar.coeffs)
if coeffs.ndim == 3:
wf = coeffs[s][k][b]
else:
wf = coeffs[k][b]
print('wf.shape', wf.shape)
print('wavecar.kpoints', wavecar.kpoints)
np.save('{}_k{}b{}.npy'.format(output, k, b), wf)


def main(file, s, k, b, output):
read_WAVECAR(file, k, b, s, output)


if __name__ == '__main__':
'''
'''
parser = argparse.ArgumentParser()
parser.add_argument("-f","--file",
help="VASP WAVECAR ", default="./WAVECAR")
parser.add_argument("-o","--output",
help="save ", default="wf")
parser.add_argument("-b","--band", type=int, nargs='+',
help="band index starting from 1", default=[1])
parser.add_argument("-k","--kpoint", type=int, nargs='+',
help="kpoint index starting from 0", default=[0])
parser.add_argument("-s","--spin", default=0, type=int,
help="spin index 1 or 0",)

args = parser.parse_args()
file = args.file
output = args.output
band = args.band
kpoint = args.kpoint
spin = args.spin
main(file, spin, kpoint, band, output)

82 changes: 28 additions & 54 deletions script/get_wf.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,28 @@
#!/usr/bin/env python3
# -*- coding=utf-8 -*-

import sys
import argparse
import numpy as np
from pymatgen.io.vasp.outputs import Wavecar

def read_WAVECAR(file='WAVECAR', ks=0, bs=1, s=0, output='wf'):
# The list of coefficients for each k-point and band for reconstructing the wavefunction.
# For non-spin-polarized, the first index corresponds to the kpoint and the second corresponds to the band
# (e.g. self.coeffs[kp][b] corresponds to k-point kp and band b).
# For spin-polarized calculations, the first index is for the spin.
wavecar = Wavecar(file)
for k in ks:
for b in bs:
#wf = wavecar.fft_mesh(kpoint=k, band=b-1)
coeffs = np.array(wavecar.coeffs)
if coeffs.ndim == 3:
wf = coeffs[s][k][b]
else:
wf = coeffs[k][b]
print('wf.shape', wf.shape)
print('wavecar.kpoints', wavecar.kpoints)
np.save('{}_k{}b{}.npy'.format(output, k, b), wf)


def main(file, s, k, b, output):
read_WAVECAR(file, k, b, s, output)


if __name__ == '__main__':
'''
'''
parser = argparse.ArgumentParser()
parser.add_argument("-f","--file",
help="VASP WAVECAR ", default="./WAVECAR")
parser.add_argument("-o","--output",
help="save ", default="wf")
parser.add_argument("-b","--band", type=int, nargs='+',
help="band index starting from 1", default=[1])
parser.add_argument("-k","--kpoint", type=int, nargs='+',
help="kpoint index starting from 0", default=[0])
parser.add_argument("-s","--spin", default=0, type=int,
help="spin index 1 or 0",)

args = parser.parse_args()
file = args.file
output = args.output
band = args.band
kpoint = args.kpoint
spin = args.spin
main(file, spin, kpoint, band, output)

from pawpyseed.core.projector import * # also imports the wavefunction module
print('read wfs')
wf_02 = Wavefunction.from_directory('DISP_-02', setup_projectors=False)

wf_01 = Wavefunction.from_directory('DISP_-01', setup_projectors=False)
wf000 = Wavefunction.from_directory('DISP_000', setup_projectors=False)
wf001 = Wavefunction.from_directory('DISP_001', setup_projectors=False)
wf002 = Wavefunction.from_directory('DISP_002', setup_projectors=False)
wf003 = Wavefunction.from_directory('DISP_003', setup_projectors=False)
wf004 = Wavefunction.from_directory('DISP_004', setup_projectors=False)
print('realspace')

wf_CBM = wf000.write_state_realspace(433, 0, 0, dim=[336, 336, 336])
np.save('CBM.npy', wf_CBM)
print('CBM')
wf_VBM = wf000.write_state_realspace(431, 0, 0, dim=[336, 336, 336])
np.save('VBM.npy', wf_VBM)
print('VBM')

wf_defects = [ wf.write_state_realspace(432, 0, 0, dim=[336, 336, 336]) for wf in [wf_02, wf_01, wf000, wf001, wf002, wf003, wf004]]
print('DEFECTS')
np.save('D_-02.npy', wf_defects[0])
np.save('D_-01.npy', wf_defects[1])
np.save('D_000.npy', wf_defects[2])
np.save('D_001.npy', wf_defects[3])
np.save('D_002.npy', wf_defects[4])
np.save('D_003.npy', wf_defects[5])
np.save('D_004.npy', wf_defects[6])

0 comments on commit 2a5ea95

Please # to comment.