-
Notifications
You must be signed in to change notification settings - Fork 1
/
field_components.py
200 lines (169 loc) · 6.95 KB
/
field_components.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 9 14:28:55 2019
@author: luizv
"""
# -*- coding: utf-8 -*-
"""
Created on Tue May 14 10:02:23 2019
@author: luizv
"""
import numpy as np
from glmtscatt.specials import (_riccati_bessel_j, _riccati_bessel_y,
legendre_p, legendre_tau, legendre_pi,
riccati_bessel_j, riccati_bessel_y,
d_riccati_bessel_j, d_riccati_bessel_y,
d2_riccati_bessel_j, d2_riccati_bessel_y,
riccati_bessel_radial_i, riccati_bessel_radial_s)
from glmtscatt.utils import (get_max_it, one, exp_im, m_exp_im,
inverse, multiply_function)
from scipy.special import riccati_jn
def plane_wave_coefficient(degree, wave_number_k):
""" Computes plane wave coefficient :math:`c_{n}^{pw}` """
return (1 / (1j * wave_number_k)) \
* pow(-1j, degree) \
* (2 * degree + 1) / (degree * (degree + 1))
def _radial_electric_i_tm(radial, theta, phi,
wave_number_k, degrees=[-1, 1],
bscs={}):
""" Computes the radial component of incident electric field in TM mode.
"""
result = 0
n = 1
riccati_bessel_list = _riccati_bessel_j(get_max_it(radial, wave_number_k),
wave_number_k * radial)
riccati_bessel = riccati_bessel_list[0]
max_it = get_max_it(radial, wave_number_k)
# while n <= get_max_it(radial, wave_number_k):
while n <= max_it:
for m in degrees:
if n >= m:
increment = plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* (d2_riccati_bessel_j(n, wave_number_k * radial)
+ riccati_bessel[n]) \
* legendre_p(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return wave_number_k * result
def radial_electric_i_tm(radial, theta, phi,
wave_number_k, degrees=[-1, 1],
bscs={}):
""" Computes the radial component of incident electric field in TM mode.
"""
result = 0
n = 1
max_it = get_max_it(radial, wave_number_k)
riccati_term = riccati_jn(n, wave_number_k * radial)[0]
while n <= max_it:
for m in degrees:
if n >= m:
increment = plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* riccati_term[n - 1] \
* legendre_p(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return result / wave_number_k / radial ** 2
def theta_electric_i_tm(radial, theta, phi, wave_number_k,
degrees=[-1, 1], bscs={}):
""" Computes the theta component of inciding electric field in TM mode.
"""
result = 0
n = 1
# Due to possible singularity near origin, we approximate null radial
# component to a small value.
radial = radial or 1E-16
riccati_bessel_list = _riccati_bessel_j(get_max_it(radial, wave_number_k),
wave_number_k * radial)
d_riccati_bessel = riccati_bessel_list[1]
max_it = get_max_it(radial, wave_number_k)
while n <= max_it:
for m in degrees:
if n >= m:
increment = plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* d_riccati_bessel[n] \
* legendre_tau(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return result / radial
def theta_electric_i_te(radial, theta, phi, wave_number_k,
degrees=[-1, 1], bscs={}):
""" Computes the theta component of inciding electric field in TE mode.
"""
result = 0
n = 1
# Due to possible singularity near origin, we approximate null radial
# component to a small value.
radial = radial or 1E-16
riccati_bessel_list = _riccati_bessel_j(get_max_it(radial, wave_number_k),
wave_number_k * radial)
riccati_bessel = riccati_bessel_list[0]
max_it = get_max_it(radial, wave_number_k)
while n <= max_it:
for m in degrees:
if n >= m:
increment = m \
* plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* riccati_bessel[n] \
* legendre_pi(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return result / radial
def phi_electric_i_tm(radial, theta, phi, wave_number_k,
degrees=[-1, 1], bscs={}):
""" Computes the phi component of inciding electric field in TM mode.
"""
result = 0
n = 1
# Due to possible singularity near origin, we approximate null radial
# component to a small value.
radial = radial or 1E-16
riccati_bessel_list = _riccati_bessel_j(get_max_it(radial, wave_number_k),
wave_number_k * radial)
d_riccati_bessel = riccati_bessel_list[1]
max_it = get_max_it(radial, wave_number_k)
while n <= max_it:
for m in degrees:
if n >= m:
increment = m \
* plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* d_riccati_bessel[n] \
* legendre_pi(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return 1j * result / radial
def phi_electric_i_te(radial, theta, phi, wave_number_k,
degrees=[-1, 1], bscs={}):
""" Computes the phi component of inciding electric field in TE mode.
"""
result = 0
n = 1
m = 0
# Due to possible singularity near origin, we approximate null radial
# component to a small value.
radial = radial or 1E-16
riccati_bessel_list = _riccati_bessel_j(get_max_it(radial,
wave_number_k),
wave_number_k * radial)
riccati_bessel = riccati_bessel_list[0]
max_it = get_max_it(radial, wave_number_k)
while n <= max_it:
for m in degrees:
if n >= m:
increment = plane_wave_coefficient(n, wave_number_k) \
* bscs[(n, m)] \
* riccati_bessel[n] \
* legendre_tau(n, abs(m), np.cos(theta)) \
* np.exp(1j * m * phi)
result += increment
n += 1
return 1j * result / radial