Coverage for Users/jsd/Library/CloudStorage/OneDrive-SimonFraserUniversity(1sfu)/projects/thztools/src/thztools/_util.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-12 16:26 -0700

1import numpy as np 

2 

3 

4def epswater(f, t=25): 

5 r"""Computes the complex relative permittivity of water. 

6 

7 Returns the complex relative permittivity at frequency f (THz) and 

8 temperature T (deg C). See [1]_ for details. 

9 

10 Parameters 

11 ---------- 

12 f : float 

13 Frequency (THz) 

14 t : float 

15 Temperature (deg C) (optional) 

16 

17 Returns 

18 ------- 

19 complex 

20 Complex relative permittivity of water. 

21 

22 References 

23 ---------- 

24 .. [1] Ellison, W. J. (2007). Permittivity of pure water, at standard 

25 atmospheric pressure, over the frequency range 0-25 THz and the 

26 temperature range 0-100 C. Journal of physical and chemical reference 

27 data, 36(1), 1-18. 

28 """ 

29 # Frequency conversion to Hz 

30 f = f * 1e12 

31 

32 # Define relaxation parameters 

33 a = np.array([79.23882, 3.815866, 1.634967]) 

34 b = np.array([0.004300598, 0.01117295, 0.006841548]) 

35 c = np.array([1.382264e-13, 3.510354e-16, 6.30035e-15]) 

36 d = np.array([652.7648, 1249.533, 405.5169]) 

37 tc = 133.1383 

38 

39 # Define resonance parameters 

40 p0 = 0.8379692 

41 p = np.array( 

42 [ 

43 -0.006118594, 

44 -0.000012936798, 

45 4235901000000, 

46 -14260880000, 

47 273815700, 

48 -1246943, 

49 9.618642e-14, 

50 1.795786e-16, 

51 -9.310017e-18, 

52 1.655473e-19, 

53 0.6165532, 

54 0.007238532, 

55 -0.00009523366, 

56 15983170000000, 

57 -74413570000, 

58 497448000, 

59 2.882476e-14, 

60 -3.142118e-16, 

61 3.528051e-18, 

62 ] 

63 ) 

64 

65 # Compute temperature - dependent functions 

66 eps0 = 87.9144 - 0.404399 * t + 9.58726e-4 * t**2 - 1.32802e-6 * t**3 

67 delta = a * np.exp(-b * t) 

68 tau = c * np.exp(d / (t + tc)) 

69 

70 delta4 = p0 + p[0] * t + p[1] * t**2 

71 f0 = p[2] + p[3] * t + p[4] * t**2 + p[5] * t**3 

72 tau4 = p[6] + p[7] * t + p[8] * t**2 + p[9] * t**3 

73 delta5 = p[10] + p[11] * t + p[12] * t**2 

74 f1 = p[13] + p[14] * t + p[15] * t**2 

75 tau5 = p[16] + p[17] * t + p[18] * t**2 

76 

77 # Put it all together 

78 epsilonr = ( 

79 eps0 

80 + 2 

81 * 1j 

82 * np.pi 

83 * f 

84 * ( 

85 delta[0] * tau[0] / (1 - 2 * 1j * np.pi * f * tau[0]) 

86 + delta[1] * tau[1] / (1 - 2 * 1j * np.pi * f * tau[1]) 

87 + delta[2] * tau[2] / (1 - 2 * 1j * np.pi * f * tau[2]) 

88 ) 

89 + 1j 

90 * np.pi 

91 * f 

92 * ( 

93 delta4 * tau4 / (1 - 2 * 1j * np.pi * tau4 * (f0 + f)) 

94 + delta4 * tau4 / (1 + 2 * 1j * np.pi * tau4 * (f0 - f)) 

95 ) 

96 + 1j 

97 * np.pi 

98 * f 

99 * ( 

100 delta5 * tau5 / (1 - 2 * 1j * np.pi * tau5 * (f1 + f)) 

101 + delta5 * tau5 / (1 + 2 * 1j * np.pi * tau5 * (f1 - f)) 

102 ) 

103 ) 

104 

105 return epsilonr