|
4 | 4 |
|
5 | 5 | import functools |
6 | 6 |
|
7 | | -import numpy as np |
8 | | -from numpy import dot, exp, log, sqrt |
| 7 | +from numpy import dot, exp, log |
9 | 8 | from scipy.constants import R |
10 | 9 |
|
11 | 10 | from polykin.properties.pvt.mixing_rules import quadratic_mixing |
| 11 | +from polykin.properties.pvt.virial import B_mixture |
12 | 12 | from polykin.utils.math import convert_FloatOrVectorLike_to_FloatVector |
13 | 13 | from polykin.utils.types import ( |
14 | | - FloatArray, |
15 | 14 | FloatSquareMatrix, |
16 | 15 | FloatVector, |
17 | 16 | FloatVectorLike, |
18 | 17 | ) |
19 | 18 |
|
20 | 19 | from .base import GasEoS |
21 | 20 |
|
22 | | -__all__ = ["Virial", "B_pure", "B_mixture"] |
| 21 | +__all__ = ["Virial"] |
23 | 22 |
|
24 | 23 |
|
25 | 24 | class Virial(GasEoS): |
@@ -116,7 +115,7 @@ def Bij( |
116 | 115 | ) -> FloatSquareMatrix: |
117 | 116 | r"""Calculate the matrix of interaction virial coefficients. |
118 | 117 |
|
119 | | - The calculation is handled by [`B_mixture`](B_mixture.md). |
| 118 | + The calculation is handled by [`B_mixture`](../../properties/pvt/B_mixture.md). |
120 | 119 |
|
121 | 120 | Parameters |
122 | 121 | ---------- |
@@ -242,110 +241,3 @@ def DA( |
242 | 241 | y = n / nT |
243 | 242 | Bm = self.Bm(T, y) |
244 | 243 | return -nT * R * T * log((V - nT * Bm) / (nT * v0)) |
245 | | - |
246 | | - |
247 | | -def B_pure( |
248 | | - T: float | FloatArray, |
249 | | - Tc: float, |
250 | | - Pc: float, |
251 | | - w: float, |
252 | | -) -> float | FloatArray: |
253 | | - r"""Estimate the second virial coefficient of a nonpolar or slightly polar |
254 | | - gas. |
255 | | -
|
256 | | - $$ \frac{B P_c}{R T_c} = B^{(0)}(T_r) + \omega B^{(1)}(T_r) $$ |
257 | | -
|
258 | | - where $B$ is the second virial coefficient, $P_c$ is the critical pressure, |
259 | | - $T_c$ is the critical temperature, $T_r=T/T_c$ is the reduced temperature, |
260 | | - and $\omega$ is the acentric factor. |
261 | | -
|
262 | | - **References** |
263 | | -
|
264 | | - * RC Reid, JM Prausniz, and BE Poling. The properties of gases & liquids |
265 | | - 4th edition, 1986, p. 40. |
266 | | -
|
267 | | - Parameters |
268 | | - ---------- |
269 | | - T : float | FloatArray |
270 | | - Temperature [K]. |
271 | | - Tc : float |
272 | | - Critical temperature [K]. |
273 | | - Pc : float |
274 | | - Critical pressure [Pa]. |
275 | | - w : float |
276 | | - Acentric factor. |
277 | | -
|
278 | | - Returns |
279 | | - ------- |
280 | | - float | FloatArray |
281 | | - Second virial coefficient, $B$ [m³/mol]. |
282 | | - """ |
283 | | - Tr = T / Tc |
284 | | - B0 = 0.083 - 0.422 / Tr**1.6 |
285 | | - B1 = 0.139 - 0.172 / Tr**4.2 |
286 | | - return R * Tc / Pc * (B0 + w * B1) |
287 | | - |
288 | | - |
289 | | -def B_mixture( |
290 | | - T: float, |
291 | | - Tc: FloatVector, |
292 | | - Pc: FloatVector, |
293 | | - Zc: FloatVector, |
294 | | - w: FloatVector, |
295 | | -) -> FloatSquareMatrix: |
296 | | - r"""Calculate the matrix of interaction virial coefficients using the |
297 | | - mixing rules of Prausnitz. |
298 | | -
|
299 | | - \begin{aligned} |
300 | | - B_{ij} &= B(T,T_{cij},P_{cij},\omega_{ij}) \\ |
301 | | - v_{cij} &= \frac{(v_{ci}^{1/3}+v_{cj}^{1/3})^3}{8} \\ |
302 | | - k_{ij} &= 1 -\frac{\sqrt{v_{ci}v_{cj}}}{v_{cij}} \\ |
303 | | - T_{cij} &= \sqrt{T_{ci}T_{cj}}(1-k_{ij}) \\ |
304 | | - Z_{cij} &= \frac{Z_{ci}+Z_{cj}}{2} \\ |
305 | | - \omega_{ij} &= \frac{\omega_{i}+\omega_{j}}{2} \\ |
306 | | - P_{cij} &= \frac{Z_{cij} R T_{cij}}{v_{cij}} |
307 | | - \end{aligned} |
308 | | -
|
309 | | - The calculation of the individual coefficients is handled by |
310 | | - [`B_pure`](B_pure.md). |
311 | | -
|
312 | | - **References** |
313 | | -
|
314 | | - * RC Reid, JM Prausniz, and BE Poling. The properties of gases & liquids |
315 | | - 4th edition, 1986, p. 80. |
316 | | -
|
317 | | - Parameters |
318 | | - ---------- |
319 | | - T : float |
320 | | - Temperature [K]. |
321 | | - Tc : FloatVector (N) |
322 | | - Critical temperatures of all components [K]. |
323 | | - Pc : FloatVector (N) |
324 | | - Critical pressures of all components [Pa]. |
325 | | - Zc : FloatVector (N) |
326 | | - Critical compressibility factors of all components. |
327 | | - w : FloatVector (N) |
328 | | - Acentric factors of all components. |
329 | | -
|
330 | | - Returns |
331 | | - ------- |
332 | | - FloatSquareMatrix (N,N) |
333 | | - Matrix of interaction virial coefficients $B_{ij}$ [m³/mol]. |
334 | | - """ |
335 | | - vc = Zc * R * Tc / Pc |
336 | | - N = Tc.size |
337 | | - B = np.empty((N, N), dtype=np.float64) |
338 | | - for i in range(N): |
339 | | - for j in range(i, N): |
340 | | - if i == j: |
341 | | - B[i, j] = B_pure(T, Tc[i], Pc[i], w[i]) |
342 | | - else: |
343 | | - vcm = (vc[i] ** (1 / 3) + vc[j] ** (1 / 3)) ** 3 / 8 |
344 | | - km = 1 - sqrt(vc[i] * vc[j]) / vcm |
345 | | - Tcm = sqrt(Tc[i] * Tc[j]) * (1 - km) |
346 | | - Zcm = (Zc[i] + Zc[j]) / 2 |
347 | | - wm = (w[i] + w[j]) / 2 |
348 | | - Pcm = Zcm * R * Tcm / vcm |
349 | | - B[i, j] = B_pure(T, Tcm, Pcm, wm) |
350 | | - B[j, i] = B[i, j] |
351 | | - return B |
0 commit comments