Skip to content

Instantly share code, notes, and snippets.

@loganbvh
Created January 11, 2023 21:31
Show Gist options
  • Save loganbvh/0cea633cbd6b0356df9726d45afb921a to your computer and use it in GitHub Desktop.
Save loganbvh/0cea633cbd6b0356df9726d45afb921a to your computer and use it in GitHub Desktop.
Maxwell's analytical formula for the mutual inductance of two coaxial circular loops
from numpy import sqrt
from scipy.special import ellipe, ellipk
import pint
ureg = pint.UnitRegistry()
def mutual_inductance(r1: float, r2: float, h: float, length_units: str = "m") -> pint.Quantity:
"""Calculates the mutual inductance between two coaxial circular loops.
All lengths, ``r1``, ``r2``, and ``h`` are assumed to be given in ``length_units``.
Reference: https://nvlpubs.nist.gov/nistpubs/bulletin/08/nbsbulletinv8n1p1_A2b.pdf, page 6.
Args:
r1: The radius of the first circle
r2: The radius of the second circle
h: The distance between the two circles along their shared axis
length_units: The units in which the first three arguments are given
Returns:
The mutual inductance as a pint Quantity
"""
# k is the modulus of the elliptic integrals
k = 2 * sqrt(r1 * r2) / sqrt((r1 + r2)**2 + h**2)
# m = k**2 is the argument accepted by the scipy functions
m = k**2
K = ellipk(m)
E = ellipe(m)
return ureg("mu_0") * ureg(length_units) * sqrt(r1 * r2) * ((2 / k - k) * K - 2 / k * E)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment