Ejemplo n.º 1
0
def test_diff():
    assert besselj(n, z).diff(z) == besselj(n - 1, z)/2 - besselj(n + 1, z)/2
    assert bessely(n, z).diff(z) == bessely(n - 1, z)/2 - bessely(n + 1, z)/2
    assert besseli(n, z).diff(z) == besseli(n - 1, z)/2 + besseli(n + 1, z)/2
    assert besselk(n, z).diff(z) == -besselk(n - 1, z)/2 - besselk(n + 1, z)/2
    assert hankel1(n, z).diff(z) == hankel1(n - 1, z)/2 - hankel1(n + 1, z)/2
    assert hankel2(n, z).diff(z) == hankel2(n - 1, z)/2 - hankel2(n + 1, z)/2
Ejemplo n.º 2
0
def test_diff():
    assert besselj(n, z).diff(z) == besselj(n - 1, z)/2 - besselj(n + 1, z)/2
    assert bessely(n, z).diff(z) == bessely(n - 1, z)/2 - bessely(n + 1, z)/2
    assert besseli(n, z).diff(z) == besseli(n - 1, z)/2 + besseli(n + 1, z)/2
    assert besselk(n, z).diff(z) == -besselk(n - 1, z)/2 - besselk(n + 1, z)/2
    assert hankel1(n, z).diff(z) == hankel1(n - 1, z)/2 - hankel1(n + 1, z)/2
    assert hankel2(n, z).diff(z) == hankel2(n - 1, z)/2 - hankel2(n + 1, z)/2
Ejemplo n.º 3
0
def test_bessel_rand():
    assert td(besselj(randcplx(), z), z)
    assert td(bessely(randcplx(), z), z)
    assert td(besseli(randcplx(), z), z)
    assert td(besselk(randcplx(), z), z)
    assert td(hankel1(randcplx(), z), z)
    assert td(hankel2(randcplx(), z), z)
    assert td(jn(randcplx(), z), z)
    assert td(yn(randcplx(), z), z)
Ejemplo n.º 4
0
def test_bessel_rand():
    assert td(besselj(randcplx(), z), z)
    assert td(bessely(randcplx(), z), z)
    assert td(besseli(randcplx(), z), z)
    assert td(besselk(randcplx(), z), z)
    assert td(hankel1(randcplx(), z), z)
    assert td(hankel2(randcplx(), z), z)
    assert td(jn(randcplx(), z), z)
    assert td(yn(randcplx(), z), z)
Ejemplo n.º 5
0
    def __init__(self, intens=None, puls=None, phas=None):
        # Célérité des ondes ; à modifier en fonction du milieu
        self.cel = 3e8
        # Composante du potentiel vecteur associée à la pulsation omega
        self.A_component = sp.I * mu * Ic / 4 * sp.hankel2(0, k * r) * sp.exp(
            sp.I * omega * t)
        # Composante du champ magnétique associée à la pulsation omega
        self.B_component = -sp.diff(self.A_component, r).simplify()

        # Conversion de fonctions formelles à fonctions numériques
        self.impl_modules = ['numpy', {"hankel2": spec.hankel2}]

        if intens is not None:
            if phas is not None:
                intens = np.asarray(intens) * np.exp(1j * np.asarray(phas))
            self.pulsations = np.array(puls)
            self.frequences = puls / (2 * np.pi)

            c0 = self.cel
            mu0_v = 4e-7 * np.pi

            spectral_data = zip(intens, puls)
            cmp = sp.re(self.B_component).subs({c: c0, mu: mu0_v})

            orthExpr = sum(
                cmp.subs({Ic: cur, omega:om}) \
                for (cur,om) in spectral_data if (cur!=0 and om!=0))

            orthFunc = sp.lambdify((r, t), orthExpr, modules=self.impl_modules)

            self.orthExpr = orthExpr
            self.orthFunc = orthFunc
            self.vorthFunc = np.vectorize(orthFunc)

            # Fonctions en cartésien
            rxy = sp.sqrt(x**2 + y**2)

            self.orthFuncCart = sp.lambdify((x, y, t),
                                            orthExpr.subs({r: rxy}),
                                            modules=self.impl_modules)
            self.vorthFuncCart = np.vectorize(self.orthFuncCart)

            self.fieldExpr = (-y * Cart.i + x * Cart.j) * orthExpr.subs(
                {r: rxy}) / rxy
            self.fieldFunc = sp.lambdify((x, y, t),
                                         self.fieldExpr.to_matrix(Cart),
                                         modules=self.impl_modules)
