-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d487846
commit 5d838b8
Showing
10 changed files
with
2,821 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name = "PCSAFTSuperancillary" | ||
name = "EoSSuperancillaries" | ||
uuid = "c1bf003f-4e47-49d9-bdfd-5a4051db3c04" | ||
authors = ["longemen3000 <longemen3000@gmail.com> and contributors"] | ||
authors = ["Hon Wa Yew <yewhonwa@gmail.com>", "Pierre Walker <[email protected]>", "Andrés Riedemann <[email protected]>"] | ||
version = "1.0.0-DEV" | ||
|
||
[compat] | ||
julia = "1" | ||
julia = "1.6" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,59 @@ | ||
# PCSAFTSuperancillary | ||
|
||
[![Build Status](https://github.com/longemen3000/PCSAFTSuperancillary.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/longemen3000/PCSAFTSuperancillary.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
[![Build Status](https://github.com/ClapeyronThermo/EoSSuperancillaries.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ClapeyronThermo/EoSSuperancillaries.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
|
||
# EoSSuperancillaries | ||
|
||
Superancillary equations to calculate saturation pressures and critical points for selected equations of state. | ||
|
||
This is a Julia port of [usnistgov/SAFTsuperanc](https://github.com/usnistgov/SAFTsuperanc) | ||
|
||
## Introduction | ||
|
||
Saturation calculation always involve iterative calculations. those calculations waste a lot of computing power. superancillaries provide direct equations that return some properties within `Float64` accuracy. | ||
|
||
It can calculate the following properties: | ||
|
||
- PC-SAFT: critical temperature, critical density, saturated densities. | ||
- van der Wals: saturated densities, saturated pressures. | ||
- Redlich-Kwong: saturated densities, saturated pressures. | ||
- Peng-Robinson: saturated densities, saturated pressures. | ||
|
||
## Usage | ||
|
||
You can install `EoSSuperancillaries` by running the following commands on the julia REPL: | ||
|
||
``` | ||
using Pkg | ||
Pkg.add(url="https://github.com/ClapeyronThermo/EoSSuperancillaries.jl") | ||
``` | ||
|
||
``` | ||
using EoSSuperancillaries, Clapeyron | ||
model = PR("water") #model for comparison. | ||
#usage for cubics | ||
a,b,_ = Clapeyron.cubic_ab(model,0.0,373.15) | ||
#direct calculation using superancillaries, takes about 150 ns | ||
p_eq = pr_psat(373.15,a,b) #96099.13581050883 | ||
vl,vv = pr_vlsat(373.15,a,b), pr_vvsat(373.15,a,b) | ||
#iterative calculation, takes about 2 μs | ||
p_eq2,vl2,vv2 = Clapeyron.saturation_pressure(model,373.15)[1] #96099.13581050835 | ||
#usage for PC-SAFT | ||
saft = PCSAFT("propane") | ||
m = saft.params.segment[1] | ||
ϵ = saft.params.epsilon[1] | ||
Tc = pcsaft_tc(m,ϵ) #150 ns | ||
Tc2 = Clapeyron.crit_pure(saft) #around 100 μs | ||
``` | ||
|
||
## Notes | ||
This is not a library to calculate general properties of equations of state. in particular, you would need a PC-SAFT pressure implementation for calculation of saturation pressures and critical pressure. | ||
|
||
While cubics can accept any alpha function for the calculation of `a`, PCSAFT superancillaries are more restricted, in the sense that they are fitted for components without association terms. | ||
|
||
Superancillaries have problems on really low reduced temperatures, but those problems are caused by the artifacts of `Float64` arithmetic. PCSAFT in particular has non-physical behaviour at low reduced temperatures, and at high reduced temperatures in conjuction with a high value of the segment length. | ||
|
||
## References | ||
1. Bell, I. H., & Deiters, U. K. (2021). Superancillary equations for cubic equations of state. Industrial & Engineering Chemistry Research, 60(27), 9983–9991. [doi:10.1021/acs.iecr.1c00847](https://doi.org/10.1021/acs.iecr.1c00847) | ||
2. Bell, I. H., & Deiters, U. K. (2023). Superancillary equations for nonpolar pure fluids modeled with the PC-SAFT equation of state. Industrial & Engineering Chemistry Research. [doi:10.1021/acs.iecr.2c02916](https://doi.org/10.1021/acs.iecr.2c02916) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
function _cubic_vsat(T,a,b,CV) | ||
T̃ = T*R̄*b/a | ||
ρ = chev_eval(CV,T̃) | ||
return b/ρ | ||
end | ||
|
||
function _cubic_vsat2(T,a,b,CV,VL) | ||
T̃ = T*R̄*b/a | ||
ρl = chev_eval(CL,T̃) | ||
ρv = chev_eval(CV,T̃) | ||
return b/ρl,b/ρv | ||
end | ||
|
||
function _cubic_psat(T,a,b,CP) | ||
T̃ = T*R̄*b/a | ||
p̃ = chev_eval(CP,T̃) | ||
return p̃*a/(b*b) | ||
end | ||
|
||
""" | ||
vl = vdw_vlsat(T,a,b) | ||
Returns the saturation liquid volume of the vdW cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vl` : Saturation Liquid Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function vdw_vlsat(T,a,b) | ||
return _cubic_vsat(T,a,b,vdW_vl) | ||
end | ||
|
||
""" | ||
vv = vdw_vvsat(T,a,b) | ||
Returns the saturation vapour volume of the vdW cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vv` : Saturation Vapour Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function vdw_vvsat(T,a,b) | ||
return _cubic_vsat(T,a,b,vdW_vv) | ||
end | ||
|
||
""" | ||
p = vdw_psat(T,a,b) | ||
Returns the saturation pressure of the vdW cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `p` : Saturation pressure `[Pa]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function vdw_psat(T,a,b) | ||
return _cubic_psat(T,a,b,vdW_p) | ||
end | ||
|
||
|
||
""" | ||
vl = rk_vlsat(T,a,b) | ||
Returns the saturation liquid volume of the Redlich-Kwong cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vl` : Saturation Liquid Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function rk_vlsat(T,a,b) | ||
return _cubic_vsat(T,a,b,RK_vl) | ||
end | ||
|
||
""" | ||
vv = rk_vvsat(T,a,b) | ||
Returns the saturation vapour volume of the Redlich-Kwong cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vv` : Saturation Vapour Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function rk_vvsat(T,a,b) | ||
return _cubic_vsat(T,a,b,RK_vv) | ||
end | ||
|
||
""" | ||
p = rk_psat(T,a,b) | ||
Returns the saturation pressure of the Redlich-Kwong cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `p` : Saturation pressure `[Pa]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function rk_psat(T,a,b) | ||
return _cubic_psat(T,a,b,RK_p) | ||
end | ||
|
||
""" | ||
vl = pr_vlsat(T,a,b) | ||
Returns the saturation liquid volume of the Peng-Robinson cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vl` : Saturation Liquid Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function pr_vlsat(T,a,b) | ||
return _cubic_vsat(T,a,b,PR_vl) | ||
end | ||
|
||
""" | ||
vv = pr_vvsat(T,a,b) | ||
Returns the saturation vapour volume of the Peng-Robinson cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `vv` : Saturation Vapour Volume `[m^3]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function pr_vvsat(T,a,b) | ||
return _cubic_vsat(T,a,b,PR_vv) | ||
end | ||
|
||
""" | ||
p = pr_psat(T,a,b) | ||
Returns the saturation pressure of the Peng-Robinson cubic equation of state. | ||
Inputs: | ||
- `T`: Temperature (Kelvin) | ||
- `a`: Atraction parameter `[m^6*Pa/mol]` | ||
- `b`: Covolume `[m^3/mol]` | ||
Outputs: | ||
- `p` : Saturation pressure `[Pa]`. Returns `NaN` if the value is outside the range of the ancillary. | ||
""" | ||
function pr_psat(T,a,b) | ||
return _cubic_psat(T,a,b,PR_p) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module EoSSuperancillaries | ||
|
||
include("utils.jl") | ||
include("Cubic/consts.jl") | ||
include("Cubic/cubic.jl") | ||
include("PCSAFT/consts.jl") | ||
include("PCSAFT/pcsaft.jl") | ||
|
||
end #module |
Oops, something went wrong.