Skip to content
Snippets Groups Projects
Commit 8e0325e2 authored by Ian Bell's avatar Ian Bell
Browse files

Show how to get meta for cubics

parent 1d76863b
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:df447d16 tags:
# General cubics
The reduced residual Helmholtz energy for the main cubic EOS (van der Waals, Peng-Robinson, and Soave-Redlich-Kwong) can be written in a common form (see https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7365965/)
$$ \alpha^r = \psi^{(-)} - \dfrac{\tau a_m}{RT_r } \psi^{(+)} $$
$$ \psi^{(-)} =-\ln(1-b_m\rho ) $$
$$ \psi^{(+)} = \dfrac{\ln\left(\dfrac{\Delta_1 b_m\rho+1}{\Delta_2b_m\rho+1}\right)}{b_m(\Delta_1-\Delta_2)} $$
with the constants given by:
* vdW: $\Delta_1=0$, $\Delta_2=0$
* SRK: $\Delta_1=1$, $\Delta_2=0$
* PR: $\Delta_1=1+\sqrt{2}$, $\Delta_2=1-\sqrt{2}$
The quantities $a_m$ and $b_m$ are described (with exact solutions for the numerical coefficients) for each of these EOS in https://pubs.acs.org/doi/abs/10.1021/acs.iecr.1c00847.
The models in teqp are instantiated based on knowledge of the critical temperature, pressure, and acentric factor. Thereafter all quantities are obtained from derivatives of $\alpha^r$.
%% Cell type:raw id:a65e7316 tags:
The Python class is here: :py:class:`GeneralizedCubic <teqp.teqp.GeneralizedCubic>`
%% Cell type:code id:9a884dab tags:
``` python
import teqp
import teqp, json
# Values taken from http://dx.doi.org/10.6028/jres.121.011
Tc_K = [ 190.564, 154.581, 150.687 ]
pc_Pa = [ 4599200, 5042800, 4863000 ]
acentric = [ 0.011, 0.022, -0.002 ]
# Instantiate Peng-Robinson model
modelPR = teqp.canonical_PR(Tc_K, pc_Pa, acentric)
# Instantiate Soave-Redlich-Kwong model
modelSRK = teqp.canonical_SRK(Tc_K, pc_Pa, acentric)
```
%% Cell type:code id:75961e5b tags:
``` python
# And you can get information about the model in JSON format
# from the get_meta function
modelPR.get_meta()
```
%% Cell type:markdown id:615c7830 tags:
## Adjusting k_ij
Fine-tuned values of $k_{ij}$ can be provided when instantiating the model, for Peng-Robinson and SRK. A complete matrix of all the $k_{ij}$ values must be provided. This allows for asymmetric mixing models in which $k_{ij}\neq k_{ji}$.
%% Cell type:code id:a8c87890 tags:
``` python
k_12 = 0.01
kmat = [[0,k_12,0],[k_12,0,0],[0,0,0]]
teqp.canonical_PR(Tc_K, pc_Pa, acentric, kmat)
teqp.canonical_SRK(Tc_K, pc_Pa, acentric, kmat)
```
%% Cell type:markdown id:c3a62795 tags:
## Superancillary
The superancillary equation gives the co-existing liquid and vapor (orthobaric) densities as a function of temperature. The set of Chebyshev expansions was developed in https://pubs.acs.org/doi/abs/10.1021/acs.iecr.1c00847 . These superancillary equations are more accurate than iterative calculations in double precision arithmetic and also at least 10 times faster to calculate, and cannot fail in iterative routines, even extremely close to the critical point.
The superancillary equation is only exposed for pure fluids to remove ambiguity when considering mixtures. The returned tuple is the liquid and vapor densities
%% Cell type:code id:1b02ef72 tags:
``` python
teqp.canonical_PR([Tc_K[0]], [pc_Pa[0]], [acentric[0]]).superanc_rhoLV(100)
```
%% Cell type:markdown id:da00ff20 tags:
## a and b
For the cubic EOS, it can be useful to obtain the a and b parameters directly. The b parameter is particularly useful because 1/b is the maximum allowed density in the EOS
%% Cell type:code id:b5f6aaea tags:
``` python
import numpy as np
z = np.array([0.3, 0.4, 0.3])
modelPR.get_a(140, z), modelPR.get_b(140, z)
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment