Skip to content

Commit

Permalink
Outputs fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
knc6 committed May 4, 2024
1 parent 320805e commit db2b697
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions jarvis/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ def read_file(self, lines=""):

def chg_set(self, text, start, end, volume, ng):
"""Return CHGCAR sets."""

lines_0 = text[start:end]
# tmp = np.empty((ng))
# p = np.fromstring('\n'.join(lines_0), sep=' ')
Expand Down Expand Up @@ -231,7 +230,6 @@ def vac_potential(
plot=True,
):
"""Calculate vacuum potential used in work-function calculation."""

if use_ase:
from ase.calculators.vasp import VaspChargeDensity

Expand Down Expand Up @@ -516,10 +514,21 @@ def efermi(self):

def all_structures(self, elements=[]):
"""Get all structure snapshots."""
force_pattern = "TOTAL-FORCE (eV/Angst)"
if not elements:
atoms = Atoms.from_poscar(
self.filename.replace("OUTCAR", "POSCAR")
).elements
try:
atoms = Atoms.from_poscar(
self.filename.replace("OUTCAR", "POSCAR")
).elements
except Exception:
print("Check POSCAR exsist, or pass elements.")
pass
blocks = []
for ii, i in enumerate(self.data):
if " free energy TOTEN =" in i:
blocks.append(i)
if " free energy ML TOTEN =" in i:
blocks.append(i)
nions = self.nions
atoms_array = []
energy_array = []
Expand Down Expand Up @@ -547,11 +556,15 @@ def all_structures(self, elements=[]):
.split("eV")[0]
)
energy_array.append(energy)
if " free energy ML TOTEN =" in i:
energy = (
self.data[ii]
.split(" free energy TOTEN =")[1]
.split("eV")[0]
)
energy_array.append(energy)

if (
" POSITION TOTAL-FORCE (eV/Angst)"
in i
):
if force_pattern in i:
coords = []
forces = []
for j in range(nions):
Expand All @@ -567,6 +580,10 @@ def all_structures(self, elements=[]):
)

atoms_array.append(atoms)
if len(blocks) != len(atoms_array):
print(
"WARNING: check OUTCAR parser", len(blocks), len(atoms_array)
)
return atoms_array, energy_array, force_array, stress_array

@property
Expand Down

0 comments on commit db2b697

Please sign in to comment.