# Path: skrf/tlineFunctions.py
# def skin_depth(f: NumberLike, rho: float, mu_r: float):
#     r"""
#     Skin depth for a material.
# 
#     The skin depth is calculated as:
# 
# 
#     .. math::
# 
#         \delta = \sqrt{\frac{ \rho }{ \pi f \mu_r \mu_0 }}
# 
#     See www.microwaves101.com [#]_ or wikipedia [#]_ for more info.
# 
#     Parameters
#     ----------
#     f : number or array-like
#         frequency, in Hz
#     rho : number of array-like
#         bulk resistivity of material, in ohm*m
#     mu_r : number or array-like
#         relative permeability of material
# 
#     Returns
#     -------
#     skin depth : number or array-like
#         the skin depth, in meter
# 
#     References
#     ----------
#     .. [#] https://www.microwaves101.com/encyclopedias/skin-depth
#     .. [#] http://en.wikipedia.org/wiki/Skin_effect
# 
#     See Also
#     --------
#     surface_resistivity
# 
#     """
#     return sqrt(rho/(pi*f*mu_r*mu_0))
# 
# def surface_resistivity(f: NumberLike, rho: float, mu_r: float):
#     r"""
#     Surface resistivity.
# 
#     The surface resistivity is calculated as:
# 
# 
#     .. math::
# 
#         \frac{ \rho }{ \delta }
# 
#     where :math:`\delta` is the skin depth from :func:`skin_depth`.
# 
#     See www.microwaves101.com [#]_ or wikipedia [#]_ for more info.
# 
#     Parameters
#     ----------
#     f : number or array-like
#         frequency, in Hz
#     rho : number or array-like
#         bulk resistivity of material, in ohm*m
#     mu_r : number or array-like
#         relative permeability of material
# 
#     Returns
#     -------
#     surface resistivity : number of array-like
#         Surface resistivity in ohms/square
# 
#     References
#     ----------
#     .. [#] https://www.microwaves101.com/encyclopedias/sheet-resistance
#     .. [#] https://en.wikipedia.org/wiki/Sheet_resistance
# 
#     See Also
#     --------
#     skin_depth
#     """
#     return rho/skin_depth(rho=rho, f=f, mu_r=mu_r)
# 
# Path: skrf/constants.py
# INF = 1e99
# ALMOST_ZERO = 1e-12
# ZERO = 1e-4
# ONE = 1.0 + 1/1e14
# LOG_OF_NEG = -100
# K_BOLTZMANN = 1.38064852e-23
# T0 = 290.
# S_DEFINITIONS = ['power', 'pseudo', 'traveling']
# S_DEF_DEFAULT = 'power'
# def to_meters(d: NumberLike, unit: str = 'm', v_g: float = c) -> NumberLike:


import numpy as npy
from numpy import log, tanh, sqrt, exp, real, imag, cosh, \
                            ones, zeros, arctan
