Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option for initial step size #4101

Merged
merged 5 commits into from
Mar 3, 2025

Conversation

andiwand
Copy link
Contributor

@andiwand andiwand commented Feb 20, 2025

Adds an option to allow the user steering the initial step size attempted by the stepper. Currently this was not set and only constrained by the maximum step size.

This will not make a big difference but is the correct thing to do IMO. Given an adaptive step size the stepper will figure out the appropriate step size after ~one failed attempt.

Summary by CodeRabbit

  • New Features
    • Added an option to specify an initial step size for propagation, offering enhanced control over accuracy.
  • Refactor
    • Revised the step size initialization process across propagation routines to separate default setup from parameter configuration.
  • Tests
    • Updated test configurations to validate the new initial step size behavior and ensure consistency in propagation performance.
  • Chores
    • Updated hash values for specific test files to maintain integrity in testing.

@andiwand andiwand added this to the next milestone Feb 20, 2025
Copy link

coderabbitai bot commented Feb 20, 2025

Walkthrough

Changed, the step size initialization has been. In several stepper classes, a single-step construction of state.stepSize has been replaced by a two-step process: first, constructing with a default constructor, then setting accuracy and the user-defined maximum step size. Added, a new option initialStepSize in the stepper options, also updated in related tests. Internal state, these changes affect, while the public interface remains unaltered.

Changes

File(s) Change Summary
Core/include/.../AtlasStepper.hpp
Core/include/.../EigenStepper.ipp
Core/src/.../StraightLineStepper.cpp
Core/src/.../SympyStepper.cpp
Modified step size initialization: now using a default constructor followed by setting accuracy (initialStepSize) and max step size via setAccuracy and setUser.
Core/include/.../StepperOptions.hpp Added new member initialStepSize with default value 10 * Acts::UnitConstants::m to StepperPlainOptions. Updated maxStepSize to std::numeric_limits<double>::max().
Tests/UnitTests/.../EigenStepperTests.cpp
Tests/UnitTests/.../StraightLineStepperTests.cpp
Tests/UnitTests/.../SympyStepperTests.cpp
Updated test configurations to include initialStepSize (e.g., 10_m) for validating new initialization behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Stepper
    participant ConstrainedStep
    Stepper->>ConstrainedStep: Construct default ConstrainedStep()
    Stepper->>ConstrainedStep: setAccuracy(initialStepSize)
    Stepper->>ConstrainedStep: setUser(maxStepSize)
Loading

Possibly related PRs

  • feat: adding G4 stepping #3812: The changes in the main PR regarding the initialization of state.stepSize in the AtlasStepper, EigenStepper, StraightLineStepper, and SympyStepper classes are directly related to similar modifications made in the initialize method of the EigenStepper in the retrieved PR, which also alters how state.stepSize is configured.
  • refactor: Drop SympyStepper::stepImpl #4103: The changes in the main PR regarding the initialization of state.stepSize in the AtlasStepper, EigenStepper, StraightLineStepper, and SympyStepper classes are directly related to the modifications in the SympyStepper class in the retrieved PR, as both involve alterations to how state.stepSize is configured during initialization.
  • feat: Adaptive step size for the AtlasStepper #4102: The changes in the main PR regarding the initialization of state.stepSize in the AtlasStepper class are related to the modifications in the retrieved PR, which also involves step size handling, although it focuses on adaptive step size adjustments rather than initialization.

Suggested labels

Track Fitting

Suggested reviewers

  • paulgessinger
  • benjaminhuth

Poem

In code’s galaxy, a change we impart,
Two steps now guide the step size, a fine art.
Default creation, then parameters align,
Balance in the code, like the Force divine.
Harmonious it sings, a new era to start.
May the changes be with us, always, in our heart.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5604630 and ff2d659.

📒 Files selected for processing (2)
  • Core/include/Acts/Propagator/AtlasStepper.hpp (1 hunks)
  • Core/src/Propagator/SympyStepper.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Core/include/Acts/Propagator/AtlasStepper.hpp
  • Core/src/Propagator/SympyStepper.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: merge-sentinel

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Component - Core Affects the Core module label Feb 20, 2025
Copy link

