Skip to content

Commit 96f0676

Browse files
committed
read energy from nwpw block
1 parent 6c28ec8 commit 96f0676

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ase_pwdft/pwdftio/pwdftreader.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,21 @@ def read_pwdft_out(filename):
2424

2525
data = json.loads(json_str)
2626

27-
pspw = data['pspw']
28-
energy = pspw['energy'] * Hartree
27+
if 'pspw' in data:
28+
pspw = data['pspw']
29+
energy = pspw['energy'] * Hartree
30+
elif 'nwpw' in data:
31+
nwpw = data['nwpw']
32+
energy = nwpw['energy'] * Hartree
33+
else:
34+
raise KeyError("Neither 'pspw' nor 'nwpw' keys are present in the output data.")
2935

3036
geo = data['geometries']
3137
geo1 = geo['geometry']
3238
nion = geo1['nion']
3339

3440
symbols = geo1['symbols']
3541
cell = np.array(geo1['unita']).reshape(3, 3)
36-
nwpw = data['nwpw']
3742
dipole = np.array(nwpw['dipole'])
3843
coors = np.array(geo1['coords']).reshape(nion, 3)
3944

0 commit comments

Comments
 (0)