Skip to content

Commit

Permalink
PwBaseWorkChain: add handler for intentional non-convergence (#695)
Browse files Browse the repository at this point in the history
In certain cases, a user will set inputs such that the SCF will not
converge, for example, by setting `scf_must_converge` to false, or by
setting `electron_maxstep` to zero. This can be useful to initialize a
charge density of a system and the workchain should not restart or fail
in this case.

The `PwParser` now returns `WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED`
instead of `ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED` if any of these
parameters are set as described. The `PwBaseWorkChain` has a new handler
for this new exit code to consider the calculation as successful and
finish the workchain.

Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
  • Loading branch information
zooks97 and sphuber authored Jun 7, 2021
1 parent f4528af commit da94161
Show file tree
Hide file tree
Showing 7 changed files with 649 additions and 1 deletion.
5 changes: 5 additions & 0 deletions aiida_quantumespresso/calculations/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def define(cls, spec):
message='The electronic minimization cycle did not reach self-consistency.')
spec.exit_code(541, 'ERROR_SYMMETRY_NON_ORTHOGONAL_OPERATION',
message='The variable cell optimization broke the symmetry of the k-points.')

# Strong warnings about calculation results, but something tells us that you're ok with that
spec.exit_code(710, 'WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED',
message='The electronic minimization cycle did not reach self-consistency, but `scf_must_converge` '
'is `False` and/or `electron_maxstep` is 0.')
# yapf: enable

@classproperty
Expand Down
9 changes: 8 additions & 1 deletion aiida_quantumespresso/parsers/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@ def validate_electronic(self, trajectory, parameters, logs):
return

if 'ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED' in logs['error']:
return self.exit_codes.ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED
scf_must_converge = self.node.inputs.parameters.get_attribute('ELECTRONS',
{}).get('scf_must_converge', True)
electron_maxstep = self.node.inputs.parameters.get_attribute('ELECTRONS', {}).get('electron_maxstep', 1)

if electron_maxstep == 0 or not scf_must_converge:
return self.exit_codes.WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED
else:
return self.exit_codes.ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED

def validate_dynamics(self, trajectory, parameters, logs):
"""Analyze problems that are specific to `dynamics` type calculations: i.e. `md` and `vc-md`."""
Expand Down
15 changes: 15 additions & 0 deletions aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def define(cls, spec):
message='The initialization calculation failed.')
spec.exit_code(501, 'ERROR_IONIC_CONVERGENCE_REACHED_EXCEPT_IN_FINAL_SCF',
message='Then ionic minimization cycle converged but the thresholds are exceeded in the final SCF.')
spec.exit_code(710, 'WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED',
message='The electronic minimization cycle did not reach self-consistency, but `scf_must_converge` '
'is `False` and/or `electron_maxstep` is 0.')
# yapf: enable

@classmethod
Expand Down Expand Up @@ -588,3 +591,15 @@ def handle_electronic_convergence_not_achieved(self, calculation):
action = f'reduced beta mixing from {mixing_beta} to {mixing_beta_new} and restarting from the last calculation'
self.report_error_handled(calculation, action)
return ProcessHandlerReport(True)

@process_handler(priority=420, exit_codes=[
PwCalculation.exit_codes.WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED,
])
def handle_electronic_convergence_warning(self, calculation):
"""Handle `WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED': consider finished."""
self.ctx.is_finished = True
self.ctx.restart_calc = calculation
action = 'electronic convergence not reached but inputs say this is ok: consider finished.'
self.report_error_handled(calculation, action)
self.results() # Call the results method to attach the output nodes
return ProcessHandlerReport(True, self.exit_codes.WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED)
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@

Program PWSCF v.6.1 (svn rev. 13369) starts on 7Jun2019 at 17:14: 0

This program is part of the open-source Quantum ESPRESSO suite
for quantum simulation of materials; please cite
"P. Giannozzi et al., J. Phys.:Condens. Matter 21 395502 (2009);
URL http://www.quantum-espresso.org",
in publications or presentations arising from this work. More details at
http://www.quantum-espresso.org/quote

Parallel version (MPI), running on 1 processors
Reading input from aiida.in

Current dimensions of program PWSCF are:
Max number of different atomic species (ntypx) = 10
Max number of k-points (npk) = 40000
Max angular momentum in pseudopotentials (lmaxx) = 3

Subspace diagonalization in iterative solution of the eigenvalue problem:
a serial algorithm will be used


G-vector sticks info
--------------------
sticks: dense smooth PW G-vecs: dense smooth PW
Sum 859 433 127 16889 5985 965



bravais-lattice index = 0
lattice parameter (alat) = 7.2558 a.u.
unit-cell volume = 270.1072 (a.u.)^3
number of atoms/cell = 2
number of atomic types = 1
number of electrons = 8.00
number of Kohn-Sham states= 4
kinetic-energy cutoff = 30.0000 Ry
charge density cutoff = 240.0000 Ry
convergence threshold = 1.0E-06
mixing beta = 0.7000
number of iterations used = 8 plain mixing
Exchange-correlation = PBE ( 1 4 3 4 0 0)