Ejemplo n.º 6
0
def test_meromorphic():
    assert besselj(2, x).is_meromorphic(x, 1) == True
    assert besselj(2, x).is_meromorphic(x, 0) == True
    assert besselj(2, x).is_meromorphic(x, oo) == False
    assert besselj(S(2) / 3, x).is_meromorphic(x, 1) == True
    assert besselj(S(2) / 3, x).is_meromorphic(x, 0) == False
    assert besselj(S(2) / 3, x).is_meromorphic(x, oo) == False
    assert besselj(x, 2 * x).is_meromorphic(x, 2) == False
    assert besselk(0, x).is_meromorphic(x, 1) == True
    assert besselk(2, x).is_meromorphic(x, 0) == True
    assert besseli(0, x).is_meromorphic(x, 1) == True
    assert besseli(2, x).is_meromorphic(x, 0) == True
    assert bessely(0, x).is_meromorphic(x, 1) == True
    assert bessely(0, x).is_meromorphic(x, 0) == False
    assert bessely(2, x).is_meromorphic(x, 0) == True
    assert hankel1(3, x**2 + 2 * x).is_meromorphic(x, 1) == True
    assert hankel1(0, x).is_meromorphic(x, 0) == False
    assert hankel2(11, 4).is_meromorphic(x, 5) == True
    assert hn1(6, 7 * x**3 + 4).is_meromorphic(x, 7) == True
    assert hn2(3, 2 * x).is_meromorphic(x, 9) == True
    assert jn(5, 2 * x + 7).is_meromorphic(x, 4) == True
    assert yn(8, x**2 + 11).is_meromorphic(x, 6) == True
Ejemplo n.º 7
0
    numerator = 2*besselj(1, ka_sintheta).evalf()#2*bessel_firstkind(1, ka_sintheta)

    try:
        rp_theta = np.abs(numerator/ka_sintheta)
    except:
        rp_theta = 0
    return rp_theta


##### Vibrating cap on sphere
Wn, Pn, h2n, h2n_prime, theta, w0, n, theta0, k, R, H_theta, kR = symbols(
        'Wn Pn h2n h2n_prime theta w0 n theta0 k R H_theta kR')
# take equation 6 to define Wn now
Wn = 0.5 * w0 * (legendre(n - 1, cos(theta0)) - legendre(n + 1, cos(theta0)))

h2n = hankel2(n, kR)
# h2n_prime_term = diff(hankel2(n, k*R), k*R)
h2n_prime_term = diff(h2n, kR)

# equation 23
common_term = ((I ** n) * Wn) / h2n_prime_term
denominator = summation(common_term, (n, 0, 20))

numerator_term = common_term * legendre(n, cos(theta))
numerator = summation(numerator_term, (n, 0, 20))

H_theta = Abs(numerator / denominator)

calc_H_theta = lambdify((theta, k, R, theta0, kR,w0), H_theta)

def vibrating_cap_of_sphere(theta, k, **kwargs):
Ejemplo n.º 8
0
def dispeq_gyrotropic_cylindersArrayFull(N_max, w_01, a_0, ee, cylXY, k, p, EE, GG, HH, c, ):
    m = list(range(-N_max, N_max + 1, 1))
    if N_max == 0:
        m = 0

    nu = m
    w = w_01
    k0 = w / c
    q = cmath.sqrt(1 - p **2)
    # q = q * (2 * ((q.imag) <= 0) - 1)
    Q = k0 * a_0 * q

    # вычисляем элементы матрицы рассеяния для внутренней области цилиндра
    mainq = EE ** 2 - GG ** 2 + EE * HH - (HH + EE) * p ** 2
    F=cmath.sqrt(EE*GG**2*HH*(GG**2-(HH-EE)**2))
    Pb=cmath.sqrt(EE-(HH+EE)*GG**2/(HH-EE)**2-2*F/(HH-EE)**2)
    Pc=cmath.sqrt(EE-(HH+EE)*GG**2/(HH-EE)**2+2*F/(HH-EE)**2)
    #radq = math.sqrt((HH - EE) ** 2 * p **4 + 2 * ((GG ** 2)*(HH + EE) - EE * (HH - EE) **2) * p **2 +(EE ** 2 - GG ** 2 - EE * HH) ** 2)
    radq = -(HH-EE)*cmath.sqrt((p**2-Pb**2)*(p**2-Pc**2))
    q1 = cmath.sqrt(0.5 * (mainq - radq) / EE)
    q2 = cmath.sqrt(0.5 * (mainq + radq) / EE)

    n1 = -(EE / (p * GG) ) * (p ** 2 + q1 ** 2 + (GG ** 2)/EE - EE)
    n2 = -(EE / (p * GG) ) * (p ** 2 + q2 ** 2 + (GG ** 2)/EE - EE)

    alp1 = -1 + (p ** 2 + q1 ** 2 - EE) / GG
    alp2 = -1 + (p ** 2 + q2 ** 2 - EE) / GG

    bet1 = 1 + p / n1
    bet2 = 1 + p / n2
#что делать с Q она мнимая, брать действительную или мнимую часть?
    Q1 = (q1 * a_0) * k0
    Q2 = (q2 * a_0) * k0
    mMax = 2 * N_max + 1
    JM = np.zeros(((3, 31)), dtype=np.complex)
    n=0
    for per in range(-N_max,N_max+1,1):
        JM[n][0] = besselj(per + 1, Q1) #JM1
        JM[n][1] = besselj(per + 1, Q2) #JM2
        JM[n][2]= besselj(per, Q1)  #Jm1
        JM[n][3]= besselj(per, Q2)  #Jm2
        JM[n][4]= JM[n][per + 2] / Q1  #Jm1_Q1
        JM[n][5]= JM[n][per + 3]/ Q2  #Jm2_Q2

        JM[n][6]= (((1j / HH) * n1) * q1) * JM[n][per + 2]  #Ez1
        JM[n][7] = (((1j / HH) * n2) * q2) * JM[n][per + 3] #Ez2
        JM[n][8] = 1j * (JM[n][per] + (alp1 * per) * JM[n][per + 4])  #Ephi1
        JM[n][9]= 1j * (JM[n][per+1] + (alp2 * per) *JM[n][per + 5] )  #Ephi2
        JM[n][10]= - q1 * JM[n][per + 2]  #Hz1
        JM[n][11]= - q2 * JM[n][per + 3]  #Hz2
        JM[n][12] = - n1 * (JM[n][per] - (bet1 * per) * JM[n][per + 4])  #Hphi1
        JM[n][13]= - n2 * (JM[n][per+1] - (bet2 * per) * JM[n][per + 5])  #Hphi2

        # вычисляем элементы матрицы рассеяния для внешней области цилиндра

        JM[n][14] = hankel2(per, Q)  #H2m
        JM[n][15]= -(JM[n][per + 14]/ Q)* per + hankel2(per + 1, Q)  #dH2m
        #Jm_out = besselj(m, Q)
        #dJm_out = Jm_out * m / Q - besselj(m + 1, Q)

        JM[n][16] =-1j * q * JM[n][per + 14]  #Ez_sct
        JM[n][17]= q * JM[n][per + 14]  #Hz_sct

        A = 1 / (k0 * (1 - p ^ 2))
        JM[n][18] = -1j*q * (A * ((p * (per / a_0)) * JM[n][per + 14])) #Ephi_sctE
        JM[n][19]= 1j*q * (A * (k0 * q * JM[n][per + 15])) #Ephi_sctH
        JM[n][20]= q * (A * ((p * (per / a_0)) * JM[n][per + 14])) #Hphi_sctH
        JM[n][21] = -q * (A * (k0 * q * JM[n][per + 15])) #Hphi_sctE
        n = n + 1
    matrixGS = np.zeros(((mMax*4*2, mMax*4*2)), dtype=np.complex)
    for jj in range(0, 2):
        for jm in range(1,  4, 1):
            for ll in range(0, 2):
                for jnu in range(1, 4, 1):
                    jmmm = (jm - 1) * 4+1
                    jnunu = (jnu - 1) * 4+1
                        # спросить про проход ведь будет совпадение номеров
                    if jj == ll:
                        if jm == jnu:
                                matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax] = JM[jm + 1][6]  # Ez1
                                matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 1] = JM[jm + 1][7]  # Ez2(jm)
                                matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 2] = JM[jm + 1][16]  # Ez_sct(jm)
                                matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 3] = 0

                                matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax] = JM[jm + 1][10]  # Hz1
                                matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 1] = JM[jm + 1][11]  # Hz2
                                matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 2] = 0
                                matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 3] = - JM[jm + 1][17]  # -Hz_sct

                                matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax] = JM[jm + 1][8]  # Ephi1
                                matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 1] = JM[jm + 1][9]  # Ephi2
                                matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 2] = -JM[jm + 1][18]  # -Ephi_sctE
                                matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 3] = -JM[jm + 1][19]  # -Ephi_sctH

                                matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax] = JM[jm + 1][12]  # Hphi1
                                matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 1] = JM[jm + 1][13]  # Hphi2
                                matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 2] = -JM[jm + 1][21]  # -Hphi_sctE
                                matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 3] = -JM[jm + 1][20]  # -Hphi_sctH
                    else:
                        Ljl = float(math.sqrt((cylXY[jj , 0] - cylXY[ll , 0]) ** 2 + (cylXY[jj , 1] - cylXY[ll , 1]) ** 2))

                        thetaIJ =float(math.atan(abs(cylXY[jj , 1] - cylXY[ll , 1]) / abs(cylXY[jj , 0] - cylXY[ll , 0])))

                        if ((cylXY[jj , 0] - cylXY[ll , 0]) <= 0 and (cylXY[jj , 1] - cylXY[ll , 1]) > 0):
                            thetaIJ = cmath.pi - thetaIJ
                        elif ((cylXY[jj , 0] - cylXY[ll , 0]) <= 0 and (cylXY[jj, 1] - cylXY[ll , 1]) <= 0):
                            thetaIJ = cmath.pi + thetaIJ
                        elif ((cylXY[jj , 1] - cylXY[ll , 1]) <= 0 and (cylXY[jj, 0] - cylXY[ll , 0]) > 0):
                            thetaIJ = 2 * cmath.pi - thetaIJ

                        JM[jnu - 1][22] = -cmath.exp(-1j * (nu[jnu - 1] - m[jm - 1]) * thetaIJ) ** hankel2((m[jm - 1] - nu[jnu - 1]), k0 * q * Ljl)

                        JM[jnu - 1][23] = besselj(m[jnu - 1], Q)  # Jm_out
                        JM[jnu - 1][24] = -JM[jnu - 1][23] * m[jnu - 1] / Q + besselj(m[jnu - 1] + 1, Q)  # dJm_out
                        # спросить почему они одинаковые?
                        JM[jnu - 1][25] = JM[jnu - 1][22] * JM[jnu - 1][23]  # Ez_inc
                        JM[jnu - 1][26] = JM[jnu - 1][22] * JM[jnu - 1][23]  # Hz_inc

                        A = 1 / (k0 * (1 - p ** 2))
                        JM[jnu - 1][27] = - JM[jnu - 1][22] * (
                        A * ((p * (m[jnu - 1] / a_0)) * JM[jnu - 1][23]))  # Ephi_incE
                        JM[jnu - 1][28] = - JM[jnu - 1][22] * (A * (- 1j * k0 * q * JM[jnu - 1][24]))  # Ephi_incH
                        JM[jnu - 1][29] = - JM[jnu - 1][22] * (A * (1j * k0 * q * JM[jnu - 1][24]))  # Hphi_incE
                        JM[jnu - 1][30] = -JM[jnu - 1][22] * (A * ((p * (m[jnu - 1] / a_0)) * JM[jnu - 1][23]))


                        matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax] = 0
                        matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 1] = 0
                        matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 2] = JM[jm + 1][25]  # Ez_inc
                        matrixGS[jmmm + jj * 4 * mMax, jnunu + ll * 4 * mMax + 3] = 0

                        matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 1] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 2] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 1, jnunu + ll * 4 * mMax + 3] = JM[jm + 1][25]  # Hz_inc

                        matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 1] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 2] = JM[jm + 1][ 27]  # Ephi_incE
                        matrixGS[jmmm + jj * 4 * mMax + 2, jnunu + ll * 4 * mMax + 3] = JM[jm + 1][28]  # Ephi_incH

                        matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 1] = 0
                        matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 2] = JM[jm + 1][29]  # Hphi_incE
                        matrixGS[jmmm + jj * 4 * mMax + 3, jnunu + ll * 4 * mMax + 3] = JM[jm + 1][30]  # Hphi_incH

    return abs(np.linalg.det(matrixGS))
