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

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

# -*- 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__ = ['WagnerMcGarry', 'AntoinePoling', 'WagnerPoling', 'AntoineExtended', 

'Antoine', 'Wagner_original', 'Wagner', 'TRC_Antoine_extended', 

'vapor_pressure_methods', 'VaporPressure', 

'boiling_critical_relation', 'Lee_Kesler', 'Ambrose_Walton', 

'Sanjari'] 

 

import os 

from thermo.utils import log, exp 

import numpy as np 

import pandas as pd 

from thermo.miscdata import _VDISaturationDict, VDI_tabular_data 

from thermo.utils import TDependentProperty 

from thermo.coolprop import has_CoolProp, PropsSI, coolprop_dict, coolprop_fluids 

 

 

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

 

WagnerMcGarry = pd.read_csv(os.path.join(folder, 'Wagner Original McGarry.csv'), 

sep='\t', index_col=0) 

_WagnerMcGarry_values = WagnerMcGarry.values 

 

AntoinePoling = pd.read_csv(os.path.join(folder, 'Antoine Collection Poling.csv'), 

sep='\t', index_col=0) 

_AntoinePoling_values = AntoinePoling.values 

 

WagnerPoling = pd.read_csv(os.path.join(folder, 'Wagner Collection Poling.csv'), 

sep='\t', index_col=0) 

_WagnerPoling_values = WagnerPoling.values 

 

AntoineExtended = pd.read_csv(os.path.join(folder, 'Antoine Extended Collection Poling.csv'), 

sep='\t', index_col=0) 

_AntoineExtended_values = AntoineExtended.values 

 

def Antoine(T, A, B, C, Base=10.0): 

'''Base 10 assumed; Coefficients type Pascal assumed; Coefficients type Kelvin or Celcius assumed. 

Alter Base to be the desired numerical base. 

 

>>> Antoine(100.0, 8.7687, 395.744, -6.469) # methane 

34478.367349639906 

>>> Antoine(180.0, 8.95894, 510.595, -15.95) # CF4 

702271.0518579542 

''' 

_Psat = Base**(A-B/(T+C)) 

return _Psat 

 

 

def Wagner_original(T, Tc, Pc, a, b, c, d): 

r'''Calculates vapor pressure using the original Wagner equation 3,6 form. 

 

Parameters are specific to a chemical, and form of Wagner equation. 

 

.. math:: 

\ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} {T_r} 

 

Parameters 

---------- 

T : float 

Temperature of fluid, [K] 

Tc : float 

Critical temperature, [K] 

Pc : float 

Critical pressure, [Pa] 

a, b, c, d : floats 

Parameters for wagner equation. Specific to a chemical. 

 

Returns 

------- 

Psat: float 

Vapor pressure [Pa] 

 

Notes 

----- 

Warning: Pc is often treated as adjustable constant. 

 

Examples 

-------- 

>>> Wagner_original(100.0, 190.53, 4596420., -6.00435, 1.1885, -0.834082, -1.22833) # CH4 

34520.44601450496 

''' 

Tr = T/Tc 

tau = 1.0-Tr 

Psat = Pc*exp((a*tau + b*tau**1.5 + c*tau**3 + d*tau**6)/Tr) 

return Psat 

 

 

def Wagner(T, Tc, Pc, a, b, c, d): 

r'''Calculates vapor pressure using the Wagner equation 2.5, 5 form. 

 

Parameters are specific to a chemical, and form of Wagner equation. 

 

.. math:: 

\ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^{2.5} 

+ d\tau^5} {T_r} 

 

Parameters 

---------- 

T : float 

Temperature of fluid, [K] 

Tc : float 

Critical temperature, [K] 

Pc : float 

Critical pressure, [Pa] 

a, b, c, d : floats 

Parameters for wagner equation. Specific to a chemical. 

Trange : array_like 

Two temperatures, Tmin and Tmax, in which equation is appropriate. 

 

Returns 

------- 

Psat: float 

Vapor pressure [Pa] 

 

Notes 

----- 

Warning: Pc is often treated as adjustable constant. 

 

Examples 

-------- 

>>> Wagner(100., 190.551, 4599200, -6.02242, 1.26652, -0.5707, -1.366) # CH4 

34415.00476263708 

 

References 

---------- 

.. [1] Wagner, W. "New Vapour Pressure Measurements for Argon and Nitrogen and 

a New Method for Establishing Rational Vapour Pressure Equations." 

Cryogenics 13, no. 8 (August 1973): 470-82. doi:10.1016/0011-2275(73)90003-9 

''' 

