diff --git a/src/aiida_quantumespresso/workflows/protocols/pw/relax.yaml b/src/aiida_quantumespresso/workflows/protocols/pw/relax.yaml index c7a151e5c..5a670967c 100644 --- a/src/aiida_quantumespresso/workflows/protocols/pw/relax.yaml +++ b/src/aiida_quantumespresso/workflows/protocols/pw/relax.yaml @@ -11,8 +11,8 @@ default_inputs: base_final_scf: pw: parameters: - CELL: - press_conv_thr: 0.5 + CONTROL: + calculation: scf default_protocol: moderate protocols: moderate: diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index 93ec1519b..a7da2eb92 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -243,13 +243,6 @@ def setup(self): self.ctx.inputs.settings = self.ctx.inputs.settings.get_dict() if 'settings' in self.ctx.inputs else {} - # If a ``parent_folder`` is specified, automatically set the parameters for a ``RestartType.Full`` unless the - # ``CONTROL.restart_mode`` has explicitly been set to ``from_scratch``. In that case, the user most likely set - # that, and we do not want to override it. - restart_mode = self.ctx.inputs.parameters['CONTROL'].get('restart_mode', None) - if 'parent_folder' in self.ctx.inputs and restart_mode != 'from_scratch': - self.set_restart_type(RestartType.FULL, self.ctx.inputs.parent_folder) - def validate_kpoints(self): """Validate the inputs related to k-points. @@ -275,15 +268,6 @@ def validate_kpoints(self): self.ctx.inputs.kpoints = kpoints - def set_max_seconds(self, max_wallclock_seconds): - """Set the `max_seconds` to a fraction of `max_wallclock_seconds` option to prevent out-of-walltime problems. - - :param max_wallclock_seconds: the maximum wallclock time that will be set in the scheduler settings. - """ - max_seconds_factor = self.defaults.delta_factor_max_seconds - max_seconds = max_wallclock_seconds * max_seconds_factor - self.ctx.inputs.parameters['CONTROL']['max_seconds'] = max_seconds - def set_restart_type(self, restart_type, parent_folder=None): """Set the restart type for the next iteration.""" @@ -319,7 +303,8 @@ def prepare_process(self): max_wallclock_seconds = self.ctx.inputs.metadata.options.get('max_wallclock_seconds', None) if max_wallclock_seconds is not None and 'max_seconds' not in self.ctx.inputs.parameters['CONTROL']: - self.set_max_seconds(max_wallclock_seconds) + max_seconds = max_wallclock_seconds * self.defaults.delta_factor_max_seconds + self.ctx.inputs.parameters['CONTROL']['max_seconds'] = max_seconds def report_error_handled(self, calculation, action): """Report an action taken for a calculation that has failed. diff --git a/src/aiida_quantumespresso/workflows/pw/relax.py b/src/aiida_quantumespresso/workflows/pw/relax.py index ba97daedd..9a344f846 100644 --- a/src/aiida_quantumespresso/workflows/pw/relax.py +++ b/src/aiida_quantumespresso/workflows/pw/relax.py @@ -168,12 +168,11 @@ def setup(self): self.ctx.relax_inputs.pw.parameters = self.ctx.relax_inputs.pw.parameters.get_dict() self.ctx.relax_inputs.pw.parameters.setdefault('CONTROL', {}) - self.ctx.relax_inputs.pw.parameters['CONTROL']['restart_mode'] = 'from_scratch' # Set the meta_convergence and add it to the context self.ctx.meta_convergence = self.inputs.meta_convergence.value volume_cannot_change = ( - self.ctx.relax_inputs.pw.parameters['CONTROL']['calculation'] in ('scf', 'relax') or + self.ctx.relax_inputs.pw.parameters['CONTROL'].get('calculation', 'scf') in ('scf', 'relax') or self.ctx.relax_inputs.pw.parameters.get('CELL', {}).get('cell_dofree', None) == 'shape' ) if self.ctx.meta_convergence and volume_cannot_change: @@ -186,7 +185,7 @@ def setup(self): if 'base_final_scf' in self.inputs: self.ctx.final_scf_inputs = AttributeDict(self.exposed_inputs(PwBaseWorkChain, namespace='base_final_scf')) - if self.ctx.relax_inputs.pw.parameters['CONTROL']['calculation'] == 'scf': + if self.ctx.relax_inputs.pw.parameters['CONTROL'].get('calculation', 'scf') == 'scf': self.report( 'Work chain will not run final SCF when `calculation` is set to `scf` for the relaxation ' '`PwBaseWorkChain`.' @@ -197,9 +196,6 @@ def setup(self): self.ctx.final_scf_inputs.pw.parameters = self.ctx.final_scf_inputs.pw.parameters.get_dict() self.ctx.final_scf_inputs.pw.parameters.setdefault('CONTROL', {}) - self.ctx.final_scf_inputs.pw.parameters['CONTROL']['calculation'] = 'scf' - self.ctx.final_scf_inputs.pw.parameters['CONTROL']['restart_mode'] = 'from_scratch' - self.ctx.final_scf_inputs.pw.parameters.pop('CELL', None) self.ctx.final_scf_inputs.metadata.call_link_label = 'final_scf' def should_run_relax(self): diff --git a/tests/workflows/protocols/pw/test_relax/test_default.yml b/tests/workflows/protocols/pw/test_relax/test_default.yml index 3aef614a4..8182ec2b2 100644 --- a/tests/workflows/protocols/pw/test_relax/test_default.yml +++ b/tests/workflows/protocols/pw/test_relax/test_default.yml @@ -44,8 +44,6 @@ base_final_scf: num_machines: 1 withmpi: true parameters: - CELL: - press_conv_thr: 0.5 CONTROL: calculation: scf etot_conv_thr: 2.0e-05 diff --git a/tests/workflows/pw/test_base.py b/tests/workflows/pw/test_base.py index 0c4d3c97c..ce1b41a8b 100644 --- a/tests/workflows/pw/test_base.py +++ b/tests/workflows/pw/test_base.py @@ -252,15 +252,11 @@ def test_set_max_seconds(generate_workchain_pw): @pytest.mark.parametrize('restart_mode, expected', ( - (None, 'restart'), + ('restart', 'restart'), ('from_scratch', 'from_scratch'), )) -def test_parent_folder(generate_workchain_pw, generate_calc_job_node, restart_mode, expected): - """Test that ``parameters`` gets automatically updated if ``parent_folder`` in the inputs. - - Specifically, the ``parameters`` should define the ``CONTROL.restart_mode`` unless it was explicitly set to - ``from_scratch`` by the caller. - """ +def test_restart_mode(generate_workchain_pw, generate_calc_job_node, restart_mode, expected): + """Test that the ``CONTROL.restart_mode`` specified by the user is always respected.""" node = generate_calc_job_node('pw', test_name='default') inputs = generate_workchain_pw(return_inputs=True)