jax_sbgeom.coils.coilset module
- class CoilSet(coils: Coil)[source]
Bases:
objectClass representing a set of coils. Includes methods for batch evaluation of coil properties. Including with the same coordinate or different coordinates for each coil.
Internally, the coils are stored as a batched Coil object. Therefore, no mixed representations are supported.
Example
>>> coil1 = DiscreteCoil.from_positions(jnp.stack([ jnp.array([1.0, 0.0, 0.0]), jnp.array( [0.0, 1.0, 0.0]), jnp.array([-1.0, 0.0, 0.0]), jnp.array([0.0, -1.0, 0.0]) ])) >>> coil2 = DiscreteCoil.from_positions(jnp.stack([ jnp.array([2.0, 0.0, 0.0]), jnp.array( [0.0, 2.0, 0.0]), jnp.array([-2.0, 0.0, 0.0]), jnp.array([0.0, -2.0, 0.0]) ])) >>> coilset = CoilSet.from_list([coil1, coil2]) >>> s = jnp.linspace(0, 1, 100) >>> positions = coilset.position(s) # shape (2, 100, 3) >>> tangents = coilset.tangent(s) # shape (2, 100, 3) >>> normals = coilset.normal(s) # shape (2, 100, 3) >>> positions_diff = coilset.position_different_s(s[None, :].repeat(coilset.n_coils, axis=0)) # shape (2, 100, 3) >>> coil1_copy = coilset[0] # Get first coil in the coilset
- coils: Coil
Coils in the coilset, stored as a batched Coil object. The batch dimension is the first dimension of all arrays in the Coil dataclass.
- property n_coils
Number of coils in the coilset. Uses the batched data shape and therefore is static information (can be used in jax.jit compiled functions as static shape).
- class FiniteSizeCoilSet(coils: Coil)[source]
Bases:
CoilSetClass representing a set of finite size coils. Includes methods for batch evaluation of coil properties. Including with the same coordinate or different coordinates for each coil. Internally, the coils are stored as a batched FiniteSizeCoil object. Therefore, no mixed representations are supported. Is a subclass of CoilSet, so all methods from CoilSet are also available.
Example
>>> coil1 = DiscreteCoil.from_positions(jnp.stack([ jnp.array([1.0, 0.0, 0.0]), jnp.array( [0.0, 1.0, 0.0]), jnp.array([-1.0, 0.0, 0.0]), jnp.array([0.0, -1.0, 0.0]) ])) >>> coil2 = DiscreteCoil.from_positions(jnp.stack([ jnp.array([2.0, 0.0, 0.0]), jnp.array( [0.0, 2.0, 0.0]), jnp.array([-2.0, 0.0, 0.0]), jnp.array([0.0, -2.0, 0.0]) ])) >>> coilset = FiniteSizeCoilSet.from_coils([coil1, coil2], CentroidFrame) >>> s = jnp.linspace(0, 1, 100) >>> radial_vectors = coilset.radial_vector(s) # shape (2, 100, 3) >>> frames = coilset.finite_size_frame(s) # shape (2, 100, 3, 3) >>> finite_sizes = coilset.finite_size(s, 0.1, 0.1) # shape (2, 100, 4, 3) >>> radial_vectors_diff = coilset.radial_vector_different_s(s[None, :].repeat(coilset.n_coils, axis=0)) # shape (2, 100, 3) >>> coil1_copy = coilset[0] # Get first coil in the coilset
- classmethod from_list(coils: List[FiniteSizeCoil])[source]
Create a FiniteSizeCoilSet from a list of FiniteSizeCoil objects.
- Parameters:
coils (
List[FiniteSizeCoil]) – List of FiniteSizeCoil objects- Returns:
FiniteSizeCoilSet object
- Return type:
- classmethod from_coils(coils: List[Coil], method: Type[FiniteSizeMethod], *args)[source]
Create a FiniteSizeCoilSet from a list of Coil objects and a FiniteSizeMethod. This method is applied to all coils in the list.
- Parameters:
coils (
List[Coil]) – List of Coil objectsmethod (
Type[FiniteSizeMethod]) – FiniteSizeMethod to use for meshingargs (tuple) – Additional arguments for the FiniteSizeMethod setup
- Returns:
FiniteSizeCoilSet object
- Return type:
- classmethod from_coilset(coilset: CoilSet, method: Type[FiniteSizeMethod], *args)[source]
- order_coilset_phi(coilset: CoilSet)[source]
Orders a CoilSet in increasing toroidal angle (phi). Works with both CoilSet and FiniteSizeCoilSet.
- Parameters
coilset (CoilSet) : CoilSet to order
- Returns
CoilSet : ordered Coil_Set
- ensure_coilset_rotation(coilset: CoilSet, positive_rotation: bool)[source]
Ensures that all coils in a CoilSet are defined in the same direction.
- Parameters
coilset (CoilSet) : CoilSet to ensure rotation
- Returns
CoilSet : CoilSet with all coils rotation
- filter_coilset(coilset: CoilSet, mask)[source]
Filters a CoilSet to only include coils where mask is True. Parameters
coilset (CoilSet) : CoilSet to filter mask (jnp.ndarray): Boolean mask to filter coils
- Returns
CoilSet : filtered CoilSet
- filter_coilset_phi(coilset: CoilSet, phi_min: float, phi_max: float)[source]
Filters a CoilSet to only include coils with centre phi between phi_min and phi_max.
- Parameters
coilset (CoilSet) : CoilSet to filter phi_min (float) : minimum phi phi_max (float) : maximum phi
- Returns
CoilSet : filtered CoilSet