Skip to content

Commit

Permalink
PpCalculation: reinstate the settings input node (#537)
Browse files Browse the repository at this point in the history
This was removed in the latest overhaul of the `PpCalculation` plugin,
however, it is actually useful to pass specific command line parameters,
such as is possible in the `PwCalculation`, to specify, for example, the
number of kpools. This makes the post processing of big charge densities
a lot more efficient on high-performance clusters with large nodes.

Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
  • Loading branch information
yakutovicha and sphuber authored Jul 14, 2020
1 parent 0031475 commit 260ada4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions aiida_quantumespresso/calculations/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def define(cls, spec):
help='Output folder of a completed `PwCalculation`')
spec.input('parameters', valid_type=orm.Dict, required=True, validator=validate_parameters,
help='Use a node that specifies the input parameters for the namelists')
spec.input('settings', valid_type=orm.Dict, required=False,
help='Optional parameters to affect the way the calculation job is performed.')
spec.input('metadata.options.input_filename', valid_type=str, default=cls._DEFAULT_INPUT_FILE)
spec.input('metadata.options.output_filename', valid_type=str, default=cls._DEFAULT_OUTPUT_FILE)
spec.input('metadata.options.parser_name', valid_type=str, default='quantumespresso.pp')
Expand Down Expand Up @@ -130,6 +132,12 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-branches,t
parameters = _uppercase_dict(self.inputs.parameters.get_dict(), dict_name='parameters')
parameters = {k: _lowercase_dict(v, dict_name=k) for k, v in parameters.items()}

# Same for settings.
if 'settings' in self.inputs:
settings = _uppercase_dict(self.inputs.settings.get_dict(), dict_name='settings')
else:
settings = {}

# Set default values. NOTE: this is different from PW/CP
for blocked in self._blocked_keywords:
namelist = blocked[0].upper()
Expand Down Expand Up @@ -204,6 +212,7 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-branches,t
))

codeinfo = datastructures.CodeInfo()
codeinfo.cmdline_params = settings.pop('CMDLINE', [])
codeinfo.stdin_name = self.inputs.metadata.options.input_filename
codeinfo.stdout_name = self.inputs.metadata.options.output_filename
codeinfo.code_uuid = self.inputs.code.uuid
Expand Down
12 changes: 11 additions & 1 deletion tests/calculations/test_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def generate_inputs(fixture_localhost, fixture_sandbox, fixture_code, generate_remote_data):
"""Return only those inputs that the parser will expect to be there."""

def _generate_inputs(parameters=None):
def _generate_inputs(parameters=None, settings=None):
from aiida_quantumespresso.utils.resources import get_default_options

if parameters is None:
Expand All @@ -24,6 +24,8 @@ def _generate_inputs(parameters=None):
generate_remote_data(fixture_localhost, fixture_sandbox.abspath, 'quantumespresso.pw'),
'parameters':
orm.Dict(dict=parameters),
'settings':
orm.Dict(dict=settings),
'metadata': {
'options': get_default_options()
}
Expand Down Expand Up @@ -79,6 +81,14 @@ def test_pp_keep_plot_file(aiida_profile, fixture_sandbox, generate_calc_job, ge
assert element in calc_info.retrieve_list


def test_pp_cmdline_setting(aiida_profile, fixture_sandbox, generate_calc_job, generate_inputs):
"""Test a `PpCalculation` with user-defined cmdline settings."""
entry_point_name = 'quantumespresso.pp'
inputs = generate_inputs(settings={'cmdline': ['-npools', '2']})
calc_info = generate_calc_job(fixture_sandbox, entry_point_name, inputs)
assert calc_info.codes_info[0].cmdline_params == ['-npools', '2']


@pytest.mark.parametrize(
('parameters', 'message'),
(
Expand Down

0 comments on commit 260ada4

Please sign in to comment.