from scipy.constants import  epsilon_0, mu_0, c, pi
from .media import Media
from ..tlineFunctions import skin_depth, surface_resistivity
from ..constants import NumberLike
from typing import Union, TYPE_CHECKING
    from .. frequency import Frequency
        alpha_dielectric: calculates losses to dielectric
        beta            : calculates phase parameter
        """
        f = self.frequency.f
        alpha = zeros(len(f))
        beta  = zeros(len(f))
        beta  = self.beta_phase
        alpha = self.alpha_dielectric
        if self.rho is not None:
            alpha += self.alpha_conductor
        return alpha + 1j*beta

def a(u: NumberLike) -> NumberLike:
    """
    Intermediary parameter. see qucs docs on microstrip lines.
    """
    return 1. + 1./49.*log((u**4+(u/52)**2)/(u**4+0.432)) + 1./18.7*log(1+(u/18.1)**3)

def b(ep_r: NumberLike) -> NumberLike:
    """
    intermediary parameter. see qucs docs on microstrip lines.
    """
    return 0.564 * ((ep_r-0.9)/(ep_r+3.))**0.053

def f(u: NumberLike) -> NumberLike:
    """
    intermediary parameter. see qucs docs on microstrip lines.
    """
    return 6 + (2*pi-6)*exp(-(30.666/u)**0.7528)


# Path: skrf/tlineFunctions.py
# def skin_depth(f: NumberLike, rho: float, mu_r: float):
#     r"""
#     Skin depth for a material.
# 
#     The skin depth is calculated as:
# 
# 
#     .. math::
# 
#         \delta = \sqrt{\frac{ \rho }{ \pi f \mu_r \mu_0 }}
# 
#     See www.microwaves101.com [#]_ or wikipedia [#]_ for more info.
# 
#     Parameters
#     ----------
#     f : number or array-like
#         frequency, in Hz
#     rho : number of array-like
#         bulk resistivity of material, in ohm*m
#     mu_r : number or array-like
#         relative permeability of material
# 
#     Returns
#     -------
#     skin depth : number or array-like
#         the skin depth, in meter
# 
#     References
#     ----------
#     .. [#] https://www.microwaves101.com/encyclopedias/skin-depth
#     .. [#] http://en.wikipedia.org/wiki/Skin_effect
# 
#     See Also
#     --------
#     surface_resistivity
# 
#     """
#     return sqrt(rho/(pi*f*mu_r*mu_0))
# 
# def surface_resistivity(f: NumberLike, rho: float, mu_r: float):
#     r"""
#     Surface resistivity.
# 
#     The surface resistivity is calculated as:
# 
# 
#     .. math::
# 
#         \frac{ \rho }{ \delta }
# 
#     where :math:`\delta` is the skin depth from :func:`skin_depth`.
# 
#     See www.microwaves101.com [#]_ or wikipedia [#]_ for more info.
# 
#     Parameters
#     ----------
#     f : number or array-like
#         frequency, in Hz
#     rho : number or array-like
#         bulk resistivity of material, in ohm*m
#     mu_r : number or array-like
#         relative permeability of material
# 
#     Returns
#     -------
#     surface resistivity : number of array-like
#         Surface resistivity in ohms/square
# 
#     References
#     ----------
#     .. [#] https://www.microwaves101.com/encyclopedias/sheet-resistance
#     .. [#] https://en.wikipedia.org/wiki/Sheet_resistance
# 
#     See Also
#     --------
#     skin_depth
#     """
#     return rho/skin_depth(rho=rho, f=f, mu_r=mu_r)
# 
# Path: skrf/constants.py
# INF = 1e99
# ALMOST_ZERO = 1e-12
# ZERO = 1e-4
# ONE = 1.0 + 1/1e14
# LOG_OF_NEG = -100
# K_BOLTZMANN = 1.38064852e-23
# T0 = 290.
# S_DEFINITIONS = ['power', 'pseudo', 'traveling']
# S_DEF_DEFAULT = 'power'
# def to_meters(d: NumberLike, unit: str = 'm', v_g: float = c) -> NumberLike:


# Path: skrf/media/mline.py
import numpy as npy
from numpy import log, tanh, sqrt, exp, real, imag, cosh, \
                            ones, zeros, arctan
from scipy.constants import  epsilon_0, mu_0, c, pi
from .media import Media
from ..tlineFunctions import skin_depth, surface_resistivity
from ..constants import NumberLike
from typing import Union, TYPE_CHECKING
    from .. frequency import Frequency

        alpha_dielectric: calculates losses to dielectric
        beta            : calculates phase parameter
        """
        f = self.frequency.f
        alpha = zeros(len(f))
        beta  = zeros(len(f))
        beta  = self.beta_phase
        alpha = self.alpha_dielectric
        if self.rho is not None:
            alpha += self.alpha_conductor
        return alpha + 1j*beta

def a(u: NumberLike) -> NumberLike:
    """
    Intermediary parameter. see qucs docs on microstrip lines.
    """
    return 1. + 1./49.*log((u**4+(u/52)**2)/(u**4+0.432)) + 1./18.7*log(1+(u/18.1)**3)

def b(ep_r: NumberLike) -> NumberLike:
    """
    intermediary parameter. see qucs docs on microstrip lines.
    """
    return 0.564 * ((ep_r-0.9)/(ep_r+3.))**0.053

def f(u: NumberLike) -> NumberLike:
    """
    intermediary parameter. see qucs docs on microstrip lines.
    """
    return 6 + (2*pi-6)*exp(-(30.666/u)**0.7528)


def ZL1(w: NumberLike, h: NumberLike) -> NumberLike: