Example #1
0
    wave = cnt.c / freq * convert(unit_in="m", unit_out="mm")

    px = np.linspace(-1, 1, opt.nxy[0]) * opt.lxy / 2
    py = np.linspace(-1, 1, opt.nxy[1]) * opt.lxy / 2
    mesh = np.meshgrid(px, py)
    x, y = mesh[0], mesh[1]
    r, t = np.sqrt(x**2 + y**2), np.arctan(y / x)
    m, n = opt.mn
    a, b = opt.radi

    pr = np.linspace(10, 50, 1000)
    m = 5
    n = 10
    print(jn_zeros(m, n)[-1])
    print(jnp_zeros(m, n)[-1])
    print(yn_zeros(m, n)[-1])
    print(ynp_zeros(m, n)[-1])

    x0_mn_1 = jn_zeros(m, 5)[-1]
    x1_mn_1 = jnp_zeros(m, 5)[-1]
    x0_mn_2 = jn_zeros(m, 7)[-1]
    x1_mn_2 = jnp_zeros(m, 7)[-1]

    d_1 = jvp(m, pr, 0) * yvp(m, x1_mn_1, 1) - \
        yvp(m, pr, 0) * jvp(m, x1_mn_1, 1)
    d_2 = jvp(m, pr, 0) * yvp(m, x1_mn_2, 1) - \
        yvp(m, pr, 0) * jvp(m, x1_mn_2, 1)

    plt.figure()
    plt.plot(pr, d_1)
    plt.plot(pr, d_2)
        txt = "{:d}".format(nth)
        txt += "\t{:.2f}\t{:.2f}\t{:.2f}".format(val, jn(0, val), jn(1, val))
        print(txt)
    for nth, val in enumerate(jn_zeros(2, 5)):
        txt = "{:d}".format(nth)
        txt += "\t{:.2f}\t{:.2f}\t{:.2f}".format(val, jn(0, val), jn(1, val))
        txt += "\t{:.2f}".format(jn(2, val))
        print(txt)
    """Compute zeros of integer-order Bessel function derivative Jn'(x).
    """
    print(jnp_zeros(0, 5))
    print(jnp_zeros(1, 5))
    print(jnp_zeros(2, 5))
    """Compute zeros of integer-order Bessel function Yn(x).
    """
    print(yn_zeros(0, 5))
    print(yn_zeros(1, 5))
    print(yn_zeros(2, 5))
    """Compute zeros of integer-order Bessel function derivative Yn'(x).
    """
    print(ynp_zeros(0, 5))
    print(ynp_zeros(1, 5))
    print(ynp_zeros(2, 5))
    """Compute zeros of integer-order Bessel functions Jn and Jn'.

    Parameters
    ----------
    nt : int
        Number (<=1200) of zeros to compute

    Returns
Example #3
0
    px = np.linspace(-1, 1, opt.nxy[0]) * opt.lxy / 2
    py = np.linspace(-1, 1, opt.nxy[1]) * opt.lxy / 2
    mesh = np.meshgrid(px, py)
    x, y = mesh[0], mesh[1]
    r, t = np.sqrt(x**2 + y**2), np.arctan(y / x)
    m, n = opt.mn
    a, b = opt.radi

    pr = np.linspace(20, 100.0, 1000)
    r0 = np.linspace(0.2, 1, 1000)
    m = 31
    n = 5
    print(jn_zeros(m, n))
    print(jnp_zeros(m, n))
    print(yn_zeros(m, n))
    print(ynp_zeros(m, n))

    plt.figure()
    #plt.plot(pr, jn_dev(r0, 37, 12, 0) - nj_dev(r0, 37, 12, 0))
    plt.plot(pr, jn_dev(r0, 31, 10, 0) - nj_dev(r0, 31, 10, 0))
    plt.plot(pr, jn_dev(r0, 31, 11, 0) - nj_dev(r0, 31, 11, 0))
    plt.xlim(0, 100)
    plt.ylim(-0.025, 0.025)
    plt.grid()

    plt.figure()
    #plt.plot(pr, jn_dev(r0, 37, 12, 1) - nj_dev(r0, 37, 12, 1))
    plt.plot(pr, jn_dev(r0, 31, 10, 1) - nj_dev(r0, 31, 10, 1))
    plt.plot(pr, jn_dev(r0, 31, 11, 1) - nj_dev(r0, 31, 11, 1))
    plt.grid()
Example #4
0
@author: shiyanlou
"""

# %matplotlib qt
from scipy import linspace
from scipy.special import jn, yn, jn_zeros, yn_zeros
import matplotlib.pyplot as plt

n = 0
x = 0.0
# Bessel function of first kind
print "J_%d(%f) = %f" % (n, x, jn(n, x))

x = 1.0
# Bessel function of second kind
print "Y_%d(%f) = %f" % (n, x, yn(n, x))

x = linspace(0, 10, 100)

fig, ax = plt.subplots()
for n in range(4):
    ax.plot(x, jn(n, x), label=r"$J_%d(x)$" % n)
ax.legend()

fig.show()

n = 0
m = 4
print jn_zeros(n, m)
print yn_zeros(n, m)