desc.magnetic_fields.field_line_integrate
- class desc.magnetic_fields.field_line_integrate(r0, z0, phis, field, params=None, source_grid=None, rtol=1e-08, atol=1e-08, max_steps=None, min_step_size=1e-08, solver=Tsit5(), bounds_R=(0, inf), bounds_Z=(-inf, inf), chunk_size=None, bs_chunk_size=None, options=None, return_aux=False)Source
Trace field lines by integration, using diffrax package.
- Parameters:
r0 (array-like) – initial starting coordinates for r,z on phi=phis[0] plane
z0 (array-like) – initial starting coordinates for r,z on phi=phis[0] plane
phis (array-like) – geometric toroidal angle values to output r,z at. Can be strictly increasing or decreasing, but must be monotonic.
field (MagneticField) – source of magnetic field to integrate
params (dict, optional) – parameters passed to field
source_grid (Grid, optional) – Collocation points used to discretize source field.
rtol (float) – relative and absolute tolerances for PID stepsize controller. Not used if
stepsize_controlleris provided.atol (float) – relative and absolute tolerances for PID stepsize controller. Not used if
stepsize_controlleris provided.max_steps (int) – maximum number of steps for the integration. Defaults to abs((phis[-1] - phis[0]) * 1000)
min_step_size (float) – minimum step size (in phi) that the integration can take. default is 1e-8
solver (diffrax.Solver) – diffrax Solver object to use in integration, defaults to Tsit5(), a RK45 explicit solver
bounds_R (tuple of (float,float), optional) – R bounds for field line integration bounding box. Trajectories that leave this box will be stopped, and NaN returned for points outside the box. Defaults to (0, np.inf)
bounds_Z (tuple of (float,float), optional) – Z bounds for field line integration bounding box. Trajectories that leave this box will be stopped, and NaN returned for points outside the box. Defaults to (-np.inf, np.inf)
chunk_size (int or None) – Chunk of field lines to trace at once. If None, traces all at once. Defaults to None.
bs_chunk_size (int or None) – Chunk size to use when evaluating Biot-Savart for the magnetic field. If None, evaluates all the source grid points at once. Defaults to None.
options (dict, optional) – Additional arguments to pass to the diffrax diffeqsolve.
return_aux (bool, optional) – Whether to return auxiliary information from the integrator. If True, will return a tuple (r, z, aux) where aux consists
statsandresultfromdiffrax.diffeqsolve. Defaults to False.
- Returns:
r, z (ndarray) – arrays of r and z coordinates of the field line, corresponding to the input phis