INNER CODE UNIT · Python
simulate
MatthewFilipovich/pycharge · src/pycharge/simulate.py:14
def simulate(sources: Sequence[Source], ts: Array, print_every: int = 100) -> Callable[[], tuple[Array, ...]]:
"""Create simulation function for time-evolution of interacting electromagnetic sources.
Uses RK4 time-stepping with trajectory interpolation to solve the corresponding equations of motion.
Args:
sources (Sequence[Source]): Sources to simulate.
ts (Array): Time points, shape ``(n_steps,)``.
print_every (int): Print progress every N steps. Set to ``0`` to disable. Default: ``100``.
Returns:
Callable[[], tuple[Array, ...]]: Function returning tuple of state arrays, one per source.
Each state array has shape ``(n_steps, n_charges, 2, 3)`` for ``[[r, v], ...]`` at each time.
Note:
Compatible with :meth:`jax.jit`. Memory scales as ``O(n_steps * n_sources * n_charges)``.
"""