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

1"""Mathematical helper functions for models.""" 

2 

3from functools import partial 

4 

5import jax 

6import jaxellip 

7from jax.typing import ArrayLike 

8 

9from qpdk.models.constants import ε_0 

10 

11 

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) 

16 

17 

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 

22 

23 

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. 

30 

31 C_pul = ε_0 * ε_eff * K(m)/K(1-m) 

32 ε_eff = (ep_r + 1) / 2. 

33 

34 Args: 

35 m: The parameter m (modulus squared) of the elliptic integral. 

36 ep_r: Relative permittivity of the substrate. 

37 

38 Returns: 

39 The capacitance per unit length in Farads/meter. 

40 """ 

41 return ε_0 * epsilon_eff(ep_r) * ellipk_ratio(m)