Main Calculation Restart¶
The crystal17.main.base
workflow builds on the crystal.main
calculation, by automating restarts of the calculation for known failure modes:
No SCF convergence within maximum cycles: the FMIXING value is lowered, and the calculation is restarted from the last known geometry and wave-function (using GUESSP)
No geometric convergence within maximum iterations: the calculation is restarted from the last known geometry and wave-function (using GUESSP)
Reaches scheduler wall-time: the calculation is restarted from the last known geometry.
Additionally, new SHRINK terms can be computed, to adhere to a minimum desired k-point spacing, given the input structure.
!verdi status
✓ profile: On profile test_profile
✓ repository: /var/folders/dm/b2qnkb_n3r72slmpxlfmcjvm00lbnd/T/tmpe58nwedg/test_repo
✓ postgres: Connected as aiida@localhost:64032
✓ rabbitmq: Connected to amqp://127.0.0.1?heartbeat=600
✓ daemon: Daemon is running as PID 52302 since 2019-08-12 12:10:21
!verdi plugin list aiida.workflows crystal17.main.base
-/|\-/|\-/Inputs
cry: required
basis_family: optional Str An alternative to specifying the basis sets manually: one can specify the n ...
clean_workdir: optional Bool If `True`, work directories of all called calculation will be cleaned at th ...
kpoints_distance: optional Float The minimum desired distance in 1/Å between k-points in reciprocal space. T ...
kpoints_force_parity: optional Bool Optional input when constructing the k-points based on a desired `kpoints_d ...
max_iterations: optional Int Maximum number of iterations the work chain will restart the calculation to ...
metadata: optional
Outputs
remote_folder: required RemoteData Input files necessary to run the process will be stored in this folder node ...
results: required Dict the data extracted from the main output file
structure: optional StructureData the structure output from the calculation
symmetry: optional SymmetryData the symmetry data from the calculation
Exit codes
1: The process has failed with an unspecified error.
2: The process failed with legacy failure mode.
10: The process returned an invalid output.
11: The process did not register a required output.
101: The maximum number of iterations was exceeded.
102: The calculation failed for an unknown reason, twice in a row.
201: The parameters could not be validated against the jsonschema.
202: The explicit `basis_sets` or `basis_family` could not be used to get the necessary basis sets.
204: The `metadata.options` did not specify both `resources.num_machines` and `max_wallclock_seconds`.
300: The calculation failed with an unrecoverable error.
320: The initialization calculation failed.
import os
from aiida.engine import run_get_node
from aiida.plugins import (
DataFactory, WorkflowFactory, CalculationFactory)
from aiida.tools.visualization import Graph
from aiida_crystal17.tests import resource_context, get_test_structure_and_symm
from aiida_crystal17.tests.utils import get_default_metadata
from aiida_crystal17.tests.utils import get_or_create_local_computer, get_or_create_code
from aiida import load_profile
profile = load_profile()
profile.name
'test_profile'
DataFactory('crystal17.basisset')
aiida_crystal17.data.basis_set.BasisSetData
computer = get_or_create_local_computer('work_directory', 'localhost')
code = get_or_create_code('crystal17.main', computer, 'mock_crystal17')
params = {
"title": "NiO Bulk with AFM spin",
"scf.single": "UHF",
"scf.k_points": (8, 8),
"scf.spinlock.SPINLOCK": (0, 15),
"scf.numerical.FMIXING": 50,
"scf.numerical.MAXCYCLE": 10,
"scf.post_scf": ["PPAN"]
}
instruct, symmetry = get_test_structure_and_symm("NiO_afm")
kind_data = DataFactory('crystal17.kinds')(data={
"kind_names": ["Ni1", "Ni2", "O"],
"spin_alpha": [True, False, False], "spin_beta": [False, True, False]})
with resource_context('basis_sets', 'sto3g') as path:
DataFactory('crystal17.basisset').upload_basisset_family(
path,
"sto3g",
"minimal basis sets",
stop_if_existing=False,
extension=".basis")
# set up calculation
process_class = code.get_builder().process_class
calc_builder = process_class.create_builder(
params, instruct, "sto3g",
symmetry=symmetry,
kinds=kind_data,
code=code,
metadata=get_default_metadata(),
unflatten=True)
wc_builder = WorkflowFactory('crystal17.main.base').get_builder()
wc_builder.cry = dict(calc_builder)
wc_builder.clean_workdir = True
outputs, wc_node = run_get_node(wc_builder)
print(wc_node.is_finished_ok)
print(wc_node.process_state)
print(wc_node.exit_status)
True
ProcessState.FINISHED
0
!verdi process status {wc_node.pk}
-/|\-/|\CryMainBaseWorkChain<16> Finished [5:results]
├── CryMainCalculation<18> Finished [411]
└── CryMainCalculation<23> Finished [0]
!verdi process report {wc_node.pk}
-/|\-/|\-/2019-08-12 11:10:35 [1 | REPORT]: [16|CryMainBaseWorkChain|run_calculation]: launching CryMainCalculation<18> iteration #1
2019-08-12 11:10:49 [4 | REPORT]: [16|CryMainBaseWorkChain|report_error_handled]: CryMainCalculation<18> failed with exit status 411: SCF convergence did not finalise (usually due to reaching step limit)
2019-08-12 11:10:49 [5 | REPORT]: [16|CryMainBaseWorkChain|report_error_handled]: Action taken: reduced fmixing from 50 to 40 and restarting from last calculation
2019-08-12 11:10:49 [6 | REPORT]: [16|CryMainBaseWorkChain|run_calculation]: launching CryMainCalculation<23> iteration #2
2019-08-12 11:10:59 [7 | REPORT]: [16|CryMainBaseWorkChain|inspect_calculation]: CryMainCalculation<23> completed successfully
2019-08-12 11:10:59 [8 | REPORT]: [16|CryMainBaseWorkChain|results]: work chain completed after 2 iterations
2019-08-12 11:10:59 [9 | REPORT]: [16|CryMainBaseWorkChain|on_terminated]: cleaned remote folders of calculations: 23 18
graph = Graph(graph_attr={'size': "8,8!", "rankdir": "LR"})
graph.recurse_descendants(
wc_node, annotate_links="both",
include_process_inputs=True
)
graph.graphviz