github-actions bot commented Feb 20, 2025

📊: Physics performance monitoring for ff2d659

Full contents

physmon summary

@andiwand andiwand marked this pull request as ready for review February 20, 2025 11:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp (1)

118-118: Good start this test is, but more coverage we need, hmmmm.

Set the initial step size to 10 meters, this test does. But test the effects of different initial step sizes, we should.

Consider adding these test cases, you should:

  • Test with very small initial step size
  • Test with initial step size larger than maxStepSize
  • Verify step size adaptation behavior with different initial values
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 299a6e7 and a8e724d.

📒 Files selected for processing (8)
  • Core/include/Acts/Propagator/AtlasStepper.hpp (1 hunks)
  • Core/include/Acts/Propagator/EigenStepper.ipp (1 hunks)
  • Core/include/Acts/Propagator/StepperOptions.hpp (1 hunks)
  • Core/src/Propagator/StraightLineStepper.cpp (1 hunks)
  • Core/src/Propagator/SympyStepper.cpp (1 hunks)
  • Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp (1 hunks)
  • Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp (2 hunks)
  • Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: CI Bridge / lcg_107: [alma9, clang19]
  • GitHub Check: CI Bridge / lcg_107: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_107: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: build_debug
🔇 Additional comments (7)
Core/include/Acts/Propagator/StepperOptions.hpp (1)

38-40: Hmmmm, good this addition is!

Well placed and documented, the new initialStepSize option is. A sensible default value of 1 meter, it has.

Core/src/Propagator/StraightLineStepper.cpp (1)

42-44: Wise changes these are, hmmmm.

A more flexible approach to step size initialization, this is. First construct with default, then set accuracy and user values separately, we do.

Core/src/Propagator/SympyStepper.cpp (1)

49-51: Consistency in the Force, I sense.

Like its siblings, this stepper now follows the same path of initialization. Harmony in the codebase, this brings.

Core/include/Acts/Propagator/EigenStepper.ipp (1)

49-51: Approve the step size initialization changes, I do!

A better way to control step size parameters, this two-step initialization is. Clear separation between initial accuracy and maximum step size, it provides. Consistent with the Force, this change is.

Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp (1)

195-195: Good test coverage, this provides!

Properly test the new initialStepSize feature, this change does. Clear and meaningful test value of 10_m, it uses. Strong with the Force, this test is.

Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp (1)

220-220: Consistency in testing, I sense!

Match the SympyStepper test configuration, this change does. Harmony in the test values, it maintains. Balance to the Force, this brings.

Core/include/Acts/Propagator/AtlasStepper.hpp (1)

163-165: Unified implementation across steppers, this achieves!

Follow the same pattern as other steppers, this change does. Harmony in the codebase, it maintains. Strong and consistent, the Force is.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Core/include/Acts/Propagator/StepperOptions.hpp (1)

43-43:

❓ Verification inconclusive

Careful we must be, when limits to infinity we stretch.

Changed the maxStepSize from 10 meters to infinity's edge, you have. Impact on the Force - performance and stability - carefully measured it must be. Consider adding configuration option for custom maximum, we should.

Consider these aspects you must:

  1. Performance impact when no practical limit exists
  2. Numerical stability with very large steps
  3. Whether configurable maximum better serves the users' needs

🌐 Web query:

What are the typical maximum step sizes used in particle tracking algorithms?

💡 Result:

The maximum step sizes in particle tracking algorithms depend on both spatial resolution and temporal stability constraints, with key factors including:

Spatial Step Size

  • Particle overlap tolerance: Algorithms can resolve overlapped particles up to 50% overlap ratio for larger particles ([1][2]). Smaller particles require stricter overlap limits.
  • Displacement per frame: For velocity gradients up to 0.2 pixels per step ([1]), spatial steps must ensure particles remain trackable between frames.
  • Subpixel precision: Centroid-based methods achieve subpixel accuracy with root mean square error < 0.07 pixels ([1][3]).

Temporal Step Size

  • Explicit methods: Stability limits impose small timesteps for high Stokes number flows (e.g., small particles). For example:
    • Forward Euler requires Δ𝑡 ≲ ( \tau ) (particle response time) ([5]).
    • Runge-Kutta 4 allows slightly larger steps but remains constrained by ( \Delta t \propto \tau ) ([5]).
  • Implicit methods: Backward Euler enables larger timesteps (e.g., ( \Delta t \approx 10\tau )) at the cost of reduced accuracy ([5]).

Practical Guidelines

  • Frame rate vs. exposure time: Exposure time ( \sigma ) should be ≤ 10% of inter-frame time (( \tau_{min} )) to minimize motion blur ([4]).
  • Microscale systems: Achieve displacement uncertainties of 0.62–0.77 µm per step with optimized imaging ([3]).

Algorithm-Specific Tradeoffs

Method Max Step Size Accuracy Use Case
Explicit Euler Small (( \sim\tau )) Low Simple flows
Implicit Euler Large (( >10\tau )) Moderate Stiff systems
Hybrid PIV-PTV Adaptive High High particle density

For microscale flows, systems like color-coded 3D PTV resolve ~400 vectors per frame with submicron precision ([3]). In macroscale applications, hybrid PTV techniques balance spatial resolution and computational cost by leveraging PIV results as initial guesses ([1][3]).

Citations:


Attention: Impact on the Force – Review Step Size Change, You Must

Changed the maxStepSize from a fixed 10 meters to the maximum value of a double, you have. This significant change could impact performance and numerical stability, hmmm. Typical particle tracking step sizes are tightly constrained by spatial resolution and time stability—not near infinity they are. Consider these points:

  • The change to an unbounded limit may allow simulation steps so large that performance degrades or physics becomes unreliable.
  • Configuration options for setting a custom maximum step size, you might add. This would balance flexibility with the need for physical realism.
  • Verify with simulations and review spatial/temporal constraints from typical particle tracking studies, you should.

Proceed with caution, you must, to ensure that the change does not propagate harmful side effects in your simulation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8e724d and dd06340.

📒 Files selected for processing (1)
  • Core/include/Acts/Propagator/StepperOptions.hpp (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: merge-sentinel
🔇 Additional comments (2)
Core/include/Acts/Propagator/StepperOptions.hpp (2)

14-14: Wise addition of limits header, I sense.

For std::numeric_limits, necessary this include is. Well placed in the include order, it stands.


39-40:

✅ Verification successful

Hmmmm... A new power to control initial steps, you seek.

Wise choice this is, allowing users to control their destiny. Default value of 10 meters, from the old maxStepSize it comes. But verify we must, that all steppers this new power they use correctly.


🏁 Script executed:

#!/bin/bash
# Search for usage of initialStepSize across steppers
ast-grep --pattern 'state.options.initialStepSize'

Length of output: 372


Approved: Verified usage of initial step size correctly, it is.

Wise change this is. Verified, the new initialStepSize member is used in all steppers as intended:

  • In Core/include/Acts/Propagator/AtlasStepper.hpp at line 164,
  • In Core/src/Propagator/StraightLineStepper.cpp at line 43,
  • And in Core/src/Propagator/SympyStepper.cpp at line 50.

Control over initial steps, this new power gives, and consistent its application remains. Approved, I do.

@andiwand
Copy link
Contributor Author

hashes changed because the root file in question stores the constraint step which does not have the same entries as on main

@github-actions github-actions bot added Component - Examples Affects the Examples module Changes Performance labels Feb 20, 2025
Copy link
Member

@benjaminhuth benjaminhuth left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@kodiakhq kodiakhq bot merged commit ce581ba into acts-project:main Mar 3, 2025
44 checks passed
@andiwand andiwand deleted the add-option-initial-step-size branch March 3, 2025 14:11
@github-actions github-actions bot removed the automerge label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes Performance Component - Core Affects the Core module Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants