Skip to content

Commit 89cee77

Browse files
Merge pull request #6 from pyiron/nbands
Nbands convergence check (vasp)
2 parents 12dcc59 + 18823ec commit 89cee77

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

pyiron_atomistics/dft/job/generic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,16 @@ def calc_md(
337337
time_step=time_step,
338338
)
339339

340+
def nbands_convergence_check(self):
341+
"""
342+
Function to check if there are a sufficient number of empty bands in the calculation to ensure electronic convergence.
343+
344+
Returns:
345+
346+
bool : True if the highest band is unoccupied, False if the highest band is occupied
347+
"""
348+
return np.all(np.isclose(self["output/electronic_structure/occ_matrix"][:,:,-1], 0)) #shape is n_spin x n_kpoints x n_bands
349+
340350
# Backward compatibility
341351
def get_encut(self):
342352
return self.encut

pyiron_atomistics/sphinx/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,16 @@ def collect_output(self, force_update=False):
13791379

13801380
def convergence_check(self):
13811381
"""
1382-
Checks if job has converged according to given cutoffs.
1382+
Checks for electronic and ionic convergence according to the user specified tolerance
1383+
1384+
Returns:
1385+
1386+
bool: True if converged
1387+
13831388
"""
1389+
# Checks if sufficient empty states are present
1390+
if not self.nbands_convergence_check():
1391+
return False
13841392
if (
13851393
self._generic_input["calc_mode"] == "minimize"
13861394
and self._output_parser._parse_dict["scf_convergence"][-1]

pyiron_atomistics/vasp/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ def collect_output(self):
404404
)
405405

406406
def convergence_check(self):
407+
"""
408+
Checks for electronic and ionic convergence according to the user specified tolerance
409+
410+
Returns:
411+
412+
bool: True if converged
413+
414+
"""
415+
# Checks if sufficient empty states are present
416+
if not self.nbands_convergence_check():
417+
return False
407418
if "IBRION" in self["input/incar/data_dict"]["Parameter"]:
408419
ind = self["input/incar/data_dict"]["Parameter"].index("IBRION")
409420
ibrion = int(self["input/incar/data_dict"]["Value"][ind])

tests/sphinx/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def test_collect_2_5(self):
542542

543543
def test_check_band_occupancy(self):
544544
self.assertTrue(self.sphinx_2_5.output.check_band_occupancy())
545+
self.assertTrue(self.sphinx_2_5.nbands_convergence_check())
545546

546547
def test_collect_2_3(self):
547548
file_location = os.path.join(

0 commit comments

Comments
 (0)