Skip to content

Commit f48e269

Browse files
committed
‼️ Remove pw namespace
1 parent 1b80920 commit f48e269

2 files changed

Lines changed: 47 additions & 49 deletions

File tree

src/aiida_quantumespresso/workflows/protocols/pw/base.yaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@ default_inputs:
77
conv_thr_per_atom: 0.2e-9
88
etot_conv_thr_per_atom: 1.e-5
99
pseudo_family: 'SSSP/1.3/PBEsol/efficiency'
10-
pw:
11-
metadata:
12-
options:
13-
max_wallclock_seconds: 43200 # Twelve hours
14-
withmpi: True
15-
parameters:
16-
CONTROL:
17-
calculation: scf
18-
forc_conv_thr: 1.e-4
19-
tprnfor: True
20-
tstress: True
21-
SYSTEM:
22-
nosym: False
23-
occupations: smearing
24-
smearing: cold
25-
degauss: 0.02
26-
ELECTRONS:
27-
electron_maxstep: 80
28-
mixing_beta: 0.4
10+
options:
11+
max_wallclock_seconds: 43200 # Twelve hours
12+
withmpi: True
13+
parameters:
14+
CONTROL:
15+
calculation: scf
16+
forc_conv_thr: 1.e-4
17+
tprnfor: True
18+
tstress: True
19+
SYSTEM:
20+
nosym: False
21+
occupations: smearing
22+
smearing: cold
23+
degauss: 0.02
24+
ELECTRONS:
25+
electron_maxstep: 80
26+
mixing_beta: 0.4
2927
default_protocol: balanced
3028
protocols:
3129
balanced:

src/aiida_quantumespresso/workflows/pw/base.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ def define(cls, spec):
4949
"""Define the process specification."""
5050

5151
super().define(spec)
52-
spec.expose_inputs(PwCalculation, namespace='pw', exclude=('kpoints',))
53-
spec.input(
54-
'kpoints',
55-
valid_type=orm.KpointsData,
56-
required=False,
57-
help='An explicit k-points list or mesh. Either this or `kpoints_distance` has to be provided.',
52+
53+
spec.expose_inputs(PwCalculation, exclude=('kpoints', 'metadata'))
54+
spec.inputs.create_port_namespace('options').absorb(
55+
PwCalculation.spec().inputs.get_port('metadata.options')
5856
)
59-
spec.input(
60-
'kpoints_distance',
61-
valid_type=orm.Float,
62-
required=False,
57+
spec.input('kpoints', valid_type=orm.KpointsData, required=False,
58+
help='An explicit k-points list or mesh. Either this or `kpoints_distance` has to be provided.')
59+
spec.input('kpoints_distance', valid_type=orm.Float, required=False,
6360
help='The minimum desired distance in 1/Å between k-points in reciprocal space. The explicit k-points will '
6461
'be generated automatically by a calculation function based on the input structure.',
6562
)
@@ -207,15 +204,16 @@ def get_builder_from_protocol(
207204
natoms = len(structure.sites)
208205

209206
# Update the parameters based on the protocol inputs
210-
parameters = inputs['pw']['parameters']
207+
parameters = inputs['parameters']
208+
209+
if overrides and 'pseudos' in overrides:
211210

212-
if overrides and 'pseudos' in overrides.get('pw', {}):
213-
pseudos = overrides['pw']['pseudos']
211+
pseudos = overrides['pseudos']
214212

215213
if sorted(pseudos.keys()) != sorted(structure.get_kind_names()):
216214
raise ValueError(f'`pseudos` override needs one value for each of the {len(structure.kinds)} kinds.')
217215

218-
system_overrides = overrides['pw'].get('parameters', {}).get('SYSTEM', {})
216+
system_overrides = overrides.get('parameters', {}).get('SYSTEM', {})
219217

220218
if not all(key in system_overrides for key in ('ecutwfc', 'ecutrho')):
221219
raise ValueError(
@@ -280,30 +278,29 @@ def get_builder_from_protocol(
280278

281279
# If overrides are provided, they are considered absolute
282280
if overrides:
283-
parameter_overrides = overrides.get('pw', {}).get('parameters', {})
281+
parameter_overrides = overrides.get('parameters', {})
284282
parameters = recursive_merge(parameters, parameter_overrides)
285283

286284
# if tot_magnetization in overrides , remove starting_magnetization from parameters
287285
if parameters.get('SYSTEM', {}).get('tot_magnetization') is not None:
288286
parameters.setdefault('SYSTEM', {}).pop('starting_magnetization', None)
289287

290-
metadata = inputs['pw']['metadata']
288+
inputs_options = inputs['options']
289+
inputs_options = cls.set_default_resources(inputs_options, code.computer.scheduler_type)
291290

292291
if options:
293-
metadata['options'] = recursive_merge(metadata['options'], options)
294-
295-
metadata['options'] = cls.set_default_resources(metadata['options'], code.computer.scheduler_type)
292+
inputs_options = recursive_merge(inputs['options'], options)
296293

297294
builder = cls.get_builder()
298-
builder.pw['code'] = code
299-
builder.pw['pseudos'] = pseudos
300-
builder.pw['structure'] = structure
301-
builder.pw['parameters'] = orm.Dict(parameters)
302-
builder.pw['metadata'] = metadata
303-
if 'settings' in inputs['pw']:
304-
builder.pw['settings'] = orm.Dict(inputs['pw']['settings'])
305-
if 'parallelization' in inputs['pw']:
306-
builder.pw['parallelization'] = orm.Dict(inputs['pw']['parallelization'])
295+
builder['code'] = code
296+
builder['pseudos'] = pseudos
297+
builder['structure'] = structure
298+
builder['parameters'] = orm.Dict(parameters)
299+
builder['options'] = inputs_options
300+
if 'settings' in inputs:
301+
builder['settings'] = orm.Dict(inputs['settings'])
302+
if 'parallelization' in inputs:
303+
builder['parallelization'] = orm.Dict(inputs['parallelization'])
307304
builder.clean_workdir = orm.Bool(inputs['clean_workdir'])
308305
if 'kpoints' in inputs:
309306
builder.kpoints = inputs['kpoints']
@@ -324,7 +321,10 @@ def setup(self):
324321
default namelists for the ``parameters`` are set to empty dictionaries if not specified.
325322
"""
326323
super().setup()
327-
self.ctx.inputs = AttributeDict(self.exposed_inputs(PwCalculation, 'pw'))
324+
self.ctx.inputs = AttributeDict(self.exposed_inputs(PwCalculation))
325+
self.ctx.inputs.metadata = AttributeDict({'options': self.inputs.options})
326+
if 'disable_cache' in self.inputs.metadata:
327+
self.ctx.inputs.metadata.disable_cache = self.inputs.metadata.disable_cache
328328

329329
self.ctx.inputs.parameters = self.ctx.inputs.parameters.get_dict()
330330
self.ctx.inputs.parameters.setdefault('CONTROL', {})
@@ -354,7 +354,7 @@ def validate_kpoints(self):
354354
kpoints = self.inputs.kpoints
355355
except AttributeError:
356356
inputs = {
357-
'structure': self.inputs.pw.structure,
357+
'structure': self.inputs.structure,
358358
'distance': self.inputs.kpoints_distance,
359359
'force_parity': self.inputs.get('kpoints_force_parity', orm.Bool(False)),
360360
'metadata': {'call_link_label': 'create_kpoints_from_distance'},

0 commit comments

Comments
 (0)