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, bounds_R=(0, inf), bounds_Z=(-inf, inf), decay_accel=1000000.0)Source

Trace field lines by integration.

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) – strictly increasing array of toroidal angles to output r,z at Note that phis is the geometric toroidal angle for positive Bphi, and the negative toroidal angle for negative Bphi

  • field (MagneticField) – source of magnetic field to integrate

  • params (dict) – 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

  • bounds_R (tuple of (float,float), optional) – R bounds for field line integration bounding box. If supplied, the RHS of the field line equations will be multiplied by exp(-r) where r is the distance to the bounding box, this is meant to prevent the field lines which escape to infinity from slowing the integration down by being traced to infinity. defaults to (0,np.inf)

  • bounds_Z (tuple of (float,float), optional) – Z bounds for field line integration bounding box. If supplied, the RHS of the field line equations will be multiplied by exp(-r) where r is the distance to the bounding box, this is meant to prevent the field lines which escape to infinity from slowing the integration down by being traced to infinity. Defaults to (-np.inf,np.inf)

  • decay_accel (float, optional) – An extra factor to the exponential that decays the RHS, i.e. the RHS is multiplied by exp(-r * decay_accel), this is to accelerate the decay of the RHS and stop the integration sooner after exiting the bounds. Defaults to 1e6

Returns:

r, z (ndarray) – arrays of r, z coordinates at specified phi angles