Tr = T/Tc 

tau = 1-T/Tc 

return Pc*exp((a*tau + b*tau**1.5 + c*tau**2.5 + d*tau**5)/Tr) 

 

 

def TRC_Antoine_extended(T, Tc, to, A, B, C, n, E, F): 

''' 

>>> TRC_Antoine_extended(180.0, 227.51, -120., 8.95894, 510.595, -15.95, 2.41377, -93.74, 7425.9) # CF4 

706317.0898414153 

''' 

x = (T - to - 273.15)/Tc 

x = max(0, x) 

_Psat = 10**(A - B/(T+C) + 0.43429*x**n + E*x**8 + F*x**12) 

return _Psat 

 

 

WAGNER_MCGARRY = 'WAGNER_MCGARRY' 

WAGNER_POLING = 'WAGNER_POLING' 

ANTOINE_POLING = 'ANTOINE_POLING' 

ANTOINE_EXTENDED_POLING = 'ANTOINE_EXTENDED_POLING' 

VDI_TABULAR = 'VDI_TABULAR' 

COOLPROP = 'COOLPROP' 

 

BOILING_CRITICAL = 'BOILING_CRITICAL' 

LEE_KESLER_PSAT = 'LEE_KESLER_PSAT' 

AMBROSE_WALTON = 'AMBROSE_WALTON' 

SANJARI = 'SANJARI' 

 

vapor_pressure_methods = [WAGNER_MCGARRY, WAGNER_POLING, ANTOINE_EXTENDED_POLING, 

COOLPROP, ANTOINE_POLING, VDI_TABULAR, AMBROSE_WALTON, 

LEE_KESLER_PSAT, BOILING_CRITICAL, SANJARI] 

'''Holds all methods available for the VaporPressure class, for use in 

iterating over them.''' 

 

 

class VaporPressure(TDependentProperty): 

'''Class for dealing with vapor pressure as a function of temperature. 

Consists of four coefficient-based methods and four data sources, one 

source of tabular information, four corresponding-states estimators, 

and the external library CoolProp. 

 

Parameters 

---------- 

Tb : float, optional 

Boiling point, [K] 

Tc : float, optional 

Critical temperature, [K] 

Pc : float, optional 

Critical pressure, [Pa] 

omega : float, optional 

Acentric factor, [-] 

CASRN : str, optional 

The CAS number of the chemical 

 

Notes 

----- 

To iterate over all methods, use the list stored in 

:obj:`vapor_pressure_methods`. 

 

**WAGNER_MCGARRY**: 

The Wagner 3,6 original model equation documented in 

:obj:`Wagner_original`, with data for 245 chemicals, from [1]_, 

**WAGNER_POLING**: 

The Wagner 2.5, 5 model equation documented in :obj:`Wagner` in [2]_, 

with data for 104 chemicals. 

**ANTOINE_EXTENDED_POLING**: 

The TRC extended Antoine model equation documented in 

:obj:`TRC_Antoine_extended` with data for 97 chemicals in [2]_. 

**ANTOINE_POLING**: 

Standard Antoine equation, as documented in the function 

:obj:`Antoine` and with data for 325 fluids from [2]_. 

Coefficients were altered to be in units of Pa and Celcius. 

**COOLPROP**: 

CoolProp external library; with select fluids from its library. 

Range is limited to that of the equations of state it uses, as 

described in [3]_. Very slow. 

**BOILING_CRITICAL**: 

Fundamental relationship in thermodynamics making several 

approximations; see :obj:`boiling_critical_relation` for details. 

Least accurate method in most circumstances. 

**LEE_KESLER_PSAT**: 

CSP method documented in :obj:`Lee_Kesler`. Widely used. 

**AMBROSE_WALTON**: 

CSP method documented in :obj:`Ambrose_Walton`. 

**SANJARI**: 

CSP method documented in :obj:`Sanjari`. 

**VDI_TABULAR**: 

Tabular data in [4]_ along the saturation curve; interpolation is as 

set by the user or the default. 

 

See Also 

-------- 

Wagner_original 

Wagner 

TRC_Antoine_extended 

Antoine 

boiling_critical_relation 

Lee_Kesler 

Ambrose_Walton 

Sanjari 

 

References 

---------- 

.. [1] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of 

Pure Liquids over Large Pressure Ranges." Industrial & Engineering 

Chemistry Process Design and Development 22, no. 2 (April 1, 1983): 

313-22. doi:10.1021/i200021a023. 

.. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. 

New York: McGraw-Hill Professional, 2000. 

.. [3] Bell, Ian H., Jorrit Wronski, Sylvain Quoilin, and Vincent Lemort. 

"Pure and Pseudo-Pure Fluid Thermophysical Property Evaluation and the 

Open-Source Thermophysical Property Library CoolProp." Industrial & 

Engineering Chemistry Research 53, no. 6 (February 12, 2014): 

2498-2508. doi:10.1021/ie4033999. http://www.coolprop.org/ 

.. [4] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition. 

Berlin; New York:: Springer, 2010. 

''' 

