Skip to content

Only compute what you need#15

Merged
smparker merged 5 commits intomasterfrom
computewhatyouneed
Feb 5, 2026
Merged

Only compute what you need#15
smparker merged 5 commits intomasterfrom
computewhatyouneed

Conversation

@smparker
Copy link
Copy Markdown
Owner

@smparker smparker commented Feb 5, 2026

Adds functionality for the dynamics method to request only the gradients it will use and to recompute others when needed. Also teach TMModel to respect these choices and save on gradient calculations.

smparker and others added 5 commits February 4, 2026 12:56
Dynamics methods can now request only the gradients and couplings they
need via needed_gradients() and needed_couplings(), and models track
availability via compute_additional(). SurfaceHoppingMD requests only
the active state gradient and calls compute_additional after hops.
Ehrenfest and A-FSSH override to request all gradients. DiabaticModel_
and AdiabaticModel_ compute everything analytically but only mark
requested quantities as available. TMModel passes gradient requests
through and provides compute_additional for post-hop availability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
TMModel now skips running rdgrad when the ground state gradient is not
requested, and compute_additional runs rdgrad on demand when a hop to
the ground state occurs. The electronics as_dict now includes
forces_available so consumers can tell which forces were computed.
Tests check only available forces instead of all states.

Also fix HarmonicModel to pass nstates=1 to ElectronicModel_ so that
the _forces_available array is correctly sized.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@smparker smparker merged commit e47ca9d into master Feb 5, 2026
6 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.

1 participant