| 1 |
""" |
| 2 |
circularWaveguide (:mod:`skrf.media.circularWaveguide`) |
| 3 |
================================================================ |
| 4 |
|
| 5 |
.. autosummary:: |
| 6 |
:toctree: generated/ |
| 7 |
|
| 8 |
CircularWaveguide |
| 9 |
|
| 10 |
""" |
| 11 |
from __future__ import annotations |
| 12 |
|
| 13 |
from typing import TYPE_CHECKING |
| 14 |
|
| 15 |
import numpy as np |
| 16 |
from numpy import sqrt, where |
| 17 |
from scipy.constants import epsilon_0, mu_0, pi |
| 18 |
from scipy.special import jn_zeros, jnp_zeros |
| 19 |
|
| 20 |
from ..constants import NumberLike |
| 21 |
from ..data import materials |
| 22 |
from .freespace import Freespace |
| 23 |
from .media import Media |
| 24 |
|
| 25 |
if TYPE_CHECKING: |
| 26 |
from ..frequency import Frequency |
| 27 |
|
| 28 |
|
| 29 |
class CircularWaveguide(Media): |
| 30 |
r""" |
| 31 |
A single mode of a homogeneously filled Circular Waveguide |
| 32 |
|
| 33 |
Represents a single mode of a homogeneously filled circular |
| 34 |
waveguide of cross-section `r^2 pi`. The mode is determined by |
| 35 |
`mode-type` (`'te'` or `'tm'`) and mode indices ( `m` and `n` ). |
| 36 |
Corrugated circular waveguides, which also support HE modes, are not |
| 37 |
supported. |
| 38 |
|
| 39 |
|
| 40 |
==================================== ============= =============== |
| 41 |
Quantity Symbol Variable |
| 42 |
==================================== ============= =============== |
| 43 |
Characteristic Wave Number :math:`k_0` :attr:`k0` |
| 44 |
Cut-off Wave Number :math:`k_c` :attr:`kc` |
| 45 |
Longitudinal Wave Number :math:`k_z` :attr:`gamma` |
| 46 |
Transverse Wave Number (a) :math:`k_x` :attr:`kx` |
| 47 |
Transverse Wave Number (b) :math:`k_y` :attr:`ky` |
| 48 |
Characteristic Impedance :math:`z_0` :attr:`z0` |
| 49 |
==================================== ============= =============== |
| 50 |
|
| 51 |
Parameters |
| 52 |
---------- |
| 53 |
frequency : :class:`~skrf.frequency.Frequency` object |
| 54 |
frequency band of this transmission line medium |
| 55 |
z0_port : number, array-like, or None |
| 56 |
`z0_port` is the port impedance for networks generated by the media. |
| 57 |
If `z0_port` is not None, the networks generated by the media are |
| 58 |
renormalized (or in other words embedded) from the characteristic |
| 59 |
impedance z0 of the media to `z0_port`. |
| 60 |
Else if `z0_port` is None, the networks port impedances will be the raw |
| 61 |
characteristic impedance z0 of the media. |
| 62 |
(Default is None) |
| 63 |
z0_override : number, array-like, or None |
| 64 |
`z0_override` override the characteristic impedance for the media. |
| 65 |
If `z0_override` is not None, the networks generated by the media have |
| 66 |
their characteristic impedance `z0` overridden by `z0_override`. |
| 67 |
(Default is None) |
| 68 |
z0 : number, array-like, or None |
| 69 |
deprecated parameter, alias to `z0_override` if `z0_override` is None. |
| 70 |
Emit a deprecation warning. |
| 71 |
r : number |
| 72 |
radius of the waveguide, in meters. |
| 73 |
mode_type : ['te','tm'] |
| 74 |
mode type, transverse electric (te) or transverse magnetic |
| 75 |
(tm) to-z. where z is direction of propagation |
| 76 |
m : int |
| 77 |
mode index in 'phi'-direction, the azimuthal index |
| 78 |
n : int |
| 79 |
mode index in 'r'-direction, the radial index |
| 80 |
ep_r : number, array-like, |
| 81 |
filling material's relative permittivity |
| 82 |
mu_r : number, array-like |
| 83 |
filling material's relative permeability |
| 84 |
rho : number, array-like, string |
| 85 |
resistivity (ohm-m) of the conductor walls. If array-like |
| 86 |
must be same length as frequency. if str, it must be a key in |
| 87 |
`skrf.data.materials`. |
| 88 |
|
| 89 |
\*args, \*\*kwargs : arguments, keyword arguments |
| 90 |
passed to :class:`~skrf.media.media.Media`'s constructor |
| 91 |
(:func:`~skrf.media.media.Media.__init__` |
| 92 |
|
| 93 |
|
| 94 |
Examples |
| 95 |
-------- |
| 96 |
In the following example an ideal waveguide of 2.39 mm diameter is |
| 97 |
constructed for the high W band, operated in the fundamental TE11 mode. |
| 98 |
If no conductivity is provided the walls are treated as perfect |
| 99 |
electric conductors. |
| 100 |
|
| 101 |
>>> freq = rf.Frequency(88, 110, 101, 'ghz') |
| 102 |
>>> rf.CircularWaveguide(freq, r=0.5 * 2.39e-3) |
| 103 |
|
| 104 |
""" |
| 105 |
def __init__(self, frequency: Frequency | None = None, |
| 106 |
z0_port: NumberLike | None = None, |
| 107 |
z0_override: NumberLike | None = None, |
| 108 |
z0: NumberLike | None = None, |
| 109 |
r: NumberLike = 1, |
| 110 |
mode_type: str = 'te', m: int = 1, n: int = 1, |
| 111 |
ep_r: NumberLike = 1, mu_r: NumberLike = 1, |
| 112 |
rho: NumberLike | str | None = None, |
| 113 |
*args, **kwargs): |
| 114 |
Media.__init__(self, frequency = frequency, |
| 115 |
z0_port = z0_port, z0_override = z0_override, z0 = z0) |
| 116 |
|
| 117 |
if mode_type.lower() not in ['te','tm']: |
| 118 |
raise ValueError('mode_type must be either \'te\' or \'tm\'') |
| 119 |
|
| 120 |
|
| 121 |
self.r = r |
| 122 |
self.mode_type = mode_type.lower() |
| 123 |
self.m = m |
| 124 |
self.n = n |
| 125 |
self.ep_r = ep_r |
| 126 |
self.mu_r = mu_r |
| 127 |
self.rho = rho |
| 128 |
|
| 129 |
def __str__(self) -> str: |
| 130 |
f=self.frequency |
| 131 |
output = \ |
| 132 |
'Circular Waveguide Media. %i-%i %s. %i points'%\ |
| 133 |
(f.f_scaled[0], f.f_scaled[-1], f.unit, f.npoints) + \ |
| 134 |
f'\n r= {self.r:.2e}m' |
| 135 |
return output |
| 136 |
|
| 137 |
def __repr__(self) -> str: |
| 138 |
return self.__str__() |
| 139 |
|
| 140 |
|
| 141 |
@classmethod |
| 142 |
def from_z0(cls, frequency: Frequency, z0: NumberLike, |
| 143 |
f: NumberLike, ep_r: NumberLike = 1, mu_r: NumberLike = 1, |
| 144 |
**kwargs): |
| 145 |
r""" |
| 146 |
Initialize from specified impedance at a given frequency, assuming the |
| 147 |
fundamental TE11 mode. |
| 148 |
|
| 149 |
Parameters |
| 150 |
---------- |
| 151 |
frequency : Frequency Object |
| 152 |
z0 : number /array |
| 153 |
characteristic impedance to create at `f` |
| 154 |
f : number |
| 155 |
frequency (in Hz) at which the resultant waveguide has the |
| 156 |
characteristic impedance Z0 |
| 157 |
ep_r : number, array-like, |
| 158 |
filling material's relative permittivity |
| 159 |
mu_r : number, array-like |
| 160 |
filling material's relative permeability |
| 161 |
\*\*kwargs : arguments, keyword arguments |
| 162 |
passed to :class:`~skrf.media.media.Media`'s constructor |
| 163 |
(:func:`~skrf.media.media.Media.__init__` |
| 164 |
""" |
| 165 |
|
| 166 |
mu = mu_0*mu_r |
| 167 |
ep = epsilon_0*ep_r |
| 168 |
w = 2*pi*f |
| 169 |
|
| 170 |
u = jnp_zeros(1, 1)[-1] |
| 171 |
r =u/(w*mu) * 1./sqrt(1/(z0*1j)**2+ep/mu) |
| 172 |
|
| 173 |
kwargs.update(dict(frequency=frequency, r=r, m=1, n=1, ep_r=ep_r, mu_r=mu_r)) |
| 174 |
|
| 175 |
return cls(**kwargs) |
| 176 |
|
| 177 |
@property |
| 178 |
def ep(self) -> NumberLike: |
| 179 |
""" |
| 180 |
The permativity of the filling material. |
| 181 |
|
| 182 |
Returns |
| 183 |
------- |
| 184 |
ep : number |
| 185 |
filling material's relative permittivity |
| 186 |
""" |
| 187 |
return self.ep_r * epsilon_0 |
| 188 |
|
| 189 |
@property |
| 190 |
def mu(self) -> NumberLike: |
| 191 |
""" |
| 192 |
The permeability of the filling material. |
| 193 |
|
| 194 |
Returns |
| 195 |
------- |
| 196 |
mu : number |
| 197 |
filling material's relative permeability |
| 198 |
|
| 199 |
""" |
| 200 |
return self.mu_r * mu_0 |
| 201 |
|
| 202 |
@property |
| 203 |
def k0(self) -> NumberLike: |
| 204 |
r""" |
| 205 |
Characteristic wave number. |
| 206 |
|
| 207 |
.. math:: |
| 208 |
|
| 209 |
k_0 = \omega \sqrt{\varepsilon \mu} |
| 210 |
|
| 211 |
Returns |
| 212 |
------- |
| 213 |
k0 : number |
| 214 |
characteristic wave number |
| 215 |
""" |
| 216 |
return 2*pi*self.frequency.f*sqrt(self.ep * self.mu) |
| 217 |
|
| 218 |
@property |
| 219 |
def kc(self) -> NumberLike: |
| 220 |
r""" |
| 221 |
Cut-off wave number. |
| 222 |
|
| 223 |
Defined as |
| 224 |
|
| 225 |
.. math:: |
| 226 |
|
| 227 |
k_c = \frac{u_{mn}}{R} |
| 228 |
|
| 229 |
where R is the radius of the waveguide, and u_mn is: |
| 230 |
|
| 231 |
* the n-th root of the m-th Bessel function for 'tm' mode |
| 232 |
* the n-th root of the Derivative of the m-th Bessel function for 'te' mode. |
| 233 |
|
| 234 |
Returns |
| 235 |
------- |
| 236 |
kc : number |
| 237 |
cut-off wavenumber |
| 238 |
""" |
| 239 |
if self.mode_type =="te": |
| 240 |
u = jnp_zeros(self.m, self.n)[-1] |
| 241 |
elif self.mode_type =="tm": |
| 242 |
u = jn_zeros(self.m,self.n)[-1] |
| 243 |
return u/self.r |
| 244 |
|
| 245 |
@property |
| 246 |
def f_cutoff(self) -> NumberLike: |
| 247 |
r""" |
| 248 |
cutoff frequency for this mode |
| 249 |
|
| 250 |
.. math:: |
| 251 |
|
| 252 |
f_c = \frac{v}{2 \pi} \frac{u_{mn}}{R} |
| 253 |
|
| 254 |
where R is the radius of the waveguide, and u_mn is: |
| 255 |
|
| 256 |
* the n-th root of the m-th Bessel function for 'tm' mode |
| 257 |
* the n-th root of the Derivative of the m-th Bessel function for 'te' mode. |
| 258 |
|
| 259 |
and v= 1/sqrt(ep*mu) is the bulk velocity inside the filling material. |
| 260 |
""" |
| 261 |
v = 1/sqrt(self.ep*self.mu) |
| 262 |
return v* self.kc/(2*np.pi) |
| 263 |
|
| 264 |
@property |
| 265 |
def f_norm(self) -> NumberLike: |
| 266 |
""" |
| 267 |
frequency vector normalized to cutoff |
| 268 |
""" |
| 269 |
return self.frequency.f/self.f_cutoff |
| 270 |
|
| 271 |
@property |
| 272 |
def rho(self) -> NumberLike: |
| 273 |
""" |
| 274 |
conductivity of sidewalls in ohm*m |
| 275 |
|
| 276 |
Parameters |
| 277 |
-------------- |
| 278 |
val : float, array-like or str |
| 279 |
the conductivity in ohm*m. If array-like must be same length |
| 280 |
as self.frequency. if str, it must be a key in |
| 281 |
`skrf.data.materials`. |
| 282 |
|
| 283 |
Examples |
| 284 |
--------- |
| 285 |
>>> wg.rho = 2.8e-8 |
| 286 |
>>> wg.rho = 2.8e-8 * ones(len(wg.frequency)) |
| 287 |
>>> wg.rho = 'al' |
| 288 |
>>> wg.rho = 'aluminum' |
| 289 |
""" |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
return self._rho |
| 296 |
|
| 297 |
@rho.setter |
| 298 |
def rho(self, val): |
| 299 |
if isinstance(val, str): |
| 300 |
self._rho = materials[val.lower()]['resistivity(ohm*m)'] |
| 301 |
else: |
| 302 |
self._rho=val |
| 303 |
|
| 304 |
@property |
| 305 |
def lambda_guide(self) -> NumberLike: |
| 306 |
r""" |
| 307 |
Guide wavelength. |
| 308 |
|
| 309 |
.. math:: |
| 310 |
|
| 311 |
\lambda_g = 2\pi/\beta |
| 312 |
|
| 313 |
the distance in which the phase of the field increases by 2 pi. |
| 314 |
""" |
| 315 |
return 2*pi/self.beta |
| 316 |
|
| 317 |
@property |
| 318 |
def lambda_cutoff(self) -> NumberLike: |
| 319 |
r""" |
| 320 |
Cutoff wavelength. |
| 321 |
|
| 322 |
.. math:: |
| 323 |
|
| 324 |
\lambda_c = v/f_c |
| 325 |
|
| 326 |
where v= 1/sqrt(ep*mu) |
| 327 |
""" |
| 328 |
v = 1/sqrt(self.ep*self.mu) |
| 329 |
return v/self.f_cutoff |
| 330 |
|
| 331 |
@property |
| 332 |
def gamma(self) -> NumberLike: |
| 333 |
r""" |
| 334 |
The propagation constant (aka Longitudinal wave number) |
| 335 |
|
| 336 |
Defined as |
| 337 |
|
| 338 |
.. math:: |
| 339 |
|
| 340 |
k_z = \pm j \sqrt {k_0^2 - k_c^2} |
| 341 |
|
| 342 |
This is: |
| 343 |
|
| 344 |
* IMAGINARY for propagating modes |
| 345 |
* REAL for non-propagating modes, |
| 346 |
|
| 347 |
Returns |
| 348 |
------- |
| 349 |
gamma : number |
| 350 |
The propagation constant |
| 351 |
|
| 352 |
|
| 353 |
""" |
| 354 |
|
| 355 |
|
| 356 |
if False: |
| 357 |
fs = Freespace(frequency=self.frequency, |
| 358 |
ep_r=self.ep_r, |
| 359 |
mu_r=self.mu_r) |
| 360 |
|
| 361 |
g= where(self.f_norm>1., |
| 362 |
sqrt(1-self.f_norm**(-2))*fs.gamma, |
| 363 |
-1j*sqrt(1-self.f_norm**(2))*fs.gamma) |
| 364 |
|
| 365 |
else: |
| 366 |
|
| 367 |
k0,kc = self.k0, self.kc |
| 368 |
g= 1j*sqrt(abs(k0**2 - kc**2)) * (k0>kc) +\ |
| 369 |
sqrt(abs(kc**2- k0**2))*(k0<kc) + \ |
| 370 |
0*(kc==k0) |
| 371 |
|
| 372 |
g = g + self.alpha_c *(self.rho is not None) |
| 373 |
|
| 374 |
return g |
| 375 |
|
| 376 |
|
| 377 |
@property |
| 378 |
def alpha_c(self) -> NumberLike: |
| 379 |
""" |
| 380 |
Loss due to finite conductivity of the sidewalls for the fundamental mode TE11. Higher order |
| 381 |
modes are not implemented, as well as effects due to surface roughness. |
| 382 |
|
| 383 |
In units of Np/m |
| 384 |
|
| 385 |
See property `rho` for setting conductivity. |
| 386 |
|
| 387 |
Effects of finite conductivity are taken from [#]_, but expressed in the same terms as in [#]_. |
| 388 |
|
| 389 |
References |
| 390 |
---------- |
| 391 |
|
| 392 |
.. [#] Eq. (3.133), Chapter 3.4, Microwave Engineering, Pozar David, 2011 |
| 393 |
.. [#] Eq. (9.8.1), Chapter 9, Electromagnetic Waves and Antennas by Sophocles J. Orfanidis |
| 394 |
http://eceweb1.rutgers.edu/~orfanidi/ewa/ |
| 395 |
|
| 396 |
See Also |
| 397 |
-------- |
| 398 |
rho |
| 399 |
""" |
| 400 |
|
| 401 |
|
| 402 |
if (self.mode_type != "te") or (self.m != 1) or (self.n != 1): |
| 403 |
raise NotImplementedError |
| 404 |
|
| 405 |
if self.rho is None: |
| 406 |
return 0 |
| 407 |
r, w, ep, rho, f_n = self.r, self.frequency.w, self.ep, \ |
| 408 |
self.rho, self.f_norm |
| 409 |
u= self.kc*r |
| 410 |
return 1./r * sqrt( (w*ep)/(2./rho) ) * ( (1/f_n)**2 + 1/(u**2 - 1) ) \ |
| 411 |
/sqrt(1-(1/f_n)**2) |
| 412 |
|
| 413 |
@property |
| 414 |
def z0_characteristic(self) -> NumberLike: |
| 415 |
""" |
| 416 |
The characteristic impedance, :math:`z_0`. |
| 417 |
|
| 418 |
Returns |
| 419 |
------- |
| 420 |
z0_characteristic : np.ndarray |
| 421 |
Characteristic Impedance in units of ohms |
| 422 |
""" |
| 423 |
omega = self.frequency.w |
| 424 |
impedance_dict = {'te': 1j*omega*self.mu/(self.gamma), |
| 425 |
'tm': -1j*self.gamma/(omega*self.ep),\ |
| 426 |
} |
| 427 |
|
| 428 |
return impedance_dict[self.mode_type] |