Exemplo n.º 1
0
def get_der_qln(l, nmax, nstop=100, zerolminus2=None, zerolminus1=None):
    """Returns the zeros of the spherical Bessel function derivative. Begins by
    assuming that the zeros of the spherical Bessel function for l lie exactly
    between the zeros of the Bessel function between l and l+1. This allows us
    to use scipy's jn_zeros function. However, this function fails to return for
    high n. To work around this we estimate the first 100 zeros using scipy's
    jn_zero function and then iteratively find the roots of the next zero by
    assuming the next zero occurs pi away from the last one. Brent's method is
    then used to find a zero between pi/2 and 3pi/2 from the last zero.

    Parameters
    ----------
    l : int
        Spherical Bessel function mode.
    nmax : int
        The maximum zero found for the spherical Bessel Function.
    nstop : int
        For n <= nstop we use scipy's jn_zeros to guess where the first nstop
        zeros are. These estimates are improved using Brent's method and assuming
        zeros lie between -pi/2 and pi/2 from the estimates.
    """
    if nmax <= nstop:
        nstop = nmax
    if zerolminus2 is None and zerolminus1 is None:
        z1 = special.jnp_zeros(l, nstop)
        z2 = special.jnp_zeros(l + 1, nstop)
        zeros_approx = np.ndarray.tolist(0.5 * (z1 + z2))
        zeros = []
        for i in range(0, len(zeros_approx)):
            a = zeros_approx[i] - 0.5 * np.pi
            b = zeros_approx[i] + 0.5 * np.pi
            val = optimize.brentq(get_der_jl, a, b, args=(l))
            zeros.append(val)
        if nstop != nmax:
            n = nstop
            while n < nmax:
                zero_last = zeros[-1]
                a = zero_last + 0.5 * np.pi
                b = zero_last + 1.5 * np.pi
                val = optimize.brentq(get_der_jl, a, b, args=(l))
                zeros.append(val)
                n += 1
    else:
        dz = zerolminus1 - zerolminus2
        z1 = zerolminus1 + 0.5 * dz
        z2 = zerolminus2 + 1.5 * dz
        zeros_approx = np.ndarray.tolist(0.5 * (z1 + z2))
        zeros = []
        for i in range(0, len(zeros_approx)):
            a = zeros_approx[i] - 0.5 * np.pi
            b = zeros_approx[i] + 0.5 * np.pi
            val = optimize.brentq(get_der_jl, a, b, args=(l))
            zeros.append(val)
    zeros = np.array(zeros)
    return zeros
Exemplo n.º 2
0
 def from_Z0(cls, frequency: 'Frequency', Z0: NumberLike,
             f: NumberLike, ep_r: NumberLike = 1, mu_r: NumberLike = 1, 
             **kwargs):
     r"""
     Initialize from specified impedance at a given frequency, assuming the 
     fundamental TE11 mode.
     
     Parameters
     ----------
     frequency : Frequency Object
     Z0 : number /array
         characteristic impedance to create at `f`
     f : number 
         frequency (in Hz) at which the resultant waveguide has the 
         characteristic impedance Z0
     ep_r : number, array-like,
         filling material's relative permittivity
     mu_r : number, array-like
         filling material's relative permeability
     \*\*kwargs : arguments, keyword arguments
         passed to :class:`~skrf.media.media.Media`'s constructor
         (:func:`~skrf.media.media.Media.__init__`            
     """
     
     mu = mu_0*mu_r
     ep = epsilon_0*ep_r
     w = 2*pi*f
     # if self.mode_type =="te":
     u = jnp_zeros(1, 1)[-1] 
     r =u/(w*mu) * 1./sqrt((1/(Z0*1j)**2+ep/mu))
     
     kwargs.update(dict(frequency=frequency, r=r, m=1, n=1, ep_r=ep_r, mu_r=mu_r))
     
     return cls(**kwargs)
Exemplo n.º 3
0
def alphaP_mn(m, n):
    alpha = sp.jnp_zeros(m, n)
    if m == 0:
        alpha = np.roll(alpha, 1)
        alpha[0] = 0

    return alpha[n - 1]
