Example #1
0
    def define(cls, spec: CalcJobProcessSpec):
        super(CryDossCalculation, cls).define(spec)

        spec.input("metadata.options.output_isovalue_fname",
                   valid_type=str,
                   default="fort.25")

        spec.input("metadata.options.parser_name",
                   valid_type=str,
                   default="crystal17.doss")

        spec.exit_code(
            352,
            "ERROR_ISOVALUE_FILE_MISSING",
            message="parser could not find the output isovalue (fort.25) file",
        )
        spec.exit_code(
            353,
            "ERROR_PARSING_ISOVALUE_FILE",
            message="error parsing output isovalue (fort.25) file",
        )

        spec.output(
            "arrays",
            valid_type=DataFactory("array"),
            required=False,
            help="energies and DoS arrays",
        )
Example #2
0
    def define(cls, spec: CalcJobProcessSpec):
        super(CryPpanCalculation, cls).define(spec)

        spec.input("metadata.options.output_ppan_fname",
                   valid_type=str,
                   default="PPAN.DAT")

        spec.input("metadata.options.parser_name",
                   valid_type=str,
                   default="crystal17.ppan")

        # TODO make dict optional

        spec.exit_code(
            352,
            "ERROR_PPAN_FILE_MISSING",
            message="parser could not find the output PPAN.dat file",
        )
        spec.exit_code(353,
                       "ERROR_PARSING_PPAN_FILE",
                       message="error parsing output PPAN.dat file")
Example #3
0
    def define(cls, spec: CalcJobProcessSpec):
        """Define the process specification, including its inputs, outputs and known exit codes.

        :param spec: the calculation job process spec to define.
        """
        super().define(spec)
        spec.input('x', valid_type=(orm.Int, orm.Float), help='The left operand.')
        spec.input('y', valid_type=(orm.Int, orm.Float), help='The right operand.')
        spec.output('sum', valid_type=(orm.Int, orm.Float), help='The sum of the left and right operand.')
        # set default options (optional)
        spec.inputs['metadata']['options']['parser_name'].default = 'arithmetic.add'
        spec.inputs['metadata']['options']['input_filename'].default = 'aiida.in'
        spec.inputs['metadata']['options']['output_filename'].default = 'aiida.out'
        spec.inputs['metadata']['options']['resources'].default = {'num_machines': 1, 'num_mpiprocs_per_machine': 1}
        # start exit codes - marker for docs
        spec.exit_code(300, 'ERROR_NO_RETRIEVED_FOLDER', message='The retrieved output node does not exist.')
        spec.exit_code(310, 'ERROR_READING_OUTPUT_FILE', message='The output file could not be read.')
        spec.exit_code(320, 'ERROR_INVALID_OUTPUT', message='The output file contains invalid output.')
        spec.exit_code(410, 'ERROR_NEGATIVE_NUMBER', message='The sum of the operands is a negative number.')
Example #4
0
    def define(cls, spec: CalcJobProcessSpec):

        super(CryPropertiesWorkChain, cls).define(spec)

        # Input requires either a pre-computed wavefunction (fort.9) file,
        # or inputs for a Crystal Calculation
        spec.input(
            "wf_folder",
            valid_type=(orm.FolderData, orm.RemoteData, orm.SinglefileData),
            required=False,
            help="the folder containing the wavefunction fort.9 file",
        )
        # expose_optional_inputs(spec, cls._scf_namespace, CryMainCalculation)
        spec.expose_inputs(
            cls._scf_class,
            namespace=cls._scf_name,
            namespace_options={"required": False, "populate_defaults": False},
        )
        spec.expose_outputs(
            cls._scf_class,
            namespace=cls._scf_name,
            namespace_options={"required": False},
        )

        # available property computations
        for pname, process_class in cls._cry_props.items():
            spec.expose_inputs(
                process_class,
                namespace=pname,
                exclude=["wf_folder"],
                namespace_options={"required": False, "populate_defaults": False},
            )
            spec.expose_outputs(
                process_class, namespace=pname, namespace_options={"required": False}
            )

        # additional input parameters
        spec.input(
            "check_remote",
            valid_type=orm.Bool,
            serializer=to_aiida_type,
            required=False,
            help=(
                "If a RemoteData wf_folder is input, check it contains the wavefunction file, "
                "before launching calculations. "
                "Note, this will fail if the remote computer is not immediately available"
            ),
        )
        spec.input(
            "clean_workdir",
            valid_type=orm.Bool,
            serializer=to_aiida_type,
            required=False,
            help="If `True`, work directories of all called calculation will be cleaned at the end of execution.",
        )
        spec.input(
            "test_run",
            valid_type=orm.Bool,
            required=False,
            serializer=to_aiida_type,
            help="break off the workchain before submitting a calculation",
        )

        spec.outline(
            cls.check_inputs,
            if_(cls.check_wf_folder)(
                cls.submit_scf_calculation, cls.check_scf_calculation
            ),
            cls.submit_prop_calculations,
            cls.check_prop_calculations,
        )

        spec.exit_code(
            200,
            "END_OF_TEST_RUN",
            message=("Workchain ended before submitting calculation."),
        )
        spec.exit_code(
            201,
            "ERROR_NO_WF_INPUT",
            message=("Neither a wf_folder nor scf calculation was supplied."),
        )
        spec.exit_code(
            202,
            "ERROR_NO_PROP_INPUT",
            message=("No property calculation inputs were supplied."),
        )
        spec.exit_code(
            203,
            "ERROR_WF_FOLDER",
            message=("The supplied folder does contain the wavefunction file."),
        )

        spec.exit_code(
            210,
            "ERROR_SCF_SUBMISSION_FAILED",
            message=("The SCF calculation submission failed."),
        )

        spec.exit_code(
            301, "ERROR_SCF_CALC_FAILED", message=("The SCF calculation failed.")
        )
        spec.exit_code(
            302,
            "ERROR_PROP_CALC_FAILED",
            message=("One or more property calculations failed."),
        )
    def define(cls, spec: CalcJobProcessSpec):
        super(Symmetrise3DStructure, cls).define(spec)
        spec.input("structure", valid_type=StructureData, required=False)
        spec.input("cif", valid_type=DataFactory("cif"), required=False)
        spec.input(
            "settings",
            valid_type=DataFactory("dict"),
            serializer=to_aiida_type,
            required=True,
            validator=cls.validate_settings,
        )

        spec.outline(cls.validate_inputs, cls.compute)

        spec.output("symmetry", valid_type=SymmetryData, required=True)
        spec.output("structure", valid_type=StructureData, required=False)

        spec.exit_code(
            300,
            "ERROR_INVALID_INPUT_RESOURCES",
            message="one of either a structure or cif input must be supplied",
        )
        spec.exit_code(
            301,
            "ERROR_NON_3D_STRUCTURE",
            message='the supplied structure must be 3D (i.e. have all dimensions pbc=True)"',
        )
        spec.exit_code(
            302,
            "ERROR_COMPUTE_OPTIONS",
            message="idealize can only be used when standardize=True",
        )
        spec.exit_code(
            303,
            "ERROR_RESET_KIND_NAMES",
            message="the kind names supplied are not compatible with the structure",
        )
        spec.exit_code(
            304, "ERROR_NEW_STRUCTURE", message="error creating new structure"
        )
        spec.exit_code(
            305,
            "ERROR_COMPUTING_SYMMETRY",
            message="error computing symmetry operations",
        )
    def define(cls, spec: CalcJobProcessSpec):

        super(PropAbstractCalculation, cls).define(spec)

        spec.input("metadata.options.input_file_name",
                   valid_type=str,
                   default="INPUT")
        spec.input("metadata.options.input_wf_name",
                   valid_type=str,
                   default="fort.9")
        spec.input("metadata.options.stdout_file_name",
                   valid_type=str,
                   default="main.out")

        spec.input(
            "wf_folder",
            valid_type=(FolderData, RemoteData, SinglefileData),
            required=True,
            help="the folder containing the wavefunction fort.9 file",
        )
        spec.input(
            "parameters",
            valid_type=DataFactory("dict"),
            required=True,
            validator=cls.validate_parameters,
            help="the input parameters to create the properties input file.",
        )

        # subclasses should implement
        # spec.input('metadata.options.parser_name', valid_type=str, default='crystal17.')

        # Unrecoverable errors: resources like the retrieved folder or its expected contents are missing
        spec.exit_code(
            200,
            "ERROR_NO_RETRIEVED_FOLDER",
            message="The retrieved folder data node could not be accessed.",
        )
        spec.exit_code(
            210,
            "ERROR_OUTPUT_FILE_MISSING",
            message="the main (stdout) output file was not found",
        )
        spec.exit_code(
            211,
            "ERROR_TEMP_FOLDER_MISSING",
            message="the temporary retrieved folder was not found",
        )

        # Unrecoverable errors: required retrieved files could not be read, parsed or are otherwise incomplete
        spec.exit_code(
            300,
            "ERROR_PARSING_STDOUT",
            message=("An error was flagged trying to parse the "
                     "crystal exec stdout file"),
        )

        spec.exit_code(
            350,
            "ERROR_CRYSTAL_INPUT",
            message="the input file could not be read by CRYSTAL",
        )
        spec.exit_code(
            351,
            "ERROR_WAVEFUNCTION_NOT_FOUND",
            message="CRYSTAL could not find the required wavefunction file",
        )
        spec.exit_code(
            352,
            "UNIT_CELL_NOT_NEUTRAL",
            message="Possibly due to erroneous CHEMOD basis set modification",
        )
        spec.exit_code(
            353,
            "SHELL_SYMMETRY_ERROR",
            message="Possibly due to erroneous CHEMOD basis set modification",
        )
        spec.exit_code(354,
                       "CHEMMOD_ERROR",
                       message="Error in CHEMOD basis set modification")

        # Significant errors but calculation can be used to restart
        spec.exit_code(
            400,
            "ERROR_OUT_OF_WALLTIME",
            message=
            "The calculation stopped prematurely because it ran out of walltime.",
        )
        spec.exit_code(
            401,
            "ERROR_OUT_OF_MEMORY",
            message=
            "The calculation stopped prematurely because it ran out of memory.",
        )
        spec.exit_code(
            402,
            "ERROR_OUT_OF_VMEMORY",
            message=
            "The calculation stopped prematurely because it ran out of virtual memory.",
        )

        spec.exit_code(
            413,
            "BASIS_SET_LINEARLY_DEPENDENT",
            message="an error encountered usually during geometry optimisation",
        )
        spec.exit_code(
            414,
            "ERROR_SCF_ABNORMAL_END",
            message="an error was encountered during an SCF computation",
        )
        spec.exit_code(
            415,
            "ERROR_MPI_ABORT",
            message=
            "an unknown error was encountered, causing the MPI to abort",
        )
        spec.exit_code(
            499,
            "ERROR_CRYSTAL_RUN",
            message="The main crystal output file flagged an unhandled error",
        )

        spec.output(
            cls.link_output_results,
            valid_type=DataFactory("dict"),
            required=True,
            help="Summary Data extracted from the output file(s)",
        )
        spec.default_output_node = cls.link_output_results
