From 7f3127bf105f7ad6c0629f875f762de6530b8aa6 Mon Sep 17 00:00:00 2001 From: Paul Saxe Date: Tue, 15 Oct 2024 17:40:56 -0400 Subject: [PATCH] Enhancement: improved output and aded to results * Added energy, etc. to results * Added more detail to printed output * Fixed bugs with the GUI and with labeling substeps. --- HISTORY.rst | 4 ++++ structure_step/structure.py | 28 ++++++++++++++++++++------ structure_step/structure_parameters.py | 4 ++-- structure_step/tk_structure.py | 15 ++++++++------ 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b16b552..e7a539e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,10 @@ ======= History ======= +2024.10.15 -- Enhancement: improved output and aded to results + * Added energy, etc. to results + * Added more detail to printed output + * Fixed bugs with the GUI and with labeling substeps. 2024.10.13 -- Added geomeTRIC minimizer * Added transition states as a target diff --git a/structure_step/structure.py b/structure_step/structure.py index 051444b..5f0bb99 100644 --- a/structure_step/structure.py +++ b/structure_step/structure.py @@ -451,11 +451,13 @@ def description_text(self, P=None, short=False, natoms=None): if P is None: P = self.parameters.values_to_dict() + result = self.header + "\n" if P["approach"] == "Optimization": + text = "" if P["optimizer"].lower().endswith("/geometric"): - text = self.describe_geomeTRIC_optimizer(P=P) + result += self.describe_geomeTRIC_optimizer(P=P) else: - text = "The structure will be optimized using the " + text += "The structure will be optimized using the " text += "{optimizer} optimizer, converging to {convergence} " max_steps = P["max steps"] @@ -472,6 +474,8 @@ def description_text(self, P=None, short=False, natoms=None): text += " The workflow will continue if the structure " text += "does not converge." + result += "\n" + str(__(text, **P, indent=7 * " ")) + # Make sure the subflowchart has the data from the parent flowchart self.subflowchart.root_directory = self.flowchart.root_directory self.subflowchart.executor = self.flowchart.executor @@ -480,12 +484,14 @@ def description_text(self, P=None, short=False, natoms=None): if not short: # Get the first real node node = self.subflowchart.get_node("1").next() - text += "\n\nThe energy and forces will be calculated as follows:\n" + result += "\n\n The energy and forces will be calculated as follows:\n" # Now walk through the steps in the subflowchart... while node is not None: try: - text += __(node.description_text(), indent=3 * " ").__str__() + result += str( + __(node.description_text(), indent=7 * " ", wrap=False) + ) except Exception as e: print(f"Error describing structure flowchart: {e} in {node}") self.logger.critical( @@ -502,10 +508,10 @@ def description_text(self, P=None, short=False, natoms=None): f"{sys.exc_info()[0]} in {str(node)}" ) raise - text += "\n" + result += "\n" node = node.next() - return self.header + "\n" + __(text, **P, indent=4 * " ").__str__() + return result def plot(self, E_units="", F_units=""): """Generate a plot of the convergence of the geometry optimization.""" @@ -656,6 +662,15 @@ def run(self): else: raise ValueError(f"Unknown approach '{P['approach']}' in Structure") + # Print the results + self.analyze() + + # Store results to db, variables, tables, and json as requested + self.store_results( + configuration=self._working_configuration, + data=self._results, + ) + return next_node def run_ase_optimizer(self, P, PP): @@ -806,6 +821,7 @@ def set_id(self, node_id=()): def set_subids(self, node_id=()): """Set the ids of the nodes in the subflowchart""" + self.subflowchart.reset_visited() node = self.subflowchart.get_node("1").next() n = 1 while node is not None: diff --git a/structure_step/structure_parameters.py b/structure_step/structure_parameters.py index 03a8a8e..7917a8c 100644 --- a/structure_step/structure_parameters.py +++ b/structure_step/structure_parameters.py @@ -91,8 +91,8 @@ class StructureParameters(seamm.Parameters): "transition state", ), "format_string": "", - "description": "Approach:", - "help_text": "The approach or method for determining the structure.", + "description": "Target:", + "help_text": "The type of structure that is the target.", }, "optimizer": { "default": "geomeTRIC/geomeTRIC", diff --git a/structure_step/tk_structure.py b/structure_step/tk_structure.py index 20265c5..7fc8d27 100644 --- a/structure_step/tk_structure.py +++ b/structure_step/tk_structure.py @@ -163,8 +163,8 @@ def create_dialog(self): # and binding to change as needed for key in ( - "approach", "target", + "approach", "optimizer", "convergence formula", "convergence", @@ -259,11 +259,14 @@ def reset_structure_frame(self, widget=None): optimizer = self["optimizer"].get() convergence = self["convergence"].get() - optimizers = [ - k - for k, v in self.metadata["optimizers"].items() - if target in v["targets"] - ] + if self.is_expr(target): + optimizers = [k for k, v in self.metadata["optimizers"].items()] + else: + optimizers = [ + k + for k, v in self.metadata["optimizers"].items() + if target in v["targets"] + ] self["optimizer"].config(values=optimizers) if optimizer not in optimizers: optimizer = optimizers[0]