Exemplo n.º 4
0
def disk_harmonic_energy(n, m, bc='dirichlet'):
	'''Get the energy of a disk harmonic function.

	This allows for functions to sort a disk harmonic mode basis on energy.

	Parameters
	----------
	n : int
		Radial order
	m : int
		Azimuthal order
	bc : string
		The boundary conditions to use. This can be either 'dirichlet', or 
		'neumann' for a Dirichlet or Neumann boundary condition respectively.
	
	Returns
	-------
	scalar
		The energy corresponding to the mode.
	'''
	m = abs(m)

	if bc == 'dirichlet':
		lambda_mn = jn_zeros(m, n)[-1]
	elif bc == 'neumann':
		lambda_mn = jnp_zeros(m, n)[-1]
	else:
		raise RuntimeError('Boundary condition not recognized.')
	
	return lambda_mn**2
Exemplo n.º 5
0
def vangelderen_cylinder_perp_ln_terms(D, R, scheme, m_max=10):
    # returns the scaling factors and the list of each summation component for ln(M(DELTA,delta,G)/M(0))
    # D:= free diffusivity in m^2 s^-1
    # R:= cylinder radius in m
    # scheme is (N, 3) and contains all the (G, DELTA, delta)
    # G:= gradient magnitude in T m^-1
    # DELTA:= gradient separation in s
    # delta:= gradient width s

    am_R = jnp_zeros(1, m_max)[:, None]
    am = am_R / R
    am2 = am**2

    # unpack for clarity
    G = scheme[:, 0]
    DELTA = scheme[:, 1]
    delta = scheme[:, 2]

    # multiplicative factor for each scheme point
    fac = -2 * gamma**2 * G**2 / D**2

    # summation terms until m_max, for each scheme point
    comp = (1 / (am**6 * (am_R**2 - 1))) * (
        2 * D * am2 * delta - 2 + 2 * np.exp(-D * am2 * delta) +
        2 * np.exp(-D * am2 * DELTA) - np.exp(-D * am2 * (DELTA - delta)) -
        np.exp(-D * am2 * (DELTA + delta)))

    return fac, comp
Exemplo n.º 6
0
def compute_all_robin_roots(beta, n, roots):
    '''
    :param beta: f = beta*J_n(x) + dJ_n(x)/dn = 0 this is how Robin is posed here
    :param n: order of J_n
    :param roots: number of roots
    :return: np array with all the roots of f
    '''
    bessel_roots = ss.jn_zeros(n,roots)
    der_bessel_roots = ss.jnp_zeros(n,roots)
    result = np.zeros(roots)
    for k in range(0,roots):
        if (n == 0 and k == 0):
                result[k] = optimize.bisect(alpha_function, 0, bessel_roots[k], args=(n,beta))

        else:
            if (n == 0):
                result[k] = optimize.bisect(alpha_function, min(der_bessel_roots[k-1], bessel_roots[k]), max(der_bessel_roots[k-1], bessel_roots[k]), args=(n,beta))
            else:
                if (alpha_function(0,n,beta) == 0):
                    result[0] = 0
                    result[k] = optimize.bisect(alpha_function, min(der_bessel_roots[k - 1], bessel_roots[k - 1]),
                                                max(der_bessel_roots[k - 1], bessel_roots[k - 1]), args=(n, beta))
                else:
                    result[k] = optimize.bisect(alpha_function, min(der_bessel_roots[k], bessel_roots[k]), max(der_bessel_roots[k], bessel_roots[k]), args=(n,beta))
    return result
Exemplo n.º 7
0
    def kc(self) -> NumberLike:
        """
        Cut-off wave number.

        Defined as

        .. math::

                k_c = \\frac{u_{mn}}{R}

        where R is the radius of the waveguide, and u_mn is:

        * the n-th root of the m-th Bessel function for 'tm' mode
        * the n-th root of the Derivative of the m-th Bessel function for 'te' mode.

        Returns
        -------
        kc : number
            cut-off wavenumber
        """
        if self.mode_type == "te":
            u = jnp_zeros(self.m, self.n)[-1]
        elif self.mode_type == "tm":
            u = jn_zeros(self.m, self.n)[-1]
        return u / self.r
Exemplo n.º 8
0
def main(args):
    m = 5
    n = 5
    l = 5

    alpha = np.zeros((m, n))
    for i in range(m):
        alpha[i][:] = sp.jnp_zeros(i, 5)
        if i == 0:
            alpha[i][:] = np.roll(alpha[i][:], 1)
            alpha[i][0] = 0

    print alpha

    frqs = np.zeros((5, 5, 5))
    print "(m,n,l)"
    print "-" * 10

    for i_m in range(m):
        for i_n in range(n):
            for i_l in range(l):
                fr = nat_frq(alpha[i_m, i_n], i_l)
                frqs[i_m, i_n, i_l] = fr
                print "(" + str(i_m) + "," + str(i_n+1) + "," + str(i_l) + "): " + str(fr)



    return 0
Exemplo n.º 9
0
    def beta_pec(self, w, alpha):
        """Return phase constant of PEC waveguide

        Args:
            w: A complex indicating the angular frequency
            alpha: A tuple (pol, n, m) where pol is 'M' for TM mode or
                'E' for TE mode, n is the order of the mode, and m is the
                number of modes in the order and the polarization.
        Returns:
            h: A complex indicating the phase constant.
        """
        w_comp = w.real + 1j * w.imag
        pol, n, m = alpha
        if pol == "E":
            chi = jnp_zeros(n, m)[-1]
        elif pol == "M":
            chi = jn_zeros(n, m)[-1]
        else:
            raise ValueError("pol must be 'E' or 'M")
        val = np.sqrt(self.fill(w_comp) * w_comp**2 - chi**2 / self.r**2)
        if abs(val.real) > abs(val.imag):
            if val.real < 0:
                val *= -1
        else:
            if val.imag < 0:
                val *= -1
        return val
Exemplo n.º 10
0
def c2_pipe(r, t, Pe=10.**4, nmax=1000):
    # Calculates exact C2(r,t) in the pipe. Assumes t scalar.

    from scipy.special import jnp_zeros, j0, j1
    mu = jnp_zeros(0, nmax)
    Pe_fran = Pe / 2.

    c2 = zeros(shape(r))

    for n in range(nmax):
        c2 += (-24. + 6 * mu[n]**2 + 72 * mu[n]**2 * t - 9 * mu[n]**4 * t +
               6 * mu[n]**4 * r**2 * t) / (3 * mu[n]**8 * j0(mu[n])) * j0(
                   mu[n] * r)
        c2 += (24 - 24 * mu[n]**2 * t) / (3 * mu[n]**7 * j0(mu[n])) * r * j1(
            mu[n] * r)

        expterm = (-120 + 9 * mu[n]**2 + mu[n]**2 * r**2 +
                   mu[n]**4 * t) / (3 * mu[n]**8 * j0(mu[n])) * j0(mu[n] * r)
        expterm += (-2. - mu[n]**2 + mu[n]**2 * r**2) / (
            3 * mu[n]**7 * j0(mu[n])) * r * j1(mu[n] * r)
        c2 += exp(-mu[n]**2 * t) * expterm
    #
    c2 *= 4
    c2 += 1. / 5760. * (29. - 240. * t - 60 * r**2 + 15 * r**4 +
                        240 * r**2 * t)
    c2 *= Pe_fran**2
    #
    c2 += 2 * t

    return c2
Exemplo n.º 11
0
    def __init__(
        self,
        diameter=None,
        diffusion_constant=CONSTANTS['water_in_axons_diffusion_constant'],
        number_of_roots=20,
        number_of_functions=50,
    ):

        self.diameter = diameter
        self.Dintra = diffusion_constant
        self.alpha = np.empty((number_of_roots, number_of_functions))
        self.alpha[0, 0] = 0
        if number_of_roots > 1:
            self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1)
        for m in range(1, number_of_functions):
            self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
Exemplo n.º 12
0
def vangelderen_cylinder_perp_ln_terms_TAYLOR(D, R, scheme, m_max=10):
    # not going to bother changing the description, it's the same thing but every exponential inside the sum as been taylored (exp(-x) = 1 + x)
    # by doing so we can take out everything other then the bessel roots from the summation
    # DISCLAIMER, this computation is weirdly off by an exact factor of 2 from Neuman

    # returns the scaling factors and the list of each summation component for ln(M(DELTA,delta,G)/M(0))
    # D:= free diffusivity in m^2 s^-1
    # R:= cylinder radius in m
    # scheme is (N, 3) and contains all the (G, DELTA, delta)
    # G:= gradient magnitude in T m^-1
    # DELTA:= gradient separation in s
    # delta:= gradient width s

    xm = jnp_zeros(1, m_max)[:, None]

    # unpack for clarity
    G = scheme[:, 0]
    DELTA = scheme[:, 1]
    delta = scheme[:, 2]

    # multiplicative factor for each scheme point
    fac = -8 * gamma**2 * G**2 * R**4 / D

    # summation terms until m_max, for each scheme point
    comp = (1 / (xm**4 * (xm**2 - 1)))

    return fac, comp
