Skip to content

Commit

Permalink
Enhancement: improved output and aded to results
Browse files Browse the repository at this point in the history
* Added energy, etc. to results
* Added more detail to printed output
* Fixed bugs with the GUI and with labeling substeps.
  • Loading branch information
paulsaxe committed Oct 15, 2024
1 parent 80f6755 commit 7f3127b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 22 additions & 6 deletions structure_step/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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."""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions structure_step/structure_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 9 additions & 6 deletions structure_step/tk_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def create_dialog(self):

# and binding to change as needed
for key in (
"approach",
"target",
"approach",
"optimizer",
"convergence formula",
"convergence",
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7f3127b

Please sign in to comment.