Skip to content

Add output files - #38

Merged
jonmarks12 merged 4 commits into
mainfrom
feature/output_files
Apr 30, 2026
Merged

Add output files#38
jonmarks12 merged 4 commits into
mainfrom
feature/output_files

Conversation

@jonmarks12

Copy link
Copy Markdown
Collaborator

Summary

This PR adds QChem inspired output files to the ML-FSM, closing #35. There is still some room for improvement beyond the files that are generated here, and we may want to consider convenience outputs (ex. ts_guess.xyz and/or the final string).

The major changes are an output writer, and changes to the optimizer return signature such that the file can report accurate per-node optimization stats. Other changes are largely adding calls to the output writer.

Changes

1. New module src/mlfsm/output.py

The FSMOutput class owns a single file handle and writes sections incrementally such that the output is useable mid-run, preserving information in partially completed runs.

Setup phase: called once before the growth loop.

  • write_header banner, credit block, timestamp, maybe a fun place to add ascii art of the tiger hawk?
  • write_parameters parameter dump
  • write_system_info formula, atoms, charge, multiple, 1-indexed fixed atoms
  • write_calculator_info uses the get_calculator_info() that pulls various calculator specific parameters. This system could be improved but this is a working first version.
  • write_initial_structures coordinate blocks
  • write_path_init writes a summary of the internal coordinates types when RIC is used

Per-iteration changes

  • _ensure_iteration_header writes header
  • write_current_frontier_node pre-interpolation geometry
  • write_forntier_node interpolated structure selected with actual step size
  • write_optimized_nodew energy + geometry, also should report nfev, nit, and nls where nls = nfev - nit
  • write_iteration_summary a Claude suggestion to write the full energy table with absolute + relative to min columns

Final summary

  • write_final)_summary total iterations, total grad calls, TS guess, full string, citation block

2. Optimizer return signature changes src/mlfsm/opt.py

Changed the return tuple of both CartesianOptimizer.optimize and InternalsOptimizer.optimize.

  • Before: (atoms, energy, njev)
  • New: (Atoms, energy, nfev, nit)
    nfev should be njev for our use case.

Wiring src/mlfsm/cos.py

  • FreezingString.__init__ has an additional output kwarg output: Optional[FSMOutput] = None, later we can shift this to be the default but given that some infastructure may rely on the vfile setup we currently have I think this should be optional for a while
  • Store the initial interpolation object used to compute path length such that it can be exposed as self.init?coordsobj. Non RIC methods get init_coordsobj = None
  • grow() wiring of above per-iteration functions
  • optimize() correctly unpacks the new function and accumulates self.ngrad += nfev

Net

There should be no changes to actual behavioral effects here, if anything the counting of gradient evaluations could be affected.

@jonmarks12
jonmarks12 requested a review from joegomes April 26, 2026 21:08
Comment thread src/mlfsm/output.py

_CITATION = """\
If you use ML-FSM in your research, please cite:
Marks, Jonah, and Joseph Gomes. "Incorporation of Internal Coordinates

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing first author inverted is stylistic choice? I am fine if this was intentional

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the MLA format that I copy and pasted from the google scholar cite button

@joegomes joegomes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this review request! LGTM!

@jonmarks12
jonmarks12 merged commit d93ca32 into main Apr 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants