Skip to content

Let an EON campaign set the bond distances of its labels, basins and guide - #90

Open
Austin243 wants to merge 1 commit into
mainfrom
fix/eon-detector-settings
Open

Austin243 wants to merge 1 commit into
mainfrom
fix/eon-detector-settings

Conversation

@Austin243

Copy link
Copy Markdown
Owner

Summary

EON mode always used the default bond distances, 1.15 and 1.30 times the sum of the covalent radii, and an EON campaign had no place for others: a detector key was refused as unknown. On a metal surface those distances make metal-metal and metal-adsorbate contacts bonds. An adsorbate that moves to the next site is then labelled as a reaction, leaves its chemical basin, and is offered to a guide as a bond to break.

An EON campaign now takes an optional detector block at its top level, beside akmc and eon, with the settings of reaction_run.detector in an MD campaign:

"detector": {"pair_thresholds": {"Pt-Pt": [0.1, 0.2], "C-Pt": [0.1, 0.2]}}

A campaign without the block gives the labels, basins and records it gave before. Adds a net 37 lines in src (+59/−22); about 20 of the added lines are signatures and calls that ruff rewraps once they gain an argument.

Before Now
detector in an EON campaign: unknown EON campaign keys: ['detector'] Read, checked by validate, and used
CO moved from on-top to bridge on Pt(111): formed C-Pt, a chemical step With the block above: no bond change, the same basin
H2 over a Cu atom, test fixture: the move between its two sites is broken Cu-H x2 and the one chemical step the run takes With Cu-H left out: a change of conformer, and the step that counts breaks H-H, as without the Cu atom
A search EON rejects as not connected was joined, or left rejected, by its metal contacts Joined by the bonds the block leaves
A guide offered Pt-Pt and C-Pt contacts to break, and never pushed together two atoms that touch the same metal atom Follows the block
A malformed block could not be written at all Refused by validate before any model loads, as in an MD campaign

EON mode classifies bonds in two functions, and both now take the campaign's settings:

Function Used for Now
labels.bond_changes the label of each process campaign's settings
the labels of both minima of a rejected search campaign's settings
joining a rejected search by its bonds campaign's settings
eon.guided_push the bonded pairs and shared neighbors a guide goes by campaign's settings

Reverse labels, basins, the thermal window and status read the saved labels and classify nothing. records.py and akmc.py hold no bond code, and status.py is MD only.

What to look at when merging

  • EON campaigns in progress refuse to resume, as after every change to the search code: eon.py, runner.py and labels.py are hashed into a campaign's contract. run exits 1 with exploration structure, settings, model, or code changed and writes nothing but last-error.json; status still reads the campaign. Finish one first, or keep it on its old install.
  • A campaign without the block is otherwise bound as before. Its contract differs from the one main writes only in those three hashes. The detector entry goes into the contract only when the settings differ from the defaults. The alternative is to always write it, as akmc and eon write their defaults: that would also bind the default distances, and it would change every contract.
  • The settings cannot change during an exploration. With a block, the contract holds all four settings, and a changed, added or removed block is refused on resume. status shows the labels saved with each record.
  • Where the block goes. At the top level, not as reaction_run.detector: an EON campaign has no reaction_run, and everything else in that block is MD only. Not under eon: those are EON's own search settings, and the bond distances also decide the runner's labels and basins. reaction_run in an EON campaign is still an unknown key.
  • persistence_frames is accepted and does nothing in EON mode, so that an MD block can be copied as it is. The settings table says so. Refusing it instead would take a few lines.
  • No new default, threshold, stopping condition or acceptance rule, and nothing in MD mode changes.
  • Python: bond_changes and guided_push take the detector settings as a required argument, so a call cannot fall back to the defaults by leaving it out. EONBackend and run_exploration take them as an optional one, so docs/figures/make_data.py runs as it is.

