celeritas icon indicating copy to clipboard operation
celeritas copied to clipboard

Optimize field propagation performance

Open sethrj opened this issue 1 year ago • 1 comments

  • [ ] Refactor FieldPropagator to have internal state and function calls rather than being one huge function with tons of if statements
  • [x] Rename classes (https://github.com/celeritas-project/celeritas/issues/721)
  • [ ] Rethink field intersection algorithm as a root finder (maybe using Regula Falsi iteration)
  • [ ] Add a derived field propagator that uses safety: https://github.com/celeritas-project/celeritas/issues/762
  • [ ] Perform propagation in local coordinate system for improved accuracy https://github.com/celeritas-project/celeritas/issues/994#issuecomment-1836508438
    • Perform integration in local coordinate system?
    • Then we could use single precision
  • [ ] Make substep length in field driver (due to change in discretization error) persistent across calls in propagator (or even across steps)

  • Input: step length
  • Super small: accept immediately
  • Goal: longest step allowed by chord length and acceptable discretization error
  • If discretization limited, accumulate until step length is reached
  • Use distance between endpoints versus dchord to tell if we're within the asymptotic region

Start with last successful step if available

  • Converged if chord length is within tolerance, discretization is in limits
  • Calculate target next step length for chord length ( * sqrt(eps / distance_chord)
  • Calculate target next step length for discretization error
  • Increase next guess if error is too large??

  • MicroFieldAdvancer
    • No iteration
    • Success if step < minimum_step (evaluated first of course)
  • ChordAdvancer: reduce step until chord is within a tolerance
    • Iteration: reduce step (exponential, no more than halving each iter)
    • Convergence: max_nsteps
    • Convergence: chord distance
    • Success if discretization error is small enough
  • Reduce step size based on scale factor
  • AccurateAdvancer:
    • sub-sub steps to accumulate to maximum step, but sub-step length changes
    • Success when accumulated length is greater than or equal to requested step length * (1 - epsilon_step)
    • StepIntegrator
      • MicroFieldAdvancer if step < minimum_step and update new step
      • GoodAdvancer otherwise:
        • Iteration: reduce step

sethrj avatar Aug 05 '24 18:08 sethrj

Not quite the ideas that we discussed with @LSchwiebert today, but at least the same part of the code with the same goal.

sethrj avatar Oct 07 '25 18:10 sethrj