Example #7
0
    def define(cls, spec: CalcJobProcessSpec):
        """Define the process specification, including its inputs, outputs and known exit codes.

        :param spec: the calculation job process spec to define.
        """
        super().define(spec)
        spec.input(
            "time",
            serializer=to_aiida_type,
            valid_type=(orm.Int, orm.Float),
            default=lambda: orm.Int(1),
            validator=_time_validator,
            help="The time to sleep.",
        )
        spec.input(
            "payload",
            serializer=to_aiida_type,
            valid_type=orm.Dict,
            default=lambda: orm.Dict(dict={}),
            help="A dictionary that will be uploaded and retrieved.",
        )
        spec.output(
            "result",
            valid_type=orm.Bool,
            help='If the output file contains "success".',
        )
        spec.output(
            "out_dict",
            valid_type=orm.Dict,
            help="Output Dict (with size metadata.options.output_dict_size).",
        )
        spec.output(
            "out_array",
            valid_type=orm.ArrayData,
            help=
            "Output ArrayData (with size metadata.options.output_array_size).",
        )
        # set default options (optional)
        spec.inputs["metadata"]["options"]["parser_name"].default = "sleep"
        spec.inputs["metadata"]["options"][
            "input_filename"].default = "aiida.in"
        spec.inputs["metadata"]["options"][
            "output_filename"].default = "aiida.out"
        spec.inputs["metadata"]["options"]["resources"].default = {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        }
        spec.input(
            "metadata.options.payload_filename",
            valid_type=str,
            default="payload.json",
            help=
            "Filename to which the content of the payload JSON is written.",
        )
        spec.input(
            "metadata.options.fail_calcjob",
            valid_type=bool,
            default=False,
            help="Intentionally fail the calculation (with code 410).",
        )
        spec.input(
            "metadata.options.output_dict_size",
            valid_type=int,
            default=100,
            help="The number of attributes for the output Dict.",
        )
        spec.input(
            "metadata.options.output_array_size",
            valid_type=int,
            default=100,
            help="The size of the numpy array for the output ArrayData.",
        )

        spec.exit_code(
            310,
            "ERROR_READING_OUTPUT_FILE",
            message="The output file could not be read.",
        )
        spec.exit_code(
            311,
            "ERROR_READING_PAYLOAD_FILE",
            message="The payload file could not be read.",
        )
        spec.exit_code(
            410,
            "ERROR_FAILED_OUTPUT",
            message="The output file contains a failed output.",
        )