Ejemplo n.º 9
0
def test_conjugate():
    n = Symbol('n')
    z = Symbol('z', extended_real=False)
    x = Symbol('x', extended_real=True)
    y = Symbol('y', real=True, positive=True)
    t = Symbol('t', negative=True)

    for f in [besseli, besselj, besselk, bessely, hankel1, hankel2]:
        assert f(n, -1).conjugate() != f(conjugate(n), -1)
        assert f(n, x).conjugate() != f(conjugate(n), x)
        assert f(n, t).conjugate() != f(conjugate(n), t)

    rz = randcplx(b=0.5)

    for f in [besseli, besselj, besselk, bessely]:
        assert f(n, 1 + I).conjugate() == f(conjugate(n), 1 - I)
        assert f(n, 0).conjugate() == f(conjugate(n), 0)
        assert f(n, 1).conjugate() == f(conjugate(n), 1)
        assert f(n, z).conjugate() == f(conjugate(n), conjugate(z))
        assert f(n, y).conjugate() == f(conjugate(n), y)
        assert tn(f(n, rz).conjugate(), f(conjugate(n), conjugate(rz)))

    assert hankel1(n, 1 + I).conjugate() == hankel2(conjugate(n), 1 - I)
    assert hankel1(n, 0).conjugate() == hankel2(conjugate(n), 0)
    assert hankel1(n, 1).conjugate() == hankel2(conjugate(n), 1)
    assert hankel1(n, y).conjugate() == hankel2(conjugate(n), y)
    assert hankel1(n, z).conjugate() == hankel2(conjugate(n), conjugate(z))
    assert tn(hankel1(n, rz).conjugate(), hankel2(conjugate(n), conjugate(rz)))

    assert hankel2(n, 1 + I).conjugate() == hankel1(conjugate(n), 1 - I)
    assert hankel2(n, 0).conjugate() == hankel1(conjugate(n), 0)
    assert hankel2(n, 1).conjugate() == hankel1(conjugate(n), 1)
    assert hankel2(n, y).conjugate() == hankel1(conjugate(n), y)
    assert hankel2(n, z).conjugate() == hankel1(conjugate(n), conjugate(z))
    assert tn(hankel2(n, rz).conjugate(), hankel1(conjugate(n), conjugate(rz)))
