Skip to content

Commit

Permalink
final commits for the VASP info attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Oct 31, 2023
1 parent a6a29c6 commit 7188847
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/sisl/io/vasp/stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ class stdoutSileVASP(SileVASP):
_info_attributes_ = [
_A("completed", r".*General timing and accounting",
lambda attr, match: lambda : True, default=lambda : False),
_A("accuracy_reached", r".*reached required accuracy",
lambda attr, match: lambda : True, default=lambda : False),
]

@deprecation("stdoutSileVASP.completed is deprecated in favor of stdoutSileVASP.info.completed", "0.16.0")
def completed(self):
""" True if the line "General timing and accounting" was found. """
return self.info.completed()

@deprecation("stdoutSileVASP.accuracy_reached is deprecated in favor of stdoutSileVASP.info.accuracy_reached", "0.16.0")
def accuracy_reached(self):
""" True if the line "reached required accuracy" was found. """
return self.info.accuracy_reached()

@sile_fh_open()
def cpu_time(self, flag="General timing and accounting"):
""" Returns the consumed cpu time (in seconds) from a given section """
Expand All @@ -41,17 +48,11 @@ def cpu_time(self, flag="General timing and accounting"):

found = self.step_to(flag, allow_reread=False)[0]
if found:
self._completed = True
for _ in range(nskip):
line = self.readline()
return float(line.split()[iplace])
raise KeyError(f"{self.__class__.__name__}.cpu_time could not find flag '{flag}' in file")

@sile_fh_open()
def accuracy_reached(self):
""" True if the line "reached required accuracy" was found. """
return self.step_to("reached required accuracy")[0]

@SileBinder()
@sile_fh_open()
@deprecate_argument("all", None, "use read_energy[:]() instead to get all entries", from_version="0.14")
Expand Down
6 changes: 3 additions & 3 deletions src/sisl/io/vasp/tests/test_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ def test_diamond_outcar_energies(sisl_files):
assert E0 == Eall[0]
assert E == Eall[-1]
assert len(Eall) > 1
assert f.completed()
assert f.info.completed()


def test_diamond_outcar_cputime(sisl_files):
f = sisl_files(_dir, 'diamond', 'OUTCAR')
f = stdoutSileVASP(f)

assert f.cpu_time() > 0.
assert f.completed()
assert f.info.completed()


def test_diamond_outcar_completed(sisl_files):
f = sisl_files(_dir, 'diamond', 'OUTCAR')
f = stdoutSileVASP(f)

assert f.completed()
assert f.info.completed()


def test_diamond_outcar_trajectory(sisl_files):
Expand Down

0 comments on commit 7188847

Please sign in to comment.