| 1 |
""" |
| 2 |
coaxial (:mod:`skrf.media.coaxial`) |
| 3 |
============================================================ |
| 4 |
|
| 5 |
A coaxial transmission line defined from its electrical or geometrical/physical properties |
| 6 |
|
| 7 |
.. autosummary:: |
| 8 |
:toctree: generated/ |
| 9 |
|
| 10 |
Coaxial |
| 11 |
|
| 12 |
""" |
| 13 |
|
| 14 |
from __future__ import annotations |
| 15 |
|
| 16 |
from typing import TYPE_CHECKING |
| 17 |
|
| 18 |
from numpy import array, exp, expm1, imag, log, size, sqrt |
| 19 |
from scipy.constants import c, epsilon_0, mu_0, pi |
| 20 |
|
| 21 |
from ..constants import INF, NumberLike |
| 22 |
from ..mathFunctions import db_2_np, db_per_100feet_2_db_per_100meter, feet_2_meter |
| 23 |
from ..tlineFunctions import skin_depth, surface_resistivity |
| 24 |
from .distributedCircuit import DistributedCircuit |
| 25 |
from .media import DefinedGammaZ0, Media |
| 26 |
|
| 27 |
if TYPE_CHECKING: |
| 28 |
from ..frequency import Frequency |
| 29 |
|
| 30 |
|
| 31 |
class Coaxial(DistributedCircuit, Media): |
| 32 |
""" |
| 33 |
A coaxial transmission line defined in terms of its inner/outer |
| 34 |
diameters and permittivity. |
| 35 |
|
| 36 |
Parameters |
| 37 |
---------- |
| 38 |
frequency : :class:`~skrf.frequency.Frequency` object |
| 39 |
Frequency band. |
| 40 |
z0_port : number, array-like, or None |
| 41 |
`z0_port` is the port impedance for networks generated by the media. |
| 42 |
If `z0_port` is not None, the networks generated by the media are |
| 43 |
renormalized (or in other words embedded) from the characteristic |
| 44 |
impedance z0 of the media to `z0_port`. |
| 45 |
Else if `z0_port` is None, the networks port impedances will be the raw |
| 46 |
characteristic impedance z0 of the media. |
| 47 |
(Default is None) |
| 48 |
z0_override : number, array-like, or None |
| 49 |
`z0_override` override the characteristic impedance for the media. |
| 50 |
If `z0_override` is not None, the networks generated by the media have |
| 51 |
their characteristic impedance `z0` overridden by `z0_override`. |
| 52 |
(Default is None) |
| 53 |
z0 : number, array-like, or None |
| 54 |
deprecated parameter, alias to `z0_override` if `z0_override` is None. |
| 55 |
Emit a deprecation warning. |
| 56 |
Dint : number, or array-like |
| 57 |
inner conductor diameter, in m |
| 58 |
Dout : number, or array-like |
| 59 |
outer conductor diameter, in m |
| 60 |
epsilon_r : number, or array-like, optional |
| 61 |
relative permittivity of the dielectric medium. |
| 62 |
Default is 1. |
| 63 |
tan_delta : number, or array-like, optional |
| 64 |
loss tangent of the dielectric medium. |
| 65 |
Default is 0. |
| 66 |
sigma : number, or array-like, optional. |
| 67 |
conductors electrical conductivity, in S/m. |
| 68 |
Default is infinity (non lossy metal). |
| 69 |
|
| 70 |
|
| 71 |
TODO : different conductivity in case of different conductor kind |
| 72 |
|
| 73 |
Note |
| 74 |
---- |
| 75 |
Dint, Dout, epsilon_r, tan_delta, sigma can all be vectors as long |
| 76 |
as they are the same length |
| 77 |
|
| 78 |
References |
| 79 |
---------- |
| 80 |
.. [#] Pozar, D.M.; , "Microwave Engineering", Wiley India Pvt. Limited, 1 sept. 2009 |
| 81 |
|
| 82 |
""" |
| 83 |
|
| 84 |
def __init__(self, frequency: Frequency | None = None, |
| 85 |
z0_port: NumberLike | None = None, |
| 86 |
z0_override: NumberLike | None = None, |
| 87 |
z0: NumberLike | None = None, |
| 88 |
Dint: NumberLike = .81e-3, Dout: NumberLike = 5e-3, |
| 89 |
epsilon_r: NumberLike = 1, tan_delta: NumberLike = 0, |
| 90 |
sigma: NumberLike = INF, |
| 91 |
*args, **kwargs): |
| 92 |
Media.__init__(self, frequency = frequency, |
| 93 |
z0_port = z0_port, z0_override = z0_override, z0 = z0) |
| 94 |
|
| 95 |
self.Dint, self.Dout = Dint,Dout |
| 96 |
self.epsilon_r, self.tan_delta, self.sigma = epsilon_r, tan_delta, sigma |
| 97 |
self.epsilon_prime = epsilon_0*self.epsilon_r |
| 98 |
self.epsilon_second = epsilon_0*self.epsilon_r*self.tan_delta |
| 99 |
|
| 100 |
@classmethod |
| 101 |
def from_attenuation_VF(cls, frequency: Frequency | None = None, |
| 102 |
z0_port: NumberLike | None = None, z0: float = 50, |
| 103 |
att=0, unit='dB/m', VF=1) -> Media: |
| 104 |
""" |
| 105 |
Init from electrical properties of the line: attenuation and velocity factor. |
| 106 |
|
| 107 |
Attenuation can be expressed in dB/m, dB/100m, dB/ft, dB/100ft, Neper/m or Neper/ft. |
| 108 |
Default unit is dB/m. A different unit is set by the `unit` parameter. |
| 109 |
|
| 110 |
Parameters |
| 111 |
---------- |
| 112 |
frequency : :class:`~skrf.frequency.Frequency` object |
| 113 |
|
| 114 |
z0_port : number, array-like, or None |
| 115 |
`z0_port` is the port impedance for networks generated by the media. |
| 116 |
If `z0_port` is not None, the networks generated by the media are |
| 117 |
renormalized (or in other words embedded) from the characteristic |
| 118 |
impedance z0 of the media to `z0_port`. |
| 119 |
Else if `z0_port` is None, the networks port impedances will be the raw |
| 120 |
characteristic impedance z0 of the media. |
| 121 |
(Default is None) |
| 122 |
z0 : number |
| 123 |
desired characteristic impedance |
| 124 |
att : number, or array-like. optional |
| 125 |
Attenuation of the coaxial line. The default is 0. |
| 126 |
If passed as an array, should be of same size than the frequency. |
| 127 |
unit : string, optional |
| 128 |
Unit of the attenuation. Can be: 'dB/m', dB/100m'', 'dB/ft', 'dB/100ft', |
| 129 |
'Neper/m' or 'Neper/ft' (or 'Np/m', 'Np/ft'). The default is 'dB/m'. |
| 130 |
VF : number, or array-like. optional |
| 131 |
Velocity Factor VF [VF]_. The default is 1. |
| 132 |
If passed as an array, should be of same size than the frequency. |
| 133 |
|
| 134 |
Returns |
| 135 |
------- |
| 136 |
media : :class:`~skrf.media.media.Media` |
| 137 |
|
| 138 |
References |
| 139 |
---------- |
| 140 |
.. [VF] : https://www.microwaves101.com/encyclopedias/light-phase-and-group-velocities |
| 141 |
|
| 142 |
""" |
| 143 |
|
| 144 |
if size(array(att, dtype="object")) not in (1, size(frequency.f)): |
| 145 |
raise ValueError('Attenuation should be scalar or of same size that the frequency.') |
| 146 |
|
| 147 |
|
| 148 |
if unit in ('dB/m', 'db/m'): |
| 149 |
alpha = db_2_np(att) |
| 150 |
elif unit in ('dB/100m', 'db/100m'): |
| 151 |
alpha = db_2_np(att/100) |
| 152 |
elif unit in ('dB/ft', 'dB/feet'): |
| 153 |
alpha = db_2_np(att/feet_2_meter()) |
| 154 |
elif unit in ('dB/100ft', 'dB/100feet'): |
| 155 |
alpha = db_2_np(db_per_100feet_2_db_per_100meter(att)/100) |
| 156 |
elif unit in ('Np/m', 'np/m', 'n/m'): |
| 157 |
alpha = att |
| 158 |
elif unit in ('Neper/feet', 'Neper/ft', |
| 159 |
'Np/feet', 'Np/ft', |
| 160 |
'np/feet', 'np/ft', |
| 161 |
'N/feet', 'N/ft'): |
| 162 |
alpha = att/feet_2_meter() |
| 163 |
else: |
| 164 |
raise ValueError('Incorrect attenuation unit. Please see documentation. ', unit) |
| 165 |
|
| 166 |
beta = 2 * pi * frequency.f / c / VF |
| 167 |
|
| 168 |
gamma = alpha + 1j*beta |
| 169 |
|
| 170 |
|
| 171 |
return DefinedGammaZ0(frequency=frequency, gamma=gamma, |
| 172 |
z0_port=z0_port, z0=z0) |
| 173 |
|
| 174 |
@classmethod |
| 175 |
def from_Z0_Dout(cls, frequency: Frequency | None = None, |
| 176 |
z0_port: NumberLike | None = None, z0: float = 50, |
| 177 |
epsilon_r: NumberLike = 1, Dout: NumberLike = 5e-3, |
| 178 |
**kw) -> Media: |
| 179 |
""" |
| 180 |
Init from characteristic impedance and outer diameter. |
| 181 |
|
| 182 |
Parameters |
| 183 |
---------- |
| 184 |
frequency : :class:`~skrf.frequency.Frequency` object |
| 185 |
|
| 186 |
z0_port : number, array-like, or None |
| 187 |
`z0_port` is the port impedance for networks generated by the media. |
| 188 |
If `z0_port` is not None, the networks generated by the media are |
| 189 |
renormalized (or in other words embedded) from the characteristic |
| 190 |
impedance z0 of the media to `z0_port`. |
| 191 |
Else if `z0_port` is None, the networks port impedances will be the raw |
| 192 |
characteristic impedance z0 of the media. |
| 193 |
(Default is None) |
| 194 |
z0 : number |
| 195 |
desired characteristic impedance |
| 196 |
Dout : number, or array-like |
| 197 |
outer conductor diameter, in m |
| 198 |
epsilon_r=1 : number, or array-like |
| 199 |
relative permittivity of the dielectric medium |
| 200 |
**kw : |
| 201 |
passed to __init__ |
| 202 |
|
| 203 |
Returns |
| 204 |
------- |
| 205 |
media : :class:`~skrf.media.media.Media` |
| 206 |
""" |
| 207 |
ep= epsilon_0*epsilon_r |
| 208 |
|
| 209 |
if imag(z0) !=0: |
| 210 |
raise NotImplementedError() |
| 211 |
|
| 212 |
b = Dout/2. |
| 213 |
b_over_a = exp(2*pi*z0*sqrt(ep/mu_0)) |
| 214 |
a = b/b_over_a |
| 215 |
Dint = 2*a |
| 216 |
return cls(frequency=frequency, z0_port = z0_port, Dint=Dint, Dout=Dout, |
| 217 |
epsilon_r=epsilon_r, **kw) |
| 218 |
|
| 219 |
|
| 220 |
@property |
| 221 |
def Rs(self) -> NumberLike: |
| 222 |
""" |
| 223 |
Surface resistivity in Ohm/area. |
| 224 |
|
| 225 |
Returns |
| 226 |
------- |
| 227 |
Rs : number or array |
| 228 |
surface resistivity |
| 229 |
|
| 230 |
""" |
| 231 |
f = self.frequency.f |
| 232 |
rho = 1./self.sigma |
| 233 |
mu_r =1 |
| 234 |
return surface_resistivity(f=f,rho=rho, mu_r=mu_r) |
| 235 |
|
| 236 |
@property |
| 237 |
def a(self) -> NumberLike: |
| 238 |
""" |
| 239 |
Inner radius of the coaxial line |
| 240 |
|
| 241 |
Returns |
| 242 |
------- |
| 243 |
a : float |
| 244 |
Inner radius |
| 245 |
|
| 246 |
""" |
| 247 |
return self.Dint/2. |
| 248 |
|
| 249 |
@property |
| 250 |
def b(self) -> NumberLike: |
| 251 |
""" |
| 252 |
Outer radius of the coaxial line |
| 253 |
|
| 254 |
Returns |
| 255 |
------- |
| 256 |
b : float |
| 257 |
Outer radius |
| 258 |
""" |
| 259 |
return self.Dout/2. |
| 260 |
|
| 261 |
|
| 262 |
@property |
| 263 |
def R(self) -> NumberLike: |
| 264 |
""" |
| 265 |
Distributed resistance R, in Ohm/m. |
| 266 |
See [#]_ for more information. |
| 267 |
|
| 268 |
Returns |
| 269 |
------- |
| 270 |
R : number, or array-like |
| 271 |
distributed resistance, in Ohm/m |
| 272 |
|
| 273 |
References |
| 274 |
------- |
| 275 |
|
| 276 |
.. [#] https://www.microwaves101.com/encyclopedias/a-more-exact-coax-attenuation-solution |
| 277 |
|
| 278 |
""" |
| 279 |
rho = 1/self.sigma |
| 280 |
delta = skin_depth(f=self.frequency.f, rho=rho, mu_r=1) |
| 281 |
|
| 282 |
delta[delta > 1e6] = 1e6 |
| 283 |
|
| 284 |
Rin = rho / (2*pi*delta*self.a + 2*pi*delta**2*expm1(-self.a/delta)) |
| 285 |
|
| 286 |
Rout = rho / (2*pi*delta*self.b) |
| 287 |
return Rin + Rout |
| 288 |
|
| 289 |
@property |
| 290 |
def L(self) -> NumberLike: |
| 291 |
""" |
| 292 |
Distributed inductance L, in H/m |
| 293 |
|
| 294 |
Returns |
| 295 |
------- |
| 296 |
L : number, or array-like |
| 297 |
distributed inductance, in H/m |
| 298 |
|
| 299 |
""" |
| 300 |
return mu_0/(2.*pi)*log(self.b/self.a) |
| 301 |
|
| 302 |
@property |
| 303 |
def C(self) -> NumberLike: |
| 304 |
""" |
| 305 |
Distributed capacitance C, in F/m |
| 306 |
|
| 307 |
Returns |
| 308 |
------- |
| 309 |
C : number, or array-like |
| 310 |
distributed capacitance, in F/m |
| 311 |
|
| 312 |
""" |
| 313 |
return 2.*pi*self.epsilon_prime/log(self.b/self.a) |
| 314 |
|
| 315 |
@property |
| 316 |
def G(self) -> NumberLike: |
| 317 |
""" |
| 318 |
Distributed conductance G, in S/m |
| 319 |
|
| 320 |
Returns |
| 321 |
------- |
| 322 |
G : number, or array-like |
| 323 |
distributed conductance, in S/m |
| 324 |
|
| 325 |
""" |
| 326 |
return 2*pi*self.frequency.w*self.epsilon_second/log(self.b/self.a) |
| 327 |
|
| 328 |
def __str__(self): |
| 329 |
f=self.frequency |
| 330 |
f_s = f'Coaxial Media. {f.f_scaled[0]}-{f.f_scaled[-1]}{f.unit}, '\ |
| 331 |
f'{f.npoints} points.' |
| 332 |
z0 = self.z0 |
| 333 |
z0_s = f'z0 = ({z0[0].real:.1f}, {z0[0].imag:.1f}j)-'\ |
| 334 |
f'({z0[-1].real:.1f}, {z0[-1].imag:.1f}j) Ohm' |
| 335 |
if self.z0_port is not None: |
| 336 |
z0_port = self.z0_port |
| 337 |
z0_port_s = \ |
| 338 |
f'z0_port = ({z0_port[0].real:.1f}, {z0_port[0].imag:.1f}j)-'\ |
| 339 |
f'({z0_port[-1].real:.1f}, {z0_port[-1].imag:.1f}j) Ohm\n' |
| 340 |
else: |
| 341 |
z0_port_s = 'z0_port is not defined.' |
| 342 |
try: |
| 343 |
output = \ |
| 344 |
f'Coaxial Media. {f_s}\n'\ |
| 345 |
f'Dint = {self.Dint * 1e3:.2f} mm,'\ |
| 346 |
f' Dout = {self.Dout * 1e3:.2f} mm\n' \ |
| 347 |
f'{z0_s}\n{z0_port_s}' |
| 348 |
except(TypeError): |
| 349 |
output = \ |
| 350 |
f'Coaxial Media. {f_s}\n'\ |
| 351 |
f'Dint = {self.Dint[0] * 1e3:.2f} mm,'\ |
| 352 |
f' Dout = {self.Dout[0] * 1e3:.2f} mm\n' \ |
| 353 |
f'{z0_s}\n{z0_port_s}' |
| 354 |
return output |