name = 'Vapor pressure' 

units = 'Pa' 

interpolation_T = lambda self, T: 1./T 

'''1/T interpolation transformation by default.''' 

interpolation_property = lambda self, P: log(P) 

'''log(P) interpolation transformation by default.''' 

interpolation_property_inv = lambda self, P: exp(P) 

'''exp(P) interpolation transformation by default; reverses 

:obj:`interpolation_property_inv`.''' 

tabular_extrapolation_permitted = False 

'''Disallow tabular extrapolation by default; CSP methods prefered 

normally.''' 

property_min = 0 

'''Mimimum valid value of vapor pressure.''' 

property_max = 1E10 

'''Maximum valid value of vapor pressure. Set slightly above the critical 

point estimated for Iridium; Mercury's 160 MPa critical point is the 

highest known.''' 

 

ranked_methods = [WAGNER_MCGARRY, WAGNER_POLING, ANTOINE_EXTENDED_POLING, 

COOLPROP, ANTOINE_POLING, VDI_TABULAR, AMBROSE_WALTON, 

LEE_KESLER_PSAT, BOILING_CRITICAL, SANJARI] 

'''Default rankings of the available methods.''' 

 

def __init__(self, Tb=None, Tc=None, Pc=None, omega=None, CASRN=''): 

self.CASRN = CASRN 

self.Tb = Tb 

self.Tc = Tc 

self.Pc = Pc 

self.omega = omega 

 

self.Tmin = None 

'''Minimum temperature at which no method can calculate vapor pressure 

under.''' 

 

self.Tmax = None 

'''Maximum temperature at which no method can calculate vapor pressure 

above; by definition the critical point.''' 

 

self.method = None 

'''The method was which was last used successfully to calculate a property; 

set only after the first property calculation.''' 

 

self.tabular_data = {} 

'''tabular_data, dict: Stored (Ts, properties) for any 

tabular data; indexed by provided or autogenerated name.''' 

self.tabular_data_interpolators = {} 

'''tabular_data_interpolators, dict: Stored (extrapolator, 

spline) tuples which are interp1d instances for each set of tabular 

data; indexed by tuple of (name, interpolation_T, 

interpolation_property, interpolation_property_inv) to ensure that 

if an interpolation transform is altered, the old interpolator which 

had been created is no longer used.''' 

 

self.sorted_valid_methods = [] 

'''sorted_valid_methods, list: Stored methods which were found valid 

at a specific temperature; set by `T_dependent_property`.''' 

self.user_methods = [] 

'''user_methods, list: Stored methods which were specified by the user 

in a ranked order of preference; set by `T_dependent_property`.''' 

 

self.all_methods = set() 

'''Set of all methods available for a given CASRN and properties; 

filled by :obj:`load_all_methods`.''' 

 

self.load_all_methods() 

 

def load_all_methods(self): 

