jax_sbgeom.coils.fourier_coil module
- class FourierCoil(fourier_cos: Array, fourier_sin: Array, centre_i: Array)[source]
Bases:
CoilClass representing a coil defined by Fourier coefficients.
It uses the Fourier series to compute the position, tangent and normal along the coil.
x = centre_i[0] + sum_{n=1}^N [ fourier_cos[0, n] * cos(2 pi n s) + fourier_sin[0, n] * sin(2 pi n s) ] y = centre_i[1] + sum_{n=1}^N [ fourier_cos[1, n] * cos(2 pi n s) + fourier_sin[1, n] * sin(2 pi n s) ] z = centre_i[2] + sum_{n=1}^N [ fourier_cos[2, n] * cos(2 pi n s) + fourier_sin[2, n] * sin(2 pi n s) ]
For creating FourierCoil objects from discrete positions, use the function curve_to_fourier_coefficients’. The parametrisation can be converted to equal-arclength by using convert_fourier_coil_to_equal_arclength or convert_fourier_coilset_to_equal_arclength.
- Parameters:
fourier_cos (
Array) – Fourier cosine coefficients [N_modes, 3]fourier_sin (
Array) – Fourier sine coefficients [N_modes, 3]centre_i (
Array) – Centre of the coil [3]
- fourier_cos: Array
- fourier_sin: Array
- centre_i: Array
- position(s)[source]
Position along the coil as a function of arc length
- Parameters:
s (jnp.ndarray) – Arc length(s) along the coil
- Returns:
Cartesian position(s) along the coil
- Return type:
jnp.ndarray
- tangent(s)[source]
Tangent vector along the coil as a function of arc length
- Parameters:
s (jnp.ndarray) – Arc length(s) along the coil
- Returns:
Tangent vector(s) along the coil
- Return type:
jnp.ndarray
- xyz_fourier_batched(positions: Array, n_modes: int)
- convert_fourier_coil_to_equal_arclength(fourier_coil: FourierCoil, n_points_sample: int = None, n_points_desired: int = None, method: Literal['pchip', 'linear'] = 'pchip')[source]
Resample a Fourier coil to have points equally spaced in arc length.
- Parameters:
fourier_coil (
FourierCoil) – Fourier coil object with N modesn_points_sample (
int) – Number of points to sample the arc length inverse. If None, uses N*16 points.n_points_desired (
int) – Number of points to resample to. If None, uses N*4 points.method (
Literal['pchip','linear']) – Method to use for interpolating the arc length inverse. ‘pchip’ is significantly better while not increasing runtime. Most of the time is spent on computing the Fourier sums.
- Returns:
Resampled positions along the coil
- Return type:
FourierCoil [n_points_desired, 3]
- convert_fourier_coilset_to_equal_arclength(fourier_coilset: CoilSet, n_points_sample: int = None, n_points_desired: int = None, method: Literal['pchip', 'linear'] = 'pchip')[source]
Resample a Fourier coilset to have points equally spaced in arc length.
Parameters
- n_points_sampleint
Number of points to sample the arc length inverse. If None, uses N*16 points.
- n_points_desiredint
Number of points to resample to. If None, uses N*4 points.
- methodLiteral[‘pchip’, ‘linear’]
Method to use for interpolating the arc length inverse. ‘pchip’ is significantly better while not increasing runtime. Most of the time is spent on computing the Fourier sums.
- Returns:
Resampled positions along the coil
- Return type:
FourierCoil [n_coils, n_points_desired, 3]
- convert_to_fourier_coil(coil: DiscreteCoil, n_modes: int = None)[source]
Convert a DiscreteCoil to a FourierCoil by computing Fourier coefficients from the discrete positions
- Parameters:
coil (
DiscreteCoil) – Discrete coil objectn_modes (
int) – Number of Fourier modes to use. If None, uses N/2 modes where N is the number of discrete points in the coil.
- Returns:
Fourier coil object
- Return type:
- convert_to_fourier_coilset(coilset: CoilSet, n_modes: int = None)[source]
Convert a DiscreteCoil to a FourierCoil by computing Fourier coefficients from the discrete positions
- Parameters:
coil (DiscreteCoil) – Discrete coil object
n_modes (
int) – Number of Fourier modes to use. If None, uses (N+1)//2 modes where N is the number of discrete points in the coil.
- Returns:
Fourier coil object
- Return type: