bfieldtools.mesh_conductor.MeshConductor

class bfieldtools.mesh_conductor.MeshConductor(verts=None, tris=None, mesh_file=None, mesh_obj=None, process=False, fix_normals=True, basis_name='inner', resistivity=1.6799999999999998e-08, thickness=0.0001, **kwargs)

Class that is used for surface mesh field calculations.

Computation functions are typically external functions that are called using lazy properties.

The mesh surface can consist of a single contiguous surface or several separate surfaces within a single mesh object. The MeshConductor object can handle data defined on the mesh being represented in several different bases:

  • inner (default)

  • vertex:

  • suh: surface harmonics basis. Order given by N_suh

The bases can include built-in boundary conditions for the data: inner and suh bases assume dirichlet boundary condition (equal value within each boundary), while vertex basis does not set a boundary condition.

First priority is to use given Trimesh object (mesh_obj). Second priority is to load mesh from file (mesh_file). Third priority is to use given verts and tris arrays (verts, tris).

Parameters
verts: array-like (Nv, 3)

Array of mesh vertices

tris: array-like (Nt, 3)

Array of mesh faces

mesh_obj: Trimesh mesh object
mesh_file: string

String describing the file path of a mesh file.

process: boolean

If True, Trimesh will pre-process the mesh.

fix_normals: boolean

If True, normals+winding should be set so that they always point “out” from the origin.

basis_name: string

Which basis to use, must be ‘inner’, ‘vertex’ or ‘suh’. See class docstring

Resistivity: float or array (Nfaces)

Resistivity value in Ohm/meter

Thickness: float or array (Nfaces)

Thickness of surface. NB! Must be small in comparison to observation distance

kwargs:
Additional options with default settings are:

‘outer_boundaries’:None, ‘resistance_full_rank’: False, ‘inductance_nchunks’:None, ‘basis_name’:’inner’ (other: suh, vertex) ‘N_suh’: 100 ‘sph_normalization’: ‘default’ ‘sph_radius’: 1 ‘N_sph’: 5 ‘approx_far’: True ‘approx_far_margin’: 2

Notes

outer_boundaries int or array_like, indices of outer boundaries given by utils.find_boundaries(). One boundary index per mesh component. If None, outer_boundaries are set to the longest boundary in each mesh component. When using basis ‘inner’, the outer boundary vertex values are fixed to zero.

resistance_full_rank (Boolean) If True, applies inflation to the resistance matrix in order to increase the rank by one. By default, is False. Don’t set to True without knowing what you are doing.

inductance_nchunks (int or None) Number of serial chunks to split self-inductance computation into, saving memory but taking more time. When approx_far is True, using more chunks is more efficient (multiply by 10-100x) If None (default), attempts to set number of chunks automatically based on the amount of free memory. Unfortunately, this estimation is not perfect.

N_suh Number of surface harmonics to use if basis_name is ‘suh’

sph_normalization ‘default’ (Ylm**2 integrated over solid angle to 1) or ‘energy’ (field energy of basis fields normalized to 1 in R-ball)

sph_radius If sph_normalization is ‘energy’, defines the radius of the inner expansion

N_sph Number of spherical harmonics degrees (l-degrees) to use for the spherical harmonics coupling computation

approx_far (Boolean) If True, usesimple quadrature for points far from the source triangles when computing self-inductance

approx_far_margin (non-negative float) Cut-off distance for “far” points measured in mean triangle side length.

set_basis(self, basis_name)

The data is stored in vertex basis i.e. every element corresponds to one vertex. The basis matrix changes basis of the operators so that a coefficient vector in the desired basis can be multiplied directly with the operator

basis_names : str ‘vertex’, ‘inner’ or ‘suh’

set_holes(self, outer_boundaries=None)

Set indices of holes to self.holes

outer_boundaries: int or array_like, indices of outer boundaries in

self.boundaries. One boundary index per mesh component. If None, outer_boundaries are set the longest boundary in each mesh component

property laplacian

Surface laplacian matrix, returned in appropiate basis.

For further information, see mesh_calculus.laplacian_matrix

property-decorated wrapper.

property mass

Mass matrix, returned in appropiate basis.

For further information, see mesh_calculus.mass_matrix

property-decorated wrapper.

property inductance

Self-inductance matrix, returned in appropiate basis.

For further information, see mesh_impedance.self_inductance_matrix

property-decorated wrapper.

property resistance

Resistance matrix. For further information, see mesh_impedance.resistance_matrix

property-decorated wrapper.

mutual_inductance(self, mesh_conductor_other, quad_degree=1, approx_far=True)

Mutual inductance between this MeshConductor object and another

Parameters:

mesh_conductor_other: MeshConductor object

Returns:
M: mutual inductance matrix M(self, other) in

in the bases specified in the mesh_conductor object

set_sph_options(self, **kwargs)

Set or reset options related to the spherical harmonics (SPH) coupling of the MeshConductor object. If SPH couplings have already been computed, these will be flushed.

Parameters
**kwargs

Any parameter related to sph, namely “N_sph”, “sph_normalization”, “sph_radius”

Returns
None.
property sph_couplings

Spherical harmonic mappings from a stream function defined on the MeshConductor mesh.

property-decorated wrapper

plot_mesh(self, cull_front=False, cull_back=False, **kwargs)

Simply plot the mesh surface in mayavi. kwargs are passed to viz.plot_mesh

save_pickle(self, target_file)

Save the MeshConductor object using a pickled Python file

Parameters
target_file: str

File name or file object to save to