Beispiel #1
0
                     scalars=ddist[:, 0],
                     vmin=-1,
                     vmax=1,
                     colormap="seismic")
mlab.colorbar()
mlab.triangular_mesh(*mesh.vertices.T, mesh.faces, representation="wireframe")
mlab.quiver3d(*mesh.triangles_center.T, *mesh.face_normals.T)

#%%
#
from bfieldtools.legacy.mesh_magnetics import (
    magnetic_field_coupling_analytic as magnetic_field_coupling_analytic_old, )
from bfieldtools.mesh_magnetics import magnetic_field_coupling_analytic

b1 = magnetic_field_coupling_analytic_old(mesh, mesh2.vertices)
b2 = magnetic_field_coupling_analytic(mesh, mesh2.vertices)

assert np.allclose(b1, b2)

mlab.figure("b field")
mlab.quiver3d(*mesh2.vertices.T, *b1[:, :, 0].T)
mlab.quiver3d(*mesh2.vertices.T, *b2[:, :, 0].T)

#%%
# Gammma
from bfieldtools.legacy.integrals import gamma0 as g1
from bfieldtools.integrals import gamma0 as g2

# RR =  mesh2.vertices[:, None, None, :] - mesh.vertices[None, mesh.faces]
t = np.linspace(-1.5, 1.5)
points = (t[:, None] * mesh.vertices[mesh.faces][0][0] +
Beispiel #2
0
from bfieldtools.sphtools import compute_sphcoeffs_mesh, basis_fields
from bfieldtools.suhtools import SuhBasis
from bfieldtools.utils import load_example_mesh

mesh = load_example_mesh("bunny_repaired")

mesh.vertices -= mesh.vertices.mean(axis=0)

mesh_field = mesh.copy()
mesh_field.vertices += 0.005 * mesh_field.vertex_normals
mesh_field = trimesh.smoothing.filter_laplacian(mesh_field, iterations=1)

Ca, Cb = basis_fields(mesh_field.vertices, 4)

bsuh = SuhBasis(mesh, 25)
Csuh = magnetic_field_coupling_analytic(mesh, mesh_field.vertices) @ bsuh.basis


#%%
def plot_basis_fields(C, comps):
    d = 0.17
    i = 0
    j = 0
    for n in comps:
        p = 1.05 * mesh_field.vertices.copy()
        p2 = mesh_field.vertices.copy()
        #        p[:,1] -= i*d
        #        p2[:,1] -= i*d
        p[:, 0] += i * d
        p2[:, 0] += i * d
        m = np.max(np.linalg.norm(C[:, :, n], axis=0))
Beispiel #3
0
import pkg_resources


# Load simple plane mesh that is centered on the origin
file_obj = pkg_resources.resource_filename(
    "bfieldtools", "example_meshes/10x10_plane.obj"
)
coilmesh = trimesh.load(file_obj, process=False)
coil = MeshConductor(mesh_obj=coilmesh)
weights = np.zeros(coilmesh.vertices.shape[0])
weights[coil.inner_vertices] = 1

test_points = coilmesh.vertices + np.array([0, 1, 0])

B0 = magnetic_field_coupling(coilmesh, test_points) @ weights
B1 = magnetic_field_coupling_analytic(coilmesh, test_points) @ weights


f = mlab.figure(None, bgcolor=(1, 1, 1), fgcolor=(0.5, 0.5, 0.5), size=(800, 800))

s = mlab.triangular_mesh(
    *coilmesh.vertices.T, coilmesh.faces, scalars=weights, colormap="viridis"
)
s.enable_contours = True
s.actor.property.render_lines_as_tubes = True
s.actor.property.line_width = 3.0

mlab.quiver3d(*test_points.T, *B0.T, color=(1, 0, 0))
mlab.quiver3d(*test_points.T, *B1.T, color=(0, 0, 1))

print(