Source code for aiida_mlip.calculations.descriptors
"""Class to run descriptors calculations."""fromaiida.commonimportdatastructuresimportaiida.common.foldersfromaiida.engineimportCalcJobProcessSpecimportaiida.engine.processesfromaiida.ormimportBoolfromaiida_mlip.calculations.singlepointimportSinglepoint
[docs]classDescriptors(Singlepoint):# numpydoc ignore=PR01""" Calcjob implementation to calculate MLIP descriptors. Methods ------- define(spec: CalcJobProcessSpec) -> None: Define the process specification, its inputs, outputs and exit codes. prepare_for_submission(folder: Folder) -> CalcInfo: Create the input files for the `CalcJob`. """
[docs]@classmethoddefdefine(cls,spec:CalcJobProcessSpec)->None:""" Define the process specification, its inputs, outputs and exit codes. Parameters ---------- spec : aiida.engine.CalcJobProcessSpec The calculation job process spec to define. """super().define(spec)# Define inputs# Remove unused singlepoint inputdelspec.inputs["properties"]spec.input("invariants_only",valid_type=Bool,required=False,help="Only calculate invariant descriptors.",)spec.input("calc_per_element",valid_type=Bool,required=False,help="Calculate mean descriptors for each element.",)spec.input("calc_per_atom",valid_type=Bool,required=False,help="Calculate descriptors for each atom.",)spec.inputs["metadata"]["options"]["parser_name"].default="mlip.descriptors_parser"
[docs]defprepare_for_submission(self,folder:aiida.common.folders.Folder)->datastructures.CalcInfo:""" Create the input files for the `Calcjob`. Parameters ---------- folder : aiida.common.folders.Folder Folder where the calculation is run. Returns ------- aiida.common.datastructures.CalcInfo An instance of `aiida.common.datastructures.CalcInfo`. """# Call the parent class method to prepare common inputscalcinfo=super().prepare_for_submission(folder)codeinfo=calcinfo.codes_info[0]# Adding command line params for when we run janus# descriptors is overwriting the placeholder "calculation" from the base.py filecodeinfo.cmdline_params[0]="descriptors"cmdline_options={key.replace("_","-"):getattr(self.inputs,key).valueforkeyin("invariants_only","calc_per_element","calc_per_atom")ifkeyinself.inputs}forflag,valueincmdline_options.items():ifisinstance(value,bool):# Add boolean flags without value if Trueifvalue:codeinfo.cmdline_params.append(f"--{flag}")else:codeinfo.cmdline_params+=[f"--{flag}",value]returncalcinfo