Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

# -*- coding: utf-8 -*- 

'''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. 

Copyright (C) 2016, Caleb Bell <Caleb.Andrew.Bell@gmail.com> 

 

Permission is hereby granted, free of charge, to any person obtaining a copy 

of this software and associated documentation files (the "Software"), to deal 

in the Software without restriction, including without limitation the rights 

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 

copies of the Software, and to permit persons to whom the Software is 

furnished to do so, subject to the following conditions: 

 

The above copyright notice and this permission notice shall be included in all 

copies or substantial portions of the Software. 

 

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 

SOFTWARE.''' 

 

from __future__ import division 

 

__all__ = ['CRC_RI_organic', 'RI_methods', 'refractive_index', 

'polarizability_from_RI', 'molar_refractivity_from_RI', 

'RI_from_molar_refractivity'] 

 

import os 

from thermo.utils import pi 

from scipy.constants import N_A 

import pandas as pd 

 

folder = os.path.join(os.path.dirname(__file__), 'Misc') 

 

CRC_RI_organic = pd.read_csv(os.path.join(folder, 'CRC Handbook Organic RI.csv'), 

sep='\t', index_col=0) 

 

CRC = 'CRC' 

NONE = 'NONE' 

RI_methods = [CRC] 

 

 

def refractive_index(CASRN, T=None, AvailableMethods=False, Method=None, 

full_info=True): 

r'''This function handles the retrieval of a chemical's refractive 

index. Lookup is based on CASRNs. Will automatically select a data source 

to use if no Method is provided; returns None if the data is not available. 

 

Function has data for approximately 4500 chemicals. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

RI : float 

Refractive Index on Na D line, [-] 

T : float, only returned if full_info == True 

Temperature at which refractive index reading was made 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain RI with the given inputs 

 

Other Parameters 

---------------- 

Method : string, optional 

A string for the method name to use, as defined by constants in 

RI_methods 

AvailableMethods : bool, optional 

If True, function will determine which methods can be used to obtain 

RI for the desired chemical, and will return methods instead of RI 

full_info : bool, optional 

If True, function will return the temperature at which the refractive 

index reading was made 

 

Notes 

----- 

Only one source is available in this function. It is: 

 

* 'CRC', a compillation of Organic RI data in [1]_. 

 

Examples 

-------- 

>>> refractive_index(CASRN='64-17-5') 

(1.3611, 293.15) 

 

References 

---------- 

.. [1] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of 

Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014. 

''' 

def list_methods(): 

methods = [] 

if CASRN in CRC_RI_organic.index: 

methods.append(CRC) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == CRC: 

_RI = float(CRC_RI_organic.at[CASRN, 'RI']) 

if full_info: 

_T = float(CRC_RI_organic.at[CASRN, 'RIT']) 

elif Method == NONE: 

_RI, _T = None, None 

else: 

raise Exception('Failure in in function') 

if full_info: 

return _RI, _T 

else: 

return _RI 

 

 

def polarizability_from_RI(RI, Vm): 

r'''Returns the polarizability of a fluid given its molar volume and 

refractive index. 

 

.. math:: 

\alpha = \left(\frac{3}{4\pi N_A}\right) 

\left(\frac{n^2-1}{n^2+2}\right)V_m 

 

Parameters 

---------- 

RI : float 

Refractive Index on Na D line, [-] 

Vm : float 

Molar volume of fluid, [m^3/mol] 

 

Returns 

------- 

alpha : float 

Polarizability [m^3] 

 

Notes 

----- 

This Lorentz-Lorentz-expression is most correct when van der Waals 

interactions dominate. Alternate conversions have been suggested. 

This is often expressed in units of cm^3 or Angstrom^3. To convert to these 

units, multiply by 1E9 or 1E30 respectively. 

 

Examples 

-------- 

>>> polarizability_from_RI(1.3611, 5.8676E-5) 

5.147658123614415e-30 

 

References 

---------- 

.. [1] Panuganti, Sai R., Fei Wang, Walter G. Chapman, and Francisco M. 

Vargas. "A Simple Method for Estimation of Dielectric Constants and 

Polarizabilities of Nonpolar and Slightly Polar Hydrocarbons." 

International Journal of Thermophysics 37, no. 7 (June 6, 2016): 1-24. 

doi:10.1007/s10765-016-2075-8. 

''' 

alpha = 3/(4*pi*N_A)*(RI**2-1)/(RI**2+2)*Vm 

return alpha 

 

 

def molar_refractivity_from_RI(RI, Vm): 

r'''Returns the molar refractivity of a fluid given its molar volume and 

refractive index. 

 

.. math:: 

R_m = \left(\frac{n^2-1}{n^2+2}\right)V_m 

 

Parameters 

---------- 

RI : float 

Refractive Index on Na D line, [-] 

Vm : float 

Molar volume of fluid, [m^3/mol] 

 

Returns 

------- 

Rm : float 

Molar refractivity [m^3/mol] 

 

Notes 

----- 

 

Examples 

-------- 

>>> molar_refractivity_from_RI(1.3611, 5.8676E-5) 

1.2985217089649597e-05 

 

References 

---------- 

.. [1] Panuganti, Sai R., Fei Wang, Walter G. Chapman, and Francisco M. 

Vargas. "A Simple Method for Estimation of Dielectric Constants and 

Polarizabilities of Nonpolar and Slightly Polar Hydrocarbons." 

International Journal of Thermophysics 37, no. 7 (June 6, 2016): 1-24. 

doi:10.1007/s10765-016-2075-8. 

''' 

Rm = (RI**2-1)/(RI**2+2)*Vm 

return Rm 

 

 

def RI_from_molar_refractivity(Rm, Vm): 

r'''Returns the refractive index of a fluid given its molar volume and 

molar refractivity. 

 

.. math:: 

RI = \sqrt{\frac{-2R_m - V_m}{R_m-V_m}} 

 

Parameters 

---------- 

Rm : float 

Molar refractivity [m^3/mol] 

Vm : float 

Molar volume of fluid, [m^3/mol] 

 

Returns 

------- 

RI : float 

Refractive Index on Na D line, [-] 

 

Notes 

----- 

 

Examples 

-------- 

>>> RI_from_molar_refractivity(1.2985e-5, 5.8676E-5) 

1.3610932757685672 

 

References 

---------- 

.. [1] Panuganti, Sai R., Fei Wang, Walter G. Chapman, and Francisco M. 

Vargas. "A Simple Method for Estimation of Dielectric Constants and 

Polarizabilities of Nonpolar and Slightly Polar Hydrocarbons." 

International Journal of Thermophysics 37, no. 7 (June 6, 2016): 1-24. 

doi:10.1007/s10765-016-2075-8. 

''' 

Rm = ((-2*Rm - Vm)/(Rm-Vm))**0.5 

return Rm 

 

 

### Mixtures 

 

#def Lorentz_Lorenz(ws=None, RIs=None, rhos=None, rho=None): 

# if not length_check([ws, RIs, rhos]): 

# raise Exception('Input dimentions are inconsistent')