bfieldtools.suhtools.SuhBasis

class bfieldtools.suhtools.SuhBasis(obj, Nc=None, boundary_condition='dirichlet', magnetic=False, solver_sparse=True, **kwargs)

Class for representing magnetic field using surface harmonics

Parameters
objTrimesh-object or Conductor-object

Represents the boundary on which current density is specified or Conductor object that wraps the mesh

NcNumber of components

If None (default), compute all components.

boundary_conditionstr “dirichlet” (default) or “neumann”

if zero-Dirichlet boundary conditions (“dirichlet”) are used the basis corresponds to inner_vertices else with zero-Neumann condition (“neumann”) the basis corresponds to all vertices

magnetic: False or ‘DC’ or ‘AC’

Determines eigenvalue equation. If False, use laplacian and mass matrices. If ‘DC’, use resistance and mass matrices. If ‘AC’, use resistance and inductance matrices.

solver_sparse: Boolean (True)

If True, use solver from scipy.sparse.linalg rather than scipy.linalg

kwargs: dict

Passed to Conductor creation if a Trimesh object is passed as ‘obj’

calculate_basis(self, shiftinvert=True, v0=None)

Calculate basis functions as eigenfunctions of matrices specified by the ‘magnetic’ parameter

Parameters
shiftinvert: Boolean (True)

use shiftinvert mode to calculate eigenstuff faster (experimental)

v0: array (b, b)

Intial value matrix for eigenvalue decomposition algorithm. Shape depends on BC: if neumann b=self.mesh_conductor.basis.shape[0], if dirichlet b=self.mesh_conductor.basis.shape[1]

field(self, coeffs, points)

Calculate field at points

Parameters

coeffs : (self.Nc,) array of basis function coefficients points : (N_points, 3) field evaluation points

Returns:

field : (N_points, 3) magnetic field

basis_fields(self, points)

Calculate basis fields at points

Return:

Fields (3, N_points, self.Nc)

fit_coeffs(self, points, data)

Fit basis function coefficients to the data

plot(self, Nfuncs, dist=0.5, Ncols=None, figure=None, figsize=(800, 800), **kwargs)

Plot basis functions on the mesh

Nfuncs: int or array-like

if int, the number functions starting from the first’Blm’, if list/array: the indices of the functions

dist: float

distance between the plotted objects relative to their size

Ncols: int or None

the number of columns in the plot If none automatically determined

fig: handle for mlab figure

figsize: size of a new figure if ‘fig’ not given

ncolors:

number of colors in the colormap

kwargs: keyword arguments passed to mayavi (colormap, etc.)