Exemplo n.º 13
0
def ExactSolutionFull(m=1, n=0):
    kap = special.jnp_zeros(m, n + 1)[n]
    if m >= 1 and n >= 0:
        return lambda r, theta, z: special.jn(m, kap * r) * np.cos(
            m * theta) * (np.cosh(kap * (1.0 + z)) / np.cosh(kap))
    else:
        return lambda r, theta, z: 0
Exemplo n.º 14
0
    def from_Z0(cls, frequency, Z0, f, ep_r=1, mu_r=1, **kw):
        '''
        Initialize from specified impedance at a given frequency, assuming the 
        fundamental TE11 mode.
        
        Parameters
        -------------
        frequency : Frequency Object
        Z0 : number /array
            characteristic impedance to create at `f`
        f : number 
            frequency (in Hz) at which the resultant waveguide has the 
            characteristic impedance Z0
        '''

        mu = mu_0 * mu_r
        ep = epsilon_0 * ep_r
        w = 2 * pi * f
        # if self.mode_type =="te":
        u = jnp_zeros(1, 1)[-1]
        r = u / (w * mu) * 1. / sqrt((1 / (Z0 * 1j)**2 + ep / mu))

        kw.update(
            dict(frequency=frequency, r=r, m=1, n=1, ep_r=ep_r, mu_r=mu_r))

        return cls(**kw)
Exemplo n.º 15
0
def calc_te(n, m, freq, a):
    """Calculat mode in circular waveguide
    :param n: TE n
    :param m: TE m
    :param freq: frequency in Hz
    :param a: radius of circle waveguide in m
    :return: Er, Ephi, Hr, Hphi
    """
    wavelength = C0 / freq
    ds = wavelength / 3
    k = 2 * pi / wavelength

    # here I multiply 1.1 only to calculate more space.
    N = 3 * round(1.1 * a * 2 / ds) + 1
    x0 = np.linspace(-1.1 * a, 1.1 * a, N)
    x, y = np.meshgrid(x0, x0)

    pnm = jnp_zeros(n, m)
    pnm = pnm[m - 1]

    kc = pnm / a
    fc = C0 * kc / 2 / pi

    if freq < fc:
        raise Exception("This mode cannot spread!")

    beta = np.sqrt(k**2 - kc**2)
    w = 2 * pi * freq
    epsr = eps0 * 1

    A = 1
    B = 1

    phi, r = cart2pol(x, y)
    r[np.where(r == 0)] = ds / 100
    z = 0

    # Transverse Electric field
    Er = -1j * w * mue0 * n / kc / kc / r * (
        A * np.cos(n * phi) - B * np.sin(n * phi)) * jv(n, kc * r) * np.exp(
            -1j * beta * z)
    Ephi = 1j * w * mue0 / kc * (A * np.sin(n * phi) + B * np.cos(n * phi)
                                 ) * jvp(n, kc * r) * np.exp(-1j * beta * z)

    # Transverse Magnetic field
    Hr = -1j * beta / kc * (A * np.sin(n * phi) + B * np.cos(n * phi)) * jvp(
        n, kc * r) * np.exp(-1j * beta * z)
    Hphi = -1j * beta * n / kc / kc / r * (
        A * np.cos(n * phi) - B * np.sin(n * phi)) * jv(n, kc * r) * np.exp(
            -1j * beta * z)

    E_abs = np.hypot(np.abs(Er), np.abs(Ephi))
    E_abs[np.where(r > a)] = 1e-20

    # filename = 'TE{n},{m}.dat'.format(n=n, m=m)
    # E_abs.tofile(filename)
    print("Calculation Complete!")
    return Er, Ephi, Hr, Hphi