r'''Method which picks out coefficients for the specified chemical 

from the various dictionaries and DataFrames storing it. All data is 

stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`, 

and :obj:`all_methods` as a set of methods for which the data exists for. 

 

Called on initialization only. See the source code for the variables at 

which the coefficients are stored. The coefficients can safely be 

altered once the class is initialized. This method can be called again 

to reset the parameters. 

''' 

methods = [] 

Tmins, Tmaxs = [], [] 

if self.CASRN in WagnerMcGarry.index: 

methods.append(WAGNER_MCGARRY) 

_, A, B, C, D, self.WAGNER_MCGARRY_Pc, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Tmin = _WagnerMcGarry_values[WagnerMcGarry.index.get_loc(self.CASRN)].tolist() 

self.WAGNER_MCGARRY_coefs = [A, B, C, D] 

Tmins.append(self.WAGNER_MCGARRY_Tmin); Tmaxs.append(self.WAGNER_MCGARRY_Tc) 

if self.CASRN in WagnerPoling.index: 

methods.append(WAGNER_POLING) 

_, A, B, C, D, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, Tmin, self.WAGNER_POLING_Tmax = _WagnerPoling_values[WagnerPoling.index.get_loc(self.CASRN)].tolist() 

# Some Tmin values are missing; Arbitrary choice of 0.1 lower limit 

self.WAGNER_POLING_Tmin = Tmin if not np.isnan(Tmin) else self.WAGNER_POLING_Tmax*0.1 

self.WAGNER_POLING_coefs = [A, B, C, D] 

Tmins.append(Tmin); Tmaxs.append(self.WAGNER_POLING_Tmax) 

if self.CASRN in AntoineExtended.index: 

methods.append(ANTOINE_EXTENDED_POLING) 

_, A, B, C, Tc, to, n, E, F, self.ANTOINE_EXTENDED_POLING_Tmin, self.ANTOINE_EXTENDED_POLING_Tmax = _AntoineExtended_values[AntoineExtended.index.get_loc(self.CASRN)].tolist() 

self.ANTOINE_EXTENDED_POLING_coefs = [Tc, to, A, B, C, n, E, F] 

Tmins.append(self.ANTOINE_EXTENDED_POLING_Tmin); Tmaxs.append(self.ANTOINE_EXTENDED_POLING_Tmax) 

if self.CASRN in AntoinePoling.index: 

methods.append(ANTOINE_POLING) 

_, A, B, C, self.ANTOINE_POLING_Tmin, self.ANTOINE_POLING_Tmax = _AntoinePoling_values[AntoinePoling.index.get_loc(self.CASRN)].tolist() 

self.ANTOINE_POLING_coefs = [A, B, C] 

Tmins.append(self.ANTOINE_POLING_Tmin); Tmaxs.append(self.ANTOINE_POLING_Tmax) 

if has_CoolProp and self.CASRN in coolprop_dict: 

methods.append(COOLPROP) 

self.CP_f = coolprop_fluids[self.CASRN] 

Tmins.append(self.CP_f.Tmin); Tmaxs.append(self.CP_f.Tc) 

if self.CASRN in _VDISaturationDict: 

methods.append(VDI_TABULAR) 

Ts, props = VDI_tabular_data(self.CASRN, 'P') 

self.VDI_Tmin = Ts[0] 

self.VDI_Tmax = Ts[-1] 

self.tabular_data[VDI_TABULAR] = (Ts, props) 

Tmins.append(self.VDI_Tmin); Tmaxs.append(self.VDI_Tmax) 

if all((self.Tb, self.Tc, self.Pc)): 

methods.append(BOILING_CRITICAL) 

Tmins.append(0.01); Tmaxs.append(self.Tc) 

if all((self.Tc, self.Pc, self.omega)): 

methods.append(LEE_KESLER_PSAT) 

methods.append(AMBROSE_WALTON) 

methods.append(SANJARI) 

Tmins.append(0.01); Tmaxs.append(self.Tc) 

self.all_methods = set(methods) 

if Tmins and Tmaxs: 

self.Tmin = min(Tmins) 

self.Tmax = max(Tmaxs) 

 

def calculate(self, T, method): 

r'''Method to calculate vapor pressure of a fluid at temperature `T` 

with a given method. 

 

This method has no exception handling; see `T_dependent_property` 

for that. 

 

Parameters 

---------- 

T : float 

Temperature at calculate vapor pressure, [K] 

method : str 

Name of the method to use 

 

Returns 

------- 

Psat : float 

Vapor pressure at T, [pa] 

''' 

if method == WAGNER_MCGARRY: 

A, B, C, D = self.WAGNER_MCGARRY_coefs 

Psat = Wagner_original(T, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Pc, A, B, C, D) 

elif method == WAGNER_POLING: 

A, B, C, D = self.WAGNER_POLING_coefs 

Psat = Wagner(T, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, A, B, C, D) 

elif method == ANTOINE_EXTENDED_POLING: 

Tc, to, A, B, C, n, E, F = self.ANTOINE_EXTENDED_POLING_coefs 

Psat = TRC_Antoine_extended(T, Tc, to, A, B, C, n, E, F) 

elif method == ANTOINE_POLING: 

A, B, C = self.ANTOINE_POLING_coefs 

Psat = Antoine(T, A, B, C, Base=10.0) 

elif method == COOLPROP: 

Psat = PropsSI('P','T', T,'Q',0, self.CASRN) 

elif method == BOILING_CRITICAL: 

Psat = boiling_critical_relation(T, self.Tb, self.Tc, self.Pc) 

elif method == LEE_KESLER_PSAT: 

Psat = Lee_Kesler(T, self.Tc, self.Pc, self.omega) 

elif method == AMBROSE_WALTON: 

Psat = Ambrose_Walton(T, self.Tc, self.Pc, self.omega) 

elif method == SANJARI: 

Psat = Sanjari(T, self.Tc, self.Pc, self.omega) 

elif method in self.tabular_data: 

Psat = self.interpolate(T, method) 

return Psat 

 

def test_method_validity(self, T, method): 

r'''Method to check the validity of a method. Follows the given 

ranges for all coefficient-based methods. For CSP methods, the models 

are considered valid from 0 K to the critical point. For tabular data, 

extrapolation outside of the range is used if 

:obj:`tabular_extrapolation_permitted` is set; if it is, the extrapolation 

is considered valid for all temperatures. 

 

It is not guaranteed that a method will work or give an accurate 

prediction simply because this method considers the method valid. 

 

Parameters 

---------- 

T : float 

Temperature at which to test the method, [K] 

method : str 

Name of the method to test 

 

Returns 

------- 

validity : bool 

Whether or not a method is valid 

''' 

if method == WAGNER_MCGARRY: 

if T < self.WAGNER_MCGARRY_Tmin or T > self.WAGNER_MCGARRY_Tc: 

return False 

elif method == WAGNER_POLING: 

if T < self.WAGNER_POLING_Tmin or T > self.WAGNER_POLING_Tmax: 

return False 

elif method == ANTOINE_EXTENDED_POLING: 

if T < self.ANTOINE_EXTENDED_POLING_Tmin or T > self.ANTOINE_EXTENDED_POLING_Tmax: 

return False 

elif method == ANTOINE_POLING: 

if T < self.ANTOINE_POLING_Tmin or T > self.ANTOINE_POLING_Tmax: 

return False 

elif method == COOLPROP: 

if T < self.CP_f.Tmin or T < self.CP_f.Tt or T > self.CP_f.Tmax or T > self.CP_f.Tc: 

return False 

elif method in [BOILING_CRITICAL, LEE_KESLER_PSAT, AMBROSE_WALTON, SANJARI]: 

if T > self.Tc or T < 0: 

return False 

# No lower limit 

elif method in self.tabular_data: 

# if tabular_extrapolation_permitted, good to go without checking 

if not self.tabular_extrapolation_permitted: 

Ts, properties = self.tabular_data[method] 

if T < Ts[0] or T > Ts[-1]: 

return False 

else: 

raise Exception('Method not valid') 

return True 

 

 

### CSP Methods 

 

def boiling_critical_relation(T, Tb, Tc, Pc): 

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a 

CSP relationship as in [1]_; requires a chemical's critical temperature 

and pressure as well as boiling point. 

 

The vapor pressure is given by: 

 

.. math:: 

\ln P^{sat}_r = h\left( 1 - \frac{1}{T_r}\right) 

 

h = T_{br} \frac{\ln(P_c/101325)}{1-T_{br}} 

 

Parameters 

---------- 

T : float 

Temperature of fluid [K] 

Tb : float 

Boiling temperature of fluid [K] 

Tc : float 

Critical temperature of fluid [K] 

Pc : float 

Critical pressure of fluid [Pa] 

 

Returns 

------- 

Psat : float 

Vapor pressure, [Pa] 

 

Notes 

----- 

Units are Pa. Formulation makes intuitive sense; a logarithmic form of 

interpolation. 

 

Examples 

-------- 

Example as in [1]_ for ethylbenzene 

 

>>> boiling_critical_relation(347.2, 409.3, 617.1, 36E5) 

15209.467273093938 

 

References 

---------- 

.. [1] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. 

The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. 

''' 

Tbr = Tb/Tc 

Tr = T/Tc 

h = Tbr*log(Pc/101325.)/(1 - Tbr) 

P = exp(h*(1-1/Tr))*Pc 

return P 

 

 

def Lee_Kesler(T, Tc, Pc, omega): 

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a 

CSP relationship by [1]_; requires a chemical's critical temperature and 

acentric factor. 

 

The vapor pressure is given by: 

 

.. math:: 

\ln P^{sat}_r = f^{(0)} + \omega f^{(1)} 

 

f^{(0)} = 5.92714-\frac{6.09648}{T_r}-1.28862\ln T_r + 0.169347T_r^6 

 

f^{(1)} = 15.2518-\frac{15.6875}{T_r} - 13.4721 \ln T_r + 0.43577T_r^6 

 

Parameters 

---------- 

T : float 

Temperature of fluid [K] 

Tc : float 

Critical temperature of fluid [K] 

Pc : float 

Critical pressure of fluid [Pa] 

omega : float 

Acentric factor [-] 

 

Returns 

------- 

Psat : float 

Vapor pressure, [Pa] 

 

Notes 

----- 

This equation appears in [1]_ in expanded form. It has been verified. 

The reduced pressure form of the equation ensures 

 

Examples 

-------- 

Example as in [2]_; Tr rounding source of tiny deviation 

 

>>> Lee_Kesler(347.2, 617.1, 36E5, 0.299) 

13078.694162949312 

 

References 

---------- 

.. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic 

Correlation Based on Three-Parameter Corresponding States." AIChE Journal 

21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313. 

.. [2] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. 

The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. 

''' 

Tr = T/Tc 

f0 = 5.92714 - 6.09648/Tr - 1.28862*log(Tr) + 0.169347*Tr**6 

f1 = 15.2518 - 15.6875/Tr - 13.4721*log(Tr) + 0.43577*Tr**6 

P = exp(f0 + omega*f1)*Pc 

return P 

 

 

def Ambrose_Walton(T, Tc, Pc, omega): 

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a 

CSP relationship by [1]_; requires a chemical's critical temperature and 

acentric factor. 

 

The vapor pressure is given by: 

 

.. math:: 

\ln P_r=f^{(0)}+\omega f^{(1)}+\omega^2f^{(2)} 

 

\tau = 1-T_{r} 

 

f^{(0)}=\frac{-5.97616\tau + 1.29874\tau^{1.5}- 0.60394\tau^{2.5} 

-1.06841\tau^5}{T_r} 

 

f^{(1)}=\frac{-5.03365\tau + 1.11505\tau^{1.5}- 5.41217\tau^{2.5} 

-7.46628\tau^5}{T_r} 

 

f^{(2)}=\frac{-0.64771\tau + 2.41539\tau^{1.5}- 4.26979\tau^{2.5} 

+3.25259\tau^5}{T_r} 

 

Parameters 

---------- 

T : float 

Temperature of fluid [K] 

Tc : float 

Critical temperature of fluid [K] 

Pc : float 

Critical pressure of fluid [Pa] 

omega : float 

Acentric factor [-] 

 

Returns 

------- 

Psat : float 

Vapor pressure, [Pa] 

 