Ejemplo n.º 10
0
def test_conjugate():
    from sympy import conjugate, I, Symbol
    n, z, x = Symbol('n'), Symbol('z', real=False), Symbol('x', real=True)
    y, t = Symbol('y', real=True, positive=True), Symbol('t', negative=True)

    for f in [besseli, besselj, besselk, bessely, hankel1, hankel2]:
        assert f(n, -1).conjugate() != f(conjugate(n), -1)
        assert f(n, x).conjugate() != f(conjugate(n), x)
        assert f(n, t).conjugate() != f(conjugate(n), t)

    rz = randcplx(b=0.5)

    for f in [besseli, besselj, besselk, bessely]:
        assert f(n, 1 + I).conjugate() == f(conjugate(n), 1 - I)
        assert f(n, 0).conjugate() == f(conjugate(n), 0)
        assert f(n, 1).conjugate() == f(conjugate(n), 1)
        assert f(n, z).conjugate() == f(conjugate(n), conjugate(z))
        assert f(n, y).conjugate() == f(conjugate(n), y)
        assert tn(f(n, rz).conjugate(), f(conjugate(n), conjugate(rz)))

    assert hankel1(n, 1 + I).conjugate() == hankel2(conjugate(n), 1 - I)
    assert hankel1(n, 0).conjugate() == hankel2(conjugate(n), 0)
    assert hankel1(n, 1).conjugate() == hankel2(conjugate(n), 1)
    assert hankel1(n, y).conjugate() == hankel2(conjugate(n), y)
    assert hankel1(n, z).conjugate() == hankel2(conjugate(n), conjugate(z))
    assert tn(hankel1(n, rz).conjugate(), hankel2(conjugate(n), conjugate(rz)))

    assert hankel2(n, 1 + I).conjugate() == hankel1(conjugate(n), 1 - I)
    assert hankel2(n, 0).conjugate() == hankel1(conjugate(n), 0)
    assert hankel2(n, 1).conjugate() == hankel1(conjugate(n), 1)
    assert hankel2(n, y).conjugate() == hankel1(conjugate(n), y)
    assert hankel2(n, z).conjugate() == hankel1(conjugate(n), conjugate(z))
    assert tn(hankel2(n, rz).conjugate(), hankel1(conjugate(n), conjugate(rz)))
