Beispiel #1
0
def sphhankel2(nv,zv):
    return sph_hankel2.subs({'n': nv, 'z': zv})
Ion_pt3 = lambdify([n, alpha, beta], ion_pt3, 'sympy')
# print(Ion_pt3(subsdict['n'],subsdict['alpha'],subsdict['beta']).evalf())

#%%

Ion = ion_pt1 + ion_pt1 + ion_pt3
Ion_func = lambdify([n, alpha, beta], Ion, 'sympy')
print(Ion_func(subsdict['n'], subsdict['alpha'], subsdict['beta']).evalf())

#%%
# The on-axis coefficients
mval = 0
Aon_num = ((2 * n + 1)**2) * factorial(n - 2 * mval) * Ion
Aon_denom_hankels = n * sph_hankel2.subs({
    'n': n - 1,
    'z': kR
}) - (n + 1) * sph_hankel2.subs({
    'n': n + 1,
    'z': kR
})
Aon_denom = I * 2 * pi * factorial(n + 2 * mval) * (Aon_denom_hankels)
Aon = Aon_num / Aon_denom

Aon_func = lambdify([n, alpha, beta, k, R], Aon, 'sympy')

#%%
D_factor = lambdify([alpha, beta, k, R], 4 * pi / (S * k**2), 'sympy')


def d_zero(A0n, alphav, betav, kv, Rv, Nterms):
    '''
Beispiel #3
0
from sympy import HadamardProduct as HP
import tqdm
x, alpha, index, k, m, n, p, r1, R, theta, y, z = symbols(
    'x alpha index k m n p r1 R theta,y,z')
dps = 300
mpmath.mp.dps = dps

from beamshapes.special_functions import sph_hankel2
from beamshapes.utilities import args_to_mpmath, args_to_str

r1 = (R * cos(alpha)) / cos(theta)

#%%
# equation 12.106
alternate_hankels = n * sph_hankel2.subs({
    'n': n - 1,
    'z': k * r1
}) - (n + 1) * sph_hankel2.subs({
    'n': n + 1,
    'z': k * r1
})
pt1_postterm = legendre(n, cos(theta)) * cos(theta)
Imn_pt1 = alternate_hankels * pt1_postterm

pt2_preterm = n * (n + 1) * sph_hankel2.subs({'z': k * r1})
alternate_legendres = (legendre(n - 1, cos(theta)) -
                       legendre(n + 1, cos(theta))) / (k * r1)
Imn_pt2 = pt2_preterm * alternate_legendres

whole_postterm = legendre(m, cos(theta)) * (r1**2 / R**2) * tan(theta)

Imn_term = (Imn_pt1 + Imn_pt2) * whole_postterm
    12.60
"""

from gmpy2 import *
from symengine import *
import mpmath
#mpmath.mp.dps = 15
from sympy import expand, symbols, Sum, summation, I, cos, sin, legendre, oo, zoo
from sympy import lambdify, pi
from beamshapes.special_functions import sph_hankel2, legendre_mvz

n, z, k, R, alpha, theta = symbols('n z k R alpha theta')

# equation 12.59
# split the big parenthesis into 3 parts (j/sph_hankel, cos(theta) term and the summation)
d_theta_term1 = I / (2 * sph_hankel2.subs({'n': 1, 'z': k * R}))

d_theta_term2_num = 3 * (1 - cos(alpha)**3) * cos(theta)
d_theta_term2_denom = (sin(alpha)**2) * (sph_hankel2.subs({
    'n': 0,
    'z': k * R
}) - 2 * sph_hankel2.subs({
    'n': 2,
    'z': k * R
}))
d_theta_term2 = d_theta_term2_num / d_theta_term2_denom
P_1ncosalpha = legendre_mvz.subs({'m': 1, 'v': n, 'z': cos(alpha)}).doit()
dtheta_t3_num = (I**(n + 1)) * ((2 * n + 1)**2) * (
    sin(alpha) * legendre(n, cos(alpha)) + cos(alpha) * P_1ncosalpha)
dtheta_t3_denom = (n - 1) * (n +
                             2) * sin(alpha) * (n * sph_hankel2.subs({
Academic Press.

"""
import numpy as np
from sympy import symbols, legendre, lambdify, I, Sum, cos
from beamshapes.special_functions import sph_hankel2
from beamshapes.utilities import dB

k, R, n, theta, NN, kR = symbols('k R n theta NN kR')
costheta = cos(theta)
kR = k * R
# eqn. 12.46

numerator_sumterm = I**(n + 1) * (2 * n + 1)**2 * legendre(n, costheta)
denominator_sumterm = n * sph_hankel2.subs({
    'n': n - 1,
    'z': kR
}) - (n + 1) * sph_hankel2.subs({
    'n': n + 1,
    'z': kR
})
sum_term = Sum(numerator_sumterm / denominator_sumterm, (n, 0, NN))
d_theta = (1 / (kR**2)) * sum_term

d_theta_func = lambdify([theta, k, R, NN], d_theta)

docs_for_dtheta = '''On-axis level for point on a sphere. 
                 Lambdified version of :code:`d_theta` SymPy expression.
                 
                 Parameters
                 ----------
                 theta : np.float>0