Add nsteps for Trotter expansion based on propagator error#1371
Open
arettig wants to merge 4 commits into
Open
Add nsteps for Trotter expansion based on propagator error#1371arettig wants to merge 4 commits into
arettig wants to merge 4 commits into
Conversation
The current implementation computes the number of steps needed in a Trotter expansion to reach an error in the ground state energy. This commit adds functionality to compute the number of steps determined by the error in the propagator itself.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces trotter_steps_required_propagator to calculate the number of Trotter steps required for accurate state evolution, updates trotter_steps_required to handle negative times correctly, and adds corresponding unit tests. The reviewer suggested adding input validation to both functions to prevent division-by-zero errors when precision parameters are non-positive, and ensuring that at least one step is returned for any non-zero simulation time when the error bound is zero.
Added checks to ensure the parameters and therefore output of trotter_steps_required functions are physically meaningful. Added several tests for edge cases of these functions.
mhucka
requested changes
Jun 23, 2026
mhucka
left a comment
Collaborator
There was a problem hiding this comment.
IMHO it would benefit for just a couple of small additions to value testing. Otherwise it looks good!
The parameter trotter_error_bound is checked within the trotter_steps_required function and a ValueError is raised if a negative value is provided.
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.
Fixes #820. Currently we compute the number of steps in a Trotter expansion based on the desired error in the ground state energy. This PR adds a function to compute the number of steps based on the desired error in the propagator$U$ (which is different). This could be useful for certain use cases like dynamics.
New tests are also added to cover this new function.