Exemplo n.º 16
0
def nj_dev(pr=0, m=31, n=11, deg=0):
    if deg == 0:
        x_mn = jn_zeros(m, n)[-1]
        func = jvp(m, x_mn, 0) * yvp(m, x_mn * pr, 0)
    elif deg == 1:
        x_mn = jnp_zeros(m, n)[-1]
        func = jvp(m, x_mn, 1) * yvp(m, x_mn * pr, 0)
    print(x_mn)
    return func
Exemplo n.º 17
0
    def __init__(
        self,
        mu=None, lambda_par=None,
        diameter=None,
        diffusion_perpendicular=CONSTANTS['water_in_axons_diffusion_constant'],
        number_of_roots=20,
        number_of_functions=50,
    ):
        self.mu = mu
        self.lambda_par = lambda_par
        self.diffusion_perpendicular = diffusion_perpendicular
        self.diameter = diameter

        self.alpha = np.empty((number_of_roots, number_of_functions))
        self.alpha[0, 0] = 0
        if number_of_roots > 1:
            self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1)
        for m in range(1, number_of_functions):
            self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
Exemplo n.º 18
0
 def __init__(self, n, p, a):
     self.n = n
     self.p = p
     self.a = a
     self.X_np = special.jn_zeros(n,p)[-1]
     self.dX_np = special.jnp_zeros(n,p)[-1]
     self.f_TE = 2 * self.Fc_TE()
     self.f_TM = 2 * self.Fc_TM()
     self.w_TE = 2 * PI * self.f_TE
     self.w_TM = 2 * PI * self.f_TM
Exemplo n.º 19
0
 def u_jnu_jnpu_pec(num_n, num_m):
     us = np.empty((2, num_n, num_m))
     jnus = np.empty((2, num_n, num_m))
     jnpus = np.empty((2, num_n, num_m))
     for n in range(num_n):
         us[0, n] = jnp_zeros(n, num_m)
         us[1, n] = jn_zeros(n, num_m)
         jnus[0, n] = jv(n, us[0, n])
         jnus[1, n] = np.zeros(num_m)
         jnpus[0, n] = np.zeros(num_m)
         jnpus[1, n] = jvp(n, us[1, n])
     return us, jnus, jnpus
Exemplo n.º 20
0
def disk_harmonic(n, m, D=1, bc='dirichlet', grid=None):
	'''Create a disk harmonic.

	Parameters
	----------
	n : int
		Radial order
	m : int
		Azimuthal order
	D : scalar
		The diameter of the pupil.
	bc : string
		The boundary conditions to use. This can be either 'dirichlet', or
		'neumann' for a Dirichlet or Neumann boundary condition respectively.
	grid : Grid
		The grid on which to evaluate the function.

	Returns
	-------
	Field
		The disk harmonic function evaluated on `grid`.

	Raises
	------
	ValueError
		If the boundary condition is not recognized.
	'''
	polar_grid = grid.as_('polar')
	r = 2 * polar_grid.r / D
	theta = polar_grid.theta

	m_negative = m < 0
	m = abs(m)

	if bc == 'dirichlet':
		lambda_mn = jn_zeros(m, n)[-1]
		norm = 1
	elif bc == 'neumann':
		lambda_mn = jnp_zeros(m, n)[-1]
		norm = 1
	else:
		raise ValueError('Boundary condition not recognized.')

	if m_negative:
		z = norm * jv(m, lambda_mn * r) * np.sin(m * theta)
	else:
		z = norm * jv(m, lambda_mn * r) * np.cos(m * theta)

	# Do manual normalization for now...
	mask = circular_aperture(D)(grid) > 0.5
	norm = np.sqrt(np.sum(z[mask]**2))

	return Field(z * mask / norm, grid)
Exemplo n.º 21
0
def vangelderen_cylinder_perp_ln_list(D, R, DELTA, delta, G, m_max=10):
    # returns the scaling factor and the list of each summation component for ln(M(DELTA,delta,G)/M(0))
    # D:= free diffusivity in m^2 s^-1
    # R:= cylinder radius in m
    # DELTA:= gradient separation in s
    # delta:= gradient width s
    # G:= gradient magnitude in T m^-1
    am_R = jnp_zeros(1,m_max)
    am = am_R / R
    am2 = am**2
    fac = -2*gamma**2*G**2/D**2
    comp = (1/(am**6*(am_R**2-1))) * (2*D*am2*delta - 2 + 2*np.exp(-D*am2*delta) + 2*np.exp(-D*am2*DELTA) - np.exp(-D*am2*(DELTA-delta)) - np.exp(-D*am2*(DELTA+delta)))
    return fac, comp
Exemplo n.º 22
0
 def __init__(self,a,H,e2,p=1,f=None,mode="TE"):
     self.mode=mode
     if mode=='TE':
         self.Xmn=spl.jnp_zeros(0,1)[0]
     elif mode=='TM':
         self.Xmn=spl.jn_zeros(0,1)[0]
     else:
         raise ValueError("mode must be either 'TE' or 'TM'" )
     self.a=a
     self.H=H
     self.e2=e2
     self.p=p
     self.f=f
     self.err=0
Exemplo n.º 23
0
def m2_pipe(t, Pe=10.**4, nmax=1000, m20=0.):
    # Calculates exact M2 in the pipe. Optional
    # initial M2(t=0), m20 included.
    from scipy.special import jnp_zeros

    mu = jnp_zeros(0, nmax)
    Pe_fran = Pe / 2.

    m2 = m20 + 2. * t + Pe_fran**2 * (-1. / 1440. + 1. / 96. * t)

    for n in range(nmax):
        m2 += Pe_fran**2 * 32. * (exp(-(mu[n]**2) * t) / (mu[n]**8))
    # end for

    return m2
Exemplo n.º 24
0
def c1_pipe(r, t, Pe=10.**4, nmax=1000):
    # Calculates exact C1(r,t) in the pipe. Assumes t scalar.

    from scipy.special import jnp_zeros, j0
    mu = jnp_zeros(0, nmax)
    Pe_fran = Pe / 2.

    c1 = zeros(shape(r))

    for n in range(nmax):
        c1 += 1. / (j0(mu[n]) *
                    mu[n]**4) * (1. - exp(-mu[n]**2 * t) * j0(mu[n] * r))
    #
    c1 *= -4 * Pe_fran

    return c1
Exemplo n.º 25
0
def coaxial_wg_tm_mn(mesh, m=31, n=11, phi=90.0, radi_a=0.0, radi_b=25.0):
    x, y = mesh[0], mesh[1]
    r, t = np.sqrt(x**2 + y**2), np.arctan(y / x)
    a, b = radi_a, radi_b

    x0_mn = jn_zeros(m, n)[-1]
    x1_mn = jnp_zeros(m, n)[-1]

    if m == 0:
        e_m = 1
    else:
        e_m = 2

    func = np.sqrt(e_m / np.pi)
    func *= 1 / np.abs(jvp(m + 1, x0_mn))
    func *= (-jvp(m, x0_mn * r / b, 0) * np.cos(m * t) +
             m / x0_mn * jvp(m, x0_mn * r / b, 0) / r * np.sin(m * t))
    return func
Exemplo n.º 26
0
def circle_wg_te_mn(mesh, m=31, n=11, phi=90.0, radi=25.0):
    x, y = mesh[0], mesh[1]
    r, t = np.sqrt(x**2 + y**2), np.arctan(y / x)
    b = radi

    x0_mn = jn_zeros(m, n)[-1]
    x1_mn = jnp_zeros(m, n)[-1]

    if m == 0:
        e_m = 1
    else:
        e_m = 2

    func = np.sqrt(e_m / np.pi)
    func *= 1 / (np.sqrt(x1_mn**2 - m**2) * np.abs(jvp(m + 1, x0_mn)))
    func *= (-m * jvp(m, x1_mn * r / b, 0) / r * np.cos(m * t) +
             x1_mn * jvp(m, x1_mn * r / b, 1) / b * np.sin(m * t))
    return func
Exemplo n.º 27
0
def m3_pipe(t, Pe=10.**4, nmax=1000, m30=0.):
    # Calculates exact M3 in the pipe. Optional
    # initial M3(t=0), m30 included.

    from scipy.special import jnp_zeros

    mu = jnp_zeros(0, nmax)
    Pe_fran = Pe / 2.

    m3 = 1. / 480. * (-17. / 896. + 112. / 896. * t)
    for n in range(nmax):
        m3 += 16. * exp(-(mu[n]**2) * t) * (-240. / (mu[n]**12) + 18. /
                                            (mu[n]**10) + t / (mu[n]**8))
    # end for

    m3 *= Pe_fran**3

    return m3