Ejemplo n.º 11
0
def test_conjugate():
    from sympy import conjugate, I, Symbol

    n = Symbol("n")
    z = Symbol("z", extended_real=False)
    x = Symbol("x", extended_real=True)
    y = Symbol("y", real=True, positive=True)
    t = Symbol("t", negative=True)

    for f in [besseli, besselj, besselk, bessely, hankel1, hankel2]:
        assert f(n, -1).conjugate() != f(conjugate(n), -1)
        assert f(n, x).conjugate() != f(conjugate(n), x)
        assert f(n, t).conjugate() != f(conjugate(n), t)

    rz = randcplx(b=0.5)

    for f in [besseli, besselj, besselk, bessely]:
        assert f(n, 1 + I).conjugate() == f(conjugate(n), 1 - I)
        assert f(n, 0).conjugate() == f(conjugate(n), 0)
        assert f(n, 1).conjugate() == f(conjugate(n), 1)
        assert f(n, z).conjugate() == f(conjugate(n), conjugate(z))
        assert f(n, y).conjugate() == f(conjugate(n), y)
        assert tn(f(n, rz).conjugate(), f(conjugate(n), conjugate(rz)))

    assert hankel1(n, 1 + I).conjugate() == hankel2(conjugate(n), 1 - I)
    assert hankel1(n, 0).conjugate() == hankel2(conjugate(n), 0)
    assert hankel1(n, 1).conjugate() == hankel2(conjugate(n), 1)
    assert hankel1(n, y).conjugate() == hankel2(conjugate(n), y)
    assert hankel1(n, z).conjugate() == hankel2(conjugate(n), conjugate(z))
    assert tn(hankel1(n, rz).conjugate(), hankel2(conjugate(n), conjugate(rz)))

    assert hankel2(n, 1 + I).conjugate() == hankel1(conjugate(n), 1 - I)
    assert hankel2(n, 0).conjugate() == hankel1(conjugate(n), 0)
    assert hankel2(n, 1).conjugate() == hankel1(conjugate(n), 1)
    assert hankel2(n, y).conjugate() == hankel1(conjugate(n), y)
    assert hankel2(n, z).conjugate() == hankel1(conjugate(n), conjugate(z))
    assert tn(hankel2(n, rz).conjugate(), hankel1(conjugate(n), conjugate(rz)))
Ejemplo n.º 12
0
def test_conjugate():
    from sympy import conjugate, I, Symbol
    n, z, x = Symbol('n'), Symbol('z', real=False), Symbol('x', real=True)
    y, t = Symbol('y', real=True, positive=True), Symbol('t', negative=True)

    for f in [besseli, besselj, besselk, bessely, jn, yn, hankel1, hankel2]:
        assert f(n, -1).conjugate() != f(conjugate(n), -1)
        assert f(n, x).conjugate() != f(conjugate(n), x)
        assert f(n, t).conjugate() != f(conjugate(n), t)

    rz = randcplx(b=0.5)

    for f in [besseli, besselj, besselk, bessely, jn, yn]:
        assert f(n, 1 + I).conjugate() == f(conjugate(n), 1 - I)
        assert f(n, 0).conjugate() == f(conjugate(n), 0)
        assert f(n, 1).conjugate() == f(conjugate(n), 1)
        assert f(n, z).conjugate() == f(conjugate(n), conjugate(z))
        assert f(n, y).conjugate() == f(conjugate(n), y)
        assert tn(f(n, rz).conjugate(), f(conjugate(n), conjugate(rz)))

    assert hankel1(n, 1 + I).conjugate() == hankel2(conjugate(n), 1 - I)
    assert hankel1(n, 0).conjugate() == hankel2(conjugate(n), 0)
    assert hankel1(n, 1).conjugate() == hankel2(conjugate(n), 1)
    assert hankel1(n, y).conjugate() == hankel2(conjugate(n), y)
    assert hankel1(n, z).conjugate() == hankel2(conjugate(n), conjugate(z))
    assert tn(hankel1(n, rz).conjugate(), hankel2(conjugate(n), conjugate(rz)))

    assert hankel2(n, 1 + I).conjugate() == hankel1(conjugate(n), 1 - I)
    assert hankel2(n, 0).conjugate() == hankel1(conjugate(n), 0)
    assert hankel2(n, 1).conjugate() == hankel1(conjugate(n), 1)
    assert hankel2(n, y).conjugate() == hankel1(conjugate(n), y)
    assert hankel2(n, z).conjugate() == hankel1(conjugate(n), conjugate(z))
    assert tn(hankel2(n, rz).conjugate(), hankel1(conjugate(n), conjugate(rz)))
Ejemplo n.º 13
0
def GetScalarGreen2D(rho=Symbol(r'\rho'), k=Symbol('k')):
    ## (del_T^2 + k^2)G= -delta(rho)
    G = 1 / (4 * I) * hankel2(0, k * rho)
    return G