Debian Codegraph @

skrf/media/cpw.py

raw symbols SCIP
1 """
2 cpw (:mod:`skrf.media.cpw`)
3 ========================================
4
5 .. autosummary::
6 :toctree: generated/
7
8 CPW
9
10 """
11 from __future__ import annotations
12
13 import warnings
14 from typing import TYPE_CHECKING
15
16 from numpy import any, exp, imag, log, real, sinh, sqrt, tanh, zeros
17 from scipy.constants import c, epsilon_0, mu_0, pi
18 from scipy.special import ellipk
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 CPW(Media):
29 r"""
30 Coplanar waveguide.
31
32
33 A coplanar waveguide transmission line is defined in terms of width,
34 spacing, and thickness on a given relative permittivity substrate of a
35 certain height. The line has a conductor resistivity and a tangential loss
36 factor. The backside of the strip can be made of air or metal (grounded
37 coplanar waveguide).
38
39 This class is highly inspired by the technical documentation [QUCSa]_
40 and sources provided by the qucs project [QUCSb]_ .
41
42 In addition, Djordjevic [DBLS01]_ /Svensson [SvDe01]_ wideband debye dielectric
43 model is considered to provide a more realistic modelling of broadband
44 microstrip with causal time domain response.
45
46 A compatibility mode is provided to mimic the behaviour of QUCS or of
47 Keysight ADS. There is known differences in the output of these
48 simulators.
49
50 The quasi-static models of characteristic impedance and effective
51 permittivity give the value at zero frequency. The dispersion models
52 compute frequency-dependant values of these variables.
53
54 * Quasi-static characteristic impedance and effective permittivity model
55 use [GhNa84]_ and [GhNa83]_. The models are corrected to account for
56 strip thickness using a first-order approach described in [GGBB96]_.
57 A comparison shows that ADS simulator uses another thickness correction
58 method that is according to ADS doc based on [Cohn60]_. This second method
59 is not implemented in skrf.
60
61 * Frequency dispersion of impedance and effective permittivity model use
62 [FGVM91]_ and [GMDK97]_.
63
64 * Loss model is computed using Wheeler's incremental inductance rule
65 [Whee42]_ applied to coplanar waveguide by [OwWu58]_ and [Ghio93]_.
66
67 Parameters
68 ----------
69 frequency : :class:`~skrf.frequency.Frequency` object, optional
70 frequency band of the media. The default is None.
71 z0_port : number, array-like, or None
72 `z0_port` is the port impedance for networks generated by the media.
73 If `z0_port` is not None, the networks generated by the media are
74 renormalized (or in other words embedded) from the characteristic
75 impedance z0 of the media to `z0_port`.
76 Else if `z0_port` is None, the networks port impedances will be the raw
77 characteristic impedance z0 of the media.
78 (Default is None)
79 z0_override : number, array-like, or None
80 `z0_override` override the characteristic impedance for the media.
81 If `z0_override` is not None, the networks generated by the media have
82 their characteristic impedance `z0` overridden by `z0_override`.
83 (Default is None)
84 z0 : number, array-like, or None
85 deprecated parameter, alias to `z0_override` if `z0_override` is None.
86 Emit a deprecation warning.
87 w : number, or array-like
88 width of the center conductor, in m. Default is 3e-3 m.
89 s : number, or array-like
90 spacing (width of the gap), in m. Default is 0.3e-3 m.
91 h : number, or array-like
92 height of the substrate between backside and conductor, in m.
93 Default is 1.55 m (equivalent to infinite height for default w and s).
94 t : number, or array-like, optional
95 conductor thickness, in m. Default is None (no width correction
96 to account for strip thickness).
97 has_metal_backside : bool, default False
98 If the backside is air (False) or metal (True)
99 ep_r : number, or array-like, optional
100 relative permittivity of the substrate at frequency f_epr_tand,
101 no unit. Default is 4.5.
102 diel : str
103 dielectric frequency dispersion model in:
104
105 * 'djordjevicsvensson' (default)
106 * 'frequencyinvariant'
107
108 rho : number, or array-like, or None
109 resistivity of conductor, ohm / m. Default is 1.68e-8 ohm /m (copper).
110 tand : number, or array-like
111 dielectric loss factor at frequency f_epr_tand. Default is 0.
112 f_low : number, or array-like
113 lower frequency for wideband Debye Djordjevic/Svensson dielectric
114 model, in Hz. Default is 1 kHz.
115 f_high : number, or array-like
116 higher frequency for wideband Debye Djordjevic/Svensson dielectric
117 model, in Hz. Default is 1 THz.
118 f_epr_tand : number, or array-like
119 measurement frequency for ep_r and tand of dielectric, in Hz.
120 Default is 1 GHz.
121 compatibility_mode: str or None (default)
122 If set to 'qucs', following behaviour happens :
123
124 * Characteristic impedance will be real (no imaginary part due to tand)
125
126 \*args, \*\*kwargs : arguments, keyword arguments
127 passed to :class:`~skrf.media.media.Media`'s constructor
128 (:func:`~skrf.media.media.Media.__init__`
129
130 Note
131 ----
132 When the thickness of the strip is smaller than 3 skin depth, the losses
133 model gives over-optimistic results and the media will issue a warning.
134 At DC, the losses of the line could be smaller than its conductor
135 resistance, which is not physical.
136
137 References
138 ----------
139 .. [QUCSa] http://qucs.sourceforge.net/docs/technical.pdf
140 .. [QUCSb] http://www.qucs.sourceforge.net/
141 .. [DBLS01] Djordjevic, R.M. Biljic, V.D. Likar-Smiljanic, T.K. Sarkar,
142 Wideband frequency-domain characterization of FR-4 and time-domain
143 causality,
144 IEEE Trans. on EMC, vol. 43, N4, 2001, p. 662-667.
145 .. [SvDe01] C. Svensson, G.E. Dermer,
146 Time domain modeling of lossy interconnects,
147 IEEE Trans. on Advanced Packaging, May 2001, N2, Vol. 24, pp.191-196.
148 .. [GhNa84] G. Ghione and C. Naldi. "Analytical Formulas for Coplanar Lines
149 in Hybrid and Monolithic MICs", Electronics Letters,
150 Vol. 20, No. 4, February 16, 1984, pp. 179-181.
151 .. [GhNa83] G. Ghione and C. Naldi. "Parameters of Coplanar Waveguides with
152 Lower Common Planes", Electronics Letters,
153 Vol. 19, No. 18, September 1, 1983, pp. 734-735.
154 .. [Cohn60] S. B. Cohn, "Thickness Corrections for Capacitive obstacles and
155 Strip Conductors", IRE Trans. on Microwave Theory and Techniques,
156 Vol. MTT-8, November 1960, pp. 638-644.
157 .. [GGBB96] K. C. Gupta, R. Garg, I. J. Bahl, and P. Bhartia, Microstrip
158 Lines and Slotlines, 2nd ed.Artech House, Inc., 1996.
159 .. [FGVM91] M. Y. Frankel, S. Gupta, J. A. Valdmanis, and G. A. Mourou,
160 "Terahertz Attenuation and Dispersion Characteristics of Coplanar
161 Transmission Lines" IEEE Trans. on Microwave Theory and Techniques,
162 vol. 39, no. 6, pp. 910-916, June 1991.
163 .. [GMDK97] S. Gevorgian, T. Martinsson, A. Deleniv, E. Kollberg, and
164 I. Vendik, "Simple and accurate dispersion expression for the
165 effective dielectric constant of coplanar waveguides" in
166 Proceedings of Microwaves, Antennas and Propagation,
167 vol. 144, no. 2.IEE, Apr. 1997, pp. 145-148.
168 .. [Whee42] H. A. Wheeler, "Formulas for the Skin Effect,"
169 Proceedings of the IRE, vol. 30, no. 9, pp. 412-424, Sept. 1942.
170 .. [OwWu58] G. H. Owyang and T. T. Wu, "The Approximate Parameters of Slot
171 Lines and Their Complement" IRE Transactions on Antennas and
172 Propagation, pp. 49-55, Jan. 1958.
173 .. [Ghio93] G. Ghione, "A CAD-Oriented Analytical Model for the Losses of
174 General Asymmetric Coplanar Lines in Hybrid and Monolithic MICs"
175 IEEE Trans. on Microwave Theory and Techniques,
176 vol. 41, no. 9, pp. 1499-1510, Sept. 1993.
177
178 """
179 def __init__(self, frequency: Frequency | None = None,
180 z0_port: NumberLike | None = None,
181 z0_override: NumberLike | None = None,
182 z0: NumberLike | None = None,
183 w: NumberLike = 3e-3, s: NumberLike = 0.3e-3,
184 h: NumberLike = 1.55,
185 ep_r: NumberLike = 4.5, t: NumberLike | None = None,
186 diel: str = 'djordjevicsvensson',
187 rho: NumberLike | None = 1.68e-8, tand: NumberLike = 0,
188 f_low: NumberLike = 1e3, f_high: NumberLike = 1e12,
189 f_epr_tand: NumberLike = 1e9,
190 has_metal_backside: bool = False,
191 compatibility_mode: str | None = None,
192 *args, **kwargs):
193 Media.__init__(self, frequency = frequency,
194 z0_port = z0_port, z0_override = z0_override, z0 = z0)
195
196 self.w, self.s, self.h, self.t, self.ep_r, self.tand, self.rho =\
197 w, s, h, t, ep_r, tand, rho
198 self.diel = diel
199 self.f_low, self.f_high, self.f_epr_tand = f_low, f_high, f_epr_tand
200 self.has_metal_backside = has_metal_backside
201 self.compatibility_mode = compatibility_mode
202
203 # variation of effective permittivity with frequency
204 # Not implemented in QUCS but implemented in ADS.
205 # 'frequencyinvariant' will give a constant complex value with a real
206 # part compatible with qucs and an imaginary part due to tand
207 self.ep_r_f, self.tand_f = self.analyse_dielectric(
208 self.ep_r, self.tand,
209 self.f_low, self.f_high, self.f_epr_tand, self.frequency.f,
210 self.diel)
211
212 # quasi-static effective permittivity of substrate + line and
213 # the impedance of the coplanar waveguide
214 # qucs use real-valued ep_r giving real-valued impedance
215 if compatibility_mode == 'qucs':
216 self.zl_eff, self.ep_reff, k1, kk1, kpk1 = \
217 self.analyse_quasi_static(
218 real(self.ep_r_f), w, s, h, t, has_metal_backside)
219 else:
220 self.zl_eff, self.ep_reff, k1, kk1, kpk1 = \
221 self.analyse_quasi_static(
222 self.ep_r_f, w, s, h, t, has_metal_backside)
223
224 # analyse dispersion of impedance and relatice permittivity
225 if compatibility_mode == 'qucs':
226 self._z_characteristic, self.ep_reff_f = self.analyse_dispersion(
227 self.zl_eff, self.ep_reff, real(self.ep_r_f), w, s, h,
228 self.frequency.f)
229 # ads does not use frequency dispersion for cpw/cpwg (so sad)
230 elif compatibility_mode == 'ads':
231 self._z_characteristic = self.zl_eff
232 self.ep_reff_f = self.ep_reff
233 # use frequency dispersion and complex permittivity by default
234 else:
235 self._z_characteristic, self.ep_reff_f = self.analyse_dispersion(
236 self.zl_eff, self.ep_reff, self.ep_r_f, w, s, h,
237 self.frequency.f)
238
239 # analyse losses of line
240 self.alpha_conductor, self.alpha_dielectric = self.analyse_loss(
241 real(self.ep_r_f), real(self.ep_reff_f), self.tand_f, rho, 1.,
242 self.frequency.f,
243 w, t, s, k1, kk1, kpk1)
244
245 def __str__(self) -> str:
246 f=self.frequency
247 output = (f'Coplanar Waveguide Media. {f.f_scaled[0]}-{f.f_scaled[-1]} {f.unit}. {f.npoints} points'
248 f'\n W= {self.w:.2e}m, S= {self.s:.2e}m')
249 return output
250
251 def __repr__(self) -> str:
252 return self.__str__()
253
254 @property
255 def z0_characteristic(self) -> NumberLike:
256 """
257 Characteristic Impedance, :math:`z_0`.
258
259 Returns
260 -------
261 z0_characteristic : np.ndarray
262 Characteristic Impedance in units of ohms
263 """
264 return self._z_characteristic
265
266 @property
267 def gamma(self) -> NumberLike:
268 """
269 Propagation constant.
270
271 Returns
272 -------
273 gamma : :class:`numpy.ndarray`
274 """
275 ep_reff, f = real(self.ep_reff_f), self.frequency.f
276
277 alpha = self.alpha_dielectric.copy()
278 if self.rho is not None:
279 alpha += self.alpha_conductor
280
281 beta = 2. * pi * f * sqrt(ep_reff) / c
282
283 return alpha + 1j * beta
284
285 def analyse_dielectric(self, ep_r: NumberLike, tand: NumberLike,
286 f_low: NumberLike, f_high: NumberLike,
287 f_epr_tand: NumberLike, f: NumberLike,
288 diel: str):
289 """
290 This function calculate the frequency-dependent relative permittivity
291 of dielectric and tangential loss factor.
292
293 References
294 ----------
295 .. [#] C. Svensson, G.E. Dermer,
296 Time domain modeling of lossy interconnects,
297 IEEE Trans. on Advanced Packaging, May 2001, N2, Vol. 24, pp.191-196.
298 .. [#] Djordjevic, R.M. Biljic, V.D. Likar-Smiljanic, T.K. Sarkar,
299 Wideband frequency-domain characterization of FR-4 and time-domain
300 causality,
301 IEEE Trans. on EMC, vol. 43, N4, 2001, p. 662-667.
302
303 Returns
304 -------
305 ep_r_f : :class:`numpy.ndarray`
306 tand_f : :class:`numpy.ndarray`
307 """
308 if diel == 'djordjevicsvensson':
309 # compute the slope for a log frequency scale, tanD dependent.
310 k = log((f_high + 1j * f_epr_tand) / (f_low + 1j * f_epr_tand))
311 fd = log((f_high + 1j * f) / (f_low + 1j * f))
312 ep_d = -tand * ep_r / imag(k)
313 # value for frequency above f_high
314 ep_inf = ep_r * (1. + tand * real(k) / imag(k))
315 # compute complex permitivity
316 ep_r_f = ep_inf + ep_d * fd
317 # get tand
318 tand_f = -imag(ep_r_f) / real(ep_r_f)
319 elif diel == 'frequencyinvariant':
320 ep_r_f = ep_r - 1j * ep_r * tand
321 tand_f = tand
322 else:
323 raise ValueError('Unknown dielectric dispersion model')
324
325 return ep_r_f, tand_f
326
327 def analyse_quasi_static(self, ep_r: NumberLike,
328 w: NumberLike, s: NumberLike,
329 h: NumberLike, t: NumberLike,
330 has_metal_backside: bool):
331 """
332 Calculates quasi-static impedance of a coplanar waveguide line.
333
334 The value of the effective permittivity as per filling
335 factor, and the effective width due to the finite conductor thickness
336 for the given coplanar waveguide line and substrate properties.
337 Model from [GhNa84]_ with air backside and [GhNa83]_ with a metal backside.
338 The models are corrected to account for
339 strip thickness using a first-order approach described in [GGBB96]_.
340 ADS simulator report to use a custom correction based on [Cohn60]_.
341 This second method is not implemented in skrf.
342
343 References
344 ----------
345 .. [GhNa84] G. Ghione and C. Naldi. "Analytical Formulas for Coplanar Lines
346 in Hybrid and Monolithic MICs", Electronics Letters,
347 Vol. 20, No. 4, February 16, 1984, pp. 179-181.
348 .. [GhNa83] G. Ghione and C. Naldi. "Parameters of Coplanar Waveguides with
349 Lower Common Planes", Electronics Letters,
350 Vol. 19, No. 18, September 1, 1983, pp. 734-735.
351 .. [Cohn60] S. B. Cohn, "Thickness Corrections for Capacitive obstacles and
352 Strip Conductors", IRE Trans. on Microwave Theory and Techniques,
353 Vol. MTT-8, November 1960, pp. 638-644.
354 .. [GGBB96] K. C. Gupta, R. Garg, I. J. Bahl, and P. Bhartia, Microstrip
355 Lines and Slotlines, 2nd ed.Artech House, Inc., 1996.
356
357 Returns
358 -------
359 zl_eff : :class:`numpy.ndarray`
360 ep_reff : :class:`numpy.ndarray`
361 """
362 Z0 = sqrt(mu_0 / epsilon_0)
363 a = w
364 b = w + 2. * s
365
366 # equation (3a) from [GhNa84] or (6) from [GhNa83]
367 k1 = a / b
368 kk1 = ellipk(k1)
369 kpk1 = ellipk(sqrt(1. - k1 * k1))
370 q1 = ellipa(k1)
371
372 # backside is metal
373 if has_metal_backside:
374 # equation (4) from [GhNa83]
375 # in qucs the 2 coefficient turn to 4 and fit better with ads
376 k3 = tanh(pi * a / 4. / h) / tanh(pi * b / 4. / h)
377 q3 = ellipa(k3)
378 qz = 1. / (q1 + q3)
379 # equation (7) from [GhNa83]
380 # equivalent to e = (q1 + ep_r * q3) / (q1 + q3) and paper
381 e = 1. + q3 * qz * (ep_r - 1.)
382 # equation (8) from [GhNa83] with later division by sqrt(e)
383 zr = Z0 / 2. * qz
384
385 # backside is air
386 else:
387 # equation (3b) from [GhNa84]
388 k2 = sinh((pi / 4.) * a / h) / sinh((pi / 4.) * b / h)
389 q2 = ellipa(k2)
390 # equation (2) from [GhNa84]
391 e = 1. + (ep_r - 1.) / 2. * q2 / q1
392 # equation (1) from [GhNa84] with later division by sqrt(e)
393 zr = Z0 / 4. / q1
394
395 # a posteriori effect of strip thickness
396 if t is not None and t > 0.:
397 # equation (7.98) from [GGBB96]
398 d = 1.25 * t / pi * (1. + log(4. * pi * w / t))
399 # equation between (7.99) and (7.100) from [GGBB96]
400 #approx. equal to ke = (w + d) / (w + d + 2 * (s - d))
401 ke = k1 + (1. - k1 * k1) * d / 2. / s
402 qe = ellipa(ke)
403
404 # backside is metal
405 if has_metal_backside:
406 # equation (8) from [GhNa83] with k1 -> ke
407 # but keep q3 unchanged ? (not in papers)
408 qz = 1. / (qe + q3)
409 zr = Z0 / 2. * qz
410 # backside is air
411 else:
412 # equation (7.99) from [GGBB96] with later division by sqrt(e)
413 zr = Z0 / 4. / qe
414
415 # modifies ep_re
416 # equation (7.100) of [GGBB96]
417 e = e - (0.7 * (e - 1.) * t / s) / (q1 + (0.7 * t / s))
418
419 ep_reff = e
420 # final division of (1) from [GhNa84] and (8) from [GhNa83]
421 zl_eff = zr / sqrt(ep_reff)
422
423 return zl_eff, ep_reff, k1, kk1, kpk1
424
425 def analyse_dispersion(self, zl_eff: NumberLike, ep_reff: NumberLike,
426 ep_r: NumberLike, w: NumberLike, s: NumberLike,
427 h: NumberLike, f: NumberLike):
428 """
429 This function computes the frequency-dependent characteristic
430 impedance and effective permittivity accounting for coplanar waveguide
431 frequency dispersion.
432
433 References
434 ----------
435 .. [#] M. Y. Frankel, S. Gupta, J. A. Valdmanis, and G. A. Mourou,
436 "Terahertz Attenuation and Dispersion Characteristics of Coplanar
437 Transmission Lines" IEEE Trans. on Microwave Theory and Techniques,
438 vol. 39, no. 6, pp. 910-916, June 1991.
439 .. [#] S. Gevorgian, T. Martinsson, A. Deleniv, E. Kollberg, and
440 I. Vendik, "Simple and accurate dispersion expression for the
441 effective dielectric constant of coplanar waveguides" in
442 Proceedings of Microwaves, Antennas and Propagation,
443 vol. 144, no. 2.IEE, Apr. 1997, pp. 145-148.
444
445 Returns
446 -------
447 z : :class:`numpy.ndarray`
448 e : :class:`numpy.ndarray`
449 """
450 # cut-off frequency of the TE0 mode
451 fte = ((c / 4.) / (h * sqrt(ep_r - 1.)))
452
453 # dispersion factor G
454 p = log(w / h)
455 u = 0.54 - (0.64 - 0.015 * p) * p
456 v = 0.43 - (0.86 - 0.54 * p) * p
457 G = exp(u * log(w / s) + v)
458
459 # add the dispersive effects to ep_reff
460 sqrt_ep_reff = sqrt(ep_reff)
461 sqrt_e = sqrt_ep_reff + (sqrt(ep_r) - sqrt_ep_reff) / \
462 (1. + G * (f / fte)**(-1.8))
463
464 e = sqrt_e**2
465
466 z = zl_eff * sqrt_ep_reff / sqrt_e
467
468 return z, e
469
470 def analyse_loss(self, ep_r: NumberLike, ep_reff: NumberLike,
471 tand: NumberLike, rho: NumberLike, mu_r: NumberLike,
472 f: NumberLike, w: NumberLike, t: NumberLike, s: NumberLike,
473 k1: NumberLike, kk1: NumberLike, kpk1: NumberLike):
474 """
475 Calculates conductor and dielectric losses of a coplanar waveguide line.
476
477 Use wheeler's incremental inductance rule [1]_, [2]_, [3]_.
478
479
480 References
481 ----------
482 .. [1] H. A. Wheeler, "Formulas for the Skin Effect,"
483 Proceedings of the IRE, vol. 30, no. 9, pp. 412-424, Sept. 1942.
484 .. [2] G. H. Owyang and T. T. Wu, "The Approximate Parameters of Slot
485 Lines and Their Complement" IRE Transactions on Antennas and
486 Propagation, pp. 49-55, Jan. 1958.
487 .. [3] G. Ghione, "A CAD-Oriented Analytical Model for the Losses of
488 General Asymmetric Coplanar Lines in Hybrid and Monolithic MICs"
489 IEEE Trans. on Microwave Theory and Techniques,
490 vol. 41, no. 9, pp. 1499-1510, Sept. 1993.
491
492 Returns
493 -------
494 a_conductor : :class:`numpy.ndarray`
495 a_dielectric : :class:`numpy.ndarray`
496 """
497 Z0 = sqrt(mu_0 / epsilon_0)
498 if t is not None and t > 0.:
499 if rho is None:
500 raise(AttributeError("must provide values conductivity and conductor thickness to calculate this. "
501 "see initializer help"))
502 r_s = surface_resistivity(f=f, rho=rho, \
503 mu_r=1)
504 ds = skin_depth(f = f, rho = rho, mu_r = 1.)
505 if any(t < 3 * ds):
506 warnings.warn(
507 'Conductor loss calculation invalid for line'
508 f'height t ({t}) < 3 * skin depth ({ds[0]})',
509 RuntimeWarning, stacklevel=2
510 )
511 n = (1. - k1) * 8. * pi / (t * (1. + k1))
512 a = w / 2.
513 b = a + s
514 ac = (pi + log(n * a)) / a + (pi + log(n * b)) / b
515 a_conductor = r_s * sqrt(ep_reff) * ac / (4. * Z0 * kk1 * kpk1 * \
516 (1. - k1 * k1))
517 else:
518 a_conductor = zeros(f.shape)
519
520 l0 = c / f
521 a_dielectric = pi * ep_r / (ep_r - 1) * (ep_reff - 1) / \
522 sqrt(ep_reff) * tand / l0
523
524 return a_conductor, a_dielectric
525
526 def ellipa(k: NumberLike):
527 """
528 Approximation of K(k)/K'(k).
529 First appeared in [#]_
530 More accurate expressions can be found in the above article and in [#]_.
531
532 The maximum relative error of the approximation implemented here is
533 about 2 ppm, so good enough for any practical purpose.
534
535 References
536 ==========
537 .. [#] Hilberg, W., "From Approximations to Exact Relations for
538 Characteristic Impedances," IEEE Trans. MTT, May 1969.
539 .. [#] Abbott, J. T., "Modeling the Capacitive Behavior of Coplanar
540 Striplines and Coplanar Waveguides using Simple Functions",
541 Rochester Institute of Technology, Rochester, New York, June 2011.
542 """
543 if k < sqrt(1. / 2.):
544 kp = sqrt(1 - k * k)
545 r = pi / log(2. * (1. + sqrt(kp)) / (1. - sqrt(kp)))
546 else:
547 r = log(2. * (1. + sqrt(k)) / (1. - sqrt(k))) / pi
548
549 return r