Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.