pycharge.functional#
Core utility functions used in PyCharge.
Functions#
|
Compute charge acceleration \(\mathbf{a}(t) = d^2\mathbf{r}/dt^2\) via automatic differentiation. |
|
Compute emission time (retarded time) \(t_r\) of a charge from an observation point. |
|
Create position interpolation function from trajectory data. |
|
Compute charge position at time t. |
|
Compute charge velocity \(\mathbf{v}(t) = d\mathbf{r}/dt\) via automatic differentiation. |
Package Contents#
- pycharge.functional.acceleration(t, charge)#
Compute charge acceleration \(\mathbf{a}(t) = d^2\mathbf{r}/dt^2\) via automatic differentiation.
- Parameters:
t (ArrayLike) – Time (scalar or array).
charge (Charge) – Charge object.
- Returns:
Acceleration \(\mathbf{a}(t) = [a_x, a_y, a_z]\).
- Return type:
Array
- pycharge.functional.emission_time(r, t, charge)#
Compute emission time (retarded time) \(t_r\) of a charge from an observation point.
Solves \(t_r = t - \frac{1}{c}\,|\mathbf{r} - \mathbf{r}_s(t_r)|\) at observation point \((\mathbf{r}, t)\) using fixed-point iteration followed by Newton’s method.
- Parameters:
r (Array) – Observation point \(\mathbf{r} = [x, y, z]\).
t (Array) – Observation time \(t\).
charge (Charge) – Charge with position function and solver config.
- Returns:
\(t_r\).
- Return type:
Array
Note
The solver parameters (
rtol,atol,max_steps,throw) are configured viacharge.solver_config.
- pycharge.functional.interpolate_position(ts, position_array, velocity_array, position_0_fn, t_end=None)#
Create position interpolation function from trajectory data.
Uses cubic Hermite interpolation for \(C^1\) continuity (continuous position and velocity). The interpolated position \(\mathbf{r}(t)\) for \(t_i \leq t \leq t_{i+1}\) is:
\[\mathbf{r}(t) = a\tau^3 + b\tau^2 + c\tau + d\]where \(\tau = (t - t_i)/(t_{i+1} - t_i)\) and coefficients ensure matching positions and velocities at interval endpoints.
- Parameters:
ts (Array) – Time points, shape
(n_steps,).position_array (Array) – Positions at each time, shape
(n_steps, 3).velocity_array (Array) – Velocities at each time, shape
(n_steps, 3).position_0_fn (Callable[[Scalar], Vector3]) – Original position function before simulation start.
t_end (Array or None) – End time for interpolation. Default: if
None, usests[-1].
- Returns:
- Function returning position at time t.
For \(t \leq t_0\), returns
position_0_fn(t). For \(t \geq t_{\mathrm{end}}\), returns final position. Otherwise, cubic Hermite interpolation.
- Return type:
Callable[[Scalar], Array]