Note
Go to the end to download the full example code.
Test diagonal of inductance matrixΒΆ
Use different number of quadrature points and two different implementations
import numpy as np
import matplotlib.pyplot as plt
from bfieldtools.utils import load_example_mesh
coilmesh = load_example_mesh("10x10_plane")
from bfieldtools.mesh_impedance import self_inductance_matrix, mutual_inductance_matrix
M1 = mutual_inductance_matrix(coilmesh, coilmesh, quad_degree=1)
M2 = mutual_inductance_matrix(coilmesh, coilmesh, quad_degree=2)
M3 = mutual_inductance_matrix(coilmesh, coilmesh, quad_degree=3)
plt.figure()
for m in (M1, M2, M3):
plt.plot(np.diag(m))
MM1 = self_inductance_matrix(coilmesh, quad_degree=1, analytic_self_coupling=True)
MM2 = self_inductance_matrix(coilmesh, quad_degree=2, analytic_self_coupling=True)
MM3 = self_inductance_matrix(coilmesh, quad_degree=3, analytic_self_coupling=True)

Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (14013 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix
Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (14045 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix
Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (13976 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix
Computing self-inductance matrix using rough quadrature (degree=1). For higher accuracy, set quad_degree to 4 or more.
Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (14004 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix
Computing self-inductance matrix using rough quadrature (degree=2). For higher accuracy, set quad_degree to 4 or more.
Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (13980 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix
Estimating 2432 MiB required for 676 by 676 vertices...
Computing inductance matrix in 20 chunks (13968 MiB memory free), when approx_far=True using more chunks is faster...
Computing triangle-coupling matrix

Total running time of the script: (0 minutes 9.568 seconds)