desc.integrals.Bounce1D

class desc.integrals.Bounce1D(grid, data, quad=None, *, automorphism=None, check=False, sentinel=-100000.0, **kwargs)Source

Computes bounce integrals using one-dimensional spline methods.

The bounce integral is defined as ∫ f(ρ,α,λ,ℓ) dℓ where

  • dℓ parametrizes the distance along the field line in meters.

  • f(ρ,α,λ,ℓ) is the quantity to integrate along the field line.

  • The boundaries of the integral are bounce points ℓ₁, ℓ₂ s.t. λB(ρ,α,ℓᵢ) = 1.

  • λ is a constant defining the integral proportional to the magnetic moment over energy.

  • B is the norm of the magnetic field.

For a particle with fixed λ, bounce points are defined to be the location on the field line such that the particle’s velocity parallel to the magnetic field is zero. The bounce integral is defined up to a sign. We choose the sign that corresponds to the particle’s guiding center trajectory traveling in the direction of increasing field-line-following coordinate ζ.

Examples

  • desc/compute/_old.py

  • tests/test_integrals.py::TestBounce::test_bounce1d_checks

See also

Bounce2D

Bounce2D uses 2D pseudo-spectral methods for the same task. The function approximation in Bounce1D is ignorant that the objects to approximate are defined on a bounded subset of ℝ². The domain is projected to ℝ, where information sampled about the function at infinity cannot support reconstruction of the function near the origin. As the functions of interest do not vanish at infinity, pseudo-spectral techniques are not used. Instead, function approximation is done with splines. This is useful if one can efficiently obtain data along field lines and the number of toroidal transits to follow a field line is not large.

Parameters:
  • grid (Grid) – Tensor-product grid in (ρ, α, ζ) Clebsch coordinates. The ζ coordinates are preferably uniformly spaced as they are the knots for the spline interpolation.

  • data (dict[str, jnp.ndarray]) – Data evaluated on grid. Must include names in Bounce1D.required_names.

  • quad (tuple[jnp.ndarray]) – Quadrature points xₖ and weights wₖ for the approximation of an integral ∫₋₁¹ g(x) dx = ∑ₖ wₖ g(xₖ). Default is 32 points.

  • automorphism (tuple[Callable] or None) – The first callable should be an automorphism of the real interval [-1, 1]. The second callable should be the derivative of the first. This map defines a change of variable for the bounce integral. The choice made for the automorphism will affect the performance of the quadrature.

  • check (bool) – Flag for debugging. Must be false for JAX transformations.

  • sentinel (float) – A number which is less than all ζ coordinates in the grid. Default is -1e5.

Methods

batch(fun, data, grid, *[, names, ...])

Compute function fun batched over flux surfaces.

check_points(points, pitch_inv, *[, plot])

Check that bounce points are computed correctly.

integrate(integrand, pitch_inv[, data, ...])

Bounce integrate ∫ f(ρ,α,λ,ℓ) dℓ.

interp_to_argmin(f, points, *[, method])

Interpolate f to the deepest point in magnetic well w.

pitch_quad(min_B, max_B, num_pitch, **kwargs)

Return 1/λ values and weights for quadrature between min_B and max_B.

plot(l, m[, pitch_inv])

Plot B and bounce points on the specified field line.

points(pitch_inv[, num_well])

Compute bounce points.

reshape(grid, f)

Reshape arrays for acceptable input to integrate.

Attributes

required_names

Required keys in the data dictionary given to the __init__ method.