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

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

# -*- 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__ = ['GWP', 'ODP', 'logP', 'GWP_methods', 'GWP_data', 'ODP_methods', 

'ODP_data', 'logP_methods', 'CRClogPDict', 'SyrresDict2'] 

 

import os 

import pandas as pd 

 

 

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

 

 

### Global Warming Potentials 

 

GWP_data = pd.read_csv(os.path.join(folder, 

'Official Global Warming Potentials.csv'), sep='\t', 

index_col=0) 

 

 

IPCC100 = 'IPCC (2007) 100yr' 

IPCC100SAR = 'IPCC (2007) 100yr-SAR' 

IPCC20 = 'IPCC (2007) 20yr' 

IPCC500 = 'IPCC (2007) 500yr' 

NONE = 'None' 

GWP_methods = [IPCC100, IPCC100SAR, IPCC20, IPCC500] 

 

 

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

r'''This function handles the retrieval of a chemical's Global Warming 

Potential, relative to CO2. 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. 

 

Returns the GWP for the 100yr outlook by default. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

GWP : float 

Global warming potential, [(impact/mass chemical)/(impact/mass CO2)] 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain GWP with the 

given inputs 

 

Other Parameters 

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

Method : string, optional 

The method name to use. Accepted methods are IPCC (2007) 100yr', 

'IPCC (2007) 100yr-SAR', 'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'.  

All valid values are also held in the list GWP_methods. 

AvailableMethods : bool, optional 

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

the GWP for the desired chemical, and will return methods 

instead of the GWP 

 

Notes 

----- 

All data is from [1]_, the official source. Several chemicals are available 

in [1]_ are not included here as they do not have a CAS. 

Methods are 'IPCC (2007) 100yr', 'IPCC (2007) 100yr-SAR', 

'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'. 

 

Examples 

-------- 

Methane, 100-yr outlook 

 

>>> GWP(CASRN='74-82-8') 

25.0 

 

References 

---------- 

.. [1] IPCC. "2.10.2 Direct Global Warming Potentials - AR4 WGI Chapter 2: 

Changes in Atmospheric Constituents and in Radiative Forcing." 2007. 

https://www.ipcc.ch/publications_and_data/ar4/wg1/en/ch2s2-10-2.html. 

''' 

def list_methods(): 

methods = [] 

if CASRN in GWP_data.index: 

methods.append(IPCC100) 

if not pd.isnull(GWP_data.at[CASRN, 'SAR 100yr']): 

methods.append(IPCC100SAR) 

methods.append(IPCC20) 

methods.append(IPCC500) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == IPCC100: 

_GWP = float(GWP_data.at[CASRN, '100yr GWP']) 

elif Method == IPCC100SAR: 

_GWP = float(GWP_data.at[CASRN, 'SAR 100yr']) 

elif Method == IPCC20: 

_GWP = float(GWP_data.at[CASRN, '20yr GWP']) 

elif Method == IPCC500: 

_GWP = float(GWP_data.at[CASRN, '500yr GWP']) 

elif Method == NONE: 

_GWP = None 

else: 

raise Exception('Failure in in function') 

return _GWP 

 

 

### Ozone Depletion Potentials 

 

ODP_data = pd.read_csv(os.path.join(folder, 

'Ozone Depletion Potentials.csv'), sep='\t', 

index_col=0) 

 

 

ODP2MAX = 'ODP2 Max' 

ODP2MIN = 'ODP2 Min' 

ODP2STR = 'ODP2 string' 

ODP2LOG = 'ODP2 logarithmic average' 

ODP1MAX = 'ODP1 Max' 

ODP1MIN = 'ODP1 Min' 

ODP1STR = 'ODP1 string' 

ODP1LOG = 'ODP1 logarithmic average' 

NONE = 'None' 

ODP_methods = [ODP2MAX, ODP1MAX, ODP2LOG, ODP1LOG, ODP2MIN, ODP1MIN, ODP2STR, ODP1STR] 

 

 

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

r'''This function handles the retrieval of a chemical's Ozone Depletion 

Potential, relative to CFC-11 (trichlorofluoromethane). 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. 

 

Returns the ODP of a chemical according to [2]_ when a method is not 

specified. If a range is provided in [2]_, the highest value is returned. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

ODP : float or str 

Ozone Depletion potential, [(impact/mass chemical)/(impact/mass CFC-11)]; 

if method selected has `string` in it, this will be returned as a 

string regardless of if a range is given or a number 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain ODP with the 

given inputs 

 

Other Parameters 

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

Method : string, optional 

The method name to use. Accepted methods are 'ODP2 Max', 'ODP2 Min',  

'ODP2 string', 'ODP2 logarithmic average', and methods for older values 

are 'ODP1 Max', 'ODP1 Min', 'ODP1 string', and 'ODP1 logarithmic average'. 

All valid values are also held in the list ODP_methods. 

Method : string, optional 

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

ODP_methods 

AvailableMethods : bool, optional 

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

the ODP for the desired chemical, and will return methods 

instead of the ODP 

 

Notes 

----- 

Values are tabulated only for a small number of halogenated hydrocarbons, 

responsible for the largest impact. The original values of ODP as defined 

in the Montreal Protocol are also available, as methods with the `ODP1` 

prefix. 

 

All values are somewhat emperical, as actual reaction rates of chemicals 

with ozone depend on temperature which depends on latitude, longitude, 

time of day, weather, and the concentrations of other pollutants. 

 

All data is from [1]_. Several mixtures listed in [1]_ are not included 

here as they are not pure species. 

Methods for values in [2]_ are 'ODP2 Max', 'ODP2 Min', 'ODP2 string', 

'ODP2 logarithmic average', and methods for older values are 'ODP1 Max', 

'ODP1 Min', 'ODP1 string', and 'ODP1 logarithmic average'. 

 

Examples 

-------- 

Dichlorotetrafluoroethane, according to [2]_. 

 

>>> ODP(CASRN='76-14-2') 

0.58 

 

References 

---------- 

.. [1] US EPA, OAR. "Ozone-Depleting Substances." Accessed April 26, 2016. 

https://www.epa.gov/ozone-layer-protection/ozone-depleting-substances. 

.. [2] WMO (World Meteorological Organization), 2011: Scientific Assessment 

of Ozone Depletion: 2010. Global Ozone Research and Monitoring 

Project-Report No. 52, Geneva, Switzerland, 516 p. 

https://www.wmo.int/pages/prog/arep/gaw/ozone_2010/documents/Ozone-Assessment-2010-complete.pdf 

''' 

