ezpzbz / aiida-catmat

Collection of AiiDA WorkChains Developed in CATMAT project
MIT License
3 stars 1 forks source link

[Feature] handling convergence issues. #28

Closed ezpzbz closed 4 years ago

ezpzbz commented 4 years ago

Is your feature request related to a problem? Please describe

Currently, we are checking for electronic and ionic convergence within the workchain. For well behaving systems, it is quite ok. However, if we face systems that the convergence becomes an issue and needs altering parameters to improve the convergence, keeping the check is the VaspMultiStageWorkChain is not a good idea and will result complications/interefernce of handlers.

Describe the solution you'd like

The ideal solution is having specific handlers with high priorities placed in VaspBaseWorkChain. These would check for convergence in misc and if calculation is not converged, they would try to identify source of issue. We might have different cases:

It would be something like:

    @process_handler(priority=550, enabled=True)
    def handle_convergence(self, calculation):
        """Handle convergence issue"""
        converged_elec = calculation.outputs.misc['converged_electronically']
        converged_ionic = calculation.outputs.misc['converged_ionically']
        nsw = self.ctx.parameters.get_dict().get('NSW', 0)
        nelm = self.ctx.parameters.get_dict().get('NELM', 60) + 50
        if nsw == 0:
            if not converged_elec:
                self.ctx.modifications.update({'NELM': nelm})
                action = f'NELM increased by 20% to {nelm}'
                self.report_error_handled(calculation, action)
        else:
            if not converged_ionic:
                self.ctx.modifications.update({'NSW': nsw + 50})
                action = f'NSW increased by 20% to {nsw+50}'
                self.report_error_handled(calculation, action)

           return ProcessHandlerReport(False)

Additional context

We may benefit from Peter Larsson's scripts for the identification stages: https://www.nsc.liu.se/~pla/vasptools/

ezpzbz commented 4 years ago

I've tested above approach and also thought about it for sometime. At the end, I think keeping the handling of convergence failure in the workchian is better idea compared to having it in base. My reason is to dedicate handlers in base to errors that can occure during the calculations.