gvec.coils#
- class gvec.coils.Coil(coil_points: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], coil_current: float)#
Bases:
object- eval_A(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the vector potential due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Cartesian coordinates of the evaluation points with shape (3,n_positions).
- Returns:
Dataset containing the vector potential at the evaluation positions.
- Return type:
xr.Dataset
- eval_B(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the magnetic field due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Cartesian coordinates of the evaluation points with shape (3,n_positions).
- Returns:
Dataset containing the magnetic field at the evaluation positions.
- Return type:
xr.Dataset
- eval_mod_A(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the modulus of the vector potential due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Cartesian coordinates of the evaluation points with shape (3,n_positions).
- Returns:
ds – Dataset containing the vector potential and its modulus at the evaluation positions.
- Return type:
xr.Dataset
- eval_mod_B(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the modulus of the magnetic field due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Cartesian coordinates of the evaluation points with shape (3,n_positions).
- Returns:
ds – Dataset containing the magnetic field and its modulus at the evaluation positions.
- Return type:
xr.Dataset
- classmethod from_simsopt(coil)#
Initialize a gvec Coil from a simsopt Coil object.
- Parameters:
coil (simsopt.field.coil.Coil) – simsopt coil object.
- Returns:
GVEC coil object.
- Return type:
- get_as_dataobject()#
Return the coil as an xarray data-set.
- Returns:
Dataset containing the coil-points and the current.
- Return type:
Dataset
- classmethod load(path: str | Path, **kwargs)#
- plot(ax=None, show=True, name: str | None = None, **kwargs)#
Visualize the coil in 3D via plotly.
- Parameters:
ax (plotly.graph_objects.Figure, optional) – Existing plotly figure to add the coil to, by default None
show (bool, optional) – Whether to show the plot, by default True
name (str, optional) – Label for the coil.
- Returns:
3D plotly figure.
- Return type:
plotly.graph_objects.Figure
- save(path: str | Path, **kwargs)#
Safe the coils discretization points and current in a netcdf file.
- Parameters:
path (str | Path) – Defines where to save te file.
- class gvec.coils.CoilSet(coils: list[Coil], coil_names: list[str] | None = None)#
Bases:
Coil,Mapping- eval_A(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the vector potential due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Evaluation positions in xyz with shape (3,n_positions).
- Returns:
Vector potential at the evaluation positions.
- Return type:
xr.Dataset
- eval_B(pos: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])#
Evaluate the magnetic field due to currents flowing in the coil at given positions.
- Parameters:
pos (ArrayLike) – Evaluation positions in xyz with shape (3,n_positions). If a DataArray is provided, “xyz” is an expected dimensions.
- Returns:
Magnetic field at the evaluation positions.
- Return type:
xr.Dataset
- classmethod from_simsopt(coilset)#
Initialize a gvec CoilSet from a simsopt CoilSet object.
- Parameters:
coil (simsopt.field.coilset.CoilSet) – simsopt coilset object.
- Returns:
GVEC coilset object.
- Return type:
- get_as_dataobject()#
Return the coil as an xarray data-set.
- Returns:
Dataset containing the coil-points and the current.
- Return type:
Dataset
- classmethod load(path: str | Path, **kwargs)#
- plot(ax=None, show=True, **kwargs)#
Visualize the coil set in 3D via plotly.
- Parameters:
ax (plotly.graph_objects.Figure, optional) – Existing plotly figure to add the coils to, by default None
show (bool, optional) – Whether to show the plot, by default True
- Returns:
3D plotly figure.
- Return type:
plotly.graph_objects.Figure
- class gvec.coils.IntersectionPlane(surf_normal: ndarray, surf_point: ndarray, xlim: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = inf, ylim: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = inf, zlim: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = inf, e_q1: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, e_q2: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None)#
Bases:
object- transform_events_to_X1_X2(events)#
- gvec.coils.check_plane_factory(surf_normal: ndarray, surf_point: ndarray)#
Function factory for checking intersection with a plane defined by a normal vector. Used for the poincare plots in fieldline tracing.
- Parameters:
surf_normal (np.ndarray) – Normal vector of the plane.
- gvec.coils.get_phi_edge_from_coils(state: State, coil_set: CoilSet | Coil)#
Calculate the total toroidal flux from the geometry of a state object and the magnetic field of a coil-set.
- gvec.coils.intersection_planes_from_state(state: State, zetas: int | float | DataArray | ndarray | Sequence = 3, min_box_size: float = 0.001)#
Create IntersectionPlane objects from a State object at specified zeta positions.
- Parameters:
state (State) – GVEC state object to construct the planes from.
zetas (CoordinateSpec, optional) – Zeta positions of the desired planes. If an integer is given linearly spaced zetas will be used. By default 3
min_box_size (float, optional) – Minimum length of the bounding box, by default 1e-3.
- Returns:
List of IntersectionPlane objects.
- Return type:
List[IntersectionPlane]
- gvec.coils.trace_fieldlines(starts: ndarray | Dataset, coils: CoilSet, time: float, surf_normals: list[ndarray] | None = None, surf_points: list[ndarray] | None = None, n_jobs: int = 1, return_solves: bool = False, verbosity: Literal['WARNING', 'INFO', 'DEBUG'] = 'INFO', **kwargs)#
Trace magnetic field lines of a coil field.
- Parameters:
starts (np.ndarray | xr.Dataset) – Initial positions of the magnetic field lines in Carthesian coordinates. Expected shape (3,n_fieldlines).
coils (CoilSet) – Coils set used for evaluating the magnetic field.
time (float) – Time for which to trace the field lines so that t_span = [0,t].
surf_normals (list[np.ndarray], optional) – List of normal vectors of the planes for which intersections of the field lines should be checked. This can then be used for Poincare plots. The default is None
surf_points (list[np.ndarray], optional) – List of points on the planes for which intersections of the field lines should be checked. If None, the origin is used. However, this does not work for the G-frame.
n_jobs (int, optional) – Number of jobs for parallelization over fieldlines, by default 1.
return_solves (bool, optional) – Whether to return a list of solve_ivp objects or an xarray datatree.
verbosity (str) – Level of the logger.