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, maxstep=1000, min_step_size=1e-08, solver=Tsit5(), bounds_R=(0, inf), bounds_Z=(-inf, inf), chunk_size=None, **kwargs)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 ode integration

  • atol (float) – relative and absolute tolerances for ode integration

  • maxstep (int) – maximum number of steps between different phis

  • 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) – Size to split computation into chunks of evaluation points. If no chunking should be done or the chunk size is the full input then supply None. Default is None.

  • kwargs (dict) – keyword arguments to be passed into the diffrax.diffeqsolve

Returns:

r, z (ndarray) – arrays of r and z coordinates of the field line, corresponding to the input phis