Left out on purpose

  • Relabelling an existing exploration under new settings. Records are immutable; a new output directory starts over.
  • A question about the block in reactionflow init, which leaves detection at its defaults for MD as well.
  • The settings in the output of validate or status, which would change that output for every campaign.
  • detection.py, where classify_bonds lives, in the hashed search code. It is not bound today.
  • A pair_thresholds that is not an object raises a raw AttributeError in both modes. An infinite break_scale passes validate in an MD campaign; an EON campaign refuses any non-finite number. The MD side is as on main.

Testing

The ways this could fail were written down first, then the tests, then the code:

  1. A place that classifies bonds still uses the defaults: process labels, the labels of a rejected search's minima, the join by bonds, the guide.
  2. run reads the block and does not hand it on, to the runner or to the backend.
  3. A campaign without the block changes: labels, basins, records, guide picks, command output, contract.
  4. A malformed block passes validate, or the two modes disagree on one.
  5. The block changes under an exploration in progress and the run goes on with mixed labels, or an unchanged block cannot resume.
  6. Callers outside the CLI break on a new argument.
  • New tests in tests/: a guide on CO bridging two Cu atoms; H2 over a Cu atom through the runner, for labels, basins, the join and the rejected minima, where leaving the contacts out gives every record of the molecule alone; the contract; run through the CLI, checking both what the backend is given and the saved labels; and validate on seven malformed blocks in both modes.
  • Each hand-off broken on purpose: 11 one-line breaks, each in a scratch copy of src. Ten fail a test of the regular suite. The eleventh, the backend not handing its settings to the guide, fails only the new real-EON case.
  • Comparison with main (34d9ed4) for campaigns without the block, using the stand-in backends of the test suite: 30 explorations through reactionflow run and run_exploration, with and without basins, with joined and rejected searches, for molecules alone and over Cu and Pt atoms, and 2,100 guided pushes. Of 483 files, the 373 records, the 30 search-state.json and the output of every command are byte-identical. The only lines that differ are the runner.py and labels.py hashes in the 30 contracts. EONBackend.contract differs only in the eon.py hash. validate and status on examples/eon/campaign.json are identical.
  • Every classification counted: in a run through the CLI, 14 of 14 bond classifications were given the defaults without the block, and 18 of 18 the block's settings with it. status and validate made none.
  • A campaign in progress: one interrupted on main in its fourth search was refused on this branch, then resumed on main to the records of an uninterrupted run.
  • Pt(111): 27 Pt atoms and CO from ASE's builders, labels and guide only, no model. By the defaults there are 135 Pt-Pt bonds and on-top to bridge is formed C-Pt. With the block above, C-O is the only bond, the same move is no bond change, and a guide has no Pt-Pt or C-Pt contact to break.
  • ruff check ., ruff format --check . and pytest pass: 361 passed, 26 skipped, against 356 and 25 on main. Python 3.12.3, macOS arm64.

Not run:

  • Real EON. pyeonclient 0.4.2 has wheels for Linux x86_64 only, so tests/test_eon_integration.py, with its one new case, and tests/test_eon_example.py were skipped here and run in eon.yml. The new case, and the two beside it, were run here against a stand-in for pyeonclient that can only build parameters; all three end as no_push before EON is asked for anything else. Every comparison above used stand-in backends.
  • Python 3.14, python -m build, a real model, a GPU and a cluster.

…guide

An EON campaign takes an optional top-level `detector` block with the settings of
`reaction_run.detector` in an MD campaign. Every place EON mode classifies bonds now uses it: the
labels of processes and of rejected searches, the join of a rejected search by its bonds, and the
bonds a guide goes by. Basins, the thermal window and `status` read those labels. Until now all of
these used the default distances and the campaign file had no place for others, so metal contacts
counted as bonds.

`validate` refuses a malformed block as it does in an MD campaign. The settings are part of the
resume contract when they differ from the defaults.

A campaign without the block gives the same labels, basins and records, and the same contract
apart from the hashes of `eon.py`, `runner.py` and `labels.py`. Those hashes stop an EON campaign
already in progress from resuming on this code.
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.

1 participant