API Reference¶
bfieldtools
– Main package¶
Surface mesh field calculations¶
Contains a class used for wrapping a mesh (in the form of a Trimesh object) together with some convenient functions and properties.
|
Class that is used for surface mesh field calculations. |
|
General-use class that contains a data array (a coupling matrix) and a bookkeeping list of computed points. |
|
Class for representing stream function(s) on a MeshConductor |
Surface mesh calculus¶
Contains functions for computing vector calculus quantities on triangle surface meshes. These include the gradient, rotated gradient, divergence, curl, Laplacian and mass matrices.
|
Sparse Laplace-Beltrami operator. |
|
Computes mass matrix of a mesh. |
|
Calculate a (rotated) gradient matrix for hat basis functions (stream functions) in a mesh. |
|
Applies mesh (rotated) gradient matrix operator on vector that is defined in the vertex locations of the mesh. |
|
Divergence of tangential vector field on mesh faces as a linear mapping. |
|
Divergence mapping applied to tangential vector field ‘vecs’ |
|
Adjoint curl of tangential vector field. |
|
Curl applied to tangential vector field |
Mesh impedance¶
Contains functions for computing the resistance and inductance matrices of triangle surface meshes. Includes both self- and mutual-inductance.
|
Resistance matrix of a mesh. |
|
Calculate a self inductance matrix for hat basis functions (stream functions) in a mesh. |
|
Calculate a mutual inductance matrix for hat basis functions (stream functions) between two surface meshes. |
|
Mutual inductance of a closed line segment loop (last segment connecting to first) and a triangle mesh. |
Stream function magnetic couplings¶
Contains functions for calculating the coupling of surface current density in a triangle mesh to magnetic field as well as scalar and vector potentials.
|
Computes the coupling matrix which gives the magnetic field at target points due to currents (stream function) on a surface mesh. |
|
Computes the coupling matrix which gives the magnetic field at target points due to currents (stream function) on a surface mesh using analytical formulas. |
|
Coupling matrix from a stream function on a mesh to scalar potential using analytic integrals. |
|
Compute vector potential coupling matrices from a linear stream function on a mesh using analytic integrals. |
Line currents¶
This module includes a convenience class for working with polyline currents
|
Class that inherits Trimesh.path.Path3D for handling discretized current loops. |
Functions for working with current polylines, e.g. for calculating the magnetic field and potentials as well as the inductance
Convex optimization of stream functions¶
Includes files for coil optimization (stream function optimization) using either a numerical solver or regularized least squares
|
Quadratic optimization of coil stream function according to a specified objective. |
|
Optimization of coil stream function according to a specified objective using least-squares. |
|
Bare-bones quadratic programming solver function for CVXPY. |
|
Use cvxopt (without CVXPY wrapper) for quadratic programming. |
Analytical integrals for fields and potentials¶
Analytic integral for vectorized field / potential computation
|
1/r integrals over the edges of a triangle called gamma_0 (line charge potentials). |
|
Calculate the solid angle of a triangles |
|
1/r potential of a uniform triangle |
|
1/r potential of a uniform triangle using centroid approximation |
|
Approximate the potential of linearly varying dipole density by |
|
Approximate the potential of linearly varying dipole density by |
|
Potential of dipolar density with magnitude of a linear shape function on a triangle, “omega_i” in de Munck’s paper |
Scalar function contouring¶
Functions for creating contours (isolines) of a scalar function defined on a triangle mesh surface. Also contains functions for modifying the generated contours.
|
Computes contour loops (isolines) for a scalar function defined on a mesh. |
|
Simplifies contours by merging small (short) segments and with only a small angle difference. |
Spherical harmonics¶
Functions for constructing real spherical harmonics (Ylms), their gradients and related magnetic field ‘basis vectorfunctions’ (Wlms for r**l components, Vlms for r**(-l) components).
Uses notations and definitions by Plattner and Simons (2014; https://arxiv.org/pdf/1306.3201.pdf) and the same normalization conventions.
Integration over a surface of unit sphere is used as the inner product <C,D> = int C dot D dOmega.
Also has many of functions for spherical <-> cartesian transformations.
|
Computes associated Legendre function (Plm) of the first kind of order m and degree l. |
|
Real spherical harmonics as defined by Plattner and Simons (2014); see Eqs. |
|
Vector basis function (Wlm) for r**l component of the magnetic field. |
|
Vector basis function (Vlm) for r**(-l) component of the magnetic field. |
|
Computes inner/outer basis functions for magnetic scalar potential. |
|
Computes magnetic field of each sph coefficient. |
|
Computes magnetic scalar potential from the sph coefficients. |
|
Computes magnetic field at some point from the sph coefficients. |
|
Computes multipole moment (spherical harmonics coefficient) transformation from the mesh. |
Surface harmonics¶
Tools for calculating the surface harmonic representation of the magnetic field. Surface harmonics can represent of any stream function as a series.
Surface harmonics == Laplace-Beltrami eigenfunctions
|
Class for representing magnetic field using surface harmonics |
Thermal noise¶
Contains functions for computing thermal noise in conductive thin objects.
|
Calculates the (AC or DC) Johnson noise current modes on the conducting surface. |
|
Calculates (AC or DC) magnetic noise covariance along x, y and z from the modes vl. |
|
Calculates (AC or DC) magnetic noise variance along x, y and z from the modes vl. |
|
Calculates (AC or DC) magnetic noise covariance between x, y and z directions from the modes vl. |
|
Visualizes current modes up to Nmodes. |
Visualization and plotting¶
Visualization functions tailored for bfieldtools. Mainly wrappers and convenience helpers around mayavi and matplotlib functions
|
Plot the mesh surface in mayavi. |
|
Plot current loops (e.g. |
|
Plot scalar data on a plane |
|
Plot scalar data defined on the vertices of a mesh. |
|
Plot any data determined on the faces of a mesh |
Utilities¶
This module contains miscellaneous utility functions used across bfieldtools.
|
Combine two or more non-overlapping Trimesh meshes without any dependency requirements. |
|
Get quad points and weights from quadrature rules implemented in quadpy |
|
Get quad points and weights from quadrature rules implemented in quadpy |
|
Calculate (dual) areas for each node in inds |
|
Finds the open boundaries of a mesh by finding the edges that only belong to a single triangle. |
|
Convenience function used load example meshes included with the package |
|
Attempts to fix face windings and normals such that normals are always “pointing out” from the origin. |
|
Linear mapping of the inner (free) weights in the stream function discretization to weights in all vertices |
|
Linear mapping of the all weights in the stream function discretization to inner (free) weights |
|
Class for constructing projection of an arbitrary function to the hat functions of the given mesh |