celldm(1)= 7.255773 celldm(2)= 0.000000 celldm(3)= 0.000000
celldm(4)= 0.000000 celldm(5)= 0.000000 celldm(6)= 0.000000

crystal axes: (cart. coord. in units of alat)
a(1) = ( 0.707107 0.707107 0.000000 )
a(2) = ( 0.707107 0.000000 0.707107 )
a(3) = ( 0.000000 0.707107 0.707107 )

reciprocal axes: (cart. coord. in units 2 pi/alat)
b(1) = ( 0.707107 0.707107 -0.707107 )
b(2) = ( 0.707107 -0.707107 0.707107 )
b(3) = ( -0.707107 0.707107 0.707107 )


PseudoPot. # 1 for Si read from file:
./pseudo/Si.pbe-n-rrkjus_psl.1.0.0.UPF
MD5 check sum: 0b0bb1205258b0d07b9f9672cf965d36
Pseudo is Ultrasoft + core correction, Zval = 4.0
Generated using "atomic" code by A. Dal Corso v.5.1
Using radial grid of 1141 points, 6 beta functions with:
l(1) = 0
l(2) = 0
l(3) = 1
l(4) = 1
l(5) = 2
l(6) = 2
Q(r) pseudized with 0 coefficients


atomic species valence mass pseudopotential
Si 4.00 28.08550 Si( 1.00)


---- OUTPUT REMOVED ----

Cartesian axes

site n. atom positions (alat units)
1 Si tau( 1) = ( 0.0000000 0.0000000 0.0000000 )
2 Si tau( 2) = ( 0.3535534 0.3535534 0.3535534 )

Crystallographic axes

site n. atom positions (cryst. coord.)
1 Si tau( 1) = ( 0.0000000 0.0000000 0.0000000 )
2 Si tau( 2) = ( 0.2500000 0.2500000 0.2500000 )

number of k points= 3
cart. coord. in units 2pi/alat
k( 1) = ( 0.0000000 0.0000000 0.0000000), wk = 0.2500000
k( 2) = ( 0.3535534 -0.3535534 -0.3535534), wk = 1.0000000
k( 3) = ( 0.0000000 0.0000000 -0.7071068), wk = 0.7500000

cryst. coord.
k( 1) = ( 0.0000000 0.0000000 0.0000000), wk = 0.2500000
k( 2) = ( 0.0000000 0.0000000 -0.5000000), wk = 1.0000000
k( 3) = ( 0.0000000 -0.5000000 -0.5000000), wk = 0.7500000

Dense grid: 16889 G-vectors FFT dimensions: ( 36, 36, 36)

Smooth grid: 5985 G-vectors FFT dimensions: ( 25, 25, 25)

Estimated max dynamical RAM per process > 10.86MB

Initial potential from superposition of free atoms

starting charge 7.99888, renormalised to 8.00000
Starting wfc are 8 randomized atomic wfcs

total cpu time spent up to now is 0.9 secs

per-process dynamical memory: 20.0 Mb

Self-consistent Calculation

iteration # 1 ecut= 30.00 Ry beta=0.70
Davidson diagonalization with overlap
ethr = 1.00E-02, avg # of iterations = 2.0

total cpu time spent up to now is 1.1 secs

total energy = -22.64340821 Ry
Harris-Foulkes estimate = -22.67223092 Ry
estimated scf accuracy < 0.10529730 Ry

iteration # 2 ecut= 30.00 Ry beta=0.70
Davidson diagonalization with overlap
ethr = 1.32E-03, avg # of iterations = 1.0

total cpu time spent up to now is 1.3 secs

total energy = -22.64972429 Ry
Harris-Foulkes estimate = -22.65005091 Ry
estimated scf accuracy < 0.00535578 Ry

iteration # 3 ecut= 30.00 Ry beta=0.70
Davidson diagonalization with overlap
ethr = 6.69E-05, avg # of iterations = 3.0

total cpu time spent up to now is 1.5 secs

total energy = -22.65168183 Ry
Harris-Foulkes estimate = -22.65176063 Ry
estimated scf accuracy < 0.00032274 Ry

End of self-consistent calculation

convergence NOT achieved after 3 iterations: stopping

Writing output data file aiida.save

---- OUTPUT REMOVED ----

Parallel routines
fft_scatter : 0.01s CPU 0.01s WALL ( 343 calls)

PWSCF : 1.37s CPU 1.51s WALL


This run was terminated on: 17:14: 2 7Jun2019

=------------------------------------------------------------------------------=
JOB DONE.
=------------------------------------------------------------------------------=
Loading

0 comments on commit da94161

Please sign in to comment.