Example #8
0
    def define(cls, spec: CalcJobProcessSpec):

        super(CryMainBaseWorkChain, cls).define(spec)
        spec.expose_inputs(CryCalculation, namespace=cls._calc_namespace, exclude=())
        spec.input(
            "{}.metadata.options.resources".format(cls._calc_namespace),
            valid_type=dict,
            required=False,
        )
        spec.input(
            "basis_family",
            valid_type=orm.Str,
            required=False,
            serializer=to_aiida_type,
            help=(
                "An alternative to specifying the basis sets manually: "
                "one can specify the name of an existing basis set family "
                "and the work chain will generate the basis sets automatically "
                "based on the input structure."
            ),
        )
        spec.input(
            "kpoints_distance",
            valid_type=orm.Float,
            required=False,
            serializer=to_aiida_type,
            validator=_validate_kpoint_distance,
            help=(
                "The minimum desired distance in 1/Å between k-points "
                "in reciprocal space. "
                "The explicit k-points will be generated automatically "
                "by the input structure, and "
                "will replace the SHRINK IS value in the input parameters."
                "Note: This methods assumes "
                "the PRIMITIVE unit cell is provided"
            ),
        )
        spec.input(
            "kpoints_force_parity",
            valid_type=orm.Bool,
            required=False,
            serializer=to_aiida_type,
            help=(
                "Optional input when constructing the k-points based "
                "on a desired `kpoints_distance`. "
                "Setting this to `True` will force the k-point mesh "
                "to have an even number of points along each lattice vector "
                "except for any non-periodic directions."
            ),
        )

        # TODO include option for symmetry calculation
        spec.outline(
            cls.setup,
            cls.validate_parameters,
            cls.validate_basis_sets,
            cls.validate_resources,
            while_(cls.should_run_process)(
                cls.prepare_calculation,
                cls.run_process,
                cls.inspect_process,
            ),
            cls.results,
        )

        spec.expose_outputs(CryCalculation, exclude=("retrieved", "optimisation"))

        spec.exit_code(
            201,
            "ERROR_INVALID_INPUT_PARAMETERS",
            message=(
                "The parameters could not be validated " "against the jsonschema."
            ),
        )
        spec.exit_code(
            202,
            "ERROR_INVALID_INPUT_BASIS_SETS",
            message=(
                "The explicit `basis_sets` or `basis_family` "
                "could not be used to get the necessary basis sets."
            ),
        )
        spec.exit_code(
            204,
            "ERROR_INVALID_INPUT_RESOURCES_UNDERSPECIFIED",
            message=(
                "The `metadata.options` did not specify both "
                "`resources.num_machines` and `max_wallclock_seconds`."
            ),
        )
        spec.exit_code(
            300,
            "ERROR_UNRECOVERABLE_FAILURE",
            message="The calculation failed with an unrecoverable error.",
        )
        spec.exit_code(
            320,
            "ERROR_INITIALIZATION_CALCULATION_FAILED",
            message="The initialization calculation failed.",
        )
    def define(cls, spec: CalcJobProcessSpec):

        super(CryAbstractCalculation, cls).define(spec)

        spec.input("metadata.options.input_file_name",
                   valid_type=str,
                   default="INPUT")
        spec.input("metadata.options.output_main_file_name",
                   valid_type=str,
                   default="main.out")

        spec.input("metadata.options.parser_name",
                   valid_type=str,
                   default="crystal17.main")

        # TODO review aiidateam/aiida_core#2997, when closed, for exit code formalization

        # Unrecoverable errors: resources like the retrieved folder or its expected contents are missing
        spec.exit_code(
            200,
            "ERROR_NO_RETRIEVED_FOLDER",
            message="The retrieved folder data node could not be accessed.",
        )
        spec.exit_code(
            210,
            "ERROR_OUTPUT_FILE_MISSING",
            message="the main (stdout) output file was not found",
        )
        spec.exit_code(
            211,
            "ERROR_TEMP_FOLDER_MISSING",
            message="the temporary retrieved folder was not found",
        )

        # Unrecoverable errors: required retrieved files could not be read, parsed or are otherwise incomplete
        spec.exit_code(
            300,
            "ERROR_PARSING_STDOUT",
            message=("An error was flagged trying to parse the "
                     "crystal exec stdout file"),
        )
        spec.exit_code(  # TODO is this an unrecoverable error?
            301,
            "ERROR_PARSING_OPTIMISATION_GEOMTRIES",
            message=(
                "An error occurred parsing the 'opta'/'optc' geometry files"),
        )
        spec.exit_code(
            302,
            "TESTGEOM_DIRECTIVE",
            message=
            ("The crystal exec stdout file denoted that the run was a testgeom"
             ),
        )

        spec.exit_code(
            350,
            "ERROR_CRYSTAL_INPUT",
            message="the input file could not be read by CRYSTAL",
        )
        spec.exit_code(
            351,
            "ERROR_WAVEFUNCTION_NOT_FOUND",
            message="CRYSTAL could not find the required wavefunction file",
        )
        spec.exit_code(
            352,
            "UNIT_CELL_NOT_NEUTRAL",
            message="Possibly due to erroneous CHEMOD basis set modification",
        )
        spec.exit_code(
            353,
            "SHELL_SYMMETRY_ERROR",
            message="Possibly due to erroneous CHEMOD basis set modification",
        )
        spec.exit_code(354,
                       "CHEMMOD_ERROR",
                       message="Error in CHEMOD basis set modification")

        # Significant errors but calculation can be used to restart
        spec.exit_code(
            400,
            "ERROR_OUT_OF_WALLTIME",
            message=
            "The calculation stopped prematurely because it ran out of walltime.",
        )
        spec.exit_code(
            401,
            "ERROR_OUT_OF_MEMORY",
            message=
            "The calculation stopped prematurely because it ran out of memory.",
        )
        spec.exit_code(
            402,
            "ERROR_OUT_OF_VMEMORY",
            message=
            "The calculation stopped prematurely because it ran out of virtual memory.",
        )

        spec.exit_code(
            411,
            "UNCONVERGED_SCF",
            message=
            "SCF convergence did not finalise (usually due to reaching step limit)",
        )
        spec.exit_code(
            412,
            "UNCONVERGED_GEOMETRY",
            message=
            "Geometry convergence did not finalise (usually due to reaching step limit)",
        )
        spec.exit_code(
            413,
            "BASIS_SET_LINEARLY_DEPENDENT",
            message="an error encountered usually during geometry optimisation",
        )
        spec.exit_code(
            414,
            "ERROR_SCF_ABNORMAL_END",
            message="an error was encountered during an SCF computation",
        )
        spec.exit_code(
            415,
            "ERROR_MPI_ABORT",
            message=
            "an unknown error was encountered, causing the MPI to abort",
        )
        spec.exit_code(
            499,
            "ERROR_CRYSTAL_RUN",
            message="The main crystal output file flagged an unhandled error",
        )

        # errors in symmetry node consistency checks
        spec.exit_code(
            510,
            "ERROR_SYMMETRY_INCONSISTENCY",
            message=("inconsistency in the input and output symmetry"),
        )
        spec.exit_code(
            520,
            "ERROR_SYMMETRY_NOT_FOUND",
            message=("primitive symmops were not found in the output file"),
        )

        spec.output(
            cls.link_output_results,
            valid_type=DataFactory("dict"),
            required=True,
            help="the data extracted from the main output file",
        )
        spec.default_output_node = cls.link_output_results
        spec.output(
            cls.link_output_structure,
            valid_type=DataFactory("structure"),
            required=False,
            help="the structure output from the calculation",
        )
        spec.output(
            cls.link_output_symmetry,
            valid_type=DataFactory("crystal17.symmetry"),
            required=False,
            help="the symmetry data from the calculation",
        )