aiida-quantumespresso
aiida-quantumespresso copied to clipboard
Add some self-contained examples of how to create and run a calculation
The previous examples
folder was deleted because the scripts were so out-of-date to be more confusing than useful. See #322 and #131 for more context.
While the CLI launchers can be educational, they are not very self-contained and don't show how to create a calculation. We should add a few, either by resurrecting the examples
folder or by adding them as downloadable files in the documentation.
I also suggest to use in these sample scripts a function that pretty-prints the input nodes, such as this (salvaged from an old protocol file), because it can be very instructive:
def pretty_print_inputs(inputs, level=0):
"""
Print a nested set of inputs in a human-readable way, indenting each nested level
:param inputs: a nested dictionary of inputs nodes
:param level: the nesting level of the current dictionary
"""
def fmt_indent(level):
return ' ' * (4 * level)
for key, value in sorted(inputs.items()):
if isinstance(value, dict):
print('{indent:}{key:}: {{'.format(indent=fmt_indent(level), key=key))
pretty_print_inputs(value, level=level + 1)
print('{indent:}}}'.format(indent=fmt_indent(level)))
elif isinstance(value, ParameterData):
print('{indent:}{key:}'.format(indent=fmt_indent(level), key=key))
for line in json.dumps(value.get_dict(), indent=4).split('\n'):
print('{indent:}{line:}'.format(indent=fmt_indent(level), line=line))
else:
print('{indent:}{key:}: {value:}'.format(indent=fmt_indent(level), key=key, value=value))