Exemplo n.º 28
0
 def norm(self, w, h, alpha, a, b):
     pol, n, m = alpha
     en = 1 if n == 0 else 2
     if self.clad(w).real < -1e6:
         radius = self.r
         if pol == 'E':
             u = jnp_zeros(n, m)[-1]
             jnu = jv(n, u)
             jnpu = 0.0
         else:
             u = jn_zeros(n, m)[-1]
             jnu = 0.0
             jnpu = jvp(n, u)
         return np.sqrt(a**2 * np.pi * radius**2 / en *
                        (1 - n**2 / u**2) * jnu**2 +
                        b**2 * np.pi * radius**2 / en * jnpu**2)
     # ac = a.conjugate()
     # bc = b.conjugate()
     u = self.samples.u(h**2, w, self.fill(w))
     jnu = jv(n, u)
     jnpu = jvp(n, u)
     v = self.samples.v(h**2, w, self.clad(w))
     knv = kv(n, v)
     knpv = kvp(n, v)
     # uc = u.conjugate()
     # jnuc = jnu.conjugate()
     # jnpuc = jnpu.conjugate()
     # vc = v.conjugate()
     # knvc = knv.conjugate()
     # knpvc = knpv.conjugate()
     val_u = 2 * np.pi * self.r**2 / en
     val_v = val_u * ((u * jnu) / (v * knv))**2
     # val_v = val_u * (uc * u * jnuc * jnu) / (vc * v * knvc * knv)
     upart_diag = self.upart_diag(n, u, jnu, jnpu, u, jnu, jnpu)
     vpart_diag = self.vpart_diag(n, v, knv, knpv, v, knv, knpv)
     upart_off = self.upart_off(n, u, jnu, u, jnu)
     vpart_off = self.vpart_off(n, v, knv, v, knv)
     return np.sqrt(val_u * (a * (a * upart_diag + b * upart_off) + b *
                             (b * upart_diag + a * upart_off)) - val_v *
                    (a * (a * vpart_diag + b * vpart_off) + b *
                     (b * vpart_diag + a * vpart_off)))
Exemplo n.º 29
0
    def _ncrs_python(self, Delta, delta, d, R, G):
        if R == 0 or R < np.finfo(float).eps:
            return 0

        GAMMA = 267.5987E6
        alpha_roots = jnp_zeros(1, 16) / R

        sum = 0
        for i in range(20):
            alpha = alpha_roots[i]

            num = (2 * d * alpha**2 * delta - 2 +
                   2 * np.exp(-d * alpha**2 * delta) +
                   2 * np.exp(-d * alpha**2 * Delta) -
                   np.exp(-d * alpha**2 * (Delta - delta)) -
                   np.exp(-d * alpha**2 * (Delta + delta)))
            dem = d**2 * alpha**6 * (R**2 * alpha**2 - 1)

            sum += (num / dem)

        return -2 * GAMMA**2 * G**2 * sum
Exemplo n.º 30
0
def main(args):
    m = 5
    n = 5
    x = 5

    alpha = np.zeros((m, n))
    for i in range(m):
        alpha[i][:] = sp.jnp_zeros(i, 5)
        if i == 0:
            alpha[i][:] = np.roll(alpha[i][:], 1)
            alpha[i][0] = 0

    print alpha

    frqs = np.zeros((5, 5, 5))
    print "(m,n,l)"
    print "-" * 10

    for i_m in range(m):
        for i_n in range(n):
            for i_x in range(x):
                i_l = i_x * 2 + 1

                frqs[i_m, i_n, i_x] = nat_frq(alpha[i_m, i_n], i_l)

    B = np.sort(frqs, axis=None)

    print "Minima"
    print "-" * 10

    for i_m in range(m):
        for i_n in range(n):
            for i_x in range(x):
                if frqs[i_m, i_n, i_x] in B[:5]:
                    i_l = i_x * 2 + 1
                    print "(" + str(i_m) + "," + str(i_n + 1) + "," + str(
                        i_l) + "): " + str(frqs[i_m, i_n, i_x])

    return 0