Notes 

----- 

 

 

Examples 

-------- 

>>> Ambrose_Walton(347.2, 617.1, 36E5, 0.299) 

13558.913459865389 

 

References 

---------- 

.. [1] Ambrose, D., and J. Walton. "Vapour Pressures up to Their Critical 

Temperatures of Normal Alkanes and 1-Alkanols." Pure and Applied 

Chemistry 61, no. 8 (1989): 1395-1403. doi:10.1351/pac198961081395. 

.. [2] Reid, Robert C..; Prausnitz, John M.; Poling, Bruce E. 

The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. 

''' 

Tr = T/Tc 

tau = 1 - T/Tc 

f0 = (-5.97616*tau + 1.29874*tau**1.5 - 0.60394*tau**2.5 - 1.06841*tau**5)/Tr 

f1 = (-5.03365*tau + 1.11505*tau**1.5 - 5.41217*tau**2.5 - 7.46628*tau**5)/Tr 

f2 = (-0.64771*tau + 2.41539*tau**1.5 - 4.26979*tau**2.5 + 3.25259*tau**5)/Tr 

Psat = Pc*exp(f0 + omega*f1 + omega**2*f2) 

return Psat 

 

 

def Sanjari(T, Tc, Pc, omega): 

r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a 

CSP relationship by [1]_. Requires a chemical's critical temperature, 

pressure, and acentric factor. Although developed for refrigerants, 

should have some generality. 

 

The vapor pressure is given by: 

 

.. math:: 

P^{sat} = P_c\exp(f^{(0)} + \omega f^{(1)} + \omega^2 f^{(2)}) 

 

f^{(0)} = a_1 + \frac{a_2}{T_r} + a_3\ln T_r + a_4 T_r^{1.9} 

 

f^{(1)} = a_5 + \frac{a_6}{T_r} + a_7\ln T_r + a_8 T_r^{1.9} 

 

f^{(2)} = a_9 + \frac{a_{10}}{T_r} + a_{11}\ln T_r + a_{12} T_r^{1.9} 

 

Parameters 

---------- 

T : float 

Temperature of fluid [K] 

Tc : float 

Critical temperature of fluid [K] 

Pc : float 

Critical pressure of fluid [Pa] 

omega : float 

Acentric factor [-] 

 

Returns 

------- 

Psat : float 

Vapor pressure, [Pa] 

 

Notes 

----- 

a 1-12 are as follows: 

6.83377, -5.76051, 0.90654, -1.16906, 

5.32034, -28.1460, -58.0352, 23.57466, 

18.19967, 16.33839, 65.6995, -35.9739. 

 

For a claimed fluid not included in the regression, R128, the claimed AARD 

was 0.428%. A re-calculation using 200 data points from 125.45 K to 

343.90225 K evenly spaced by 1.09775 K as generated by NIST Webbook April 

2016 produced an AARD of 0.644%. It is likely that the author's regression 

used more precision in its coefficients than was shown here. Nevertheless, 

the function is reproduced as shown in [1]_. 

 

For Tc=808 K, Pc=1100000 Pa, omega=1.1571, this function actually declines 

after 770 K. 

 

Examples 

-------- 

>>> Sanjari(347.2, 617.1, 36E5, 0.299) 

13651.916109552498 

 

References 

---------- 

.. [1] Sanjari, Ehsan, Mehrdad Honarmand, Hamidreza Badihi, and Ali 

Ghaheri. "An Accurate Generalized Model for Predict Vapor Pressure of 

Refrigerants." International Journal of Refrigeration 36, no. 4 

(June 2013): 1327-32. doi:10.1016/j.ijrefrig.2013.01.007. 

''' 

Tr = T/Tc 

f0 = 6.83377 + -5.76051/Tr + 0.90654*log(Tr) + -1.16906*Tr**1.9 

f1 = 5.32034 + -28.1460/Tr + -58.0352*log(Tr) + 23.57466*Tr**1.9 

f2 = 18.19967 + 16.33839/Tr + 65.6995*log(Tr) + -35.9739*Tr**1.9 

P = Pc*exp(f0 + omega*f1 + omega**2*f2) 

return P