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

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

# -*- 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__ = ['API_TDB_data', 'ATcT_l', 'ATcT_g', 'Hf_methods', 'Hf', 

'Hf_l_methods', 'Hf_l', 'Hf_g_methods', 'Hf_g'] 

 

import os 

import numpy as np 

import pandas as pd 

from thermo.heat_capacity import TRC_gas_data 

 

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

 

 

API_TDB_data = pd.read_csv(os.path.join(folder, 'API TDB Albahri Hf.csv'), 

sep='\t', index_col=0) 

 

ATcT_l = pd.read_csv(os.path.join(folder, 'ATcT 1.112 (l).csv'), 

sep='\t', index_col=0) 

 

ATcT_g = pd.read_csv(os.path.join(folder, 'ATcT 1.112 (g).csv'), 

sep='\t', index_col=0) 

 

 

API_TDB = 'API_TDB' 

NONE = 'NONE' 

Hf_methods = [API_TDB] 

 

 

def Hf(CASRN, AvailableMethods=False, Method=None): 

r'''This function handles the retrieval of a chemical's standard-phase 

heat of formation. The lookup is based on CASRNs. Selects the only 

data source available ('API TDB') if the chemical is in it. 

Returns None if the data is not available. 

 

Function has data for 571 chemicals. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

Hf : float 

Standard-state heat of formation, [J/mol] 

methods : list, only returned if AvailableMethods == True 

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

 

Other Parameters 

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

Method : string, optional 

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

Hf_methods 

AvailableMethods : bool, optional 

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

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

 

Notes 

----- 

Only one source of information is available to this function. it is: 

 

* 'API_TDB', a compilation of heats of formation of unspecified phase. 

Not the original data, but as reproduced in [1]_. Some chemicals with 

duplicated CAS numbers were removed. 

 

Examples 

-------- 

>>> Hf(CASRN='7732-18-5') 

-241820.0 

 

References 

---------- 

.. [1] Albahri, Tareq A., and Abdulla F. Aljasmi. "SGC Method for 

Predicting the Standard Enthalpy of Formation of Pure Compounds from 

Their Molecular Structures." Thermochimica Acta 568 

(September 20, 2013): 46-60. doi:10.1016/j.tca.2013.06.020. 

''' 

def list_methods(): 

methods = [] 

if CASRN in API_TDB_data.index: 

methods.append(API_TDB) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == API_TDB: 

_Hf = float(API_TDB_data.at[CASRN, 'Hf']) 

elif Method == NONE: 

_Hf = None 

else: 

raise Exception('Failure in in function') 

return _Hf 

 

 

ATCT_L = 'ATCT_L' 

ATCT_G = 'ATCT_G' 

 

Hf_l_methods = [ATCT_L] 

 

 

def Hf_l(CASRN, AvailableMethods=False, Method=None): 

r'''This function handles the retrieval of a chemical's liquid standard 

phase heat of formation. The lookup is based on CASRNs. Selects the only 

data source available, Active Thermochemical Tables (l), if the chemical is 

in it. Returns None if the data is not available. 

 

Function has data for 34 chemicals. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

Hfl : float 

Liquid standard-state heat of formation, [J/mol] 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain Hf(l) with the given inputs 

 

Other Parameters 

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

Method : string, optional 

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

Hf_l_methods 

AvailableMethods : bool, optional 

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

Hf(l) for the desired chemical, and will return methods instead of Hf(l) 

 

Notes 

----- 

Only one source of information is available to this function. It is: 

 

* 'ATCT_L', the Active Thermochemical Tables version 1.112. 

 

Examples 

-------- 

>>> Hf_l('67-56-1') 

-238400.0 

 

References 

---------- 

.. [1] Ruscic, Branko, Reinhardt E. Pinzon, Gregor von Laszewski, Deepti 

Kodeboyina, Alexander Burcat, David Leahy, David Montoy, and Albert F. 

Wagner. "Active Thermochemical Tables: Thermochemistry for the 21st 

Century." Journal of Physics: Conference Series 16, no. 1 

(January 1, 2005): 561. doi:10.1088/1742-6596/16/1/078. 

''' 

def list_methods(): 

methods = [] 

if CASRN in ATcT_l.index: 

methods.append(ATCT_L) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == ATCT_L: 

_Hfl = float(ATcT_l.at[CASRN, 'Hf_298K']) 

elif Method == NONE: 

return None 

else: 

raise Exception('Failure in in function') 

return _Hfl 

 

 

TRC = 'TRC' 

Hf_g_methods = [ATCT_G, TRC] 

 

 

def Hf_g(CASRN, AvailableMethods=False, Method=None): 

r'''This function handles the retrieval of a chemical's gas heat of 

formation. 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. 

 

Prefered sources are 'Active Thermochemical Tables (g)' for high accuracy, 

and 'TRC' for less accuracy but more chemicals. 

Function has data for approximately 2000 chemicals. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

_Hfg : float 

Gas phase heat of formation, [J/mol] 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain Hf(g) with the given inputs 

 

Other Parameters 

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

Method : string, optional 

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

Hf_g_methods 

AvailableMethods : bool, optional 

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

Hf(g) for the desired chemical, and will return methods instead of Hf(g) 

 

Notes 

----- 

Sources are: 

 

* 'ATCT_G', the Active Thermochemical Tables version 1.112. 

* 'TRC', from a 1994 compilation. 

 

Examples 

-------- 

>>> Hf_g('67-56-1') 

-200700.0 

 

References 

---------- 

.. [1] Ruscic, Branko, Reinhardt E. Pinzon, Gregor von Laszewski, Deepti 

Kodeboyina, Alexander Burcat, David Leahy, David Montoy, and Albert F. 

Wagner. "Active Thermochemical Tables: Thermochemistry for the 21st 

Century." Journal of Physics: Conference Series 16, no. 1 

(January 1, 2005): 561. doi:10.1088/1742-6596/16/1/078. 

.. [2] Frenkelʹ, M. L, Texas Engineering Experiment Station, and 

Thermodynamics Research Center. Thermodynamics of Organic Compounds in 

the Gas State. College Station, Tex.: Thermodynamics Research Center, 

1994. 

''' 

def list_methods(): 

methods = [] 

if CASRN in ATcT_g.index: 

methods.append(ATCT_G) 

if CASRN in TRC_gas_data.index and not np.isnan(TRC_gas_data.at[CASRN, 'Hf']): 

methods.append(TRC) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == ATCT_G: 

_Hfg = float(ATcT_g.at[CASRN, 'Hf_298K']) 

elif Method == TRC: 

_Hfg = float(TRC_gas_data.at[CASRN, 'Hf']) 

elif Method == NONE: 

return None 

else: 

raise Exception('Failure in in function') 

return _Hfg