Coverage for qpdk / models / math.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-14 10:27 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-14 10:27 +0000
1"""Mathematical helper functions for models."""
3from functools import partial
5import jax
6import jaxellip
7from jax.typing import ArrayLike
9from qpdk.models.constants import ε_0
12@partial(jax.jit, inline=True)
13def ellipk_ratio(m: ArrayLike) -> jax.Array:
14 """Ratio of complete elliptic integrals of the first kind K(m) / K(1-m)."""
15 return jaxellip.ellipk(m) / jaxellip.ellipk(1 - m)
18@partial(jax.jit, inline=True)
19def epsilon_eff(ep_r: ArrayLike) -> jax.Array:
20 """Effective permittivity for a substrate with relative permittivity ep_r."""
21 return (ep_r + 1) / 2
24@partial(jax.jit, inline=True)
25def capacitance_per_length_conformal(
26 m: ArrayLike,
27 ep_r: ArrayLike,
28) -> jax.Array:
29 """Calculate capacitance per unit length using conformal mapping.
31 C_pul = ε_0 * ε_eff * K(m)/K(1-m)
32 ε_eff = (ep_r + 1) / 2.
34 Args:
35 m: The parameter m (modulus squared) of the elliptic integral.
36 ep_r: Relative permittivity of the substrate.
38 Returns:
39 The capacitance per unit length in Farads/meter.
40 """
41 return ε_0 * epsilon_eff(ep_r) * ellipk_ratio(m)