def list_methods(): 

methods = [] 

if CASRN in ODP_data.index: 

if not pd.isnull(ODP_data.at[CASRN, 'ODP2 Max']): 

methods.append(ODP2MAX) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP1 Max']): 

methods.append(ODP1MAX) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP2 Design']): 

methods.append(ODP2LOG) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP1 Design']): 

methods.append(ODP1LOG) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP2 Min']): 

methods.append(ODP2MIN) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP1 Min']): 

methods.append(ODP1MIN) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP2']): 

methods.append(ODP2STR) 

if not pd.isnull(ODP_data.at[CASRN, 'ODP1']): 

methods.append(ODP1STR) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == ODP2MAX: 

_ODP = float(ODP_data.at[CASRN, 'ODP2 Max']) 

elif Method == ODP1MAX: 

_ODP = float(ODP_data.at[CASRN, 'ODP1 Max']) 

elif Method == ODP2MIN: 

_ODP = float(ODP_data.at[CASRN, 'ODP2 Min']) 

elif Method == ODP1MIN: 

_ODP = float(ODP_data.at[CASRN, 'ODP1 Min']) 

elif Method == ODP2LOG: 

_ODP = float(ODP_data.at[CASRN, 'ODP2 Design']) 

elif Method == ODP1LOG: 

_ODP = float(ODP_data.at[CASRN, 'ODP1 Design']) 

elif Method == ODP2STR: 

_ODP = str(ODP_data.at[CASRN, 'ODP2']) 

elif Method == ODP1STR: 

_ODP = str(ODP_data.at[CASRN, 'ODP1']) 

elif Method == NONE: 

_ODP = None 

else: 

raise Exception('Failure in in function') 

return _ODP 

 

 

### log P 

 

CRClogPDict = pd.read_csv(os.path.join(folder, 

'CRC logP table.csv'), sep='\t', 

index_col=0) 

 

SyrresDict2 = pd.read_csv(os.path.join(folder, 

'Syrres logP data.csv.gz'), sep='\t', 

index_col=0, compression='gzip') 

 

SYRRES = 'SYRRES' 

CRC = 'CRC' 

NONE = 'NONE' 

logP_methods = [SYRRES, CRC] 

 

 

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

r'''This function handles the retrieval of a chemical's octanol-water 

partition coefficient. 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. 

 

Parameters 

---------- 

CASRN : string 

CASRN [-] 

 

Returns 

------- 

logP : float 

Octanol-water partition coefficient, [-] 

methods : list, only returned if AvailableMethods == True 

List of methods which can be used to obtain logP with the 

given inputs 

 

Other Parameters 

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

Method : string, optional 

The method name to use. Accepted methods are 'SYRRES', or 'CRC',  

All valid values are also held in the list logP_methods. 

AvailableMethods : bool, optional 

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

the logP for the desired chemical, and will return methods 

instead of the logP 

 

Notes 

----- 

.. math:: 

\log P_{ oct/wat} = \log\left(\frac{\left[{solute} 

\right]_{ octanol}^{un-ionized}}{\left[{solute} 

\right]_{ water}^{ un-ionized}}\right) 

 

Examples 

-------- 

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

-0.74 

 

References 

---------- 

.. [1] Syrres. 2006. KOWWIN Data, SrcKowData2.zip. 

http://esc.syrres.com/interkow/Download/SrcKowData2.zip 

.. [2] 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 CRClogPDict.index: 

methods.append(CRC) 

if CASRN in SyrresDict2.index: 

methods.append(SYRRES) 

methods.append(NONE) 

return methods 

if AvailableMethods: 

return list_methods() 

if not Method: 

Method = list_methods()[0] 

 

if Method == CRC: 

_logP = float(CRClogPDict.at[CASRN, 'logP']) 

elif Method == SYRRES: 

_logP = float(SyrresDict2.at[CASRN, 'logP']) 

elif Method == NONE: 

_logP = None 

else: 

raise Exception('Failure in in function') 

return _logP