[docs]classGeomOptParser(SPParser):""" Parser class for parsing output of geometry optimisation calculation. Inherits from SPParser. Parameters ---------- node : aiida.orm.nodes.process.process.ProcessNode ProcessNode of calculation. Methods ------- parse(**kwargs: Any) -> int: Parse outputs, store results in the database. Returns ------- int An exit code. Raises ------ exceptions.ParsingError If the ProcessNode being passed was not produced by a `GeomOpt`. """
[docs]def__init__(self,node:ProcessNode):""" Check that the ProcessNode being passed was produced by a `GeomOpt`. Parameters ---------- node : aiida.orm.nodes.process.process.ProcessNode ProcessNode of calculation. """super().__init__(node)ifnotissubclass(node.process_class,GeomoptCalc):raiseexceptions.ParsingError("Can only parse `GeomOpt` calculations")
[docs]defparse(self,**kwargs)->ExitCode:""" Parse outputs, store results in the database. Parameters ---------- **kwargs : Any Any keyword arguments. Returns ------- int An exit code. """# Call the parent parse method to handle common parsing logicexit_code=super().parse(**kwargs)ifexit_code==ExitCode(0):traj_file=(self.node.inputs.traj).value# Parse the trajectory file and save it as `SingleFileData`withself.retrieved.open(traj_file,"rb")ashandle:self.out("traj_file",SinglefileData(file=handle,filename=traj_file))# Parse trajectory and save it as `TrajectoryData`opt,traj_output=xyz_to_aiida_traj(Path(self.node.get_remote_workdir(),traj_file))self.out("traj_output",traj_output)# Parse the final structure of the trajectory to obtain the opt structureself.out("final_structure",opt)returnexit_code