Debian Codegraph @

skrf/media/mline.py

raw symbols SCIP
1 """
2 MLine (:mod:`skrf.media.MLine`)
3 ========================================
4
5 .. autosummary::
6 :toctree: generated/
7
8 MLine
9
10 """
11 from __future__ import annotations
12
13 import warnings
14 from typing import TYPE_CHECKING
15
16 import numpy as np
17 from numpy import arctan, cosh, exp, imag, log, log10, ones, real, sqrt, tanh, zeros
18 from scipy.constants import c, epsilon_0, mu_0, pi
19
20 from ..constants import NumberLike
21 from ..tlineFunctions import skin_depth, surface_resistivity
22 from .media import Media
23
24 if TYPE_CHECKING:
25 from ..frequency import Frequency
26
27
28 class MLine(Media):
29 r"""
30 A microstripline transmission line defined in terms of width, thickness
31 and height on a given relative permittivity substrate. The line has a
32 conductor resistivity and a tangential loss factor.
33
34 This class is highly inspired from the technical documentation [QUCS_tech]_
35 and sources provided by the qucs project [QUCS_repo]_ .
36
37 In addition, Djordjevic [Djordjevic]_ /Svensson [Svensson]_ wideband debye dielectric
38 model is considered to provide more realistic modelling of broadband
39 microstrip with as causal time domain response.
40
41 A compatibility mode is provided to mimic the behaviour of QUCS or of
42 Keysight ADS. There is known differences in the output of these
43 simulators.
44
45 The quasi-static models of characteristic impedance and effective
46 permittivity give the value at zero frequency. The dispersion models
47 compute a frequency-dependant values of these variables.
48
49 * Quasi-static characteristic impedance and effective permittivity models:
50
51 + Hammerstad and Jensen (default) [Hammerstad]_
52 + Schneider [Schneider1969]_
53 + Wheeler [Wheeler1942]_, [Wheeler1977]_
54
55 * Frequency dispersion of impedance and effective permittivity models:
56
57 + Hammerstad and Jensen [Hammerstad]_
58 + Kirschning and Jansen (default) [Kirschning]_
59 + Kobayashi [Kobayashi]_
60 + Schneider [Schneider1972]_
61 + Yamashita [Yamashita]_
62 + (No dispersion)
63
64 * Strip thickness correction model:
65
66 + all quasi-static models add a certain amount to W to account for
67 non-zero thickness of the strip. Computation with zero thickness is
68 possible.
69
70 Parameters
71 ----------
72 frequency : :class:`~skrf.frequency.Frequency` object
73 frequency band of the media
74 z0_port : number, array-like, or None
75 `z0_port` is the port impedance for networks generated by the media.
76 If `z0_port` is not None, the networks generated by the media are
77 renormalized (or in other words embedded) from the characteristic
78 impedance z0 of the media to `z0_port`.
79 Else if `z0_port` is None, the networks port impedances will be the raw
80 characteristic impedance z0 of the media.
81 (Default is None)
82 z0_override : number, array-like, or None
83 `z0_override` override the characteristic impedance for the media.
84 If `z0_override` is not None, the networks generated by the media have
85 their characteristic impedance `z0` overridden by `z0_override`.
86 (Default is None)
87 z0 : number, array-like, or None
88 deprecated parameter, alias to `z0_override` if `z0_override` is None.
89 Emit a deprecation warning.
90 w : number, or array-like
91 width of conductor, in m
92 h : number, or array-like
93 height of substrate between ground plane and conductor, in m
94 t : number, or array-like or None, optional
95 conductor thickness, in m. Default is None (no width correction
96 to account strip thickness).
97 ep_r : number, or array-like
98 relative permittivity of dielectric at frequency f_epr_tand, no unit
99 mu_r : number, array-like
100 relative permeability mof dielectric, no unit
101 model : str
102 microstripline quasi-static impedance and dielectric model in:
103
104 * 'hammerstadjensen' (default)
105 * 'schneider'
106 * 'wheeler'
107
108 disp : str
109 microstripline impedance and dielectric frequency dispersion model in:
110
111 * 'hammerstadjensen'
112 * 'kirschningjansen' (default)
113 * 'kobayashi'
114 * 'schneider'
115 * 'yamashita'
116 * 'none'
117
118 diel : str
119 dielectric frequency dispersion model in:
120
121 * 'djordjevicsvensson' (default)
122 * 'frequencyinvariant'
123
124 rho: number, or array-like, optional
125 resistivity of conductor, ohm / m
126 tand : number, or array-like
127 dielectric loss factor at frequency f_epr_tand
128 rough : number, or array-like
129 RMS roughness of conductor in m
130 f_low : number, or array-like
131 lower frequency for wideband Debye Djordjevic/Svensson dielectric
132 model, in Hz
133 f_high : number, or array-like
134 higher frequency for wideband Debye Djordjevic/Svensson dielectric
135 model, in Hz
136 f_epr_tand : number, or array-like
137 measurement frequency for ep_r and tand of dielectric, in Hz
138 compatibility_mode: str or None (default)
139 If set to 'qucs', following behaviour happens :
140
141 * Characteristic impedance will be real (no imaginary part due to tand)
142 * Quasi-static relative permittivity and impedance will by used for
143 loss computation instead of frequency-dispersed values
144 * Kobayashi and Yamashita models will disperse permittivity but keep
145 quasi-static impedance values
146
147 \*args, \*\*kwargs : arguments, keyword arguments
148 passed to :class:`~skrf.media.media.Media`'s constructor
149 (:func:`~skrf.media.media.Media.__init__`
150
151 Note
152 ----
153 In the case dispersion model only include effective permittivity, no
154 dispersion is used for impedance in QUCS mode and Kirschning Jansen is
155 used in ADS mode. QUCS mode is the default.
156
157 When the thickness of the strip is smaller than 3 skin depth, the losses
158 model gives over-optimistic results and the media will issue a warning.
159 At DC, the losses of the line could be smaller than its conductor
160 resistance, which is not physical.
161
162 References
163 ----------
164 .. [QUCS_tech] http://qucs.sourceforge.net/docs/technical.pdf
165 .. [QUCS_repo] https://github.com/Qucs/qucsator/blob/develop/src/components/microstrip/msline.cpp
166 .. [Hammerstad] E. Hammerstad and Ø. Jensen,
167 "Accurate Models for Microstrip Computer-Aided Design",
168 Symposium on Microwave Theory and Techniques, pp. 407-409, June 1980.
169 .. [Kirschning] M. Kirschning and R. H. Jansen,
170 "Accurate Model for Effective Dielectric Constant of Microstrip with
171 Validity up to Millimeter-Wave Frequencies", Electronics Letters,
172 vol. 8, no. 6, pp. 272-273, Mar. 1982.
173 .. [Jansen] R. H. Jansen and M. Kirschning,
174 "Arguments and an accurate Model for the Power-Current Formulation of
175 Microstrip Characteristic Impedance",
176 Archiv für Elektronik und Übertragungstechnik (AEÜ), vol. 37,
177 pp. 108-112, 1983.
178 .. [Kobayashi] M. Kobayashi,
179 "A Dispersion Formula Satisfying Recent Requirements in Microstrip
180 CAD", IEEE Trans. on Microwave Theory and Techniques, vol. 36, no. 8,
181 pp. 1246-1250, Aug. 1988.
182 .. [Schneider1969] M. V. Schneider,
183 "Microstrip Lines for Microwave Integrated Circuits",
184 The Bell System Technical Journal, vol. 48, pp. 1421-1444, May 1969.
185 .. [Schneider1972] M. V. Schneider, "Microstrip Dispersion", Proceedings of the IEEE,
186 Letters, vol. 60, Jan. 1972, pp. 144-146.
187 .. [Wheeler1977] H. A. Wheeler,
188 "Transmission-Line Properties of a Strip on a Dielectric Sheet on a
189 Plane, IEEE Trans. on Microwave Theory and Techniques, vol. 25, no. 8,
190 pp. 631-647, Aug. 1977.
191 .. [Wheeler1942] H. A. Wheeler, "Formulas for the Skin Effect,"
192 Proceedings of the IRE, vol. 30, no. 9, pp. 412-424, Sept. 1942.
193 .. [Yamashita] E. Yamashita, K. Atsuki, and T. Ueda,
194 "An Approximate Dispersion Formula of Microstrip Lines for Computer
195 Aided Design of Microwave Integrated Circuits", IEEE Trans. on
196 Microwave Theory and Techniques, vol. 27, pp. 1036-1038, Dec. 1979.
197 .. [Svensson] C. Svensson, G.E. Dermer,
198 Time domain modeling of lossy interconnects,
199 IEEE Trans. on Advanced Packaging, May 2001, N2, Vol. 24, pp.191-196.
200 .. [Djordjevic] Djordjevic, R.M. Biljic, V.D. Likar-Smiljanic, T.K. Sarkar,
201 Wideband frequency-domain characterization of FR-4 and time-domain
202 causality,
203 IEEE Trans. on EMC, vol. 43, N4, 2001, p. 662-667.
204 """
205 def __init__(self, frequency: Frequency | None = None,
206 z0_port: NumberLike | None = None,
207 z0_override: NumberLike | None = None,
208 z0: NumberLike | None = None,
209 w: NumberLike = 3, h: NumberLike = 1.6,
210 t: NumberLike | None = None,
211 ep_r: NumberLike = 4.5,
212 mu_r: NumberLike = 1.0,
213 model: str = 'hammerstadjensen',
214 disp: str = 'kirschningjansen',
215 diel: str = 'djordjevicsvensson',
216 rho: NumberLike = 1.68e-8, tand: NumberLike = 0,
217 rough: NumberLike = 0.15e-6,
218 f_low: NumberLike = 1e3, f_high: NumberLike = 1e12,
219 f_epr_tand: NumberLike = 1e9,
220 compatibility_mode: str | None = None,
221 *args, **kwargs):
222 Media.__init__(self, frequency = frequency,
223 z0_port = z0_port, z0_override = z0_override, z0 = z0)
224
225 self.w, self.h, self.t = w, h, t
226 self.ep_r, self.mu_r = ep_r, mu_r
227 self.model, self.disp, self.diel = model, disp, diel
228 self.rho, self.tand, self.rough, self.disp = rho, tand, rough, disp
229 self.f_low, self.f_high, self.f_epr_tand = f_low, f_high, f_epr_tand
230 self.compatibility_mode = compatibility_mode
231
232 # variation ofeffective permittivity with frequency
233 # Not implemented on QUCS but implemented on ADS.
234 # 'frequencyinvariant' will give a constant complex value with a real
235 # part compatible with qucs and an imaginary part due to tand
236 self.ep_r_f, self.tand_f = self.analyse_dielectric(
237 self.ep_r, self.tand,
238 self.f_low, self.f_high, self.f_epr_tand, self.frequency.f,
239 self.diel)
240
241 # quasi-static effective permittivity of substrate + line and
242 # the impedance of the microstrip line
243 # qucs use real-valued ep_r giving real-valued impedance
244 if compatibility_mode == 'qucs':
245 self.zl_eff, self.ep_reff, self.w_eff = self.analyse_quasi_static(
246 real(self.ep_r_f), self.w, self.h, self.t, self.model)
247 # ads use complex permittivity giving complex impedance and
248 # effective permittivity
249 else:
250 self.zl_eff, self.ep_reff, self.w_eff = self.analyse_quasi_static(
251 self.ep_r_f, self.w, self.h, self.t, self.model)
252
253 # analyse dispersion of impedance and relatice permittivity
254 # qucs use w here, but w_eff seems better
255 if compatibility_mode == 'qucs':
256 self._z_characteristic, self.ep_reff_f = self.analyse_dispersion(
257 self.zl_eff, self.ep_reff, real(self.ep_r_f),
258 self.w, self.w_eff, self.h, self.t,
259 self.frequency.f, self.disp)
260 else:
261 self._z_characteristic, self.ep_reff_f = self.analyse_dispersion(
262 self.zl_eff, self.ep_reff, self.ep_r_f,
263 self.w_eff, self.w_eff, self.h, self.t,
264 self.frequency.f, self.disp)
265
266 # analyse losses of line
267 # qucs use quasi-static values here, leading to a difference
268 # against ads
269 if compatibility_mode == 'qucs':
270 self.alpha_conductor, self.alpha_dielectric = self.analyse_loss(
271 real(self.ep_r_f), real(self.ep_reff), self.tand_f,
272 self.rho, self.mu_r,
273 real(self.zl_eff), real(self.zl_eff),
274 self.frequency.f, self.w, self.t, self.rough)
275 else:
276 self.alpha_conductor, self.alpha_dielectric = self.analyse_loss(
277 real(self.ep_r_f), real(self.ep_reff_f), self.tand_f,
278 self.rho, self.mu_r,
279 real(self._z_characteristic), real(self._z_characteristic),
280 self.frequency.f, self.w, self.t, self.rough)
281
282 def __str__(self) -> str:
283 f=self.frequency
284 output = (
285 f'Microstripline Media. {f.f_scaled[0]}-{f.f_scaled[-1]} {f.unit}. {f.npoints} points'
286 f'\n W= {self.w:.2e}m, H= {self.h:.2e}m')
287 return output
288
289 def __repr__(self) -> str:
290 return self.__str__()
291
292
293 @property
294 def gamma(self):
295 """
296 Propagation constant.
297
298 Returns
299 -------
300 gamma : :class:`numpy.ndarray`
301 """
302 ep_reff, f = real(self.ep_reff_f), self.frequency.f
303
304 alpha = self.alpha_dielectric.copy()
305 if self.rho is not None:
306 alpha += self.alpha_conductor
307
308 beta = 2 * pi * f* sqrt(ep_reff) / c
309
310 return alpha + 1j*beta
311
312 @property
313 def z0_characteristic(self) -> np.ndarray:
314 """
315 Characteristic Impedance, :math:`z_0`
316
317 Returns
318 -------
319 z0_characteristic : np.ndarray
320 Characteristic Impedance in units of ohms
321 """
322 if self.z0_override is None:
323 return self._z_characteristic
324 else:
325 return self.z0_override
326
327 @property
328 def Z0_f(self) -> np.ndarray:
329 """
330 Alias fos Characteristic Impedance for backward compatibility.
331 Deprecated, do not use.
332
333 Returns
334 -------
335 z0 : :class:`numpy.ndarray`
336 """
337 warnings.warn(
338 "`Z0_f` is deprecated, use `Z0` instead",
339 DeprecationWarning, stacklevel = 2
340 )
341 return self._z_characteristic
342
343 def analyse_dielectric(self, ep_r: NumberLike, tand: NumberLike,
344 f_low: NumberLike, f_high: NumberLike,
345 f_epr_tand: NumberLike, f: NumberLike,
346 diel: str):
347 """
348 This function calculate the frequency dependent relative permittivity
349 of dielectric and and tangential loss factor.
350
351 References
352 ----------
353 .. [#] C. Svensson, G.E. Dermer,
354 Time domain modeling of lossy interconnects,
355 IEEE Trans. on Advanced Packaging, May 2001, N2, Vol. 24, pp.191-196.
356 .. [#] Djordjevic, R.M. Biljic, V.D. Likar-Smiljanic, T.K. Sarkar,
357 Wideband frequency-domain characterization of FR-4 and time-domain
358 causality,
359 IEEE Trans. on EMC, vol. 43, N4, 2001, p. 662-667.
360
361 Returns
362 -------
363 ep_r_f : :class:`numpy.ndarray`
364 tand_f : :class:`numpy.ndarray`
365 """
366 if diel == 'djordjevicsvensson':
367 # compute the slope for a log frequency scale, tanD dependent.
368 k = log((f_high + 1j * f_epr_tand) / (f_low + 1j * f_epr_tand))
369 fd = log((f_high + 1j * f) / (f_low + 1j * f))
370 ep_d = -tand * ep_r / imag(k)
371 # value for frequency above f_high
372 ep_inf = ep_r * (1. + tand * real(k) / imag(k))
373 # compute complex permitivity
374 ep_r_f = ep_inf + ep_d * fd
375 # get tand
376 tand_f = -imag(ep_r_f) / real(ep_r_f)
377 elif diel == 'frequencyinvariant':
378 ep_r_f = ep_r - 1j * ep_r * tand
379 tand_f = tand
380 else:
381 raise ValueError('Unknown dielectric dispersion model')
382
383 return ep_r_f, tand_f
384
385 def analyse_quasi_static(self, ep_r: NumberLike,
386 w: NumberLike, h: NumberLike, t: NumberLike,
387 model: str):
388 """
389 This function calculates the quasi-static impedance of a microstrip
390 line, the value of the effective permittivity as per filling factor
391 and the effective width due to the finite conductor thickness for the
392 given microstrip line and substrate properties.
393
394 References
395 ----------
396 .. [#] E. Hammerstad and Ø. Jensen,
397 "Accurate Models for Microstrip Computer-Aided Design", Symposium
398 on Microwave Theory and Techniques, pp. 407-409, June 1980.
399 .. [#] H. A. Wheeler,
400 "Transmission-Line Properties of a Strip on a Dielectric Sheet on a
401 Plane, IEEE Trans. on Microwave Theory and Techniques, vol. 25,
402 no. 8, pp. 631-647, Aug. 1977.
403 .. [#] M. V. Schneider,
404 "Microstrip Lines for Microwave Integrated Circuits",
405 The Bell System Technical Journal, vol. 48, pp. 1421-1444, May 1969.
406
407 Returns
408 -------
409 zl_eff : :class:`numpy.ndarray`
410 ep_reff : :class:`numpy.ndarray`
411 """
412 Z0 = sqrt(mu_0 / epsilon_0)
413 zl_eff = Z0
414 ep_reff = ep_r
415 w_eff = w
416
417 if model == 'wheeler':
418 # compute strip thickness effect
419 dw1 = 0
420 if t is not None and t > 0:
421 dw1 = t / pi * log(4. * exp(1.) / sqrt((t / h)**2) + \
422 (1. / pi / (w / t + 1.1))**2)
423 dwr = (1. + 1. / ep_r) / 2. * dw1
424 wr = w + dwr
425 w_eff = wr
426
427 # compute characteristic impedance
428 if (w / h) < 3.3:
429 cp = log(4. * h / wr + sqrt((4 * h / wr)**2 + 2))
430 b = (ep_r - 1.) / (ep_r + 1.) / \
431 2 * (log(pi / 2.) + log(4. / pi) / ep_r)
432 zl_eff = (cp - b) * Z0 / pi / sqrt(2 * (ep_r + 1.))
433 else:
434 cp = 1 + log(pi / 2.) + log(wr / h / 2. + 0.94)
435 d = 1. / pi / 2. * (1. + log(pi**2 / 16.)) * (ep_r - 1.) \
436 / ep_r**2
437 x = 2. * log(2.) / pi + wr / h / 2. + (ep_r + 1.) / 2 / pi / \
438 ep_r * cp + d
439 zl_eff = Z0 / 2 / x / sqrt(ep_r)
440
441 # compute effective dielectric constant
442 if (w / h) < 1.3:
443 a = log(8 * h / wr) + (wr / h)**2 / 32
444 b = (ep_r - 1.) / (ep_r + 1.) / \
445 2 * (log(pi / 2.) + log(4. / pi) / ep_r)
446 ep_reff = (ep_r + 1.) / 2. * (a / (a - b))**2
447 else:
448 # qucsator is 4.0137 but doc 0.94 * 2 = 1.88
449 d = (ep_r - 1.) / 2. / pi / ep_r * \
450 (log(2.1349 * wr / h + 4.0137) - 0.5169 / ep_r)
451 e = wr / h / 2 + 1. / pi * log(8.5397 * wr / h + 16.0547)
452 ep_reff = ep_r * ((e - d) / e)**2
453
454 elif model == 'schneider':
455 u = w / h
456 dw = 0
457
458 # consider strip thickness equations
459 if t is not None and t > 0:
460 if t < (w / 2):
461 if u < (1. / pi / 2):
462 arg = 2 * pi * w / t
463 else:
464 arg = h / t
465 dw = t / pi * (1. + log(2 * arg))
466 if (t / dw) >= 0.75:
467 dw = 0
468 w_eff = w + dw
469 u = w_eff / h
470
471 # effective dielectric constant
472 ep_reff = (ep_r + 1.) / 2. + (ep_r - 1.) / 2. / sqrt (1. + 10. / u)
473
474 # characteristic impedance
475 if u < 1.:
476 z = 1. / pi / 2. * log(8. / u + u / 4)
477 else:
478 z = 1. / (u + 2.42 - 0.44 / u + (1. - 1. / u)**6)
479 zl_eff = Z0 * z / sqrt(ep_reff)
480
481 elif model == 'hammerstadjensen':
482 u = w / h
483 if t is not None:
484 t = t/h
485 du1 = 0.
486
487 # compute strip thickness effect
488 if t is not None and t > 0:
489 # Qucs formula 11.22 is wrong, normalized w has to be used instead (see Hammerstad and Jensen Article)
490 # Normalized w is named u and is actually used in qucsator source code
491 # coth(alpha) = 1/tanh(alpha)
492 du1 = t / pi * log(1. + 4. * exp(1.) / t * tanh(sqrt(6.517 * u))**2)
493
494 # sech(alpha) = 1/cosh(alpha)
495 dur = du1 * (1. + 1. / cosh(sqrt(ep_r - 1.))) / 2.
496
497 u1 = u + du1
498 ur = u + dur
499 w_eff = ur * h
500
501 # compute impedances for homogeneous medium
502 zr = hammerstad_zl(ur)
503 z1 = hammerstad_zl(u1)
504
505 # compute effective dielectric constant
506 a, b = hammerstad_ab(ur, ep_r)
507 e = hammerstad_er(ur, ep_r, a, b)
508
509 # compute final characteristic impedance and dielectric constant
510 #including strip thickness effects
511 zl_eff = zr / sqrt(e)
512 ep_reff = e * (z1 / zr)**2
513
514 else:
515 raise ValueError('Unknown microstripline quasi-static model')
516
517 return zl_eff, ep_reff, w_eff
518
519 def analyse_dispersion(self, zl_eff: NumberLike, ep_reff: NumberLike,
520 ep_r: NumberLike, wr: NumberLike, w_eff: NumberLike,
521 h: NumberLike, t: NumberLike, f: NumberLike,
522 disp: str):
523 """
524 This function compute the frequency dependent characteristic
525 impedance and effective permittivity accounting for microstripline
526 frequency dispersion.
527
528 References
529 ----------
530 .. [#] M. Kobayashi,
531 "A Dispersion Formula Satisfying Recent Requirements in Microstrip
532 CAD", IEEE Trans. on Microwave Theory and Techniques, vol. 36,
533 no. 8, pp. 1246-1250, Aug. 1988.
534 .. [#] M. V. Schneider, "Microstrip Dispersion", Proceedings of the
535 IEEE, Letters, vol. 60, Jan. 1972, pp. 144-146.
536 .. [#] M. Kirschning and R. H. Jansen,
537 "Accurate Model for Effective Dielectric Constant of Microstrip
538 with Validity up to Millimeter-Wave Frequencies", Electronics
539 Letters, vol. 8, no. 6, pp. 272-273, Mar. 1982.
540 .. [#] R. H. Jansen and M. Kirschning,
541 "Arguments and an accurate Model for the Power-Current Formulation of
542 Microstrip Characteristic Impedance",
543 Archiv für Elektronik und Übertragungstechnik (AEÜ), vol. 37,
544 pp. 108-112, 1983.
545 .. [#] E. Yamashita, K. Atsuki, and T. Ueda,
546 "An Approximate Dispersion Formula of Microstrip Lines for
547 Computer Aided Design of Microwave Integrated Circuits",
548 IEEE Trans. on Microwave Theory and Techniques, vol. 27,
549 pp. 1036-1038, Dec. 1979.
550
551 Returns
552 -------
553 z : :class:`numpy.ndarray`
554 e : :class:`numpy.ndarray`
555 """
556 u = wr/h
557 if disp == 'schneider':
558 k = sqrt(ep_reff / ep_r)
559 fn = 4. * h * f / c * sqrt(ep_r - 1.)
560 fn2 = fn**2
561 e = ep_reff * ((1. + fn2) / (1. + k * fn2))**2
562 z = zl_eff * sqrt(ep_reff / e)
563 elif disp == 'hammerstadjensen':
564 Z0 = sqrt(mu_0 / epsilon_0)
565 g = pi**2 / 12 * (ep_r - 1) / ep_reff * sqrt(2 * pi * zl_eff / Z0)
566 fp = (2 * mu_0 * h * f) / zl_eff
567 e = ep_r - (ep_r - ep_reff) / (1 + g * fp**2)
568 z = zl_eff * sqrt(ep_reff / e) * (e - 1) / (ep_reff - 1)
569 elif disp == 'kirschningjansen':
570 fn = f * h * 1e-6
571 e = kirsching_er(u, fn, ep_r, ep_reff)
572 z, _ = kirsching_zl(u, fn, ep_r, ep_reff, e, zl_eff)
573 elif disp == 'yamashita':
574 k = sqrt(ep_r / ep_reff)
575 fp = 4 * h * f / c * sqrt(ep_r - 1) * \
576 (0.5 + (1 + 2 * log10(1 + u))**2)
577 e = ep_reff * ((1 + k * fp**1.5 / 4) / (1 + fp**1.5 / 4))**2
578 # qucs keep quasi-static impedance here
579 if self.compatibility_mode == 'qucs':
580 z = np.ones(f.shape) * zl_eff
581 # use Kirschning Jansen for impedance dispersion by default
582 else:
583 fn = f * h * 1e-6
584 z, _ = kirsching_zl(wr / h, fn, ep_r, ep_reff, e, zl_eff)
585 elif disp == 'kobayashi':
586 fk = c * arctan(ep_r * sqrt((ep_reff - 1) / (ep_r - ep_reff)))/ \
587 (2 * pi * h * sqrt(ep_r - ep_reff))
588 fh = fk / (0.75 + (0.75 - 0.332 / (ep_r**1.73)) * u)
589 no = 1 + 1 / (1 + sqrt(u)) + 0.32 * (1 / (1 + sqrt(u)))**3
590 nc = np.where(u < 0.7,
591 1 + 1.4 / (1 + u) * (0.15 - 0.235 * exp(-0.45 * f / fh)),
592 1)
593 n = np.where(no * nc < 2.32, no * nc, 2.32)
594 e = ep_r - (ep_r - ep_reff) / (1 + (f / fh)**n)
595 # qucs keep quasi-static impedance here
596 if self.compatibility_mode == 'qucs':
597 z = np.ones(f.shape) * zl_eff
598 # use Kirschning Jansen for impedance dispersion by default
599 else:
600 fn = f * h * 1e-6
601 z, _ = kirsching_zl(wr / h, fn, ep_r, ep_reff, e, zl_eff)
602 elif disp == 'none':
603 e = ones(f.shape) * ep_reff
604 z = ones(f.shape) * zl_eff
605
606 else:
607 raise ValueError('Unknown microstripline dispersion model')
608
609 return z, e
610
611 def analyse_loss(self, ep_r: NumberLike, ep_reff: NumberLike,
612 tand: NumberLike, rho: NumberLike, mu_r: NumberLike,
613 zl_eff_f1: NumberLike, zl_eff_f2: NumberLike,
614 f: NumberLike, w: NumberLike, t: NumberLike,
615 D: NumberLike):
616 """
617 The function calculates the conductor and dielectric losses of a
618 single microstrip line using wheeler's incremental inductance rule.
619
620 References
621 ----------
622 .. [#] H. A. Wheeler, "Formulas for the Skin Effect,"
623 Proceedings of the IRE, vol. 30, no. 9, pp. 412-424, Sept. 1942.
624
625 Returns
626 -------
627 a_conductor : :class:`numpy.ndarray`
628 a_dielectric : :class:`numpy.ndarray`
629 """
630 # limited to only Hammerstad and Jensen model
631 Z0 = np.sqrt(mu_0/epsilon_0)
632
633 # conductor losses
634 if t is not None and t > 0:
635 if rho is None:
636 raise(AttributeError('must provide resistivity rho. '
637 'see initializer help'))
638 else:
639 Rs = surface_resistivity(f=f, rho=rho, mu_r=1)
640 ds = skin_depth(f, rho, mu_r)
641 if(np.any(t < 3 * ds)):
642 warnings.warn(
643 'Conductor loss calculation invalid for line'
644 f'height t ({t}) < 3 * skin depth ({ds[0]})',
645 RuntimeWarning, stacklevel=2
646 )
647 # current distribution factor
648 Ki = exp(-1.2 * ((zl_eff_f1 + zl_eff_f2) / 2 / Z0)**0.7)
649 # D is RMS surface roughness
650 Kr = 1 + 2 / pi * arctan(1.4 * (D/ds)**2)
651 a_conductor = Rs / (zl_eff_f1 * w) * Ki * Kr
652 else:
653 a_conductor = zeros(f.shape)
654
655 # dielectric losses
656 l0 = c / f
657 a_dielectric = pi * ep_r / (ep_r - 1) * (ep_reff - 1) / \
658 sqrt(ep_reff) * tand / l0
659
660 return a_conductor, a_dielectric
661
662 def hammerstad_ab(u: NumberLike, ep_r: NumberLike) -> NumberLike:
663 """
664 Hammerstad parameters for relative permittivity dispersion.
665 """
666 a = 1. + log((u**4 + (u / 52.)**2) / (u**4 + 0.432)) / 49. \
667 + log(1 + (u / 18.1)**3) / 18.7
668
669 b = 0.564 * ((ep_r - 0.9) / (ep_r + 3.))**0.053
670
671 return a, b
672
673 def hammerstad_zl(u: NumberLike) -> NumberLike:
674 """
675 Hammerstad quasi-static impedance.
676 """
677 fu = 6 + (2 * pi - 6) * exp(-(30.666 / u)**0.7528)
678 Z0 = sqrt(mu_0/epsilon_0)
679 return Z0 / 2. / pi * log(fu / u + sqrt(1. + (2. / u)**2))
680
681 def hammerstad_er(u: NumberLike, ep_r: NumberLike, a: NumberLike,
682 b: NumberLike) -> NumberLike:
683 """
684 Hammerstad quasi-static relative permittivity.
685 """
686 return (ep_r + 1) / 2 + (ep_r - 1) / 2 * (1. + 10. / u)**(-a * b)
687
688 def kirsching_zl(u: NumberLike, fn: NumberLike,
689 ep_r: NumberLike, ep_reff: NumberLike, ep_reff_f: NumberLike,
690 zl_eff: NumberLike):
691 """
692 Kirschning Jansen impedance dispersion.
693 """
694 #fn = f * h * 1e-6 # GHz-mm
695 R1 = np.minimum(0.03891 * ep_r**1.4, 20.)
696 R2 = np.minimum(0.2671 * u**7, 20.)
697 R3 = 4.766 * exp(-3.228 * u**0.641)
698 R4 = 0.016 + (0.0514 * ep_r)**4.524
699 R5 = (fn / 28.843)**12
700 R6 = np.minimum(22.20 * u **1.92, 20.)
701 R7 = 1.206 - 0.3144 * exp(-R1) * (1 - exp(-R2))
702 R8 = 1 + 1.275 * (1 - exp(-0.004625 * R3 * ep_r**1.674 \
703 * (fn / 18.365)**2.745))
704 R9 = 5.086 * R4 * R5/(0.3838 + 0.386 * R4) \
705 * exp(-R6) / (1 + 1.2992 * R5) \
706 * (ep_r - 1)**6 / (1 + 10 * (ep_r - 1)**6)
707 R10 = 0.00044 * ep_r**2.136 + 0.0184
708 R11 = (fn / 19.47)**6 / (1 + 0.0962 * (fn / 19.47)**6)
709 R12 = 1 / (1 + 0.00245 * u**2)
710 R13 = 0.9408 * ep_reff_f**R8 - 0.9603
711 R14 = (0.9408 - R9) * ep_reff**R8 - 0.9603
712 R15 = 0.707 * R10 * (fn / 12.3)**1.097
713 R16 = 1 + 0.0503 * ep_r**2 * R11 * (1 - exp(-(u / 15)**6))
714 R17 = R7 * (1 - 1.1241 * R12 / R16 \
715 *exp(-0.026 * fn**1.15656 - R15))
716 return zl_eff * (R13 / R14)**R17, R17
717
718 def kirsching_er(u: NumberLike, fn: NumberLike,
719 ep_r: NumberLike, ep_reff: NumberLike):
720 """
721 Kirschning Jansen relative permittivity dispersion.
722 """
723 # in the paper fn is in GHz-cm while in Qucs it is GHz-mm, thus a factor
724 # 10 for all constant that multiply or divide fn
725 P1 = 0.27488 + (0.6315 + 0.525 / ( 1+ 0.0157 * fn)**20) * u \
726 -0.065683 * exp(-8.7513 * u)
727 P2 = 0.33622 * (1 -exp(-0.03442 * ep_r))
728 P3 = 0.0363 * exp(-4.6 * u) * (1 - exp(-(fn / 38.7)**4.97))
729 P4 = 1 + 2.751 * (1 - exp(-(ep_r / 15.916)**8))
730 Pf = P1 * P2 * ((0.1844 + P3 * P4) * fn)**1.5763
731 return ep_r - (ep_r - ep_reff) / (1 + Pf)